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

Side by Side Diff: chrome/browser/ui/cocoa/location_bar/autocomplete_text_field_editor_unittest.mm

Issue 17593006: mac: Update clients of scoped_nsobject.h. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: iwyu, scoped_nsprotocol Created 7 years, 6 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/ui/cocoa/location_bar/autocomplete_text_field_editor.h" 5 #import "chrome/browser/ui/cocoa/location_bar/autocomplete_text_field_editor.h"
6 6
7 #include "base/memory/scoped_nsobject.h" 7 #include "base/mac/scoped_nsobject.h"
8 #include "base/memory/scoped_ptr.h" 8 #include "base/memory/scoped_ptr.h"
9 #include "base/strings/string_util.h" 9 #include "base/strings/string_util.h"
10 #include "chrome/app/chrome_command_ids.h" // IDC_* 10 #include "chrome/app/chrome_command_ids.h" // IDC_*
11 #import "chrome/browser/ui/cocoa/cocoa_test_helper.h" 11 #import "chrome/browser/ui/cocoa/cocoa_test_helper.h"
12 #import "chrome/browser/ui/cocoa/location_bar/autocomplete_text_field_unittest_h elper.h" 12 #import "chrome/browser/ui/cocoa/location_bar/autocomplete_text_field_unittest_h elper.h"
13 #include "grit/generated_resources.h" 13 #include "grit/generated_resources.h"
14 #include "testing/gmock/include/gmock/gmock-matchers.h" 14 #include "testing/gmock/include/gmock/gmock-matchers.h"
15 #include "testing/gtest/include/gtest/gtest.h" 15 #include "testing/gtest/include/gtest/gtest.h"
16 #import "testing/gtest_mac.h" 16 #import "testing/gtest_mac.h"
17 #include "testing/platform_test.h" 17 #include "testing/platform_test.h"
18 #import "third_party/ocmock/OCMock/OCMock.h"
18 #include "third_party/ocmock/gtest_support.h" 19 #include "third_party/ocmock/gtest_support.h"
19 #import "third_party/ocmock/OCMock/OCMock.h"
20 #import "third_party/ocmock/ocmock_extensions.h" 20 #import "third_party/ocmock/ocmock_extensions.h"
21 #import "ui/base/test/cocoa_test_event_utils.h" 21 #import "ui/base/test/cocoa_test_event_utils.h"
22 22
23 using ::testing::Return; 23 using ::testing::Return;
24 using ::testing::ReturnArg; 24 using ::testing::ReturnArg;
25 using ::testing::StrictMock; 25 using ::testing::StrictMock;
26 using ::testing::A; 26 using ::testing::A;
27 27
28 namespace { 28 namespace {
29 29
30 // TODO(shess): Very similar to AutocompleteTextFieldTest. Maybe 30 // TODO(shess): Very similar to AutocompleteTextFieldTest. Maybe
31 // those can be shared. 31 // those can be shared.
32 32
33 class AutocompleteTextFieldEditorTest : public CocoaTest { 33 class AutocompleteTextFieldEditorTest : public CocoaTest {
34 public: 34 public:
35 virtual void SetUp() { 35 virtual void SetUp() {
36 CocoaTest::SetUp(); 36 CocoaTest::SetUp();
37 NSRect frame = NSMakeRect(0, 0, 50, 30); 37 NSRect frame = NSMakeRect(0, 0, 50, 30);
38 scoped_nsobject<AutocompleteTextField> field( 38 base::scoped_nsobject<AutocompleteTextField> field(
39 [[AutocompleteTextField alloc] initWithFrame:frame]); 39 [[AutocompleteTextField alloc] initWithFrame:frame]);
40 field_ = field.get(); 40 field_ = field.get();
41 [field_ setStringValue:@"Testing"]; 41 [field_ setStringValue:@"Testing"];
42 [[test_window() contentView] addSubview:field_]; 42 [[test_window() contentView] addSubview:field_];
43 43
44 // Arrange for |field_| to get the right field editor. 44 // Arrange for |field_| to get the right field editor.
45 window_delegate_.reset( 45 window_delegate_.reset(
46 [[AutocompleteTextFieldWindowTestDelegate alloc] init]); 46 [[AutocompleteTextFieldWindowTestDelegate alloc] init]);
47 [test_window() setDelegate:window_delegate_.get()]; 47 [test_window() setDelegate:window_delegate_.get()];
48 48
49 // Get the field editor setup. 49 // Get the field editor setup.
50 [test_window() makePretendKeyWindowAndSetFirstResponder:field_]; 50 [test_window() makePretendKeyWindowAndSetFirstResponder:field_];
51 editor_ = static_cast<AutocompleteTextFieldEditor*>([field_ currentEditor]); 51 editor_ = static_cast<AutocompleteTextFieldEditor*>([field_ currentEditor]);
52 52
53 EXPECT_TRUE(editor_); 53 EXPECT_TRUE(editor_);
54 EXPECT_TRUE([editor_ isKindOfClass:[AutocompleteTextFieldEditor class]]); 54 EXPECT_TRUE([editor_ isKindOfClass:[AutocompleteTextFieldEditor class]]);
55 } 55 }
56 56
57 AutocompleteTextFieldEditor* editor_; 57 AutocompleteTextFieldEditor* editor_;
58 AutocompleteTextField* field_; 58 AutocompleteTextField* field_;
59 scoped_nsobject<AutocompleteTextFieldWindowTestDelegate> window_delegate_; 59 base::scoped_nsobject<AutocompleteTextFieldWindowTestDelegate>
60 window_delegate_;
60 }; 61 };
61 62
62 // Disabled because it crashes sometimes. http://crbug.com/49522 63 // Disabled because it crashes sometimes. http://crbug.com/49522
63 // Can't rename DISABLED_ because the TEST_VIEW macro prepends. 64 // Can't rename DISABLED_ because the TEST_VIEW macro prepends.
64 // http://crbug.com/53621 65 // http://crbug.com/53621
65 #if 0 66 #if 0
66 TEST_VIEW(AutocompleteTextFieldEditorTest, field_); 67 TEST_VIEW(AutocompleteTextFieldEditorTest, field_);
67 #endif 68 #endif
68 69
69 // Test that control characters are stripped from insertions. 70 // Test that control characters are stripped from insertions.
(...skipping 30 matching lines...) Expand all
100 101
101 // Test that |delegate| can provide page action menus. 102 // Test that |delegate| can provide page action menus.
102 TEST_F(AutocompleteTextFieldEditorTest, PageActionMenus) { 103 TEST_F(AutocompleteTextFieldEditorTest, PageActionMenus) {
103 // The event just needs to be something the mock can recognize. 104 // The event just needs to be something the mock can recognize.
104 NSEvent* event = cocoa_test_event_utils::MouseEventAtPoint(NSZeroPoint, 105 NSEvent* event = cocoa_test_event_utils::MouseEventAtPoint(NSZeroPoint,
105 NSRightMouseDown, 106 NSRightMouseDown,
106 0); 107 0);
107 108
108 // Trivial menu which we can recognize and which doesn't look like 109 // Trivial menu which we can recognize and which doesn't look like
109 // the default editor context menu. 110 // the default editor context menu.
110 scoped_nsobject<id> menu([[NSMenu alloc] initWithTitle:@"Menu"]); 111 base::scoped_nsobject<id> menu([[NSMenu alloc] initWithTitle:@"Menu"]);
111 [menu addItemWithTitle:@"Go Fish" 112 [menu addItemWithTitle:@"Go Fish"
112 action:@selector(goFish:) 113 action:@selector(goFish:)
113 keyEquivalent:@""]; 114 keyEquivalent:@""];
114 115
115 // So that we don't have to mock the observer. 116 // So that we don't have to mock the observer.
116 [editor_ setEditable:NO]; 117 [editor_ setEditable:NO];
117 118
118 // The delegate's intercept point gets called, and results are 119 // The delegate's intercept point gets called, and results are
119 // propagated back. 120 // propagated back.
120 { 121 {
(...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after
401 for (NSUInteger i = 0; i < [items count]; ++i) { 402 for (NSUInteger i = 0; i < [items count]; ++i) {
402 NSMenuItem* item = [items objectAtIndex:i]; 403 NSMenuItem* item = [items objectAtIndex:i];
403 if ([item action] == @selector(copyURL:)) { 404 if ([item action] == @selector(copyURL:)) {
404 EXPECT_FALSE([editor_ validateMenuItem:item]); 405 EXPECT_FALSE([editor_ validateMenuItem:item]);
405 break; 406 break;
406 } 407 }
407 } 408 }
408 } 409 }
409 410
410 } // namespace 411 } // namespace
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698