OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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/time.h" | 8 #include "base/time.h" |
9 #include "chrome/app/chrome_dll_resource.h" | 9 #include "chrome/app/chrome_dll_resource.h" |
10 #include "chrome/common/chrome_paths.h" | 10 #include "chrome/common/chrome_paths.h" |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
52 void RunStartupTest(const char* label, bool want_warm, bool important) { | 52 void RunStartupTest(const char* label, bool want_warm, bool important) { |
53 // Install the location of the test profile file. | 53 // Install the location of the test profile file. |
54 set_template_user_data(ComputeTypicalUserDataSource().ToWStringHack()); | 54 set_template_user_data(ComputeTypicalUserDataSource().ToWStringHack()); |
55 | 55 |
56 TimeDelta timings[kNumCycles]; | 56 TimeDelta timings[kNumCycles]; |
57 for (int i = 0; i < kNumCycles; ++i) { | 57 for (int i = 0; i < kNumCycles; ++i) { |
58 UITest::SetUp(); | 58 UITest::SetUp(); |
59 | 59 |
60 // Switch to the "new tab" tab, which should be any new tab after the | 60 // Switch to the "new tab" tab, which should be any new tab after the |
61 // first (the first is about:blank). | 61 // first (the first is about:blank). |
62 BrowserProxy* window = automation()->GetBrowserWindow(0); | 62 scoped_refptr<BrowserProxy> window(automation()->GetBrowserWindow(0)); |
63 ASSERT_TRUE(window); | 63 ASSERT_TRUE(window.get()); |
64 int tab_count = -1; | 64 int tab_count = -1; |
65 ASSERT_TRUE(window->GetTabCount(&tab_count)); | 65 ASSERT_TRUE(window->GetTabCount(&tab_count)); |
66 ASSERT_EQ(1, tab_count); | 66 ASSERT_EQ(1, tab_count); |
67 | 67 |
68 // Hit ctl-t and wait for the tab to load. | 68 // Hit ctl-t and wait for the tab to load. |
69 window->ApplyAccelerator(IDC_NEW_TAB); | 69 window->ApplyAccelerator(IDC_NEW_TAB); |
70 ASSERT_TRUE(window->WaitForTabCountToBecome(2, 5000)); | 70 ASSERT_TRUE(window->WaitForTabCountToBecome(2, 5000)); |
71 int load_time; | 71 int load_time; |
72 ASSERT_TRUE(automation()->WaitForInitialNewTabUILoad(&load_time)); | 72 ASSERT_TRUE(automation()->WaitForInitialNewTabUILoad(&load_time)); |
73 timings[i] = TimeDelta::FromMilliseconds(load_time); | 73 timings[i] = TimeDelta::FromMilliseconds(load_time); |
74 | 74 |
75 if (want_warm) { | 75 if (want_warm) { |
76 // Bring up a second tab, now that we've already shown one tab. | 76 // Bring up a second tab, now that we've already shown one tab. |
77 window->ApplyAccelerator(IDC_NEW_TAB); | 77 window->ApplyAccelerator(IDC_NEW_TAB); |
78 ASSERT_TRUE(window->WaitForTabCountToBecome(3, 5000)); | 78 ASSERT_TRUE(window->WaitForTabCountToBecome(3, 5000)); |
79 ASSERT_TRUE(automation()->WaitForInitialNewTabUILoad(&load_time)); | 79 ASSERT_TRUE(automation()->WaitForInitialNewTabUILoad(&load_time)); |
80 timings[i] = TimeDelta::FromMilliseconds(load_time); | 80 timings[i] = TimeDelta::FromMilliseconds(load_time); |
81 } | 81 } |
82 | 82 |
83 delete window; | 83 window = NULL; |
84 UITest::TearDown(); | 84 UITest::TearDown(); |
85 } | 85 } |
86 | 86 |
87 PrintTimings(label, timings, important); | 87 PrintTimings(label, timings, important); |
88 } | 88 } |
89 }; | 89 }; |
90 | 90 |
91 // TODO(pamg): run these tests with a reference build? | 91 // TODO(pamg): run these tests with a reference build? |
92 TEST_F(NewTabUIStartupTest, PerfCold) { | 92 TEST_F(NewTabUIStartupTest, PerfCold) { |
93 RunStartupTest("tab_cold", false /* cold */, true /* important */); | 93 RunStartupTest("tab_cold", false /* cold */, true /* important */); |
94 } | 94 } |
95 | 95 |
96 TEST_F(NewTabUIStartupTest, DISABLED_PerfWarm) { | 96 TEST_F(NewTabUIStartupTest, DISABLED_PerfWarm) { |
97 RunStartupTest("tab_warm", true /* warm */, false /* not important */); | 97 RunStartupTest("tab_warm", true /* warm */, false /* not important */); |
98 } | 98 } |
99 | 99 |
100 } // namespace | 100 } // namespace |
OLD | NEW |