| 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/strings/stringprintf.h" | 9 #include "base/strings/stringprintf.h" |
| 10 #include "base/test/trace_event_analyzer.h" | 10 #include "base/test/trace_event_analyzer.h" |
| 11 #include "base/version.h" | 11 #include "base/version.h" |
| 12 #include "chrome/browser/ui/browser.h" | 12 #include "chrome/browser/ui/browser.h" |
| 13 #include "chrome/browser/ui/browser_window.h" | 13 #include "chrome/browser/ui/browser_window.h" |
| 14 #include "chrome/common/chrome_paths.h" | 14 #include "chrome/common/chrome_paths.h" |
| 15 #include "chrome/common/chrome_switches.h" | 15 #include "chrome/common/chrome_switches.h" |
| 16 #include "chrome/test/base/in_process_browser_test.h" | 16 #include "chrome/test/base/in_process_browser_test.h" |
| 17 #include "chrome/test/base/test_launcher_utils.h" |
| 17 #include "chrome/test/base/tracing.h" | 18 #include "chrome/test/base/tracing.h" |
| 18 #include "chrome/test/base/ui_test_utils.h" | 19 #include "chrome/test/base/ui_test_utils.h" |
| 19 #include "content/public/browser/gpu_data_manager.h" | 20 #include "content/public/browser/gpu_data_manager.h" |
| 20 #include "content/public/common/content_switches.h" | 21 #include "content/public/common/content_switches.h" |
| 21 #include "content/public/test/browser_test_utils.h" | 22 #include "content/public/test/browser_test_utils.h" |
| 22 #include "gpu/config/gpu_feature_type.h" | 23 #include "gpu/config/gpu_feature_type.h" |
| 23 #include "gpu/config/gpu_info.h" | 24 #include "gpu/config/gpu_info.h" |
| 24 #include "gpu/config/gpu_test_config.h" | 25 #include "gpu/config/gpu_test_config.h" |
| 25 #include "net/base/net_util.h" | 26 #include "net/base/net_util.h" |
| 26 #include "ui/gl/gl_implementation.h" | 27 #include "ui/compositor/compositor_setup.h" |
| 28 #include "ui/gl/gl_switches.h" |
| 27 | 29 |
| 28 #if defined(OS_MACOSX) | 30 #if defined(OS_MACOSX) |
| 29 #include "ui/gl/io_surface_support_mac.h" | 31 #include "ui/gl/io_surface_support_mac.h" |
| 30 #endif | 32 #endif |
| 31 | 33 |
| 32 #if defined(OS_WIN) | 34 #if defined(OS_WIN) |
| 33 #include "base/win/windows_version.h" | 35 #include "base/win/windows_version.h" |
| 34 #endif | 36 #endif |
| 35 | 37 |
| 36 using content::GpuDataManager; | 38 using content::GpuDataManager; |
| 37 using gpu::GpuFeatureType; | 39 using gpu::GpuFeatureType; |
| 38 using trace_analyzer::Query; | 40 using trace_analyzer::Query; |
| 39 using trace_analyzer::TraceAnalyzer; | 41 using trace_analyzer::TraceAnalyzer; |
| 40 using trace_analyzer::TraceEventVector; | 42 using trace_analyzer::TraceEventVector; |
| 41 | 43 |
| 42 namespace { | 44 namespace { |
| 43 | 45 |
| 44 const char kSwapBuffersEvent[] = "SwapBuffers"; | 46 const char kSwapBuffersEvent[] = "SwapBuffers"; |
| 45 const char kAcceleratedCanvasCreationEvent[] = "Canvas2DLayerBridgeCreation"; | 47 const char kAcceleratedCanvasCreationEvent[] = "Canvas2DLayerBridgeCreation"; |
| 46 const char kWebGLCreationEvent[] = "DrawingBufferCreation"; | 48 const char kWebGLCreationEvent[] = "DrawingBufferCreation"; |
| 47 | 49 |
| 48 class GpuFeatureTest : public InProcessBrowserTest { | 50 class GpuFeatureTest : public InProcessBrowserTest { |
| 49 public: | 51 public: |
| 50 GpuFeatureTest() : category_patterns_("test_gpu") {} | 52 GpuFeatureTest() : category_patterns_("test_gpu"), gpu_enabled_(false) {} |
| 51 | |
| 52 virtual void SetUp() OVERRIDE { | |
| 53 // We expect to use real GL contexts for these tests. | |
| 54 UseRealGLContexts(); | |
| 55 | |
| 56 InProcessBrowserTest::SetUp(); | |
| 57 } | |
| 58 | 53 |
| 59 virtual void SetUpInProcessBrowserTestFixture() OVERRIDE { | 54 virtual void SetUpInProcessBrowserTestFixture() OVERRIDE { |
| 60 base::FilePath test_dir; | 55 base::FilePath test_dir; |
| 61 ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &test_dir)); | 56 ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &test_dir)); |
| 62 gpu_test_dir_ = test_dir.AppendASCII("gpu"); | 57 gpu_test_dir_ = test_dir.AppendASCII("gpu"); |
| 63 } | 58 } |
| 64 | 59 |
| 65 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { | 60 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { |
| 61 // Do not use mesa if real GPU is required. |
| 62 if (!command_line->HasSwitch(switches::kUseGpuInTests)) { |
| 63 #if !defined(OS_MACOSX) |
| 64 CHECK(test_launcher_utils::OverrideGLImplementation( |
| 65 command_line, gfx::kGLImplementationOSMesaName)) << |
| 66 "kUseGL must not be set by test framework code!"; |
| 67 #endif |
| 68 } else { |
| 69 gpu_enabled_ = true; |
| 70 } |
| 66 command_line->AppendSwitch(switches::kDisablePopupBlocking); | 71 command_line->AppendSwitch(switches::kDisablePopupBlocking); |
| 72 ui::DisableTestCompositor(); |
| 67 command_line->AppendSwitchASCII(switches::kWindowSize, "400,300"); | 73 command_line->AppendSwitchASCII(switches::kWindowSize, "400,300"); |
| 68 } | 74 } |
| 69 | 75 |
| 70 void SetupBlacklist(const std::string& json_blacklist) { | 76 void SetupBlacklist(const std::string& json_blacklist) { |
| 71 gpu::GPUInfo gpu_info; | 77 gpu::GPUInfo gpu_info; |
| 72 GpuDataManager::GetInstance()->InitializeForTesting( | 78 GpuDataManager::GetInstance()->InitializeForTesting( |
| 73 json_blacklist, gpu_info); | 79 json_blacklist, gpu_info); |
| 74 } | 80 } |
| 75 | 81 |
| 76 // If expected_reply is NULL, we don't check the reply content. | 82 // If expected_reply is NULL, we don't check the reply content. |
| 77 void RunTest(const base::FilePath& url, | 83 void RunTest(const base::FilePath& url, |
| 78 const char* expected_reply, | 84 const char* expected_reply, |
| 79 bool new_tab) { | 85 bool new_tab) { |
| 80 #if defined(OS_LINUX) && !defined(NDEBUG) | 86 #if defined(OS_LINUX) && !defined(NDEBUG) |
| 81 // Bypass tests on GPU Linux Debug bots. | 87 // Bypass tests on GPU Linux Debug bots. |
| 82 if (gfx::GetGLImplementation() != gfx::kGLImplementationOSMesaGL) | 88 if (gpu_enabled_) |
| 83 return; | 89 return; |
| 84 #endif | 90 #endif |
| 85 | 91 |
| 86 base::FilePath test_path; | 92 base::FilePath test_path; |
| 87 test_path = gpu_test_dir_.Append(url); | 93 test_path = gpu_test_dir_.Append(url); |
| 88 ASSERT_TRUE(base::PathExists(test_path)) | 94 ASSERT_TRUE(base::PathExists(test_path)) |
| 89 << "Missing test file: " << test_path.value(); | 95 << "Missing test file: " << test_path.value(); |
| 90 | 96 |
| 91 content::DOMMessageQueue message_queue; | 97 content::DOMMessageQueue message_queue; |
| 92 if (new_tab) { | 98 if (new_tab) { |
| (...skipping 11 matching lines...) Expand all Loading... |
| 104 if (expected_reply) | 110 if (expected_reply) |
| 105 EXPECT_STREQ(expected_reply, result.c_str()); | 111 EXPECT_STREQ(expected_reply, result.c_str()); |
| 106 } | 112 } |
| 107 | 113 |
| 108 // Open the URL and check the trace stream for the given event. | 114 // Open the URL and check the trace stream for the given event. |
| 109 void RunEventTest(const base::FilePath& url, | 115 void RunEventTest(const base::FilePath& url, |
| 110 const char* event_name = NULL, | 116 const char* event_name = NULL, |
| 111 bool event_expected = false) { | 117 bool event_expected = false) { |
| 112 #if defined(OS_LINUX) && !defined(NDEBUG) | 118 #if defined(OS_LINUX) && !defined(NDEBUG) |
| 113 // Bypass tests on GPU Linux Debug bots. | 119 // Bypass tests on GPU Linux Debug bots. |
| 114 if (gfx::GetGLImplementation() != gfx::kGLImplementationOSMesaGL) | 120 if (gpu_enabled_) |
| 115 return; | 121 return; |
| 116 #endif | 122 #endif |
| 117 #if defined(OS_MACOSX) | 123 #if defined(OS_MACOSX) |
| 118 // Bypass tests on Mac OSX 10.5 bots (IOSurfaceSupport is now required). | 124 // Bypass tests on Mac OSX 10.5 bots (IOSurfaceSupport is now required). |
| 119 if (!IOSurfaceSupport::Initialize()) | 125 if (!IOSurfaceSupport::Initialize()) |
| 120 return; | 126 return; |
| 121 #endif | 127 #endif |
| 122 | 128 |
| 123 ASSERT_TRUE(tracing::BeginTracing(category_patterns_)); | 129 ASSERT_TRUE(tracing::BeginTracing(category_patterns_)); |
| 124 | 130 |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 160 analyzer_.reset(TraceAnalyzer::Create(trace_events_json_)); | 166 analyzer_.reset(TraceAnalyzer::Create(trace_events_json_)); |
| 161 analyzer_->AssociateBeginEndEvents(); | 167 analyzer_->AssociateBeginEndEvents(); |
| 162 return true; | 168 return true; |
| 163 } | 169 } |
| 164 | 170 |
| 165 protected: | 171 protected: |
| 166 base::FilePath gpu_test_dir_; | 172 base::FilePath gpu_test_dir_; |
| 167 scoped_ptr<TraceAnalyzer> analyzer_; | 173 scoped_ptr<TraceAnalyzer> analyzer_; |
| 168 std::string category_patterns_; | 174 std::string category_patterns_; |
| 169 std::string trace_events_json_; | 175 std::string trace_events_json_; |
| 176 bool gpu_enabled_; |
| 170 }; | 177 }; |
| 171 | 178 |
| 172 #if defined(OS_WIN) || defined(ADDRESS_SANITIZER) | 179 #if defined(OS_WIN) || defined(ADDRESS_SANITIZER) |
| 173 // This test is flaky on Windows. http://crbug.com/177113 | 180 // This test is flaky on Windows. http://crbug.com/177113 |
| 174 // Also fails under AddressSanitizer. http://crbug.com/185178 | 181 // Also fails under AddressSanitizer. http://crbug.com/185178 |
| 175 #define MAYBE_AcceleratedCompositingAllowed DISABLED_AcceleratedCompositingAllow
ed | 182 #define MAYBE_AcceleratedCompositingAllowed DISABLED_AcceleratedCompositingAllow
ed |
| 176 #else | 183 #else |
| 177 #define MAYBE_AcceleratedCompositingAllowed AcceleratedCompositingAllowed | 184 #define MAYBE_AcceleratedCompositingAllowed AcceleratedCompositingAllowed |
| 178 #endif | 185 #endif |
| 179 | 186 |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 294 IN_PROC_BROWSER_TEST_F(WebGLTest, WebGLDisabled) { | 301 IN_PROC_BROWSER_TEST_F(WebGLTest, WebGLDisabled) { |
| 295 const base::FilePath url(FILE_PATH_LITERAL("feature_webgl.html")); | 302 const base::FilePath url(FILE_PATH_LITERAL("feature_webgl.html")); |
| 296 RunEventTest(url, kWebGLCreationEvent, false); | 303 RunEventTest(url, kWebGLCreationEvent, false); |
| 297 } | 304 } |
| 298 | 305 |
| 299 IN_PROC_BROWSER_TEST_F(GpuFeatureTest, MultisamplingAllowed) { | 306 IN_PROC_BROWSER_TEST_F(GpuFeatureTest, MultisamplingAllowed) { |
| 300 EXPECT_FALSE(GpuDataManager::GetInstance()->IsFeatureBlacklisted( | 307 EXPECT_FALSE(GpuDataManager::GetInstance()->IsFeatureBlacklisted( |
| 301 gpu::GPU_FEATURE_TYPE_MULTISAMPLING)); | 308 gpu::GPU_FEATURE_TYPE_MULTISAMPLING)); |
| 302 | 309 |
| 303 // Multisampling is not supported if running on top of osmesa. | 310 // Multisampling is not supported if running on top of osmesa. |
| 304 if (gfx::GetGLImplementation() != gfx::kGLImplementationOSMesaGL) | 311 std::string use_gl = CommandLine::ForCurrentProcess()->GetSwitchValueASCII( |
| 312 switches::kUseGL); |
| 313 if (use_gl == gfx::kGLImplementationOSMesaName) |
| 305 return; | 314 return; |
| 306 | 315 |
| 307 // Linux Intel uses mesa driver, where multisampling is not supported. | 316 // Linux Intel uses mesa driver, where multisampling is not supported. |
| 308 // Multisampling is also not supported on virtualized mac os. | 317 // Multisampling is also not supported on virtualized mac os. |
| 309 std::vector<std::string> configs; | 318 std::vector<std::string> configs; |
| 310 configs.push_back("LINUX INTEL"); | 319 configs.push_back("LINUX INTEL"); |
| 311 configs.push_back("MAC VMWARE"); | 320 configs.push_back("MAC VMWARE"); |
| 312 if (gpu::GPUTestBotConfig::CurrentConfigMatches(configs)) | 321 if (gpu::GPUTestBotConfig::CurrentConfigMatches(configs)) |
| 313 return; | 322 return; |
| 314 | 323 |
| (...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 542 LOG(INFO) << | 551 LOG(INFO) << |
| 543 base::StringPrintf( | 552 base::StringPrintf( |
| 544 "%d (resize offset %d): IOSurface width %d -> %d; Creates %d " | 553 "%d (resize offset %d): IOSurface width %d -> %d; Creates %d " |
| 545 "Expected %d", offset_i, offsets[offset_i], | 554 "Expected %d", offset_i, offsets[offset_i], |
| 546 old_width, new_width, num_creates, expected_creates); | 555 old_width, new_width, num_creates, expected_creates); |
| 547 } | 556 } |
| 548 } | 557 } |
| 549 } | 558 } |
| 550 #endif | 559 #endif |
| 551 | 560 |
| 552 } // namespace | 561 } // namespace anonymous |
| OLD | NEW |