summaryrefslogtreecommitdiffstats
path: root/chrome/test/startup/feature_startup_test.cc
diff options
context:
space:
mode:
Diffstat (limited to 'chrome/test/startup/feature_startup_test.cc')
-rw-r--r--chrome/test/startup/feature_startup_test.cc86
1 files changed, 76 insertions, 10 deletions
diff --git a/chrome/test/startup/feature_startup_test.cc b/chrome/test/startup/feature_startup_test.cc
index 574b283..5743e35 100644
--- a/chrome/test/startup/feature_startup_test.cc
+++ b/chrome/test/startup/feature_startup_test.cc
@@ -39,11 +39,7 @@ class NewTabUIStartupTest : public UITest {
PrintResultList("new_tab", "", label, times, "ms", important);
}
- // Run the test, by bringing up a browser and timing the new tab startup.
- // |want_warm| is true if we should output warm-disk timings, false if
- // we should report cold timings.
- void RunStartupTest(const char* label, bool want_warm, bool important,
- int profile_type) {
+ void InitProfile(UITest::ProfileType profile_type) {
profile_type_ = profile_type;
// Install the location of the test profile file.
@@ -53,6 +49,14 @@ class NewTabUIStartupTest : public UITest {
// Disable the first run notification because it has an animation which
// masks any real performance regressions.
launch_arguments_.AppendSwitch(switches::kDisableNewTabFirstRun);
+ }
+
+ // Run the test, by bringing up a browser and timing the new tab startup.
+ // |want_warm| is true if we should output warm-disk timings, false if
+ // we should report cold timings.
+ void RunStartupTest(const char* label, bool want_warm, bool important,
+ UITest::ProfileType profile_type) {
+ InitProfile(profile_type);
TimeDelta timings[kNumCycles];
for (int i = 0; i < kNumCycles; ++i) {
@@ -66,9 +70,9 @@ class NewTabUIStartupTest : public UITest {
// We resize the window so that we hit the normal layout of the NTP and
// not the small layout mode.
#if defined(OS_WIN)
-// TODO(port): SetBounds returns false when not implemented.
-// It is OK to comment out the resize since it will still be useful to test the
-// default size of the window.
+ // TODO(port): SetBounds returns false when not implemented.
+ // It is OK to comment out the resize since it will still be useful to
+ // test the default size of the window.
ASSERT_TRUE(window->GetWindow().get()->SetBounds(gfx::Rect(1000, 1000)));
#endif
int tab_count = -1;
@@ -80,15 +84,14 @@ class NewTabUIStartupTest : public UITest {
ASSERT_TRUE(window->WaitForTabCountToBecome(2, 5000));
int load_time;
ASSERT_TRUE(automation()->WaitForInitialNewTabUILoad(&load_time));
- timings[i] = TimeDelta::FromMilliseconds(load_time);
if (want_warm) {
// Bring up a second tab, now that we've already shown one tab.
window->ApplyAccelerator(IDC_NEW_TAB);
ASSERT_TRUE(window->WaitForTabCountToBecome(3, 5000));
ASSERT_TRUE(automation()->WaitForInitialNewTabUILoad(&load_time));
- timings[i] = TimeDelta::FromMilliseconds(load_time);
}
+ timings[i] = TimeDelta::FromMilliseconds(load_time);
window = NULL;
UITest::TearDown();
@@ -96,6 +99,65 @@ class NewTabUIStartupTest : public UITest {
PrintTimings(label, timings, important);
}
+
+ void RunNewTabTimingTest() {
+ InitProfile(UITest::DEFAULT_THEME);
+
+ TimeDelta scriptstart_times[kNumCycles];
+ TimeDelta domcontentloaded_times[kNumCycles];
+ TimeDelta onload_times[kNumCycles];
+
+ for (int i = 0; i < kNumCycles; ++i) {
+ UITest::SetUp();
+
+ // Switch to the "new tab" tab, which should be any new tab after the
+ // first (the first is about:blank).
+ scoped_refptr<BrowserProxy> window(automation()->GetBrowserWindow(0));
+ ASSERT_TRUE(window.get());
+
+ // We resize the window so that we hit the normal layout of the NTP and
+ // not the small layout mode.
+#if defined(OS_WIN)
+ // TODO(port): SetBounds returns false when not implemented.
+ // It is OK to comment out the resize since it will still be useful to
+ // test the default size of the window.
+ ASSERT_TRUE(window->GetWindow().get()->SetBounds(gfx::Rect(1000, 1000)));
+#endif
+ int tab_count = -1;
+ ASSERT_TRUE(window->GetTabCount(&tab_count));
+ ASSERT_EQ(1, tab_count);
+
+ // Hit ctl-t and wait for the tab to load.
+ window->ApplyAccelerator(IDC_NEW_TAB);
+ ASSERT_TRUE(window->WaitForTabCountToBecome(2, 5000));
+ int duration;
+ ASSERT_TRUE(automation()->WaitForInitialNewTabUILoad(&duration));
+
+ // Collect the timing information.
+ ASSERT_TRUE(automation()->GetMetricEventDuration("NewTab.ScriptStart",
+ &duration));
+ ASSERT_NE(duration, -1);
+ scriptstart_times[i] = TimeDelta::FromMilliseconds(duration);
+
+ ASSERT_TRUE(automation()->GetMetricEventDuration(
+ "NewTab.DOMContentLoaded", &duration));
+ ASSERT_NE(duration, -1);
+ domcontentloaded_times[i] = TimeDelta::FromMilliseconds(duration);
+
+ ASSERT_TRUE(automation()->GetMetricEventDuration("NewTab.Onload",
+ &duration));
+ ASSERT_NE(duration, -1);
+ onload_times[i] = TimeDelta::FromMilliseconds(duration);
+
+ window = NULL;
+ UITest::TearDown();
+ }
+
+ PrintTimings("script_start", scriptstart_times, false /* important */);
+ PrintTimings("domcontent_loaded", domcontentloaded_times,
+ false /* important */);
+ PrintTimings("onload", onload_times, false /* important */);
+ }
};
// TODO(pamg): run these tests with a reference build?
@@ -115,6 +177,10 @@ TEST_F(NewTabUIStartupTest, ComplexThemeCold) {
UITest::COMPLEX_THEME);
}
+TEST_F(NewTabUIStartupTest, NewTabTimingTestsCold) {
+ RunNewTabTimingTest();
+}
+
#if defined(OS_LINUX)
TEST_F(NewTabUIStartupTest, GtkThemeCold) {
RunStartupTest("tab_gtk_theme_cold", false /* cold */,