summaryrefslogtreecommitdiffstats
path: root/chrome/browser
diff options
context:
space:
mode:
authorsky@google.com <sky@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-02-24 17:22:43 +0000
committersky@google.com <sky@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-02-24 17:22:43 +0000
commit28d9c672a6fcf2d93c487ffb9b855c4d7fe58d22 (patch)
treed054790c8671b83c6bf339836231af818e7fc367 /chrome/browser
parentd3bd376a7f7ed527f387ab8dbff1b8c832a55354 (diff)
downloadchromium_src-28d9c672a6fcf2d93c487ffb9b855c4d7fe58d22.zip
chromium_src-28d9c672a6fcf2d93c487ffb9b855c4d7fe58d22.tar.gz
chromium_src-28d9c672a6fcf2d93c487ffb9b855c4d7fe58d22.tar.bz2
Attempt at fixing flakeyness when running session restore ui tests in
purify. I believe the ui test isn't waiting for the session restore to complete, so that when the ui test does various asserts the state of the browser is wrong. BUG=6495 TEST=covered by tests Review URL: http://codereview.chromium.org/28051 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@10268 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser')
-rw-r--r--chrome/browser/browser_init.cc11
-rw-r--r--chrome/browser/sessions/session_restore_uitest.cc20
2 files changed, 20 insertions, 11 deletions
diff --git a/chrome/browser/browser_init.cc b/chrome/browser/browser_init.cc
index 047103a..c690ad8 100644
--- a/chrome/browser/browser_init.cc
+++ b/chrome/browser/browser_init.cc
@@ -450,11 +450,18 @@ bool BrowserInit::ProcessCommandLine(
// compatibility with the old testing code
// If there are any loose parameters, we expect each one to generate a
// new tab; if there are none then we get one homepage tab.
+ int expected_tab_count = 1;
+ if (command_line.HasSwitch(switches::kRestoreLastSession)) {
+ StringToInt(command_line.GetSwitchValue(switches::kRestoreLastSession),
+ &expected_tab_count);
+ } else {
+ expected_tab_count =
+ std::max(1, static_cast<int>(command_line.GetLooseValues().size()));
+ }
CreateAutomationProvider<TestingAutomationProvider>(
testing_channel_id,
profile,
- std::max(static_cast<int>(command_line.GetLooseValues().size()),
- 1));
+ static_cast<size_t>(expected_tab_count));
}
#endif
}
diff --git a/chrome/browser/sessions/session_restore_uitest.cc b/chrome/browser/sessions/session_restore_uitest.cc
index 737f239..cd00a93 100644
--- a/chrome/browser/sessions/session_restore_uitest.cc
+++ b/chrome/browser/sessions/session_restore_uitest.cc
@@ -5,6 +5,7 @@
#include "base/command_line.h"
#include "base/file_util.h"
#include "base/scoped_ptr.h"
+#include "base/string_util.h"
#include "chrome/app/chrome_dll_resource.h"
#include "chrome/common/chrome_paths.h"
#include "chrome/common/chrome_switches.h"
@@ -33,12 +34,13 @@ class SessionRestoreUITest : public UITest {
path_prefix.AppendASCII("bot3.html"));
}
- virtual void QuitBrowserAndRestore() {
+ virtual void QuitBrowserAndRestore(int expected_tab_count) {
UITest::TearDown();
clear_profile_ = false;
- launch_arguments_.AppendSwitch(switches::kRestoreLastSession);
+ launch_arguments_.AppendSwitchWithValue(switches::kRestoreLastSession,
+ IntToWString(expected_tab_count));
UITest::SetUp();
}
@@ -96,7 +98,7 @@ TEST_F(SessionRestoreUITest, Basic) {
NavigateToURL(url1);
NavigateToURL(url2);
- QuitBrowserAndRestore();
+ QuitBrowserAndRestore(1);
// NOTE: Don't use GetActiveWindow here, when run with the screen locked
// active windows returns NULL.
@@ -120,7 +122,7 @@ TEST_F(SessionRestoreUITest, RestoresForwardAndBackwardNavs) {
scoped_ptr<TabProxy> active_tab(GetActiveTab());
ASSERT_TRUE(active_tab->GoBack());
- QuitBrowserAndRestore();
+ QuitBrowserAndRestore(1);
// NOTE: Don't use GetActiveWindow here, when run with the screen locked
// active windows returns NULL.
@@ -158,7 +160,7 @@ TEST_F(SessionRestoreUITest, RestoresCrossSiteForwardAndBackwardNavs) {
scoped_ptr<TabProxy> active_tab(GetActiveTab());
ASSERT_TRUE(active_tab->GoBack());
- QuitBrowserAndRestore();
+ QuitBrowserAndRestore(1);
// NOTE: Don't use GetActiveWindow here, when run with the screen locked
// active windows returns NULL.
@@ -201,7 +203,7 @@ TEST_F(SessionRestoreUITest, TwoTabsSecondSelected) {
ASSERT_TRUE(browser_proxy->AppendTab(url2));
- QuitBrowserAndRestore();
+ QuitBrowserAndRestore(2);
browser_proxy.reset();
ASSERT_TRUE(automation()->GetBrowserWindowCount(&window_count) &&
@@ -246,7 +248,7 @@ TEST_F(SessionRestoreUITest, ClosedTabStaysClosed) {
scoped_ptr<TabProxy> active_tab(browser_proxy->GetActiveTab());
active_tab->Close(true);
- QuitBrowserAndRestore();
+ QuitBrowserAndRestore(1);
browser_proxy.reset();
tab_proxy.reset();
@@ -328,7 +330,7 @@ TEST_F(SessionRestoreUITest, DISABLED_TwoWindowsCloseOneRestoreOnlyOne) {
// Restart and make sure we have only one window with one tab and the url
// is url1.
- QuitBrowserAndRestore();
+ QuitBrowserAndRestore(1);
AssertOneWindowWithOneTab();
@@ -412,7 +414,7 @@ TEST_F(SessionRestoreUITest, DISABLED_ShareProcessesOnRestore) {
// Restart.
browser_proxy.reset();
last_tab.reset();
- QuitBrowserAndRestore();
+ QuitBrowserAndRestore(3);
// Wait for each tab to finish being restored, then make sure the process
// count matches.