OLD | NEW |
---|---|
(Empty) | |
1 | |
2 /* | |
3 * Copyright 2013 Google Inc. | |
4 * | |
5 * Use of this source code is governed by a BSD-style license that can be | |
6 * found in the LICENSE file. | |
7 */ | |
8 #include "Test.h" | |
9 #include "SkError.h" | |
10 #include "SkPath.h" | |
11 #include "SkRect.h" | |
12 | |
13 #define CHECK(errcode) REPORTER_ASSERT( reporter, (err = SkGetLastError()) == kE rror_##errcode); \ | |
scroggo
2013/04/08 19:24:53
Minor nit:
I find macros to be more readable if th
humper
2013/04/08 19:43:23
Done.
| |
14 if (err != kError_NoError) \ | |
15 { \ | |
16 SkDebugf("Last error string: %s\n", SkGetLastErrorStr ing());\ | |
17 SkClearLastError(); \ | |
18 }\ | |
19 | |
20 void cb(SkError err, void *context) { | |
21 int *context_ptr = static_cast<int *>(context); | |
22 SkDebugf("CB (0x%x): %s\n", *context_ptr, SkGetLastErrorString()); | |
23 } | |
24 | |
25 static void ErrorTest(skiatest::Reporter* reporter) { | |
26 SkError err; | |
27 | |
28 CHECK(NoError); | |
29 | |
30 SkRect r = SkRect::MakeWH(50, 100); | |
31 CHECK(NoError); | |
32 | |
33 SkPath path; | |
34 path.addRect(r); | |
35 CHECK(NoError); | |
36 | |
37 path.addRoundRect(r, 10, 10); | |
38 CHECK(NoError); | |
39 | |
40 // should trigger the default error callback, which just prints to the scren . | |
41 path.addRoundRect(r, -10, -10); | |
42 CHECK(InvalidArgument); | |
43 CHECK(NoError); | |
44 | |
45 int test_value = 0xdeadbeef; | |
46 SkSetErrorCallback(cb, &test_value); | |
47 | |
48 // should trigger *our* callback. | |
49 path.addRoundRect(r, -10, -10); | |
50 CHECK(InvalidArgument); | |
51 CHECK(NoError); | |
52 | |
53 // Should trigger the default one again. | |
54 SkSetErrorCallback(NULL, NULL); | |
55 path.addRoundRect(r, -10, -10); | |
56 CHECK(InvalidArgument); | |
57 CHECK(NoError); | |
58 } | |
59 | |
60 #include "TestClassDef.h" | |
61 DEFINE_TESTCLASS("Error", ErrorTestClass, ErrorTest) | |
OLD | NEW |