summaryrefslogtreecommitdiffstats
path: root/chrome/browser/automation
diff options
context:
space:
mode:
authorestade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-09-22 19:57:24 +0000
committerestade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-09-22 19:57:24 +0000
commit8dd404bbb05b99e7ee13b4e70899ebbcaeb3e8fb (patch)
tree0e4b5ba4be534f7e769db542d0882d6983fcb59a /chrome/browser/automation
parent24f4035eb84f25a51bf7ed6696671c99bf89bb25 (diff)
downloadchromium_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
Diffstat (limited to 'chrome/browser/automation')
-rw-r--r--chrome/browser/automation/automation_provider.cc39
-rw-r--r--chrome/browser/automation/automation_provider.h15
-rw-r--r--chrome/browser/automation/automation_provider_gtk.cc32
-rw-r--r--chrome/browser/automation/automation_provider_mac.mm28
-rw-r--r--chrome/browser/automation/automation_provider_win.cc83
5 files changed, 109 insertions, 88 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);
+ }
+}