summaryrefslogtreecommitdiffstats
path: root/chrome/test
diff options
context:
space:
mode:
authorhuanr@chromium.org <huanr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-04-14 22:18:06 +0000
committerhuanr@chromium.org <huanr@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-04-14 22:18:06 +0000
commit5c3fcc1d176ce541896e77f39508c36b940331f4 (patch)
tree22d827bd0a64ad9f289c75da2e34c2973534b204 /chrome/test
parent366a4f184426cf32a93cc8c80eaf1ef353a83622 (diff)
downloadchromium_src-5c3fcc1d176ce541896e77f39508c36b940331f4.zip
chromium_src-5c3fcc1d176ce541896e77f39508c36b940331f4.tar.gz
chromium_src-5c3fcc1d176ce541896e77f39508c36b940331f4.tar.bz2
Remove the usage of GetLastActiveBrowserWindow
as the function is flakey. BUG=10501 Review URL: http://codereview.chromium.org/67139 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@13709 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/test')
-rw-r--r--chrome/test/automated_ui_tests/automated_ui_test_base.cc10
-rw-r--r--chrome/test/automated_ui_tests/automated_ui_tests.cc27
-rw-r--r--chrome/test/automation/automation_proxy.h7
3 files changed, 19 insertions, 25 deletions
diff --git a/chrome/test/automated_ui_tests/automated_ui_test_base.cc b/chrome/test/automated_ui_tests/automated_ui_test_base.cc
index 5ad7f97..9b3c631 100644
--- a/chrome/test/automated_ui_tests/automated_ui_test_base.cc
+++ b/chrome/test/automated_ui_tests/automated_ui_test_base.cc
@@ -61,13 +61,8 @@ bool AutomatedUITestBase::NewTab() {
}
bool AutomatedUITestBase::RunCommandAsync(int browser_command) {
- scoped_ptr<BrowserProxy> last_browser;
BrowserProxy* browser = active_browser();
if (NULL == browser) {
- last_browser.reset(automation()->GetLastActiveBrowserWindow());
- browser = last_browser.get();
- }
- if (NULL == browser) {
LogErrorMessage("browser_window_not_found");
return false;
}
@@ -80,13 +75,8 @@ bool AutomatedUITestBase::RunCommandAsync(int browser_command) {
}
bool AutomatedUITestBase::RunCommand(int browser_command) {
- scoped_ptr<BrowserProxy> last_browser;
BrowserProxy* browser = active_browser();
if (NULL == browser) {
- last_browser.reset(automation()->GetLastActiveBrowserWindow());
- browser = last_browser.get();
- }
- if (NULL == browser) {
LogErrorMessage("browser_window_not_found");
return false;
}
diff --git a/chrome/test/automated_ui_tests/automated_ui_tests.cc b/chrome/test/automated_ui_tests/automated_ui_tests.cc
index e162b62..7c17706 100644
--- a/chrome/test/automated_ui_tests/automated_ui_tests.cc
+++ b/chrome/test/automated_ui_tests/automated_ui_tests.cc
@@ -195,6 +195,7 @@ void AutomatedUITest::RunAutomatedUITest() {
// Try and start up again.
CloseBrowserAndServer();
LaunchBrowserAndServer();
+ set_active_browser(automation()->GetBrowserWindow(0));
if (DidCrash(true)) {
no_errors = false;
// We crashed again, so skip to the end of the this command.
@@ -340,6 +341,7 @@ bool AutomatedUITest::DoAction(const std::string & action) {
did_complete_action = ShowBookmarkBar();
} else if (LowerCaseEqualsASCII(action, "setup")) {
LaunchBrowserAndServer();
+ set_active_browser(automation()->GetBrowserWindow(0));
did_complete_action = true;
} else if (LowerCaseEqualsASCII(action, "sleep")) {
// This is for debugging, it probably shouldn't be used real tests.
@@ -417,8 +419,8 @@ bool AutomatedUITest::ChangeEncoding() {
bool AutomatedUITest::CloseActiveTab() {
bool return_value = false;
- scoped_ptr<BrowserProxy> browser(automation()->GetLastActiveBrowserWindow());
- if (browser.get() == NULL) {
+ BrowserProxy* browser = active_browser();
+ if (browser == NULL) {
AddErrorAttribute("browser_window_not_found");
return false;
}
@@ -478,8 +480,8 @@ bool AutomatedUITest::JavaScriptDebugger() {
}
bool AutomatedUITest::Navigate() {
- scoped_ptr<BrowserProxy> browser(automation()->GetLastActiveBrowserWindow());
- if (browser.get() == NULL) {
+ BrowserProxy* browser = active_browser();
+ if (browser == NULL) {
AddErrorAttribute("browser_window_not_found");
return false;
}
@@ -676,8 +678,8 @@ bool AutomatedUITest::FuzzyTestDialog(int num_actions) {
}
bool AutomatedUITest::ForceCrash() {
- scoped_ptr<BrowserProxy> browser(automation()->GetLastActiveBrowserWindow());
- if (browser.get() == NULL) {
+ BrowserProxy* browser = active_browser();
+ if (browser == NULL) {
AddErrorAttribute("browser_window_not_found");
return false;
}
@@ -693,19 +695,20 @@ bool AutomatedUITest::ForceCrash() {
}
bool AutomatedUITest::DragActiveTab(bool drag_right, bool drag_out) {
- scoped_ptr<BrowserProxy> browser(automation()->GetLastActiveBrowserWindow());
+ BrowserProxy* browser = active_browser();
+ if (browser == NULL) {
+ AddErrorAttribute("browser_window_not_found");
+ return false;
+ }
+
scoped_ptr<WindowProxy> window(
- GetAndActivateWindowForBrowser(browser.get()));
+ GetAndActivateWindowForBrowser(browser));
if (window.get() == NULL) {
AddErrorAttribute("active_window_not_found");
return false;
}
bool is_timeout;
- if (browser.get() == NULL) {
- AddErrorAttribute("browser_window_not_found");
- return false;
- }
int tab_count;
browser->GetTabCountWithTimeout(&tab_count,
action_max_timeout_ms(),
diff --git a/chrome/test/automation/automation_proxy.h b/chrome/test/automation/automation_proxy.h
index e229001..e9d55d1 100644
--- a/chrome/test/automation/automation_proxy.h
+++ b/chrome/test/automation/automation_proxy.h
@@ -128,9 +128,10 @@ class AutomationProxy : public IPC::Channel::Listener,
// Returns the BrowserProxy for the browser window which was last active,
// transferring ownership of the pointer to the caller.
- // If there was no last active browser window, or the last active browser
- // window no longer exists (for example, if it was closed), returns
- // GetBrowserWindow(0).
+ // TODO: If there was no last active browser window, or the last active
+ // browser window no longer exists (for example, if it was closed),
+ // returns GetBrowserWindow(0). See crbug.com/10501. As for now this
+ // function is flakey.
BrowserProxy* GetLastActiveBrowserWindow();
// Returns the WindowProxy for the currently active window, transferring