diff options
author | tony@chromium.org <tony@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-10-07 17:01:44 +0000 |
---|---|---|
committer | tony@chromium.org <tony@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-10-07 17:01:44 +0000 |
commit | 84abba65c18ad3746066129990ad46421675d5a2 (patch) | |
tree | a3e6193d74f96ab728b3baeeb0a35fdd3dd47e47 /chrome/test | |
parent | 0c882b2856e5851765ce89f63d337902a3e6b823 (diff) | |
download | chromium_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')
-rw-r--r-- | chrome/test/automation/automation_messages_internal.h | 6 | ||||
-rw-r--r-- | chrome/test/automation/automation_proxy.cc | 6 | ||||
-rw-r--r-- | chrome/test/automation/automation_proxy.h | 4 | ||||
-rw-r--r-- | chrome/test/startup/feature_startup_test.cc | 86 | ||||
-rw-r--r-- | chrome/test/startup/startup_test.cc | 2 | ||||
-rw-r--r-- | chrome/test/ui/ui_test.cc | 2 | ||||
-rw-r--r-- | chrome/test/ui/ui_test.h | 22 |
7 files changed, 105 insertions, 23 deletions
diff --git a/chrome/test/automation/automation_messages_internal.h b/chrome/test/automation/automation_messages_internal.h index c9d04dd..5d009b5 100644 --- a/chrome/test/automation/automation_messages_internal.h +++ b/chrome/test/automation/automation_messages_internal.h @@ -1113,4 +1113,10 @@ IPC_BEGIN_MESSAGES(Automation) int /* tab_handle */, int /* The font size */) + // Returns a metric event duration that was last recorded. Returns -1 if the + // event hasn't occurred yet. + IPC_SYNC_MESSAGE_ROUTED1_1(AutomationMsg_GetMetricEventDuration, + std::string /* event_name */, + int /* duration ms */) + IPC_END_MESSAGES(Automation) diff --git a/chrome/test/automation/automation_proxy.cc b/chrome/test/automation/automation_proxy.cc index a039ffb3..69a363c 100644 --- a/chrome/test/automation/automation_proxy.cc +++ b/chrome/test/automation/automation_proxy.cc @@ -342,6 +342,12 @@ bool AutomationProxy::IsURLDisplayed(GURL url) { return false; } +bool AutomationProxy::GetMetricEventDuration(const std::string& event_name, + int* duration_ms) { + return Send(new AutomationMsg_GetMetricEventDuration(0, event_name, + duration_ms)); +} + bool AutomationProxy::SetFilteredInet(bool enabled) { return Send(new AutomationMsg_SetFilteredInet(0, enabled)); } diff --git a/chrome/test/automation/automation_proxy.h b/chrome/test/automation/automation_proxy.h index dac3bc3..ce3ff17 100644 --- a/chrome/test/automation/automation_proxy.h +++ b/chrome/test/automation/automation_proxy.h @@ -124,6 +124,10 @@ class AutomationProxy : public IPC::Channel::Listener, // Returns true if one of the tabs in any window displays given url. bool IsURLDisplayed(GURL url); + // Get the duration of the last |event_name| in the browser. Returns + // false if the IPC failed to send. + bool GetMetricEventDuration(const std::string& event_name, int* duration_ms); + // Returns the BrowserProxy for the browser window at the given index, // transferring ownership of the pointer to the caller. // On failure, returns NULL. 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 diff --git a/chrome/test/ui/ui_test.cc b/chrome/test/ui/ui_test.cc index 30ed274..8308ca0 100644 --- a/chrome/test/ui/ui_test.cc +++ b/chrome/test/ui/ui_test.cc @@ -924,7 +924,7 @@ void UITest::RewritePreferencesFile(const FilePath& user_data_dir) { } // static -FilePath UITest::ComputeTypicalUserDataSource(int profile_type) { +FilePath UITest::ComputeTypicalUserDataSource(ProfileType profile_type) { FilePath source_history_file; EXPECT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &source_history_file)); diff --git a/chrome/test/ui/ui_test.h b/chrome/test/ui/ui_test.h index 5c45e8c..c87ffe1 100644 --- a/chrome/test/ui/ui_test.h +++ b/chrome/test/ui/ui_test.h @@ -362,9 +362,18 @@ class UITest : public testing::Test { log_level_ = value; } + // Profile theme type choices. + typedef enum { + DEFAULT_THEME = 0, + COMPLEX_THEME = 1, + NATIVE_THEME = 2, + CUSTOM_FRAME = 3, + CUSTOM_FRAME_NATIVE_THEME = 4, + } ProfileType; + // Returns the directory name where the "typical" user data is that we use // for testing. - static FilePath ComputeTypicalUserDataSource(int profile_type); + static FilePath ComputeTypicalUserDataSource(ProfileType profile_type); // Rewrite the preferences file to point to the proper image directory. static void RewritePreferencesFile(const FilePath& user_data_dir); @@ -443,15 +452,6 @@ class UITest : public testing::Test { void StartHttpServer(const FilePath& root_directory); void StopHttpServer(); - // Profile theme type choices. - typedef enum { - DEFAULT_THEME = 0, - COMPLEX_THEME = 1, - NATIVE_THEME = 2, - CUSTOM_FRAME = 3, - CUSTOM_FRAME_NATIVE_THEME = 4, - } ProfileType; - private: // Check that no processes related to Chrome exist, displaying // the given message if any do. @@ -518,7 +518,7 @@ class UITest : public testing::Test { bool use_existing_browser_; // Duplicate of the static version. // Default value comes from static. bool enable_file_cookies_; // Enable file cookies, default is true. - int profile_type_; // Are we using a profile with a + ProfileType profile_type_; // Are we using a profile with a // complex theme? private: |