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

Unified Diff: tests/DrawTextTest.cpp

Issue 1438893002: Increment text pointer when the width is zero in the subpixel with center and right alignment. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Add test cases for code. Created 5 years, 1 month 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 | « src/core/SkFindAndPlaceGlyph.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/DrawTextTest.cpp
diff --git a/tests/DrawTextTest.cpp b/tests/DrawTextTest.cpp
index 3a96c4ff2d8cb3621c952ccac24ca0a2495e17c2..f2da450fe86b14a47a2fa0d3ac777e0d0819611b 100644
--- a/tests/DrawTextTest.cpp
+++ b/tests/DrawTextTest.cpp
@@ -74,33 +74,38 @@ DEF_TEST(DrawText, reporter) {
create(&drawPosTextBitmap, drawPosTextRect);
SkCanvas drawPosTextCanvas(drawPosTextBitmap);
- for (float offsetY = 0.0f; offsetY < 1.0f; offsetY += (1.0f / 16.0f)) {
- for (float offsetX = 0.0f; offsetX < 1.0f; offsetX += (1.0f / 16.0f)) {
- SkPoint point = SkPoint::Make(25.0f + offsetX,
- 25.0f + offsetY);
-
- for (int align = 0; align < SkPaint::kAlignCount; ++align) {
- paint.setTextAlign(static_cast<SkPaint::Align>(align));
-
- for (unsigned int flags = 0; flags < (1 << 3); ++flags) {
- static const unsigned int antiAliasFlag = 1;
- static const unsigned int subpixelFlag = 1 << 1;
- static const unsigned int lcdFlag = 1 << 2;
-
- paint.setAntiAlias(SkToBool(flags & antiAliasFlag));
- paint.setSubpixelText(SkToBool(flags & subpixelFlag));
- paint.setLCDRenderText(SkToBool(flags & lcdFlag));
-
- // Test: drawText and drawPosText draw the same.
- drawBG(&drawTextCanvas);
- drawTextCanvas.drawText("A", 1, point.fX, point.fY, paint);
-
- drawBG(&drawPosTextCanvas);
- drawPosTextCanvas.drawPosText("A", 1, &point, paint);
-
- REPORTER_ASSERT(reporter,
- compare(drawTextBitmap, drawTextRect,
- drawPosTextBitmap, drawPosTextRect));
+ // Two test cases "A" for the normal path through the code, and " " to check the
+ // early return path.
+ const char* cases[] = {"A", " "};
+ for (auto c : cases) {
+ for (float offsetY = 0.0f; offsetY < 1.0f; offsetY += (1.0f / 16.0f)) {
+ for (float offsetX = 0.0f; offsetX < 1.0f; offsetX += (1.0f / 16.0f)) {
+ SkPoint point = SkPoint::Make(25.0f + offsetX,
+ 25.0f + offsetY);
+
+ for (int align = 0; align < SkPaint::kAlignCount; ++align) {
+ paint.setTextAlign(static_cast<SkPaint::Align>(align));
+
+ for (unsigned int flags = 0; flags < (1 << 3); ++flags) {
+ static const unsigned int antiAliasFlag = 1;
+ static const unsigned int subpixelFlag = 1 << 1;
+ static const unsigned int lcdFlag = 1 << 2;
+
+ paint.setAntiAlias(SkToBool(flags & antiAliasFlag));
+ paint.setSubpixelText(SkToBool(flags & subpixelFlag));
+ paint.setLCDRenderText(SkToBool(flags & lcdFlag));
+
+ // Test: drawText and drawPosText draw the same.
+ drawBG(&drawTextCanvas);
+ drawTextCanvas.drawText(c, 1, point.fX, point.fY, paint);
+
+ drawBG(&drawPosTextCanvas);
+ drawPosTextCanvas.drawPosText(c, 1, &point, paint);
+
+ REPORTER_ASSERT(reporter,
+ compare(drawTextBitmap, drawTextRect,
+ drawPosTextBitmap, drawPosTextRect));
+ }
}
}
}
« no previous file with comments | « src/core/SkFindAndPlaceGlyph.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698