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

Side by Side Diff: chrome/browser/cocoa/find_bar_cocoa_controller_unittest.mm

Issue 2876002: Mac/clang: First pass over unit_tests (Closed)
Patch Set: '' Created 10 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
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 #include "base/string_util.h" 5 #include "base/string_util.h"
6 #include "base/sys_string_conversions.h" 6 #include "base/sys_string_conversions.h"
7 #include "chrome/browser/browser_window.h" 7 #include "chrome/browser/browser_window.h"
8 #include "chrome/browser/find_notification_details.h" 8 #include "chrome/browser/find_notification_details.h"
9 #import "chrome/browser/cocoa/cocoa_test_helper.h" 9 #import "chrome/browser/cocoa/cocoa_test_helper.h"
10 #import "chrome/browser/cocoa/find_bar_cocoa_controller.h" 10 #import "chrome/browser/cocoa/find_bar_cocoa_controller.h"
(...skipping 11 matching lines...) Expand all
22 22
23 @implementation FindBarCocoaController(Testing) 23 @implementation FindBarCocoaController(Testing)
24 - (NSView*)findBarView { 24 - (NSView*)findBarView {
25 return findBarView_; 25 return findBarView_;
26 } 26 }
27 27
28 - (NSString*)findText { 28 - (NSString*)findText {
29 return [findText_ stringValue]; 29 return [findText_ stringValue];
30 } 30 }
31 31
32 - (NSTextField*)findTextField { 32 - (FindBarTextField*)findTextField {
33 return findText_; 33 return findText_;
34 } 34 }
35 @end 35 @end
36 36
37 namespace { 37 namespace {
38 38
39 class FindBarCocoaControllerTest : public CocoaTest { 39 class FindBarCocoaControllerTest : public CocoaTest {
40 public: 40 public:
41 virtual void SetUp() { 41 virtual void SetUp() {
42 CocoaTest::SetUp(); 42 CocoaTest::SetUp();
(...skipping 23 matching lines...) Expand all
66 } 66 }
67 67
68 TEST_F(FindBarCocoaControllerTest, SetFindText) { 68 TEST_F(FindBarCocoaControllerTest, SetFindText) {
69 NSTextField* findTextField = [controller_ findTextField]; 69 NSTextField* findTextField = [controller_ findTextField];
70 70
71 // Start by making the find bar visible. 71 // Start by making the find bar visible.
72 [controller_ showFindBar:NO]; 72 [controller_ showFindBar:NO];
73 EXPECT_TRUE([controller_ isFindBarVisible]); 73 EXPECT_TRUE([controller_ isFindBarVisible]);
74 74
75 // Set the find text. 75 // Set the find text.
76 const NSString* kFindText = @"Google"; 76 NSString* const kFindText = @"Google";
77 [controller_ setFindText:kFindText]; 77 [controller_ setFindText:kFindText];
78 EXPECT_EQ( 78 EXPECT_EQ(
79 NSOrderedSame, 79 NSOrderedSame,
80 [[findTextField stringValue] compare:kFindText]); 80 [[findTextField stringValue] compare:kFindText]);
81 81
82 // Call clearResults, which doesn't actually clear the find text but 82 // Call clearResults, which doesn't actually clear the find text but
83 // simply sets it back to what it was before. This is silly, but 83 // simply sets it back to what it was before. This is silly, but
84 // matches the behavior on other platforms. |details| isn't used by 84 // matches the behavior on other platforms. |details| isn't used by
85 // our implementation of clearResults, so it's ok to pass in an 85 // our implementation of clearResults, so it's ok to pass in an
86 // empty |details|. 86 // empty |details|.
87 FindNotificationDetails details; 87 FindNotificationDetails details;
88 [controller_ clearResults:details]; 88 [controller_ clearResults:details];
89 EXPECT_EQ( 89 EXPECT_EQ(
90 NSOrderedSame, 90 NSOrderedSame,
91 [[findTextField stringValue] compare:kFindText]); 91 [[findTextField stringValue] compare:kFindText]);
92 } 92 }
93 93
94 TEST_F(FindBarCocoaControllerTest, ResultLabelUpdatesCorrectly) { 94 TEST_F(FindBarCocoaControllerTest, ResultLabelUpdatesCorrectly) {
95 // TODO(rohitrao): Test this. It may involve creating some dummy 95 // TODO(rohitrao): Test this. It may involve creating some dummy
96 // FindNotificationDetails objects. 96 // FindNotificationDetails objects.
97 } 97 }
98 98
99 TEST_F(FindBarCocoaControllerTest, FindTextIsGlobal) { 99 TEST_F(FindBarCocoaControllerTest, FindTextIsGlobal) {
100 scoped_nsobject<FindBarCocoaController> otherController( 100 scoped_nsobject<FindBarCocoaController> otherController(
101 [[FindBarCocoaController alloc] init]); 101 [[FindBarCocoaController alloc] init]);
102 [[test_window() contentView] addSubview:[otherController view]]; 102 [[test_window() contentView] addSubview:[otherController view]];
103 103
104 // Setting the text in one controller should update the other controller's 104 // Setting the text in one controller should update the other controller's
105 // text as well. 105 // text as well.
106 const NSString* kFindText = @"Respect to the man in the ice cream van"; 106 NSString* const kFindText = @"Respect to the man in the ice cream van";
107 [controller_ setFindText:kFindText]; 107 [controller_ setFindText:kFindText];
108 EXPECT_EQ( 108 EXPECT_EQ(
109 NSOrderedSame, 109 NSOrderedSame,
110 [[controller_ findText] compare:kFindText]); 110 [[controller_ findText] compare:kFindText]);
111 EXPECT_EQ( 111 EXPECT_EQ(
112 NSOrderedSame, 112 NSOrderedSame,
113 [[otherController.get() findText] compare:kFindText]); 113 [[otherController.get() findText] compare:kFindText]);
114 } 114 }
115 115
116 TEST_F(FindBarCocoaControllerTest, SettingFindTextUpdatesFindPboard) { 116 TEST_F(FindBarCocoaControllerTest, SettingFindTextUpdatesFindPboard) {
117 const NSString* kFindText = 117 NSString* const kFindText =
118 @"It's not a bird, it's not a plane, it must be Dave who's on the train"; 118 @"It's not a bird, it's not a plane, it must be Dave who's on the train";
119 [controller_ setFindText:kFindText]; 119 [controller_ setFindText:kFindText];
120 EXPECT_EQ( 120 EXPECT_EQ(
121 NSOrderedSame, 121 NSOrderedSame,
122 [[[FindPasteboard sharedInstance] findText] compare:kFindText]); 122 [[[FindPasteboard sharedInstance] findText] compare:kFindText]);
123 } 123 }
124 124
125 } // namespace 125 } // namespace
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698