diff options
author | grt@chromium.org <grt@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-02-02 14:04:56 +0000 |
---|---|---|
committer | grt@chromium.org <grt@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-02-02 14:04:56 +0000 |
commit | cb77c3bd41bb6421a7d2448592e60f86a215062f (patch) | |
tree | fd5d443dbdfcaf0cb0b353cc8b452af5dbab4a3e /chrome_frame/test | |
parent | 639b8e60a802c7e40bdb36c1c1f4fb78dc8e7ae3 (diff) | |
download | chromium_src-cb77c3bd41bb6421a7d2448592e60f86a215062f.zip chromium_src-cb77c3bd41bb6421a7d2448592e60f86a215062f.tar.gz chromium_src-cb77c3bd41bb6421a7d2448592e60f86a215062f.tar.bz2 |
Fix use of OnAccDocLoad in CF integration tests.
The matcher TabContentsTitleEq is now used by expectations so that actions are only performed when the relevant render window's document is loaded.
BUG=111916
TEST=covered by chrome_frame_tests.exe
Review URL: https://chromiumcodereview.appspot.com/9159030
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@120209 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome_frame/test')
-rw-r--r-- | chrome_frame/test/data/anchor.html | 2 | ||||
-rw-r--r-- | chrome_frame/test/data/context_menu.html | 2 | ||||
-rw-r--r-- | chrome_frame/test/data/form-get.html | 2 | ||||
-rw-r--r-- | chrome_frame/test/data/link.html | 3 | ||||
-rw-r--r-- | chrome_frame/test/data/window_open.html | 1 | ||||
-rw-r--r-- | chrome_frame/test/mock_ie_event_sink_actions.h | 34 | ||||
-rw-r--r-- | chrome_frame/test/mock_ie_event_sink_test.h | 28 | ||||
-rw-r--r-- | chrome_frame/test/navigation_test.cc | 54 | ||||
-rw-r--r-- | chrome_frame/test/ui_test.cc | 81 |
9 files changed, 152 insertions, 55 deletions
diff --git a/chrome_frame/test/data/anchor.html b/chrome_frame/test/data/anchor.html index fa0bfa3..cfc20cc 100644 --- a/chrome_frame/test/data/anchor.html +++ b/chrome_frame/test/data/anchor.html @@ -1,6 +1,6 @@ <html> <head> - <title> Chrome Frame Test </title> + <title>Chrome Frame Test</title> </head> <body> Chrome frame in full tab mode diff --git a/chrome_frame/test/data/context_menu.html b/chrome_frame/test/data/context_menu.html index 3e075b9..b586b78 100644 --- a/chrome_frame/test/data/context_menu.html +++ b/chrome_frame/test/data/context_menu.html @@ -1,5 +1,6 @@ <html> <head> + <title>context menu</title> <meta http-equiv="x-ua-compatible" content="chrome=1" /> <script type="text/javascript" src="chrome_frame_tester_helpers.js"> </script> @@ -40,4 +41,3 @@ <input type="text" name="textField" id="textField" size="25" value=""></td> </body> </html> - diff --git a/chrome_frame/test/data/form-get.html b/chrome_frame/test/data/form-get.html index 5d1b024..e6b15d5 100644 --- a/chrome_frame/test/data/form-get.html +++ b/chrome_frame/test/data/form-get.html @@ -1,6 +1,6 @@ <html> <head> - <title> ChromeFrame form submit test(GET method) </title> + <title>ChromeFrame form submit test(GET method)</title> </head> <body> <br /> diff --git a/chrome_frame/test/data/link.html b/chrome_frame/test/data/link.html index a2c3513..8336405 100644 --- a/chrome_frame/test/data/link.html +++ b/chrome_frame/test/data/link.html @@ -1,4 +1,7 @@ <html> + <head> + <title>link</title> + </head> <body> <a href="simple.html">Simple page</a> </body> diff --git a/chrome_frame/test/data/window_open.html b/chrome_frame/test/data/window_open.html index a7cffe0..b61c8ae 100644 --- a/chrome_frame/test/data/window_open.html +++ b/chrome_frame/test/data/window_open.html @@ -1,5 +1,6 @@ <html> <head> + <title>window open</title> <script type="text/javascript"> var new_window; diff --git a/chrome_frame/test/mock_ie_event_sink_actions.h b/chrome_frame/test/mock_ie_event_sink_actions.h index 22c4075..10af3fd 100644 --- a/chrome_frame/test/mock_ie_event_sink_actions.h +++ b/chrome_frame/test/mock_ie_event_sink_actions.h @@ -6,10 +6,13 @@ #define CHROME_FRAME_TEST_MOCK_IE_EVENT_SINK_ACTIONS_H_ #include <windows.h> +#include <algorithm> #include <string> #include "base/basictypes.h" #include "base/bind.h" +#include "base/string_util.h" +#include "base/string16.h" #include "base/threading/platform_thread.h" #include "base/time.h" #include "chrome/common/chrome_switches.h" @@ -32,6 +35,37 @@ MATCHER_P(AccSatisfies, matcher, "satisfies the given AccObjectMatcher") { return matcher.DoesMatch(arg); } +// Returns true if the title of the page rendered in the window |arg| equals +// |the_title|. For pages rendered in Chrome, the title of the parent of |arg| +// is the page title. For pages rendered in IE, the title of the grandparent of +// |arg| begins with the page title. To handle both cases, attempt a prefix +// match on each window starting with the parent of |arg|. +MATCHER_P(TabContentsTitleEq, the_title, "") { + const string16 title(the_title); + DCHECK(!title.empty()); + HWND parent = GetParent(arg); + if (parent != NULL) { + string16 parent_title(255, L'\0'); + std::ostringstream titles_found(std::string("titles found: ")); + string16 first_title; + do { + parent_title.resize(255, L'\0'); + parent_title.resize(GetWindowText(parent, &parent_title[0], + parent_title.size())); + if (parent_title.size() >= title.size() && + std::equal(title.begin(), title.end(), parent_title.begin())) { + return true; + } + titles_found << "\"" << UTF16ToASCII(parent_title) << "\" "; + parent = GetParent(parent); + } while(parent != NULL); + *result_listener << titles_found.str(); + } else { + *result_listener << "the window has no parent"; + } + return false; +} + // IWebBrowser2 actions ACTION_P2(Navigate, mock, navigate_url) { diff --git a/chrome_frame/test/mock_ie_event_sink_test.h b/chrome_frame/test/mock_ie_event_sink_test.h index cd9113b..3b636c8 100644 --- a/chrome_frame/test/mock_ie_event_sink_test.h +++ b/chrome_frame/test/mock_ie_event_sink_test.h @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -308,12 +308,22 @@ class MockIEEventSinkTest { return GetTestUrl(L"simple.html"); } + // Returns the title of the html page at |GetSimplePageUrl()|. + std::wstring GetSimplePageTitle() { + return L"simple web page"; + } + // Returns the url for an html page just containing one link to the simple // page mentioned above. std::wstring GetLinkPageUrl() { return GetTestUrl(L"link.html"); } + // Returns the title of the html page at |GetLinkPageUrl()|. + std::wstring GetLinkPageTitle() { + return L"link"; + } + // Returns the url for an html page containing several anchors pointing // to different parts of the page. |index| specifies what fragment to // append to the url. If zero, no fragment is appended. The highest fragment @@ -326,6 +336,22 @@ class MockIEEventSinkTest { return GetTestUrl(base_name); } + // Returns the title of the html page at |GetAnchorPageUrl()|. + std::wstring GetAnchorPageTitle() { + return L"Chrome Frame Test"; + } + + // Returns the url for an html page that will, when clicked, open a new window + // to |target|. + std::wstring GetWindowOpenUrl(const wchar_t* target) { + return GetTestUrl(std::wstring(L"window_open.html?").append(target)); + } + + // Returns the title of the html page at |GetWindowOpenUrl()|. + std::wstring GetWindowOpenTitle() { + return L"window open"; + } + protected: CloseIeAtEndOfScope last_resort_close_ie_; chrome_frame_test::TimedMsgLoop loop_; diff --git a/chrome_frame/test/navigation_test.cc b/chrome_frame/test/navigation_test.cc index ebee34f..cde8da35 100644 --- a/chrome_frame/test/navigation_test.cc +++ b/chrome_frame/test/navigation_test.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -192,10 +192,12 @@ TEST_P(FullTabNavigationTest, FLAKY_MultipleBackForward) { // Test multiple back and forward operations among urls with anchors. TEST_P(FullTabNavigationTest, BackForwardAnchor) { + std::wstring title(GetAnchorPageTitle()); bool in_cf = GetParam().invokes_cf(); ie_mock_.ExpectAnyNavigations(); server_mock_.ExpectAndServeAnyRequests(GetParam()); MockAccEventObserver acc_observer; + EXPECT_CALL(acc_observer, OnAccDocLoad(_)).Times(testing::AnyNumber()); // Navigate to anchor 1. // Back/Forward state at this point: @@ -203,9 +205,9 @@ TEST_P(FullTabNavigationTest, BackForwardAnchor) { // Forward: 0 EXPECT_CALL(ie_mock_, OnLoad(in_cf, StrEq(GetAnchorPageUrl(0)))) .Times(testing::AtMost(1)); - EXPECT_CALL(acc_observer, OnAccDocLoad(_)) + EXPECT_CALL(acc_observer, OnAccDocLoad(TabContentsTitleEq(title))) .WillOnce(AccDoDefaultAction(AccObjectMatcher(L"*1", L"link"))) - .WillRepeatedly(testing::Return()); + .RetiresOnSaturation(); InSequence expect_in_sequence_for_scope; // Navigate to anchor 2 after the previous navigation is complete @@ -335,18 +337,18 @@ TEST_P(FullTabNavigationTest, DISABLED_JavascriptWindowOpenDifferentDomain) { LOG(ERROR) << "Test disabled for this configuration."; return; } - std::wstring parent_url = - GetTestUrl(L"window_open.html?http://www.nonexistent.com"); + std::wstring parent_url = GetWindowOpenUrl(L"http://www.nonexistent.com"); MockAccEventObserver acc_observer; MockIEEventSink new_window_mock; ie_mock_.ExpectAnyNavigations(); new_window_mock.ExpectAnyNavigations(); server_mock_.ExpectAndServeAnyRequests(GetParam()); + EXPECT_CALL(acc_observer, OnAccDocLoad(_)).Times(testing::AnyNumber()); EXPECT_CALL(ie_mock_, OnLoad(GetParam().invokes_cf(), StrEq(parent_url))); - EXPECT_CALL(acc_observer, OnAccDocLoad(_)) - .WillOnce(AccLeftClick(AccObjectMatcher())) - .WillRepeatedly(testing::Return()); + EXPECT_CALL(acc_observer, + OnAccDocLoad(TabContentsTitleEq(GetWindowOpenTitle()))) + .WillOnce(AccLeftClick(AccObjectMatcher())); ie_mock_.ExpectNewWindow(&new_window_mock); EXPECT_CALL(new_window_mock, OnNavigateError(_, _, _, _, _)) @@ -377,19 +379,20 @@ TEST_P(FullTabNavigationTest, JavascriptWindowOpenCanClose) { return; } - std::wstring parent_url = GetTestUrl(L"window_open.html?simple.html"); + std::wstring parent_url = GetWindowOpenUrl(L"simple.html"); MockAccEventObserver acc_observer; MockIEEventSink new_window_mock; ie_mock_.ExpectAnyNavigations(); new_window_mock.ExpectAnyNavigations(); server_mock_.ExpectAndServeAnyRequests(GetParam()); + EXPECT_CALL(acc_observer, OnAccDocLoad(_)).Times(testing::AnyNumber()); // 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()); + EXPECT_CALL(acc_observer, + OnAccDocLoad(TabContentsTitleEq(GetWindowOpenTitle()))) + .WillOnce(AccLeftClick(AccObjectMatcher())); ie_mock_.ExpectNewWindow(&new_window_mock); EXPECT_CALL(new_window_mock, OnLoad(_, StrEq(GetSimplePageUrl()))) @@ -472,19 +475,20 @@ TEST_P(NavigationTransitionTest, JavascriptWindowOpen) { return; } - std::wstring parent_url = GetTestUrl(L"window_open.html?simple.html"); + std::wstring parent_url = GetWindowOpenUrl(L"simple.html"); std::wstring new_window_url = GetSimplePageUrl(); MockAccEventObserver acc_observer; testing::StrictMock<MockIEEventSink> new_window_mock; + EXPECT_CALL(acc_observer, OnAccDocLoad(_)).Times(testing::AnyNumber()); ie_mock_.ExpectNavigation(page1_.invokes_cf(), parent_url); 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()); + EXPECT_CALL(acc_observer, + OnAccDocLoad(TabContentsTitleEq(GetWindowOpenTitle()))) + .WillOnce(AccLeftClick(AccObjectMatcher())); // If the parent window is in CF, the child should always load in CF since // the domain is the same. @@ -544,7 +548,8 @@ TEST_P(NavigationTransitionTest, FollowLink) { .Times(testing::Between(1, 2)) .WillRepeatedly(SendResponse(&server_mock_, page1_)); EXPECT_CALL(ie_mock_, OnLoad(page1_.invokes_cf(), StrEq(GetLinkPageUrl()))); - EXPECT_CALL(acc_observer, OnAccDocLoad(_)) + EXPECT_CALL(acc_observer, + OnAccDocLoad(TabContentsTitleEq(GetLinkPageTitle()))) .WillOnce(AccDoDefaultAction(AccObjectMatcher(L"", L"link"))) .RetiresOnSaturation(); @@ -659,14 +664,15 @@ TEST_P(FullTabNavigationTest, FormPostBackForward) { std::wstring kFormPostUrl = GetTestUrl(L"form-get.html"); std::wstring kFormPostActionUrl = GetTestUrl(L"action.html?field1=a&field2=b&submit=Submit"); + std::wstring kFormPostTitle(L"ChromeFrame form submit test(GET method)"); MockAccEventObserver acc_observer; server_mock_.ExpectAndServeAnyRequests(GetParam()); + EXPECT_CALL(acc_observer, OnAccDocLoad(_)).Times(testing::AnyNumber()); - EXPECT_CALL(acc_observer, OnAccDocLoad(_)) - .Times(testing::AtLeast(1)) + EXPECT_CALL(acc_observer, OnAccDocLoad(TabContentsTitleEq(kFormPostTitle))) .WillOnce(AccDoDefaultAction(AccObjectMatcher(L"Submit"))) - .WillRepeatedly(testing::Return()); + .RetiresOnSaturation(); InSequence expect_in_sequence_for_scope; @@ -1202,13 +1208,14 @@ TEST_F(FullTabNavigationTest, JavascriptWindowOpenNoReferrerOpensInHost) { } MockAccEventObserver acc_observer; + EXPECT_CALL(acc_observer, OnAccDocLoad(_)).Times(testing::AnyNumber()); testing::StrictMock<MockIEEventSink> new_window_mock; testing::StrictMock<MockIEEventSink> no_referrer_target_opener_window_mock; std::wstring initial_url = - GetTestUrl(L"window_open.html?open_href_target_no_referrer.html"); + GetWindowOpenUrl(L"open_href_target_no_referrer.html"); std::wstring parent_url = GetTestUrl( L"open_href_target_no_referrer.html"); @@ -1218,9 +1225,10 @@ TEST_F(FullTabNavigationTest, JavascriptWindowOpenNoReferrerOpensInHost) { ie_mock_.ExpectNavigation(false, initial_url); EXPECT_CALL(ie_mock_, OnLoad(false, StrEq(initial_url))); - EXPECT_CALL(acc_observer, OnAccDocLoad(_)) + EXPECT_CALL(acc_observer, + OnAccDocLoad(TabContentsTitleEq(GetWindowOpenTitle()))) .WillOnce(AccLeftClick(AccObjectMatcher())) - .WillRepeatedly(testing::Return()); + .RetiresOnSaturation(); ie_mock_.ExpectNewWindow(&no_referrer_target_opener_window_mock); diff --git a/chrome_frame/test/ui_test.cc b/chrome_frame/test/ui_test.cc index f551f52..c5bd340 100644 --- a/chrome_frame/test/ui_test.cc +++ b/chrome_frame/test/ui_test.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2011 The Chromium Authors. All rights reserved. +// Copyright (c) 2012 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -388,6 +388,7 @@ class ContextMenuTest : public MockIEEventSinkTest, public testing::Test { virtual void SetUp() { context_menu_page_url = GetTestUrl(L"context_menu.html"); + context_menu_page_title = L"context menu"; // Clear clipboard to make sure there is no effect from previous tests. SetClipboardText(L""); // These are UI-related tests, so we do not care about the exact @@ -406,7 +407,8 @@ class ContextMenuTest : public MockIEEventSinkTest, public testing::Test { // Open 'Save As' dialog. const char* kSaveDlgCaption = "Save As"; - EXPECT_CALL(acc_observer_, OnAccDocLoad(_)) + EXPECT_CALL(acc_observer_, + OnAccDocLoad(TabContentsTitleEq(L"Save As download test"))) .WillOnce(testing::DoAll( WatchWindow(&win_observer_mock, kSaveDlgCaption, ""), AccRightClick(AccObjectMatcher(L"", role)))); @@ -437,6 +439,8 @@ class ContextMenuTest : public MockIEEventSinkTest, public testing::Test { protected: // Html page that holds a text field for context menu testing. std::wstring context_menu_page_url; + // Title of said html page. + std::wstring context_menu_page_title; // This is the text value used to test cut/copy/paste etc. const std::wstring kTextFieldInitValue; @@ -448,7 +452,8 @@ TEST_F(ContextMenuTest, CFReload) { server_mock_.ExpectAndServeAnyRequests(CFInvocation::MetaTag()); InSequence expect_in_sequence_for_scope; - EXPECT_CALL(acc_observer_, OnAccDocLoad(_)) + EXPECT_CALL(acc_observer_, + OnAccDocLoad(TabContentsTitleEq(GetSimplePageTitle()))) .WillOnce(OpenContextMenuAsync()); EXPECT_CALL(acc_observer_, OnMenuPopup(_)) .WillOnce(AccLeftClick(AccObjectMatcher(L"Reload"))); @@ -474,7 +479,8 @@ TEST_F(ContextMenuTest, CFViewSource) { InSequence expect_in_sequence_for_scope; // View the page source. - EXPECT_CALL(acc_observer_, OnAccDocLoad(_)) + EXPECT_CALL(acc_observer_, + OnAccDocLoad(TabContentsTitleEq(GetSimplePageTitle()))) .WillOnce(OpenContextMenuAsync()); EXPECT_CALL(acc_observer_, OnMenuPopup(_)) .WillOnce(AccLeftClick(AccObjectMatcher(L"View page source"))); @@ -509,7 +515,8 @@ TEST_F(ContextMenuTest, DISABLED_CFPageInfo) { InSequence expect_in_sequence_for_scope; // View page information. - EXPECT_CALL(acc_observer_, OnAccDocLoad(_)) + EXPECT_CALL(acc_observer_, + OnAccDocLoad(TabContentsTitleEq(GetSimplePageTitle()))) .WillOnce(testing::DoAll( WatchWindow(&win_observer_mock, "", "Chrome_WidgetWin_*"), OpenContextMenuAsync())); @@ -537,7 +544,8 @@ TEST_F(ContextMenuTest, CFInspector) { // Devtools begins life with "Untitled" caption and it changes // later to the 'Developer Tools - <url> form. const char* kPageInfoCaptionPattern = "Untitled*"; - EXPECT_CALL(acc_observer_, OnAccDocLoad(_)) + EXPECT_CALL(acc_observer_, + OnAccDocLoad(TabContentsTitleEq(GetSimplePageTitle()))) .WillOnce(testing::DoAll( WatchWindow(&win_observer_mock, kPageInfoCaptionPattern, ""), OpenContextMenuAsync())); @@ -593,7 +601,8 @@ TEST_F(ContextMenuTest, CFAboutVersionLoads) { new_window_mock.ExpectAnyNavigations(); InSequence expect_in_sequence_for_scope; - EXPECT_CALL(acc_observer_, OnAccDocLoad(_)) + EXPECT_CALL(acc_observer_, + OnAccDocLoad(TabContentsTitleEq(GetSimplePageTitle()))) .WillOnce(OpenContextMenuAsync()); EXPECT_CALL(acc_observer_, OnMenuPopup(_)) .WillOnce(AccLeftClick(AccObjectMatcher(L"About*"))); @@ -619,8 +628,9 @@ TEST_F(ContextMenuTest, IEOpen) { server_mock_.ExpectAndServeAnyRequests(CFInvocation::None()); InSequence expect_in_sequence_for_scope; - // Open the link throught the context menu. - EXPECT_CALL(acc_observer_, OnAccDocLoad(_)) + // Open the link through the context menu. + EXPECT_CALL(acc_observer_, + OnAccDocLoad(TabContentsTitleEq(GetLinkPageTitle()))) .WillOnce(AccRightClick(AccObjectMatcher(L"", L"link"))); EXPECT_CALL(acc_observer_, OnMenuPopup(_)) .WillOnce(AccLeftClick(AccObjectMatcher(L"Open"))); @@ -645,7 +655,8 @@ TEST_F(ContextMenuTest, IEOpenInNewWindow) { InSequence expect_in_sequence_for_scope; // Open the link in a new window. - EXPECT_CALL(acc_observer_, OnAccDocLoad(_)) + EXPECT_CALL(acc_observer_, + OnAccDocLoad(TabContentsTitleEq(GetLinkPageTitle()))) .WillOnce(AccRightClick(AccObjectMatcher(L"", L"link"))); EXPECT_CALL(acc_observer_, OnMenuPopup(_)) .WillOnce(AccLeftClick(AccObjectMatcher(L"Open in New Window"))); @@ -667,15 +678,17 @@ TEST_F(ContextMenuTest, IEOpenInNewWindow) { TEST_F(ContextMenuTest, IEBackForward) { server_mock_.ExpectAndServeAnyRequests(CFInvocation::None()); std::wstring page1 = GetLinkPageUrl(); + std::wstring title1 = GetLinkPageTitle(); std::wstring page2 = GetSimplePageUrl(); + std::wstring title2 = GetSimplePageTitle(); InSequence expect_in_sequence_for_scope; // Navigate to second page. - EXPECT_CALL(acc_observer_, OnAccDocLoad(_)) + EXPECT_CALL(acc_observer_, OnAccDocLoad(TabContentsTitleEq(title1))) .WillOnce(Navigate(&ie_mock_, page2)); // Go back. - EXPECT_CALL(acc_observer_, OnAccDocLoad(_)) + EXPECT_CALL(acc_observer_, OnAccDocLoad(TabContentsTitleEq(title2))) .WillOnce(testing::DoAll( VerifyPageLoad(&ie_mock_, IN_IE, page2), OpenContextMenuAsync())); @@ -683,7 +696,7 @@ TEST_F(ContextMenuTest, IEBackForward) { .WillOnce(AccLeftClick(AccObjectMatcher(L"Back"))); // Go forward. - EXPECT_CALL(acc_observer_, OnAccDocLoad(_)) + EXPECT_CALL(acc_observer_, OnAccDocLoad(TabContentsTitleEq(title1))) .WillOnce(testing::DoAll( VerifyPageLoad(&ie_mock_, IN_IE, page1), OpenContextMenuAsync())); @@ -704,7 +717,8 @@ TEST_F(ContextMenuTest, FLAKY_CFOpenLinkInNewWindow) { new_window_mock.ExpectAnyNavigations(); // Invoke 'Open link in new window' context menu item. - EXPECT_CALL(acc_observer_, OnAccDocLoad(_)) + EXPECT_CALL(acc_observer_, + OnAccDocLoad(TabContentsTitleEq(GetLinkPageTitle()))) .Times(testing::AtMost(2)) .WillOnce(AccRightClick(AccObjectMatcher(L"", L"link"))) .WillOnce(testing::Return()); @@ -725,7 +739,8 @@ TEST_F(ContextMenuTest, CFCopyLinkAddress) { server_mock_.ExpectAndServeAnyRequests(CFInvocation::MetaTag()); // Invoke 'Copy link address' context menu item. - EXPECT_CALL(acc_observer_, OnAccDocLoad(_)) + EXPECT_CALL(acc_observer_, + OnAccDocLoad(TabContentsTitleEq(GetLinkPageTitle()))) .WillOnce(AccRightClick(AccObjectMatcher(L"", L"link"))); EXPECT_CALL(acc_observer_, OnMenuPopup(_)) .WillOnce(testing::DoAll( @@ -743,7 +758,8 @@ TEST_F(ContextMenuTest, CFTxtFieldCut) { AccObjectMatcher txtfield_matcher(L"", L"editable text"); // Invoke "Cut" context menu item of text field. - EXPECT_CALL(acc_observer_, OnAccDocLoad(_)) + EXPECT_CALL(acc_observer_, + OnAccDocLoad(TabContentsTitleEq(context_menu_page_title))) .WillOnce(testing::DoAll( AccRightClick(txtfield_matcher), AccWatchForOneValueChange(&acc_observer_, txtfield_matcher))); @@ -765,7 +781,8 @@ TEST_F(ContextMenuTest, CFTxtFieldCopy) { AccObjectMatcher txtfield_matcher(L"", L"editable text"); // Invoke "Copy" context menu item of text field. - EXPECT_CALL(acc_observer_, OnAccDocLoad(_)) + EXPECT_CALL(acc_observer_, + OnAccDocLoad(TabContentsTitleEq(context_menu_page_title))) .WillOnce(testing::DoAll( AccRightClick(txtfield_matcher), AccWatchForOneValueChange(&acc_observer_, txtfield_matcher))); @@ -789,7 +806,8 @@ TEST_F(ContextMenuTest, DISABLED_CFTxtFieldPaste) { AccObjectMatcher txtfield_matcher(L"", L"editable text"); // Invoke "Paste" context menu item of text field. - EXPECT_CALL(acc_observer_, OnAccDocLoad(_)) + EXPECT_CALL(acc_observer_, + OnAccDocLoad(TabContentsTitleEq(context_menu_page_title))) .WillOnce(testing::DoAll( AccRightClick(txtfield_matcher), AccWatchForOneValueChange(&acc_observer_, txtfield_matcher))); @@ -811,7 +829,8 @@ TEST_F(ContextMenuTest, CFTxtFieldDelete) { AccObjectMatcher txtfield_matcher(L"", L"editable text"); // Invoke 'Delete' context menu item of text field. - EXPECT_CALL(acc_observer_, OnAccDocLoad(_)) + EXPECT_CALL(acc_observer_, + OnAccDocLoad(TabContentsTitleEq(context_menu_page_title))) .WillOnce(testing::DoAll( AccRightClick(txtfield_matcher), AccWatchForOneValueChange(&acc_observer_, txtfield_matcher))); @@ -829,7 +848,8 @@ TEST_F(ContextMenuTest, CFTxtFieldSelectAll) { server_mock_.ExpectAndServeAnyRequests(CFInvocation::MetaTag()); // Invoke 'Select all' context menu item of text field. - EXPECT_CALL(acc_observer_, OnAccDocLoad(_)) + EXPECT_CALL(acc_observer_, + OnAccDocLoad(TabContentsTitleEq(context_menu_page_title))) .WillOnce(AccRightClick(AccObjectMatcher(L"", L"editable text"))); EXPECT_CALL(acc_observer_, OnMenuPopup(_)) .WillOnce(testing::DoAll( @@ -850,7 +870,8 @@ TEST_F(ContextMenuTest, CFTxtFieldUndo) { // Change the value of text field to 'A', then invoke 'Undo' context menu item // of text field. - EXPECT_CALL(acc_observer_, OnAccDocLoad(_)) + EXPECT_CALL(acc_observer_, + OnAccDocLoad(TabContentsTitleEq(context_menu_page_title))) .WillOnce(testing::DoAll( AccSendCharMessage(txtfield_matcher, L'A'), AccRightClick(txtfield_matcher))); @@ -873,7 +894,8 @@ TEST_F(ContextMenuTest, CFTxtFieldRedo) { InSequence expect_in_sequence_for_scope; // Change text field value to 'A', then undo it. - EXPECT_CALL(acc_observer_, OnAccDocLoad(_)) + EXPECT_CALL(acc_observer_, + OnAccDocLoad(TabContentsTitleEq(context_menu_page_title))) .WillOnce(testing::DoAll( AccSendCharMessage(txtfield_matcher, L'A'), AccRightClick(txtfield_matcher))); @@ -900,8 +922,11 @@ TEST_F(ContextMenuTest, CFTxtFieldRedo) { TEST_F(ContextMenuTest, CFBackForward) { std::wstring page1 = GetLinkPageUrl(); + std::wstring title1 = GetLinkPageTitle(); std::wstring page2 = GetSimplePageUrl(); + std::wstring title2 = GetSimplePageTitle(); std::wstring page3 = GetTestUrl(L"anchor.html"); + std::wstring title3 = GetAnchorPageTitle(); server_mock_.ExpectAndServeRequestWithCardinality( CFInvocation::MetaTag(), page1, testing::Exactly(2)); @@ -915,19 +940,19 @@ TEST_F(ContextMenuTest, CFBackForward) { InSequence expect_in_sequence_for_scope; // Navigate to second page. - EXPECT_CALL(acc_observer_, OnAccDocLoad(_)) + EXPECT_CALL(acc_observer_, OnAccDocLoad(TabContentsTitleEq(title1))) .WillOnce(testing::DoAll( VerifyPageLoad(&ie_mock_, IN_CF, page1), Navigate(&ie_mock_, page2))); // Navigate to third page. - EXPECT_CALL(acc_observer_, OnAccDocLoad(_)) + EXPECT_CALL(acc_observer_, OnAccDocLoad(TabContentsTitleEq(title2))) .WillOnce(testing::DoAll( VerifyPageLoad(&ie_mock_, IN_IE, page2), Navigate(&ie_mock_, page3))); // Go back. - EXPECT_CALL(acc_observer_, OnAccDocLoad(_)) + EXPECT_CALL(acc_observer_, OnAccDocLoad(TabContentsTitleEq(title3))) .WillOnce(testing::DoAll( VerifyPageLoad(&ie_mock_, IN_CF, page3), OpenContextMenuAsync())); @@ -936,7 +961,7 @@ TEST_F(ContextMenuTest, CFBackForward) { .WillOnce(AccLeftClick(AccObjectMatcher(L"Back"))); // Go back - EXPECT_CALL(acc_observer_, OnAccDocLoad(_)) + EXPECT_CALL(acc_observer_, OnAccDocLoad(TabContentsTitleEq(title2))) .WillOnce(testing::DoAll( VerifyPageLoad(&ie_mock_, IN_IE, page2), OpenContextMenuAsync())); @@ -945,7 +970,7 @@ TEST_F(ContextMenuTest, CFBackForward) { .WillOnce(AccLeftClick(AccObjectMatcher(L"Back"))); // Go forward. - EXPECT_CALL(acc_observer_, OnAccDocLoad(_)) + EXPECT_CALL(acc_observer_, OnAccDocLoad(TabContentsTitleEq(title1))) .WillOnce(testing::DoAll( VerifyPageLoad(&ie_mock_, IN_CF, page1), OpenContextMenuAsync())); @@ -954,7 +979,7 @@ TEST_F(ContextMenuTest, CFBackForward) { .WillOnce(AccLeftClick(AccObjectMatcher(L"Forward"))); // Go forward. - EXPECT_CALL(acc_observer_, OnAccDocLoad(_)) + EXPECT_CALL(acc_observer_, OnAccDocLoad(TabContentsTitleEq(title2))) .WillOnce(testing::DoAll( VerifyPageLoad(&ie_mock_, IN_IE, page2), OpenContextMenuAsync())); |