| OLD | NEW |
| 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 #include "chrome/app/chrome_dll_resource.h" // IDC_* |
| 10 #import "chrome/browser/cocoa/autocomplete_text_field_unittest_helper.h" | 11 #import "chrome/browser/cocoa/autocomplete_text_field_unittest_helper.h" |
| 11 #import "chrome/browser/cocoa/cocoa_test_helper.h" | 12 #import "chrome/browser/cocoa/cocoa_test_helper.h" |
| 12 #include "grit/generated_resources.h" | 13 #include "grit/generated_resources.h" |
| 13 #include "testing/gtest/include/gtest/gtest.h" | 14 #include "testing/gtest/include/gtest/gtest.h" |
| 14 #include "testing/platform_test.h" | 15 #include "testing/platform_test.h" |
| 15 | 16 |
| 16 using ::testing::Return; | 17 using ::testing::Return; |
| 17 | 18 |
| 18 namespace { | 19 namespace { |
| 19 | 20 |
| (...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 167 | 168 |
| 168 // Test that the menu is constructed correctly when CanPasteAndGo(). | 169 // Test that the menu is constructed correctly when CanPasteAndGo(). |
| 169 TEST_F(AutocompleteTextFieldEditorTest, CanPasteAndGoMenu) { | 170 TEST_F(AutocompleteTextFieldEditorTest, CanPasteAndGoMenu) { |
| 170 EXPECT_CALL(field_observer_, CanPasteAndGo()) | 171 EXPECT_CALL(field_observer_, CanPasteAndGo()) |
| 171 .WillOnce(Return(true)); | 172 .WillOnce(Return(true)); |
| 172 EXPECT_CALL(field_observer_, GetPasteActionStringId()) | 173 EXPECT_CALL(field_observer_, GetPasteActionStringId()) |
| 173 .WillOnce(Return(IDS_PASTE_AND_GO)); | 174 .WillOnce(Return(IDS_PASTE_AND_GO)); |
| 174 | 175 |
| 175 NSMenu* menu = [editor_.get() menuForEvent:nil]; | 176 NSMenu* menu = [editor_.get() menuForEvent:nil]; |
| 176 NSArray* items = [menu itemArray]; | 177 NSArray* items = [menu itemArray]; |
| 177 ASSERT_EQ([items count], 4U); | 178 ASSERT_EQ([items count], 6U); |
| 178 // TODO(shess): Check the titles, too? | 179 // TODO(shess): Check the titles, too? |
| 179 NSUInteger i = 0; // Use an index to make future changes easier. | 180 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(cut:)); |
| 181 EXPECT_EQ([[items objectAtIndex:i++] action], @selector(copy:)); | 182 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(paste:)); |
| 183 EXPECT_EQ([[items objectAtIndex:i++] action], @selector(pasteAndGo:)); | 184 EXPECT_EQ([[items objectAtIndex:i++] action], @selector(pasteAndGo:)); |
| 185 EXPECT_TRUE([[items objectAtIndex:i++] isSeparatorItem]); |
| 186 |
| 187 EXPECT_EQ([[items objectAtIndex:i] action], @selector(commandDispatch:)); |
| 188 EXPECT_EQ([[items objectAtIndex:i] tag], IDC_EDIT_SEARCH_ENGINES); |
| 189 i++; |
| 184 } | 190 } |
| 185 | 191 |
| 186 // Test that the menu is constructed correctly when !CanPasteAndGo(). | 192 // Test that the menu is constructed correctly when !CanPasteAndGo(). |
| 187 TEST_F(AutocompleteTextFieldEditorTest, CannotPasteAndGoMenu) { | 193 TEST_F(AutocompleteTextFieldEditorTest, CannotPasteAndGoMenu) { |
| 188 EXPECT_CALL(field_observer_, CanPasteAndGo()) | 194 EXPECT_CALL(field_observer_, CanPasteAndGo()) |
| 189 .WillOnce(Return(false)); | 195 .WillOnce(Return(false)); |
| 190 | 196 |
| 191 NSMenu* menu = [editor_.get() menuForEvent:nil]; | 197 NSMenu* menu = [editor_.get() menuForEvent:nil]; |
| 192 NSArray* items = [menu itemArray]; | 198 NSArray* items = [menu itemArray]; |
| 193 ASSERT_EQ([items count], 3U); | 199 ASSERT_EQ([items count], 3U); |
| (...skipping 20 matching lines...) Expand all Loading... |
| 214 NSArray* items = [menu itemArray]; | 220 NSArray* items = [menu itemArray]; |
| 215 ASSERT_EQ([items count], 3U); | 221 ASSERT_EQ([items count], 3U); |
| 216 // TODO(shess): Check the titles, too? | 222 // TODO(shess): Check the titles, too? |
| 217 NSUInteger i = 0; // Use an index to make future changes easier. | 223 NSUInteger i = 0; // Use an index to make future changes easier. |
| 218 EXPECT_EQ([[items objectAtIndex:i++] action], @selector(cut:)); | 224 EXPECT_EQ([[items objectAtIndex:i++] action], @selector(cut:)); |
| 219 EXPECT_EQ([[items objectAtIndex:i++] action], @selector(copy:)); | 225 EXPECT_EQ([[items objectAtIndex:i++] action], @selector(copy:)); |
| 220 EXPECT_EQ([[items objectAtIndex:i++] action], @selector(paste:)); | 226 EXPECT_EQ([[items objectAtIndex:i++] action], @selector(paste:)); |
| 221 } | 227 } |
| 222 | 228 |
| 223 } // namespace | 229 } // namespace |
| OLD | NEW |