summaryrefslogtreecommitdiffstats
path: root/chrome/test/startup
diff options
context:
space:
mode:
authortony@chromium.org <tony@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-10-07 17:01:44 +0000
committertony@chromium.org <tony@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-10-07 17:01:44 +0000
commit84abba65c18ad3746066129990ad46421675d5a2 (patch)
treea3e6193d74f96ab728b3baeeb0a35fdd3dd47e47 /chrome/test/startup
parent0c882b2856e5851765ce89f63d337902a3e6b823 (diff)
downloadchromium_src-84abba65c18ad3746066129990ad46421675d5a2.zip
chromium_src-84abba65c18ad3746066129990ad46421675d5a2.tar.gz
chromium_src-84abba65c18ad3746066129990ad46421675d5a2.tar.bz2
Revert "Revert "Add startup tests that log start script, domcontentloaded, and onload.""
This reverts commit r28209 and relands r28199. The failure seems to have been flaky (it passed on the other bots and on the following run). I want to try to land again. If it fails again, I'll disable the test. TBR=mattm Review URL: http://codereview.chromium.org/268003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@28268 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/test/startup')
-rw-r--r--chrome/test/startup/feature_startup_test.cc86
-rw-r--r--chrome/test/startup/startup_test.cc2
2 files changed, 77 insertions, 11 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 */,
diff --git a/chrome/test/startup/startup_test.cc b/chrome/test/startup/startup_test.cc
index 69035d8..7e52741 100644
--- a/chrome/test/startup/startup_test.cc
+++ b/chrome/test/startup/startup_test.cc
@@ -50,7 +50,7 @@ class StartupTest : public UITest {
}
void RunStartupTest(const char* graph, const char* trace,
- bool test_cold, bool important, int profile_type) {
+ bool test_cold, bool important, UITest::ProfileType profile_type) {
profile_type_ = profile_type;
// Sets the profile data for the run. For now, this is only used for