Commit 36bb47ae authored by Caleb Raitto's avatar Caleb Raitto Committed by Commit Bot

Fix all ShapeResultTest memory leaks.

Bug: 960984
Change-Id: Ie4ba78bfcc60baab5ee29d1d766e66926a580e66
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1618161Reviewed-by: default avatarEmil A Eklund <eae@chromium.org>
Commit-Queue: Caleb Raitto <caraitto@chromium.org>
Cr-Commit-Position: refs/heads/master@{#661149}
parent 7d21fefc
......@@ -4,6 +4,7 @@
#include "third_party/blink/renderer/platform/fonts/shaping/shape_result.h"
#include "base/containers/span.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/blink/renderer/platform/fonts/font.h"
#include "third_party/blink/renderer/platform/fonts/font_cache.h"
......@@ -34,6 +35,14 @@ class ShapeResultTest : public testing::Test {
void TestCopyRangesLatin(const ShapeResult*) const;
void TestCopyRangesArabic(const ShapeResult*) const;
// Release the ShapeResults held inside an array of ShapeResult::ShapeRange
// instances.
static void ReleaseShapeRange(base::span<ShapeResult::ShapeRange> ranges) {
for (auto& range : ranges) {
range.target->Release();
}
}
ShapeResult* CreateShapeResult(TextDirection direction) const {
return new ShapeResult(
direction == TextDirection::kLtr ? &font : &arabic_font, 0, direction);
......@@ -79,6 +88,7 @@ void ShapeResultTest::TestCopyRangesLatin(const ShapeResult* result) const {
EXPECT_TRUE(CompareResultGlyphs(glyphs[1], reference_glyphs[1], 0u, 10u));
EXPECT_TRUE(CompareResultGlyphs(glyphs[2], reference_glyphs[2], 0u, 10u));
EXPECT_TRUE(CompareResultGlyphs(glyphs[3], reference_glyphs[3], 0u, 8u));
ReleaseShapeRange(ranges);
}
void ShapeResultTest::TestCopyRangesArabic(const ShapeResult* result) const {
......@@ -115,6 +125,7 @@ void ShapeResultTest::TestCopyRangesArabic(const ShapeResult* result) const {
EXPECT_TRUE(CompareResultGlyphs(glyphs[1], reference_glyphs[1], 0u, 3u));
EXPECT_TRUE(CompareResultGlyphs(glyphs[2], reference_glyphs[2], 0u, 3u));
EXPECT_TRUE(CompareResultGlyphs(glyphs[3], reference_glyphs[3], 0u, 5u));
ReleaseShapeRange(ranges);
}
TEST_F(ShapeResultTest, CopyRangeLatin) {
......@@ -189,6 +200,7 @@ TEST_F(ShapeResultTest, CopyRangeLatinMultiRunWithHoles) {
EXPECT_TRUE(CompareResultGlyphs(glyphs[0], reference_glyphs[0], 0u, 13u));
EXPECT_TRUE(CompareResultGlyphs(glyphs[1], reference_glyphs[1], 0u, 3u));
EXPECT_TRUE(CompareResultGlyphs(glyphs[2], reference_glyphs[2], 0u, 6u));
ReleaseShapeRange(ranges);
}
TEST_F(ShapeResultTest, CopyRangeArabic) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment