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

Side by Side Diff: tests/skia_test.cpp

Issue 12521016: Add --resourcePath flag to the test program. (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 7 years, 9 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
« no previous file with comments | « tests/Test.h ('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 /* 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 #include "SkGraphics.h" 8 #include "SkGraphics.h"
9 #include "Test.h" 9 #include "Test.h"
10 #include "SkOSFile.h" 10 #include "SkOSFile.h"
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 } else if (SkPATH_SEPARATOR != path[len - 1]) { 92 } else if (SkPATH_SEPARATOR != path[len - 1]) {
93 // resize to len + 1, to make room for searator 93 // resize to len + 1, to make room for searator
94 storage->set(path, len + 1); 94 storage->set(path, len + 1);
95 storage->writable_str()[len] = SkPATH_SEPARATOR; 95 storage->writable_str()[len] = SkPATH_SEPARATOR;
96 path = storage->c_str(); 96 path = storage->c_str();
97 } 97 }
98 } 98 }
99 return path; 99 return path;
100 } 100 }
101 101
102 static const char* gTmpDir; 102 static SkString gTmpDir;
103 103
104 const char* Test::GetTmpDir() { 104 const SkString& Test::GetTmpDir() {
105 return gTmpDir; 105 return gTmpDir;
106 } 106 }
107 107
108 static SkString gResourcePath;
109
110 const SkString& Test::GetResourcePath() {
111 return gResourcePath;
112 }
113
108 int tool_main(int argc, char** argv); 114 int tool_main(int argc, char** argv);
109 int tool_main(int argc, char** argv) { 115 int tool_main(int argc, char** argv) {
110 #if SK_ENABLE_INST_COUNT 116 #if SK_ENABLE_INST_COUNT
111 gPrintInstCount = true; 117 gPrintInstCount = true;
112 #endif 118 #endif
113 SkGraphics::Init(); 119 SkGraphics::Init();
114 120
115 const char* matchStr = NULL; 121 const char* matchStr = NULL;
116 122
117 char* const* stop = argv + argc; 123 char* const* stop = argv + argc;
118 for (++argv; argv < stop; ++argv) { 124 for (++argv; argv < stop; ++argv) {
119 if (strcmp(*argv, "--match") == 0) { 125 if (strcmp(*argv, "--match") == 0) {
120 ++argv; 126 ++argv;
121 if (argv < stop && **argv) { 127 if (argv < stop && **argv) {
122 matchStr = *argv; 128 matchStr = *argv;
123 } else { 129 } else {
124 SkDebugf("no following argument to --match\n"); 130 SkDebugf("no following argument to --match\n");
125 return -1; 131 return -1;
126 } 132 }
127 } else if (0 == strcmp(*argv, "--tmpDir")) { 133 } else if (0 == strcmp(*argv, "--tmpDir")) {
128 ++argv; 134 ++argv;
129 if (argv < stop && **argv) { 135 if (argv < stop && **argv) {
130 gTmpDir = *argv; 136 make_canonical_dir_path(*argv, &gTmpDir);
131 } else { 137 } else {
132 SkDebugf("no following argument to --tmpDir\n"); 138 SkDebugf("no following argument to --tmpDir\n");
133 return -1; 139 return -1;
134 } 140 }
141 } else if ((0 == strcmp(*argv, "--resourcePath")) ||
142 (0 == strcmp(*argv, "-i"))) {
143 argv++;
144 if (argv < stop && **argv) {
145 make_canonical_dir_path(*argv, &gResourcePath);
146 }
135 } 147 }
136 } 148 }
137 149
138 SkString tmpDirStorage;
139 gTmpDir = make_canonical_dir_path(gTmpDir, &tmpDirStorage);
140
141 { 150 {
142 SkString header("Skia UnitTests:"); 151 SkString header("Skia UnitTests:");
143 if (matchStr) { 152 if (matchStr) {
144 header.appendf(" --match %s", matchStr); 153 header.appendf(" --match %s", matchStr);
145 } 154 }
146 if (gTmpDir) { 155 if (!gTmpDir.isEmpty()) {
147 header.appendf(" --tmpDir %s", gTmpDir); 156 header.appendf(" --tmpDir %s", gTmpDir.c_str());
157 }
158 if (!gResourcePath.isEmpty()) {
159 header.appendf(" --resourcePath %s", gResourcePath.c_str());
148 } 160 }
149 #ifdef SK_DEBUG 161 #ifdef SK_DEBUG
150 header.append(" SK_DEBUG"); 162 header.append(" SK_DEBUG");
151 #else 163 #else
152 header.append(" SK_RELEASE"); 164 header.append(" SK_RELEASE");
153 #endif 165 #endif
154 #ifdef SK_SCALAR_IS_FIXED 166 #ifdef SK_SCALAR_IS_FIXED
155 header.append(" SK_SCALAR_IS_FIXED"); 167 header.append(" SK_SCALAR_IS_FIXED");
156 #else 168 #else
157 header.append(" SK_SCALAR_IS_FLOAT"); 169 header.append(" SK_SCALAR_IS_FLOAT");
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
197 GpuTest::DestroyContexts(); 209 GpuTest::DestroyContexts();
198 210
199 return (failCount == 0) ? 0 : 1; 211 return (failCount == 0) ? 0 : 1;
200 } 212 }
201 213
202 #if !defined(SK_BUILD_FOR_IOS) && !defined(SK_BUILD_FOR_NACL) 214 #if !defined(SK_BUILD_FOR_IOS) && !defined(SK_BUILD_FOR_NACL)
203 int main(int argc, char * const argv[]) { 215 int main(int argc, char * const argv[]) {
204 return tool_main(argc, (char**) argv); 216 return tool_main(argc, (char**) argv);
205 } 217 }
206 #endif 218 #endif
OLDNEW
« no previous file with comments | « tests/Test.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698