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