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); |
} |