2 * Copyright 2013 Google Inc.
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
14 skiatest::Reporter *fReporter;
15 unsigned int *fIntPointer;
18 #define CHECK(errcode) \
19 REPORTER_ASSERT( reporter, (err = SkGetLastError()) == errcode); \
20 if (err != kNoError_SkError) \
25 static void cb(SkError err, void *context) {
26 ErrorContext *context_ptr = static_cast<ErrorContext *>(context);
27 REPORTER_ASSERT( context_ptr->fReporter, (*(context_ptr->fIntPointer) == 0xdeadbeef) );
30 DEF_TEST(Error, reporter) {
33 unsigned int test_value = 0xdeadbeef;
35 context.fReporter = reporter;
36 context.fIntPointer = &test_value;
38 SkSetErrorCallback(cb, &context);
40 CHECK(kNoError_SkError);
42 SkRect r = SkRect::MakeWH(50, 100);
43 CHECK(kNoError_SkError);
47 CHECK(kNoError_SkError);
49 path.addRoundRect(r, 10, 10);
50 CHECK(kNoError_SkError);
52 // should trigger the default error callback, which just prints to the screen.
53 path.addRoundRect(r, -10, -10);
54 CHECK(kInvalidArgument_SkError);
55 CHECK(kNoError_SkError);
57 // should trigger *our* callback.
58 path.addRoundRect(r, -10, -10);
59 CHECK(kInvalidArgument_SkError);
60 CHECK(kNoError_SkError);