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

Unified Diff: tests/PipeTest.cpp

Issue 2335973003: change write-image to use pipeverbs like everyone else, and add test (Closed)
Patch Set: switch to [define_image] write_image Created 4 years, 3 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/pipe/SkPipeReader.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/PipeTest.cpp
diff --git a/tests/PipeTest.cpp b/tests/PipeTest.cpp
index f345debb8ca46ba012350137059f516fd5219163..7f42071a7564cf6548b2aeec286f83f50c8f60be 100644
--- a/tests/PipeTest.cpp
+++ b/tests/PipeTest.cpp
@@ -49,7 +49,7 @@ static bool deep_equal(SkImage* a, SkImage* b) {
return true;
}
-DEF_TEST(Pipe_image, reporter) {
+DEF_TEST(Pipe_image_draw_first, reporter) {
sk_sp<SkImage> img = GetResourceAsImage("mandrill_128.png");
SkASSERT(img.get());
@@ -86,3 +86,30 @@ DEF_TEST(Pipe_image, reporter) {
auto img2 = drain_as_image(&deserializer, &stream);
REPORTER_ASSERT(reporter, img1.get() == img2.get());
}
+
+DEF_TEST(Pipe_image_draw_second, reporter) {
+ sk_sp<SkImage> img = GetResourceAsImage("mandrill_128.png");
+ SkASSERT(img.get());
+
+ SkPipeSerializer serializer;
+ SkPipeDeserializer deserializer;
+ SkDynamicMemoryWStream stream;
+
+ serializer.write(img.get(), &stream);
+ size_t offset0 = stream.bytesWritten();
+ REPORTER_ASSERT(reporter, offset0 > 100); // the raw image must be sorta big
+ drain_as_image(&deserializer, &stream);
+
+ // The 2nd image should be nice and small
+ serializer.write(img.get(), &stream);
+ size_t offset1 = stream.bytesWritten();
+ REPORTER_ASSERT(reporter, offset1 <= 32);
+ drain_as_image(&deserializer, &stream);
+
+ // Now try drawing the image, it should also be small
+ SkCanvas* wc = serializer.beginWrite(SkRect::MakeWH(100, 100), &stream);
+ wc->drawImage(img, 0, 0, nullptr);
+ serializer.endWrite();
+ size_t offset2 = stream.bytesWritten();
+ REPORTER_ASSERT(reporter, offset2 <= 32);
+}
« no previous file with comments | « src/pipe/SkPipeReader.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698