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

Side by Side 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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 #import "chrome/browser/cocoa/autocomplete_text_field_editor.h" 5 #import "chrome/browser/cocoa/autocomplete_text_field_editor.h"
6 6
7 #include "base/scoped_nsobject.h" 7 #include "base/scoped_nsobject.h"
8 #include "base/scoped_ptr.h" 8 #include "base/scoped_ptr.h"
9 #include "base/string_util.h" 9 #include "base/string_util.h"
10 #import "chrome/browser/cocoa/autocomplete_text_field_unittest_helper.h" 10 #import "chrome/browser/cocoa/autocomplete_text_field_unittest_helper.h"
11 #import "chrome/browser/cocoa/cocoa_test_helper.h" 11 #import "chrome/browser/cocoa/cocoa_test_helper.h"
12 #include "grit/generated_resources.h"
12 #include "testing/gtest/include/gtest/gtest.h" 13 #include "testing/gtest/include/gtest/gtest.h"
13 #include "testing/platform_test.h" 14 #include "testing/platform_test.h"
14 15
16 using ::testing::Return;
17
15 namespace { 18 namespace {
16 19
17 int NumTypesOnPasteboard(NSPasteboard* pb) { 20 int NumTypesOnPasteboard(NSPasteboard* pb) {
18 return [[pb types] count]; 21 return [[pb types] count];
19 } 22 }
20 23
21 void ClearPasteboard(NSPasteboard* pb) { 24 void ClearPasteboard(NSPasteboard* pb) {
22 [pb declareTypes:[NSArray array] owner:nil]; 25 [pb declareTypes:[NSArray array] owner:nil];
23 } 26 }
24 27
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
149 [field_ display]; 152 [field_ display];
150 [editor_ display]; 153 [editor_ display];
151 } 154 }
152 155
153 // Test that -paste: is correctly delegated to the observer. 156 // Test that -paste: is correctly delegated to the observer.
154 TEST_F(AutocompleteTextFieldEditorTest, Paste) { 157 TEST_F(AutocompleteTextFieldEditorTest, Paste) {
155 EXPECT_CALL(field_observer_, OnPaste()); 158 EXPECT_CALL(field_observer_, OnPaste());
156 [editor_.get() paste:nil]; 159 [editor_.get() paste:nil];
157 } 160 }
158 161
162 // Test that -pasteAndGo: is correctly delegated to the observer.
163 TEST_F(AutocompleteTextFieldEditorTest, PasteAndGo) {
164 EXPECT_CALL(field_observer_, OnPasteAndGo());
165 [editor_.get() pasteAndGo:nil];
166 }
167
168 // Test that the menu is constructed correctly when CanPasteAndGo().
169 TEST_F(AutocompleteTextFieldEditorTest, CanPasteAndGoMenu) {
170 EXPECT_CALL(field_observer_, CanPasteAndGo())
171 .WillOnce(Return(true));
172 EXPECT_CALL(field_observer_, GetPasteActionStringId())
173 .WillOnce(Return(IDS_PASTE_AND_GO));
174
175 NSMenu* menu = [editor_.get() menuForEvent:nil];
176 NSArray* items = [menu itemArray];
177 ASSERT_EQ([items count], 4U);
178 // TODO(shess): Check the titles, too?
179 NSUInteger i = 0; // Use an index to make future changes easier.
180 EXPECT_EQ([[items objectAtIndex:i++] action], @selector(cut:));
181 EXPECT_EQ([[items objectAtIndex:i++] action], @selector(copy:));
182 EXPECT_EQ([[items objectAtIndex:i++] action], @selector(paste:));
183 EXPECT_EQ([[items objectAtIndex:i++] action], @selector(pasteAndGo:));
184 }
185
186 // Test that the menu is constructed correctly when !CanPasteAndGo().
187 TEST_F(AutocompleteTextFieldEditorTest, CannotPasteAndGoMenu) {
188 EXPECT_CALL(field_observer_, CanPasteAndGo())
189 .WillOnce(Return(false));
190
191 NSMenu* menu = [editor_.get() menuForEvent:nil];
192 NSArray* items = [menu itemArray];
193 ASSERT_EQ([items count], 3U);
194 // TODO(shess): Check the titles, too?
195 NSUInteger i = 0; // Use an index to make future changes easier.
196 EXPECT_EQ([[items objectAtIndex:i++] action], @selector(cut:));
197 EXPECT_EQ([[items objectAtIndex:i++] action], @selector(copy:));
198 EXPECT_EQ([[items objectAtIndex:i++] action], @selector(paste:));
199 }
200
159 } // namespace 201 } // namespace
OLDNEW
« 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