summaryrefslogtreecommitdiffstats
path: root/chrome_frame
diff options
context:
space:
mode:
authorkkania@chromium.org <kkania@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-09-01 16:15:31 +0000
committerkkania@chromium.org <kkania@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-09-01 16:15:31 +0000
commite2ff9b407c0a1237af4447818d552f0da7e273b9 (patch)
treeaa328937a1a9c99af4ea16196a777076bdfc947b /chrome_frame
parentd5a5892a7d00af0d331a5697117e14101dd6a12c (diff)
downloadchromium_src-e2ff9b407c0a1237af4447818d552f0da7e273b9.zip
chromium_src-e2ff9b407c0a1237af4447818d552f0da7e273b9.tar.gz
chromium_src-e2ff9b407c0a1237af4447818d552f0da7e273b9.tar.bz2
[chrome frame] Clean up chrome frame tests and get rid of most dependencies on SendInput.
BUG=none TEST=none Review URL: http://codereview.chromium.org/3222004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@58182 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome_frame')
-rw-r--r--chrome_frame/test/chrome_frame_ui_test_utils.cc221
-rw-r--r--chrome_frame/test/chrome_frame_ui_test_utils.h74
-rw-r--r--chrome_frame/test/data/form-get.html8
-rw-r--r--chrome_frame/test/data/window_open.html6
-rw-r--r--chrome_frame/test/ie_event_sink.cc15
-rw-r--r--chrome_frame/test/ie_event_sink.h7
-rw-r--r--chrome_frame/test/mock_ie_event_sink_actions.h312
-rw-r--r--chrome_frame/test/mock_ie_event_sink_test.cc11
-rw-r--r--chrome_frame/test/mock_ie_event_sink_test.h14
-rw-r--r--chrome_frame/test/navigation_test.cc209
-rw-r--r--chrome_frame/test/ui_test.cc51
-rw-r--r--chrome_frame/test/win_event_receiver.cc22
-rw-r--r--chrome_frame/test/win_event_receiver.h17
13 files changed, 550 insertions, 417 deletions
diff --git a/chrome_frame/test/chrome_frame_ui_test_utils.cc b/chrome_frame/test/chrome_frame_ui_test_utils.cc
index af4a149..3ff61f7 100644
--- a/chrome_frame/test/chrome_frame_ui_test_utils.cc
+++ b/chrome_frame/test/chrome_frame_ui_test_utils.cc
@@ -18,6 +18,7 @@
#include "gfx/rect.h"
#include "chrome_frame/test/win_event_receiver.h"
#include "testing/gtest/include/gtest/gtest.h"
+#include "third_party/xulrunner-sdk/win/include/accessibility/AccessibleEventId.h"
namespace chrome_frame_test {
@@ -89,45 +90,11 @@ AccObject* AccObject::CreateFromPoint(int x, int y) {
}
bool AccObject::DoDefaultAction() {
- HWND parent_window = NULL;
- ::WindowFromAccessibleObject(accessible_, &parent_window);
- if (!parent_window) {
- DLOG(ERROR) << "Could not get the window containing the given "
- << "accessibility object: " << GetDescription();
- return false;
- }
- wchar_t class_name[MAX_PATH];
- if (!::GetClassName(parent_window, class_name, arraysize(class_name))) {
- DLOG(ERROR) << "Could not get class name from accessibily object's window";
- return false;
- }
- if (wcscmp(class_name, L"#32768") == 0) {
- // Hack: if the desktop is locked, menu items cannot be selected using
- // accDoDefaultAction for some unknown reason. Get around this by
- // sending mouse button messages at the menu item location. Do this
- // even if the desktop is unlocked for consistency. We do not do this
- // for all objects because DoDefaultAction is not always equivalent to
- // a mouse click.
- gfx::Rect menu_item_rect;
- if (GetLocation(&menu_item_rect)) {
- DLOG(WARNING) << "Attempting to click menu item via mouse messages. "
- << "May not work for all menus";
- // WM_LBUTTON* messages supposedly expect relative coordinates to the
- // client area, which for popup menus seems to be the entire desktop.
- gfx::Point center = menu_item_rect.CenterPoint();
- LPARAM coordinates = (center.y() << 16) | center.x();
- ::PostMessage(parent_window, WM_LBUTTONDOWN, (WPARAM)0, coordinates);
- ::PostMessage(parent_window, WM_LBUTTONUP, (WPARAM)0, coordinates);
- return true;
- }
- // TODO(kkania): Try sending the access key for the menu item to the
- // menu if the mouse button messages are found to be insufficient
- // at times.
- DLOG(ERROR) << "Could not get location of menu item via MSAA. "
- << "Accessibility object: " << WideToUTF8(this->GetDescription())
- << std::endl << "This is necessary to select a menu item since the "
- << "desktop is locked.";
- return false;
+ // Prevent clients from using this method to try to select menu items, which
+ // does not work with a locked desktop.
+ std::wstring class_name;
+ if (GetWindowClassName(&class_name)) {
+ DCHECK(class_name != L"#32768") << "Do not use DoDefaultAction with menus";
}
HRESULT result = accessible_->accDoDefaultAction(child_id_);
@@ -136,6 +103,14 @@ bool AccObject::DoDefaultAction() {
return SUCCEEDED(result);
}
+bool AccObject::LeftClick() {
+ return PostMouseButtonMessages(WM_LBUTTONDOWN, WM_LBUTTONUP);
+}
+
+bool AccObject::RightClick() {
+ return PostMouseButtonMessages(WM_RBUTTONDOWN, WM_RBUTTONUP);
+}
+
bool AccObject::Focus() {
EXPECT_HRESULT_SUCCEEDED(
accessible_->accSelect(SELFLAG_TAKEFOCUS, child_id_));
@@ -252,6 +227,25 @@ bool AccObject::GetLocation(gfx::Rect* location) {
return SUCCEEDED(result);
}
+bool AccObject::GetLocationInClient(gfx::Rect* client_location) {
+ DCHECK(client_location);
+ gfx::Rect location;
+ if (!GetLocation(&location))
+ return false;
+ HWND container_window = NULL;
+ if (!GetWindow(&container_window))
+ return false;
+ POINT offset = {0, 0};
+ if (!::ScreenToClient(container_window, &offset)) {
+ DLOG(ERROR) << "Could not convert from screen to client coordinates for "
+ << "window containing accessibility object: " << GetDescription();
+ return false;
+ }
+ location.Offset(offset.x, offset.y);
+ *client_location = location;
+ return true;
+}
+
AccObject* AccObject::GetParent() {
if (IsSimpleElement())
return new AccObject(accessible_);
@@ -345,6 +339,24 @@ bool AccObject::GetChildCount(int* child_count) {
return true;
}
+bool AccObject::GetWindow(HWND* window) {
+ DCHECK(window);
+ return SUCCEEDED(::WindowFromAccessibleObject(accessible_, window)) && window;
+}
+
+bool AccObject::GetWindowClassName(std::wstring* class_name) {
+ DCHECK(class_name);
+ HWND container_window = NULL;
+ if (GetWindow(&container_window)) {
+ wchar_t class_arr[MAX_PATH];
+ if (::GetClassName(container_window, class_arr, arraysize(class_arr))) {
+ *class_name = class_arr;
+ return true;
+ }
+ }
+ return false;
+}
+
bool AccObject::IsSimpleElement() {
return V_I4(&child_id_) != CHILDID_SELF;
}
@@ -397,6 +409,33 @@ std::wstring AccObject::GetTree() {
return string_stream.str();
}
+bool AccObject::PostMouseButtonMessages(int button_up, int button_down) {
+ std::wstring class_name;
+ if (!GetWindowClassName(&class_name)) {
+ DLOG(ERROR) << "Could not get class name of window for accessibility "
+ << "object: " << GetDescription();
+ return false;
+ }
+ gfx::Rect location;
+ if (class_name == L"#32768") {
+ // For some reason, it seems that menus expect screen coordinates.
+ if (!GetLocation(&location))
+ return false;
+ } else {
+ if (!GetLocationInClient(&location))
+ return false;
+ }
+ HWND container_window;
+ if (!GetWindow(&container_window))
+ return false;
+
+ gfx::Point center = location.CenterPoint();
+ LPARAM coordinates = (center.y() << 16) | center.x();
+ ::PostMessage(container_window, button_up, 0, coordinates);
+ ::PostMessage(container_window, button_down, 0, coordinates);
+ return true;
+}
+
// AccObjectMatcher methods
AccObjectMatcher::AccObjectMatcher(const std::wstring& name,
const std::wstring& role_text,
@@ -406,22 +445,7 @@ AccObjectMatcher::AccObjectMatcher(const std::wstring& name,
bool AccObjectMatcher::FindHelper(AccObject* object,
scoped_refptr<AccObject>* match) const {
- // Determine if |object| is a match.
- bool does_match = true;
- std::wstring name, role_text, value;
- if (name_.length()) {
- object->GetName(&name);
- does_match = MatchPatternWide(name, name_);
- }
- if (does_match && role_text_.length()) {
- object->GetRoleText(&role_text);
- does_match = MatchPatternWide(role_text, role_text_);
- }
- if (does_match && value_.length()) {
- object->GetValue(&value);
- does_match = MatchPatternWide(value, value_);
- }
- if (does_match) {
+ if (DoesMatch(object)) {
*match = object;
} else {
// Try to match the children of |object|.
@@ -459,6 +483,25 @@ bool AccObjectMatcher::FindInWindow(HWND hwnd,
return Find(object.get(), match);
}
+bool AccObjectMatcher::DoesMatch(AccObject* object) const {
+ DCHECK(object);
+ bool does_match = true;
+ std::wstring name, role_text, value;
+ if (name_.length()) {
+ object->GetName(&name);
+ does_match = MatchPatternWide(name, name_);
+ }
+ if (does_match && role_text_.length()) {
+ object->GetRoleText(&role_text);
+ does_match = MatchPatternWide(role_text, role_text_);
+ }
+ if (does_match && value_.length()) {
+ object->GetValue(&value);
+ does_match = MatchPatternWide(value, value_);
+ }
+ return does_match;
+}
+
std::wstring AccObjectMatcher::GetDescription() const {
std::wostringstream ss;
ss << L"[";
@@ -472,6 +515,74 @@ std::wstring AccObjectMatcher::GetDescription() const {
return ss.str();
}
+// AccEventObserver methods
+AccEventObserver::AccEventObserver()
+ : ALLOW_THIS_IN_INITIALIZER_LIST(event_handler_(new EventHandler(this))),
+ is_watching_(false) {
+ event_receiver_.SetListenerForEvents(this, EVENT_SYSTEM_MENUPOPUPSTART,
+ EVENT_OBJECT_VALUECHANGE);
+}
+
+AccEventObserver::~AccEventObserver() {
+ event_handler_->observer_ = NULL;
+}
+
+void AccEventObserver::WatchForOneValueChange(const AccObjectMatcher& matcher) {
+ is_watching_ = true;
+ watching_for_matcher_ = matcher;
+}
+
+void AccEventObserver::OnEventReceived(DWORD event,
+ HWND hwnd,
+ LONG object_id,
+ LONG child_id) {
+ // Process events in a separate task to stop reentrancy problems.
+ DCHECK(MessageLoop::current());
+ MessageLoop::current()->PostTask(FROM_HERE,
+ NewRunnableMethod(event_handler_.get(), &EventHandler::Handle,
+ event, hwnd, object_id, child_id));
+}
+
+// AccEventObserver::EventHandler methods
+AccEventObserver::EventHandler::EventHandler(AccEventObserver* observer)
+ : observer_(observer) {
+}
+
+void AccEventObserver::EventHandler::Handle(DWORD event,
+ HWND hwnd,
+ LONG object_id,
+ LONG child_id) {
+ if (!observer_)
+ return;
+ switch (event) {
+ case EVENT_SYSTEM_MENUPOPUPSTART:
+ observer_->OnMenuPopup(hwnd);
+ break;
+ case IA2_EVENT_DOCUMENT_LOAD_COMPLETE:
+ observer_->OnAccDocLoad(hwnd);
+ break;
+ case EVENT_OBJECT_VALUECHANGE:
+ if (observer_->is_watching_) {
+ scoped_refptr<AccObject> object(
+ AccObject::CreateFromEvent(hwnd, object_id, child_id));
+ if (object) {
+ if (observer_->watching_for_matcher_.DoesMatch(object.get())) {
+ // Stop watching before calling OnAccValueChange in case the
+ // client invokes our watch method during the call.
+ observer_->is_watching_ = false;
+ std::wstring new_value;
+ if (object->GetValue(&new_value)) {
+ observer_->OnAccValueChange(hwnd, object.get(), new_value);
+ }
+ }
+ }
+ }
+ break;
+ default:
+ break;
+ }
+}
+
// Other methods
bool FindAccObjectInWindow(HWND hwnd, const AccObjectMatcher& matcher,
scoped_refptr<AccObject>* object) {
diff --git a/chrome_frame/test/chrome_frame_ui_test_utils.h b/chrome_frame/test/chrome_frame_ui_test_utils.h
index 3882483..b6b4f6a 100644
--- a/chrome_frame/test/chrome_frame_ui_test_utils.h
+++ b/chrome_frame/test/chrome_frame_ui_test_utils.h
@@ -13,6 +13,7 @@
#include "base/ref_counted.h"
#include "base/scoped_comptr_win.h"
#include "base/scoped_variant_win.h"
+#include "chrome_frame/test/win_event_receiver.h"
namespace gfx {
class Rect;
@@ -47,18 +48,27 @@ class AccObject : public base::RefCounted<AccObject> {
// Creates an AccObject from querying the given IDispatch. May return NULL
// if the object does not implement IAccessible. The client owns the created
// AccObject.
- // Note: This does not work in Chrome.
static AccObject* CreateFromDispatch(IDispatch* dispatch);
// Creates an AccObject corresponding to the accessible object at the screen
// coordinates given. Returns NULL on failure. The client owns the created
// AccObject.
+ // Note: This does not work in Chrome.
static AccObject* CreateFromPoint(int x, int y);
// Performs the default action on this object. Returns whether the action
// performed successfully. Will cause test failure if unsuccessful.
+ // Note: This does not work for selecting menu items if the desktop is locked.
bool DoDefaultAction();
+ // Posts a left click message at this object's center point to the window
+ // containing this object.
+ bool LeftClick();
+
+ // Posts a right click message at this object's center point to the window
+ // containing this object.
+ bool RightClick();
+
// Focuses this object. Returns whether the object receives focus. Will cause
// test failure if the object is not focused.
bool Focus();
@@ -86,6 +96,10 @@ class AccObject : public base::RefCounted<AccObject> {
// on success.
bool GetLocation(gfx::Rect* location);
+ // Gets the location of the object relative to the containing window's
+ // client rect.
+ bool GetLocationInClient(gfx::Rect* location);
+
// Gets the parent of the object. May return NULL.
AccObject* GetParent();
@@ -96,6 +110,14 @@ class AccObject : public base::RefCounted<AccObject> {
// Gets the number of children of this object and returns true on success.
bool GetChildCount(int* child_count);
+ // Gets the window containing this object and returns true on success. This
+ // method will return false if the object is not contained within a window.
+ bool GetWindow(HWND* window);
+
+ // Gets the class name for the window containing this object and returns true
+ // on success. If this object does not have a window, this will return false.
+ bool GetWindowClassName(std::wstring* class_name);
+
// Returns whether this object is a simple element.
bool IsSimpleElement();
@@ -114,6 +136,9 @@ class AccObject : public base::RefCounted<AccObject> {
friend class base::RefCounted<AccObject>;
~AccObject() {}
+ // Helper method for posting mouse button messages at this object's location.
+ bool PostMouseButtonMessages(int button_up, int button_down);
+
ScopedComPtr<IAccessible> accessible_;
ScopedVariant child_id_;
@@ -150,6 +175,9 @@ class AccObjectMatcher {
// given window, which must support the IAccessible interface.
bool FindInWindow(HWND hwnd, scoped_refptr<AccObject>* match) const;
+ // Returns whether |object| satisfies this matcher.
+ bool DoesMatch(AccObject* object) const;
+
// Return a description of the matcher, for debugging/logging purposes.
std::wstring GetDescription() const;
@@ -161,6 +189,50 @@ class AccObjectMatcher {
std::wstring value_;
};
+// Observes various accessibility events.
+class AccEventObserver : public WinEventListener {
+ public:
+ AccEventObserver();
+ virtual ~AccEventObserver();
+
+ // Begins watching for a value changed event for an accessibility object that
+ // satisfies |matcher|. Once the event occurs, this observer will stop
+ // watching.
+ void WatchForOneValueChange(const AccObjectMatcher& matcher);
+
+ // Called when the DOM accessibility tree for the page is ready.
+ virtual void OnAccDocLoad(HWND hwnd) = 0;
+
+ // Called when an accessibility object value changes. Only called if the
+ // observer was set to watch for it.
+ virtual void OnAccValueChange(HWND hwnd, AccObject* object,
+ const std::wstring& new_value) = 0;
+
+ // Called when a new menu is shown.
+ virtual void OnMenuPopup(HWND hwnd) = 0;
+
+ private:
+ class EventHandler : public base::RefCounted<EventHandler> {
+ public:
+ EventHandler(AccEventObserver* observer);
+
+ // Examines the given event and invokes the corresponding method of its
+ // observer.
+ void Handle(DWORD event, HWND hwnd, LONG object_id, LONG child_id);
+
+ AccEventObserver* observer_;
+ };
+
+ // Overriden from WinEventListener.
+ virtual void OnEventReceived(DWORD event, HWND hwnd, LONG object_id,
+ LONG child_id);
+
+ scoped_refptr<EventHandler> event_handler_;
+ bool is_watching_;
+ AccObjectMatcher watching_for_matcher_;
+ WinEventReceiver event_receiver_;
+};
+
// Finds an AccObject from the given window that satisfied |matcher|.
// Will cause test failure in case of error or if no match is found in the
// accessibility tree of the specified window. Returns whether the object was
diff --git a/chrome_frame/test/data/form-get.html b/chrome_frame/test/data/form-get.html
index 91768ea..5d1b024 100644
--- a/chrome_frame/test/data/form-get.html
+++ b/chrome_frame/test/data/form-get.html
@@ -1,14 +1,8 @@
<html>
<head>
<title> ChromeFrame form submit test(GET method) </title>
- <script type="text/javascript">
- function submitForm() {
- var submit = document.getElementById("submit_button");
- submit.click();
- }
- </script>
</head>
- <body onkeypress="submitForm();">
+ <body>
<br />
<form name="login" method="get" action="action.html">
<table width="90%" border="0" align="center" cellpadding="4"
diff --git a/chrome_frame/test/data/window_open.html b/chrome_frame/test/data/window_open.html
index eb8599f..a7cffe0 100644
--- a/chrome_frame/test/data/window_open.html
+++ b/chrome_frame/test/data/window_open.html
@@ -3,13 +3,13 @@
<script type="text/javascript">
var new_window;
- function OnDblClick() {
+ function OnClick() {
// Open popup to the url from the given query string.
var url = window.location.search.substring(1);
new_window = window.open(url, "_blank",
"left=10, top=10, height=250, width=250");
}
-
+
function OnKeyPress() {
var char_code = String.fromCharCode(event.keyCode);
if (char_code == 'C') {
@@ -18,7 +18,7 @@
}
</script>
</head>
- <body onkeypress="OnKeyPress();" ondblclick="OnDblClick();">
+ <body onkeypress="OnKeyPress();" onclick="OnClick();">
ChromeFrame full tab mode window open popup test
</body>
</html>
diff --git a/chrome_frame/test/ie_event_sink.cc b/chrome_frame/test/ie_event_sink.cc
index 324a25f..7da31dc 100644
--- a/chrome_frame/test/ie_event_sink.cc
+++ b/chrome_frame/test/ie_event_sink.cc
@@ -190,6 +190,14 @@ bool IEEventSink::IsCFRendering() {
return false;
}
+void IEEventSink::PostMessageToCF(const std::wstring& message,
+ const std::wstring& target) {
+ ScopedBstr message_bstr(message.c_str());
+ ScopedVariant target_variant(target.c_str());
+ EXPECT_HRESULT_SUCCEEDED(
+ chrome_frame_->postMessage(message_bstr, target_variant));
+}
+
void IEEventSink::SetFocusToRenderer() {
simulate_input::SetKeyboardFocusToWindow(GetRendererWindow());
}
@@ -240,6 +248,13 @@ void IEEventSink::Exec(const GUID* cmd_group_guid, DWORD command_id,
command_id, cmd_exec_opt, in_args, out_args));
}
+HWND IEEventSink::GetBrowserWindow() {
+ HWND browser_window = NULL;
+ web_browser2_->get_HWND(reinterpret_cast<SHANDLE_PTR*>(&browser_window));
+ EXPECT_TRUE(::IsWindow(browser_window));
+ return browser_window;
+}
+
HWND IEEventSink::GetRendererWindow() {
HWND renderer_window = NULL;
if (IsCFRendering()) {
diff --git a/chrome_frame/test/ie_event_sink.h b/chrome_frame/test/ie_event_sink.h
index aa0a2d7..189d98e 100644
--- a/chrome_frame/test/ie_event_sink.h
+++ b/chrome_frame/test/ie_event_sink.h
@@ -97,6 +97,9 @@ class IEEventSink
// be fired when the window closes (async).
HRESULT CloseWebBrowser();
+ // Posts a message to the given target in ChromeFrame. |target| may be "*".
+ void PostMessageToCF(const std::wstring& message, const std::wstring& target);
+
// Set input focus to chrome frame window.
void SetFocusToRenderer();
@@ -108,6 +111,10 @@ class IEEventSink
// SendInput API.
void SendMouseClick(int x, int y, simulate_input::MouseButton button);
+ // Get the HWND for the browser's main window. Will fail test if window
+ // not found.
+ HWND GetBrowserWindow();
+
// Get the HWND for the browser's renderer window. Will fail test if
// renderer window not found.
HWND GetRendererWindow();
diff --git a/chrome_frame/test/mock_ie_event_sink_actions.h b/chrome_frame/test/mock_ie_event_sink_actions.h
index 56fab9f..d6d8160 100644
--- a/chrome_frame/test/mock_ie_event_sink_actions.h
+++ b/chrome_frame/test/mock_ie_event_sink_actions.h
@@ -27,30 +27,24 @@ MATCHER_P(UrlPathEq, url, "equals the path and query portion of the url") {
return arg == chrome_frame_test::GetPathAndQueryFromUrl(url);
}
-ACTION_P3(DelayCloseBrowserMock, loop, delay, mock) {
- loop->PostDelayedTask(FROM_HERE, NewRunnableMethod(mock->event_sink(),
- &IEEventSink::CloseWebBrowser), delay);
-}
-
-ACTION_P(SetFocusToRenderer, mock) {
- simulate_input::SetKeyboardFocusToWindow(
- mock->event_sink()->GetRendererWindow());
-}
+// IWebBrowser2 actions
ACTION_P2(Navigate, mock, navigate_url) {
mock->event_sink()->Navigate(navigate_url);
}
-ACTION_P2(WatchWindow, mock, window_class) {
- mock->WatchWindow(window_class);
+ACTION_P3(DelayNavigateToCurrentUrl, mock, loop, delay) {
+ loop->PostDelayedTask(FROM_HERE, NewRunnableFunction(&NavigateToCurrentUrl,
+ mock), delay);
}
-ACTION_P(StopWindowWatching, mock) {
- mock->StopWatching();
+ACTION_P(CloseBrowserMock, mock) {
+ mock->event_sink()->CloseWebBrowser();
}
-ACTION_P(ExpectRendererHasFocus, mock) {
- mock->event_sink()->ExpectRendererWindowHasFocus();
+ACTION_P3(DelayCloseBrowserMock, loop, delay, mock) {
+ loop->PostDelayedTask(FROM_HERE, NewRunnableMethod(mock->event_sink(),
+ &IEEventSink::CloseWebBrowser), delay);
}
ACTION_P2(ConnectDocPropNotifySink, mock, sink) {
@@ -66,15 +60,6 @@ ACTION_P(DisconnectDocPropNotifySink, sink) {
sink->Detach();
}
-ACTION_P3(DelayNavigateToCurrentUrl, mock, loop, delay) {
- loop->PostDelayedTask(FROM_HERE, NewRunnableFunction(&NavigateToCurrentUrl,
- mock), delay);
-}
-
-ACTION_P2(ExpectDocumentReadystate, mock, ready_state) {
- mock->ExpectDocumentReadystate(ready_state);
-}
-
ACTION_P8(DelayExecCommand, mock, loop, delay, cmd_group_guid, cmd_id,
cmd_exec_opt, in_args, out_args) {
loop->PostDelayedTask(FROM_HERE, NewRunnableMethod(mock->event_sink(),
@@ -82,35 +67,128 @@ ACTION_P8(DelayExecCommand, mock, loop, delay, cmd_group_guid, cmd_id,
out_args), delay);
}
-ACTION_P3(DelayRefresh, mock, loop, delay) {
+ACTION_P3(DelayGoBack, mock, loop, delay) {
loop->PostDelayedTask(FROM_HERE, NewRunnableMethod(mock->event_sink(),
- &IEEventSink::Refresh), delay);
+ &IEEventSink::GoBack), delay);
}
-ACTION_P6(DelaySendMouseClick, mock, loop, delay, x, y, button) {
+ACTION_P3(DelayGoForward, mock, loop, delay) {
loop->PostDelayedTask(FROM_HERE, NewRunnableMethod(mock->event_sink(),
- &IEEventSink::SendMouseClick, x, y, button), delay);
+ &IEEventSink::GoForward), delay);
}
-ACTION_P5(DelaySendDoubleClick, mock, loop, delay, x, y) {
- loop->PostDelayedTask(FROM_HERE, NewRunnableMethod(mock->event_sink(),
- &IEEventSink::SendMouseClick, x, y, simulate_input::LEFT), delay);
+ACTION_P3(DelayRefresh, mock, loop, delay) {
loop->PostDelayedTask(FROM_HERE, NewRunnableMethod(mock->event_sink(),
- &IEEventSink::SendMouseClick, x, y, simulate_input::LEFT), delay + 100);
+ &IEEventSink::Refresh), delay);
}
-ACTION_P4(DelaySendChar, loop, delay, c, mod) {
- loop->PostDelayedTask(FROM_HERE, NewRunnableFunction(
- simulate_input::SendCharA, c, mod), delay);
+// Accessibility-related actions
+
+ACTION_P(AccDoDefaultAction, matcher) {
+ scoped_refptr<AccObject> object;
+ if (FindAccObjectInWindow(arg0, matcher, &object)) {
+ EXPECT_TRUE(object->DoDefaultAction());
+ }
}
-ACTION_P3(DelaySendString, loop, delay, str) {
- loop->PostDelayedTask(FROM_HERE, NewRunnableFunction(
- simulate_input::SendStringW, str), delay);
+ACTION_P(AccLeftClick, matcher) {
+ scoped_refptr<AccObject> object;
+ if (FindAccObjectInWindow(arg0, matcher, &object)) {
+ EXPECT_TRUE(object->LeftClick());
+ }
+}
+
+ACTION_P(AccRightClick, matcher) {
+ scoped_refptr<AccObject> object;
+ if (FindAccObjectInWindow(arg0, matcher, &object)) {
+ EXPECT_TRUE(object->RightClick());
+ }
+}
+
+ACTION_P(AccFocus, matcher) {
+ scoped_refptr<AccObject> object;
+ if (FindAccObjectInWindow(arg0, matcher, &object)) {
+ EXPECT_TRUE(object->Focus());
+ }
+}
+
+ACTION_P(AccSelect, matcher) {
+ scoped_refptr<AccObject> object;
+ if (FindAccObjectInWindow(arg0, matcher, &object)) {
+ EXPECT_TRUE(object->Select());
+ }
+}
+
+ACTION_P2(AccSetValue, matcher, value) {
+ scoped_refptr<AccObject> object;
+ if (FindAccObjectInWindow(arg0, matcher, &object)) {
+ EXPECT_TRUE(object->SetValue(value));
+ }
+}
+
+ACTION_P2(AccDoDefaultActionInRenderer, mock, matcher) {
+ HWND window = mock->event_sink()->GetRendererWindow();
+ scoped_refptr<AccObject> object;
+ if (FindAccObjectInWindow(window, matcher, &object)) {
+ EXPECT_TRUE(object->DoDefaultAction());
+ }
+}
+
+ACTION_P2(AccLeftClickInBrowser, mock, matcher) {
+ HWND window = mock->event_sink()->GetBrowserWindow();
+ scoped_refptr<AccObject> object;
+ if (FindAccObjectInWindow(window, matcher, &object)) {
+ EXPECT_TRUE(object->LeftClick());
+ }
+}
+
+ACTION_P3(AccSetValueInBrowser, mock, matcher, value) {
+ HWND window = mock->event_sink()->GetBrowserWindow();
+ scoped_refptr<AccObject> object;
+ if (FindAccObjectInWindow(window, matcher, &object)) {
+ EXPECT_TRUE(object->SetValue(value));
+ }
+}
+
+ACTION_P2(AccWatchForOneValueChange, observer, matcher) {
+ observer->WatchForOneValueChange(matcher);
+}
+
+// Various other actions
+
+ACTION(OpenContextMenuAsync) {
+ // Special case this implementation because the top-left of the window is
+ // much more likely to be empty than the center.
+ HWND hwnd = arg0;
+ LPARAM coordinates = (1 << 16) | 1;
+ // IE needs both messages in order to work. Chrome does not support
+ // WM_CONTEXTMENU in the renderer: http://crbug.com/51746.
+ ::PostMessage(hwnd, WM_RBUTTONDOWN, 0, coordinates);
+ ::PostMessage(hwnd, WM_RBUTTONUP, 0, coordinates);
+}
+
+ACTION_P(PostCharMessage, character_code) {
+ ::PostMessage(arg0, WM_CHAR, character_code, 0);
+}
+
+ACTION_P2(PostCharMessageToRenderer, mock, character_code) {
+ HWND window = mock->event_sink()->GetRendererWindow();
+ ::PostMessage(window, WM_CHAR, character_code, 0);
+}
+
+ACTION_P2(PostCharMessagesToRenderer, mock, character_codes) {
+ HWND window = mock->event_sink()->GetRendererWindow();
+ std::string codes = character_codes;
+ for (size_t i = 0; i < codes.length(); i++)
+ ::PostMessage(window, WM_CHAR, codes[i], 0);
}
-ACTION_P5(SendExtendedKeysEnter, loop, delay, c, repeat, mod) {
- chrome_frame_test::DelaySendExtendedKeysEnter(loop, delay, c, repeat, mod);
+ACTION_P2(WatchWindow, mock, window_class) {
+ mock->WatchWindow(window_class);
+}
+
+ACTION_P(StopWindowWatching, mock) {
+ mock->StopWatching();
}
namespace {
@@ -133,18 +211,16 @@ ACTION_P(DelayDoCloseWindow, delay) {
delay);
}
-ACTION_P3(DelayGoBack, mock, loop, delay) {
- loop->PostDelayedTask(FROM_HERE, NewRunnableMethod(mock->event_sink(),
- &IEEventSink::GoBack), delay);
+ACTION(KillChromeFrameProcesses) {
+ KillAllNamedProcessesWithArgument(
+ UTF8ToWide(chrome_frame_test::kChromeImageName),
+ UTF8ToWide(switches::kChromeFrame));
}
-ACTION_P3(DelayGoForward, mock, loop, delay) {
- loop->PostDelayedTask(FROM_HERE, NewRunnableMethod(mock->event_sink(),
- &IEEventSink::GoForward), delay);
-}
+// Verifying actions
-ACTION_P(CloseBrowserMock, mock) {
- mock->event_sink()->CloseWebBrowser();
+ACTION_P(ExpectRendererHasFocus, mock) {
+ mock->event_sink()->ExpectRendererWindowHasFocus();
}
ACTION_P(VerifyAddressBarUrl, mock) {
@@ -156,43 +232,6 @@ ACTION_P3(VerifyPageLoad, mock, in_cf, url) {
mock->event_sink()->ExpectAddressBarUrl(url);
}
-ACTION_P4(DelaySendScanCode, loop, delay, c, mod) {
- loop->PostDelayedTask(FROM_HERE, NewRunnableFunction(
- simulate_input::SendScanCode, c, mod), delay);
-}
-
-
-ACTION(KillChromeFrameProcesses) {
- KillAllNamedProcessesWithArgument(
- UTF8ToWide(chrome_frame_test::kChromeImageName),
- UTF8ToWide(switches::kChromeFrame));
-}
-
-// This function selects the address bar via the Alt+d shortcut. This is done
-// via a delayed task which executes after the delay which is passed in.
-// The subsequent operations like typing in the actual url and then hitting
-// enter to force the browser to navigate to it each execute as delayed tasks
-// timed at the delay passed in. The recommended value for delay is 2000 ms
-// to account for the time taken for the accelerator keys to be reflected back
-// from Chrome.
-ACTION_P3(TypeUrlInAddressBar, loop, url, delay) {
- loop->PostDelayedTask(FROM_HERE, NewRunnableFunction(
- simulate_input::SendCharA, 'd', simulate_input::ALT),
- delay);
-
- const unsigned int kInterval = 500;
- int next_delay = delay + kInterval;
-
- loop->PostDelayedTask(FROM_HERE, NewRunnableFunction(
- simulate_input::SendStringW, url), next_delay);
-
- next_delay = next_delay + kInterval;
-
- loop->PostDelayedTask(FROM_HERE, NewRunnableFunction(
- simulate_input::SendCharA, VK_RETURN, simulate_input::NONE),
- next_delay);
-}
-
ACTION_P5(ValidateWindowSize, mock, left, top, width, height) {
int actual_left = 0;
int actual_top = 0;
@@ -220,8 +259,12 @@ ACTION_P(VerifyAddressBarUrlWithGcf, mock) {
mock->event_sink()->ExpectAddressBarUrl(expected_url);
}
-// Polls to see if the file is saved and closes the browser once it is.
-// This doesn't do any checking of the contents of the file.
+ACTION_P2(ExpectDocumentReadystate, mock, ready_state) {
+ mock->ExpectDocumentReadystate(ready_state);
+}
+
+// Polling actions
+
ACTION_P3(CloseWhenFileSaved, mock, file, timeout_ms) {
base::Time start = base::Time::Now();
while (!file_util::PathExists(file)) {
@@ -234,89 +277,42 @@ ACTION_P3(CloseWhenFileSaved, mock, file, timeout_ms) {
mock->event_sink()->CloseWebBrowser();
}
-ACTION_P2(OpenContextMenu, loop, delay) {
- loop->PostDelayedTask(FROM_HERE, NewRunnableFunction(
- simulate_input::SendScanCode, VK_F10, simulate_input::SHIFT), delay);
-}
+// Flaky actions
-ACTION_P3(SelectItem, loop, delay, index) {
- chrome_frame_test::DelaySendExtendedKeysEnter(loop, delay, VK_DOWN, index + 1,
- simulate_input::NONE);
+ACTION_P(SetFocusToRenderer, mock) {
+ simulate_input::SetKeyboardFocusToWindow(
+ mock->event_sink()->GetRendererWindow());
}
-ACTION(FocusWindow) {
- scoped_refptr<AccObject> object;
- if (FindAccObjectInWindow(arg0, AccObjectMatcher(), &object))
- object->Focus();
+ACTION_P4(DelaySendChar, loop, delay, c, mod) {
+ loop->PostDelayedTask(FROM_HERE, NewRunnableFunction(
+ simulate_input::SendCharA, c, mod), delay);
}
-ACTION_P(DoDefaultAction, matcher) {
- scoped_refptr<AccObject> object;
- if (FindAccObjectInWindow(arg0, matcher, &object))
- object->DoDefaultAction();
+ACTION_P4(DelaySendScanCode, loop, delay, c, mod) {
+ loop->PostDelayedTask(FROM_HERE, NewRunnableFunction(
+ simulate_input::SendScanCode, c, mod), delay);
}
-ACTION_P(FocusAccObject, matcher) {
- scoped_refptr<AccObject> object;
- if (FindAccObjectInWindow(arg0, matcher, &object))
- object->Focus();
-}
+// This function selects the address bar via the Alt+d shortcut.
+ACTION_P3(TypeUrlInAddressBar, loop, url, delay) {
+ loop->PostDelayedTask(FROM_HERE, NewRunnableFunction(
+ simulate_input::SendCharA, 'd', simulate_input::ALT),
+ delay);
-ACTION_P(SelectAccObject, matcher) {
- scoped_refptr<AccObject> object;
- if (FindAccObjectInWindow(arg0, matcher, &object))
- object->Select();
-}
+ const unsigned int kInterval = 500;
+ int next_delay = delay + kInterval;
-ACTION_P2(SetAccObjectValue, matcher, value) {
- scoped_refptr<AccObject> object;
- if (FindAccObjectInWindow(arg0, matcher, &object))
- object->SetValue(value);
-}
+ loop->PostDelayedTask(FROM_HERE, NewRunnableFunction(
+ simulate_input::SendStringW, url), next_delay);
-ACTION(OpenContextMenuAsync) {
- // Special case this implementation because the top-left of the window is
- // much more likely to be empty than the center.
- HWND hwnd = arg0;
- scoped_refptr<AccObject> object;
- // TODO(kkania): Switch to using WM_CONTEXTMENU with coordinates -1, -1
- // when Chrome supports this. See render_widget_host_view_win.h.
- LPARAM coordinates = (1 << 16) | 1;
- // IE needs both messages in order to work.
- ::PostMessage(hwnd, WM_RBUTTONDOWN, (WPARAM)0, coordinates);
- ::PostMessage(hwnd, WM_RBUTTONUP, (WPARAM)0, coordinates);
-}
+ next_delay = next_delay + kInterval;
-ACTION_P(OpenContextMenuAsync, matcher) {
- HWND hwnd = arg0;
- scoped_refptr<AccObject> object;
- if (FindAccObjectInWindow(hwnd, matcher, &object)) {
- // TODO(kkania): Switch to using WM_CONTEXTMENU with coordinates -1, -1
- // when Chrome supports this. See render_widget_host_view_win.h.
- gfx::Rect object_rect;
- bool got_location = object->GetLocation(&object_rect);
- EXPECT_TRUE(got_location) << "Could not get bounding rect for object: "
- << object->GetDescription();
- if (got_location) {
- // WM_RBUTTON* messages expect a relative coordinate, while GetLocation
- // returned a screen coordinate. Adjust.
- RECT rect;
- BOOL got_window_rect = ::GetWindowRect(hwnd, &rect);
- EXPECT_TRUE(got_window_rect) << "Could not get window bounds";
- if (got_window_rect) {
- gfx::Rect window_rect(rect);
- gfx::Point relative_origin =
- object_rect.CenterPoint().Subtract(window_rect.origin());
- LPARAM coordinates = (relative_origin.y() << 16) | relative_origin.x();
- // IE needs both messages in order to work.
- ::PostMessage(hwnd, WM_RBUTTONDOWN, (WPARAM)0, coordinates);
- ::PostMessage(hwnd, WM_RBUTTONUP, (WPARAM)0, coordinates);
- }
- }
- }
+ loop->PostDelayedTask(FROM_HERE, NewRunnableFunction(
+ simulate_input::SendCharA, VK_RETURN, simulate_input::NONE),
+ next_delay);
}
} // namespace chrome_frame_test
#endif // CHROME_FRAME_TEST_MOCK_IE_EVENT_SINK_ACTIONS_H_
-
diff --git a/chrome_frame/test/mock_ie_event_sink_test.cc b/chrome_frame/test/mock_ie_event_sink_test.cc
index b6e0146..9037358 100644
--- a/chrome_frame/test/mock_ie_event_sink_test.cc
+++ b/chrome_frame/test/mock_ie_event_sink_test.cc
@@ -100,12 +100,10 @@ void MockIEEventSink::ExpectNavigation(bool is_cf, const std::wstring& url) {
}
}
-void MockIEEventSink::ExpectInPageNavigation(bool is_cf,
- const std::wstring& url) {
+void MockIEEventSink::ExpectNavigationOptionalBefore(bool is_cf,
+ const std::wstring& url) {
InSequence expect_in_sequence_for_scope;
if (is_cf && GetInstalledIEVersion() == IE_6) {
- // OnBeforeNavigation events are not sent for navigation between different
- // anchors in a CF page in IE6.
ExpectNavigationCardinality(url, testing::AtMost(1),
testing::Between(1, 2));
} else {
@@ -115,14 +113,11 @@ void MockIEEventSink::ExpectInPageNavigation(bool is_cf,
void MockIEEventSink::ExpectJavascriptWindowOpenNavigation(
bool parent_cf, bool new_window_cf, const std::wstring& url) {
- DCHECK(!(parent_cf && !new_window_cf)) << "Cannot expect popup to be loaded"
- " in Internet Explorer if parent window is loaded in Chrome Frame.";
-
if (parent_cf) {
InSequence expect_in_sequence_for_scope;
ExpectNavigation(IN_CF, L"");
ExpectNavigationCardinality(L"", testing::AtMost(1),
- testing::Between(1, 2));
+ testing::Between(1, 2));
} else {
if (new_window_cf) {
ExpectNavigationCardinality(url, testing::AtMost(1), testing::AtMost(1));
diff --git a/chrome_frame/test/mock_ie_event_sink_test.h b/chrome_frame/test/mock_ie_event_sink_test.h
index 75ecf4d..4a1e31d 100644
--- a/chrome_frame/test/mock_ie_event_sink_test.h
+++ b/chrome_frame/test/mock_ie_event_sink_test.h
@@ -9,9 +9,11 @@
#include <atlcom.h>
#include <string>
+#include "base/file_path.h"
#include "base/string_number_conversions.h"
#include "base/utf_string_conversions.h"
#include "chrome_frame/test/chrome_frame_test_utils.h"
+#include "chrome_frame/test/chrome_frame_ui_test_utils.h"
#include "chrome_frame/test/ie_event_sink.h"
#include "chrome_frame/test/test_server.h"
#include "chrome_frame/test/test_with_web_server.h"
@@ -97,9 +99,11 @@ class MockIEEventSink : public IEEventListener {
// Expect a normal navigation to |url| to occur in CF or IE.
void ExpectNavigation(bool is_cf, const std::wstring& url);
- // Same as above, but used when the new navigation is to a diffrent fragment
- // in the same page.
- void ExpectInPageNavigation(bool is_cf, const std::wstring& url);
+ // Similar as above, but should be used in cases where IE6 with CF may not
+ // generate an OnBeforeNavigate event during the navigation. This occurs
+ // during in-page navigation (via anchors), form submission, window.open
+ // to target "self", and possibly others.
+ void ExpectNavigationOptionalBefore(bool is_cf, const std::wstring& url);
// Expect a navigation in a new window created by a window.open call to |url|.
// |parent_cf| signifies whether the parent frame was loaded in CF, while
@@ -217,9 +221,11 @@ class MockWindowObserver : public WindowObserver {
WindowWatchdog window_watcher_;
};
-class MockAccessibilityEventObserver : public AccessibilityEventObserver {
+class MockAccEventObserver : public AccEventObserver {
public:
MOCK_METHOD1(OnAccDocLoad, void (HWND)); // NOLINT
+ MOCK_METHOD3(OnAccValueChange, void (HWND, AccObject*, // NOLINT
+ const std::wstring&));
MOCK_METHOD1(OnMenuPopup, void (HWND)); // NOLINT
};
diff --git a/chrome_frame/test/navigation_test.cc b/chrome_frame/test/navigation_test.cc
index 76cad4e..89a78e6 100644
--- a/chrome_frame/test/navigation_test.cc
+++ b/chrome_frame/test/navigation_test.cc
@@ -20,8 +20,6 @@ using testing::StrEq;
namespace chrome_frame_test {
-const wchar_t tab_enter_keys[] = { VK_TAB, VK_RETURN, 0 };
-
// Test fixture for navigation-related tests. Each test is run thrice: IE, CF
// with meta tag invocation, and CF with http header invocation. This is
// accomplished by using gTest's parameterized test.
@@ -41,13 +39,22 @@ INSTANTIATE_TEST_CASE_P(HttpHeader, FullTabNavigationTest, testing::Values(
CFInvocation(CFInvocation::HTTP_HEADER)));
// This tests navigation to a typed URL.
-TEST_P(FullTabNavigationTest, FLAKY_TypeUrl) {
+TEST_P(FullTabNavigationTest, TypeUrl) {
+ MockAccEventObserver acc_observer;
+ EXPECT_CALL(acc_observer, OnAccDocLoad(_)).Times(testing::AnyNumber());
+ AccObjectMatcher address_matcher(L"Address", L"editable text");
+ AccObjectMatcher go_matcher(L"Go*", L"push button");
+
ie_mock_.ExpectNavigation(IN_IE, GetSimplePageUrl());
server_mock_.ExpectAndServeRequest(CFInvocation::None(), GetSimplePageUrl());
+ // Enter the new url into the address bar.
EXPECT_CALL(ie_mock_, OnLoad(IN_IE, StrEq(GetSimplePageUrl())))
.WillOnce(testing::DoAll(
- SetFocusToRenderer(&ie_mock_),
- TypeUrlInAddressBar(&loop_, GetAnchorPageUrl(0), 2000)));
+ AccSetValueInBrowser(&ie_mock_, address_matcher, GetAnchorPageUrl(0)),
+ AccWatchForOneValueChange(&acc_observer, address_matcher)));
+ // Click the go button once the address has changed.
+ EXPECT_CALL(acc_observer, OnAccValueChange(_, _, GetAnchorPageUrl(0)))
+ .WillOnce(AccLeftClickInBrowser(&ie_mock_, go_matcher));
bool in_cf = GetParam().invokes_cf();
ie_mock_.ExpectNavigation(in_cf, GetAnchorPageUrl(0));
@@ -59,18 +66,26 @@ TEST_P(FullTabNavigationTest, FLAKY_TypeUrl) {
}
// This tests navigation to a typed URL containing an fragment.
-TEST_P(FullTabNavigationTest, FLAKY_TypeAnchorUrl) {
+TEST_P(FullTabNavigationTest, TypeAnchorUrl) {
if (IsIBrowserServicePatchEnabled()) {
LOG(ERROR) << "Not running test. IBrowserServicePatch is in place.";
return;
}
+ MockAccEventObserver acc_observer;
+ EXPECT_CALL(acc_observer, OnAccDocLoad(_)).Times(testing::AnyNumber());
+ AccObjectMatcher address_matcher(L"Address", L"editable text");
+ AccObjectMatcher go_matcher(L"Go*", L"push button");
ie_mock_.ExpectNavigation(IN_IE, GetSimplePageUrl());
server_mock_.ExpectAndServeRequest(CFInvocation::None(), GetSimplePageUrl());
+ // Enter the new url into the address bar.
EXPECT_CALL(ie_mock_, OnLoad(IN_IE, StrEq(GetSimplePageUrl())))
.WillOnce(testing::DoAll(
- SetFocusToRenderer(&ie_mock_),
- TypeUrlInAddressBar(&loop_, GetAnchorPageUrl(1), 2000)));
+ AccSetValueInBrowser(&ie_mock_, address_matcher, GetAnchorPageUrl(1)),
+ AccWatchForOneValueChange(&acc_observer, address_matcher)));
+ // Click the go button once the address has changed.
+ EXPECT_CALL(acc_observer, OnAccValueChange(_, _, GetAnchorPageUrl(1)))
+ .WillOnce(AccLeftClickInBrowser(&ie_mock_, go_matcher));
bool in_cf = GetParam().invokes_cf();
ie_mock_.ExpectNavigation(in_cf, GetAnchorPageUrl(1));
@@ -81,38 +96,23 @@ TEST_P(FullTabNavigationTest, FLAKY_TypeAnchorUrl) {
LaunchIEAndNavigate(GetSimplePageUrl());
}
-// Tests refreshing when a cached copy is available.
-TEST_P(FullTabNavigationTest, FLAKY_RefreshWithCachedCopy) {
+// Tests refreshing causes a page load.
+TEST_P(FullTabNavigationTest, Refresh) {
if (GetInstalledIEVersion() == IE_7) {
LOG(ERROR) << "Test disabled for this configuration.";
return;
}
bool in_cf = GetParam().invokes_cf();
- ie_mock_.ExpectAnyNavigations();
- InSequence expect_in_scope_for_sequence;
-
- testing::Cardinality initial_req_cardinality = testing::Exactly(1);
- // TODO(kkania): Remove this allowance for double request on meta tag when no
- // longer necessary.
- if (GetParam().type() == CFInvocation::META_TAG)
- initial_req_cardinality = testing::Between(1, 2);
- EXPECT_CALL(server_mock_, Get(_, UrlPathEq(GetSimplePageUrl()), _))
- .Times(initial_req_cardinality)
- .WillRepeatedly(SendAllowCacheResponse(&server_mock_, GetParam()));
+ server_mock_.ExpectAndServeAnyRequests(GetParam());
+ InSequence expect_in_sequence_for_scope;
+
+ ie_mock_.ExpectNavigation(IN_IE, GetSimplePageUrl());
EXPECT_CALL(ie_mock_, OnLoad(in_cf, StrEq(GetSimplePageUrl())))
- .WillOnce(testing::DoAll(
- SetFocusToRenderer(&ie_mock_),
- DelayRefresh(&ie_mock_, &loop_, 0)));
+ .WillOnce(DelayRefresh(&ie_mock_, &loop_, 0));
if (in_cf) {
- // For some reason IE7 requests the resource again.
- if (GetInstalledIEVersion() == IE_7) {
- server_mock_.ExpectAndServeRequest(GetParam(), GetSimplePageUrl());
- }
EXPECT_CALL(ie_mock_, OnLoad(in_cf, StrEq(GetSimplePageUrl())))
- .WillOnce(testing::DoAll(
- SetFocusToRenderer(&ie_mock_),
- CloseBrowserMock(&ie_mock_)));
+ .WillOnce(CloseBrowserMock(&ie_mock_));
} else {
// For some reason IE still requests the resource again, but does not
// trigger another load.
@@ -124,7 +124,7 @@ TEST_P(FullTabNavigationTest, FLAKY_RefreshWithCachedCopy) {
}
// Test that multiple back and forward requests work.
-TEST_P(FullTabNavigationTest, FLAKY_MultipleBackForward) {
+TEST_P(FullTabNavigationTest, MultipleBackForward) {
std::wstring page1 = GetSimplePageUrl();
std::wstring page2 = GetLinkPageUrl();
std::wstring page3 = GetAnchorPageUrl(0);
@@ -185,65 +185,53 @@ TEST_P(FullTabNavigationTest, FLAKY_MultipleBackForward) {
VerifyAddressBarUrl(&ie_mock_),
CloseBrowserMock(&ie_mock_)));
- LaunchIEAndNavigate(page1);
+ LaunchIENavigateAndLoop(page1,
+ kChromeFrameLongNavigationTimeoutInSeconds * 2);
}
// Test multiple back and forward operations among urls with anchors.
-// Marking this test FLAKY as it fails at times on the buildbot.
-// http://code.google.com/p/chromium/issues/detail?id=26549
-TEST_P(FullTabNavigationTest, FLAKY_BackForwardAnchor) {
+TEST_P(FullTabNavigationTest, BackForwardAnchor) {
bool in_cf = GetParam().invokes_cf();
- if (!in_cf) {
- LOG(ERROR) << "Test not yet implemented.";
- return;
- }
+ ie_mock_.ExpectAnyNavigations();
server_mock_.ExpectAndServeAnyRequests(GetParam());
- InSequence expect_in_sequence_for_scope;
+ MockAccEventObserver acc_observer;
- // Navigate to anchor 1:
- // - First set focus to chrome renderer window
- // Call WebBrowserEventSink::SetFocusToRenderer only once
- // in the beginning. Calling it again will change focus from the
- // current location to an element near the simulated mouse click.
- // - Then send keyboard input of TAB + ENTER to cause navigation.
- // It's better to send input as PostDelayedTask since the Activex
- // message loop_ on the other side might be blocked when we get
- // called in Onload.
+ // Navigate to anchor 1.
// Back/Forward state at this point:
// Back: 0
// Forward: 0
- ie_mock_.ExpectNavigation(in_cf, GetAnchorPageUrl(0));
EXPECT_CALL(ie_mock_, OnLoad(in_cf, StrEq(GetAnchorPageUrl(0))))
- .WillOnce(testing::DoAll(
- SetFocusToRenderer(&ie_mock_),
- DelaySendString(&loop_, 500, tab_enter_keys)));
+ .Times(testing::AtMost(1));
+ EXPECT_CALL(acc_observer, OnAccDocLoad(_))
+ .WillOnce(AccDoDefaultAction(AccObjectMatcher(L"*1", L"link")))
+ .WillRepeatedly(testing::Return());
+ InSequence expect_in_sequence_for_scope;
// Navigate to anchor 2 after the previous navigation is complete
// Back/Forward state at this point:
// Back: 1 (kAnchorUrl)
// Forward: 0
- ie_mock_.ExpectInPageNavigation(in_cf, GetAnchorPageUrl(1));
EXPECT_CALL(ie_mock_, OnLoad(in_cf, StrEq(GetAnchorPageUrl(1))))
.WillOnce(testing::DoAll(
VerifyAddressBarUrl(&ie_mock_),
- DelaySendString(&loop_, 500, tab_enter_keys)));
+ AccDoDefaultActionInRenderer(&ie_mock_,
+ AccObjectMatcher(L"*2", L"link"))));
// Navigate to anchor 3 after the previous navigation is complete
// Back/Forward state at this point:
// Back: 2 (kAnchorUrl, kAnchor1Url)
// Forward: 0
- ie_mock_.ExpectInPageNavigation(in_cf, GetAnchorPageUrl(2));
EXPECT_CALL(ie_mock_, OnLoad(in_cf, StrEq(GetAnchorPageUrl(2))))
.WillOnce(testing::DoAll(
VerifyAddressBarUrl(&ie_mock_),
- DelaySendString(&loop_, 500, tab_enter_keys)));
+ AccDoDefaultActionInRenderer(&ie_mock_,
+ AccObjectMatcher(L"*3", L"link"))));
// We will reach anchor 3 once the navigation is complete,
// then go back to anchor 2
// Back/Forward state at this point:
// Back: 3 (kAnchorUrl, kAnchor1Url, kAnchor2Url)
// Forward: 0
- ie_mock_.ExpectInPageNavigation(in_cf, GetAnchorPageUrl(3));
EXPECT_CALL(ie_mock_, OnLoad(in_cf, StrEq(GetAnchorPageUrl(3))))
.WillOnce(testing::DoAll(
VerifyAddressBarUrl(&ie_mock_),
@@ -254,7 +242,6 @@ TEST_P(FullTabNavigationTest, FLAKY_BackForwardAnchor) {
// Back/Forward state at this point:
// Back: 3 (kAnchorUrl, kAnchor1Url, kAnchor2Url)
// Forward: 1 (kAnchor3Url)
- ie_mock_.ExpectNavigation(in_cf, GetAnchorPageUrl(2));
EXPECT_CALL(ie_mock_, OnLoad(in_cf, StrEq(GetAnchorPageUrl(2))))
.WillOnce(testing::DoAll(
VerifyAddressBarUrl(&ie_mock_),
@@ -265,7 +252,6 @@ TEST_P(FullTabNavigationTest, FLAKY_BackForwardAnchor) {
// Back/Forward state at this point:
// Back: 2 (kAnchorUrl, kAnchor1Url)
// Forward: 2 (kAnchor2Url, kAnchor3Url)
- ie_mock_.ExpectNavigation(in_cf, GetAnchorPageUrl(1));
EXPECT_CALL(ie_mock_, OnLoad(in_cf, StrEq(GetAnchorPageUrl(1))))
.WillOnce(testing::DoAll(
VerifyAddressBarUrl(&ie_mock_),
@@ -275,14 +261,12 @@ TEST_P(FullTabNavigationTest, FLAKY_BackForwardAnchor) {
// Back/Forward state at this point:
// Back: 3 (kAnchorUrl, kAnchor1Url, kAnchor2Url)
// Forward: 1 (kAnchor3Url)
- ie_mock_.ExpectNavigation(in_cf, GetAnchorPageUrl(2));
EXPECT_CALL(ie_mock_, OnLoad(in_cf, StrEq(GetAnchorPageUrl(2))))
.WillOnce(testing::DoAll(
VerifyAddressBarUrl(&ie_mock_),
DelayGoForward(&ie_mock_, &loop_, 0)));
// We have gone a few steps back and forward, this should be enough for now.
- ie_mock_.ExpectNavigation(in_cf, GetAnchorPageUrl(3));
EXPECT_CALL(ie_mock_, OnLoad(in_cf, StrEq(GetAnchorPageUrl(3))))
.WillOnce(CloseBrowserMock(&ie_mock_));
@@ -361,16 +345,18 @@ TEST_P(FullTabNavigationTest, DISABLED_JavascriptWindowOpenDifferentDomain) {
}
std::wstring parent_url =
GetTestUrl(L"window_open.html?http://www.nonexistent.com");
+ MockAccEventObserver acc_observer;
MockIEEventSink new_window_mock;
ie_mock_.ExpectAnyNavigations();
new_window_mock.ExpectAnyNavigations();
server_mock_.ExpectAndServeAnyRequests(GetParam());
- EXPECT_CALL(ie_mock_, OnLoad(GetParam().invokes_cf(), StrEq(parent_url)))
- .WillOnce(DelaySendDoubleClick(&ie_mock_, &loop_, 0, 10, 10));
+ EXPECT_CALL(ie_mock_, OnLoad(GetParam().invokes_cf(), StrEq(parent_url)));
+ EXPECT_CALL(acc_observer, OnAccDocLoad(_))
+ .WillOnce(AccLeftClick(AccObjectMatcher()))
+ .WillRepeatedly(testing::Return());
ie_mock_.ExpectNewWindow(&new_window_mock);
-
EXPECT_CALL(new_window_mock, OnNavigateError(_, _, _, _, _))
.Times(1)
.WillOnce(CloseBrowserMock(&new_window_mock));
@@ -388,35 +374,34 @@ TEST_P(FullTabNavigationTest, DISABLED_JavascriptWindowOpenDifferentDomain) {
ASSERT_TRUE(new_window_mock.event_sink()->web_browser2() != NULL);
}
-// Tests that a page that calls window.open can then close the popup.
-// Marking this test as FLAKY initially as it relies on getting focus and user
-// input which don't work correctly at times.
-// http://code.google.com/p/chromium/issues/detail?id=26549
-TEST_P(FullTabNavigationTest, FLAKY_JavascriptWindowOpenCanClose) {
- std::wstring parent_url =
- GetTestUrl(L"window_open.html?simple.html");
+// Tests that the parent window can successfully close its popup through
+// the javascript close method.
+TEST_P(FullTabNavigationTest, JavascriptWindowOpenCanClose) {
+ std::wstring parent_url = GetTestUrl(L"window_open.html?simple.html");
+ MockAccEventObserver acc_observer;
MockIEEventSink new_window_mock;
ie_mock_.ExpectAnyNavigations();
new_window_mock.ExpectAnyNavigations();
server_mock_.ExpectAndServeAnyRequests(GetParam());
- // Sending 'A' to the renderer should cause window.open then window.close.
- EXPECT_CALL(ie_mock_, OnLoad(GetParam().invokes_cf(), StrEq(parent_url)))
- .WillOnce(DelaySendDoubleClick(&ie_mock_, &loop_, 0, 10, 10));
+ // Tell the page to open the popup. Some versions of IE will prevent a popup
+ // unless a click is involved.
+ EXPECT_CALL(ie_mock_, OnLoad(GetParam().invokes_cf(), StrEq(parent_url)));
+ EXPECT_CALL(acc_observer, OnAccDocLoad(_))
+ .WillOnce(AccLeftClick(AccObjectMatcher()))
+ .WillRepeatedly(testing::Return());
ie_mock_.ExpectNewWindow(&new_window_mock);
-
EXPECT_CALL(new_window_mock, OnLoad(_, StrEq(GetSimplePageUrl())))
.Times(testing::AtMost(2))
- .WillOnce(testing::DoAll(
- SetFocusToRenderer(&ie_mock_),
- DelaySendChar(&loop_, 500, 'C', simulate_input::NONE)))
- .WillOnce(testing::Return()); // just to stop a gmock warning
+ .WillOnce(PostCharMessageToRenderer(&ie_mock_, 'C')) // close the popup
+ .WillOnce(testing::Return());
EXPECT_CALL(new_window_mock, OnQuit())
.WillOnce(CloseBrowserMock(&ie_mock_));
- LaunchIEAndNavigate(parent_url);
+ LaunchIENavigateAndLoop(parent_url,
+ kChromeFrameLongNavigationTimeoutInSeconds * 2);
}
// Parameter for tests using the NavigationTransitionTest fixture. Includes two
@@ -451,9 +436,6 @@ class NavigationTransitionTest
// This instantiates each parameterized test with some of the different CF
// invocation methods.
-// TODO(kkania): Do not allow these tests to be cache the pages. This is used
-// currently because otherwise the meta tags can cause double requests. Change
-// ExpectAndServeRequestAllowCache to ExpectAndServeRequest when allowed.
INSTANTIATE_TEST_CASE_P(
IEToIE,
NavigationTransitionTest,
@@ -481,29 +463,29 @@ INSTANTIATE_TEST_CASE_P(
CFInvocation::META_TAG, CFInvocation::NONE)));
// Test window.open calls.
-// Marking this test as FLAKY initially as it relies on getting focus and user
-// input which don't work correctly at times.
-// http://code.google.com/p/chromium/issues/detail?id=26549
-TEST_P(NavigationTransitionTest, FLAKY_JavascriptWindowOpen) {
+TEST_P(NavigationTransitionTest, JavascriptWindowOpen) {
std::wstring parent_url = GetTestUrl(L"window_open.html?simple.html");
std::wstring new_window_url = GetSimplePageUrl();
+ MockAccEventObserver acc_observer;
testing::StrictMock<MockIEEventSink> new_window_mock;
ie_mock_.ExpectNavigation(page1_.invokes_cf(), parent_url);
- server_mock_.ExpectAndServeRequestAllowCache(page1_, parent_url);
- EXPECT_CALL(ie_mock_, OnLoad(page1_.invokes_cf(), StrEq(parent_url)))
- .WillOnce(DelaySendDoubleClick(&ie_mock_, &loop_, 0, 10, 10));
+ server_mock_.ExpectAndServeRequest(page1_, parent_url);
+ EXPECT_CALL(ie_mock_, OnLoad(page1_.invokes_cf(), StrEq(parent_url)));
+ // Tell the page to open the popup. Some versions of IE will prevent a popup
+ // unless a click is involved.
+ EXPECT_CALL(acc_observer, OnAccDocLoad(_))
+ .WillOnce(AccLeftClick(AccObjectMatcher()))
+ .WillRepeatedly(testing::Return());
- // If the parent window is in CF, the child will load in CF regardless of
- // whether the child page invokes CF.
+ // If the parent window is in CF, the child should always load in CF since
+ // the domain is the same.
bool expect_cf = page1_.invokes_cf() || page2_.invokes_cf();
ie_mock_.ExpectNewWindow(&new_window_mock);
new_window_mock.ExpectJavascriptWindowOpenNavigation(page1_.invokes_cf(),
expect_cf,
new_window_url);
- EXPECT_CALL(server_mock_, Get(_, UrlPathEq(new_window_url), _))
- .Times(testing::AtMost(1))
- .WillOnce(SendAllowCacheResponse(&server_mock_, page2_));
+ server_mock_.ExpectAndServeRequest(page2_, new_window_url);
EXPECT_CALL(new_window_mock, OnLoad(expect_cf, StrEq(new_window_url)))
.WillOnce(testing::DoAll(
ValidateWindowSize(&new_window_mock, 10, 10, 250, 250),
@@ -522,12 +504,12 @@ TEST_P(NavigationTransitionTest, DISABLED_JavascriptRedirection) {
std::wstring redirect_url = GetTestUrl(L"javascript_redirect.html");
ie_mock_.ExpectNavigation(page1_.invokes_cf(), redirect_url);
- server_mock_.ExpectAndServeRequestAllowCache(page1_, redirect_url);
+ server_mock_.ExpectAndServeRequest(page1_, redirect_url);
EXPECT_CALL(ie_mock_, OnLoad(page1_.invokes_cf(), StrEq(redirect_url)))
.WillOnce(VerifyAddressBarUrl(&ie_mock_));
ie_mock_.ExpectNavigation(page2_.invokes_cf(), GetSimplePageUrl());
- server_mock_.ExpectAndServeRequestAllowCache(page2_, GetSimplePageUrl());
+ server_mock_.ExpectAndServeRequest(page2_, GetSimplePageUrl());
EXPECT_CALL(ie_mock_, OnLoad(page2_.invokes_cf(), StrEq(GetSimplePageUrl())))
.WillOnce(testing::DoAll(
VerifyAddressBarUrl(&ie_mock_),
@@ -545,7 +527,7 @@ TEST_P(NavigationTransitionTest, FollowLink) {
LOG(ERROR) << "Test disabled for this configuration.";
return;
}
- MockAccessibilityEventObserver acc_observer;
+ MockAccEventObserver acc_observer;
EXPECT_CALL(acc_observer, OnAccDocLoad(_)).Times(testing::AnyNumber());
ie_mock_.ExpectNavigation(page1_.invokes_cf(), GetLinkPageUrl());
@@ -555,7 +537,7 @@ TEST_P(NavigationTransitionTest, FollowLink) {
.WillRepeatedly(SendResponse(&server_mock_, page1_));
EXPECT_CALL(ie_mock_, OnLoad(page1_.invokes_cf(), StrEq(GetLinkPageUrl())));
EXPECT_CALL(acc_observer, OnAccDocLoad(_))
- .WillOnce(DoDefaultAction(AccObjectMatcher(L"", L"link")))
+ .WillOnce(AccDoDefaultAction(AccObjectMatcher(L"", L"link")))
.RetiresOnSaturation();
ie_mock_.ExpectNavigation(page2_.invokes_cf(), GetSimplePageUrl());
@@ -637,7 +619,7 @@ TEST_F(NavigationTest, DISABLED_DownloadInNewWindow) {
LaunchIEAndNavigate(kDownloadFromNewWin);
}
-TEST_P(FullTabNavigationTest, FLAKY_FormPostBackForward) {
+TEST_P(FullTabNavigationTest, FormPostBackForward) {
bool in_cf = GetParam().invokes_cf();
// Navigate to the form-get.html page:
// - First set focus to chrome renderer window
@@ -646,23 +628,24 @@ TEST_P(FullTabNavigationTest, FLAKY_FormPostBackForward) {
// action.html page.
// Navigate backwards from the action.html page and then navigate forward
// from the form-get.html page.
-
- std::wstring kFormPostUrl =
- GetTestUrl(L"form-get.html");
-
+ std::wstring kFormPostUrl = GetTestUrl(L"form-get.html");
std::wstring kFormPostActionUrl =
GetTestUrl(L"action.html?field1=a&field2=b&submit=Submit");
+ MockAccEventObserver acc_observer;
server_mock_.ExpectAndServeAnyRequests(GetParam());
+
+ EXPECT_CALL(acc_observer, OnAccDocLoad(_))
+ .Times(testing::AtLeast(1))
+ .WillOnce(AccDoDefaultAction(AccObjectMatcher(L"Submit")))
+ .WillRepeatedly(testing::Return());
+
InSequence expect_in_sequence_for_scope;
ie_mock_.ExpectNavigation(in_cf, kFormPostUrl);
- EXPECT_CALL(ie_mock_, OnLoad(in_cf, StrEq(kFormPostUrl)))
- .WillOnce(testing::DoAll(
- SetFocusToRenderer(&ie_mock_),
- DelaySendChar(&loop_, 500, 'C', simulate_input::NONE)));
+ EXPECT_CALL(ie_mock_, OnLoad(in_cf, StrEq(kFormPostUrl)));
- ie_mock_.ExpectNavigation(in_cf, kFormPostActionUrl);
+ ie_mock_.ExpectNavigationOptionalBefore(in_cf, kFormPostActionUrl);
EXPECT_CALL(ie_mock_, OnLoad(in_cf, StrEq(kFormPostActionUrl)))
.WillOnce(testing::DoAll(
VerifyAddressBarUrl(&ie_mock_),
@@ -674,7 +657,7 @@ TEST_P(FullTabNavigationTest, FLAKY_FormPostBackForward) {
VerifyAddressBarUrl(&ie_mock_),
DelayGoForward(&ie_mock_, &loop_, 0)));
- ie_mock_.ExpectNavigation(in_cf, kFormPostActionUrl);
+ ie_mock_.ExpectNavigationOptionalBefore(in_cf, kFormPostActionUrl);
EXPECT_CALL(ie_mock_, OnLoad(in_cf, StrEq(kFormPostActionUrl)))
.WillOnce(CloseBrowserMock(&ie_mock_));
@@ -700,7 +683,7 @@ TEST_P(FullTabNavigationTest, CF_UnloadEventTest) {
ie_mock_.ExpectNavigation(in_cf, kUnloadEventTestUrl);
EXPECT_CALL(ie_mock_, OnLoad(in_cf, StrEq(kUnloadEventTestUrl)));
- ie_mock_.ExpectNavigation(in_cf, kUnloadEventMainUrl);
+ ie_mock_.ExpectNavigationOptionalBefore(in_cf, kUnloadEventMainUrl);
EXPECT_CALL(ie_mock_, OnLoad(in_cf, StrEq(kUnloadEventMainUrl)));
EXPECT_CALL(ie_mock_, OnMessage(_, _, _))
diff --git a/chrome_frame/test/ui_test.cc b/chrome_frame/test/ui_test.cc
index 3781951..54fd0d2 100644
--- a/chrome_frame/test/ui_test.cc
+++ b/chrome_frame/test/ui_test.cc
@@ -7,6 +7,7 @@
#include "base/scoped_variant_win.h"
#include "base/test/test_file_util.h"
+#include "base/utf_string_conversions.h"
#include "chrome/common/url_constants.h"
#include "chrome_frame/test/chrome_frame_test_utils.h"
#include "chrome_frame/test/chrome_frame_ui_test_utils.h"
@@ -46,22 +47,18 @@ INSTANTIATE_TEST_CASE_P(CF, FullTabUITest,
testing::Values(CFInvocation::MetaTag()));
// Tests keyboard input.
-// Marking this test FLAKY as it fails at times on the buildbot.
-// http://code.google.com/p/chromium/issues/detail?id=26549
-TEST_P(FullTabUITest, FLAKY_KeyboardInput) {
+TEST_P(FullTabUITest, KeyboardInput) {
if (!GetParam().invokes_cf()) {
LOG(ERROR) << "Test not implemented for this configuration.";
return;
}
std::wstring key_event_url = GetTestUrl(L"keyevent.html");
- const wchar_t* input = L"Chrome";
+ const char* input = "Chrome";
EXPECT_CALL(ie_mock_, OnLoad(GetParam().invokes_cf(), StrEq(key_event_url)))
- .WillOnce(testing::DoAll(
- SetFocusToRenderer(&ie_mock_),
- DelaySendString(&loop_, 500, input)));
+ .WillOnce(PostCharMessagesToRenderer(&ie_mock_, input));
- EXPECT_CALL(ie_mock_, OnMessage(StrCaseEq(input), _, _))
+ EXPECT_CALL(ie_mock_, OnMessage(StrCaseEq(UTF8ToWide(input)), _, _))
.WillOnce(CloseBrowserMock(&ie_mock_));
LaunchIEAndNavigate(key_event_url);
@@ -183,7 +180,7 @@ TEST_P(FullTabUITest, FLAKY_AltD) {
}
// Tests that the renderer has focus after navigation.
-TEST_P(FullTabUITest, FLAKY_RendererHasFocus) {
+TEST_P(FullTabUITest, RendererHasFocus) {
EXPECT_CALL(ie_mock_, OnLoad(GetParam().invokes_cf(),
StrEq(GetSimplePageUrl())))
.WillOnce(testing::DoAll(
@@ -194,9 +191,7 @@ TEST_P(FullTabUITest, FLAKY_RendererHasFocus) {
}
// Tests that view source works.
-// This test has been marked FLAKY
-// http://code.google.com/p/chromium/issues/detail?id=35370
-TEST_P(FullTabUITest, FLAKY_ViewSource) {
+TEST_P(FullTabUITest, ViewSource) {
bool in_cf = GetParam().invokes_cf();
if (!in_cf) {
LOG(ERROR) << "Test not implemented for this configuration.";
@@ -332,7 +327,7 @@ class ContextMenuTest : public MockIEEventSinkTest, public testing::Test {
}
protected:
- testing::NiceMock<MockAccessibilityEventObserver> acc_observer_;
+ testing::NiceMock<MockAccEventObserver> acc_observer_;
};
// Test reloading from the context menu.
@@ -343,7 +338,7 @@ TEST_F(ContextMenuTest, CFReload) {
EXPECT_CALL(acc_observer_, OnAccDocLoad(_))
.WillOnce(OpenContextMenuAsync());
EXPECT_CALL(acc_observer_, OnMenuPopup(_))
- .WillOnce(DoDefaultAction(AccObjectMatcher(L"Reload")));
+ .WillOnce(AccLeftClick(AccObjectMatcher(L"Reload")));
EXPECT_CALL(ie_mock_, OnLoad(IN_CF, StrEq(GetSimplePageUrl())))
.WillOnce(CloseBrowserMock(&ie_mock_));
@@ -362,7 +357,7 @@ TEST_F(ContextMenuTest, CFViewSource) {
EXPECT_CALL(acc_observer_, OnAccDocLoad(_))
.WillOnce(OpenContextMenuAsync());
EXPECT_CALL(acc_observer_, OnMenuPopup(_))
- .WillOnce(DoDefaultAction(AccObjectMatcher(L"View page source")));
+ .WillOnce(AccLeftClick(AccObjectMatcher(L"View page source")));
// Expect notification for view-source window, handle new window event
// and attach a new ie_mock_ to the received web browser
@@ -400,7 +395,7 @@ TEST_F(ContextMenuTest, CFPageInfo) {
WatchWindow(&win_observer_mock, kPageInfoWindowClass),
OpenContextMenuAsync()));
EXPECT_CALL(acc_observer_, OnMenuPopup(_))
- .WillOnce(DoDefaultAction(AccObjectMatcher(L"View page info")));
+ .WillOnce(AccLeftClick(AccObjectMatcher(L"View page info")));
// Expect page info dialog to pop up. Dismiss the dialog with 'Esc' key
const char* kPageInfoCaption = "Security Information";
@@ -424,7 +419,7 @@ TEST_F(ContextMenuTest, CFInspector) {
WatchWindow(&win_observer_mock, kPageInfoWindowClass),
OpenContextMenuAsync()));
EXPECT_CALL(acc_observer_, OnMenuPopup(_))
- .WillOnce(DoDefaultAction(AccObjectMatcher(L"Inspect element")));
+ .WillOnce(AccLeftClick(AccObjectMatcher(L"Inspect element")));
// Devtools begins life with "Untitled" caption and it changes
// later to the 'Developer Tools - <url> form.
@@ -451,7 +446,7 @@ TEST_F(ContextMenuTest, CFSaveAs) {
WatchWindow(&win_observer_mock, kSaveDlgClass),
OpenContextMenuAsync()));
EXPECT_CALL(acc_observer_, OnMenuPopup(_))
- .WillOnce(DoDefaultAction(AccObjectMatcher(L"Save as...")));
+ .WillOnce(AccLeftClick(AccObjectMatcher(L"Save as...")));
// Get safe download name using temporary file.
FilePath temp_file_path;
@@ -461,9 +456,9 @@ TEST_F(ContextMenuTest, CFSaveAs) {
EXPECT_CALL(win_observer_mock, OnWindowDetected(_, StrEq("Save As")))
.WillOnce(testing::DoAll(
- SetAccObjectValue(AccObjectMatcher(L"File name:", L"", L"simple*"),
+ AccSetValue(AccObjectMatcher(L"File name:", L"", L"simple*"),
temp_file_path.value()),
- DoDefaultAction(AccObjectMatcher(L"Save", L"push button")),
+ AccDoDefaultAction(AccObjectMatcher(L"Save", L"push button")),
CloseWhenFileSaved(&ie_mock_, temp_file_path, 5000)));
LaunchIENavigateAndLoop(GetSimplePageUrl(),
@@ -483,7 +478,7 @@ TEST_F(ContextMenuTest, CFAboutVersionLoads) {
EXPECT_CALL(acc_observer_, OnAccDocLoad(_))
.WillOnce(OpenContextMenuAsync());
EXPECT_CALL(acc_observer_, OnMenuPopup(_))
- .WillOnce(DoDefaultAction(AccObjectMatcher(L"About*")));
+ .WillOnce(AccLeftClick(AccObjectMatcher(L"About*")));
ie_mock_.ExpectNewWindow(&new_window_mock);
// For some reason this happens occasionally at least on Win7 IE8.
@@ -508,9 +503,9 @@ TEST_F(ContextMenuTest, IEOpen) {
// Open the link throught the context menu.
EXPECT_CALL(acc_observer_, OnAccDocLoad(_))
- .WillOnce(OpenContextMenuAsync(AccObjectMatcher(L"", L"link")));
+ .WillOnce(AccRightClick(AccObjectMatcher(L"", L"link")));
EXPECT_CALL(acc_observer_, OnMenuPopup(_))
- .WillOnce(DoDefaultAction(AccObjectMatcher(L"Open")));
+ .WillOnce(AccLeftClick(AccObjectMatcher(L"Open")));
EXPECT_CALL(ie_mock_, OnLoad(IN_IE, StrEq(GetSimplePageUrl())))
.WillOnce(testing::DoAll(
@@ -528,9 +523,9 @@ TEST_F(ContextMenuTest, IEOpenInNewWindow) {
// Open the link in a new window.
EXPECT_CALL(acc_observer_, OnAccDocLoad(_))
- .WillOnce(OpenContextMenuAsync(AccObjectMatcher(L"", L"link")));
+ .WillOnce(AccRightClick(AccObjectMatcher(L"", L"link")));
EXPECT_CALL(acc_observer_, OnMenuPopup(_))
- .WillOnce(DoDefaultAction(AccObjectMatcher(L"Open in New Window")));
+ .WillOnce(AccLeftClick(AccObjectMatcher(L"Open in New Window")));
ie_mock_.ExpectNewWindow(&new_window_mock);
EXPECT_CALL(new_window_mock, OnLoad(IN_IE, StrEq(GetSimplePageUrl())))
@@ -546,8 +541,6 @@ TEST_F(ContextMenuTest, IEOpenInNewWindow) {
}
// Test Back/Forward from context menu.
-// Marking this test FLAKY as it fails at times on the buildbot.
-// http://code.google.com/p/chromium/issues/detail?id=26549
TEST_F(ContextMenuTest, IEBackForward) {
server_mock_.ExpectAndServeAnyRequests(CFInvocation::None());
std::wstring page1 = GetLinkPageUrl();
@@ -564,7 +557,7 @@ TEST_F(ContextMenuTest, IEBackForward) {
VerifyPageLoad(&ie_mock_, IN_IE, page2),
OpenContextMenuAsync()));
EXPECT_CALL(acc_observer_, OnMenuPopup(_))
- .WillOnce(DoDefaultAction(AccObjectMatcher(L"Back")));
+ .WillOnce(AccLeftClick(AccObjectMatcher(L"Back")));
// Go forward.
EXPECT_CALL(acc_observer_, OnAccDocLoad(_))
@@ -572,7 +565,7 @@ TEST_F(ContextMenuTest, IEBackForward) {
VerifyPageLoad(&ie_mock_, IN_IE, page1),
OpenContextMenuAsync()));
EXPECT_CALL(acc_observer_, OnMenuPopup(_))
- .WillOnce(DoDefaultAction(AccObjectMatcher(L"Forward")));
+ .WillOnce(AccLeftClick(AccObjectMatcher(L"Forward")));
EXPECT_CALL(ie_mock_, OnLoad(IN_IE, StrEq(page2)))
.WillOnce(CloseBrowserMock(&ie_mock_));
diff --git a/chrome_frame/test/win_event_receiver.cc b/chrome_frame/test/win_event_receiver.cc
index b967d5c..e6295cd 100644
--- a/chrome_frame/test/win_event_receiver.cc
+++ b/chrome_frame/test/win_event_receiver.cc
@@ -9,8 +9,6 @@
#include "chrome_frame/function_stub.h"
-#include "third_party/xulrunner-sdk/win/include/accessibility/AccessibleEventId.h"
-
// WinEventReceiver methods
WinEventReceiver::WinEventReceiver()
: listener_(NULL),
@@ -117,23 +115,3 @@ void WindowWatchdog::OnEventReceived(DWORD event, HWND hwnd, LONG object_id,
i->observer->OnWindowDetected(hwnd, caption);
}
}
-
-// AccessibilityEventListener methods
-AccessibilityEventObserver::AccessibilityEventObserver() {
- event_receiver_.SetListenerForEvents(this, EVENT_SYSTEM_MENUPOPUPSTART,
- IA2_EVENT_DOCUMENT_LOAD_COMPLETE);
-}
-
-void AccessibilityEventObserver::OnEventReceived(DWORD event,
- HWND hwnd,
- LONG object_id,
- LONG child_id) {
- switch (event) {
- case EVENT_SYSTEM_MENUPOPUPSTART:
- OnMenuPopup(hwnd);
- break;
- case IA2_EVENT_DOCUMENT_LOAD_COMPLETE:
- OnAccDocLoad(hwnd);
- break;
- }
-}
diff --git a/chrome_frame/test/win_event_receiver.h b/chrome_frame/test/win_event_receiver.h
index afa5924..c330520 100644
--- a/chrome_frame/test/win_event_receiver.h
+++ b/chrome_frame/test/win_event_receiver.h
@@ -89,21 +89,4 @@ class WindowWatchdog : public WinEventListener {
WinEventReceiver win_event_receiver_;
};
-class AccessibilityEventObserver : public WinEventListener {
- public:
- AccessibilityEventObserver();
-
- // Called when the DOM accessibility tree for the page is ready.
- virtual void OnAccDocLoad(HWND hwnd) = 0;
-
- // Called when a new menu is shown.
- virtual void OnMenuPopup(HWND hwnd) = 0;
-
- private:
- virtual void OnEventReceived(DWORD event, HWND hwnd, LONG object_id,
- LONG child_id);
-
- WinEventReceiver event_receiver_;
-};
-
#endif // CHROME_FRAME_TEST_WIN_EVENT_RECEIVER_H_