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

Side by Side Diff: tests/PixelRefTest.cpp

Issue 132403008: Remove unnamed namespace usage from tests/ (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
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 20 matching lines...) Expand all
31 REPORTER_ASSERT(reporter, success); 31 REPORTER_ASSERT(reporter, success);
32 success = bitmap.asImageInfo(&info); 32 success = bitmap.asImageInfo(&info);
33 REPORTER_ASSERT(reporter, success == gRec[i].fExpectedSuccess); 33 REPORTER_ASSERT(reporter, success == gRec[i].fExpectedSuccess);
34 if (gRec[i].fExpectedSuccess) { 34 if (gRec[i].fExpectedSuccess) {
35 REPORTER_ASSERT(reporter, info.fAlphaType == gRec[i].fAlphaType); 35 REPORTER_ASSERT(reporter, info.fAlphaType == gRec[i].fAlphaType);
36 REPORTER_ASSERT(reporter, info.fColorType == gRec[i].fExpectedColorT ype); 36 REPORTER_ASSERT(reporter, info.fColorType == gRec[i].fExpectedColorT ype);
37 } 37 }
38 } 38 }
39 } 39 }
40 40
41 namespace {
42
43 class TestListener : public SkPixelRef::GenIDChangeListener { 41 class TestListener : public SkPixelRef::GenIDChangeListener {
44 public: 42 public:
45 explicit TestListener(int* ptr) : fPtr(ptr) {} 43 explicit TestListener(int* ptr) : fPtr(ptr) {}
robertphillips 2014/01/14 13:19:37 virtual?
tfarina 2014/01/21 23:37:43 Done.
46 void onChange() SK_OVERRIDE { (*fPtr)++; } 44 void onChange() SK_OVERRIDE { (*fPtr)++; }
47 private: 45 private:
48 int* fPtr; 46 int* fPtr;
49 }; 47 };
50 48
51 } // namespace
52
53 DEF_TEST(PixelRef_GenIDChange, r) { 49 DEF_TEST(PixelRef_GenIDChange, r) {
54 SkImageInfo info = { 10, 10, kPMColor_SkColorType, kPremul_SkAlphaType }; 50 SkImageInfo info = { 10, 10, kPMColor_SkColorType, kPremul_SkAlphaType };
55 51
56 SkAutoTUnref<SkPixelRef> pixelRef(SkMallocPixelRef::NewAllocate(info, 0, NUL L)); 52 SkAutoTUnref<SkPixelRef> pixelRef(SkMallocPixelRef::NewAllocate(info, 0, NUL L));
57 53
58 // Register a listener. 54 // Register a listener.
59 int count = 0; 55 int count = 0;
60 pixelRef->addGenIDChangeListener(SkNEW_ARGS(TestListener, (&count))); 56 pixelRef->addGenIDChangeListener(SkNEW_ARGS(TestListener, (&count)));
61 REPORTER_ASSERT(r, 0 == count); 57 REPORTER_ASSERT(r, 0 == count);
62 58
(...skipping 15 matching lines...) Expand all
78 pixelRef->notifyPixelsChanged(); 74 pixelRef->notifyPixelsChanged();
79 REPORTER_ASSERT(r, 1 == count); 75 REPORTER_ASSERT(r, 1 == count);
80 76
81 // Quick check that NULL is safe. 77 // Quick check that NULL is safe.
82 REPORTER_ASSERT(r, 0 != pixelRef->getGenerationID()); 78 REPORTER_ASSERT(r, 0 != pixelRef->getGenerationID());
83 pixelRef->addGenIDChangeListener(NULL); 79 pixelRef->addGenIDChangeListener(NULL);
84 pixelRef->notifyPixelsChanged(); 80 pixelRef->notifyPixelsChanged();
85 81
86 test_info(r); 82 test_info(r);
87 } 83 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698