Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(212)

Side by Side Diff: chrome/test/startup/feature_startup_test.cc

Issue 113229: Add new tab startup test to the linux & mac build. (Closed)
Patch Set: make the test actually run Created 11 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 <windows.h>
6
7 #include "app/win_util.h"
8 #include "base/file_util.h" 5 #include "base/file_util.h"
9 #include "base/path_service.h" 6 #include "base/path_service.h"
10 #include "base/perftimer.h" 7 #include "base/perftimer.h"
11 #include "base/time.h" 8 #include "base/time.h"
12 #include "chrome/app/chrome_dll_resource.h" 9 #include "chrome/app/chrome_dll_resource.h"
13 #include "chrome/common/chrome_paths.h" 10 #include "chrome/common/chrome_paths.h"
14 #include "chrome/test/automation/browser_proxy.h" 11 #include "chrome/test/automation/browser_proxy.h"
15 #include "chrome/test/ui/ui_test.h" 12 #include "chrome/test/ui/ui_test.h"
16 #include "net/base/net_util.h" 13 #include "net/base/net_util.h"
17 14
18 using base::TimeDelta; 15 using base::TimeDelta;
19 16
20 namespace { 17 namespace {
21 18
22 // Returns the directory name where the "typical" user data is that we use for 19 // Returns the directory name where the "typical" user data is that we use for
23 // testing. 20 // testing.
24 std::wstring ComputeTypicalUserDataSource() { 21 FilePath ComputeTypicalUserDataSource() {
25 std::wstring source_history_file; 22 FilePath source_history_file;
26 EXPECT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, 23 EXPECT_TRUE(PathService::Get(chrome::DIR_TEST_DATA,
27 &source_history_file)); 24 &source_history_file));
28 file_util::AppendToPath(&source_history_file, L"profiles"); 25 source_history_file = source_history_file.AppendASCII("profiles")
29 file_util::AppendToPath(&source_history_file, L"typical_history"); 26 .AppendASCII("typical_history");
30 return source_history_file; 27 return source_history_file;
31 } 28 }
32 29
33 class NewTabUIStartupTest : public UITest { 30 class NewTabUIStartupTest : public UITest {
34 public: 31 public:
35 NewTabUIStartupTest() { 32 NewTabUIStartupTest() {
36 show_window_ = true; 33 show_window_ = true;
37 } 34 }
38 35
39 void SetUp() {} 36 void SetUp() {}
40 void TearDown() {} 37 void TearDown() {}
41 38
42 static const int kNumCycles = 5; 39 static const int kNumCycles = 5;
43 40
44 void PrintTimings(const char* label, TimeDelta timings[kNumCycles], 41 void PrintTimings(const char* label, TimeDelta timings[kNumCycles],
45 bool important) { 42 bool important) {
46 std::string times; 43 std::string times;
47 for (int i = 0; i < kNumCycles; ++i) 44 for (int i = 0; i < kNumCycles; ++i)
48 StringAppendF(&times, "%.2f,", timings[i].InMillisecondsF()); 45 StringAppendF(&times, "%.2f,", timings[i].InMillisecondsF());
49 PrintResultList("new_tab", "", label, times, "ms", important); 46 PrintResultList("new_tab", "", label, times, "ms", important);
50 } 47 }
51 48
52 // Run the test, by bringing up a browser and timing the new tab startup. 49 // Run the test, by bringing up a browser and timing the new tab startup.
53 // |want_warm| is true if we should output warm-disk timings, false if 50 // |want_warm| is true if we should output warm-disk timings, false if
54 // we should report cold timings. 51 // we should report cold timings.
55 void RunStartupTest(const char* label, bool want_warm, bool important) { 52 void RunStartupTest(const char* label, bool want_warm, bool important) {
56 // Install the location of the test profile file. 53 // Install the location of the test profile file.
57 set_template_user_data(ComputeTypicalUserDataSource()); 54 set_template_user_data(ComputeTypicalUserDataSource().ToWStringHack());
58 55
59 TimeDelta timings[kNumCycles]; 56 TimeDelta timings[kNumCycles];
60 for (int i = 0; i < kNumCycles; ++i) { 57 for (int i = 0; i < kNumCycles; ++i) {
61 UITest::SetUp(); 58 UITest::SetUp();
62 59
63 // 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
64 // first (the first is about:blank). 61 // first (the first is about:blank).
65 BrowserProxy* window = automation()->GetBrowserWindow(0); 62 BrowserProxy* window = automation()->GetBrowserWindow(0);
66 ASSERT_TRUE(window); 63 ASSERT_TRUE(window);
67 int tab_count = -1; 64 int tab_count = -1;
(...skipping 27 matching lines...) Expand all
95 92
96 // TODO(pamg): run these tests with a reference build? 93 // TODO(pamg): run these tests with a reference build?
97 94
98 TEST_F(NewTabUIStartupTest, PerfCold) { 95 TEST_F(NewTabUIStartupTest, PerfCold) {
99 RunStartupTest("tab_cold", false /* not cold */, true /* important */); 96 RunStartupTest("tab_cold", false /* not cold */, true /* important */);
100 } 97 }
101 98
102 TEST_F(NewTabUIStartupTest, DISABLED_PerfWarm) { 99 TEST_F(NewTabUIStartupTest, DISABLED_PerfWarm) {
103 RunStartupTest("tab_warm", true /* cold */, false /* not important */); 100 RunStartupTest("tab_warm", true /* cold */, false /* not important */);
104 } 101 }
OLDNEW
« chrome/browser/automation/automation_provider.cc ('K') | « chrome/chrome.gyp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698