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/file_util.h" | 5 #include "base/file_util.h" |
6 #include "base/path_service.h" | 6 #include "base/path_service.h" |
7 #include "base/perftimer.h" | 7 #include "base/perftimer.h" |
8 #include "base/stringprintf.h" | 8 #include "base/stringprintf.h" |
9 #include "base/time.h" | 9 #include "base/time.h" |
10 #include "chrome/app/chrome_command_ids.h" | 10 #include "chrome/app/chrome_command_ids.h" |
11 #include "chrome/common/chrome_paths.h" | 11 #include "chrome/common/chrome_paths.h" |
12 #include "chrome/common/chrome_switches.h" | 12 #include "chrome/common/chrome_switches.h" |
13 #include "chrome/test/automation/automation_proxy.h" | 13 #include "chrome/test/automation/automation_proxy.h" |
14 #include "chrome/test/automation/browser_proxy.h" | 14 #include "chrome/test/automation/browser_proxy.h" |
15 #include "chrome/test/automation/window_proxy.h" | 15 #include "chrome/test/automation/window_proxy.h" |
16 #include "chrome/test/perf/perf_test.h" | 16 #include "chrome/test/perf/perf_test.h" |
| 17 #include "chrome/test/perf/perf_ui_test_suite.h" |
17 #include "chrome/test/ui/ui_perf_test.h" | 18 #include "chrome/test/ui/ui_perf_test.h" |
18 #include "net/base/net_util.h" | 19 #include "net/base/net_util.h" |
19 #include "ui/gfx/rect.h" | 20 #include "ui/gfx/rect.h" |
20 | 21 |
21 using base::TimeDelta; | 22 using base::TimeDelta; |
22 | 23 |
23 namespace { | 24 namespace { |
24 | 25 |
25 class NewTabUIStartupTest : public UIPerfTest { | 26 class NewTabUIStartupTest : public UIPerfTest { |
26 public: | 27 public: |
27 NewTabUIStartupTest() { | 28 NewTabUIStartupTest() { |
28 show_window_ = true; | 29 show_window_ = true; |
29 } | 30 } |
30 | 31 |
31 virtual void SetUp() {} | 32 virtual void SetUp() {} |
32 virtual void TearDown() {} | 33 virtual void TearDown() {} |
33 | 34 |
34 static const int kNumCycles = 5; | 35 static const int kNumCycles = 5; |
35 | 36 |
36 void PrintTimings(const char* label, TimeDelta timings[kNumCycles], | 37 void PrintTimings(const char* label, TimeDelta timings[kNumCycles], |
37 bool important) { | 38 bool important) { |
38 std::string times; | 39 std::string times; |
39 for (int i = 0; i < kNumCycles; ++i) | 40 for (int i = 0; i < kNumCycles; ++i) |
40 base::StringAppendF(×, "%.2f,", timings[i].InMillisecondsF()); | 41 base::StringAppendF(×, "%.2f,", timings[i].InMillisecondsF()); |
41 perf_test::PrintResultList( | 42 perf_test::PrintResultList( |
42 "new_tab", std::string(), label, times, "ms", important); | 43 "new_tab", std::string(), label, times, "ms", important); |
43 } | 44 } |
44 | 45 |
45 void InitProfile(UITestBase::ProfileType profile_type) { | 46 void InitProfile(PerfUITestSuite::ProfileType profile_type) { |
46 profile_type_ = profile_type; | |
47 | |
48 // Install the location of the test profile file. | 47 // Install the location of the test profile file. |
49 set_template_user_data(UITest::ComputeTypicalUserDataSource( | 48 set_template_user_data( |
50 profile_type)); | 49 PerfUITestSuite::GetPathForProfileType(profile_type)); |
51 } | 50 } |
52 | 51 |
53 // Run the test, by bringing up a browser and timing the new tab startup. | 52 // Run the test, by bringing up a browser and timing the new tab startup. |
54 // |want_warm| is true if we should output warm-disk timings, false if | 53 // |want_warm| is true if we should output warm-disk timings, false if |
55 // we should report cold timings. | 54 // we should report cold timings. |
56 void RunStartupTest(const char* label, bool want_warm, bool important, | 55 void RunStartupTest(const char* label, bool want_warm, bool important, |
57 UITestBase::ProfileType profile_type) { | 56 PerfUITestSuite::ProfileType profile_type) { |
58 InitProfile(profile_type); | 57 InitProfile(profile_type); |
59 | 58 |
60 TimeDelta timings[kNumCycles]; | 59 TimeDelta timings[kNumCycles]; |
61 for (int i = 0; i < kNumCycles; ++i) { | 60 for (int i = 0; i < kNumCycles; ++i) { |
62 UITest::SetUp(); | 61 UITest::SetUp(); |
63 | 62 |
64 // Switch to the "new tab" tab, which should be any new tab after the | 63 // Switch to the "new tab" tab, which should be any new tab after the |
65 // first (the first is about:blank). | 64 // first (the first is about:blank). |
66 scoped_refptr<BrowserProxy> window(automation()->GetBrowserWindow(0)); | 65 scoped_refptr<BrowserProxy> window(automation()->GetBrowserWindow(0)); |
67 ASSERT_TRUE(window.get()); | 66 ASSERT_TRUE(window.get()); |
(...skipping 27 matching lines...) Expand all Loading... |
95 timings[i] = TimeDelta::FromMilliseconds(load_time); | 94 timings[i] = TimeDelta::FromMilliseconds(load_time); |
96 | 95 |
97 window = NULL; | 96 window = NULL; |
98 UITest::TearDown(); | 97 UITest::TearDown(); |
99 } | 98 } |
100 | 99 |
101 PrintTimings(label, timings, important); | 100 PrintTimings(label, timings, important); |
102 } | 101 } |
103 | 102 |
104 void RunNewTabTimingTest() { | 103 void RunNewTabTimingTest() { |
105 InitProfile(UITestBase::DEFAULT_THEME); | 104 InitProfile(PerfUITestSuite::DEFAULT_THEME); |
106 | 105 |
107 TimeDelta scriptstart_times[kNumCycles]; | 106 TimeDelta scriptstart_times[kNumCycles]; |
108 TimeDelta domcontentloaded_times[kNumCycles]; | 107 TimeDelta domcontentloaded_times[kNumCycles]; |
109 TimeDelta onload_times[kNumCycles]; | 108 TimeDelta onload_times[kNumCycles]; |
110 | 109 |
111 for (int i = 0; i < kNumCycles; ++i) { | 110 for (int i = 0; i < kNumCycles; ++i) { |
112 UITest::SetUp(); | 111 UITest::SetUp(); |
113 | 112 |
114 // Switch to the "new tab" tab, which should be any new tab after the | 113 // Switch to the "new tab" tab, which should be any new tab after the |
115 // first (the first is about:blank). | 114 // first (the first is about:blank). |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
156 PrintTimings("domcontent_loaded", domcontentloaded_times, | 155 PrintTimings("domcontent_loaded", domcontentloaded_times, |
157 false /* important */); | 156 false /* important */); |
158 PrintTimings("onload", onload_times, false /* important */); | 157 PrintTimings("onload", onload_times, false /* important */); |
159 } | 158 } |
160 }; | 159 }; |
161 | 160 |
162 // FLAKY: http://crbug.com/69940 | 161 // FLAKY: http://crbug.com/69940 |
163 TEST_F(NewTabUIStartupTest, DISABLED_PerfRefCold) { | 162 TEST_F(NewTabUIStartupTest, DISABLED_PerfRefCold) { |
164 UseReferenceBuild(); | 163 UseReferenceBuild(); |
165 RunStartupTest("tab_cold_ref", false /* cold */, true /* important */, | 164 RunStartupTest("tab_cold_ref", false /* cold */, true /* important */, |
166 UITestBase::DEFAULT_THEME); | 165 PerfUITestSuite::DEFAULT_THEME); |
167 } | 166 } |
168 | 167 |
169 // FLAKY: http://crbug.com/69940 | 168 // FLAKY: http://crbug.com/69940 |
170 TEST_F(NewTabUIStartupTest, DISABLED_PerfCold) { | 169 TEST_F(NewTabUIStartupTest, DISABLED_PerfCold) { |
171 RunStartupTest("tab_cold", false /* cold */, true /* important */, | 170 RunStartupTest("tab_cold", false /* cold */, true /* important */, |
172 UITestBase::DEFAULT_THEME); | 171 PerfUITestSuite::DEFAULT_THEME); |
173 } | 172 } |
174 | 173 |
175 // FLAKY: http://crbug.com/69940 | 174 // FLAKY: http://crbug.com/69940 |
176 TEST_F(NewTabUIStartupTest, DISABLED_PerfRefWarm) { | 175 TEST_F(NewTabUIStartupTest, DISABLED_PerfRefWarm) { |
177 UseReferenceBuild(); | 176 UseReferenceBuild(); |
178 RunStartupTest("tab_warm_ref", true /* warm */, true /* not important */, | 177 RunStartupTest("tab_warm_ref", true /* warm */, true /* not important */, |
179 UITestBase::DEFAULT_THEME); | 178 PerfUITestSuite::DEFAULT_THEME); |
180 } | 179 } |
181 | 180 |
182 // FLAKY: http://crbug.com/69940 | 181 // FLAKY: http://crbug.com/69940 |
183 TEST_F(NewTabUIStartupTest, DISABLED_PerfWarm) { | 182 TEST_F(NewTabUIStartupTest, DISABLED_PerfWarm) { |
184 RunStartupTest("tab_warm", true /* warm */, true /* not important */, | 183 RunStartupTest("tab_warm", true /* warm */, true /* not important */, |
185 UITestBase::DEFAULT_THEME); | 184 PerfUITestSuite::DEFAULT_THEME); |
186 } | 185 } |
187 | 186 |
188 // FLAKY: http://crbug.com/69940 | 187 // FLAKY: http://crbug.com/69940 |
189 TEST_F(NewTabUIStartupTest, DISABLED_ComplexThemeCold) { | 188 TEST_F(NewTabUIStartupTest, DISABLED_ComplexThemeCold) { |
190 RunStartupTest("tab_complex_theme_cold", false /* cold */, | 189 RunStartupTest("tab_complex_theme_cold", false /* cold */, |
191 false /* not important */, | 190 false /* not important */, |
192 UITestBase::COMPLEX_THEME); | 191 PerfUITestSuite::COMPLEX_THEME); |
193 } | 192 } |
194 | 193 |
195 // FLAKY: http://crbug.com/69940 | 194 // FLAKY: http://crbug.com/69940 |
196 TEST_F(NewTabUIStartupTest, DISABLED_NewTabTimingTestsCold) { | 195 TEST_F(NewTabUIStartupTest, DISABLED_NewTabTimingTestsCold) { |
197 RunNewTabTimingTest(); | 196 RunNewTabTimingTest(); |
198 } | 197 } |
199 | 198 |
200 } // namespace | 199 } // namespace |
OLD | NEW |