Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(667)

Unified Diff: tests/TextBlobTest.cpp

Issue 1404153002: Fix TextBlobTest valgrind error (Closed) Base URL: https://chromium.googlesource.com/skia.git@master
Patch Set: Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/TextBlobTest.cpp
diff --git a/tests/TextBlobTest.cpp b/tests/TextBlobTest.cpp
index 2a74e5a2dbbd8b24076215f367b5df9faef6a98b..027fd2ac76c7aa514dda22c1043ba7d8413b92c1 100644
--- a/tests/TextBlobTest.cpp
+++ b/tests/TextBlobTest.cpp
@@ -11,7 +11,6 @@
#include "Test.h"
-
class TextBlobTester {
public:
// This unit test feeds an SkTextBlobBuilder various runs then checks to see if
@@ -155,13 +154,19 @@ public:
// don't trigger asserts (http://crbug.com/542643).
SkPaint p;
p.setTextSize(0);
- p.setTextEncoding(SkPaint::kGlyphID_TextEncoding);
+ p.setTextEncoding(SkPaint::kUTF8_TextEncoding);
const char* txt = "BOOO";
- const size_t len = strlen(txt);
- const SkTextBlobBuilder::RunBuffer& buffer = builder.allocRunPos(p, (int)len);
- p.textToGlyphs(txt, len, buffer.glyphs);
- memset(buffer.pos, 0, sizeof(SkScalar) * len * 2);
+ const size_t txtLen = strlen(txt);
+ const int glyphCount = p.textToGlyphs(txt, txtLen, nullptr);
+
+ p.setTextEncoding(SkPaint::kGlyphID_TextEncoding);
+ const SkTextBlobBuilder::RunBuffer& buffer = builder.allocRunPos(p, glyphCount);
+
+ p.setTextEncoding(SkPaint::kUTF8_TextEncoding);
+ p.textToGlyphs(txt, txtLen, buffer.glyphs);
+
+ memset(buffer.pos, 0, sizeof(SkScalar) * glyphCount * 2);
SkAutoTUnref<const SkTextBlob> blob(builder.build());
REPORTER_ASSERT(reporter, blob->bounds().isEmpty());
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698