diff options
author | stoyan@chromium.org <stoyan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-05-28 19:12:46 +0000 |
---|---|---|
committer | stoyan@chromium.org <stoyan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-05-28 19:12:46 +0000 |
commit | 802376eb9aacca5284b76da93face73a9488bdb6 (patch) | |
tree | 705226a6750fed9a1429aaf07fe9c0a03303c759 /chrome/test/automated_ui_tests | |
parent | 319d4ae6c8b2236fa7e0acf218c533a5a93af5a6 (diff) | |
download | chromium_src-802376eb9aacca5284b76da93face73a9488bdb6.zip chromium_src-802376eb9aacca5284b76da93face73a9488bdb6.tar.gz chromium_src-802376eb9aacca5284b76da93face73a9488bdb6.tar.bz2 |
Make automation proxy objects to ref_counted. That allows to process async notifications directly in channel background thread. Add support for listener-less ChannelProxy.
BUG=none
TEST=none
Review URL: http://codereview.chromium.org/113722
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@17093 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/test/automated_ui_tests')
5 files changed, 27 insertions, 26 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 abd0cf3..bb96fd32 100644 --- a/chrome/test/automated_ui_tests/automated_ui_test_base.cc +++ b/chrome/test/automated_ui_tests/automated_ui_test_base.cc @@ -2,7 +2,6 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "base/scoped_ptr.h" #include "chrome/app/chrome_dll_resource.h" #include "chrome/test/automated_ui_tests/automated_ui_test_base.h" #include "chrome/test/automation/browser_proxy.h" @@ -66,8 +65,8 @@ bool AutomatedUITestBase::CloseActiveWindow() { LogErrorMessage("Application closed unexpectedly."); return false; } - BrowserProxy* browser = automation()->FindNormalBrowserWindow(); - if (browser == NULL) { + scoped_refptr<BrowserProxy> browser(automation()->FindNormalBrowserWindow()); + if (!browser.get()) { LogErrorMessage("Can't find browser window."); return false; } @@ -88,7 +87,7 @@ bool AutomatedUITestBase::GoOffTheRecord() { } bool AutomatedUITestBase::OpenAndActivateNewBrowserWindow( - BrowserProxy** previous_browser) { + scoped_refptr<BrowserProxy>* previous_browser) { if (!automation()->OpenNewBrowserWindow(SW_SHOWNORMAL)) { LogWarningMessage("failed_to_open_new_browser_window"); return false; @@ -97,7 +96,7 @@ bool AutomatedUITestBase::OpenAndActivateNewBrowserWindow( automation()->GetBrowserWindowCount(&num_browser_windows); // Get the most recently opened browser window and activate the tab // in order to activate this browser window. - scoped_ptr<BrowserProxy> browser( + scoped_refptr<BrowserProxy> browser( automation()->GetBrowserWindow(num_browser_windows - 1)); if (browser.get() == NULL) { LogErrorMessage("browser_window_not_found"); @@ -110,14 +109,17 @@ bool AutomatedUITestBase::OpenAndActivateNewBrowserWindow( return false; } + if (previous_browser) { + DCHECK(previous_browser->get() == NULL); + active_browser_.swap(*previous_browser); + } + active_browser_.swap(browser); - if (previous_browser) - *previous_browser = browser.release(); return true; } bool AutomatedUITestBase::Navigate(const GURL& url) { - scoped_ptr<TabProxy> tab(GetActiveTab()); + scoped_refptr<TabProxy> tab(GetActiveTab()); if (tab.get() == NULL) { LogErrorMessage("active_tab_not_found"); return false; @@ -176,7 +178,7 @@ bool AutomatedUITestBase::RunCommand(int browser_command) { return true; } -TabProxy* AutomatedUITestBase::GetActiveTab() { +scoped_refptr<TabProxy> AutomatedUITestBase::GetActiveTab() { BrowserProxy* browser = active_browser(); if (browser == NULL) { LogErrorMessage("browser_window_not_found"); @@ -184,7 +186,7 @@ TabProxy* AutomatedUITestBase::GetActiveTab() { } bool did_timeout; - TabProxy* tab = + scoped_refptr<TabProxy> tab = browser->GetActiveTabWithTimeout(action_max_timeout_ms(), &did_timeout); if (did_timeout) return NULL; diff --git a/chrome/test/automated_ui_tests/automated_ui_test_base.h b/chrome/test/automated_ui_tests/automated_ui_test_base.h index 731bf40..4724f83 100644 --- a/chrome/test/automated_ui_tests/automated_ui_test_base.h +++ b/chrome/test/automated_ui_tests/automated_ui_test_base.h @@ -62,7 +62,8 @@ class AutomatedUITestBase : public UITest { // If optional parameter previous_browser is passed in, it is set to be the // previous browser window when new window is successfully created, and the // caller owns previous_browser. - bool OpenAndActivateNewBrowserWindow(BrowserProxy** previous_browser); + bool OpenAndActivateNewBrowserWindow( + scoped_refptr<BrowserProxy>* previous_browser); // Reload the active tab. // Returns true if successful, false otherwise. @@ -89,7 +90,7 @@ class AutomatedUITestBase : public UITest { bool RunCommand(int browser_command); void set_active_browser(BrowserProxy* browser) { - active_browser_.reset(browser); + active_browser_ = browser; } BrowserProxy* active_browser() const { return active_browser_.get(); } @@ -97,9 +98,9 @@ class AutomatedUITestBase : public UITest { // create a corresponding TabProxy and transfer the ownership to caller. // If success return the pointer to the newly created TabProxy and the // caller owns the TabProxy. Return NULL otherwise. - TabProxy* GetActiveTab(); + scoped_refptr<TabProxy> GetActiveTab(); private: - scoped_ptr<BrowserProxy> active_browser_; + scoped_refptr<BrowserProxy> active_browser_; DISALLOW_COPY_AND_ASSIGN(AutomatedUITestBase); }; diff --git a/chrome/test/automated_ui_tests/automated_ui_test_test.cc b/chrome/test/automated_ui_tests/automated_ui_test_test.cc index bbdd042..3110aae 100644 --- a/chrome/test/automated_ui_tests/automated_ui_test_test.cc +++ b/chrome/test/automated_ui_tests/automated_ui_test_test.cc @@ -104,9 +104,8 @@ TEST_F(AutomatedUITestBase, OpenBrowserWindow) { active_browser()->GetTabCount(&tab_count); ASSERT_EQ(1, tab_count); - BrowserProxy* previous_browser; - ASSERT_TRUE(OpenAndActivateNewBrowserWindow(&previous_browser)); - scoped_ptr<BrowserProxy>browser_1(previous_browser); + scoped_refptr<BrowserProxy> browser_1; + ASSERT_TRUE(OpenAndActivateNewBrowserWindow(&browser_1)); automation()->GetBrowserWindowCount(&num_browser_windows); ASSERT_EQ(2, num_browser_windows); active_browser()->GetTabCount(&tab_count); @@ -117,8 +116,8 @@ TEST_F(AutomatedUITestBase, OpenBrowserWindow) { active_browser()->GetTabCount(&tab_count); ASSERT_EQ(2, tab_count); - ASSERT_TRUE(OpenAndActivateNewBrowserWindow(&previous_browser)); - scoped_ptr<BrowserProxy>browser_2(previous_browser); + scoped_refptr<BrowserProxy> browser_2; + ASSERT_TRUE(OpenAndActivateNewBrowserWindow(&browser_2)); automation()->GetBrowserWindowCount(&num_browser_windows); ASSERT_EQ(3, num_browser_windows); active_browser()->GetTabCount(&tab_count); diff --git a/chrome/test/automated_ui_tests/automated_ui_tests.cc b/chrome/test/automated_ui_tests/automated_ui_tests.cc index d935387..23c1ae4 100644 --- a/chrome/test/automated_ui_tests/automated_ui_tests.cc +++ b/chrome/test/automated_ui_tests/automated_ui_tests.cc @@ -591,7 +591,7 @@ bool AutomatedUITest::FuzzyTestDialog(int num_actions) { } bool AutomatedUITest::ForceCrash() { - scoped_ptr<TabProxy> tab(GetActiveTab()); + scoped_refptr<TabProxy> tab(GetActiveTab()); GURL test_url("about:crash"); bool did_timeout; tab->NavigateToURLWithTimeout(test_url, kDebuggingTimeoutMsec, &did_timeout); @@ -609,7 +609,7 @@ bool AutomatedUITest::DragActiveTab(bool drag_right, bool drag_out) { return false; } - scoped_ptr<WindowProxy> window( + scoped_refptr<WindowProxy> window( GetAndActivateWindowForBrowser(browser)); if (window.get() == NULL) { AddErrorAttribute("active_window_not_found"); @@ -688,7 +688,7 @@ bool AutomatedUITest::DragActiveTab(bool drag_right, bool drag_out) { return true; } -WindowProxy* AutomatedUITest::GetAndActivateWindowForBrowser( +scoped_refptr<WindowProxy> AutomatedUITest::GetAndActivateWindowForBrowser( BrowserProxy* browser) { bool did_timeout; if (!browser->BringToFrontWithTimeout(action_max_timeout_ms(), @@ -697,13 +697,12 @@ WindowProxy* AutomatedUITest::GetAndActivateWindowForBrowser( return NULL; } - WindowProxy* window = browser->GetWindow(); - return window; + return browser->GetWindow(); } bool AutomatedUITest::SimulateKeyPressInActiveWindow(wchar_t key, int flags) { - scoped_ptr<WindowProxy> window(automation()->GetActiveWindow()); + scoped_refptr<WindowProxy> window(automation()->GetActiveWindow()); if (window.get() == NULL) { AddErrorAttribute("active_window_not_found"); return false; diff --git a/chrome/test/automated_ui_tests/automated_ui_tests.h b/chrome/test/automated_ui_tests/automated_ui_tests.h index 39c12c4..9b35349 100644 --- a/chrome/test/automated_ui_tests/automated_ui_tests.h +++ b/chrome/test/automated_ui_tests/automated_ui_tests.h @@ -342,7 +342,7 @@ class AutomatedUITest : public AutomatedUITestBase { // Returns the WindowProxy associated with the given BrowserProxy // (transferring ownership of the pointer to the caller) and brings that // window to the top. - WindowProxy* GetAndActivateWindowForBrowser(BrowserProxy* browser); + scoped_refptr<WindowProxy> GetAndActivateWindowForBrowser(BrowserProxy* browser); // Calls SimulateOSKeyPress on the active window. Simulates a key press at // the OS level. |key| is the key pressed and |flags| specifies which |