| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2013 Google Inc. | 2 * Copyright 2013 Google Inc. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
| 5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
| 6 */ | 6 */ |
| 7 | 7 |
| 8 #include "SkError.h" | 8 #include "SkError.h" |
| 9 #include "SkPath.h" | 9 #include "SkPath.h" |
| 10 #include "SkRect.h" | 10 #include "SkRect.h" |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 { \ | 21 { \ |
| 22 SkClearLastError(); \ | 22 SkClearLastError(); \ |
| 23 } | 23 } |
| 24 | 24 |
| 25 static void cb(SkError err, void *context) { | 25 static void cb(SkError err, void *context) { |
| 26 ErrorContext *context_ptr = static_cast<ErrorContext *>(context); | 26 ErrorContext *context_ptr = static_cast<ErrorContext *>(context); |
| 27 REPORTER_ASSERT( context_ptr->fReporter, (*(context_ptr->fIntPointer) == 0xd
eadbeef) ); | 27 REPORTER_ASSERT( context_ptr->fReporter, (*(context_ptr->fIntPointer) == 0xd
eadbeef) ); |
| 28 } | 28 } |
| 29 | 29 |
| 30 DEF_TEST(Error, reporter) { | 30 DEF_TEST(Error, reporter) { |
| 31 // Some previous user of this thread may have left an error laying around. |
| 32 SkClearLastError(); |
| 33 |
| 31 SkError err; | 34 SkError err; |
| 32 | 35 |
| 33 unsigned int test_value = 0xdeadbeef; | 36 unsigned int test_value = 0xdeadbeef; |
| 34 ErrorContext context; | 37 ErrorContext context; |
| 35 context.fReporter = reporter; | 38 context.fReporter = reporter; |
| 36 context.fIntPointer = &test_value; | 39 context.fIntPointer = &test_value; |
| 37 | 40 |
| 38 SkSetErrorCallback(cb, &context); | 41 SkSetErrorCallback(cb, &context); |
| 39 | 42 |
| 40 CHECK(kNoError_SkError); | 43 CHECK(kNoError_SkError); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 52 // should trigger the default error callback, which just prints to the scree
n. | 55 // should trigger the default error callback, which just prints to the scree
n. |
| 53 path.addRoundRect(r, -10, -10); | 56 path.addRoundRect(r, -10, -10); |
| 54 CHECK(kInvalidArgument_SkError); | 57 CHECK(kInvalidArgument_SkError); |
| 55 CHECK(kNoError_SkError); | 58 CHECK(kNoError_SkError); |
| 56 | 59 |
| 57 // should trigger *our* callback. | 60 // should trigger *our* callback. |
| 58 path.addRoundRect(r, -10, -10); | 61 path.addRoundRect(r, -10, -10); |
| 59 CHECK(kInvalidArgument_SkError); | 62 CHECK(kInvalidArgument_SkError); |
| 60 CHECK(kNoError_SkError); | 63 CHECK(kNoError_SkError); |
| 61 } | 64 } |
| OLD | NEW |