summaryrefslogtreecommitdiffstats
path: root/chrome/test/automation
diff options
context:
space:
mode:
authordmazzoni@chromium.org <dmazzoni@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-03-22 15:29:20 +0000
committerdmazzoni@chromium.org <dmazzoni@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-03-22 15:29:20 +0000
commited256c7bd9828576ce865926e898a6c592b14037 (patch)
tree598f0023ad717aa23953cd4bcb666fc2df1410f6 /chrome/test/automation
parentb4fe9eb3acfd443091ebecbbbd1f87247cce9e1d (diff)
downloadchromium_src-ed256c7bd9828576ce865926e898a6c592b14037.zip
chromium_src-ed256c7bd9828576ce865926e898a6c592b14037.tar.gz
chromium_src-ed256c7bd9828576ce865926e898a6c592b14037.tar.bz2
Keyboard accessibility for the page and app menus.
Works on Windows, and on Linux with toolkit_views. The goal is to make Chrome behave more like a standard Windows application, for users who rely on the keyboard and expect standard keyboard accelerators to work. Pressing F10, or pressing and releasing Alt, will set focus to the Page menu, as if it was the first item in a menu bar. Pressing enter, space, up arrow, or down arrow will open the focused menu. Once a menu is opened, pressing left and right arrows will switch between the two menus. Pressing escape will return focus to the title of the previously open menu. A new UI test attempts to select something from the menus using only the keyboard. It works on Linux (with toolkit_views) and on Windows. BUG=none TEST=New keyboard accessibility ui test. Review URL: http://codereview.chromium.org/660323 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@42217 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/test/automation')
-rw-r--r--chrome/test/automation/automation_messages_internal.h14
-rw-r--r--chrome/test/automation/window_proxy.cc34
-rw-r--r--chrome/test/automation/window_proxy.h8
3 files changed, 56 insertions, 0 deletions
diff --git a/chrome/test/automation/automation_messages_internal.h b/chrome/test/automation/automation_messages_internal.h
index 7447020..b73ef4b 100644
--- a/chrome/test/automation/automation_messages_internal.h
+++ b/chrome/test/automation/automation_messages_internal.h
@@ -348,6 +348,14 @@ IPC_BEGIN_MESSAGES(Automation)
int /* view_handle */,
int /* focused_view_id */)
+ // Block until the focused view id changes to something other than
+ // |previous_view_id|.
+ IPC_SYNC_MESSAGE_ROUTED2_2(AutomationMsg_WaitForFocusedViewIDToChange,
+ int /* window handle */,
+ int /* previous_view_id */,
+ bool /* success */,
+ int /* new_view_id */)
+
// This message shows/hides the window.
IPC_SYNC_MESSAGE_ROUTED2_1(AutomationMsg_SetWindowVisible,
int /* view_handle */,
@@ -1288,4 +1296,10 @@ IPC_BEGIN_MESSAGES(Automation)
int64 /* id */,
bool /* success */)
+ // Determine if a pop-up menu is open.
+ IPC_SYNC_MESSAGE_ROUTED1_2(AutomationMsg_IsPopUpMenuOpen,
+ int /* window handle */,
+ bool /* success */,
+ bool /* is_open */)
+
IPC_END_MESSAGES(Automation)
diff --git a/chrome/test/automation/window_proxy.cc b/chrome/test/automation/window_proxy.cc
index 295f05b..4875300 100644
--- a/chrome/test/automation/window_proxy.cc
+++ b/chrome/test/automation/window_proxy.cc
@@ -8,6 +8,7 @@
#include <algorithm>
#include "base/logging.h"
+#include "base/time.h"
#include "chrome/test/automation/automation_constants.h"
#include "chrome/test/automation/automation_messages.h"
#include "chrome/test/automation/automation_proxy.h"
@@ -16,6 +17,9 @@
#include "gfx/rect.h"
#include "googleurl/src/gurl.h"
+using base::TimeDelta;
+using base::TimeTicks;
+
bool WindowProxy::SimulateOSClick(const gfx::Point& click, int flags) {
if (!is_valid()) return false;
@@ -123,6 +127,14 @@ bool WindowProxy::GetFocusedViewID(int* view_id) {
view_id));
}
+bool WindowProxy::WaitForFocusedViewIDToChange(
+ int old_view_id, int* new_view_id) {
+ bool result = false;
+ sender_->Send(new AutomationMsg_WaitForFocusedViewIDToChange
+ (0, handle_, old_view_id, &result, new_view_id));
+ return result;
+}
+
scoped_refptr<BrowserProxy> WindowProxy::GetBrowser() {
return GetBrowserWithTimeout(base::kNoTimeout, NULL);
}
@@ -163,3 +175,25 @@ bool WindowProxy::IsMaximized(bool* maximized) {
&result));
return result;
}
+
+bool WindowProxy::WaitForPopupMenuOpen(uint32 timeout_ms) {
+ const TimeTicks start = TimeTicks::Now();
+ const TimeDelta timeout = TimeDelta::FromMilliseconds(timeout_ms);
+ while (TimeTicks::Now() - start < timeout) {
+ PlatformThread::Sleep(automation::kSleepTime);
+
+ bool is_open = false;
+ bool success = false;
+ bool is_timeout = false;
+ sender_->SendWithTimeout(new AutomationMsg_IsPopUpMenuOpen(
+ 0, handle_, &success, &is_open),
+ timeout_ms, &is_timeout);
+ if (!success)
+ return false;
+ if (is_timeout)
+ return false;
+ if (is_open)
+ return true;
+ }
+ return false;
+}
diff --git a/chrome/test/automation/window_proxy.h b/chrome/test/automation/window_proxy.h
index 3c5deca..be7ed64 100644
--- a/chrome/test/automation/window_proxy.h
+++ b/chrome/test/automation/window_proxy.h
@@ -90,6 +90,14 @@ class WindowProxy : public AutomationResourceProxy {
// was retrieved.
bool GetFocusedViewID(int* view_id);
+ // Waits until the focused view ID changes to something other than
+ // |old_view_id|. Returns true if the focused view ID did change.
+ bool WaitForFocusedViewIDToChange(int old_view_id, int* new_view_id);
+
+ // Waits until a pop-up menu is opened. Returns true on success, or false
+ // if a pop-up menu is not opened within the timeout period.
+ bool WaitForPopupMenuOpen(uint32 timeout_ms);
+
// Returns the browser this window corresponds to, or NULL if this window
// is not a browser. The caller owns the returned BrowserProxy.
scoped_refptr<BrowserProxy> GetBrowser();