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/tracing.h" | 17 #include "chrome/test/base/tracing.h" |
18 #include "chrome/test/base/ui_test_utils.h" | 18 #include "chrome/test/base/ui_test_utils.h" |
19 #include "content/public/browser/gpu_data_manager.h" | 19 #include "content/public/browser/gpu_data_manager.h" |
| 20 #include "content/public/common/content_client.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/filename_util.h" | 26 #include "net/base/filename_util.h" |
26 #include "ui/gl/gl_implementation.h" | 27 #include "ui/gl/gl_implementation.h" |
27 | 28 |
28 #if defined(OS_MACOSX) | 29 #if defined(OS_MACOSX) |
29 #include "ui/gl/io_surface_support_mac.h" | 30 #include "ui/gl/io_surface_support_mac.h" |
30 #endif | 31 #endif |
31 | 32 |
32 #if defined(OS_WIN) | 33 #if defined(OS_WIN) |
33 #include "base/win/windows_version.h" | 34 #include "base/win/windows_version.h" |
34 #endif | 35 #endif |
35 | 36 |
36 using content::GpuDataManager; | 37 using content::GpuDataManager; |
37 using gpu::GpuFeatureType; | 38 using gpu::GpuFeatureType; |
38 using trace_analyzer::Query; | 39 using trace_analyzer::Query; |
39 using trace_analyzer::TraceAnalyzer; | 40 using trace_analyzer::TraceAnalyzer; |
40 using trace_analyzer::TraceEventVector; | 41 using trace_analyzer::TraceEventVector; |
41 | 42 |
42 namespace { | 43 namespace { |
43 | 44 |
44 const char kSwapBuffersEvent[] = "SwapBuffers"; | |
45 const char kAcceleratedCanvasCreationEvent[] = "Canvas2DLayerBridgeCreation"; | 45 const char kAcceleratedCanvasCreationEvent[] = "Canvas2DLayerBridgeCreation"; |
46 const char kWebGLCreationEvent[] = "DrawingBufferCreation"; | 46 const char kWebGLCreationEvent[] = "DrawingBufferCreation"; |
47 | 47 |
| 48 class FakeContentClient : public content::ContentClient { |
| 49 }; |
| 50 |
48 class GpuFeatureTest : public InProcessBrowserTest { | 51 class GpuFeatureTest : public InProcessBrowserTest { |
49 public: | 52 public: |
50 GpuFeatureTest() : category_patterns_("test_gpu") {} | 53 GpuFeatureTest() : category_patterns_("test_gpu") {} |
51 | 54 |
| 55 virtual void SetUp() OVERRIDE { |
| 56 content::SetContentClient(&content_client_); |
| 57 } |
| 58 |
| 59 virtual void TearDown() OVERRIDE { |
| 60 content::SetContentClient(NULL); |
| 61 } |
| 62 |
52 virtual void SetUpInProcessBrowserTestFixture() OVERRIDE { | 63 virtual void SetUpInProcessBrowserTestFixture() OVERRIDE { |
53 base::FilePath test_dir; | 64 base::FilePath test_dir; |
54 ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &test_dir)); | 65 ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &test_dir)); |
55 gpu_test_dir_ = test_dir.AppendASCII("gpu"); | 66 gpu_test_dir_ = test_dir.AppendASCII("gpu"); |
56 } | 67 } |
57 | 68 |
58 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { | 69 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { |
59 command_line->AppendSwitch(switches::kDisablePopupBlocking); | 70 command_line->AppendSwitch(switches::kDisablePopupBlocking); |
60 command_line->AppendSwitchASCII(switches::kWindowSize, "400,300"); | 71 command_line->AppendSwitchASCII(switches::kWindowSize, "400,300"); |
61 } | 72 } |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
153 analyzer_.reset(TraceAnalyzer::Create(trace_events_json_)); | 164 analyzer_.reset(TraceAnalyzer::Create(trace_events_json_)); |
154 analyzer_->AssociateBeginEndEvents(); | 165 analyzer_->AssociateBeginEndEvents(); |
155 return true; | 166 return true; |
156 } | 167 } |
157 | 168 |
158 protected: | 169 protected: |
159 base::FilePath gpu_test_dir_; | 170 base::FilePath gpu_test_dir_; |
160 scoped_ptr<TraceAnalyzer> analyzer_; | 171 scoped_ptr<TraceAnalyzer> analyzer_; |
161 std::string category_patterns_; | 172 std::string category_patterns_; |
162 std::string trace_events_json_; | 173 std::string trace_events_json_; |
| 174 FakeContentClient content_client_; |
163 }; | 175 }; |
164 | 176 |
165 class GpuFeaturePixelTest : public GpuFeatureTest { | 177 class GpuFeaturePixelTest : public GpuFeatureTest { |
166 protected: | 178 protected: |
167 virtual void SetUp() OVERRIDE { | 179 virtual void SetUp() OVERRIDE { |
168 EnablePixelOutput(); | 180 EnablePixelOutput(); |
169 GpuFeatureTest::SetUp(); | 181 GpuFeatureTest::SetUp(); |
170 } | 182 } |
171 }; | 183 }; |
172 | 184 |
173 #if defined(OS_WIN) || defined(ADDRESS_SANITIZER) || defined(USE_AURA) || \ | 185 class GpuCompositingBlockedTest : public GpuFeatureTest { |
174 defined(OS_MACOSX) | |
175 // This test is flaky on Windows. http://crbug.com/177113 | |
176 // Also fails under AddressSanitizer. http://crbug.com/185178 | |
177 // It fundamentally doesn't test the right thing on Aura. | |
178 // http://crbug.com/280675 | |
179 // This does not work with software compositing on Mac. http://crbug.com/286038 | |
180 #define MAYBE_AcceleratedCompositingAllowed DISABLED_AcceleratedCompositingAllow
ed | |
181 #else | |
182 #define MAYBE_AcceleratedCompositingAllowed AcceleratedCompositingAllowed | |
183 #endif | |
184 | |
185 IN_PROC_BROWSER_TEST_F(GpuFeatureTest, MAYBE_AcceleratedCompositingAllowed) { | |
186 EXPECT_FALSE(GpuDataManager::GetInstance()->IsFeatureBlacklisted( | |
187 gpu::GPU_FEATURE_TYPE_ACCELERATED_COMPOSITING)); | |
188 | |
189 const base::FilePath url(FILE_PATH_LITERAL("feature_compositing.html")); | |
190 RunEventTest(url, kSwapBuffersEvent, true); | |
191 } | |
192 | |
193 class AcceleratedCompositingBlockedTest : public GpuFeatureTest { | |
194 public: | 186 public: |
195 virtual void SetUpInProcessBrowserTestFixture() OVERRIDE { | 187 virtual void SetUpInProcessBrowserTestFixture() OVERRIDE { |
196 GpuFeatureTest::SetUpInProcessBrowserTestFixture(); | 188 GpuFeatureTest::SetUpInProcessBrowserTestFixture(); |
197 const std::string json_blacklist = | 189 const std::string json_blacklist = |
198 "{\n" | 190 "{\n" |
199 " \"name\": \"gpu blacklist\",\n" | 191 " \"name\": \"gpu blacklist\",\n" |
200 " \"version\": \"1.0\",\n" | 192 " \"version\": \"1.0\",\n" |
201 " \"entries\": [\n" | 193 " \"entries\": [\n" |
202 " {\n" | 194 " {\n" |
203 " \"id\": 1,\n" | 195 " \"id\": 1,\n" |
204 " \"features\": [\n" | 196 " \"features\": [\n" |
205 " \"accelerated_compositing\"\n" | 197 " \"gpu_compositing\"\n" |
206 " ]\n" | 198 " ]\n" |
207 " }\n" | 199 " }\n" |
208 " ]\n" | 200 " ]\n" |
209 "}"; | 201 "}"; |
210 SetupBlacklist(json_blacklist); | 202 SetupBlacklist(json_blacklist); |
211 } | 203 } |
212 }; | 204 }; |
213 | 205 |
214 #if defined(USE_AURA) || defined(OS_MACOSX) | 206 IN_PROC_BROWSER_TEST_F(GpuCompositingBlockedTest, GpuCompositingBlocked) { |
215 // Compositing is always on for Aura and Mac. | |
216 #define MAYBE_AcceleratedCompositingBlocked DISABLED_AcceleratedCompositingBlock
ed | |
217 #else | |
218 // TODO(jam): http://crbug.com/350550 | |
219 #define MAYBE_AcceleratedCompositingBlocked DISABLED_AcceleratedCompositingBlock
ed | |
220 #endif | |
221 | |
222 IN_PROC_BROWSER_TEST_F(AcceleratedCompositingBlockedTest, | |
223 MAYBE_AcceleratedCompositingBlocked) { | |
224 EXPECT_TRUE(GpuDataManager::GetInstance()->IsFeatureBlacklisted( | 207 EXPECT_TRUE(GpuDataManager::GetInstance()->IsFeatureBlacklisted( |
225 gpu::GPU_FEATURE_TYPE_ACCELERATED_COMPOSITING)); | 208 gpu::GPU_FEATURE_TYPE_GPU_COMPOSITING)); |
226 | |
227 const base::FilePath url(FILE_PATH_LITERAL("feature_compositing.html")); | |
228 RunEventTest(url, kSwapBuffersEvent, false); | |
229 } | 209 } |
230 | 210 |
231 // Times out: http://crbug.com/166060 | 211 IN_PROC_BROWSER_TEST_F(GpuFeatureTest, WebGLAllowed) { |
232 IN_PROC_BROWSER_TEST_F(GpuFeatureTest, DISABLED_WebGLAllowed) { | |
233 EXPECT_FALSE(GpuDataManager::GetInstance()->IsFeatureBlacklisted( | 212 EXPECT_FALSE(GpuDataManager::GetInstance()->IsFeatureBlacklisted( |
234 gpu::GPU_FEATURE_TYPE_WEBGL)); | 213 gpu::GPU_FEATURE_TYPE_WEBGL)); |
235 | 214 |
| 215 // The below times out: http://crbug.com/166060 |
| 216 return; |
| 217 |
236 const base::FilePath url(FILE_PATH_LITERAL("feature_webgl.html")); | 218 const base::FilePath url(FILE_PATH_LITERAL("feature_webgl.html")); |
237 RunEventTest(url, kWebGLCreationEvent, true); | 219 RunEventTest(url, kWebGLCreationEvent, true); |
238 } | 220 } |
239 | 221 |
240 IN_PROC_BROWSER_TEST_F(GpuFeatureTest, WebGLBlocked) { | 222 IN_PROC_BROWSER_TEST_F(GpuFeatureTest, WebGLBlocked) { |
241 const std::string json_blacklist = | 223 const std::string json_blacklist = |
242 "{\n" | 224 "{\n" |
243 " \"name\": \"gpu blacklist\",\n" | 225 " \"name\": \"gpu blacklist\",\n" |
244 " \"version\": \"1.0\",\n" | 226 " \"version\": \"1.0\",\n" |
245 " \"entries\": [\n" | 227 " \"entries\": [\n" |
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
397 RunTest(url, "\"SUCCESS\"", false); | 379 RunTest(url, "\"SUCCESS\"", false); |
398 } | 380 } |
399 | 381 |
400 // crbug.com/176466 | 382 // crbug.com/176466 |
401 IN_PROC_BROWSER_TEST_F(GpuFeatureTest, | 383 IN_PROC_BROWSER_TEST_F(GpuFeatureTest, |
402 DISABLED_CanOpenPopupAndRenderWith2DCanvas) { | 384 DISABLED_CanOpenPopupAndRenderWith2DCanvas) { |
403 const base::FilePath url(FILE_PATH_LITERAL("canvas_popup.html")); | 385 const base::FilePath url(FILE_PATH_LITERAL("canvas_popup.html")); |
404 RunTest(url, "\"SUCCESS\"", false); | 386 RunTest(url, "\"SUCCESS\"", false); |
405 } | 387 } |
406 | 388 |
407 class ThreadedCompositorTest : public GpuFeatureTest { | |
408 public: | |
409 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { | |
410 GpuFeatureTest::SetUpCommandLine(command_line); | |
411 command_line->AppendSwitch(switches::kEnableThreadedCompositing); | |
412 } | |
413 }; | |
414 | |
415 // http://crbug.com/157985 | |
416 IN_PROC_BROWSER_TEST_F(ThreadedCompositorTest, DISABLED_ThreadedCompositor) { | |
417 const base::FilePath url(FILE_PATH_LITERAL("feature_compositing.html")); | |
418 RunEventTest(url, kSwapBuffersEvent, true); | |
419 } | |
420 | |
421 | |
422 #if defined(OS_WIN) || defined(OS_CHROMEOS) || defined(OS_MACOSX) | 389 #if defined(OS_WIN) || defined(OS_CHROMEOS) || defined(OS_MACOSX) |
423 // http://crbug.com/162343: flaky on Windows and Mac, failing on ChromiumOS. | 390 // http://crbug.com/162343: flaky on Windows and Mac, failing on ChromiumOS. |
424 #define MAYBE_RafNoDamage DISABLED_RafNoDamage | 391 #define MAYBE_RafNoDamage DISABLED_RafNoDamage |
425 #else | 392 #else |
426 #define MAYBE_RafNoDamage RafNoDamage | 393 #define MAYBE_RafNoDamage RafNoDamage |
427 #endif | 394 #endif |
428 IN_PROC_BROWSER_TEST_F(GpuFeatureTest, MAYBE_RafNoDamage) { | 395 IN_PROC_BROWSER_TEST_F(GpuFeatureTest, MAYBE_RafNoDamage) { |
429 category_patterns_ = "-test_*"; | 396 category_patterns_ = "-test_*"; |
430 const base::FilePath url(FILE_PATH_LITERAL("feature_raf_no_damage.html")); | 397 const base::FilePath url(FILE_PATH_LITERAL("feature_raf_no_damage.html")); |
431 RunEventTest(url); | 398 RunEventTest(url); |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
536 "%d (resize offset %d): IOSurface width %d -> %d; Creates %d " | 503 "%d (resize offset %d): IOSurface width %d -> %d; Creates %d " |
537 "Expected %d", offset_i, offsets[offset_i], | 504 "Expected %d", offset_i, offsets[offset_i], |
538 old_width, new_width, num_creates, expected_creates); | 505 old_width, new_width, num_creates, expected_creates); |
539 } | 506 } |
540 } | 507 } |
541 LOG(INFO) << "finished test"; | 508 LOG(INFO) << "finished test"; |
542 } | 509 } |
543 #endif | 510 #endif |
544 | 511 |
545 } // namespace | 512 } // namespace |
OLD | NEW |