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

Side by Side Diff: tests/ErrorTest.cpp

Issue 13699004: first draft of error checking / reporting API (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 7 years, 8 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 unified diff | Download patch | Annotate | Revision Log
« src/core/SkPath.cpp ('K') | « src/core/SkPath.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(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)
OLDNEW
« src/core/SkPath.cpp ('K') | « src/core/SkPath.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698