| OLD | NEW | 
|    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 "Test.h" |    9 #include "Test.h" | 
|   10 #include <initializer_list> |   10 #include <initializer_list> | 
| (...skipping 23 matching lines...) Expand all  Loading... | 
|   34     SkCommandLineFlags::StringArray config1 = make_string_array({"gpu"}); |   34     SkCommandLineFlags::StringArray config1 = make_string_array({"gpu"}); | 
|   35     SkCommandLineConfigArray configs; |   35     SkCommandLineConfigArray configs; | 
|   36     ParseConfigs(config1, &configs); |   36     ParseConfigs(config1, &configs); | 
|   37  |   37  | 
|   38     REPORTER_ASSERT(reporter, configs.count() == 1); |   38     REPORTER_ASSERT(reporter, configs.count() == 1); | 
|   39     REPORTER_ASSERT(reporter, configs[0]->getTag().equals("gpu")); |   39     REPORTER_ASSERT(reporter, configs[0]->getTag().equals("gpu")); | 
|   40     REPORTER_ASSERT(reporter, configs[0]->getViaParts().count() == 0); |   40     REPORTER_ASSERT(reporter, configs[0]->getViaParts().count() == 0); | 
|   41 #if SK_SUPPORT_GPU |   41 #if SK_SUPPORT_GPU | 
|   42     REPORTER_ASSERT(reporter, configs[0]->asConfigGpu()); |   42     REPORTER_ASSERT(reporter, configs[0]->asConfigGpu()); | 
|   43     REPORTER_ASSERT(reporter, configs[0]->asConfigGpu()->getContextType() |   43     REPORTER_ASSERT(reporter, configs[0]->asConfigGpu()->getContextType() | 
|   44                     == GrContextFactory::kNative_GLContextType); |   44                     == GrContextFactory::kNativeGL_ContextType); | 
|   45     REPORTER_ASSERT(reporter, configs[0]->asConfigGpu()->getUseNVPR() == false); |   45     REPORTER_ASSERT(reporter, configs[0]->asConfigGpu()->getUseNVPR() == false); | 
|   46     REPORTER_ASSERT(reporter, configs[0]->asConfigGpu()->getUseDIText() == false
     ); |   46     REPORTER_ASSERT(reporter, configs[0]->asConfigGpu()->getUseDIText() == false
     ); | 
|   47     REPORTER_ASSERT(reporter, configs[0]->asConfigGpu()->getSamples() == 0); |   47     REPORTER_ASSERT(reporter, configs[0]->asConfigGpu()->getSamples() == 0); | 
|   48     REPORTER_ASSERT(reporter, configs[0]->asConfigGpu()->getColorType() == kN32_
     SkColorType); |   48     REPORTER_ASSERT(reporter, configs[0]->asConfigGpu()->getColorType() == kN32_
     SkColorType); | 
|   49     REPORTER_ASSERT(reporter, configs[0]->asConfigGpu()->getProfileType() |   49     REPORTER_ASSERT(reporter, configs[0]->asConfigGpu()->getProfileType() | 
|   50                     == kLinear_SkColorProfileType); |   50                     == kLinear_SkColorProfileType); | 
|   51 #endif |   51 #endif | 
|   52 } |   52 } | 
|   53  |   53  | 
|   54 DEF_TEST(ParseConfigs_OutParam, reporter) { |   54 DEF_TEST(ParseConfigs_OutParam, reporter) { | 
| (...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  177     }); |  177     }); | 
|  178  |  178  | 
|  179     SkCommandLineConfigArray configs; |  179     SkCommandLineConfigArray configs; | 
|  180     ParseConfigs(config1, &configs); |  180     ParseConfigs(config1, &configs); | 
|  181     REPORTER_ASSERT(reporter, configs.count() == config1.count()); |  181     REPORTER_ASSERT(reporter, configs.count() == config1.count()); | 
|  182     for (int i = 0; i < config1.count(); ++i) { |  182     for (int i = 0; i < config1.count(); ++i) { | 
|  183         REPORTER_ASSERT(reporter, configs[i]->getTag().equals(config1[i])); |  183         REPORTER_ASSERT(reporter, configs[i]->getTag().equals(config1[i])); | 
|  184     } |  184     } | 
|  185 #if SK_SUPPORT_GPU |  185 #if SK_SUPPORT_GPU | 
|  186     REPORTER_ASSERT(reporter, configs[0]->asConfigGpu()->getContextType() == |  186     REPORTER_ASSERT(reporter, configs[0]->asConfigGpu()->getContextType() == | 
|  187                     GrContextFactory::kNative_GLContextType); |  187                     GrContextFactory::kNativeGL_ContextType); | 
|  188     REPORTER_ASSERT(reporter, configs[0]->asConfigGpu()->getUseNVPR()); |  188     REPORTER_ASSERT(reporter, configs[0]->asConfigGpu()->getUseNVPR()); | 
|  189     REPORTER_ASSERT(reporter, !configs[0]->asConfigGpu()->getUseDIText()); |  189     REPORTER_ASSERT(reporter, !configs[0]->asConfigGpu()->getUseDIText()); | 
|  190     REPORTER_ASSERT(reporter, configs[0]->asConfigGpu()->getSamples() == 0); |  190     REPORTER_ASSERT(reporter, configs[0]->asConfigGpu()->getSamples() == 0); | 
|  191 #if SK_ANGLE |  191 #if SK_ANGLE | 
|  192 #ifdef SK_BUILD_FOR_WIN |  192 #ifdef SK_BUILD_FOR_WIN | 
|  193     REPORTER_ASSERT(reporter, configs[1]->asConfigGpu()->getContextType() == |  193     REPORTER_ASSERT(reporter, configs[1]->asConfigGpu()->getContextType() == | 
|  194                     GrContextFactory::kANGLE_GLContextType); |  194                     GrContextFactory::kANGLE_ContextType); | 
|  195 #else |  195 #else | 
|  196     REPORTER_ASSERT(reporter, !configs[1]->asConfigGpu()); |  196     REPORTER_ASSERT(reporter, !configs[1]->asConfigGpu()); | 
|  197 #endif |  197 #endif | 
|  198     REPORTER_ASSERT(reporter, configs[2]->asConfigGpu()->getContextType() == |  198     REPORTER_ASSERT(reporter, configs[2]->asConfigGpu()->getContextType() == | 
|  199                     GrContextFactory::kANGLE_GL_GLContextType); |  199                     GrContextFactory::kANGLE_GL_ContextType); | 
|  200 #else |  200 #else | 
|  201     REPORTER_ASSERT(reporter, !configs[1]->asConfigGpu()); |  201     REPORTER_ASSERT(reporter, !configs[1]->asConfigGpu()); | 
|  202     REPORTER_ASSERT(reporter, !configs[2]->asConfigGpu()); |  202     REPORTER_ASSERT(reporter, !configs[2]->asConfigGpu()); | 
|  203 #endif |  203 #endif | 
|  204 #if SK_MESA |  204 #if SK_MESA | 
|  205     REPORTER_ASSERT(reporter, configs[3]->asConfigGpu()->getContextType() == |  205     REPORTER_ASSERT(reporter, configs[3]->asConfigGpu()->getContextType() == | 
|  206                     GrContextFactory::kMESA_GLContextType); |  206                     GrContextFactory::kMESA_ContextType); | 
|  207 #else |  207 #else | 
|  208     REPORTER_ASSERT(reporter, !configs[3]->asConfigGpu()); |  208     REPORTER_ASSERT(reporter, !configs[3]->asConfigGpu()); | 
|  209 #endif |  209 #endif | 
|  210 #if SK_COMMAND_BUFFER |  210 #if SK_COMMAND_BUFFER | 
|  211     REPORTER_ASSERT(reporter, configs[4]->asConfigGpu()->getContextType() == |  211     REPORTER_ASSERT(reporter, configs[4]->asConfigGpu()->getContextType() == | 
|  212                     GrContextFactory::kCommandBuffer_GLContextType); |  212                     GrContextFactory::kCommandBuffer_ContextType); | 
|  213  |  213  | 
|  214 #else |  214 #else | 
|  215     REPORTER_ASSERT(reporter, !configs[4]->asConfigGpu()); |  215     REPORTER_ASSERT(reporter, !configs[4]->asConfigGpu()); | 
|  216 #endif |  216 #endif | 
|  217     REPORTER_ASSERT(reporter, configs[5]->asConfigGpu()->getContextType() == |  217     REPORTER_ASSERT(reporter, configs[5]->asConfigGpu()->getContextType() == | 
|  218                     GrContextFactory::kNative_GLContextType); |  218                     GrContextFactory::kNativeGL_ContextType); | 
|  219     REPORTER_ASSERT(reporter, !configs[5]->asConfigGpu()->getUseNVPR()); |  219     REPORTER_ASSERT(reporter, !configs[5]->asConfigGpu()->getUseNVPR()); | 
|  220     REPORTER_ASSERT(reporter, !configs[5]->asConfigGpu()->getUseDIText()); |  220     REPORTER_ASSERT(reporter, !configs[5]->asConfigGpu()->getUseDIText()); | 
|  221     REPORTER_ASSERT(reporter, configs[5]->asConfigGpu()->getSamples() == 0); |  221     REPORTER_ASSERT(reporter, configs[5]->asConfigGpu()->getSamples() == 0); | 
|  222     REPORTER_ASSERT(reporter, configs[6]->asConfigGpu()->getContextType() == |  222     REPORTER_ASSERT(reporter, configs[6]->asConfigGpu()->getContextType() == | 
|  223                     GrContextFactory::kGLES_GLContextType); |  223                     GrContextFactory::kGLES_ContextType); | 
|  224     REPORTER_ASSERT(reporter, !configs[6]->asConfigGpu()->getUseNVPR()); |  224     REPORTER_ASSERT(reporter, !configs[6]->asConfigGpu()->getUseNVPR()); | 
|  225     REPORTER_ASSERT(reporter, !configs[6]->asConfigGpu()->getUseDIText()); |  225     REPORTER_ASSERT(reporter, !configs[6]->asConfigGpu()->getUseDIText()); | 
|  226     REPORTER_ASSERT(reporter, configs[6]->asConfigGpu()->getSamples() == 0); |  226     REPORTER_ASSERT(reporter, configs[6]->asConfigGpu()->getSamples() == 0); | 
|  227     REPORTER_ASSERT(reporter, configs[7]->asConfigGpu()->getContextType() == |  227     REPORTER_ASSERT(reporter, configs[7]->asConfigGpu()->getContextType() == | 
|  228                               GrContextFactory::kGL_GLContextType); |  228                               GrContextFactory::kGL_ContextType); | 
|  229     REPORTER_ASSERT(reporter, !configs[7]->asConfigGpu()->getUseNVPR()); |  229     REPORTER_ASSERT(reporter, !configs[7]->asConfigGpu()->getUseNVPR()); | 
|  230     REPORTER_ASSERT(reporter, !configs[7]->asConfigGpu()->getUseDIText()); |  230     REPORTER_ASSERT(reporter, !configs[7]->asConfigGpu()->getUseDIText()); | 
|  231     REPORTER_ASSERT(reporter, configs[7]->asConfigGpu()->getSamples() == 0); |  231     REPORTER_ASSERT(reporter, configs[7]->asConfigGpu()->getSamples() == 0); | 
|  232 #endif |  232 #endif | 
|  233 } |  233 } | 
|  234  |  234  | 
|  235 DEF_TEST(ParseConfigs_ExtendedGpuConfigsIncorrect, reporter) { |  235 DEF_TEST(ParseConfigs_ExtendedGpuConfigsIncorrect, reporter) { | 
|  236     SkCommandLineFlags::StringArray config1 = make_string_array({ |  236     SkCommandLineFlags::StringArray config1 = make_string_array({ | 
|  237         "gpu(nvpr=1)", // Number as bool. |  237         "gpu(nvpr=1)", // Number as bool. | 
|  238         "gpu(api=gl,)", // Trailing in comma. |  238         "gpu(api=gl,)", // Trailing in comma. | 
| (...skipping 14 matching lines...) Expand all  Loading... | 
|  253     REPORTER_ASSERT(reporter, configs.count() == config1.count()); |  253     REPORTER_ASSERT(reporter, configs.count() == config1.count()); | 
|  254     for (int i = 0; i < config1.count(); ++i) { |  254     for (int i = 0; i < config1.count(); ++i) { | 
|  255         REPORTER_ASSERT(reporter, configs[i]->getTag().equals(config1[i])); |  255         REPORTER_ASSERT(reporter, configs[i]->getTag().equals(config1[i])); | 
|  256         REPORTER_ASSERT(reporter, configs[i]->getBackend().equals(config1[i])); |  256         REPORTER_ASSERT(reporter, configs[i]->getBackend().equals(config1[i])); | 
|  257 #if SK_SUPPORT_GPU |  257 #if SK_SUPPORT_GPU | 
|  258         REPORTER_ASSERT(reporter, !configs[i]->asConfigGpu()); |  258         REPORTER_ASSERT(reporter, !configs[i]->asConfigGpu()); | 
|  259 #endif |  259 #endif | 
|  260     } |  260     } | 
|  261 } |  261 } | 
|  262  |  262  | 
|  263  |  | 
|  264 DEF_TEST(ParseConfigs_ExtendedGpuConfigsSurprises, reporter) { |  263 DEF_TEST(ParseConfigs_ExtendedGpuConfigsSurprises, reporter) { | 
|  265     // These just list explicitly some properties of the system. |  264     // These just list explicitly some properties of the system. | 
|  266     SkCommandLineFlags::StringArray config1 = make_string_array({ |  265     SkCommandLineFlags::StringArray config1 = make_string_array({ | 
|  267         // Options are not canonized -> two same configs have a different tag. |  266         // Options are not canonized -> two same configs have a different tag. | 
|  268         "gpu(nvpr=true,dit=true)", "gpu(dit=true,nvpr=true)", |  267         "gpu(nvpr=true,dit=true)", "gpu(dit=true,nvpr=true)", | 
|  269         // API native is alias for gl or gles, but it's not canonized -> differe
     nt tag. |  268         "gpu(api=debug)", "gpu(api=gl)", "gpu(api=gles)", "" | 
|  270         "gpu(api=native)", "gpu(api=gl)", "gpu(api=gles)", "" |  269         "gpu", "gpu()", "gpu(samples=0)", "gpu(api=gles,samples=0)" | 
|  271         // Default values are not canonized -> different tag. |  | 
|  272         "gpu", "gpu()", "gpu(samples=0)", "gpu(api=native,samples=0)" |  | 
|  273     }); |  270     }); | 
|  274     SkCommandLineConfigArray configs; |  271     SkCommandLineConfigArray configs; | 
|  275     ParseConfigs(config1, &configs); |  272     ParseConfigs(config1, &configs); | 
|  276     REPORTER_ASSERT(reporter, configs.count() == config1.count()); |  273     REPORTER_ASSERT(reporter, configs.count() == config1.count()); | 
|  277     for (int i = 0; i < config1.count(); ++i) { |  274     for (int i = 0; i < config1.count(); ++i) { | 
|  278         REPORTER_ASSERT(reporter, configs[i]->getTag().equals(config1[i])); |  275         REPORTER_ASSERT(reporter, configs[i]->getTag().equals(config1[i])); | 
|  279 #if SK_SUPPORT_GPU |  276 #if SK_SUPPORT_GPU | 
|  280         REPORTER_ASSERT(reporter, configs[i]->getBackend().equals("gpu")); |  277         REPORTER_ASSERT(reporter, configs[i]->getBackend().equals("gpu")); | 
|  281         REPORTER_ASSERT(reporter, configs[i]->asConfigGpu()); |  278         REPORTER_ASSERT(reporter, configs[i]->asConfigGpu()); | 
|  282 #else |  279 #else | 
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  351             REPORTER_ASSERT(reporter, |  348             REPORTER_ASSERT(reporter, | 
|  352                             configs[i]->getViaParts()[j].equals(expectedConfigs[
     i].vias[j])); |  349                             configs[i]->getViaParts()[j].equals(expectedConfigs[
     i].vias[j])); | 
|  353         } |  350         } | 
|  354     } |  351     } | 
|  355 #if SK_SUPPORT_GPU |  352 #if SK_SUPPORT_GPU | 
|  356     REPORTER_ASSERT(reporter, configs[0]->asConfigGpu()); |  353     REPORTER_ASSERT(reporter, configs[0]->asConfigGpu()); | 
|  357     REPORTER_ASSERT(reporter, !configs[1]->asConfigGpu()); |  354     REPORTER_ASSERT(reporter, !configs[1]->asConfigGpu()); | 
|  358     REPORTER_ASSERT(reporter, !configs[2]->asConfigGpu()); |  355     REPORTER_ASSERT(reporter, !configs[2]->asConfigGpu()); | 
|  359 #endif |  356 #endif | 
|  360 } |  357 } | 
| OLD | NEW |