| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "base/command_line.h" | 5 #include "base/command_line.h" |
| 6 #include "base/file_util.h" | 6 #include "base/file_util.h" |
| 7 #include "base/memory/scoped_ptr.h" | 7 #include "base/memory/scoped_ptr.h" |
| 8 #include "base/path_service.h" | 8 #include "base/path_service.h" |
| 9 #include "base/test/trace_event_analyzer.h" | 9 #include "base/test/trace_event_analyzer.h" |
| 10 #include "base/version.h" | 10 #include "base/version.h" |
| (...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 147 | 147 |
| 148 protected: | 148 protected: |
| 149 FilePath gpu_test_dir_; | 149 FilePath gpu_test_dir_; |
| 150 scoped_ptr<TraceAnalyzer> analyzer_; | 150 scoped_ptr<TraceAnalyzer> analyzer_; |
| 151 std::string trace_categories_; | 151 std::string trace_categories_; |
| 152 std::string trace_events_json_; | 152 std::string trace_events_json_; |
| 153 bool gpu_enabled_; | 153 bool gpu_enabled_; |
| 154 }; | 154 }; |
| 155 | 155 |
| 156 IN_PROC_BROWSER_TEST_F(GpuFeatureTest, AcceleratedCompositingAllowed) { | 156 IN_PROC_BROWSER_TEST_F(GpuFeatureTest, AcceleratedCompositingAllowed) { |
| 157 GpuFeatureType type = GpuDataManager::GetInstance()->GetGpuFeatureType(); | 157 GpuFeatureType type = |
| 158 GpuDataManager::GetInstance()->GetBlacklistedFeatures(); |
| 158 EXPECT_EQ(type, 0); | 159 EXPECT_EQ(type, 0); |
| 159 | 160 |
| 160 const FilePath url(FILE_PATH_LITERAL("feature_compositing.html")); | 161 const FilePath url(FILE_PATH_LITERAL("feature_compositing.html")); |
| 161 RunTest(url, EXPECT_GPU_SWAP_BUFFERS); | 162 RunTest(url, EXPECT_GPU_SWAP_BUFFERS); |
| 162 } | 163 } |
| 163 | 164 |
| 164 IN_PROC_BROWSER_TEST_F(GpuFeatureTest, AcceleratedCompositingBlocked) { | 165 IN_PROC_BROWSER_TEST_F(GpuFeatureTest, AcceleratedCompositingBlocked) { |
| 165 const std::string json_blacklist = | 166 const std::string json_blacklist = |
| 166 "{\n" | 167 "{\n" |
| 167 " \"name\": \"gpu blacklist\",\n" | 168 " \"name\": \"gpu blacklist\",\n" |
| 168 " \"version\": \"1.0\",\n" | 169 " \"version\": \"1.0\",\n" |
| 169 " \"entries\": [\n" | 170 " \"entries\": [\n" |
| 170 " {\n" | 171 " {\n" |
| 171 " \"id\": 1,\n" | 172 " \"id\": 1,\n" |
| 172 " \"blacklist\": [\n" | 173 " \"blacklist\": [\n" |
| 173 " \"accelerated_compositing\"\n" | 174 " \"accelerated_compositing\"\n" |
| 174 " ]\n" | 175 " ]\n" |
| 175 " }\n" | 176 " }\n" |
| 176 " ]\n" | 177 " ]\n" |
| 177 "}"; | 178 "}"; |
| 178 SetupBlacklist(json_blacklist); | 179 SetupBlacklist(json_blacklist); |
| 179 GpuFeatureType type = GpuDataManager::GetInstance()->GetGpuFeatureType(); | 180 GpuFeatureType type = |
| 181 GpuDataManager::GetInstance()->GetBlacklistedFeatures(); |
| 180 EXPECT_EQ(type, content::GPU_FEATURE_TYPE_ACCELERATED_COMPOSITING); | 182 EXPECT_EQ(type, content::GPU_FEATURE_TYPE_ACCELERATED_COMPOSITING); |
| 181 | 183 |
| 182 const FilePath url(FILE_PATH_LITERAL("feature_compositing.html")); | 184 const FilePath url(FILE_PATH_LITERAL("feature_compositing.html")); |
| 183 RunTest(url, EXPECT_NO_GPU_SWAP_BUFFERS); | 185 RunTest(url, EXPECT_NO_GPU_SWAP_BUFFERS); |
| 184 } | 186 } |
| 185 | 187 |
| 186 class AcceleratedCompositingTest : public GpuFeatureTest { | 188 class AcceleratedCompositingTest : public GpuFeatureTest { |
| 187 public: | 189 public: |
| 188 virtual void SetUpCommandLine(CommandLine* command_line) { | 190 virtual void SetUpCommandLine(CommandLine* command_line) { |
| 189 GpuFeatureTest::SetUpCommandLine(command_line); | 191 GpuFeatureTest::SetUpCommandLine(command_line); |
| 190 command_line->AppendSwitch(switches::kDisableAcceleratedCompositing); | 192 command_line->AppendSwitch(switches::kDisableAcceleratedCompositing); |
| 191 } | 193 } |
| 192 }; | 194 }; |
| 193 | 195 |
| 194 IN_PROC_BROWSER_TEST_F(AcceleratedCompositingTest, | 196 IN_PROC_BROWSER_TEST_F(AcceleratedCompositingTest, |
| 195 AcceleratedCompositingDisabled) { | 197 AcceleratedCompositingDisabled) { |
| 196 const FilePath url(FILE_PATH_LITERAL("feature_compositing.html")); | 198 const FilePath url(FILE_PATH_LITERAL("feature_compositing.html")); |
| 197 RunTest(url, EXPECT_NO_GPU_SWAP_BUFFERS); | 199 RunTest(url, EXPECT_NO_GPU_SWAP_BUFFERS); |
| 198 } | 200 } |
| 199 | 201 |
| 200 IN_PROC_BROWSER_TEST_F(GpuFeatureTest, WebGLAllowed) { | 202 IN_PROC_BROWSER_TEST_F(GpuFeatureTest, WebGLAllowed) { |
| 201 GpuFeatureType type = GpuDataManager::GetInstance()->GetGpuFeatureType(); | 203 GpuFeatureType type = |
| 204 GpuDataManager::GetInstance()->GetBlacklistedFeatures(); |
| 202 EXPECT_EQ(type, 0); | 205 EXPECT_EQ(type, 0); |
| 203 | 206 |
| 204 const FilePath url(FILE_PATH_LITERAL("feature_webgl.html")); | 207 const FilePath url(FILE_PATH_LITERAL("feature_webgl.html")); |
| 205 RunTest(url, EXPECT_GPU_SWAP_BUFFERS); | 208 RunTest(url, EXPECT_GPU_SWAP_BUFFERS); |
| 206 } | 209 } |
| 207 | 210 |
| 208 IN_PROC_BROWSER_TEST_F(GpuFeatureTest, WebGLBlocked) { | 211 IN_PROC_BROWSER_TEST_F(GpuFeatureTest, WebGLBlocked) { |
| 209 const std::string json_blacklist = | 212 const std::string json_blacklist = |
| 210 "{\n" | 213 "{\n" |
| 211 " \"name\": \"gpu blacklist\",\n" | 214 " \"name\": \"gpu blacklist\",\n" |
| 212 " \"version\": \"1.0\",\n" | 215 " \"version\": \"1.0\",\n" |
| 213 " \"entries\": [\n" | 216 " \"entries\": [\n" |
| 214 " {\n" | 217 " {\n" |
| 215 " \"id\": 1,\n" | 218 " \"id\": 1,\n" |
| 216 " \"blacklist\": [\n" | 219 " \"blacklist\": [\n" |
| 217 " \"webgl\"\n" | 220 " \"webgl\"\n" |
| 218 " ]\n" | 221 " ]\n" |
| 219 " }\n" | 222 " }\n" |
| 220 " ]\n" | 223 " ]\n" |
| 221 "}"; | 224 "}"; |
| 222 SetupBlacklist(json_blacklist); | 225 SetupBlacklist(json_blacklist); |
| 223 GpuFeatureType type = GpuDataManager::GetInstance()->GetGpuFeatureType(); | 226 GpuFeatureType type = |
| 227 GpuDataManager::GetInstance()->GetBlacklistedFeatures(); |
| 224 EXPECT_EQ(type, content::GPU_FEATURE_TYPE_WEBGL); | 228 EXPECT_EQ(type, content::GPU_FEATURE_TYPE_WEBGL); |
| 225 | 229 |
| 226 const FilePath url(FILE_PATH_LITERAL("feature_webgl.html")); | 230 const FilePath url(FILE_PATH_LITERAL("feature_webgl.html")); |
| 227 RunTest(url, EXPECT_NO_GPU_SWAP_BUFFERS); | 231 RunTest(url, EXPECT_NO_GPU_SWAP_BUFFERS); |
| 228 } | 232 } |
| 229 | 233 |
| 230 class WebGLTest : public GpuFeatureTest { | 234 class WebGLTest : public GpuFeatureTest { |
| 231 public: | 235 public: |
| 232 virtual void SetUpCommandLine(CommandLine* command_line) { | 236 virtual void SetUpCommandLine(CommandLine* command_line) { |
| 233 GpuFeatureTest::SetUpCommandLine(command_line); | 237 GpuFeatureTest::SetUpCommandLine(command_line); |
| 234 #if !defined(OS_ANDROID) | 238 #if !defined(OS_ANDROID) |
| 235 // On Android, WebGL is disabled by default | 239 // On Android, WebGL is disabled by default |
| 236 command_line->AppendSwitch(switches::kDisableExperimentalWebGL); | 240 command_line->AppendSwitch(switches::kDisableExperimentalWebGL); |
| 237 #endif | 241 #endif |
| 238 } | 242 } |
| 239 }; | 243 }; |
| 240 | 244 |
| 241 IN_PROC_BROWSER_TEST_F(WebGLTest, WebGLDisabled) { | 245 IN_PROC_BROWSER_TEST_F(WebGLTest, WebGLDisabled) { |
| 242 const FilePath url(FILE_PATH_LITERAL("feature_webgl.html")); | 246 const FilePath url(FILE_PATH_LITERAL("feature_webgl.html")); |
| 243 RunTest(url, EXPECT_NO_GPU_SWAP_BUFFERS); | 247 RunTest(url, EXPECT_NO_GPU_SWAP_BUFFERS); |
| 244 } | 248 } |
| 245 | 249 |
| 246 IN_PROC_BROWSER_TEST_F(GpuFeatureTest, MultisamplingAllowed) { | 250 IN_PROC_BROWSER_TEST_F(GpuFeatureTest, MultisamplingAllowed) { |
| 247 GpuFeatureType type = GpuDataManager::GetInstance()->GetGpuFeatureType(); | 251 GpuFeatureType type = |
| 252 GpuDataManager::GetInstance()->GetBlacklistedFeatures(); |
| 248 EXPECT_EQ(type, 0); | 253 EXPECT_EQ(type, 0); |
| 249 | 254 |
| 250 // Multisampling is not supported if running on top of osmesa. | 255 // Multisampling is not supported if running on top of osmesa. |
| 251 std::string use_gl = CommandLine::ForCurrentProcess()->GetSwitchValueASCII( | 256 std::string use_gl = CommandLine::ForCurrentProcess()->GetSwitchValueASCII( |
| 252 switches::kUseGL); | 257 switches::kUseGL); |
| 253 if (use_gl == gfx::kGLImplementationOSMesaName) | 258 if (use_gl == gfx::kGLImplementationOSMesaName) |
| 254 return; | 259 return; |
| 255 | 260 |
| 256 // Linux Intel uses mesa driver, where multisampling is not supported. | 261 // Linux Intel uses mesa driver, where multisampling is not supported. |
| 257 // Multisampling is also not supported on virtualized mac os. | 262 // Multisampling is also not supported on virtualized mac os. |
| (...skipping 19 matching lines...) Expand all Loading... |
| 277 " \"entries\": [\n" | 282 " \"entries\": [\n" |
| 278 " {\n" | 283 " {\n" |
| 279 " \"id\": 1,\n" | 284 " \"id\": 1,\n" |
| 280 " \"blacklist\": [\n" | 285 " \"blacklist\": [\n" |
| 281 " \"multisampling\"\n" | 286 " \"multisampling\"\n" |
| 282 " ]\n" | 287 " ]\n" |
| 283 " }\n" | 288 " }\n" |
| 284 " ]\n" | 289 " ]\n" |
| 285 "}"; | 290 "}"; |
| 286 SetupBlacklist(json_blacklist); | 291 SetupBlacklist(json_blacklist); |
| 287 GpuFeatureType type = GpuDataManager::GetInstance()->GetGpuFeatureType(); | 292 GpuFeatureType type = |
| 293 GpuDataManager::GetInstance()->GetBlacklistedFeatures(); |
| 288 EXPECT_EQ(type, content::GPU_FEATURE_TYPE_MULTISAMPLING); | 294 EXPECT_EQ(type, content::GPU_FEATURE_TYPE_MULTISAMPLING); |
| 289 | 295 |
| 290 const FilePath url(FILE_PATH_LITERAL("feature_multisampling.html")); | 296 const FilePath url(FILE_PATH_LITERAL("feature_multisampling.html")); |
| 291 RunTest(url, "\"FALSE\"", true); | 297 RunTest(url, "\"FALSE\"", true); |
| 292 } | 298 } |
| 293 | 299 |
| 294 class WebGLMultisamplingTest : public GpuFeatureTest { | 300 class WebGLMultisamplingTest : public GpuFeatureTest { |
| 295 public: | 301 public: |
| 296 virtual void SetUpCommandLine(CommandLine* command_line) { | 302 virtual void SetUpCommandLine(CommandLine* command_line) { |
| 297 GpuFeatureTest::SetUpCommandLine(command_line); | 303 GpuFeatureTest::SetUpCommandLine(command_line); |
| 298 command_line->AppendSwitch(switches::kDisableGLMultisampling); | 304 command_line->AppendSwitch(switches::kDisableGLMultisampling); |
| 299 } | 305 } |
| 300 }; | 306 }; |
| 301 | 307 |
| 302 IN_PROC_BROWSER_TEST_F(WebGLMultisamplingTest, MultisamplingDisabled) { | 308 IN_PROC_BROWSER_TEST_F(WebGLMultisamplingTest, MultisamplingDisabled) { |
| 303 // Multisampling fails on virtualized mac os. | 309 // Multisampling fails on virtualized mac os. |
| 304 if (GPUTestBotConfig::CurrentConfigMatches("MAC VMWARE")) | 310 if (GPUTestBotConfig::CurrentConfigMatches("MAC VMWARE")) |
| 305 return; | 311 return; |
| 306 | 312 |
| 307 const FilePath url(FILE_PATH_LITERAL("feature_multisampling.html")); | 313 const FilePath url(FILE_PATH_LITERAL("feature_multisampling.html")); |
| 308 RunTest(url, "\"FALSE\"", true); | 314 RunTest(url, "\"FALSE\"", true); |
| 309 } | 315 } |
| 310 | 316 |
| 311 IN_PROC_BROWSER_TEST_F(GpuFeatureTest, Canvas2DAllowed) { | 317 IN_PROC_BROWSER_TEST_F(GpuFeatureTest, Canvas2DAllowed) { |
| 312 // Accelerated canvas 2D is not supported on XP. | 318 // Accelerated canvas 2D is not supported on XP. |
| 313 if (GPUTestBotConfig::CurrentConfigMatches("XP")) | 319 if (GPUTestBotConfig::CurrentConfigMatches("XP")) |
| 314 return; | 320 return; |
| 315 | 321 |
| 316 GpuFeatureType type = GpuDataManager::GetInstance()->GetGpuFeatureType(); | 322 GpuFeatureType type = |
| 323 GpuDataManager::GetInstance()->GetBlacklistedFeatures(); |
| 317 EXPECT_EQ(type, 0); | 324 EXPECT_EQ(type, 0); |
| 318 | 325 |
| 319 const FilePath url(FILE_PATH_LITERAL("feature_canvas2d.html")); | 326 const FilePath url(FILE_PATH_LITERAL("feature_canvas2d.html")); |
| 320 RunTest(url, EXPECT_GPU_SWAP_BUFFERS); | 327 RunTest(url, EXPECT_GPU_SWAP_BUFFERS); |
| 321 } | 328 } |
| 322 | 329 |
| 323 IN_PROC_BROWSER_TEST_F(GpuFeatureTest, Canvas2DBlocked) { | 330 IN_PROC_BROWSER_TEST_F(GpuFeatureTest, Canvas2DBlocked) { |
| 324 const std::string json_blacklist = | 331 const std::string json_blacklist = |
| 325 "{\n" | 332 "{\n" |
| 326 " \"name\": \"gpu blacklist\",\n" | 333 " \"name\": \"gpu blacklist\",\n" |
| 327 " \"version\": \"1.0\",\n" | 334 " \"version\": \"1.0\",\n" |
| 328 " \"entries\": [\n" | 335 " \"entries\": [\n" |
| 329 " {\n" | 336 " {\n" |
| 330 " \"id\": 1,\n" | 337 " \"id\": 1,\n" |
| 331 " \"blacklist\": [\n" | 338 " \"blacklist\": [\n" |
| 332 " \"accelerated_2d_canvas\"\n" | 339 " \"accelerated_2d_canvas\"\n" |
| 333 " ]\n" | 340 " ]\n" |
| 334 " }\n" | 341 " }\n" |
| 335 " ]\n" | 342 " ]\n" |
| 336 "}"; | 343 "}"; |
| 337 SetupBlacklist(json_blacklist); | 344 SetupBlacklist(json_blacklist); |
| 338 GpuFeatureType type = GpuDataManager::GetInstance()->GetGpuFeatureType(); | 345 GpuFeatureType type = |
| 346 GpuDataManager::GetInstance()->GetBlacklistedFeatures(); |
| 339 EXPECT_EQ(type, content::GPU_FEATURE_TYPE_ACCELERATED_2D_CANVAS); | 347 EXPECT_EQ(type, content::GPU_FEATURE_TYPE_ACCELERATED_2D_CANVAS); |
| 340 | 348 |
| 341 const FilePath url(FILE_PATH_LITERAL("feature_canvas2d.html")); | 349 const FilePath url(FILE_PATH_LITERAL("feature_canvas2d.html")); |
| 342 RunTest(url, EXPECT_NO_GPU_SWAP_BUFFERS); | 350 RunTest(url, EXPECT_NO_GPU_SWAP_BUFFERS); |
| 343 } | 351 } |
| 344 | 352 |
| 345 class Canvas2DDisabledTest : public GpuFeatureTest { | 353 class Canvas2DDisabledTest : public GpuFeatureTest { |
| 346 public: | 354 public: |
| 347 virtual void SetUpCommandLine(CommandLine* command_line) { | 355 virtual void SetUpCommandLine(CommandLine* command_line) { |
| 348 GpuFeatureTest::SetUpCommandLine(command_line); | 356 GpuFeatureTest::SetUpCommandLine(command_line); |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 411 // indicate that the renderer is not simply spinning on RAF. | 419 // indicate that the renderer is not simply spinning on RAF. |
| 412 EXPECT_GT(stats.mean_us, 15000.0); | 420 EXPECT_GT(stats.mean_us, 15000.0); |
| 413 | 421 |
| 414 // Print out the trace events upon error to debug failures. | 422 // Print out the trace events upon error to debug failures. |
| 415 if (stats.mean_us <= 15000.0) { | 423 if (stats.mean_us <= 15000.0) { |
| 416 fprintf(stderr, "\n\nTRACE JSON:\n\n%s\n\n", trace_events_json_.c_str()); | 424 fprintf(stderr, "\n\nTRACE JSON:\n\n%s\n\n", trace_events_json_.c_str()); |
| 417 } | 425 } |
| 418 } | 426 } |
| 419 | 427 |
| 420 } // namespace anonymous | 428 } // namespace anonymous |
| OLD | NEW |