| 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/test/automation/browser_proxy.h" | 13 #include "chrome/test/automation/browser_proxy.h" |
| 13 #include "chrome/test/automation/window_proxy.h" | 14 #include "chrome/test/automation/window_proxy.h" |
| 14 #include "chrome/test/ui/ui_test.h" | 15 #include "chrome/test/ui/ui_test.h" |
| 15 #include "net/base/net_util.h" | 16 #include "net/base/net_util.h" |
| 16 | 17 |
| 17 using base::TimeDelta; | 18 using base::TimeDelta; |
| 18 | 19 |
| 19 namespace { | 20 namespace { |
| 20 | 21 |
| 21 // Returns the directory name where the "typical" user data is that we use for | 22 // Returns the directory name where the "typical" user data is that we use for |
| (...skipping 26 matching lines...) Expand all Loading... |
| 48 PrintResultList("new_tab", "", label, times, "ms", important); | 49 PrintResultList("new_tab", "", label, times, "ms", important); |
| 49 } | 50 } |
| 50 | 51 |
| 51 // 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. |
| 52 // |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 |
| 53 // we should report cold timings. | 54 // we should report cold timings. |
| 54 void RunStartupTest(const char* label, bool want_warm, bool important) { | 55 void RunStartupTest(const char* label, bool want_warm, bool important) { |
| 55 // Install the location of the test profile file. | 56 // Install the location of the test profile file. |
| 56 set_template_user_data(ComputeTypicalUserDataSource().ToWStringHack()); | 57 set_template_user_data(ComputeTypicalUserDataSource().ToWStringHack()); |
| 57 | 58 |
| 59 // Disable the first run notification because it has an animation which |
| 60 // masks any real performance regressions. |
| 61 launch_arguments_.AppendSwitch(switches::kDisableNewTabFirstRun); |
| 62 |
| 58 TimeDelta timings[kNumCycles]; | 63 TimeDelta timings[kNumCycles]; |
| 59 for (int i = 0; i < kNumCycles; ++i) { | 64 for (int i = 0; i < kNumCycles; ++i) { |
| 60 UITest::SetUp(); | 65 UITest::SetUp(); |
| 61 | 66 |
| 62 // Switch to the "new tab" tab, which should be any new tab after the | 67 // Switch to the "new tab" tab, which should be any new tab after the |
| 63 // first (the first is about:blank). | 68 // first (the first is about:blank). |
| 64 scoped_refptr<BrowserProxy> window(automation()->GetBrowserWindow(0)); | 69 scoped_refptr<BrowserProxy> window(automation()->GetBrowserWindow(0)); |
| 65 ASSERT_TRUE(window.get()); | 70 ASSERT_TRUE(window.get()); |
| 66 | 71 |
| 67 // We resize the window so that we hit the normal layout of the NTP and | 72 // We resize the window so that we hit the normal layout of the NTP and |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 102 // TODO(pamg): run these tests with a reference build? | 107 // TODO(pamg): run these tests with a reference build? |
| 103 TEST_F(NewTabUIStartupTest, PerfCold) { | 108 TEST_F(NewTabUIStartupTest, PerfCold) { |
| 104 RunStartupTest("tab_cold", false /* cold */, true /* important */); | 109 RunStartupTest("tab_cold", false /* cold */, true /* important */); |
| 105 } | 110 } |
| 106 | 111 |
| 107 TEST_F(NewTabUIStartupTest, DISABLED_PerfWarm) { | 112 TEST_F(NewTabUIStartupTest, DISABLED_PerfWarm) { |
| 108 RunStartupTest("tab_warm", true /* warm */, false /* not important */); | 113 RunStartupTest("tab_warm", true /* warm */, false /* not important */); |
| 109 } | 114 } |
| 110 | 115 |
| 111 } // namespace | 116 } // namespace |
| OLD | NEW |