Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(389)

Side by Side Diff: chrome_frame/test/ui_test.cc

Issue 9323025: Fix races in CFTxtFieldUndo and CFTxtFieldRedo tests. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include <mshtmcid.h> 5 #include <mshtmcid.h>
6 #include <string> 6 #include <string>
7 7
8 #include "base/test/test_file_util.h" 8 #include "base/test/test_file_util.h"
9 #include "base/utf_string_conversions.h" 9 #include "base/utf_string_conversions.h"
10 #include "base/win/scoped_bstr.h" 10 #include "base/win/scoped_bstr.h"
(...skipping 850 matching lines...) Expand 10 before | Expand all | Expand 10 after
861 .WillOnce(CloseBrowserMock(&ie_mock_)); 861 .WillOnce(CloseBrowserMock(&ie_mock_));
862 862
863 LaunchIEAndNavigate(context_menu_page_url + L"?action=selectall"); 863 LaunchIEAndNavigate(context_menu_page_url + L"?action=selectall");
864 } 864 }
865 865
866 // Test CF text field context menu - undo. 866 // Test CF text field context menu - undo.
867 TEST_F(ContextMenuTest, CFTxtFieldUndo) { 867 TEST_F(ContextMenuTest, CFTxtFieldUndo) {
868 server_mock_.ExpectAndServeAnyRequests(CFInvocation::MetaTag()); 868 server_mock_.ExpectAndServeAnyRequests(CFInvocation::MetaTag());
869 AccObjectMatcher txtfield_matcher(L"", L"editable text"); 869 AccObjectMatcher txtfield_matcher(L"", L"editable text");
870 870
871 // Change the value of text field to 'A', then invoke 'Undo' context menu item 871 // Change the value of text field to 'A'.
872 // of text field.
873 EXPECT_CALL(acc_observer_, 872 EXPECT_CALL(acc_observer_,
874 OnAccDocLoad(TabContentsTitleEq(context_menu_page_title))) 873 OnAccDocLoad(TabContentsTitleEq(context_menu_page_title)))
875 .WillOnce(testing::DoAll( 874 .WillOnce(testing::DoAll(
876 AccSendCharMessage(txtfield_matcher, L'A'), 875 AccWatchForOneValueChange(&acc_observer_, txtfield_matcher),
877 AccRightClick(txtfield_matcher))); 876 AccSendCharMessage(txtfield_matcher, L'A')));
877 // Bring up the context menu once the value has changed.
878 EXPECT_CALL(acc_observer_, OnAccValueChange(_, _, StrEq(L"A")))
879 .WillOnce(AccRightClick(txtfield_matcher));
880 // Then select "Undo".
878 EXPECT_CALL(acc_observer_, OnMenuPopup(_)) 881 EXPECT_CALL(acc_observer_, OnMenuPopup(_))
879 .WillOnce(testing::DoAll( 882 .WillOnce(testing::DoAll(
880 AccWatchForOneValueChange(&acc_observer_, txtfield_matcher), 883 AccWatchForOneValueChange(&acc_observer_, txtfield_matcher),
881 AccLeftClick(AccObjectMatcher(L"Undo*")))); 884 AccLeftClick(AccObjectMatcher(L"Undo*"))));
882 885
883 // Verify that value has been reset to initial value after undo operation. 886 // Verify that value has been reset to initial value after undo operation.
884 EXPECT_CALL(acc_observer_, OnAccValueChange(_, _, StrEq(kTextFieldInitValue))) 887 EXPECT_CALL(acc_observer_, OnAccValueChange(_, _, StrEq(kTextFieldInitValue)))
885 .WillOnce(CloseBrowserMock(&ie_mock_)); 888 .WillOnce(CloseBrowserMock(&ie_mock_));
886 889
887 LaunchIEAndNavigate(context_menu_page_url); 890 LaunchIEAndNavigate(context_menu_page_url);
888 } 891 }
889 892
890 // Test CF text field context menu - redo. 893 // Test CF text field context menu - redo.
891 TEST_F(ContextMenuTest, CFTxtFieldRedo) { 894 TEST_F(ContextMenuTest, CFTxtFieldRedo) {
892 server_mock_.ExpectAndServeAnyRequests(CFInvocation::MetaTag()); 895 server_mock_.ExpectAndServeAnyRequests(CFInvocation::MetaTag());
893 AccObjectMatcher txtfield_matcher(L"", L"editable text"); 896 AccObjectMatcher txtfield_matcher(L"", L"editable text");
894 InSequence expect_in_sequence_for_scope; 897 InSequence expect_in_sequence_for_scope;
895 898
896 // Change text field value to 'A', then undo it. 899 // Change text field from its initial value to 'A'.
897 EXPECT_CALL(acc_observer_, 900 EXPECT_CALL(acc_observer_,
898 OnAccDocLoad(TabContentsTitleEq(context_menu_page_title))) 901 OnAccDocLoad(TabContentsTitleEq(context_menu_page_title)))
899 .WillOnce(testing::DoAll( 902 .WillOnce(testing::DoAll(
900 AccSendCharMessage(txtfield_matcher, L'A'), 903 AccWatchForOneValueChange(&acc_observer_, txtfield_matcher),
901 AccRightClick(txtfield_matcher))); 904 AccSendCharMessage(txtfield_matcher, L'A')));
905 // Bring up the context menu.
906 EXPECT_CALL(acc_observer_, OnAccValueChange(_, _, StrEq(L"A")))
907 .WillOnce(AccRightClick(txtfield_matcher));
908 // Select "Undo"
902 EXPECT_CALL(acc_observer_, OnMenuPopup(_)) 909 EXPECT_CALL(acc_observer_, OnMenuPopup(_))
903 .WillOnce(testing::DoAll( 910 .WillOnce(testing::DoAll(
904 AccWatchForOneValueChange(&acc_observer_, txtfield_matcher), 911 AccWatchForOneValueChange(&acc_observer_, txtfield_matcher),
905 AccLeftClick(AccObjectMatcher(L"Undo*")))); 912 AccLeftClick(AccObjectMatcher(L"Undo*"))));
906 913
907 // After undo operation is done, invoke 'Redo' context menu item. 914 // After undo operation is done, bring up the context menu again.
908 EXPECT_CALL(acc_observer_, OnAccValueChange(_, _, StrEq(kTextFieldInitValue))) 915 EXPECT_CALL(acc_observer_, OnAccValueChange(_, _, StrEq(kTextFieldInitValue)))
916 .WillOnce(AccRightClick(txtfield_matcher));
917 // Select "Redo"
918 EXPECT_CALL(acc_observer_, OnMenuPopup(_))
909 .WillOnce(testing::DoAll( 919 .WillOnce(testing::DoAll(
910 AccRightClick(txtfield_matcher), 920 AccWatchForOneValueChange(&acc_observer_, txtfield_matcher),
911 AccWatchForOneValueChange(&acc_observer_, txtfield_matcher))); 921 AccLeftClick(AccObjectMatcher(L"Redo*"))));
912 EXPECT_CALL(acc_observer_, OnMenuPopup(_))
913 .WillOnce(AccLeftClick(AccObjectMatcher(L"Redo*")));
914 922
915 // After redo operation is done, verify that text field value is reset to its 923 // Verify that text field value is reset to its changed value 'A' and exit.
916 // changed value 'A'.
917 EXPECT_CALL(acc_observer_, OnAccValueChange(_, _, StrEq(L"A"))) 924 EXPECT_CALL(acc_observer_, OnAccValueChange(_, _, StrEq(L"A")))
918 .WillOnce(CloseBrowserMock(&ie_mock_)); 925 .WillOnce(CloseBrowserMock(&ie_mock_));
919 926
920 LaunchIEAndNavigate(context_menu_page_url); 927 LaunchIEAndNavigate(context_menu_page_url);
921 } 928 }
922 929
923 TEST_F(ContextMenuTest, CFBackForward) { 930 TEST_F(ContextMenuTest, CFBackForward) {
924 std::wstring page1 = GetLinkPageUrl(); 931 std::wstring page1 = GetLinkPageUrl();
925 std::wstring title1 = GetLinkPageTitle(); 932 std::wstring title1 = GetLinkPageTitle();
926 std::wstring page2 = GetSimplePageUrl(); 933 std::wstring page2 = GetSimplePageUrl();
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
988 .WillOnce(AccLeftClick(AccObjectMatcher(L"Forward"))); 995 .WillOnce(AccLeftClick(AccObjectMatcher(L"Forward")));
989 996
990 EXPECT_CALL(ie_mock_, OnLoad(IN_CF, StrEq(page3))) 997 EXPECT_CALL(ie_mock_, OnLoad(IN_CF, StrEq(page3)))
991 .WillOnce(CloseBrowserMock(&ie_mock_)); 998 .WillOnce(CloseBrowserMock(&ie_mock_));
992 999
993 LaunchIENavigateAndLoop(page1, 1000 LaunchIENavigateAndLoop(page1,
994 kChromeFrameVeryLongNavigationTimeoutInSeconds); 1001 kChromeFrameVeryLongNavigationTimeoutInSeconds);
995 } 1002 }
996 1003
997 } // namespace chrome_frame_test 1004 } // namespace chrome_frame_test
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698