| 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/gfx/rect.h" | 6 #include "base/gfx/rect.h" |
| 7 #include "base/path_service.h" | 7 #include "base/path_service.h" |
| 8 #include "base/perftimer.h" | 8 #include "base/perftimer.h" |
| 9 #include "base/time.h" | 9 #include "base/time.h" |
| 10 #include "chrome/app/chrome_dll_resource.h" | 10 #include "chrome/app/chrome_dll_resource.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/browser_proxy.h" | 13 #include "chrome/test/automation/browser_proxy.h" |
| 14 #include "chrome/test/automation/window_proxy.h" | 14 #include "chrome/test/automation/window_proxy.h" |
| 15 #include "chrome/test/ui/ui_test.h" | 15 #include "chrome/test/ui/ui_test.h" |
| 16 #include "net/base/net_util.h" | 16 #include "net/base/net_util.h" |
| 17 | 17 |
| 18 using base::TimeDelta; | 18 using base::TimeDelta; |
| 19 | 19 |
| 20 namespace { | 20 namespace { |
| 21 | 21 |
| 22 // Returns the directory name where the "typical" user data is that we use for | |
| 23 // testing. | |
| 24 FilePath ComputeTypicalUserDataSource() { | |
| 25 FilePath source_history_file; | |
| 26 EXPECT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, | |
| 27 &source_history_file)); | |
| 28 source_history_file = source_history_file.AppendASCII("profiles") | |
| 29 .AppendASCII("typical_history"); | |
| 30 return source_history_file; | |
| 31 } | |
| 32 | |
| 33 class NewTabUIStartupTest : public UITest { | 22 class NewTabUIStartupTest : public UITest { |
| 34 public: | 23 public: |
| 35 NewTabUIStartupTest() { | 24 NewTabUIStartupTest() { |
| 36 show_window_ = true; | 25 show_window_ = true; |
| 37 } | 26 } |
| 38 | 27 |
| 39 void SetUp() {} | 28 void SetUp() {} |
| 40 void TearDown() {} | 29 void TearDown() {} |
| 41 | 30 |
| 42 static const int kNumCycles = 5; | 31 static const int kNumCycles = 5; |
| 43 | 32 |
| 44 void PrintTimings(const char* label, TimeDelta timings[kNumCycles], | 33 void PrintTimings(const char* label, TimeDelta timings[kNumCycles], |
| 45 bool important) { | 34 bool important) { |
| 46 std::string times; | 35 std::string times; |
| 47 for (int i = 0; i < kNumCycles; ++i) | 36 for (int i = 0; i < kNumCycles; ++i) |
| 48 StringAppendF(×, "%.2f,", timings[i].InMillisecondsF()); | 37 StringAppendF(×, "%.2f,", timings[i].InMillisecondsF()); |
| 49 PrintResultList("new_tab", "", label, times, "ms", important); | 38 PrintResultList("new_tab", "", label, times, "ms", important); |
| 50 } | 39 } |
| 51 | 40 |
| 52 // Run the test, by bringing up a browser and timing the new tab startup. | 41 // 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 | 42 // |want_warm| is true if we should output warm-disk timings, false if |
| 54 // we should report cold timings. | 43 // we should report cold timings. |
| 55 void RunStartupTest(const char* label, bool want_warm, bool important) { | 44 void RunStartupTest(const char* label, bool want_warm, bool important, |
| 45 int profile_type) { |
| 56 // Install the location of the test profile file. | 46 // Install the location of the test profile file. |
| 57 set_template_user_data(ComputeTypicalUserDataSource().ToWStringHack()); | 47 set_template_user_data(UITest::ComputeTypicalUserDataSource( |
| 48 profile_type).ToWStringHack()); |
| 58 | 49 |
| 59 // Disable the first run notification because it has an animation which | 50 // Disable the first run notification because it has an animation which |
| 60 // masks any real performance regressions. | 51 // masks any real performance regressions. |
| 61 launch_arguments_.AppendSwitch(switches::kDisableNewTabFirstRun); | 52 launch_arguments_.AppendSwitch(switches::kDisableNewTabFirstRun); |
| 62 | 53 |
| 63 TimeDelta timings[kNumCycles]; | 54 TimeDelta timings[kNumCycles]; |
| 64 for (int i = 0; i < kNumCycles; ++i) { | 55 for (int i = 0; i < kNumCycles; ++i) { |
| 65 UITest::SetUp(); | 56 UITest::SetUp(); |
| 66 | 57 |
| 67 // Switch to the "new tab" tab, which should be any new tab after the | 58 // Switch to the "new tab" tab, which should be any new tab after the |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 99 window = NULL; | 90 window = NULL; |
| 100 UITest::TearDown(); | 91 UITest::TearDown(); |
| 101 } | 92 } |
| 102 | 93 |
| 103 PrintTimings(label, timings, important); | 94 PrintTimings(label, timings, important); |
| 104 } | 95 } |
| 105 }; | 96 }; |
| 106 | 97 |
| 107 // TODO(pamg): run these tests with a reference build? | 98 // TODO(pamg): run these tests with a reference build? |
| 108 TEST_F(NewTabUIStartupTest, PerfCold) { | 99 TEST_F(NewTabUIStartupTest, PerfCold) { |
| 109 RunStartupTest("tab_cold", false /* cold */, true /* important */); | 100 RunStartupTest("tab_cold", false /* cold */, true /* important */, |
| 101 UITest::DEFAULT_THEME); |
| 110 } | 102 } |
| 111 | 103 |
| 112 TEST_F(NewTabUIStartupTest, DISABLED_PerfWarm) { | 104 TEST_F(NewTabUIStartupTest, DISABLED_PerfWarm) { |
| 113 RunStartupTest("tab_warm", true /* warm */, false /* not important */); | 105 RunStartupTest("tab_warm", true /* warm */, false /* not important */, |
| 106 UITest::DEFAULT_THEME); |
| 107 } |
| 108 |
| 109 TEST_F(NewTabUIStartupTest, ComplexTheme) { |
| 110 RunStartupTest("tab_complex_theme_cold", false /* cold */, |
| 111 false /* not important */, |
| 112 UITest::COMPLEX_THEME); |
| 114 } | 113 } |
| 115 | 114 |
| 116 } // namespace | 115 } // namespace |
| OLD | NEW |