summaryrefslogtreecommitdiffstats
path: root/chrome_frame
diff options
context:
space:
mode:
authorgrt@chromium.org <grt@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-02-03 13:39:07 +0000
committergrt@chromium.org <grt@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-02-03 13:39:07 +0000
commite1035cd84b8cb43dcbe1e40a7f2fd4ac960343cc (patch)
treec9bee633c97cddd31e0b37b94889d540cb29bb60 /chrome_frame
parent0546bfc9d910889e42984d15b0a232172c9c3771 (diff)
downloadchromium_src-e1035cd84b8cb43dcbe1e40a7f2fd4ac960343cc.zip
chromium_src-e1035cd84b8cb43dcbe1e40a7f2fd4ac960343cc.tar.gz
chromium_src-e1035cd84b8cb43dcbe1e40a7f2fd4ac960343cc.tar.bz2
Fix races in CFTxtFieldUndo and CFTxtFieldRedo tests.
These tests were counting on a guarantee that value change events would come in before menu popup events. As it happens, this isn't always the case. The tests now wait for the inital value change event to come in before performing subsequent operations, thereby avoiding the race. BUG=none TEST=none Review URL: https://chromiumcodereview.appspot.com/9323025 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@120322 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome_frame')
-rw-r--r--chrome_frame/test/ui_test.cc35
1 files changed, 21 insertions, 14 deletions
diff --git a/chrome_frame/test/ui_test.cc b/chrome_frame/test/ui_test.cc
index c5bd340..86fc302 100644
--- a/chrome_frame/test/ui_test.cc
+++ b/chrome_frame/test/ui_test.cc
@@ -868,13 +868,16 @@ TEST_F(ContextMenuTest, CFTxtFieldUndo) {
server_mock_.ExpectAndServeAnyRequests(CFInvocation::MetaTag());
AccObjectMatcher txtfield_matcher(L"", L"editable text");
- // Change the value of text field to 'A', then invoke 'Undo' context menu item
- // of text field.
+ // Change the value of text field to 'A'.
EXPECT_CALL(acc_observer_,
OnAccDocLoad(TabContentsTitleEq(context_menu_page_title)))
.WillOnce(testing::DoAll(
- AccSendCharMessage(txtfield_matcher, L'A'),
- AccRightClick(txtfield_matcher)));
+ AccWatchForOneValueChange(&acc_observer_, txtfield_matcher),
+ AccSendCharMessage(txtfield_matcher, L'A')));
+ // Bring up the context menu once the value has changed.
+ EXPECT_CALL(acc_observer_, OnAccValueChange(_, _, StrEq(L"A")))
+ .WillOnce(AccRightClick(txtfield_matcher));
+ // Then select "Undo".
EXPECT_CALL(acc_observer_, OnMenuPopup(_))
.WillOnce(testing::DoAll(
AccWatchForOneValueChange(&acc_observer_, txtfield_matcher),
@@ -893,27 +896,31 @@ TEST_F(ContextMenuTest, CFTxtFieldRedo) {
AccObjectMatcher txtfield_matcher(L"", L"editable text");
InSequence expect_in_sequence_for_scope;
- // Change text field value to 'A', then undo it.
+ // Change text field from its initial value to 'A'.
EXPECT_CALL(acc_observer_,
OnAccDocLoad(TabContentsTitleEq(context_menu_page_title)))
.WillOnce(testing::DoAll(
- AccSendCharMessage(txtfield_matcher, L'A'),
- AccRightClick(txtfield_matcher)));
+ AccWatchForOneValueChange(&acc_observer_, txtfield_matcher),
+ AccSendCharMessage(txtfield_matcher, L'A')));
+ // Bring up the context menu.
+ EXPECT_CALL(acc_observer_, OnAccValueChange(_, _, StrEq(L"A")))
+ .WillOnce(AccRightClick(txtfield_matcher));
+ // Select "Undo"
EXPECT_CALL(acc_observer_, OnMenuPopup(_))
.WillOnce(testing::DoAll(
AccWatchForOneValueChange(&acc_observer_, txtfield_matcher),
AccLeftClick(AccObjectMatcher(L"Undo*"))));
- // After undo operation is done, invoke 'Redo' context menu item.
+ // After undo operation is done, bring up the context menu again.
EXPECT_CALL(acc_observer_, OnAccValueChange(_, _, StrEq(kTextFieldInitValue)))
- .WillOnce(testing::DoAll(
- AccRightClick(txtfield_matcher),
- AccWatchForOneValueChange(&acc_observer_, txtfield_matcher)));
+ .WillOnce(AccRightClick(txtfield_matcher));
+ // Select "Redo"
EXPECT_CALL(acc_observer_, OnMenuPopup(_))
- .WillOnce(AccLeftClick(AccObjectMatcher(L"Redo*")));
+ .WillOnce(testing::DoAll(
+ AccWatchForOneValueChange(&acc_observer_, txtfield_matcher),
+ AccLeftClick(AccObjectMatcher(L"Redo*"))));
- // After redo operation is done, verify that text field value is reset to its
- // changed value 'A'.
+ // Verify that text field value is reset to its changed value 'A' and exit.
EXPECT_CALL(acc_observer_, OnAccValueChange(_, _, StrEq(L"A")))
.WillOnce(CloseBrowserMock(&ie_mock_));