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

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

Issue 207047: [Mac] Convert Omnibox paste-and-go to use AutocompleteTextFieldObserver. (Closed)
Patch Set: Oops - remove test before its time. Created 11 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/cocoa/autocomplete_text_field_editor_unittest.mm
diff --git a/chrome/browser/cocoa/autocomplete_text_field_editor_unittest.mm b/chrome/browser/cocoa/autocomplete_text_field_editor_unittest.mm
index bdb496202d76f6f4754bebedce66beb8c8e00ec7..c4ec3461a9946a6b705a80116151a3e846ebfd4c 100644
--- a/chrome/browser/cocoa/autocomplete_text_field_editor_unittest.mm
+++ b/chrome/browser/cocoa/autocomplete_text_field_editor_unittest.mm
@@ -9,9 +9,12 @@
#include "base/string_util.h"
#import "chrome/browser/cocoa/autocomplete_text_field_unittest_helper.h"
#import "chrome/browser/cocoa/cocoa_test_helper.h"
+#include "grit/generated_resources.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "testing/platform_test.h"
+using ::testing::Return;
+
namespace {
int NumTypesOnPasteboard(NSPasteboard* pb) {
@@ -156,4 +159,43 @@ TEST_F(AutocompleteTextFieldEditorTest, Paste) {
[editor_.get() paste:nil];
}
+// Test that -pasteAndGo: is correctly delegated to the observer.
+TEST_F(AutocompleteTextFieldEditorTest, PasteAndGo) {
+ EXPECT_CALL(field_observer_, OnPasteAndGo());
+ [editor_.get() pasteAndGo:nil];
+}
+
+// Test that the menu is constructed correctly when CanPasteAndGo().
+TEST_F(AutocompleteTextFieldEditorTest, CanPasteAndGoMenu) {
+ EXPECT_CALL(field_observer_, CanPasteAndGo())
+ .WillOnce(Return(true));
+ EXPECT_CALL(field_observer_, GetPasteActionStringId())
+ .WillOnce(Return(IDS_PASTE_AND_GO));
+
+ NSMenu* menu = [editor_.get() menuForEvent:nil];
+ NSArray* items = [menu itemArray];
+ ASSERT_EQ([items count], 4U);
+ // 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(paste:));
+ EXPECT_EQ([[items objectAtIndex:i++] action], @selector(pasteAndGo:));
+}
+
+// Test that the menu is constructed correctly when !CanPasteAndGo().
+TEST_F(AutocompleteTextFieldEditorTest, CannotPasteAndGoMenu) {
+ EXPECT_CALL(field_observer_, CanPasteAndGo())
+ .WillOnce(Return(false));
+
+ NSMenu* menu = [editor_.get() menuForEvent:nil];
+ NSArray* items = [menu itemArray];
+ ASSERT_EQ([items count], 3U);
+ // 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(paste:));
+}
+
} // namespace
« no previous file with comments | « chrome/browser/cocoa/autocomplete_text_field_editor.mm ('k') | chrome/browser/cocoa/autocomplete_text_field_unittest_helper.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698