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

Side by Side Diff: tests/TestConfigParsing.cpp

Issue 2378163003: Use brackets for explicit GPU config params in tools (Closed)
Patch Set: Created 4 years, 2 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 | « no previous file | tools/flags/SkCommonFlagsConfig.cpp » ('j') | 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 2015 Google Inc. 2 * Copyright 2015 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 "SkCommonFlagsConfig.h" 8 #include "SkCommonFlagsConfig.h"
9 #include "SkColorSpace.h" 9 #include "SkColorSpace.h"
10 #include "Test.h" 10 #include "Test.h"
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after
199 REPORTER_ASSERT(reporter, configs[31]->asConfigGpu()); 199 REPORTER_ASSERT(reporter, configs[31]->asConfigGpu());
200 REPORTER_ASSERT(reporter, configs[31]->asConfigGpu()->getSamples() == 4); 200 REPORTER_ASSERT(reporter, configs[31]->asConfigGpu()->getSamples() == 4);
201 #ifdef SK_VULKAN 201 #ifdef SK_VULKAN
202 REPORTER_ASSERT(reporter, configs[32]->asConfigGpu()); 202 REPORTER_ASSERT(reporter, configs[32]->asConfigGpu());
203 #endif 203 #endif
204 #endif 204 #endif
205 } 205 }
206 206
207 DEF_TEST(ParseConfigs_ExtendedGpuConfigsCorrect, reporter) { 207 DEF_TEST(ParseConfigs_ExtendedGpuConfigsCorrect, reporter) {
208 SkCommandLineFlags::StringArray config1 = make_string_array({ 208 SkCommandLineFlags::StringArray config1 = make_string_array({
209 "gpu(nvpr=true,dit=false)", 209 "gpu[nvpr=true,dit=false]",
210 "gpu(api=angle)", 210 "gpu[api=angle]",
211 "gpu(api=angle-gl)", 211 "gpu[api=angle-gl]",
212 "gpu(api=mesa,samples=77)", 212 "gpu[api=mesa,samples=77]",
213 "gpu(dit=true,api=commandbuffer)", 213 "gpu[dit=true,api=commandbuffer]",
214 "gpu()", 214 "gpu[]",
215 "gpu(api=gles)", 215 "gpu[api=gles]",
216 "gpu(api=gl)", 216 "gpu[api=gl]",
217 "gpu(api=vulkan)", 217 "gpu[api=vulkan]",
218 }); 218 });
219 219
220 SkCommandLineConfigArray configs; 220 SkCommandLineConfigArray configs;
221 ParseConfigs(config1, &configs); 221 ParseConfigs(config1, &configs);
222 REPORTER_ASSERT(reporter, configs.count() == config1.count()); 222 REPORTER_ASSERT(reporter, configs.count() == config1.count());
223 for (int i = 0; i < config1.count(); ++i) { 223 for (int i = 0; i < config1.count(); ++i) {
224 REPORTER_ASSERT(reporter, configs[i]->getTag().equals(config1[i])); 224 REPORTER_ASSERT(reporter, configs[i]->getTag().equals(config1[i]));
225 } 225 }
226 #if SK_SUPPORT_GPU 226 #if SK_SUPPORT_GPU
227 REPORTER_ASSERT(reporter, configs[0]->asConfigGpu()->getContextType() == 227 REPORTER_ASSERT(reporter, configs[0]->asConfigGpu()->getContextType() ==
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
271 GrContextFactory::kVulkan_ContextType); 271 GrContextFactory::kVulkan_ContextType);
272 REPORTER_ASSERT(reporter, !configs[7]->asConfigGpu()->getUseNVPR()); 272 REPORTER_ASSERT(reporter, !configs[7]->asConfigGpu()->getUseNVPR());
273 REPORTER_ASSERT(reporter, !configs[7]->asConfigGpu()->getUseDIText()); 273 REPORTER_ASSERT(reporter, !configs[7]->asConfigGpu()->getUseDIText());
274 REPORTER_ASSERT(reporter, configs[7]->asConfigGpu()->getSamples() == 0); 274 REPORTER_ASSERT(reporter, configs[7]->asConfigGpu()->getSamples() == 0);
275 #endif 275 #endif
276 #endif 276 #endif
277 } 277 }
278 278
279 DEF_TEST(ParseConfigs_ExtendedGpuConfigsIncorrect, reporter) { 279 DEF_TEST(ParseConfigs_ExtendedGpuConfigsIncorrect, reporter) {
280 SkCommandLineFlags::StringArray config1 = make_string_array({ 280 SkCommandLineFlags::StringArray config1 = make_string_array({
281 "gpu(nvpr=1)", // Number as bool. 281 "gpu[nvpr=1]", // Number as bool.
282 "gpu(api=gl,)", // Trailing in comma. 282 "gpu[api=gl,]", // Trailing in comma.
283 "gpu(api=angle-glu)", // Unknown api. 283 "gpu[api=angle-glu]", // Unknown api.
284 "gpu(api=,samples=0)", // Empty api. 284 "gpu[api=,samples=0]", // Empty api.
285 "gpu(samples=true)", // Value true as a number. 285 "gpu[samples=true]", // Value true as a number.
286 "gpu(samples=0,samples=0)", // Duplicate option key. 286 "gpu[samples=0,samples=0]", // Duplicate option key.
287 "gpu(,samples=0)", // Leading comma. 287 "gpu[,samples=0]", // Leading comma.
288 "gpu(samples=54", // Missing closing parenthesis. 288 "gpu[samples=54", // Missing closing parenthesis.
289 ",,", 289 ",,",
290 "gpu(", // Missing parenthesis. 290 "gpu[", // Missing bracket.
291 "samples=54" // No backend. 291 "samples=54" // No backend.
292 "gpu(nvpr=true )", // Space. 292 "gpu[nvpr=true ]", // Space.
293 }); 293 });
294 294
295 SkCommandLineConfigArray configs; 295 SkCommandLineConfigArray configs;
296 ParseConfigs(config1, &configs); 296 ParseConfigs(config1, &configs);
297 REPORTER_ASSERT(reporter, configs.count() == config1.count()); 297 REPORTER_ASSERT(reporter, configs.count() == config1.count());
298 for (int i = 0; i < config1.count(); ++i) { 298 for (int i = 0; i < config1.count(); ++i) {
299 REPORTER_ASSERT(reporter, configs[i]->getTag().equals(config1[i])); 299 REPORTER_ASSERT(reporter, configs[i]->getTag().equals(config1[i]));
300 REPORTER_ASSERT(reporter, configs[i]->getBackend().equals(config1[i])); 300 REPORTER_ASSERT(reporter, configs[i]->getBackend().equals(config1[i]));
301 #if SK_SUPPORT_GPU 301 #if SK_SUPPORT_GPU
302 REPORTER_ASSERT(reporter, !configs[i]->asConfigGpu()); 302 REPORTER_ASSERT(reporter, !configs[i]->asConfigGpu());
303 #endif 303 #endif
304 } 304 }
305 } 305 }
306 306
307 DEF_TEST(ParseConfigs_ExtendedGpuConfigsSurprises, reporter) { 307 DEF_TEST(ParseConfigs_ExtendedGpuConfigsSurprises, reporter) {
308 // These just list explicitly some properties of the system. 308 // These just list explicitly some properties of the system.
309 SkCommandLineFlags::StringArray config1 = make_string_array({ 309 SkCommandLineFlags::StringArray config1 = make_string_array({
310 // Options are not canonized -> two same configs have a different tag. 310 // Options are not canonized -> two same configs have a different tag.
311 "gpu(nvpr=true,dit=true)", "gpu(dit=true,nvpr=true)", 311 "gpu[nvpr=true,dit=true]", "gpu[dit=true,nvpr=true]",
312 "gpu(api=debug)", "gpu(api=gl)", "gpu(api=gles)", "" 312 "gpu[api=debug]", "gpu[api=gl]", "gpu[api=gles]", ""
313 "gpu", "gpu()", "gpu(samples=0)", "gpu(api=gles,samples=0)" 313 "gpu", "gpu[]", "gpu[samples=0]", "gpu[api=gles,samples=0]"
314 }); 314 });
315 SkCommandLineConfigArray configs; 315 SkCommandLineConfigArray configs;
316 ParseConfigs(config1, &configs); 316 ParseConfigs(config1, &configs);
317 REPORTER_ASSERT(reporter, configs.count() == config1.count()); 317 REPORTER_ASSERT(reporter, configs.count() == config1.count());
318 for (int i = 0; i < config1.count(); ++i) { 318 for (int i = 0; i < config1.count(); ++i) {
319 REPORTER_ASSERT(reporter, configs[i]->getTag().equals(config1[i])); 319 REPORTER_ASSERT(reporter, configs[i]->getTag().equals(config1[i]));
320 #if SK_SUPPORT_GPU 320 #if SK_SUPPORT_GPU
321 REPORTER_ASSERT(reporter, configs[i]->getBackend().equals("gpu")); 321 REPORTER_ASSERT(reporter, configs[i]->getBackend().equals("gpu"));
322 REPORTER_ASSERT(reporter, configs[i]->asConfigGpu()); 322 REPORTER_ASSERT(reporter, configs[i]->asConfigGpu());
323 #else 323 #else
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
356 break; 356 break;
357 } 357 }
358 REPORTER_ASSERT(reporter, 358 REPORTER_ASSERT(reporter,
359 configs[i]->getViaParts()[j].equals(expectedConfigs[ i].vias[j])); 359 configs[i]->getViaParts()[j].equals(expectedConfigs[ i].vias[j]));
360 } 360 }
361 } 361 }
362 } 362 }
363 363
364 DEF_TEST(ParseConfigs_ViaParsingExtendedForm, reporter) { 364 DEF_TEST(ParseConfigs_ViaParsingExtendedForm, reporter) {
365 SkCommandLineFlags::StringArray config1 = make_string_array({ 365 SkCommandLineFlags::StringArray config1 = make_string_array({
366 "zz-qq-gpu(api=gles)", 366 "zz-qq-gpu[api=gles]",
367 "a-gpu(samples=1", 367 "a-gpu[samples=1",
368 "abc-def-angle-gl(samples=1)", 368 "abc-def-angle-gl[samples=1]",
369 }); 369 });
370 370
371 SkCommandLineConfigArray configs; 371 SkCommandLineConfigArray configs;
372 ParseConfigs(config1, &configs); 372 ParseConfigs(config1, &configs);
373 const struct { 373 const struct {
374 const char* backend; 374 const char* backend;
375 const char* vias[3]; 375 const char* vias[3];
376 } expectedConfigs[] = { 376 } expectedConfigs[] = {
377 #if SK_SUPPORT_GPU 377 #if SK_SUPPORT_GPU
378 {"gpu", {"zz", "qq", nullptr}}, 378 {"gpu", {"zz", "qq", nullptr}},
379 #else 379 #else
380 {"gpu(api=gles)", {"zz", "qq", nullptr}}, 380 {"gpu[api=gles]", {"zz", "qq", nullptr}},
381 #endif 381 #endif
382 {"gpu(samples=1", {"a", nullptr, nullptr}}, // This is not extended form , but via still 382 {"gpu[samples=1", {"a", nullptr, nullptr}}, // This is not extended form , but via still
383 // works as expected. 383 // works as expected.
384 {"gl(samples=1)", {"abc", "def", "angle"}} // This is not extended form . Also 384 {"gl[samples=1]", {"abc", "def", "angle"}} // This is not extended form . Also
385 // angle-gl is not a "backen d" in this case. 385 // angle-gl is not a "backen d" in this case.
386 }; 386 };
387 for (int i = 0; i < config1.count(); ++i) { 387 for (int i = 0; i < config1.count(); ++i) {
388 REPORTER_ASSERT(reporter, configs[i]->getTag().equals(config1[i])); 388 REPORTER_ASSERT(reporter, configs[i]->getTag().equals(config1[i]));
389 REPORTER_ASSERT(reporter, configs[i]->getBackend().equals(expectedConfig s[i].backend)); 389 REPORTER_ASSERT(reporter, configs[i]->getBackend().equals(expectedConfig s[i].backend));
390 for (int j = 0; j < static_cast<int>(SK_ARRAY_COUNT(expectedConfigs[i].v ias)); ++j) { 390 for (int j = 0; j < static_cast<int>(SK_ARRAY_COUNT(expectedConfigs[i].v ias)); ++j) {
391 if (!expectedConfigs[i].vias[j]) { 391 if (!expectedConfigs[i].vias[j]) {
392 REPORTER_ASSERT(reporter, configs[i]->getViaParts().count() == 392 REPORTER_ASSERT(reporter, configs[i]->getViaParts().count() ==
393 static_cast<int>(j)); 393 static_cast<int>(j));
394 break; 394 break;
395 } 395 }
396 REPORTER_ASSERT(reporter, 396 REPORTER_ASSERT(reporter,
397 configs[i]->getViaParts()[j].equals(expectedConfigs[ i].vias[j])); 397 configs[i]->getViaParts()[j].equals(expectedConfigs[ i].vias[j]));
398 } 398 }
399 } 399 }
400 #if SK_SUPPORT_GPU 400 #if SK_SUPPORT_GPU
401 REPORTER_ASSERT(reporter, configs[0]->asConfigGpu()); 401 REPORTER_ASSERT(reporter, configs[0]->asConfigGpu());
402 REPORTER_ASSERT(reporter, !configs[1]->asConfigGpu()); 402 REPORTER_ASSERT(reporter, !configs[1]->asConfigGpu());
403 REPORTER_ASSERT(reporter, !configs[2]->asConfigGpu()); 403 REPORTER_ASSERT(reporter, !configs[2]->asConfigGpu());
404 #endif 404 #endif
405 } 405 }
OLDNEW
« no previous file with comments | « no previous file | tools/flags/SkCommonFlagsConfig.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698