Chromium Code Reviews| Index: tests/ErrorTest.cpp |
| diff --git a/tests/ErrorTest.cpp b/tests/ErrorTest.cpp |
| index 761f8bf66f7ffc20951f343d15f9f7343dc24d1e..5b928085071c026748bbab020736b9b3cb5e10ce 100644 |
| --- a/tests/ErrorTest.cpp |
| +++ b/tests/ErrorTest.cpp |
| @@ -10,21 +10,32 @@ |
| #include "SkPath.h" |
| #include "SkRect.h" |
| +typedef struct { |
|
tfarina
2013/09/11 19:39:25
typedef should not be necessary here as we compile
tfarina
2013/09/11 19:39:25
I think this can be simply:
struct ErrorContext {
|
| + skiatest::Reporter *fReporter; |
| + unsigned int *fIntPointer; |
| +} ErrorContext; |
|
tfarina
2013/09/11 19:39:25
this is creating a variable as far as I can see. D
mtklein
2013/09/11 20:51:19
Oh how I love C++ syntax!
typedef struct { ... }
|
| + |
| #define CHECK(errcode) \ |
| REPORTER_ASSERT( reporter, (err = SkGetLastError()) == errcode); \ |
| if (err != kNoError_SkError) \ |
| { \ |
| - SkDebugf("Last error string: %s\n", SkGetLastErrorString()); \ |
| SkClearLastError(); \ |
| } |
| static void cb(SkError err, void *context) { |
| - int *context_ptr = static_cast<int *>(context); |
| - SkDebugf("CB (0x%x): %s\n", *context_ptr, SkGetLastErrorString()); |
| + ErrorContext *context_ptr = static_cast<ErrorContext *>(context); |
| + REPORTER_ASSERT( context_ptr->fReporter, (*(context_ptr->fIntPointer) == 0xdeadbeef) ); |
| } |
| static void ErrorTest(skiatest::Reporter* reporter) { |
| SkError err; |
| + |
| + unsigned int test_value = 0xdeadbeef; |
| + ErrorContext context; |
| + context.fReporter = reporter; |
| + context.fIntPointer = &test_value; |
| + |
| + SkSetErrorCallback(cb, &context); |
| CHECK(kNoError_SkError); |
| @@ -43,19 +54,10 @@ static void ErrorTest(skiatest::Reporter* reporter) { |
| CHECK(kInvalidArgument_SkError); |
| CHECK(kNoError_SkError); |
| - int test_value = 0xdeadbeef; |
| - SkSetErrorCallback(cb, &test_value); |
| - |
| // should trigger *our* callback. |
| path.addRoundRect(r, -10, -10); |
| CHECK(kInvalidArgument_SkError); |
| CHECK(kNoError_SkError); |
| - |
| - // Should trigger the default one again. |
| - SkSetErrorCallback(NULL, NULL); |
| - path.addRoundRect(r, -10, -10); |
| - CHECK(kInvalidArgument_SkError); |
| - CHECK(kNoError_SkError); |
| } |
| #include "TestClassDef.h" |