diff options
-rw-r--r-- | chrome/browser/browser_focus_uitest.cc | 24 | ||||
-rw-r--r-- | chrome/browser/browser_uitest.cc | 3 | ||||
-rw-r--r-- | chrome/browser/renderer_host/resource_dispatcher_host_uitest.cc | 4 | ||||
-rw-r--r-- | chrome/browser/views/constrained_window_impl_interactive_uitest.cc | 11 | ||||
-rw-r--r-- | chrome/browser/views/find_bar_win_interactive_uitest.cc | 3 | ||||
-rw-r--r-- | chrome/browser/views/tabs/tab_dragging_test.cc | 15 | ||||
-rw-r--r-- | chrome/common/pref_service_uitest.cc | 3 | ||||
-rw-r--r-- | chrome/test/automated_ui_tests/automated_ui_tests.cc | 4 | ||||
-rw-r--r-- | chrome/test/automation/automation_proxy.cc | 82 | ||||
-rw-r--r-- | chrome/test/automation/automation_proxy.h | 21 | ||||
-rw-r--r-- | chrome/test/automation/automation_proxy_uitest.cc | 16 | ||||
-rw-r--r-- | chrome/test/automation/browser_proxy.cc | 49 | ||||
-rw-r--r-- | chrome/test/automation/browser_proxy.h | 14 | ||||
-rw-r--r-- | chrome/test/automation/window_proxy.cc | 31 | ||||
-rw-r--r-- | chrome/test/automation/window_proxy.h | 8 | ||||
-rw-r--r-- | chrome/test/reliability/page_load_test.cc | 3 | ||||
-rw-r--r-- | chrome/test/ui/omnibox_uitest.cc | 5 |
17 files changed, 136 insertions, 160 deletions
diff --git a/chrome/browser/browser_focus_uitest.cc b/chrome/browser/browser_focus_uitest.cc index 160c3ab..dcc00f6 100644 --- a/chrome/browser/browser_focus_uitest.cc +++ b/chrome/browser/browser_focus_uitest.cc @@ -68,8 +68,7 @@ TEST_F(BrowserFocusTest, BrowsersRememberFocus) { scoped_ptr<WindowProxy> window(automation()->GetActiveWindow()); ASSERT_TRUE(window.get() != NULL); - scoped_ptr<BrowserProxy> browser(automation()-> - GetBrowserForWindow(window.get())); + scoped_ptr<BrowserProxy> browser(window->GetBrowser()); ASSERT_TRUE(browser.get() != NULL); int focused_view_id; @@ -103,8 +102,7 @@ TEST_F(BrowserFocusTest, BrowsersRememberFocus) { EXPECT_TRUE(automation()->OpenNewBrowserWindow(SW_SHOWNORMAL)); scoped_ptr<WindowProxy> new_window(automation()->GetActiveWindow()); ASSERT_TRUE(new_window.get() != NULL); - scoped_ptr<BrowserProxy> new_browser(automation()-> - GetBrowserForWindow(new_window.get())); + scoped_ptr<BrowserProxy> new_browser(new_window->GetBrowser()); ASSERT_TRUE(new_browser.get() != NULL); // Let's make sure we have 2 different browser windows. @@ -138,8 +136,7 @@ TEST_F(BrowserFocusTest, TabsRememberFocus) { scoped_ptr<WindowProxy> window(automation()->GetActiveWindow()); ASSERT_TRUE(window.get() != NULL); - scoped_ptr<BrowserProxy> browser( - automation()->GetBrowserForWindow(window.get())); + scoped_ptr<BrowserProxy> browser(window->GetBrowser()); ASSERT_TRUE(browser.get() != NULL); // First we navigate to our test page. @@ -209,16 +206,14 @@ TEST_F(BrowserFocusTest, BackgroundBrowserDontStealFocus) { scoped_ptr<WindowProxy> window(automation()->GetActiveWindow()); ASSERT_TRUE(window.get() != NULL); - scoped_ptr<BrowserProxy> browser( - automation()->GetBrowserForWindow(window.get())); + scoped_ptr<BrowserProxy> browser(window->GetBrowser()); ASSERT_TRUE(browser.get() != NULL); // Open a new browser window. EXPECT_TRUE(automation()->OpenNewBrowserWindow(SW_SHOWNORMAL)); scoped_ptr<WindowProxy> new_window(automation()->GetActiveWindow()); ASSERT_TRUE(window.get() != NULL); - scoped_ptr<BrowserProxy> new_browser( - automation()->GetBrowserForWindow(new_window.get())); + scoped_ptr<BrowserProxy> new_browser(new_window->GetBrowser()); ASSERT_TRUE(new_browser.get() != NULL); GURL steal_focus_url = server->TestServerPageW(kStealFocusPage); @@ -249,8 +244,7 @@ TEST_F(BrowserFocusTest, LocationBarLockFocus) { scoped_ptr<WindowProxy> window(automation()->GetActiveWindow()); ASSERT_TRUE(window.get() != NULL); - scoped_ptr<BrowserProxy> browser( - automation()->GetBrowserForWindow(window.get())); + scoped_ptr<BrowserProxy> browser(window->GetBrowser()); ASSERT_TRUE(browser.get() != NULL); // Click on the location bar. @@ -283,8 +277,7 @@ TEST_F(BrowserFocusTest, FocusTraversal) { scoped_ptr<WindowProxy> window(automation()->GetActiveWindow()); ASSERT_TRUE(window.get() != NULL); - scoped_ptr<BrowserProxy> browser( - automation()->GetBrowserForWindow(window.get())); + scoped_ptr<BrowserProxy> browser(window->GetBrowser()); ASSERT_TRUE(browser.get() != NULL); // Click on the location bar. @@ -358,8 +351,7 @@ TEST_F(BrowserFocusTest, FindFocusTest) { scoped_ptr<WindowProxy> window(automation()->GetActiveWindow()); ASSERT_TRUE(window.get() != NULL); - scoped_ptr<BrowserProxy> browser( - automation()->GetBrowserForWindow(window.get())); + scoped_ptr<BrowserProxy> browser(window->GetBrowser()); ASSERT_TRUE(browser.get() != NULL); // Press Ctrl+F, which will make the Find box open and request focus. diff --git a/chrome/browser/browser_uitest.cc b/chrome/browser/browser_uitest.cc index 1037a89..f64abe7 100644 --- a/chrome/browser/browser_uitest.cc +++ b/chrome/browser/browser_uitest.cc @@ -32,8 +32,7 @@ class BrowserTest : public UITest { protected: HWND GetMainWindow() { scoped_ptr<BrowserProxy> browser(automation()->GetBrowserWindow(0)); - scoped_ptr<WindowProxy> window( - automation()->GetWindowForBrowser(browser.get())); + scoped_ptr<WindowProxy> window(browser->GetWindow()); HWND window_handle; EXPECT_TRUE(window->GetHWND(&window_handle)); diff --git a/chrome/browser/renderer_host/resource_dispatcher_host_uitest.cc b/chrome/browser/renderer_host/resource_dispatcher_host_uitest.cc index 0ff6044..49cafcd 100644 --- a/chrome/browser/renderer_host/resource_dispatcher_host_uitest.cc +++ b/chrome/browser/renderer_host/resource_dispatcher_host_uitest.cc @@ -69,8 +69,8 @@ TEST_F(ResourceDispatcherTest, SniffNoContentTypeNoData) { EXPECT_EQ(1, GetTabCount()); // Make sure the download shelf is not showing. - scoped_ptr<BrowserProxy> window(automation()->GetBrowserWindow(0)); - scoped_ptr<TabProxy> dl_tab(window->GetTab(0)); + scoped_ptr<BrowserProxy> browser(automation()->GetBrowserWindow(0)); + scoped_ptr<TabProxy> dl_tab(browser->GetTab(0)); ASSERT_TRUE(dl_tab.get()); bool visible = false; diff --git a/chrome/browser/views/constrained_window_impl_interactive_uitest.cc b/chrome/browser/views/constrained_window_impl_interactive_uitest.cc index 4eaef9ed..51d12f7 100644 --- a/chrome/browser/views/constrained_window_impl_interactive_uitest.cc +++ b/chrome/browser/views/constrained_window_impl_interactive_uitest.cc @@ -31,7 +31,7 @@ class InteractiveConstrainedWindowTest : public UITest { browser_.reset(automation()->GetBrowserWindow(0)); ASSERT_TRUE(browser_.get()); - window_.reset(automation()->GetWindowForBrowser(browser_.get())); + window_.reset(browser_->GetWindow()); ASSERT_TRUE(window_.get()); tab_.reset(browser_->GetTab(0)); @@ -71,8 +71,7 @@ TEST_F(InteractiveConstrainedWindowTest, TestOpenAndResizeTo) { scoped_ptr<BrowserProxy> popup_browser(automation()->GetBrowserWindow(1)); ASSERT_TRUE(popup_browser != NULL); - scoped_ptr<WindowProxy> popup_window( - automation()->GetWindowForBrowser(popup_browser.get())); + scoped_ptr<WindowProxy> popup_window(popup_browser->GetWindow()); ASSERT_TRUE(popup_window != NULL); // Make sure we were created with the correct width and height. @@ -187,8 +186,7 @@ TEST_F(InteractiveConstrainedWindowTest, WindowOpenWindowClosePopup) { // Make sure we have a blocked popup notification scoped_ptr<BrowserProxy> popup_browser(automation()->GetBrowserWindow(1)); ASSERT_TRUE(popup_browser.get()); - scoped_ptr<WindowProxy> popup_window( - automation()->GetWindowForBrowser(popup_browser.get())); + scoped_ptr<WindowProxy> popup_window(popup_browser->GetWindow()); ASSERT_TRUE(popup_window.get()); scoped_ptr<TabProxy> popup_tab(popup_browser->GetTab(0)); ASSERT_TRUE(popup_tab.get()); @@ -235,8 +233,7 @@ TEST_F(InteractiveConstrainedWindowTest, ShowAlertFromNormalPopup) { scoped_ptr<BrowserProxy> popup_browser(automation()->GetBrowserWindow(1)); ASSERT_TRUE(popup_browser.get()); - scoped_ptr<WindowProxy> popup_window( - automation()->GetWindowForBrowser(popup_browser.get())); + scoped_ptr<WindowProxy> popup_window(popup_browser->GetWindow()); ASSERT_TRUE(popup_window.get()); scoped_ptr<TabProxy> popup_tab(popup_browser->GetTab(0)); ASSERT_TRUE(popup_tab.get()); diff --git a/chrome/browser/views/find_bar_win_interactive_uitest.cc b/chrome/browser/views/find_bar_win_interactive_uitest.cc index c036b7c..2923f26 100644 --- a/chrome/browser/views/find_bar_win_interactive_uitest.cc +++ b/chrome/browser/views/find_bar_win_interactive_uitest.cc @@ -58,8 +58,7 @@ TEST_F(FindInPageTest, CrashEscHandlers) { scoped_ptr<BrowserProxy> browser(automation()->GetLastActiveBrowserWindow()); ASSERT_TRUE(browser.get() != NULL); - scoped_ptr<WindowProxy> window( - automation()->GetWindowForBrowser(browser.get())); + scoped_ptr<WindowProxy> window(browser->GetWindow()); ASSERT_TRUE(window.get() != NULL); // First we navigate to our test page (tab A). diff --git a/chrome/browser/views/tabs/tab_dragging_test.cc b/chrome/browser/views/tabs/tab_dragging_test.cc index 642d34f..a136046 100644 --- a/chrome/browser/views/tabs/tab_dragging_test.cc +++ b/chrome/browser/views/tabs/tab_dragging_test.cc @@ -31,8 +31,7 @@ protected: TEST_F(TabDraggingTest, Tab1Tab2) { scoped_ptr<BrowserProxy> browser(automation()->GetBrowserWindow(0)); ASSERT_TRUE(browser.get()); - scoped_ptr<WindowProxy> window( - automation()->GetWindowForBrowser(browser.get())); + scoped_ptr<WindowProxy> window(browser->GetWindow()); ASSERT_TRUE(window.get()); // Get initial tab count. @@ -135,8 +134,7 @@ TEST_F(TabDraggingTest, Tab1Tab2) { TEST_F(TabDraggingTest, Tab1Tab3) { scoped_ptr<BrowserProxy> browser(automation()->GetBrowserWindow(0)); ASSERT_TRUE(browser.get()); - scoped_ptr<WindowProxy> window( - automation()->GetWindowForBrowser(browser.get())); + scoped_ptr<WindowProxy> window(browser->GetWindow()); ASSERT_TRUE(window.get()); // Get initial tab count. @@ -246,8 +244,7 @@ TEST_F(TabDraggingTest, Tab1Tab3) { TEST_F(TabDraggingTest, Tab1Tab3Escape) { scoped_ptr<BrowserProxy> browser(automation()->GetBrowserWindow(0)); ASSERT_TRUE(browser.get()); - scoped_ptr<WindowProxy> window( - automation()->GetWindowForBrowser(browser.get())); + scoped_ptr<WindowProxy> window(browser->GetWindow()); ASSERT_TRUE(window.get()); // Get initial tab count. @@ -360,8 +357,7 @@ TEST_F(TabDraggingTest, Tab1Tab3Escape) { TEST_F(TabDraggingTest, Tab2OutOfTabStrip) { scoped_ptr<BrowserProxy> browser(automation()->GetBrowserWindow(0)); ASSERT_TRUE(browser.get()); - scoped_ptr<WindowProxy> window( - automation()->GetWindowForBrowser(browser.get())); + scoped_ptr<WindowProxy> window(browser->GetWindow()); ASSERT_TRUE(window.get()); // Get initial tab count. @@ -484,8 +480,7 @@ TEST_F(TabDraggingTest, Tab2OutOfTabStrip) { // Now check to make sure a new window has opened. scoped_ptr<BrowserProxy> browser2(automation()->GetBrowserWindow(1)); ASSERT_TRUE(browser2.get()); - scoped_ptr<WindowProxy> window2( - automation()->GetWindowForBrowser(browser2.get())); + scoped_ptr<WindowProxy> window2(browser2->GetWindow()); ASSERT_TRUE(window2.get()); // Make sure that the new window has only one tab. diff --git a/chrome/common/pref_service_uitest.cc b/chrome/common/pref_service_uitest.cc index 4ffd4e7..a1736c3 100644 --- a/chrome/common/pref_service_uitest.cc +++ b/chrome/common/pref_service_uitest.cc @@ -91,8 +91,7 @@ TEST_F(PreferenceServiceTest, PreservedWindowPlacementIsLoaded) { // Retrieve the screen rect for the launched window scoped_ptr<BrowserProxy> browser(automation()->GetBrowserWindow(0)); ASSERT_TRUE(browser.get()); - scoped_ptr<WindowProxy> window( - automation()->GetWindowForBrowser(browser.get())); + scoped_ptr<WindowProxy> window(browser->GetWindow()); HWND hWnd; ASSERT_TRUE(window->GetHWND(&hWnd)); diff --git a/chrome/test/automated_ui_tests/automated_ui_tests.cc b/chrome/test/automated_ui_tests/automated_ui_tests.cc index 81d0f0b..0a4981e 100644 --- a/chrome/test/automated_ui_tests/automated_ui_tests.cc +++ b/chrome/test/automated_ui_tests/automated_ui_tests.cc @@ -825,13 +825,13 @@ bool AutomatedUITest::DragActiveTab(bool drag_right, bool drag_out) { WindowProxy* AutomatedUITest::GetAndActivateWindowForBrowser( BrowserProxy* browser) { - WindowProxy* window = automation()->GetWindowForBrowser(browser); - bool did_timeout; if (!browser->BringToFrontWithTimeout(action_max_timeout_ms(), &did_timeout)) { AddWarningAttribute("failed_to_bring_window_to_front"); return NULL; } + + WindowProxy* window = browser->GetWindow(); return window; } diff --git a/chrome/test/automation/automation_proxy.cc b/chrome/test/automation/automation_proxy.cc index 59303b6..9f3c886 100644 --- a/chrome/test/automation/automation_proxy.cc +++ b/chrome/test/automation/automation_proxy.cc @@ -9,7 +9,6 @@ #include "base/logging.h" #include "base/ref_counted.h" #include "chrome/common/ipc_message_macros.h" -#include "chrome/test/automation/autocomplete_edit_proxy.h" #include "chrome/test/automation/automation_constants.h" #include "chrome/test/automation/automation_messages.h" #include "chrome/test/automation/browser_proxy.h" @@ -473,87 +472,6 @@ BrowserProxy* AutomationProxy::GetLastActiveBrowserWindow() { return new BrowserProxy(this, tracker_.get(), handle); } -BrowserProxy* AutomationProxy::GetBrowserForWindow(WindowProxy* window) { - return GetBrowserForWindowWithTimeout(window, INFINITE, NULL); -} - -BrowserProxy* AutomationProxy::GetBrowserForWindowWithTimeout( - WindowProxy* window, uint32 timeout_ms, bool* is_timeout) { - DCHECK(window); - if (!window->is_valid() || !window->handle()) - return false; - - IPC::Message* response = NULL; - bool succeeded = SendAndWaitForResponseWithTimeout( - new AutomationMsg_BrowserForWindowRequest(0, window->handle()), &response, - AutomationMsg_BrowserForWindowResponse::ID, timeout_ms, is_timeout); - if (!succeeded) - return NULL; - - scoped_ptr<IPC::Message> response_deleter(response); // Delete on exit. - int browser_handle = 0; - void* iter = NULL; - bool handle_ok; - succeeded = response->ReadBool(&iter, &handle_ok); - if (succeeded) - succeeded = response->ReadInt(&iter, &browser_handle); - - if (succeeded) { - return new BrowserProxy(this, tracker_.get(), browser_handle); - } else { - return NULL; - } -} - -WindowProxy* AutomationProxy::GetWindowForBrowser(BrowserProxy* browser) { - if (!browser->is_valid() || !browser->handle()) - return false; - - IPC::Message* response = NULL; - bool succeeded = SendAndWaitForResponse( - new AutomationMsg_WindowForBrowserRequest(0, browser->handle()), &response, - AutomationMsg_WindowForBrowserResponse::ID); - if (!succeeded) - return NULL; - - scoped_ptr<IPC::Message> response_deleter(response); // Delete on exit. - int window_handle; - void* iter = NULL; - bool handle_ok; - succeeded = response->ReadBool(&iter, &handle_ok); - if (succeeded) - succeeded = response->ReadInt(&iter, &window_handle); - - if (succeeded) { - return new WindowProxy(this, tracker_.get(), window_handle); - } else { - return NULL; - } -} - -AutocompleteEditProxy* AutomationProxy::GetAutocompleteEditForBrowser( - BrowserProxy* browser) { - if (!browser->is_valid() || !browser->handle()) - return NULL; - - IPC::Message* response = NULL; - if (!SendAndWaitForResponse( - new AutomationMsg_AutocompleteEditForBrowserRequest(0, browser->handle()), - &response, AutomationMsg_AutocompleteEditForBrowserResponse::ID)) - return NULL; - scoped_ptr<IPC::Message> response_deleter(response); - - int autocomplete_edit_handle; - void* iter = NULL; - bool handle_ok; - if (!response->ReadBool(&iter, &handle_ok) || - !response->ReadInt(&iter, &autocomplete_edit_handle)) - return NULL; - - return new AutocompleteEditProxy(this, tracker_.get(), - autocomplete_edit_handle); -} - bool AutomationProxy::Send(IPC::Message* message) { if (channel_.get()) return channel_->Send(message); diff --git a/chrome/test/automation/automation_proxy.h b/chrome/test/automation/automation_proxy.h index 6632604..e388333 100644 --- a/chrome/test/automation/automation_proxy.h +++ b/chrome/test/automation/automation_proxy.h @@ -141,27 +141,6 @@ class AutomationProxy : public IPC::Channel::Listener, // On failure, returns NULL. WindowProxy* GetActiveWindow(); - // Returns the browser this window corresponds to, or NULL if this window - // is not a browser. The caller owns the returned BrowserProxy. - BrowserProxy* GetBrowserForWindow(WindowProxy* window); - - // Same as GetBrowserForWindow except return NULL if response isn't received - // before the specified timeout. - BrowserProxy* GetBrowserForWindowWithTimeout(WindowProxy* window, - uint32 timeout_ms, - bool* is_timeout); - - // Returns the WindowProxy for this browser's window. It can be used to - // retreive view bounds, simulate clicks and key press events. The caller - // owns the returned WindowProxy. - // On failure, returns NULL. - WindowProxy* GetWindowForBrowser(BrowserProxy* browser); - - // Returns an AutocompleteEdit for this browser's window. It can be used to - // manipulate the omnibox. The caller owns the returned pointer. - // On failure, returns NULL. - AutocompleteEditProxy* GetAutocompleteEditForBrowser(BrowserProxy* browser); - // Tells the browser to enable or disable network request filtering. Returns // false if the message fails to send to the browser. bool SetFilteredInet(bool enabled); diff --git a/chrome/test/automation/automation_proxy_uitest.cc b/chrome/test/automation/automation_proxy_uitest.cc index add33f4..bc109885 100644 --- a/chrome/test/automation/automation_proxy_uitest.cc +++ b/chrome/test/automation/automation_proxy_uitest.cc @@ -67,8 +67,7 @@ TEST_F(AutomationProxyVisibleTest, WindowGetViewBounds) { { scoped_ptr<BrowserProxy> browser(automation()->GetBrowserWindow(0)); ASSERT_TRUE(browser.get()); - scoped_ptr<WindowProxy> window( - automation()->GetWindowForBrowser(browser.get())); + scoped_ptr<WindowProxy> window(browser->GetWindow()); ASSERT_TRUE(window.get()); scoped_ptr<TabProxy> tab1(browser->GetTab(0)); @@ -445,8 +444,7 @@ TEST_F(AutomationProxyTest, Cookies) { TEST_F(AutomationProxyTest, GetHWND) { scoped_ptr<BrowserProxy> browser(automation()->GetBrowserWindow(0)); ASSERT_TRUE(browser.get()); - scoped_ptr<WindowProxy> window( - automation()->GetWindowForBrowser(browser.get())); + scoped_ptr<WindowProxy> window(browser->GetWindow()); ASSERT_TRUE(window.get()); HWND handle; @@ -767,7 +765,7 @@ TEST_F(AutomationProxyTest, AutocompleteGetSetText) { scoped_ptr<BrowserProxy> browser(automation()->GetBrowserWindow(0)); ASSERT_TRUE(browser.get()); scoped_ptr<AutocompleteEditProxy> edit( - automation()->GetAutocompleteEditForBrowser(browser.get())); + browser->GetAutocompleteEdit()); ASSERT_TRUE(edit.get()); EXPECT_TRUE(edit->is_valid()); const std::wstring text_to_set = L"Lollerskates"; @@ -776,7 +774,7 @@ TEST_F(AutomationProxyTest, AutocompleteGetSetText) { EXPECT_TRUE(edit->GetText(&actual_text)); EXPECT_EQ(text_to_set, actual_text); scoped_ptr<AutocompleteEditProxy> edit2( - automation()->GetAutocompleteEditForBrowser(browser.get())); + browser->GetAutocompleteEdit()); EXPECT_TRUE(edit2->GetText(&actual_text)); EXPECT_EQ(text_to_set, actual_text); } @@ -785,13 +783,13 @@ TEST_F(AutomationProxyTest, AutocompleteParallelProxy) { scoped_ptr<BrowserProxy> browser1(automation()->GetBrowserWindow(0)); ASSERT_TRUE(browser1.get()); scoped_ptr<AutocompleteEditProxy> edit1( - automation()->GetAutocompleteEditForBrowser(browser1.get())); + browser1->GetAutocompleteEdit()); ASSERT_TRUE(edit1.get()); EXPECT_TRUE(browser1->ApplyAccelerator(IDC_NEW_WINDOW)); scoped_ptr<BrowserProxy> browser2(automation()->GetBrowserWindow(1)); ASSERT_TRUE(browser2.get()); scoped_ptr<AutocompleteEditProxy> edit2( - automation()->GetAutocompleteEditForBrowser(browser2.get())); + browser2->GetAutocompleteEdit()); ASSERT_TRUE(edit2.get()); EXPECT_TRUE(browser2->GetTab(0)->WaitForTabToBeRestored( action_max_timeout_ms())); @@ -810,7 +808,7 @@ TEST_F(AutomationProxyVisibleTest, AutocompleteMatchesTest) { scoped_ptr<BrowserProxy> browser(automation()->GetBrowserWindow(0)); ASSERT_TRUE(browser.get()); scoped_ptr<AutocompleteEditProxy> edit( - automation()->GetAutocompleteEditForBrowser(browser.get())); + browser->GetAutocompleteEdit()); ASSERT_TRUE(edit.get()); EXPECT_TRUE(browser->ApplyAccelerator(IDC_FOCUS_LOCATION)); EXPECT_TRUE(edit->is_valid()); diff --git a/chrome/test/automation/browser_proxy.cc b/chrome/test/automation/browser_proxy.cc index cab64bf..a08fdc6 100644 --- a/chrome/test/automation/browser_proxy.cc +++ b/chrome/test/automation/browser_proxy.cc @@ -8,10 +8,12 @@ #include "base/logging.h" #include "base/time.h" +#include "chrome/test/automation/autocomplete_edit_proxy.h" #include "chrome/test/automation/automation_constants.h" #include "chrome/test/automation/automation_messages.h" #include "chrome/test/automation/automation_proxy.h" #include "chrome/test/automation/tab_proxy.h" +#include "chrome/test/automation/window_proxy.h" using base::TimeDelta; using base::TimeTicks; @@ -477,3 +479,50 @@ bool BrowserProxy::SetBooleanPreference(const std::wstring& name, return false; } + +WindowProxy* BrowserProxy::GetWindow() { + if (!is_valid()) + return false; + + IPC::Message* response = NULL; + bool succeeded = sender_->SendAndWaitForResponse( + new AutomationMsg_WindowForBrowserRequest(0, handle_), &response, + AutomationMsg_WindowForBrowserResponse::ID); + if (!succeeded) + return NULL; + + scoped_ptr<IPC::Message> response_deleter(response); // Delete on exit. + int window_handle; + void* iter = NULL; + bool handle_ok; + succeeded = response->ReadBool(&iter, &handle_ok); + if (succeeded) + succeeded = response->ReadInt(&iter, &window_handle); + + if (succeeded) { + return new WindowProxy(sender_, tracker_, window_handle); + } else { + return NULL; + } +} + +AutocompleteEditProxy* BrowserProxy::GetAutocompleteEdit() { + if (!is_valid()) + return NULL; + + IPC::Message* response = NULL; + if (!sender_->SendAndWaitForResponse( + new AutomationMsg_AutocompleteEditForBrowserRequest(0, handle_), + &response, AutomationMsg_AutocompleteEditForBrowserResponse::ID)) + return NULL; + scoped_ptr<IPC::Message> response_deleter(response); + + int autocomplete_edit_handle; + void* iter = NULL; + bool handle_ok; + if (!response->ReadBool(&iter, &handle_ok) || + !response->ReadInt(&iter, &autocomplete_edit_handle)) + return NULL; + + return new AutocompleteEditProxy(sender_, tracker_, autocomplete_edit_handle); +} diff --git a/chrome/test/automation/browser_proxy.h b/chrome/test/automation/browser_proxy.h index c67dd33..4df9269 100644 --- a/chrome/test/automation/browser_proxy.h +++ b/chrome/test/automation/browser_proxy.h @@ -11,6 +11,8 @@ class GURL; class TabProxy; +class WindowProxy; +class AutocompleteEditProxy; namespace gfx { class Rect; @@ -91,6 +93,18 @@ class BrowserProxy : public AutomationResourceProxy { // the specified timout. TabProxy* GetActiveTabWithTimeout(uint32 timeout_ms, bool* is_timeout) const; + // Returns the WindowProxy for this browser's window. It can be used to + // retreive view bounds, simulate clicks and key press events. The caller + // owns the returned WindowProxy. + // On failure, returns NULL. + WindowProxy* GetWindow(); + + // Returns an AutocompleteEdit for this browser's window. It can be used to + // manipulate the omnibox. The caller owns the returned pointer. + // On failure, returns NULL. + AutocompleteEditProxy* GetAutocompleteEdit(); + + // Apply the accelerator with given id (IDC_BACK, IDC_NEWTAB ...) // Returns true if the call was successful. // diff --git a/chrome/test/automation/window_proxy.cc b/chrome/test/automation/window_proxy.cc index 986b41d2..1780956 100644 --- a/chrome/test/automation/window_proxy.cc +++ b/chrome/test/automation/window_proxy.cc @@ -160,3 +160,34 @@ bool WindowProxy::GetFocusedViewID(int* view_id) { return false; } + +BrowserProxy* WindowProxy::GetBrowser() { + return GetBrowserWithTimeout(INFINITE, NULL); +} + +BrowserProxy* WindowProxy::GetBrowserWithTimeout(uint32 timeout_ms, + bool* is_timeout) { + if (!is_valid()) + return false; + + IPC::Message* response = NULL; + bool succeeded = sender_->SendAndWaitForResponseWithTimeout( + new AutomationMsg_BrowserForWindowRequest(0, handle_), &response, + AutomationMsg_BrowserForWindowResponse::ID, timeout_ms, is_timeout); + if (!succeeded) + return NULL; + + scoped_ptr<IPC::Message> response_deleter(response); // Delete on exit. + int browser_handle = 0; + void* iter = NULL; + bool handle_ok; + succeeded = response->ReadBool(&iter, &handle_ok); + if (succeeded) + succeeded = response->ReadInt(&iter, &browser_handle); + + if (succeeded) { + return new BrowserProxy(sender_, tracker_, browser_handle); + } else { + return NULL; + } +} diff --git a/chrome/test/automation/window_proxy.h b/chrome/test/automation/window_proxy.h index 30d6612..1f3da79 100644 --- a/chrome/test/automation/window_proxy.h +++ b/chrome/test/automation/window_proxy.h @@ -77,6 +77,14 @@ class WindowProxy : public AutomationResourceProxy { // was retrieved. bool GetFocusedViewID(int* view_id); + // Returns the browser this window corresponds to, or NULL if this window + // is not a browser. The caller owns the returned BrowserProxy. + BrowserProxy* GetBrowser(); + + // Same as GetWindow except return NULL if response isn't received + // before the specified timeout. + BrowserProxy* GetBrowserWithTimeout(uint32 timeout_ms, bool* is_timeout); + private: DISALLOW_EVIL_CONSTRUCTORS(WindowProxy); }; diff --git a/chrome/test/reliability/page_load_test.cc b/chrome/test/reliability/page_load_test.cc index 0dfe427..b451006 100644 --- a/chrome/test/reliability/page_load_test.cc +++ b/chrome/test/reliability/page_load_test.cc @@ -154,8 +154,7 @@ class PageLoadTest : public UITest { // Page down twice. scoped_ptr<BrowserProxy> browser(automation()->GetBrowserWindow(0)); if (browser.get()) { - scoped_ptr<WindowProxy> window( - automation()->GetWindowForBrowser(browser.get())); + scoped_ptr<WindowProxy> window(browser->GetWindow()); if (window.get()) { bool activation_timeout; browser->BringToFrontWithTimeout(action_max_timeout_ms(), diff --git a/chrome/test/ui/omnibox_uitest.cc b/chrome/test/ui/omnibox_uitest.cc index 7b317af..f77a301 100644 --- a/chrome/test/ui/omnibox_uitest.cc +++ b/chrome/test/ui/omnibox_uitest.cc @@ -75,10 +75,9 @@ bool OmniboxTest::IsMatch(const std::wstring& input_text, void OmniboxTest::RunQueryChain(const std::wstring& input_text) { // Get a handle on the omnibox and give it focus. scoped_ptr<BrowserProxy> browser(automation()->GetBrowserWindow(0)); - scoped_ptr<WindowProxy> window( - automation()->GetWindowForBrowser(browser.get())); + scoped_ptr<WindowProxy> window(browser->GetWindow()); scoped_ptr<AutocompleteEditProxy> autocomplete_edit( - automation()->GetAutocompleteEditForBrowser(browser.get())); + browser->GetAutocompleteEdit()); ASSERT_TRUE(browser->ApplyAccelerator(IDC_FOCUS_LOCATION)); // Try every proper prefix of input_text. There's no use trying |