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" |
11 #include "chrome/browser/gpu_blacklist.h" | 11 #include "chrome/browser/gpu_blacklist.h" |
12 #include "chrome/browser/ui/browser.h" | 12 #include "chrome/browser/ui/browser.h" |
13 #include "chrome/common/chrome_paths.h" | 13 #include "chrome/common/chrome_paths.h" |
14 #include "chrome/common/chrome_switches.h" | 14 #include "chrome/common/chrome_switches.h" |
15 #include "chrome/test/base/in_process_browser_test.h" | 15 #include "chrome/test/base/in_process_browser_test.h" |
16 #include "chrome/test/base/test_launcher_utils.h" | 16 #include "chrome/test/base/test_launcher_utils.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_switches.h" | 20 #include "content/public/common/content_switches.h" |
21 #include "content/test/gpu/gpu_test_config.h" | 21 #include "content/test/gpu/gpu_test_config.h" |
22 #include "net/base/net_util.h" | 22 #include "net/base/net_util.h" |
23 #include "ui/gfx/gl/gl_switches.h" | 23 #include "ui/gfx/gl/gl_switches.h" |
24 | 24 |
25 using content::GpuDataManager; | 25 using content::GpuDataManager; |
26 using content::GpuFeatureType; | 26 using content::GpuFeatureType; |
| 27 using trace_analyzer::Query; |
| 28 using trace_analyzer::TraceAnalyzer; |
| 29 using trace_analyzer::TraceEventVector; |
27 | 30 |
28 namespace { | 31 namespace { |
29 | 32 |
30 typedef uint32 GpuResultFlags; | 33 typedef uint32 GpuResultFlags; |
31 #define EXPECT_NO_GPU_PROCESS GpuResultFlags(1<<0) | 34 #define EXPECT_NO_GPU_PROCESS GpuResultFlags(1<<0) |
32 // Expect a SwapBuffers to occur (see gles2_cmd_decoder.cc). | 35 // Expect a SwapBuffers to occur (see gles2_cmd_decoder.cc). |
33 #define EXPECT_GPU_SWAP_BUFFERS GpuResultFlags(1<<1) | 36 #define EXPECT_GPU_SWAP_BUFFERS GpuResultFlags(1<<1) |
34 | 37 |
35 class GpuFeatureTest : public InProcessBrowserTest { | 38 class GpuFeatureTest : public InProcessBrowserTest { |
36 public: | 39 public: |
37 GpuFeatureTest() : gpu_enabled_(false) {} | 40 GpuFeatureTest() : trace_categories_("test_gpu"), gpu_enabled_(false) {} |
38 | 41 |
39 virtual void SetUpInProcessBrowserTestFixture() { | 42 virtual void SetUpInProcessBrowserTestFixture() { |
40 FilePath test_dir; | 43 FilePath test_dir; |
41 ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &test_dir)); | 44 ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &test_dir)); |
42 gpu_test_dir_ = test_dir.AppendASCII("gpu"); | 45 gpu_test_dir_ = test_dir.AppendASCII("gpu"); |
43 } | 46 } |
44 | 47 |
45 virtual void SetUpCommandLine(CommandLine* command_line) { | 48 virtual void SetUpCommandLine(CommandLine* command_line) { |
46 // This enables DOM automation for tab contents. | 49 // This enables DOM automation for tab contents. |
47 EnableDOMAutomation(); | 50 EnableDOMAutomation(); |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
104 void RunTest(const FilePath& url, GpuResultFlags expectations) { | 107 void RunTest(const FilePath& url, GpuResultFlags expectations) { |
105 #if defined(OS_LINUX) && !defined(NDEBUG) | 108 #if defined(OS_LINUX) && !defined(NDEBUG) |
106 // Bypass tests on GPU Linux Debug bots. | 109 // Bypass tests on GPU Linux Debug bots. |
107 if (gpu_enabled_) | 110 if (gpu_enabled_) |
108 return; | 111 return; |
109 #endif | 112 #endif |
110 | 113 |
111 using trace_analyzer::Query; | 114 using trace_analyzer::Query; |
112 using trace_analyzer::TraceAnalyzer; | 115 using trace_analyzer::TraceAnalyzer; |
113 | 116 |
114 ASSERT_TRUE(tracing::BeginTracing("test_gpu")); | 117 ASSERT_TRUE(tracing::BeginTracing(trace_categories_)); |
115 | 118 |
116 // Have to use a new tab for the blacklist to work. | 119 // Have to use a new tab for the blacklist to work. |
117 RunTest(url, NULL, true); | 120 RunTest(url, NULL, true); |
118 | 121 |
119 std::string json_events; | 122 ASSERT_TRUE(tracing::EndTracing(&trace_events_json_)); |
120 ASSERT_TRUE(tracing::EndTracing(&json_events)); | |
121 | 123 |
122 scoped_ptr<TraceAnalyzer> analyzer(TraceAnalyzer::Create(json_events)); | 124 analyzer_.reset(TraceAnalyzer::Create(trace_events_json_)); |
123 analyzer->AssociateBeginEndEvents(); | 125 analyzer_->AssociateBeginEndEvents(); |
124 trace_analyzer::TraceEventVector events; | 126 TraceEventVector events; |
125 | 127 |
126 // This measurement is flaky, because the GPU process is sometimes | 128 // This measurement is flaky, because the GPU process is sometimes |
127 // started before the test (always with force-compositing-mode on CrOS). | 129 // started before the test (always with force-compositing-mode on CrOS). |
128 if (expectations & EXPECT_NO_GPU_PROCESS) { | 130 if (expectations & EXPECT_NO_GPU_PROCESS) { |
129 EXPECT_EQ(0u, analyzer->FindEvents( | 131 EXPECT_EQ(0u, analyzer_->FindEvents( |
130 Query::MatchBeginName("OnGraphicsInfoCollected"), &events)); | 132 Query::MatchBeginName("OnGraphicsInfoCollected"), &events)); |
131 } | 133 } |
132 | 134 |
133 // Check for swap buffers if expected: | 135 // Check for swap buffers if expected: |
134 if (expectations & EXPECT_GPU_SWAP_BUFFERS) { | 136 if (expectations & EXPECT_GPU_SWAP_BUFFERS) { |
135 EXPECT_GT(analyzer->FindEvents(Query::EventName() == | 137 EXPECT_GT(analyzer_->FindEvents(Query::EventName() == |
136 Query::String("SwapBuffers"), &events), | 138 Query::String("SwapBuffers"), &events), |
137 size_t(0)); | 139 size_t(0)); |
138 } | 140 } |
139 } | 141 } |
140 | 142 |
141 protected: | 143 protected: |
142 FilePath gpu_test_dir_; | 144 FilePath gpu_test_dir_; |
| 145 scoped_ptr<TraceAnalyzer> analyzer_; |
| 146 std::string trace_categories_; |
| 147 std::string trace_events_json_; |
143 bool gpu_enabled_; | 148 bool gpu_enabled_; |
144 }; | 149 }; |
145 | 150 |
146 IN_PROC_BROWSER_TEST_F(GpuFeatureTest, AcceleratedCompositingAllowed) { | 151 IN_PROC_BROWSER_TEST_F(GpuFeatureTest, AcceleratedCompositingAllowed) { |
147 GpuFeatureType type = GpuDataManager::GetInstance()->GetGpuFeatureType(); | 152 GpuFeatureType type = GpuDataManager::GetInstance()->GetGpuFeatureType(); |
148 EXPECT_EQ(type, 0); | 153 EXPECT_EQ(type, 0); |
149 | 154 |
150 const FilePath url(FILE_PATH_LITERAL("feature_compositing.html")); | 155 const FilePath url(FILE_PATH_LITERAL("feature_compositing.html")); |
151 RunTest(url, EXPECT_GPU_SWAP_BUFFERS); | 156 RunTest(url, EXPECT_GPU_SWAP_BUFFERS); |
152 } | 157 } |
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
364 GpuFeatureTest::SetUpCommandLine(command_line); | 369 GpuFeatureTest::SetUpCommandLine(command_line); |
365 command_line->AppendSwitch(switches::kEnableThreadedCompositing); | 370 command_line->AppendSwitch(switches::kEnableThreadedCompositing); |
366 } | 371 } |
367 }; | 372 }; |
368 | 373 |
369 IN_PROC_BROWSER_TEST_F(ThreadedCompositorTest, DISABLED_ThreadedCompositor) { | 374 IN_PROC_BROWSER_TEST_F(ThreadedCompositorTest, DISABLED_ThreadedCompositor) { |
370 const FilePath url(FILE_PATH_LITERAL("feature_compositing.html")); | 375 const FilePath url(FILE_PATH_LITERAL("feature_compositing.html")); |
371 RunTest(url, EXPECT_GPU_SWAP_BUFFERS); | 376 RunTest(url, EXPECT_GPU_SWAP_BUFFERS); |
372 } | 377 } |
373 | 378 |
| 379 // TODO(jbates) unmark FLAKY once it's verified to not be flaky. |
| 380 IN_PROC_BROWSER_TEST_F(GpuFeatureTest, FLAKY_RafNoDamage) { |
| 381 trace_categories_ = "-test_*"; |
| 382 const FilePath url(FILE_PATH_LITERAL("feature_raf_no_damage.html")); |
| 383 RunTest(url, GpuResultFlags(0)); |
| 384 |
| 385 TraceEventVector events; |
| 386 size_t num_events = analyzer_->FindEvents( |
| 387 Query::MatchBeginName("___RafWithNoDamage___"), &events); |
| 388 |
| 389 trace_analyzer::RateStats stats; |
| 390 trace_analyzer::RateStatsOptions stats_options; |
| 391 stats_options.trim_min = stats_options.trim_max = num_events / 10; |
| 392 EXPECT_TRUE(trace_analyzer::GetRateStats(events, &stats, &stats_options)); |
| 393 |
| 394 LOG(INFO) << "Number of RAFs: " << num_events << |
| 395 " Mean: " << stats.mean_us << |
| 396 " Min: " << stats.min_us << |
| 397 " Max: " << stats.max_us << |
| 398 " StdDev: " << stats.standard_deviation_us; |
| 399 |
| 400 // Expect that the average time between RAFs is more than 15ms. That will |
| 401 // indicate that the renderer is not simply spinning on RAF. |
| 402 EXPECT_GT(stats.mean_us, 15000.0); |
| 403 |
| 404 if (stats.mean_us <= 15000.0) { |
| 405 fprintf(stderr, "\n\nTRACE JSON:\n\n%s\n\n", trace_events_json_.c_str()); |
| 406 } |
| 407 } |
| 408 |
374 } // namespace anonymous | 409 } // namespace anonymous |
375 | 410 |
OLD | NEW |