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

Side by Side Diff: tests/PixelRefTest.cpp

Issue 111323005: Remvoe duplicate impl for SkImageInfo flattening (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 7 years 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/PictureTest.cpp ('k') | tests/SerializationTest.cpp » ('j') | 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 SkMallocPixelRef pixelRef(NULL, 0, NULL); // We don't really care about the pixels here. 54 SkImageInfo info = { 10, 10, kPMColor_SkColorType, kPremul_SkAlphaType };
55
56 SkAutoTUnref<SkPixelRef> pixelRef(SkMallocPixelRef::NewAllocate(info, 0, NUL L));
55 57
56 // Register a listener. 58 // Register a listener.
57 int count = 0; 59 int count = 0;
58 pixelRef.addGenIDChangeListener(SkNEW_ARGS(TestListener, (&count))); 60 pixelRef->addGenIDChangeListener(SkNEW_ARGS(TestListener, (&count)));
59 REPORTER_ASSERT(r, 0 == count); 61 REPORTER_ASSERT(r, 0 == count);
60 62
61 // 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.
62 // (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?)
63 pixelRef.notifyPixelsChanged(); 65 pixelRef->notifyPixelsChanged();
64 REPORTER_ASSERT(r, 0 == count); 66 REPORTER_ASSERT(r, 0 == count);
65 67
66 // Force the generation ID to be calculated. 68 // Force the generation ID to be calculated.
67 REPORTER_ASSERT(r, 0 != pixelRef.getGenerationID()); 69 REPORTER_ASSERT(r, 0 != pixelRef->getGenerationID());
68 70
69 // Our listener was dropped in the first call to notifyPixelsChanged(). Thi s is a no-op. 71 // Our listener was dropped in the first call to notifyPixelsChanged(). Thi s is a no-op.
70 pixelRef.notifyPixelsChanged(); 72 pixelRef->notifyPixelsChanged();
71 REPORTER_ASSERT(r, 0 == count); 73 REPORTER_ASSERT(r, 0 == count);
72 74
73 // Force the generation ID to be recalculated, then add a listener. 75 // Force the generation ID to be recalculated, then add a listener.
74 REPORTER_ASSERT(r, 0 != pixelRef.getGenerationID()); 76 REPORTER_ASSERT(r, 0 != pixelRef->getGenerationID());
75 pixelRef.addGenIDChangeListener(SkNEW_ARGS(TestListener, (&count))); 77 pixelRef->addGenIDChangeListener(SkNEW_ARGS(TestListener, (&count)));
76 pixelRef.notifyPixelsChanged(); 78 pixelRef->notifyPixelsChanged();
77 REPORTER_ASSERT(r, 1 == count); 79 REPORTER_ASSERT(r, 1 == count);
78 80
79 // Quick check that NULL is safe. 81 // Quick check that NULL is safe.
80 REPORTER_ASSERT(r, 0 != pixelRef.getGenerationID()); 82 REPORTER_ASSERT(r, 0 != pixelRef->getGenerationID());
81 pixelRef.addGenIDChangeListener(NULL); 83 pixelRef->addGenIDChangeListener(NULL);
82 pixelRef.notifyPixelsChanged(); 84 pixelRef->notifyPixelsChanged();
83 85
84 test_info(r); 86 test_info(r);
85 } 87 }
OLDNEW
« no previous file with comments | « tests/PictureTest.cpp ('k') | tests/SerializationTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698