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

Side by Side Diff: tests/Test.h

Issue 1446453003: Generate list of GPU contexts outside SurfaceTest tests (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: remove ImageTest modifications Created 5 years, 1 month 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
OLDNEW
1 1
2 /* 2 /*
3 * Copyright 2011 Google Inc. 3 * Copyright 2011 Google Inc.
4 * 4 *
5 * Use of this source code is governed by a BSD-style license that can be 5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file. 6 * found in the LICENSE file.
7 */ 7 */
8 #ifndef skiatest_Test_DEFINED 8 #ifndef skiatest_Test_DEFINED
9 #define skiatest_Test_DEFINED 9 #define skiatest_Test_DEFINED
10 10
11 #include "SkString.h" 11 #include "SkString.h"
12 #include "SkTRegistry.h" 12 #include "SkTRegistry.h"
13 #include "SkTypes.h" 13 #include "SkTypes.h"
14 14
15 class GrContextFactory; 15 class GrContextFactory;
16 class GrContext;
16 17
17 namespace skiatest { 18 namespace skiatest {
18 19
19 SkString GetTmpDir(); 20 SkString GetTmpDir();
20 21
21 struct Failure { 22 struct Failure {
22 Failure(const char* f, int l, const char* c, const SkString& m) 23 Failure(const char* f, int l, const char* c, const SkString& m)
23 : fileName(f), lineNo(l), condition(c), message(m) {} 24 : fileName(f), lineNo(l), condition(c), message(m) {}
24 const char* fileName; 25 const char* fileName;
25 int lineNo; 26 int lineNo;
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 ... 63 ...
63 REPORTER_ASSERT_MESSAGE(reporter, x == 15, "x should be 15"); 64 REPORTER_ASSERT_MESSAGE(reporter, x == 15, "x should be 15");
64 ... 65 ...
65 if (x != 15) { 66 if (x != 15) {
66 ERRORF(reporter, "x should be 15, but is %d", x); 67 ERRORF(reporter, "x should be 15, but is %d", x);
67 return; 68 return;
68 } 69 }
69 ... 70 ...
70 } 71 }
71 */ 72 */
73 enum GPUTestContexts {
74 kNone_GPUTestContexts = 0,
75 kNull_GPUTestContexts = 1,
76 kNative_GPUTestContexts = 1 << 1,
77 kOther_GPUTestContexts = 1 << 2, // Other than native, used only for below.
78 kAllRendering_GPUTestContexts = kNative_GPUTestContexts | kOther_GPUTestCont exts,
79 kAll_GPUTestContexts = kAllRendering_GPUTestContexts | kNull_GPUTestContexts
80 };
81 void RunWithGPUTestContexts(void(*test)(skiatest::Reporter*, GrContext*),
82 skiatest::GPUTestContexts,
83 skiatest::Reporter* reporter,
84 GrContextFactory* factory);
72 } // namespace skiatest 85 } // namespace skiatest
73 86
74 #define REPORTER_ASSERT(r, cond) \ 87 #define REPORTER_ASSERT(r, cond) \
75 do { \ 88 do { \
76 if (!(cond)) { \ 89 if (!(cond)) { \
77 REPORT_FAILURE(r, #cond, SkString()); \ 90 REPORT_FAILURE(r, #cond, SkString()); \
78 } \ 91 } \
79 } while (0) 92 } while (0)
80 93
81 #define REPORTER_ASSERT_MESSAGE(r, cond, message) \ 94 #define REPORTER_ASSERT_MESSAGE(r, cond, message) \
(...skipping 13 matching lines...) Expand all
95 skiatest::TestRegistry name##TestRegistry( \ 108 skiatest::TestRegistry name##TestRegistry( \
96 skiatest::Test(#name, false, test_##name)); \ 109 skiatest::Test(#name, false, test_##name)); \
97 void test_##name(skiatest::Reporter* reporter, GrContextFactory*) 110 void test_##name(skiatest::Reporter* reporter, GrContextFactory*)
98 111
99 #define DEF_GPUTEST(name, reporter, factory) \ 112 #define DEF_GPUTEST(name, reporter, factory) \
100 static void test_##name(skiatest::Reporter*, GrContextFactory*); \ 113 static void test_##name(skiatest::Reporter*, GrContextFactory*); \
101 skiatest::TestRegistry name##TestRegistry( \ 114 skiatest::TestRegistry name##TestRegistry( \
102 skiatest::Test(#name, true, test_##name)); \ 115 skiatest::Test(#name, true, test_##name)); \
103 void test_##name(skiatest::Reporter* reporter, GrContextFactory* factory) 116 void test_##name(skiatest::Reporter* reporter, GrContextFactory* factory)
104 117
118 #define DEF_GPUTEST_FOR_CONTEXTS(name, contexts, reporter, context) \
119 static void test_##name(skiatest::Reporter*, GrContext*); \
120 static void test_gpu_contexts_##name(skiatest::Reporter* reporter, \
121 GrContextFactory* factory) { \
122 skiatest::RunWithGPUTestContexts(test_##name, contexts, reporter, factor y); \
123 } \
124 skiatest::TestRegistry name##TestRegistry( \
125 skiatest::Test(#name, true, test_gpu_contexts_##name)); \
126 void test_##name(skiatest::Reporter* reporter, GrContext* context)
127
128 #define DEF_GPUTEST_FOR_ALL_CONTEXTS(name, reporter, context) \
129 DEF_GPUTEST_FOR_CONTEXTS(name, skiatest::kAll_GPUTestContexts, reporter, context)
130 #define DEF_GPUTEST_FOR_RENDERING_CONTEXTS(name, reporter, context) \
131 DEF_GPUTEST_FOR_CONTEXTS(name, skiatest::kAllRendering_GPUTestContexts, reporter, context)
132 #define DEF_GPUTEST_FOR_NULL_CONTEXT(name, reporter, context) \
133 DEF_GPUTEST_FOR_CONTEXTS(name, skiatest::kNull_GPUTestContexts, reporter , context)
134 #define DEF_GPUTEST_FOR_NATIVE_CONTEXT(name, reporter, context) \
135 DEF_GPUTEST_FOR_CONTEXTS(name, skiatest::kNative_GPUTestContexts, report er, context)
136
105 #define REQUIRE_PDF_DOCUMENT(TEST_NAME, REPORTER) \ 137 #define REQUIRE_PDF_DOCUMENT(TEST_NAME, REPORTER) \
106 do { \ 138 do { \
107 SkDynamicMemoryWStream testStream; \ 139 SkDynamicMemoryWStream testStream; \
108 SkAutoTUnref<SkDocument> testDoc(SkDocument::CreatePDF(&testStream)); \ 140 SkAutoTUnref<SkDocument> testDoc(SkDocument::CreatePDF(&testStream)); \
109 if (!testDoc) { \ 141 if (!testDoc) { \
110 if ((REPORTER) && (REPORTER)->verbose()) { \ 142 if ((REPORTER) && (REPORTER)->verbose()) { \
111 SkDebugf("PDF disabled; %s test skipped.", #TEST_NAME); \ 143 SkDebugf("PDF disabled; %s test skipped.", #TEST_NAME); \
112 } \ 144 } \
113 return; \ 145 return; \
114 } \ 146 } \
115 } while (false) 147 } while (false)
116 148
117 #endif 149 #endif
OLDNEW
« tests/SurfaceTest.cpp ('K') | « tests/SurfaceTest.cpp ('k') | tests/Test.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698