OLD | NEW |
1 #include "Test.h" | 1 #include "Test.h" |
2 | 2 |
3 #include "SkMallocPixelRef.h" | 3 #include "SkMallocPixelRef.h" |
4 #include "SkPixelRef.h" | 4 #include "SkPixelRef.h" |
5 | 5 |
6 class TestListener : public SkPixelRef::GenIDChangeListener { | 6 class TestListener : public SkPixelRef::GenIDChangeListener { |
7 public: | 7 public: |
8 explicit TestListener(int* ptr) : fPtr(ptr) {} | 8 explicit TestListener(int* ptr) : fPtr(ptr) {} |
9 virtual void onChange() SK_OVERRIDE { (*fPtr)++; } | 9 void onChange() SK_OVERRIDE { (*fPtr)++; } |
10 private: | 10 private: |
11 int* fPtr; | 11 int* fPtr; |
12 }; | 12 }; |
13 | 13 |
14 DEF_TEST(PixelRef_GenIDChange, r) { | 14 DEF_TEST(PixelRef_GenIDChange, r) { |
15 SkImageInfo info = SkImageInfo::MakeN32Premul(10, 10); | 15 SkImageInfo info = SkImageInfo::MakeN32Premul(10, 10); |
16 | 16 |
17 SkAutoTUnref<SkPixelRef> pixelRef(SkMallocPixelRef::NewAllocate(info, 0, NUL
L)); | 17 SkAutoTUnref<SkPixelRef> pixelRef(SkMallocPixelRef::NewAllocate(info, 0, NUL
L)); |
18 | 18 |
19 // Register a listener. | 19 // Register a listener. |
(...skipping 17 matching lines...) Expand all Loading... |
37 REPORTER_ASSERT(r, 0 != pixelRef->getGenerationID()); | 37 REPORTER_ASSERT(r, 0 != pixelRef->getGenerationID()); |
38 pixelRef->addGenIDChangeListener(SkNEW_ARGS(TestListener, (&count))); | 38 pixelRef->addGenIDChangeListener(SkNEW_ARGS(TestListener, (&count))); |
39 pixelRef->notifyPixelsChanged(); | 39 pixelRef->notifyPixelsChanged(); |
40 REPORTER_ASSERT(r, 1 == count); | 40 REPORTER_ASSERT(r, 1 == count); |
41 | 41 |
42 // Quick check that NULL is safe. | 42 // Quick check that NULL is safe. |
43 REPORTER_ASSERT(r, 0 != pixelRef->getGenerationID()); | 43 REPORTER_ASSERT(r, 0 != pixelRef->getGenerationID()); |
44 pixelRef->addGenIDChangeListener(NULL); | 44 pixelRef->addGenIDChangeListener(NULL); |
45 pixelRef->notifyPixelsChanged(); | 45 pixelRef->notifyPixelsChanged(); |
46 } | 46 } |
OLD | NEW |