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

Unified Diff: tests/ImageGeneratorTest.cpp

Issue 1223413002: remove getter for imagegenerator factory, update test (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: document that SkData will never be null Created 5 years, 5 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/core/SkImageGenerator.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/ImageGeneratorTest.cpp
diff --git a/tests/ImageGeneratorTest.cpp b/tests/ImageGeneratorTest.cpp
index c856d8be604d020dc54243693fb86443692a5777..a7151b93fbfe0f51ba247187f7ca8c8e94d1a5ee 100644
--- a/tests/ImageGeneratorTest.cpp
+++ b/tests/ImageGeneratorTest.cpp
@@ -10,31 +10,32 @@
#include "SkImageGenerator.h"
#include "Test.h"
-static SkImageGenerator* my_factory(SkData* data) {
- int* ptr = *(int**)data->data();
- *ptr = 1; // signal that we were called
+static bool gMyFactoryWasCalled;
+
+static SkImageGenerator* my_factory(SkData*) {
+ gMyFactoryWasCalled = true;
return NULL;
}
static void test_imagegenerator_factory(skiatest::Reporter* reporter) {
- int factoryHasBeenCalled = 0;
- int* sentinelPtr = &factoryHasBeenCalled;
- SkData* data = SkData::NewWithCopy(&sentinelPtr, sizeof(sentinelPtr));
+ // just need a non-empty data to test things
+ SkData* data = SkData::NewWithCString("test_imagegenerator_factory");
+
+ gMyFactoryWasCalled = false;
SkImageGenerator* gen;
- REPORTER_ASSERT(reporter, 0 == *sentinelPtr);
+ REPORTER_ASSERT(reporter, !gMyFactoryWasCalled);
gen = SkImageGenerator::NewFromEncoded(data);
REPORTER_ASSERT(reporter, NULL == gen);
- REPORTER_ASSERT(reporter, 0 == *sentinelPtr);
+ REPORTER_ASSERT(reporter, !gMyFactoryWasCalled);
// Test is racy, in that it hopes no other thread is changing this global...
SkGraphics::ImageGeneratorFromEncodedFactory prev =
- SkGraphics::GetImageGeneratorFromEncodedFactory();
- SkGraphics::SetImageGeneratorFromEncodedFactory(my_factory);
+ SkGraphics::SetImageGeneratorFromEncodedFactory(my_factory);
gen = SkImageGenerator::NewFromEncoded(data);
REPORTER_ASSERT(reporter, NULL == gen);
- REPORTER_ASSERT(reporter, 1 == *sentinelPtr);
+ REPORTER_ASSERT(reporter, gMyFactoryWasCalled);
SkGraphics::SetImageGeneratorFromEncodedFactory(prev);
}
« no previous file with comments | « src/core/SkImageGenerator.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698