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

Unified Diff: tests/PictureTest.cpp

Issue 478673002: Expose API for whether an SkPicture contains text (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Add a test Created 6 years, 4 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 | « src/core/SkPictureData.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/PictureTest.cpp
diff --git a/tests/PictureTest.cpp b/tests/PictureTest.cpp
index b3f13f03a6ee00da479394449cd5b21aaa1fb240..b7e4bb6ccaebeadfdae4f0927c84858e87bbf6a6 100644
--- a/tests/PictureTest.cpp
+++ b/tests/PictureTest.cpp
@@ -919,6 +919,63 @@ static void test_gpu_picture_optimization(skiatest::Reporter* reporter,
#endif
+static void test_has_text(skiatest::Reporter* reporter) {
+ SkPictureRecorder recorder;
+ SkPaint paint;
+ paint.setColor(SK_ColorBLUE);
+ SkPoint point = SkPoint::Make(10, 10);
+
+ SkCanvas* canvas = recorder.beginRecording(100, 100);
+ {
+ canvas->drawRect(SkRect::MakeWH(20, 20), paint);
+ }
+ SkAutoTUnref<SkPicture> picture(recorder.endRecording());
+ REPORTER_ASSERT(reporter, !picture->hasText());
+
+ canvas = recorder.beginRecording(100, 100);
+ {
+ canvas->drawText("Q", 1, point.fX, point.fY, paint);
+ }
+ picture.reset(recorder.endRecording());
+ REPORTER_ASSERT(reporter, picture->hasText());
+
+ canvas = recorder.beginRecording(100, 100);
+ {
+ canvas->drawPosText("Q", 1, &point, paint);
+ }
+ picture.reset(recorder.endRecording());
+ REPORTER_ASSERT(reporter, picture->hasText());
+
+ canvas = recorder.beginRecording(100, 100);
+ {
+ canvas->drawPosTextH("Q", 1, &point.fX, point.fY, paint);
+ }
+ picture.reset(recorder.endRecording());
+ REPORTER_ASSERT(reporter, picture->hasText());
+
+ canvas = recorder.beginRecording(100, 100);
+ {
+ SkPath path;
+ path.moveTo(0, 0);
+ path.lineTo(50, 50);
+
+ canvas->drawTextOnPathHV("Q", 1, path, point.fX, point.fY, paint);
+ }
+ picture.reset(recorder.endRecording());
+ REPORTER_ASSERT(reporter, picture->hasText());
+
+ canvas = recorder.beginRecording(100, 100);
+ {
+ SkPath path;
+ path.moveTo(0, 0);
+ path.lineTo(50, 50);
+
+ canvas->drawTextOnPath("Q", 1, path, NULL, paint);
+ }
+ picture.reset(recorder.endRecording());
+ REPORTER_ASSERT(reporter, picture->hasText());
+}
+
static void set_canvas_to_save_count_4(SkCanvas* canvas) {
canvas->restoreToCount(1);
canvas->save();
@@ -1561,6 +1618,7 @@ DEF_TEST(Picture, reporter) {
#if SK_SUPPORT_GPU
test_gpu_veto(reporter);
#endif
+ test_has_text(reporter);
test_gatherpixelrefs(reporter);
test_gatherpixelrefsandrects(reporter);
test_bitmap_with_encoded_data(reporter);
« no previous file with comments | « src/core/SkPictureData.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698