diff options
author | estade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-09-22 19:57:24 +0000 |
---|---|---|
committer | estade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-09-22 19:57:24 +0000 |
commit | 8dd404bbb05b99e7ee13b4e70899ebbcaeb3e8fb (patch) | |
tree | 0e4b5ba4be534f7e769db542d0882d6983fcb59a | |
parent | 24f4035eb84f25a51bf7ed6696671c99bf89bb25 (diff) | |
download | chromium_src-8dd404bbb05b99e7ee13b4e70899ebbcaeb3e8fb.zip chromium_src-8dd404bbb05b99e7ee13b4e70899ebbcaeb3e8fb.tar.gz chromium_src-8dd404bbb05b99e7ee13b4e70899ebbcaeb3e8fb.tar.bz2 |
Automated ui test porting + cleanup:
- Change POINTs to gfx::Point
- Get rid of 2 unused automation messages (the messages themselves are staying for now so we don't mess with the reference build)
-- add new automation messages to replace GetWindowHWND, which is not portable
- re-enable automated_ui_test_interactive_test (it seems to have been dropped when we converted to gyp)
- compile additional tests on linux (they don't pass, so they are disabled)
- stub out linux tab dragging automation implementation (browser side)
- delete various cruft
BUG=19758
Review URL: http://codereview.chromium.org/211033
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@26846 0039d316-1c4b-4281-b951-d872f2087c98
21 files changed, 273 insertions, 351 deletions
diff --git a/chrome/browser/automation/automation_provider.cc b/chrome/browser/automation/automation_provider.cc index 263ad5b..5bef5e4 100644 --- a/chrome/browser/automation/automation_provider.cc +++ b/chrome/browser/automation/automation_provider.cc @@ -282,24 +282,24 @@ void AutomationProvider::OnMessageReceived(const IPC::Message& message) { FindNormalBrowserWindow) IPC_MESSAGE_HANDLER(AutomationMsg_IsWindowActive, IsWindowActive) IPC_MESSAGE_HANDLER(AutomationMsg_ActivateWindow, ActivateWindow) -#if defined(OS_WIN) - IPC_MESSAGE_HANDLER(AutomationMsg_WindowHWND, GetWindowHWND) -#endif // defined(OS_WIN) + IPC_MESSAGE_HANDLER(AutomationMsg_IsWindowMaximized, IsWindowMaximized) IPC_MESSAGE_HANDLER(AutomationMsg_WindowExecuteCommandAsync, ExecuteBrowserCommandAsync) IPC_MESSAGE_HANDLER_DELAY_REPLY(AutomationMsg_WindowExecuteCommand, ExecuteBrowserCommand) + IPC_MESSAGE_HANDLER(AutomationMsg_TerminateSession, TerminateSession) IPC_MESSAGE_HANDLER(AutomationMsg_WindowViewBounds, WindowGetViewBounds) + IPC_MESSAGE_HANDLER(AutomationMsg_GetWindowBounds, GetWindowBounds) IPC_MESSAGE_HANDLER(AutomationMsg_SetWindowBounds, SetWindowBounds) IPC_MESSAGE_HANDLER(AutomationMsg_SetWindowVisible, SetWindowVisible) #if !defined(OS_MACOSX) IPC_MESSAGE_HANDLER(AutomationMsg_WindowClick, WindowSimulateClick) IPC_MESSAGE_HANDLER(AutomationMsg_WindowKeyPress, WindowSimulateKeyPress) #endif // !defined(OS_MACOSX) -#if defined(OS_WIN) +#if defined(OS_WIN) || defined(OS_LINUX) IPC_MESSAGE_HANDLER_DELAY_REPLY(AutomationMsg_WindowDrag, WindowSimulateDrag) -#endif // defined(OS_WIN) +#endif // defined(OS_WIN) || defined(OS_LINUX) IPC_MESSAGE_HANDLER(AutomationMsg_TabCount, GetTabCount) IPC_MESSAGE_HANDLER(AutomationMsg_Tab, GetTab) #if defined(OS_WIN) @@ -347,7 +347,6 @@ void AutomationProvider::OnMessageReceived(const IPC::Message& message) { WaitForTabToBeRestored) IPC_MESSAGE_HANDLER(AutomationMsg_SetInitialFocus, SetInitialFocus) #if defined(OS_WIN) - IPC_MESSAGE_HANDLER(AutomationMsg_TabReposition, OnTabReposition) IPC_MESSAGE_HANDLER(AutomationMsg_ForwardContextMenuCommandToChrome, OnForwardContextMenuCommandToChrome) #endif @@ -815,34 +814,6 @@ class InvokeTaskLaterTask : public Task { DISALLOW_COPY_AND_ASSIGN(InvokeTaskLaterTask); }; -#if defined(OS_WIN) -// TODO(port): Replace POINT and other windowsisms. - -// This task sends a WindowDragResponse message with the appropriate -// routing ID to the automation proxy. This is implemented as a task so that -// we know that the mouse events (and any tasks that they spawn on the message -// loop) have been processed by the time this is sent. -class WindowDragResponseTask : public Task { - public: - WindowDragResponseTask(AutomationProvider* provider, - IPC::Message* reply_message) - : provider_(provider), reply_message_(reply_message) {} - virtual ~WindowDragResponseTask() {} - - virtual void Run() { - DCHECK(reply_message_ != NULL); - AutomationMsg_WindowDrag::WriteReplyParams(reply_message_, true); - provider_->Send(reply_message_); - } - - private: - AutomationProvider* provider_; - IPC::Message* reply_message_; - - DISALLOW_COPY_AND_ASSIGN(WindowDragResponseTask); -}; -#endif // defined(OS_WIN) - #if defined(OS_WIN) || defined(OS_LINUX) void AutomationProvider::WindowSimulateClick(const IPC::Message& message, int handle, diff --git a/chrome/browser/automation/automation_provider.h b/chrome/browser/automation/automation_provider.h index 3223ad4..acab989 100644 --- a/chrome/browser/automation/automation_provider.h +++ b/chrome/browser/automation/automation_provider.h @@ -36,7 +36,6 @@ struct AutomationMsg_Find_Params; namespace IPC { -struct Reposition_Params; struct ExternalTabSettings; } @@ -157,23 +156,17 @@ class AutomationProvider : public base::RefCounted<AutomationProvider>, void FindNormalBrowserWindow(int* handle); void GetLastActiveBrowserWindow(int* handle); void GetActiveWindow(int* handle); -#if defined(OS_WIN) - // TODO(port): Replace HWND. - void GetWindowHWND(int handle, HWND* win32_handle); -#endif // defined(OS_WIN) void ExecuteBrowserCommandAsync(int handle, int command, bool* success); void ExecuteBrowserCommand(int handle, int command, IPC::Message* reply_message); + void TerminateSession(int handle, bool* success); void WindowGetViewBounds(int handle, int view_id, bool screen_coordinates, bool* success, gfx::Rect* bounds); -#if defined(OS_WIN) - // TODO(port): Replace POINT. void WindowSimulateDrag(int handle, - std::vector<POINT> drag_path, + std::vector<gfx::Point> drag_path, int flags, bool press_escape_en_route, IPC::Message* reply_message); -#endif // defined(OS_WIN) void WindowSimulateClick(const IPC::Message& message, int handle, const gfx::Point& click, @@ -182,10 +175,12 @@ class AutomationProvider : public base::RefCounted<AutomationProvider>, int handle, wchar_t key, int flags); + void GetWindowBounds(int handle, gfx::Rect* bounds, bool* result); void SetWindowBounds(int handle, const gfx::Rect& bounds, bool* result); void SetWindowVisible(int handle, bool visible, bool* result); void IsWindowActive(int handle, bool* success, bool* is_active); void ActivateWindow(int handle); + void IsWindowMaximized(int handle, bool* is_maximized, bool* success); void GetTabCount(int handle, int* tab_count); void GetTab(int win_handle, int tab_index, int* tab_handle); @@ -326,8 +321,6 @@ class AutomationProvider : public base::RefCounted<AutomationProvider>, // TODO(port): remove windowisms. #if defined(OS_WIN) - void OnTabReposition(int tab_handle, - const IPC::Reposition_Params& params); void OnForwardContextMenuCommandToChrome(int tab_handle, int command); #endif // defined(OS_WIN) diff --git a/chrome/browser/automation/automation_provider_gtk.cc b/chrome/browser/automation/automation_provider_gtk.cc index eb86492..7036bf3 100644 --- a/chrome/browser/automation/automation_provider_gtk.cc +++ b/chrome/browser/automation/automation_provider_gtk.cc @@ -9,6 +9,7 @@ #include "chrome/browser/gtk/browser_window_gtk.h" #include "chrome/browser/gtk/view_id_util.h" #include "chrome/common/gtk_util.h" +#include "chrome/test/automation/automation_messages.h" void AutomationProvider::SetWindowBounds(int handle, const gfx::Rect& bounds, bool* success) { @@ -63,7 +64,15 @@ void AutomationProvider::WindowGetViewBounds(int handle, int view_id, } } -void AutomationProvider::ActivateWindow(int handle) { NOTIMPLEMENTED(); } +void AutomationProvider::ActivateWindow(int handle) { + NOTIMPLEMENTED(); +} + +void AutomationProvider::IsWindowMaximized(int handle, bool* is_maximized, + bool* success) { + *success = false; + NOTIMPLEMENTED(); +} void AutomationProvider::GetFocusedViewID(int handle, int* view_id) { NOTIMPLEMENTED(); @@ -84,3 +93,24 @@ void AutomationProvider::GetBookmarkBarVisibility(int handle, bool* visible, *animating = false; NOTIMPLEMENTED(); } + +void AutomationProvider::WindowSimulateDrag(int handle, + std::vector<gfx::Point> drag_path, + int flags, + bool press_escape_en_route, + IPC::Message* reply_message) { + NOTIMPLEMENTED(); + AutomationMsg_WindowDrag::WriteReplyParams(reply_message, false); + Send(reply_message); +} + +void AutomationProvider::TerminateSession(int handle, bool* success) { + *success = false; + NOTIMPLEMENTED(); +} + +void AutomationProvider::GetWindowBounds(int handle, gfx::Rect* bounds, + bool* result) { + *result = false; + NOTIMPLEMENTED(); +} diff --git a/chrome/browser/automation/automation_provider_mac.mm b/chrome/browser/automation/automation_provider_mac.mm index 6e8ae1b..0ee52a2 100644 --- a/chrome/browser/automation/automation_provider_mac.mm +++ b/chrome/browser/automation/automation_provider_mac.mm @@ -7,6 +7,7 @@ #import <Cocoa/Cocoa.h> #include "base/gfx/point.h" #include "base/gfx/rect.h" +#include "chrome/test/automation/automation_messages.h" void AutomationProvider::SetWindowBounds(int handle, const gfx::Rect& bounds, bool* success) { @@ -52,6 +53,12 @@ void AutomationProvider::WindowGetViewBounds(int handle, int view_id, void AutomationProvider::ActivateWindow(int handle) { NOTIMPLEMENTED(); } +void AutomationProvider::IsWindowMaximized(int handle, bool* is_maximized, + bool* success) { + *success = false; + NOTIMPLEMENTED(); +} + void AutomationProvider::GetFocusedViewID(int handle, int* view_id) { NOTIMPLEMENTED(); } @@ -71,3 +78,24 @@ void AutomationProvider::GetBookmarkBarVisibility(int handle, bool* visible, *animating = false; NOTIMPLEMENTED(); } + +void AutomationProvider::WindowSimulateDrag(int handle, + std::vector<gfx::Point> drag_path, + int flags, + bool press_escape_en_route, + IPC::Message* reply_message) { + NOTIMPLEMENTED(); + AutomationMsg_WindowDrag::WriteReplyParams(reply_message, false); + Send(reply_message); +} + +void AutomationProvider::TerminateSession(int handle, bool* success) { + *success = false; + NOTIMPLEMENTED(); +} + +void AutomationProvider::GetWindowBounds(int handle, gfx::Rect* bounds, + bool* result) { + *result = false; + NOTIMPLEMENTED(); +} diff --git a/chrome/browser/automation/automation_provider_win.cc b/chrome/browser/automation/automation_provider_win.cc index 696476b..42c0d26 100644 --- a/chrome/browser/automation/automation_provider_win.cc +++ b/chrome/browser/automation/automation_provider_win.cc @@ -74,10 +74,6 @@ void AutomationProvider::GetActiveWindow(int* handle) { *handle = window_tracker_->Add(window); } -void AutomationProvider::GetWindowHWND(int handle, HWND* win32_handle) { - *win32_handle = window_tracker_->GetResource(handle); -} - void AutomationProvider::WindowGetViewBounds(int handle, int view_id, bool screen_coordinates, bool* success, @@ -184,15 +180,13 @@ class WindowDragResponseTask : public Task { }; void AutomationProvider::WindowSimulateDrag(int handle, - std::vector<POINT> drag_path, + std::vector<gfx::Point> drag_path, int flags, bool press_escape_en_route, IPC::Message* reply_message) { - bool succeeded = false; if (browser_tracker_->ContainsHandle(handle) && (drag_path.size() > 1)) { gfx::NativeWindow window = browser_tracker_->GetResource(handle)->window()->GetNativeHandle(); - succeeded = true; UINT down_message = 0; UINT up_message = 0; @@ -221,19 +215,19 @@ void AutomationProvider::WindowSimulateDrag(int handle, DCHECK(browser); HWND top_level_hwnd = reinterpret_cast<HWND>(browser->window()->GetNativeHandle()); - POINT temp = drag_path[0]; + POINT temp = drag_path[0].ToPOINT(); MapWindowPoints(top_level_hwnd, HWND_DESKTOP, &temp, 1); MoveMouse(temp); SendMessage(top_level_hwnd, down_message, wparam_flags, - MAKELPARAM(drag_path[0].x, drag_path[0].y)); + MAKELPARAM(drag_path[0].x(), drag_path[0].y())); for (int i = 1; i < static_cast<int>(drag_path.size()); ++i) { - temp = drag_path[i]; + temp = drag_path[i].ToPOINT(); MapWindowPoints(top_level_hwnd, HWND_DESKTOP, &temp, 1); MoveMouse(temp); SendMessage(top_level_hwnd, WM_MOUSEMOVE, wparam_flags, - MAKELPARAM(drag_path[i].x, drag_path[i].y)); + MAKELPARAM(drag_path[i].x(), drag_path[i].y())); } - POINT end = drag_path[drag_path.size() - 1]; + POINT end = drag_path[drag_path.size() - 1].ToPOINT(); MapWindowPoints(top_level_hwnd, HWND_DESKTOP, &end, 1); MoveMouse(end); @@ -253,7 +247,7 @@ void AutomationProvider::WindowSimulateDrag(int handle, MessageLoop::current()->PostTask(FROM_HERE, new InvokeTaskLaterTask( new WindowDragResponseTask(this, reply_message))); } else { - AutomationMsg_WindowDrag::WriteReplyParams(reply_message, true); + AutomationMsg_WindowDrag::WriteReplyParams(reply_message, false); Send(reply_message); } } @@ -290,6 +284,18 @@ void AutomationProvider::GetBookmarkBarVisibility(int handle, bool* visible, } } +void AutomationProvider::GetWindowBounds(int handle, gfx::Rect* bounds, + bool* success) { + *success = false; + HWND hwnd = window_tracker_->GetResource(handle); + if (hwnd) { + *success = true; + WINDOWPLACEMENT window_placement; + GetWindowPlacement(hwnd, &window_placement); + *bounds = window_placement.rcNormalPosition; + } +} + void AutomationProvider::SetWindowBounds(int handle, const gfx::Rect& bounds, bool* success) { *success = false; @@ -319,6 +325,19 @@ void AutomationProvider::ActivateWindow(int handle) { } } +void AutomationProvider::IsWindowMaximized(int handle, bool* is_maximized, + bool* success) { + *success = false; + + HWND hwnd = window_tracker_->GetResource(handle); + if (hwnd) { + *success = true; + WINDOWPLACEMENT window_placement; + GetWindowPlacement(hwnd, &window_placement); + *is_maximized = (window_placement.showCmd == SW_MAXIMIZE); + } +} + void AutomationProvider::GetTabHWND(int handle, HWND* tab_hwnd) { *tab_hwnd = NULL; @@ -408,35 +427,6 @@ ExternalTabContainer* AutomationProvider::GetExternalTabForHandle(int handle) { return NULL; } -void AutomationProvider::OnTabReposition( - int tab_handle, const IPC::Reposition_Params& params) { - if (!tab_tracker_->ContainsHandle(tab_handle)) - return; - - if (!IsWindow(params.window)) - return; - - unsigned long process_id = 0; - unsigned long thread_id = 0; - - thread_id = GetWindowThreadProcessId(params.window, &process_id); - - if (thread_id != GetCurrentThreadId()) { - NOTREACHED(); - return; - } - - SetWindowPos(params.window, params.window_insert_after, params.left, - params.top, params.width, params.height, params.flags); - - if (params.set_parent) { - if (IsWindow(params.parent_window)) { - if (!SetParent(params.window, params.parent_window)) - DLOG(WARNING) << "SetParent failed. Error 0x%x" << GetLastError(); - } - } -} - void AutomationProvider::OnForwardContextMenuCommandToChrome(int tab_handle, int command) { if (tab_tracker_->ContainsHandle(tab_handle)) { @@ -485,3 +475,12 @@ void AutomationProvider::ConnectExternalTab( } } +void AutomationProvider::TerminateSession(int handle, bool* success) { + *success = false; + + if (browser_tracker_->ContainsHandle(handle)) { + Browser* browser = browser_tracker_->GetResource(handle); + HWND window = browser->window()->GetNativeHandle(); + *success = (::PostMessageW(window, WM_ENDSESSION, 0, 0) == TRUE); + } +} diff --git a/chrome/browser/browser_uitest.cc b/chrome/browser/browser_uitest.cc index a9d93b7..1ef62a1 100644 --- a/chrome/browser/browser_uitest.cc +++ b/chrome/browser/browser_uitest.cc @@ -24,17 +24,6 @@ namespace { class BrowserTest : public UITest { - protected: -#if defined(OS_WIN) - HWND GetMainWindow() { - scoped_refptr<BrowserProxy> browser(automation()->GetBrowserWindow(0)); - scoped_refptr<WindowProxy> window(browser->GetWindow()); - - HWND window_handle; - EXPECT_TRUE(window->GetHWND(&window_handle)); - return window_handle; - } -#endif }; class VisibleBrowserTest : public UITest { @@ -53,10 +42,8 @@ TEST_F(BrowserTest, WindowsSessionEnd) { NavigateToURL(net::FilePathToFileURL(test_file)); PlatformThread::Sleep(action_timeout_ms()); - // Simulate an end of session. Normally this happens when the user - // shuts down the pc or logs off. - HWND window_handle = GetMainWindow(); - ASSERT_TRUE(::PostMessageW(window_handle, WM_ENDSESSION, 0, 0)); + scoped_refptr<BrowserProxy> browser(automation()->GetBrowserWindow(0)); + ASSERT_TRUE(browser->TerminateSession()); PlatformThread::Sleep(action_timeout_ms()); ASSERT_FALSE(IsBrowserRunning()); diff --git a/chrome/browser/views/tabs/tab_dragging_test.cc b/chrome/browser/views/tabs/tab_dragging_test.cc index 81332bd..2c36d36 100644 --- a/chrome/browser/views/tabs/tab_dragging_test.cc +++ b/chrome/browser/views/tabs/tab_dragging_test.cc @@ -103,12 +103,9 @@ TEST_F(TabDraggingTest, DISABLED_Tab1Tab2) { // | Tab_1 | // ---- ---- ---- - POINT start; - POINT end; - start.x = bounds1.x() + bounds1.width()/2; - start.y = bounds1.y() + bounds1.height()/2; - end.x = start.x + 2*bounds1.width()/3; - end.y = start.y; + gfx::Point start(bounds1.x() + bounds1.width() / 2, + bounds1.y() + bounds1.height() / 2); + gfx::Point end(start.x() + 2 * bounds1.width() / 3, start.y()); ASSERT_TRUE(browser->SimulateDrag(start, end, views::Event::EF_LEFT_BUTTON_DOWN, false)); @@ -204,12 +201,11 @@ TEST_F(TabDraggingTest, DISABLED_Tab1Tab3) { // | Tab_1 | // ---- ---- ---- - POINT start; - POINT end; - start.x = bounds1.x() + bounds1.width()/2; - start.y = bounds1.y() + bounds1.height()/2; - end.x = start.x + bounds1.width()/2 + bounds2.width() + bounds3.width()/2; - end.y = start.y; + gfx::Point start(bounds1.x() + bounds1.width() / 2, + bounds1.y() + bounds1.height() / 2); + gfx::Point end(start.x() + bounds1.width() / 2 + bounds2.width() + + bounds3.width() / 2, + start.y()); ASSERT_TRUE(browser->SimulateDrag(start, end, views::Event::EF_LEFT_BUTTON_DOWN, false)); @@ -312,12 +308,11 @@ TEST_F(TabDraggingTest, DISABLED_Tab1Tab3Escape) { // | Tab_1 | // ---- ---- ---- - POINT start; - POINT end; - start.x = bounds1.x() + bounds1.width()/2; - start.y = bounds1.y() + bounds1.height()/2; - end.x = start.x + bounds1.width()/2 + bounds2.width() + bounds3.width()/2; - end.y = start.y; + gfx::Point start(bounds1.x() + bounds1.width() / 2, + bounds1.y() + bounds1.height() / 2); + gfx::Point end(start.x() + bounds1.width() / 2 + bounds2.width() + + bounds3.width() / 2, + start.y()); // Simulate drag with 'true' as the last parameter. This will interrupt // in-flight with Escape. @@ -435,12 +430,10 @@ TEST_F(TabDraggingTest, Tab2OutOfTabStrip) { // | Tab_2 | (New Window) // ---- ---- ---- ---- ---- ---- ---- - POINT start; - POINT end; - start.x = bounds2.x() + bounds2.width()/2; - start.y = bounds2.y() + bounds2.height()/2; - end.x = start.x; - end.y = start.y + 3*urlbar_bounds.height(); + gfx::Point start(bounds2.x() + bounds2.width() / 2, + bounds2.y() + bounds2.height() / 2); + gfx::Point end(start.x(), + start.y() + 3 * urlbar_bounds.height()); // Simulate tab drag. ASSERT_TRUE(browser->SimulateDrag(start, end, diff --git a/chrome/chrome.gyp b/chrome/chrome.gyp index 8298e06..ef7a8b9 100644 --- a/chrome/chrome.gyp +++ b/chrome/chrome.gyp @@ -3822,6 +3822,7 @@ '..', ], 'sources': [ + 'test/automated_ui_tests/automated_ui_test_interactive_test.cc', 'test/automated_ui_tests/automated_ui_tests.cc', 'test/automated_ui_tests/automated_ui_tests.h', ], diff --git a/chrome/common/pref_service_uitest.cc b/chrome/common/pref_service_uitest.cc index 9bb027a..00f05a0 100644 --- a/chrome/common/pref_service_uitest.cc +++ b/chrome/common/pref_service_uitest.cc @@ -6,6 +6,7 @@ #include "base/command_line.h" #include "base/file_util.h" +#include "base/gfx/rect.h" #include "base/test_file_util.h" #include "base/values.h" #include "build/build_config.h" @@ -96,37 +97,34 @@ TEST_F(PreferenceServiceTest, PreservedWindowPlacementIsLoaded) { ASSERT_TRUE(browser.get()); scoped_refptr<WindowProxy> window(browser->GetWindow()); - HWND hWnd; - ASSERT_TRUE(window->GetHWND(&hWnd)); - - WINDOWPLACEMENT window_placement; - ASSERT_TRUE(GetWindowPlacement(hWnd, &window_placement)); + gfx::Rect bounds; + ASSERT_TRUE(window->GetBounds(&bounds)); // Retrieve the expected rect values from "Preferences" int bottom = 0; std::wstring kBrowserWindowPlacement(prefs::kBrowserWindowPlacement); EXPECT_TRUE(root_dict->GetInteger(kBrowserWindowPlacement + L".bottom", &bottom)); - EXPECT_EQ(bottom, window_placement.rcNormalPosition.bottom); + EXPECT_EQ(bottom, bounds.y() + bounds.height()); int top = 0; EXPECT_TRUE(root_dict->GetInteger(kBrowserWindowPlacement + L".top", &top)); - EXPECT_EQ(top, window_placement.rcNormalPosition.top); + EXPECT_EQ(top, bounds.y()); int left = 0; EXPECT_TRUE(root_dict->GetInteger(kBrowserWindowPlacement + L".left", &left)); - EXPECT_EQ(left, window_placement.rcNormalPosition.left); + EXPECT_EQ(left, bounds.x()); int right = 0; EXPECT_TRUE(root_dict->GetInteger(kBrowserWindowPlacement + L".right", &right)); - EXPECT_EQ(right, window_placement.rcNormalPosition.right); - - // Find if launched window is maximized - bool is_window_maximized = (window_placement.showCmd == SW_MAXIMIZE); + EXPECT_EQ(right, bounds.x() + bounds.width()); + // Find if launched window is maximized. + bool is_window_maximized = false; + ASSERT_TRUE(window->IsMaximized(&is_window_maximized)); bool is_maximized = false; EXPECT_TRUE(root_dict->GetBoolean(kBrowserWindowPlacement + L".maximized", &is_maximized)); 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 5f2ef95..81ed10e 100644 --- a/chrome/test/automated_ui_tests/automated_ui_test_base.cc +++ b/chrome/test/automated_ui_tests/automated_ui_test_base.cc @@ -2,6 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +#include "base/gfx/point.h" +#include "base/gfx/rect.h" #include "chrome/app/chrome_dll_resource.h" #include "chrome/browser/view_ids.h" #include "chrome/test/automated_ui_tests/automated_ui_test_base.h" @@ -9,10 +11,7 @@ #include "chrome/test/automation/tab_proxy.h" #include "chrome/test/automation/window_proxy.h" #include "chrome/test/ui/ui_test.h" - -#if defined(TOOLKIT_VIEWS) -#include "views/view.h" -#endif +#include "views/event.h" AutomatedUITestBase::AutomatedUITestBase() {} @@ -84,7 +83,6 @@ bool AutomatedUITestBase::DuplicateTab() { return RunCommand(IDC_DUPLICATE_TAB); } -#if defined(OS_WIN) bool AutomatedUITestBase::DragTabOut() { BrowserProxy* browser = active_browser(); if (browser == NULL) { @@ -141,13 +139,13 @@ bool AutomatedUITestBase::DragTabOut() { return false; } - // Click on the center of the tab, and drag it downwads. - POINT start; - POINT end; - start.x = dragged_tab_bounds.x() + dragged_tab_bounds.width()/2; - start.y = dragged_tab_bounds.y() + dragged_tab_bounds.height()/2; - end.x = start.x; - end.y = start.y + 3*urlbar_bounds.height(); + // Click on the center of the tab, and drag it downwards. + gfx::Point start; + gfx::Point end; + start.set_x(dragged_tab_bounds.x() + dragged_tab_bounds.width() / 2); + start.set_y(dragged_tab_bounds.y() + dragged_tab_bounds.height() / 2); + end.set_x(start.x()); + end.set_y(start.y() + 3 * urlbar_bounds.height()); if (!browser->SimulateDragWithTimeout(start, end, views::Event::EF_LEFT_BUTTON_DOWN, @@ -203,8 +201,8 @@ bool AutomatedUITestBase::DragActiveTab(bool drag_right) { } // Click on the center of the tab, and drag it to the left or the right. - POINT dragged_tab_point(dragged_tab_bounds.CenterPoint().ToPOINT()); - POINT destination_point(dragged_tab_point); + gfx::Point dragged_tab_point = dragged_tab_bounds.CenterPoint(); + gfx::Point destination_point = dragged_tab_point; int new_tab_index; if (drag_right) { @@ -213,14 +211,14 @@ bool AutomatedUITestBase::DragActiveTab(bool drag_right) { return false; } new_tab_index = tab_index + 1; - destination_point.x += 2 * dragged_tab_bounds.width() / 3; + destination_point.Offset(2 * dragged_tab_bounds.width() / 3, 0); } else { if (tab_index <= 0) { LogInfoMessage("cant_drag_to_left"); return false; } new_tab_index = tab_index - 1; - destination_point.x -= 2 * dragged_tab_bounds.width() / 3; + destination_point.Offset(-2 * dragged_tab_bounds.width() / 3, 0); } if (!browser->SimulateDragWithTimeout(dragged_tab_point, @@ -239,7 +237,6 @@ bool AutomatedUITestBase::DragActiveTab(bool drag_right) { return true; } -#endif bool AutomatedUITestBase::FindInPage() { if (!RunCommandAsync(IDC_FIND)) diff --git a/chrome/test/automated_ui_tests/automated_ui_test_interactive_test.cc b/chrome/test/automated_ui_tests/automated_ui_test_interactive_test.cc index 66f57b0..f7ac5fc 100644 --- a/chrome/test/automated_ui_tests/automated_ui_test_interactive_test.cc +++ b/chrome/test/automated_ui_tests/automated_ui_test_interactive_test.cc @@ -7,6 +7,12 @@ #include "chrome/test/automation/tab_proxy.h" #include "chrome/test/ui/ui_test.h" +#if defined(OS_WINDOWS) +#define MAYBE(x) x +#else +#define MAYBE(x) DISABLED_##x +#endif + namespace { bool WaitForURLDisplayedForTab(BrowserProxy* browser, int tab_index, @@ -24,21 +30,21 @@ bool WaitForURLDisplayedForTab(BrowserProxy* browser, int tab_index, return false; } -} +} // namespace -TEST_F(AutomatedUITestBase, DragOut) { +TEST_F(AutomatedUITestBase, MAYBE(DragOut)) { int tab_count; active_browser()->GetTabCount(&tab_count); ASSERT_EQ(1, tab_count); ASSERT_FALSE(DragTabOut()); NewTab(); - Navigate(GURL(L"about:")); + Navigate(GURL("about:")); active_browser()->GetTabCount(&tab_count); ASSERT_EQ(2, tab_count); NewTab(); active_browser()->GetTabCount(&tab_count); ASSERT_EQ(3, tab_count); - GURL chrome_downloads_url(L"chrome://downloads/"); + GURL chrome_downloads_url("chrome://downloads/"); Navigate(chrome_downloads_url); ASSERT_TRUE(WaitForURLDisplayedForTab(active_browser(), 2, chrome_downloads_url)); @@ -48,7 +54,7 @@ TEST_F(AutomatedUITestBase, DragOut) { ASSERT_EQ(2, window_count); } -TEST_F(AutomatedUITestBase, DragLeftRight) { +TEST_F(AutomatedUITestBase, MAYBE(DragLeftRight)) { int tab_count; active_browser()->GetTabCount(&tab_count); ASSERT_EQ(1, tab_count); @@ -57,13 +63,13 @@ TEST_F(AutomatedUITestBase, DragLeftRight) { NewTab(); active_browser()->GetTabCount(&tab_count); ASSERT_EQ(2, tab_count); - GURL about_url(L"about:"); + GURL about_url("about:"); Navigate(about_url); NewTab(); active_browser()->GetTabCount(&tab_count); ASSERT_EQ(3, tab_count); - GURL chrome_downloads_url(L"chrome://downloads/"); + GURL chrome_downloads_url("chrome://downloads/"); Navigate(chrome_downloads_url); ASSERT_TRUE(WaitForURLDisplayedForTab(active_browser(), 2, chrome_downloads_url)); diff --git a/chrome/test/automated_ui_tests/automated_ui_tests.cc b/chrome/test/automated_ui_tests/automated_ui_tests.cc index 394b91c..252689c 100644 --- a/chrome/test/automated_ui_tests/automated_ui_tests.cc +++ b/chrome/test/automated_ui_tests/automated_ui_tests.cc @@ -319,15 +319,12 @@ bool AutomatedUITest::DoAction(const std::string& action) { did_complete_action = PressDownArrow(); } else if (LowerCaseEqualsASCII(action, "downloads")) { did_complete_action = ShowDownloads(); -// TODO(estade): port. -#if defined(OS_WIN) } else if (LowerCaseEqualsASCII(action, "dragtableft")) { did_complete_action = DragActiveTab(false); } else if (LowerCaseEqualsASCII(action, "dragtabout")) { did_complete_action = DragTabOut(); } else if (LowerCaseEqualsASCII(action, "dragtabright")) { did_complete_action = DragActiveTab(true); -#endif // defined(OS_WIN) } else if (LowerCaseEqualsASCII(action, "duplicatetab")) { did_complete_action = DuplicateTab(); } else if (LowerCaseEqualsASCII(action, "editsearchengines")) { diff --git a/chrome/test/automation/automation_messages.h b/chrome/test/automation/automation_messages.h index 416d168..90b95dd 100644 --- a/chrome/test/automation/automation_messages.h +++ b/chrome/test/automation/automation_messages.h @@ -163,69 +163,6 @@ struct ParamTraits<NavigationEntry::PageType> { } }; -#if defined(OS_WIN) -struct Reposition_Params { - HWND window; - HWND window_insert_after; - int left; - int top; - int width; - int height; - int flags; - bool set_parent; - HWND parent_window; -}; - -// Traits for SetWindowPos_Params structure to pack/unpack. -template <> -struct ParamTraits<Reposition_Params> { - typedef Reposition_Params param_type; - static void Write(Message* m, const param_type& p) { - WriteParam(m, p.window); - WriteParam(m, p.window_insert_after); - WriteParam(m, p.left); - WriteParam(m, p.top); - WriteParam(m, p.width); - WriteParam(m, p.height); - WriteParam(m, p.flags); - WriteParam(m, p.set_parent); - WriteParam(m, p.parent_window); - } - static bool Read(const Message* m, void** iter, param_type* p) { - return ReadParam(m, iter, &p->window) && - ReadParam(m, iter, &p->window_insert_after) && - ReadParam(m, iter, &p->left) && - ReadParam(m, iter, &p->top) && - ReadParam(m, iter, &p->width) && - ReadParam(m, iter, &p->height) && - ReadParam(m, iter, &p->flags) && - ReadParam(m, iter, &p->set_parent) && - ReadParam(m, iter, &p->parent_window); - } - static void Log(const param_type& p, std::wstring* l) { - l->append(L"("); - LogParam(p.window, l); - l->append(L", "); - LogParam(p.window_insert_after, l); - l->append(L", "); - LogParam(p.left, l); - l->append(L", "); - LogParam(p.top, l); - l->append(L", "); - LogParam(p.width, l); - l->append(L", "); - LogParam(p.height, l); - l->append(L", "); - LogParam(p.flags, l); - l->append(L", "); - LogParam(p.set_parent, l); - l->append(L", "); - LogParam(p.parent_window, l); - l->append(L")"); - } -}; -#endif // defined(OS_WIN) - struct AutomationURLRequest { std::string url; std::string method; diff --git a/chrome/test/automation/automation_messages_internal.h b/chrome/test/automation/automation_messages_internal.h index 49aa1a5..a4d86ad 100644 --- a/chrome/test/automation/automation_messages_internal.h +++ b/chrome/test/automation/automation_messages_internal.h @@ -157,18 +157,16 @@ IPC_BEGIN_MESSAGES(Automation) GURL) #if defined(OS_WIN) - // TODO(port): Port these messages. - // - // This message requests the HWND of the top-level window that corresponds - // to the given automation handle. - // The return value contains the HWND value, which is 0 if the call fails. - IPC_SYNC_MESSAGE_ROUTED1_1(AutomationMsg_WindowHWND, - int /* automation handle */, - HWND /* Win32 handle */ ) + // TODO(estade): delete this unused message. + IPC_SYNC_MESSAGE_ROUTED0_0(AutomationMsg_WindowHWND) // This message requests the HWND of the tab that corresponds // to the given automation handle. // The return value contains the HWND value, which is 0 if the call fails. + // + // TODO(estade): The only test that uses this message is + // NPAPIVisiblePluginTester.SelfDeletePluginInvokeInSynchronousMouseMove. It + // can probably be done in another way, and this can be removed. IPC_SYNC_MESSAGE_ROUTED1_1(AutomationMsg_TabHWND, int /* tab_handle */, HWND /* win32 Window Handle */) @@ -280,14 +278,15 @@ IPC_BEGIN_MESSAGES(Automation) // This message requests that a drag be performed in window coordinate space // Request: // int - the handle of the window that's the context for this drag - // std::vector<POINT> - the path of the drag in window coordinate space; - // it should have at least 2 points (start and end) + // std::vector<gfx::Point> - the path of the drag in window coordinate + // space; it should have at least 2 points + // (start and end) // int - the flags which identify the mouse button(s) for the drag, as - // defined in chrome/views/event.h + // defined in chrome/views/event.h // Response: // bool - true if the drag could be performed IPC_SYNC_MESSAGE_ROUTED4_1(AutomationMsg_WindowDrag, - int, std::vector<POINT>, int, bool, bool) + int, std::vector<gfx::Point>, int, bool, bool) #endif // defined(OS_WIN) // Similar to AutomationMsg_InitialLoadsComplete, this indicates that the @@ -868,11 +867,8 @@ IPC_BEGIN_MESSAGES(Automation) IPC_MESSAGE_ROUTED3(AutomationMsg_NavigationFailed, int, int, GURL) #if defined(OS_WIN) - // This message is an outgoing message from an automation client to Chrome. - // It is used to reposition a chrome tab window. - IPC_MESSAGE_ROUTED2(AutomationMsg_TabReposition, - int /* tab handle */, - IPC::Reposition_Params /* SetWindowPos params */) + // TODO(estade): delete this message. It is unused. + IPC_MESSAGE_ROUTED0(AutomationMsg_TabReposition) #endif // defined(OS_WIN) // Gets the title of the top level browser window. @@ -1078,4 +1074,36 @@ IPC_BEGIN_MESSAGES(Automation) gfx::NativeWindow /* Tab window */, int /* Handle to the new tab */) +#if defined(OS_LINUX) || defined(OS_MACOSX) + // TODO(estade): this should be merged with the windows message of the same + // name. See comment for WindowClick. + IPC_SYNC_MESSAGE_ROUTED4_1(AutomationMsg_WindowDrag, + int, std::vector<gfx::Point>, int, bool, bool) +#endif // defined(OS_LINUX) || defined(OS_MACOSX) + + // This message gets the bounds of the window. + // Request: + // int - the handle of the window to query + // Response: + // gfx::Rect - the bounds of the window + // bool - true if the query was successful + IPC_SYNC_MESSAGE_ROUTED1_2(AutomationMsg_GetWindowBounds, int, gfx::Rect, + bool) + + // Simulate an end of session. Normally this happens when the user + // shuts down the machine or logs off. + // Request: + // int - the handle of the browser + // Response: + // bool - true if succesful + IPC_SYNC_MESSAGE_ROUTED1_1(AutomationMsg_TerminateSession, int, bool) + + // Returns whether the window is maximized. + // Request: + // int - the handle of the window + // Response: + // bool - true if the window is maximized + // bool - true if query is successful + IPC_SYNC_MESSAGE_ROUTED1_2(AutomationMsg_IsWindowMaximized, int, bool, bool) + IPC_END_MESSAGES(Automation) diff --git a/chrome/test/automation/automation_proxy_uitest.cc b/chrome/test/automation/automation_proxy_uitest.cc index b12ad63..ce59f7f 100644 --- a/chrome/test/automation/automation_proxy_uitest.cc +++ b/chrome/test/automation/automation_proxy_uitest.cc @@ -29,6 +29,12 @@ #include "net/url_request/url_request_unittest.h" #include "views/event.h" +#if defined(OS_MACOSX) +#define MAYBE_WindowGetViewBounds DISABLED_WindowGetViewBounds +#else +#define MAYBE_WindowGetViewBounds WindowGetViewBounds +#endif + class AutomationProxyTest : public UITest { protected: AutomationProxyTest() { @@ -64,10 +70,8 @@ TEST_F(AutomationProxyTest, GetBrowserWindow) { } }; -// TODO(port): This test is for Chrome Views, which we only use on Windows. -// Maybe split this into a _win.cc file? -#if defined(OS_WIN) -TEST_F(AutomationProxyVisibleTest, WindowGetViewBounds) { +// TODO(estade): port automation provider for this test to mac. +TEST_F(AutomationProxyVisibleTest, MAYBE_WindowGetViewBounds) { { scoped_refptr<BrowserProxy> browser(automation()->GetBrowserWindow(0)); ASSERT_TRUE(browser.get()); @@ -155,7 +159,6 @@ TEST_F(AutomationProxyVisibleTest, WindowGetViewBounds) { */ } } -#endif // defined(OS_WIN) TEST_F(AutomationProxyTest, GetTabCount) { scoped_refptr<BrowserProxy> window(automation()->GetBrowserWindow(0)); @@ -458,20 +461,6 @@ TEST_F(AutomationProxyTest, Cookies) { EXPECT_TRUE(value_result.find("foo2=baz2") != std::string::npos); } -// TODO(port): Determine what tests need this and port. -#if defined(OS_WIN) -TEST_F(AutomationProxyTest, GetHWND) { - scoped_refptr<BrowserProxy> browser(automation()->GetBrowserWindow(0)); - ASSERT_TRUE(browser.get()); - scoped_refptr<WindowProxy> window(browser->GetWindow()); - ASSERT_TRUE(window.get()); - - HWND handle; - ASSERT_TRUE(window->GetHWND(&handle)); - ASSERT_TRUE(handle); -} -#endif - TEST_F(AutomationProxyTest, NavigateToURLAsync) { AutomationProxy* automation_object = automation(); scoped_refptr<BrowserProxy> window(automation_object->GetBrowserWindow(0)); diff --git a/chrome/test/automation/browser_proxy.cc b/chrome/test/automation/browser_proxy.cc index 12ab876..6543b26 100644 --- a/chrome/test/automation/browser_proxy.cc +++ b/chrome/test/automation/browser_proxy.cc @@ -6,6 +6,7 @@ #include <vector> +#include "base/gfx/point.h" #include "base/logging.h" #include "base/platform_thread.h" #include "base/time.h" @@ -178,18 +179,16 @@ bool BrowserProxy::ApplyAccelerator(int id) { return RunCommandAsync(id); } -#if defined(OS_WIN) -// TODO(port): Replace POINT. -bool BrowserProxy::SimulateDrag(const POINT& start, - const POINT& end, +bool BrowserProxy::SimulateDrag(const gfx::Point& start, + const gfx::Point& end, int flags, bool press_escape_en_route) { return SimulateDragWithTimeout(start, end, flags, base::kNoTimeout, NULL, press_escape_en_route); } -bool BrowserProxy::SimulateDragWithTimeout(const POINT& start, - const POINT& end, +bool BrowserProxy::SimulateDragWithTimeout(const gfx::Point& start, + const gfx::Point& end, int flags, uint32 timeout_ms, bool* is_timeout, @@ -197,7 +196,7 @@ bool BrowserProxy::SimulateDragWithTimeout(const POINT& start, if (!is_valid()) return false; - std::vector<POINT> drag_path; + std::vector<gfx::Point> drag_path; drag_path.push_back(start); drag_path.push_back(end); @@ -209,7 +208,6 @@ bool BrowserProxy::SimulateDragWithTimeout(const POINT& start, return result; } -#endif // defined(OS_WIN) bool BrowserProxy::WaitForTabCountToBecome(int count, int wait_timeout) { const TimeTicks start = TimeTicks::Now(); @@ -272,21 +270,6 @@ bool BrowserProxy::IsFindWindowFullyVisible(bool* is_visible) { new AutomationMsg_FindWindowVisibility(0, handle_, is_visible)); } -#if defined(OS_WIN) -// TODO(port): Replace HWND. -bool BrowserProxy::GetHWND(HWND* handle) const { - if (!is_valid()) - return false; - - if (!handle) { - NOTREACHED(); - return false; - } - - return sender_->Send(new AutomationMsg_WindowHWND(0, handle_, handle)); -} -#endif // defined(OS_WIN) - bool BrowserProxy::RunCommandAsync(int browser_command) const { if (!is_valid()) return false; @@ -395,6 +378,17 @@ bool BrowserProxy::SetBooleanPreference(const std::wstring& name, return result; } +bool BrowserProxy::TerminateSession() { + if (!is_valid()) + return false; + + bool result = false; + + sender_->Send(new AutomationMsg_TerminateSession(0, handle_, &result)); + + return result; +} + scoped_refptr<WindowProxy> BrowserProxy::GetWindow() const { if (!is_valid()) return NULL; diff --git a/chrome/test/automation/browser_proxy.h b/chrome/test/automation/browser_proxy.h index 8afa0b6..05b1b534 100644 --- a/chrome/test/automation/browser_proxy.h +++ b/chrome/test/automation/browser_proxy.h @@ -21,6 +21,7 @@ class WindowProxy; class AutocompleteEditProxy; namespace gfx { + class Point; class Rect; } @@ -122,22 +123,21 @@ class BrowserProxy : public AutomationResourceProxy { // desktop. bool ApplyAccelerator(int id); -#if defined(OS_WIN) - // TODO(port): Use portable replacement for POINT. - // Performs a drag operation between the start and end points (both defined // in window coordinates). |flags| specifies which buttons are pressed for // the drag, as defined in chrome/views/event.h. - virtual bool SimulateDrag(const POINT& start, const POINT& end, int flags, + virtual bool SimulateDrag(const gfx::Point& start, + const gfx::Point& end, + int flags, bool press_escape_en_route); // Like SimulateDrag, but returns false if response is not received before // the specified timeout. - virtual bool SimulateDragWithTimeout(const POINT& start, const POINT& end, + virtual bool SimulateDragWithTimeout(const gfx::Point& start, + const gfx::Point& end, int flags, uint32 timeout_ms, bool* is_timeout, bool press_escape_en_route); -#endif // defined(OS_WIN) // Block the thread until the tab count is |count|. // |wait_timeout| is the timeout, in milliseconds, for waiting. @@ -161,17 +161,6 @@ class BrowserProxy : public AutomationResourceProxy { // will be false. Returns false on failure. bool IsFindWindowFullyVisible(bool* is_visible); -#if defined(OS_WIN) - // TODO(port): Use portable equivalent of HWND. - - // Gets the outermost HWND that corresponds to the given browser. - // Returns true if the call was successful. - // Note that ideally this should go and the version of WindowProxy should be - // used instead. We have to keep it for start_up_tests that test against a - // reference build. - bool GetHWND(HWND* handle) const; -#endif // defined(OS_WIN) - // Run the specified command in the browser (see browser_commands.cc for the // list of supported commands). Returns true if the command was successfully // dispatched, false otherwise. @@ -206,6 +195,10 @@ class BrowserProxy : public AutomationResourceProxy { // Sets the boolean value of the specified preference. bool SetBooleanPreference(const std::wstring& name, bool value); + // Simulates a termination the browser session (as if the user logged off the + // mahine). + bool TerminateSession(); + protected: virtual ~BrowserProxy() {} private: diff --git a/chrome/test/automation/tab_proxy.cc b/chrome/test/automation/tab_proxy.cc index 85ab3fc..96126a3 100644 --- a/chrome/test/automation/tab_proxy.cc +++ b/chrome/test/automation/tab_proxy.cc @@ -665,28 +665,10 @@ bool TabProxy::OverrideEncoding(const std::string& encoding) { } #if defined(OS_WIN) -void TabProxy::Reposition(HWND window, HWND window_insert_after, int left, - int top, int width, int height, int flags, - HWND parent_window) { - - IPC::Reposition_Params params = {0}; - params.window = window; - params.window_insert_after = window_insert_after; - params.left = left; - params.top = top; - params.width = width; - params.height = height; - params.flags = flags; - params.set_parent = (::IsWindow(parent_window) ? true : false); - params.parent_window = parent_window; - sender_->Send(new AutomationMsg_TabReposition(0, handle_, params)); -} - void TabProxy::SendContextMenuCommand(int selected_command) { sender_->Send(new AutomationMsg_ForwardContextMenuCommandToChrome( 0, handle_, selected_command)); } - #endif // defined(OS_WIN) void TabProxy::SelectAll() { diff --git a/chrome/test/automation/tab_proxy.h b/chrome/test/automation/tab_proxy.h index e8dbe49..aea80df 100644 --- a/chrome/test/automation/tab_proxy.h +++ b/chrome/test/automation/tab_proxy.h @@ -310,15 +310,8 @@ class TabProxy : public AutomationResourceProxy { bool OverrideEncoding(const std::string& encoding); #if defined(OS_WIN) - // Resizes the tab window. - // The parent_window parameter allows a parent to be specified for the window - // passed in. - void Reposition(HWND window, HWND window_insert_after, int left, int top, - int width, int height, int flags, HWND parent_window); - // Sends the selected context menu command to the chrome instance void SendContextMenuCommand(int selected_command); - #endif // defined(OS_WIN) // Selects all contents on the page. diff --git a/chrome/test/automation/window_proxy.cc b/chrome/test/automation/window_proxy.cc index cb672d3..5766259 100644 --- a/chrome/test/automation/window_proxy.cc +++ b/chrome/test/automation/window_proxy.cc @@ -16,19 +16,6 @@ #include "chrome/test/automation/tab_proxy.h" #include "googleurl/src/gurl.h" -#if defined(OS_WIN) -bool WindowProxy::GetHWND(HWND* handle) const { - if (!is_valid()) return false; - - if (!handle) { - NOTREACHED(); - return false; - } - - return sender_->Send(new AutomationMsg_WindowHWND(0, handle_, handle)); -} -#endif // defined(OS_WIN) - bool WindowProxy::SimulateOSClick(const gfx::Point& click, int flags) { if (!is_valid()) return false; @@ -106,6 +93,15 @@ bool WindowProxy::GetViewBoundsWithTimeout(int view_id, gfx::Rect* bounds, return result; } +bool WindowProxy::GetBounds(gfx::Rect* bounds) { + if (!is_valid()) + return false; + bool result = false; + sender_->Send(new AutomationMsg_GetWindowBounds(0, handle_, bounds, + &result)); + return result; +} + bool WindowProxy::SetBounds(const gfx::Rect& bounds) { if (!is_valid()) return false; @@ -156,3 +152,14 @@ scoped_refptr<BrowserProxy> WindowProxy::GetBrowserWithTimeout( result.swap(&browser); return result; } + +bool WindowProxy::IsMaximized(bool* maximized) { + if (!is_valid()) + return false; + + bool result = false; + + sender_->Send(new AutomationMsg_IsWindowMaximized(0, handle_, maximized, + &result)); + return result; +} diff --git a/chrome/test/automation/window_proxy.h b/chrome/test/automation/window_proxy.h index 0133ff7..539ac20 100644 --- a/chrome/test/automation/window_proxy.h +++ b/chrome/test/automation/window_proxy.h @@ -36,14 +36,6 @@ class WindowProxy : public AutomationResourceProxy { int handle) : AutomationResourceProxy(tracker, sender, handle) {} -#if defined(OS_WIN) - // TODO(port): Use portable replacements for windowsisms. - - // Gets the outermost HWND that corresponds to the given window. - // Returns true if the call was successful. - bool GetHWND(HWND* handle) const; -#endif // defined(OS_WIN) - // Simulates a click at the OS level. |click| is in the window's coordinates // and |flags| specifies which buttons are pressed (as defined in // chrome/views/event.h). Note that this is equivalent to the user moving @@ -72,6 +64,9 @@ class WindowProxy : public AutomationResourceProxy { // Returns true if the call was successful. bool Activate(); + // Sets |maximized| to true if this window is maximized. + bool IsMaximized(bool* maximized); + // Gets the bounds (in window coordinates) that correspond to the view with // the given ID in this window. Returns true if bounds could be obtained. // If |screen_coordinates| is true, the bounds are returned in the coordinates @@ -84,6 +79,10 @@ class WindowProxy : public AutomationResourceProxy { bool screen_coordinates, uint32 timeout_ms, bool* is_timeout); + // Gets the position and size of the window. Returns true if setting the + // bounds was successful. + bool GetBounds(gfx::Rect* bounds); + // Sets the position and size of the window. Returns true if setting the // bounds was successful. bool SetBounds(const gfx::Rect& bounds); |