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

Side by Side Diff: tests/XfermodeTest.cpp

Issue 166583002: Factory methods for heap-allocated SkPathEffect and SkXfermode objects. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Update experimental/PdfViewer Created 6 years, 10 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
« no previous file with comments | « tests/DrawPathTest.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
1 /* 1 /*
2 * Copyright 2011 Google Inc. 2 * Copyright 2011 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 "SkColor.h" 8 #include "SkColor.h"
9 #include "SkXfermode.h" 9 #include "SkXfermode.h"
10 #include "Test.h" 10 #include "Test.h"
(...skipping 19 matching lines...) Expand all
30 if (xfer) { 30 if (xfer) {
31 reportedMode = (SkXfermode::Mode) -1; 31 reportedMode = (SkXfermode::Mode) -1;
32 REPORTER_ASSERT(reporter, xfer->asMode(&reportedMode)); 32 REPORTER_ASSERT(reporter, xfer->asMode(&reportedMode));
33 REPORTER_ASSERT(reporter, reportedMode == mode); 33 REPORTER_ASSERT(reporter, reportedMode == mode);
34 xfer->unref(); 34 xfer->unref();
35 } else { 35 } else {
36 REPORTER_ASSERT(reporter, SkXfermode::kSrcOver_Mode == mode); 36 REPORTER_ASSERT(reporter, SkXfermode::kSrcOver_Mode == mode);
37 } 37 }
38 } 38 }
39 39
40 SkXfermode* bogusXfer = new SkProcXfermode(bogusXfermodeProc); 40 SkXfermode* bogusXfer = SkProcXfermode::Create(bogusXfermodeProc);
41 SkXfermode::Mode reportedMode = ILLEGAL_MODE; 41 SkXfermode::Mode reportedMode = ILLEGAL_MODE;
42 REPORTER_ASSERT(reporter, !bogusXfer->asMode(&reportedMode)); 42 REPORTER_ASSERT(reporter, !bogusXfer->asMode(&reportedMode));
43 REPORTER_ASSERT(reporter, reportedMode == ILLEGAL_MODE); 43 REPORTER_ASSERT(reporter, reportedMode == ILLEGAL_MODE);
44 REPORTER_ASSERT(reporter, !SkXfermode::AsMode(bogusXfer, &reportedMode)); 44 REPORTER_ASSERT(reporter, !SkXfermode::AsMode(bogusXfer, &reportedMode));
45 REPORTER_ASSERT(reporter, reportedMode == ILLEGAL_MODE); 45 REPORTER_ASSERT(reporter, reportedMode == ILLEGAL_MODE);
46 bogusXfer->unref(); 46 bogusXfer->unref();
47 } 47 }
48 48
49 static void test_IsMode(skiatest::Reporter* reporter) { 49 static void test_IsMode(skiatest::Reporter* reporter) {
50 REPORTER_ASSERT(reporter, SkXfermode::IsMode(NULL, 50 REPORTER_ASSERT(reporter, SkXfermode::IsMode(NULL,
51 SkXfermode::kSrcOver_Mode)); 51 SkXfermode::kSrcOver_Mode));
52 52
53 for (int i = 0; i <= SkXfermode::kLastMode; ++i) { 53 for (int i = 0; i <= SkXfermode::kLastMode; ++i) {
54 SkXfermode::Mode mode = (SkXfermode::Mode)i; 54 SkXfermode::Mode mode = (SkXfermode::Mode)i;
55 55
56 SkXfermode* xfer = SkXfermode::Create(mode); 56 SkXfermode* xfer = SkXfermode::Create(mode);
57 REPORTER_ASSERT(reporter, SkXfermode::IsMode(xfer, mode)); 57 REPORTER_ASSERT(reporter, SkXfermode::IsMode(xfer, mode));
58 SkSafeUnref(xfer); 58 SkSafeUnref(xfer);
59 59
60 if (SkXfermode::kSrcOver_Mode != mode) { 60 if (SkXfermode::kSrcOver_Mode != mode) {
61 REPORTER_ASSERT(reporter, !SkXfermode::IsMode(NULL, mode)); 61 REPORTER_ASSERT(reporter, !SkXfermode::IsMode(NULL, mode));
62 } 62 }
63 } 63 }
64 } 64 }
65 65
66 DEF_TEST(Xfermode, reporter) { 66 DEF_TEST(Xfermode, reporter) {
67 test_asMode(reporter); 67 test_asMode(reporter);
68 test_IsMode(reporter); 68 test_IsMode(reporter);
69 } 69 }
OLDNEW
« no previous file with comments | « tests/DrawPathTest.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698