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

Unified Diff: chrome/browser/ui/cocoa/location_bar/autocomplete_text_field_editor_unittest.mm

Issue 2523053003: Mac: Fix errors in adding the "Paste & Go" menu item. (Closed)
Patch Set: gmock dance Created 4 years, 1 month 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/ui/cocoa/location_bar/autocomplete_text_field_editor.mm ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/cocoa/location_bar/autocomplete_text_field_editor_unittest.mm
diff --git a/chrome/browser/ui/cocoa/location_bar/autocomplete_text_field_editor_unittest.mm b/chrome/browser/ui/cocoa/location_bar/autocomplete_text_field_editor_unittest.mm
index 3f1a19a7a5ac49960ea0bcf25181d006f52913a7..e5e5123946c4cebe0826114b06e8a57ea855b9d6 100644
--- a/chrome/browser/ui/cocoa/location_bar/autocomplete_text_field_editor_unittest.mm
+++ b/chrome/browser/ui/cocoa/location_bar/autocomplete_text_field_editor_unittest.mm
@@ -251,6 +251,7 @@ TEST_F(AutocompleteTextFieldEditorObserverTest, PasteAndGo) {
// Test that the menu is constructed correctly.
TEST_F(AutocompleteTextFieldEditorObserverTest, Menu) {
+ EXPECT_CALL(field_observer_, CanPasteAndGo()).WillOnce(Return(true));
EXPECT_CALL(field_observer_, GetPasteActionStringId()).
WillOnce(Return(IDS_PASTE_AND_GO));
@@ -262,7 +263,9 @@ TEST_F(AutocompleteTextFieldEditorObserverTest, Menu) {
EXPECT_EQ([[items objectAtIndex:i++] action], @selector(cut:));
EXPECT_EQ([[items objectAtIndex:i++] action], @selector(copy:));
EXPECT_EQ([[items objectAtIndex:i++] action], @selector(paste:));
- EXPECT_EQ([[items objectAtIndex:i++] action], @selector(pasteAndGo:));
+ NSMenuItem* pasteAndGo = [items objectAtIndex:i++];
+ EXPECT_EQ([pasteAndGo action], @selector(pasteAndGo:));
+ EXPECT_TRUE([pasteAndGo isEnabled]);
EXPECT_TRUE([[items objectAtIndex:i++] isSeparatorItem]);
EXPECT_EQ([[items objectAtIndex:i] tag], IDC_EDIT_SEARCH_ENGINES);
EXPECT_EQ([[items objectAtIndex:i++] action], @selector(commandDispatch:));
@@ -299,16 +302,16 @@ TEST_F(AutocompleteTextFieldEditorObserverTest, CanPasteAndGoValidate) {
for (NSUInteger i = 0; i < [items count]; ++i) {
NSMenuItem* item = [items objectAtIndex:i];
if ([item action] == @selector(pasteAndGo:)) {
+ EXPECT_TRUE([item isEnabled]);
EXPECT_TRUE([editor_ validateMenuItem:item]);
break;
}
}
}
-// Test that the menu validation works as expected when !CanPasteAndGo().
+// Test that the GetPasteActionStringId() is not called when !CanPasteAndGo().
TEST_F(AutocompleteTextFieldEditorObserverTest, CannotPasteAndGoValidate) {
- EXPECT_CALL(field_observer_, GetPasteActionStringId())
- .WillOnce(Return(IDS_PASTE_AND_GO));
+ EXPECT_CALL(field_observer_, GetPasteActionStringId()).Times(0);
EXPECT_CALL(field_observer_, CanPasteAndGo()).WillOnce(Return(false));
NSMenu* menu = MenuFromRightClick(editor_);
@@ -317,6 +320,7 @@ TEST_F(AutocompleteTextFieldEditorObserverTest, CannotPasteAndGoValidate) {
for (NSUInteger i = 0; i < [items count]; ++i) {
NSMenuItem* item = [items objectAtIndex:i];
if ([item action] == @selector(pasteAndGo:)) {
+ EXPECT_FALSE([item isEnabled]);
EXPECT_FALSE([editor_ validateMenuItem:item]);
break;
}
« no previous file with comments | « chrome/browser/ui/cocoa/location_bar/autocomplete_text_field_editor.mm ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698