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

Side by Side Diff: tests/PixelRefTest.cpp

Issue 134843008: Revert of Revert "Revert of https://codereview.chromium.org/129423002/" (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 6 years, 11 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « tests/MallocPixelRefTest.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #include "Test.h" 1 #include "Test.h"
2 #include "TestClassDef.h" 2 #include "TestClassDef.h"
3 3
4 #include "SkPixelRef.h" 4 #include "SkPixelRef.h"
5 #include "SkMallocPixelRef.h" 5 #include "SkMallocPixelRef.h"
6 6
7 static void test_info(skiatest::Reporter* reporter) { 7 static void test_info(skiatest::Reporter* reporter) {
8 static const struct { 8 static const struct {
9 SkBitmap::Config fConfig; 9 SkBitmap::Config fConfig;
10 SkAlphaType fAlphaType; 10 SkAlphaType fAlphaType;
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 public: 44 public:
45 explicit TestListener(int* ptr) : fPtr(ptr) {} 45 explicit TestListener(int* ptr) : fPtr(ptr) {}
46 void onChange() SK_OVERRIDE { (*fPtr)++; } 46 void onChange() SK_OVERRIDE { (*fPtr)++; }
47 private: 47 private:
48 int* fPtr; 48 int* fPtr;
49 }; 49 };
50 50
51 } // namespace 51 } // namespace
52 52
53 DEF_TEST(PixelRef_GenIDChange, r) { 53 DEF_TEST(PixelRef_GenIDChange, r) {
54 SkImageInfo info = SkImageInfo::MakeN32Premul(10, 10); 54 SkImageInfo info = { 10, 10, kPMColor_SkColorType, kPremul_SkAlphaType };
55 55
56 SkAutoTUnref<SkPixelRef> pixelRef(SkMallocPixelRef::NewAllocate(info, 0, NUL L)); 56 SkAutoTUnref<SkPixelRef> pixelRef(SkMallocPixelRef::NewAllocate(info, 0, NUL L));
57 57
58 // Register a listener. 58 // Register a listener.
59 int count = 0; 59 int count = 0;
60 pixelRef->addGenIDChangeListener(SkNEW_ARGS(TestListener, (&count))); 60 pixelRef->addGenIDChangeListener(SkNEW_ARGS(TestListener, (&count)));
61 REPORTER_ASSERT(r, 0 == count); 61 REPORTER_ASSERT(r, 0 == count);
62 62
63 // No one has looked at our pixelRef's generation ID, so invalidating it doe sn't make sense. 63 // No one has looked at our pixelRef's generation ID, so invalidating it doe sn't make sense.
64 // (An SkPixelRef tree falls in the forest but there's nobody around to hear it. Do we care?) 64 // (An SkPixelRef tree falls in the forest but there's nobody around to hear it. Do we care?)
(...skipping 13 matching lines...) Expand all
78 pixelRef->notifyPixelsChanged(); 78 pixelRef->notifyPixelsChanged();
79 REPORTER_ASSERT(r, 1 == count); 79 REPORTER_ASSERT(r, 1 == count);
80 80
81 // Quick check that NULL is safe. 81 // Quick check that NULL is safe.
82 REPORTER_ASSERT(r, 0 != pixelRef->getGenerationID()); 82 REPORTER_ASSERT(r, 0 != pixelRef->getGenerationID());
83 pixelRef->addGenIDChangeListener(NULL); 83 pixelRef->addGenIDChangeListener(NULL);
84 pixelRef->notifyPixelsChanged(); 84 pixelRef->notifyPixelsChanged();
85 85
86 test_info(r); 86 test_info(r);
87 } 87 }
OLDNEW
« no previous file with comments | « tests/MallocPixelRefTest.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698