summaryrefslogtreecommitdiffstats
path: root/chrome/test
diff options
context:
space:
mode:
authorbryeung@google.com <bryeung@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2010-12-08 14:57:19 +0000
committerbryeung@google.com <bryeung@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2010-12-08 14:57:19 +0000
commit546ae4e00d8d3a344d7c7587327f591dca2265bc (patch)
tree35a47b9eccf545d381b0558957cea823140e9549 /chrome/test
parent391bb5da06453b5080bdec0b652bc5e5bf364cd6 (diff)
downloadchromium_src-546ae4e00d8d3a344d7c7587327f591dca2265bc.zip
chromium_src-546ae4e00d8d3a344d7c7587327f591dca2265bc.tar.gz
chromium_src-546ae4e00d8d3a344d7c7587327f591dca2265bc.tar.bz2
Propagate is_editable_node in the FOCUS_CHANGED_IN_PAGE notification.
Also fixes up types and a bug in WindowedNotificationObserverWithDetails. BUG=none TEST=updated BrowserFocusTest.FocusTraversal Review URL: http://codereview.chromium.org/5516005 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@68597 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/test')
-rw-r--r--chrome/test/ui_test_utils.h48
1 files changed, 45 insertions, 3 deletions
diff --git a/chrome/test/ui_test_utils.h b/chrome/test/ui_test_utils.h
index 09b96f1..f6e383f 100644
--- a/chrome/test/ui_test_utils.h
+++ b/chrome/test/ui_test_utils.h
@@ -23,6 +23,7 @@
#include "chrome/common/notification_source.h"
#include "chrome/test/automation/dom_element_proxy.h"
#include "gfx/native_widget_types.h"
+#include "testing/gtest/include/gtest/gtest.h"
class AppModalDialog;
class BookmarkModel;
@@ -403,9 +404,9 @@ class WindowedNotificationObserverWithDetails
: WindowedNotificationObserver(notification_type, source) {}
// Fills |details| with the details of the notification received for |source|.
- bool GetDetailsFor(const void* source, U* details) {
+ bool GetDetailsFor(uintptr_t source, U* details) {
typename std::map<uintptr_t, U>::const_iterator iter =
- details_.find(reinterpret_cast<uintptr_t>(source));
+ details_.find(source);
if (iter == details_.end())
return false;
*details = iter->second;
@@ -415,7 +416,9 @@ class WindowedNotificationObserverWithDetails
virtual void Observe(NotificationType type,
const NotificationSource& source,
const NotificationDetails& details) {
- details_[source.map_key()] = *Details<U>(details).ptr();
+ const U* details_ptr = Details<U>(details).ptr();
+ if (details_ptr)
+ details_[source.map_key()] = *details_ptr;
WindowedNotificationObserver::Observe(type, source, details);
}
@@ -425,6 +428,45 @@ class WindowedNotificationObserverWithDetails
DISALLOW_COPY_AND_ASSIGN(WindowedNotificationObserverWithDetails);
};
+// See SendKeyPressAndWait. This function additionally performs a check on the
+// NotificationDetails using the provided Details<U>.
+template <class U>
+bool SendKeyPressAndWaitWithDetails(
+ const Browser* browser,
+ app::KeyboardCode key,
+ bool control,
+ bool shift,
+ bool alt,
+ bool command,
+ NotificationType type,
+ const NotificationSource& source,
+ const Details<U>& details) WARN_UNUSED_RESULT;
+
+template <class U>
+bool SendKeyPressAndWaitWithDetails(
+ const Browser* browser,
+ app::KeyboardCode key,
+ bool control,
+ bool shift,
+ bool alt,
+ bool command,
+ NotificationType type,
+ const NotificationSource& source,
+ const Details<U>& details) {
+ WindowedNotificationObserverWithDetails<U> observer(type, source);
+
+ if (!SendKeyPressSync(browser, key, control, shift, alt, command))
+ return false;
+
+ observer.Wait();
+
+ U my_details;
+ if (!observer.GetDetailsFor(source.map_key(), &my_details))
+ return false;
+
+ return *details.ptr() == my_details && !testing::Test::HasFatalFailure();
+}
+
// Hide a native window.
void HideNativeWindow(gfx::NativeWindow window);