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

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

Issue 10915069: Add Copy URL option to Omnibox context menu when URL is replaced by Instant Extended. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 8 years, 3 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 side-by-side diff with in-line comments
Download patch
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 fefc8a0ac491e1558d4674c50f6b5c5570510c00..3a98265ced90a4fe54e2082d6758c936c29d5a16 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
@@ -202,6 +202,14 @@ TEST_F(AutocompleteTextFieldEditorObserverTest, Copy) {
[editor_ copy:nil];
}
+// Test that -copyURL: is correctly delegated to the observer.
+TEST_F(AutocompleteTextFieldEditorObserverTest, CopyURL) {
+ EXPECT_CALL(field_observer_, CanCopy()).WillOnce(Return(true));
+ EXPECT_CALL(field_observer_,
+ CopyURLToPasteboard(A<NSPasteboard*>())).Times(1);
+ [editor_ copyURL:nil];
+}
+
// Test that -cut: is correctly delegated to the observer and clears
// the text field.
TEST_F(AutocompleteTextFieldEditorObserverTest, Cut) {
@@ -234,8 +242,8 @@ TEST_F(AutocompleteTextFieldEditorObserverTest, PasteAndGo) {
// Test that the menu is constructed correctly when CanPasteAndGo().
TEST_F(AutocompleteTextFieldEditorObserverTest, CanPasteAndGoMenu) {
- EXPECT_CALL(field_observer_, CanPasteAndGo())
- .WillOnce(Return(true));
+ EXPECT_CALL(field_observer_, ShouldAddCopyURL()).WillOnce(Return(false));
+ EXPECT_CALL(field_observer_, CanPasteAndGo()).WillOnce(Return(true));
EXPECT_CALL(field_observer_, GetPasteActionStringId())
.WillOnce(Return(IDS_PASTE_AND_GO));
@@ -257,8 +265,8 @@ TEST_F(AutocompleteTextFieldEditorObserverTest, CanPasteAndGoMenu) {
// Test that the menu is constructed correctly when !CanPasteAndGo().
TEST_F(AutocompleteTextFieldEditorObserverTest, CannotPasteAndGoMenu) {
- EXPECT_CALL(field_observer_, CanPasteAndGo())
- .WillOnce(Return(false));
+ EXPECT_CALL(field_observer_, ShouldAddCopyURL()).WillOnce(Return(false));
+ EXPECT_CALL(field_observer_, CanPasteAndGo()).WillOnce(Return(false));
NSMenu* menu = [editor_ menuForEvent:nil];
NSArray* items = [menu itemArray];
@@ -297,4 +305,26 @@ TEST_F(AutocompleteTextFieldEditorObserverTest, CanPasteAndGoMenuNotEditable) {
EXPECT_EQ([[items objectAtIndex:i++] action], @selector(paste:));
}
+// Test that the menu is constructed correctly when ShouldAddCopyURL() returns
+// true.
+TEST_F(AutocompleteTextFieldEditorObserverTest, ShouldAllowCopyURLMenu) {
+ EXPECT_CALL(field_observer_, ShouldAddCopyURL()).WillOnce(Return(true));
+ EXPECT_CALL(field_observer_, CanPasteAndGo()).WillOnce(Return(false));
+
+ NSMenu* menu = [editor_ menuForEvent:nil];
+ NSArray* items = [menu itemArray];
+ ASSERT_EQ([items count], 6U);
+ // TODO(shess): Check the titles, too?
+ NSUInteger i = 0; // Use an index to make future changes easier.
+ EXPECT_EQ([[items objectAtIndex:i++] action], @selector(cut:));
+ EXPECT_EQ([[items objectAtIndex:i++] action], @selector(copy:));
+ EXPECT_EQ([[items objectAtIndex:i++] action], @selector(copyURL:));
+ EXPECT_EQ([[items objectAtIndex:i++] action], @selector(paste:));
+ EXPECT_TRUE([[items objectAtIndex:i++] isSeparatorItem]);
+
+ EXPECT_EQ([[items objectAtIndex:i] action], @selector(commandDispatch:));
+ EXPECT_EQ([[items objectAtIndex:i] tag], IDC_EDIT_SEARCH_ENGINES);
+}
+
+
} // namespace

Powered by Google App Engine
This is Rietveld 408576698