| 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 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 51 #endif | 51 #endif |
| 52 } | 52 } |
| 53 | 53 |
| 54 DEF_TEST(ParseConfigs_OutParam, reporter) { | 54 DEF_TEST(ParseConfigs_OutParam, reporter) { |
| 55 // Clears the out parameter. | 55 // Clears the out parameter. |
| 56 SkCommandLineFlags::StringArray config1 = make_string_array({"gpu"}); | 56 SkCommandLineFlags::StringArray config1 = make_string_array({"gpu"}); |
| 57 SkCommandLineConfigArray configs; | 57 SkCommandLineConfigArray configs; |
| 58 ParseConfigs(config1, &configs); | 58 ParseConfigs(config1, &configs); |
| 59 REPORTER_ASSERT(reporter, configs.count() == 1); | 59 REPORTER_ASSERT(reporter, configs.count() == 1); |
| 60 REPORTER_ASSERT(reporter, configs[0]->getTag().equals("gpu")); | 60 REPORTER_ASSERT(reporter, configs[0]->getTag().equals("gpu")); |
| 61 |
| 61 SkCommandLineFlags::StringArray config2 = make_string_array({"8888"}); | 62 SkCommandLineFlags::StringArray config2 = make_string_array({"8888"}); |
| 62 ParseConfigs(config2, &configs); | 63 ParseConfigs(config2, &configs); |
| 63 REPORTER_ASSERT(reporter, configs.count() == 1); | 64 REPORTER_ASSERT(reporter, configs.count() == 1); |
| 64 REPORTER_ASSERT(reporter, configs[0]->getTag().equals("8888")); | 65 REPORTER_ASSERT(reporter, configs[0]->getTag().equals("8888")); |
| 66 |
| 67 SkCommandLineFlags::StringArray config3 = make_string_array({"gl"}); |
| 68 ParseConfigs(config3, &configs); |
| 69 REPORTER_ASSERT(reporter, configs.count() == 1); |
| 70 REPORTER_ASSERT(reporter, configs[0]->getTag().equals("gl")); |
| 65 } | 71 } |
| 66 | 72 |
| 67 DEF_TEST(ParseConfigs_DefaultConfigs, reporter) { | 73 DEF_TEST(ParseConfigs_DefaultConfigs, reporter) { |
| 68 // Parses all default configs and returns correct "tag". | 74 // Parses all default configs and returns correct "tag". |
| 69 | 75 |
| 70 SkCommandLineFlags::StringArray config1 = make_string_array({ | 76 SkCommandLineFlags::StringArray config1 = make_string_array({ |
| 71 "565", "8888", "debug", "gpu", "gpudebug", "gpudft", "gpunull", "msaa16"
, "msaa4", | 77 "565", "8888", "debug", "gpu", "gpudebug", "gpudft", "gpunull", "msaa16"
, "msaa4", |
| 72 "nonrendering", "null", "nullgpu", "nvpr16", "nvpr4", "nvprdit16", "nvpr
dit4", "pdf", | 78 "nonrendering", "null", "nullgpu", "nvpr16", "nvpr4", "nvprdit16", "nvpr
dit4", "pdf", |
| 73 "skp", "svg", "xps", "angle", "angle-gl", "commandbuffer", "mesa", "hwui
", | 79 "skp", "svg", "xps", "angle", "angle-gl", "commandbuffer", "mesa", "hwui
", |
| 74 "gpuf16", "gpusrgb" | 80 "gpuf16", "gpusrgb", "gl", "glnvpr4", "glnvprdit4", "glsrgb", "glmsaa4" |
| 75 }); | 81 }); |
| 76 | 82 |
| 77 SkCommandLineConfigArray configs; | 83 SkCommandLineConfigArray configs; |
| 78 ParseConfigs(config1, &configs); | 84 ParseConfigs(config1, &configs); |
| 79 | 85 |
| 80 REPORTER_ASSERT(reporter, configs.count() == config1.count()); | 86 REPORTER_ASSERT(reporter, configs.count() == config1.count()); |
| 81 for (int i = 0; i < config1.count(); ++i) { | 87 for (int i = 0; i < config1.count(); ++i) { |
| 82 REPORTER_ASSERT(reporter, configs[i]->getTag().equals(config1[i])); | 88 REPORTER_ASSERT(reporter, configs[i]->getTag().equals(config1[i])); |
| 83 REPORTER_ASSERT(reporter, configs[i]->getViaParts().count() == 0); | 89 REPORTER_ASSERT(reporter, configs[i]->getViaParts().count() == 0); |
| 84 } | 90 } |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 134 #if SK_COMMAND_BUFFER | 140 #if SK_COMMAND_BUFFER |
| 135 REPORTER_ASSERT(reporter, configs[22]->asConfigGpu()); | 141 REPORTER_ASSERT(reporter, configs[22]->asConfigGpu()); |
| 136 #else | 142 #else |
| 137 REPORTER_ASSERT(reporter, !configs[22]->asConfigGpu()); | 143 REPORTER_ASSERT(reporter, !configs[22]->asConfigGpu()); |
| 138 #endif | 144 #endif |
| 139 #if SK_MESA | 145 #if SK_MESA |
| 140 REPORTER_ASSERT(reporter, configs[23]->asConfigGpu()); | 146 REPORTER_ASSERT(reporter, configs[23]->asConfigGpu()); |
| 141 #else | 147 #else |
| 142 REPORTER_ASSERT(reporter, !configs[23]->asConfigGpu()); | 148 REPORTER_ASSERT(reporter, !configs[23]->asConfigGpu()); |
| 143 #endif | 149 #endif |
| 150 REPORTER_ASSERT(reporter, configs[27]->asConfigGpu()); |
| 151 REPORTER_ASSERT(reporter, configs[28]->asConfigGpu()); |
| 152 REPORTER_ASSERT(reporter, configs[28]->asConfigGpu()->getSamples() == 4); |
| 153 REPORTER_ASSERT(reporter, configs[28]->asConfigGpu()->getUseNVPR()); |
| 154 REPORTER_ASSERT(reporter, configs[29]->asConfigGpu()); |
| 155 REPORTER_ASSERT(reporter, configs[29]->asConfigGpu()->getSamples() == 4); |
| 156 REPORTER_ASSERT(reporter, configs[29]->asConfigGpu()->getUseNVPR()); |
| 157 REPORTER_ASSERT(reporter, configs[29]->asConfigGpu()->getUseDIText()); |
| 158 REPORTER_ASSERT(reporter, configs[30]->asConfigGpu()); |
| 159 REPORTER_ASSERT(reporter, configs[30]->asConfigGpu()->getColorType() == kN3
2_SkColorType); |
| 160 REPORTER_ASSERT(reporter, configs[30]->asConfigGpu()->getProfileType() == |
| 161 kSRGB_SkColorProfileType); |
| 162 REPORTER_ASSERT(reporter, configs[31]->asConfigGpu()); |
| 163 REPORTER_ASSERT(reporter, configs[31]->asConfigGpu()->getSamples() == 4); |
| 144 #endif | 164 #endif |
| 145 } | 165 } |
| 146 | 166 |
| 147 DEF_TEST(ParseConfigs_ExtendedGpuConfigsCorrect, reporter) { | 167 DEF_TEST(ParseConfigs_ExtendedGpuConfigsCorrect, reporter) { |
| 148 SkCommandLineFlags::StringArray config1 = make_string_array({ | 168 SkCommandLineFlags::StringArray config1 = make_string_array({ |
| 149 "gpu(nvpr=true,dit=false)", | 169 "gpu(nvpr=true,dit=false)", |
| 150 "gpu(api=angle)", | 170 "gpu(api=angle)", |
| 151 "gpu(api=angle-gl)", | 171 "gpu(api=angle-gl)", |
| 152 "gpu(api=mesa,samples=77)", | 172 "gpu(api=mesa,samples=77)", |
| 153 "gpu(dit=true,api=commandbuffer)", | 173 "gpu(dit=true,api=commandbuffer)", |
| 154 "gpu()", | 174 "gpu()", |
| 155 "gpu(api=gles)" | 175 "gpu(api=gles)", |
| 176 "gpu(api=gl)" |
| 156 }); | 177 }); |
| 157 | 178 |
| 158 SkCommandLineConfigArray configs; | 179 SkCommandLineConfigArray configs; |
| 159 ParseConfigs(config1, &configs); | 180 ParseConfigs(config1, &configs); |
| 160 REPORTER_ASSERT(reporter, configs.count() == config1.count()); | 181 REPORTER_ASSERT(reporter, configs.count() == config1.count()); |
| 161 for (int i = 0; i < config1.count(); ++i) { | 182 for (int i = 0; i < config1.count(); ++i) { |
| 162 REPORTER_ASSERT(reporter, configs[i]->getTag().equals(config1[i])); | 183 REPORTER_ASSERT(reporter, configs[i]->getTag().equals(config1[i])); |
| 163 } | 184 } |
| 164 #if SK_SUPPORT_GPU | 185 #if SK_SUPPORT_GPU |
| 165 REPORTER_ASSERT(reporter, configs[0]->asConfigGpu()->getContextType() == | 186 REPORTER_ASSERT(reporter, configs[0]->asConfigGpu()->getContextType() == |
| (...skipping 30 matching lines...) Expand all Loading... |
| 196 REPORTER_ASSERT(reporter, configs[5]->asConfigGpu()->getContextType() == | 217 REPORTER_ASSERT(reporter, configs[5]->asConfigGpu()->getContextType() == |
| 197 GrContextFactory::kNative_GLContextType); | 218 GrContextFactory::kNative_GLContextType); |
| 198 REPORTER_ASSERT(reporter, !configs[5]->asConfigGpu()->getUseNVPR()); | 219 REPORTER_ASSERT(reporter, !configs[5]->asConfigGpu()->getUseNVPR()); |
| 199 REPORTER_ASSERT(reporter, !configs[5]->asConfigGpu()->getUseDIText()); | 220 REPORTER_ASSERT(reporter, !configs[5]->asConfigGpu()->getUseDIText()); |
| 200 REPORTER_ASSERT(reporter, configs[5]->asConfigGpu()->getSamples() == 0); | 221 REPORTER_ASSERT(reporter, configs[5]->asConfigGpu()->getSamples() == 0); |
| 201 REPORTER_ASSERT(reporter, configs[6]->asConfigGpu()->getContextType() == | 222 REPORTER_ASSERT(reporter, configs[6]->asConfigGpu()->getContextType() == |
| 202 GrContextFactory::kGLES_GLContextType); | 223 GrContextFactory::kGLES_GLContextType); |
| 203 REPORTER_ASSERT(reporter, !configs[6]->asConfigGpu()->getUseNVPR()); | 224 REPORTER_ASSERT(reporter, !configs[6]->asConfigGpu()->getUseNVPR()); |
| 204 REPORTER_ASSERT(reporter, !configs[6]->asConfigGpu()->getUseDIText()); | 225 REPORTER_ASSERT(reporter, !configs[6]->asConfigGpu()->getUseDIText()); |
| 205 REPORTER_ASSERT(reporter, configs[6]->asConfigGpu()->getSamples() == 0); | 226 REPORTER_ASSERT(reporter, configs[6]->asConfigGpu()->getSamples() == 0); |
| 206 | 227 REPORTER_ASSERT(reporter, configs[7]->asConfigGpu()->getContextType() == |
| 228 GrContextFactory::kGL_GLContextType); |
| 229 REPORTER_ASSERT(reporter, !configs[7]->asConfigGpu()->getUseNVPR()); |
| 230 REPORTER_ASSERT(reporter, !configs[7]->asConfigGpu()->getUseDIText()); |
| 231 REPORTER_ASSERT(reporter, configs[7]->asConfigGpu()->getSamples() == 0); |
| 207 #endif | 232 #endif |
| 208 } | 233 } |
| 209 | 234 |
| 210 DEF_TEST(ParseConfigs_ExtendedGpuConfigsIncorrect, reporter) { | 235 DEF_TEST(ParseConfigs_ExtendedGpuConfigsIncorrect, reporter) { |
| 211 SkCommandLineFlags::StringArray config1 = make_string_array({ | 236 SkCommandLineFlags::StringArray config1 = make_string_array({ |
| 212 "gpu(nvpr=1)", // Number as bool. | 237 "gpu(nvpr=1)", // Number as bool. |
| 213 "gpu(api=gl,)", // Trailing in comma. | 238 "gpu(api=gl,)", // Trailing in comma. |
| 214 "gpu(api=angle-glu)", // Unknown api. | 239 "gpu(api=angle-glu)", // Unknown api. |
| 215 "gpu(api=,samples=0)", // Empty api. | 240 "gpu(api=,samples=0)", // Empty api. |
| 216 "gpu(samples=true)", // Value true as a number. | 241 "gpu(samples=true)", // Value true as a number. |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 326 REPORTER_ASSERT(reporter, | 351 REPORTER_ASSERT(reporter, |
| 327 configs[i]->getViaParts()[j].equals(expectedConfigs[
i].vias[j])); | 352 configs[i]->getViaParts()[j].equals(expectedConfigs[
i].vias[j])); |
| 328 } | 353 } |
| 329 } | 354 } |
| 330 #if SK_SUPPORT_GPU | 355 #if SK_SUPPORT_GPU |
| 331 REPORTER_ASSERT(reporter, configs[0]->asConfigGpu()); | 356 REPORTER_ASSERT(reporter, configs[0]->asConfigGpu()); |
| 332 REPORTER_ASSERT(reporter, !configs[1]->asConfigGpu()); | 357 REPORTER_ASSERT(reporter, !configs[1]->asConfigGpu()); |
| 333 REPORTER_ASSERT(reporter, !configs[2]->asConfigGpu()); | 358 REPORTER_ASSERT(reporter, !configs[2]->asConfigGpu()); |
| 334 #endif | 359 #endif |
| 335 } | 360 } |
| OLD | NEW |