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/path_service.h" | 6 #include "base/path_service.h" |
7 #include "base/stringprintf.h" | 7 #include "base/stringprintf.h" |
8 #include "base/test/trace_event_analyzer.h" | 8 #include "base/test/trace_event_analyzer.h" |
| 9 #include "chrome/browser/ui/browser.h" |
9 #include "chrome/common/chrome_paths.h" | 10 #include "chrome/common/chrome_paths.h" |
10 #include "chrome/common/chrome_switches.h" | 11 #include "chrome/common/chrome_switches.h" |
11 #include "chrome/test/base/test_switches.h" | 12 #include "chrome/test/base/test_switches.h" |
12 #include "chrome/test/base/tracing.h" | 13 #include "chrome/test/base/tracing.h" |
13 #include "chrome/test/base/ui_test_utils.h" | 14 #include "chrome/test/base/ui_test_utils.h" |
14 #include "chrome/test/perf/browser_perf_test.h" | 15 #include "chrome/test/perf/browser_perf_test.h" |
15 #include "chrome/test/perf/perf_test.h" | 16 #include "chrome/test/perf/perf_test.h" |
16 #include "content/public/common/content_switches.h" | 17 #include "content/public/common/content_switches.h" |
17 #include "googleurl/src/gurl.h" | 18 #include "googleurl/src/gurl.h" |
18 #include "net/base/mock_host_resolver.h" | 19 #include "net/base/mock_host_resolver.h" |
19 #include "net/base/net_util.h" | 20 #include "net/base/net_util.h" |
20 #include "testing/gtest/include/gtest/gtest.h" | 21 #include "testing/gtest/include/gtest/gtest.h" |
21 #include "ui/gfx/gl/gl_switches.h" | 22 #include "ui/gfx/gl/gl_switches.h" |
22 | 23 |
23 namespace { | 24 namespace { |
24 | 25 |
25 enum ThroughputTestFlags { | 26 enum ThroughputTestFlags { |
26 kNone = 0, | 27 kNone = 0, |
27 kInternal = 1 << 0 // Test uses internal test data. | 28 kInternal = 1 << 0 // Test uses internal test data. |
28 }; | 29 }; |
29 | 30 |
30 const int kSpinUpTimeMs = 5 * 1000; | 31 const int kSpinUpTimeMs = 4 * 1000; |
31 const int kRunTimeMs = 10 * 1000; | 32 const int kRunTimeMs = 10 * 1000; |
32 const int kIgnoreSomeFrames = 3; | 33 const int kIgnoreSomeFrames = 3; |
33 | 34 |
34 class ThroughputTest : public BrowserPerfTest { | 35 class ThroughputTest : public BrowserPerfTest { |
35 public: | 36 public: |
36 explicit ThroughputTest(bool use_gpu) : use_gpu_(use_gpu) {} | 37 explicit ThroughputTest(bool use_gpu) : use_gpu_(use_gpu) {} |
37 | 38 |
38 bool IsGpuAvailable() const { | 39 bool IsGpuAvailable() const { |
39 return CommandLine::ForCurrentProcess()->HasSwitch("enable-gpu"); | 40 return CommandLine::ForCurrentProcess()->HasSwitch("enable-gpu"); |
40 } | 41 } |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
111 return; | 112 return; |
112 } | 113 } |
113 | 114 |
114 std::string json_events; | 115 std::string json_events; |
115 TraceEventVector events_sw, events_gpu; | 116 TraceEventVector events_sw, events_gpu; |
116 scoped_ptr<TraceAnalyzer> analyzer; | 117 scoped_ptr<TraceAnalyzer> analyzer; |
117 | 118 |
118 LOG(INFO) << gurl.possibly_invalid_spec(); | 119 LOG(INFO) << gurl.possibly_invalid_spec(); |
119 ui_test_utils::NavigateToURLWithDisposition( | 120 ui_test_utils::NavigateToURLWithDisposition( |
120 browser(), gurl, CURRENT_TAB, ui_test_utils::BROWSER_TEST_NONE); | 121 browser(), gurl, CURRENT_TAB, ui_test_utils::BROWSER_TEST_NONE); |
| 122 ui_test_utils::WaitForLoadStop(browser()->GetSelectedWebContents()); |
121 | 123 |
122 // Let the test spin up. | 124 // Let the test spin up. |
123 LOG(INFO) << "Spinning up test...\n"; | 125 LOG(INFO) << "Spinning up test...\n"; |
124 ASSERT_TRUE(tracing::BeginTracing("test_gpu")); | 126 ASSERT_TRUE(tracing::BeginTracing("test_gpu")); |
125 Wait(kSpinUpTimeMs); | 127 Wait(kSpinUpTimeMs); |
126 ASSERT_TRUE(tracing::EndTracing(&json_events)); | 128 ASSERT_TRUE(tracing::EndTracing(&json_events)); |
127 | 129 |
128 // Check if GPU is rendering: | 130 // Check if GPU is rendering: |
129 analyzer.reset(TraceAnalyzer::Create(json_events)); | 131 analyzer.reset(TraceAnalyzer::Create(json_events)); |
130 bool ran_on_gpu = (analyzer->FindEvents(Query::EventName() == | 132 bool ran_on_gpu = (analyzer->FindEvents(Query::EventName() == |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
213 | 215 |
214 IN_PROC_BROWSER_TEST_F(ThroughputTestSW, CanvasDemoSW) { | 216 IN_PROC_BROWSER_TEST_F(ThroughputTestSW, CanvasDemoSW) { |
215 RunTest("canvas-demo", kInternal); | 217 RunTest("canvas-demo", kInternal); |
216 } | 218 } |
217 | 219 |
218 IN_PROC_BROWSER_TEST_F(ThroughputTestGPU, CanvasDemoGPU) { | 220 IN_PROC_BROWSER_TEST_F(ThroughputTestGPU, CanvasDemoGPU) { |
219 RunTest("canvas-demo", kInternal); | 221 RunTest("canvas-demo", kInternal); |
220 } | 222 } |
221 | 223 |
222 } // namespace | 224 } // namespace |
OLD | NEW |