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

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

Issue 402066: Moved a whole pile of unittests over to CocoaTest. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 11 years, 1 month 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) 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 <Cocoa/Cocoa.h>
6
7 #include "base/scoped_ptr.h"
8 #include "base/scoped_nsobject.h"
9 #include "base/string_util.h" 5 #include "base/string_util.h"
10 #include "base/sys_string_conversions.h" 6 #include "base/sys_string_conversions.h"
11 #include "chrome/browser/browser_window.h" 7 #include "chrome/browser/browser_window.h"
12 #include "chrome/browser/find_notification_details.h" 8 #include "chrome/browser/find_notification_details.h"
13 #import "chrome/browser/cocoa/cocoa_test_helper.h" 9 #import "chrome/browser/cocoa/cocoa_test_helper.h"
14 #import "chrome/browser/cocoa/find_bar_cocoa_controller.h" 10 #import "chrome/browser/cocoa/find_bar_cocoa_controller.h"
15 #import "chrome/browser/cocoa/find_pasteboard.h" 11 #import "chrome/browser/cocoa/find_pasteboard.h"
16 #import "chrome/browser/cocoa/find_bar_text_field.h" 12 #import "chrome/browser/cocoa/find_bar_text_field.h"
17 #include "testing/gtest/include/gtest/gtest.h" 13 #include "testing/gtest/include/gtest/gtest.h"
18 #include "testing/platform_test.h" 14 #include "testing/platform_test.h"
(...skipping 14 matching lines...) Expand all
33 return [findText_ stringValue]; 29 return [findText_ stringValue];
34 } 30 }
35 31
36 - (NSTextField*)findTextField { 32 - (NSTextField*)findTextField {
37 return findText_; 33 return findText_;
38 } 34 }
39 @end 35 @end
40 36
41 namespace { 37 namespace {
42 38
43 class FindBarCocoaControllerTest : public PlatformTest { 39 class FindBarCocoaControllerTest : public CocoaTest {
44 public: 40 public:
45 virtual void SetUp() { 41 virtual void SetUp() {
46 PlatformTest::SetUp(); 42 CocoaTest::SetUp();
47
48 // TODO(rohitrao): We don't really need to do this once per test.
49 // Consider moving it to SetUpTestCase().
50 controller_.reset([[FindBarCocoaController alloc] init]); 43 controller_.reset([[FindBarCocoaController alloc] init]);
51 [helper_.contentView() addSubview:[controller_ view]]; 44 [[test_window() contentView] addSubview:[controller_ view]];
52 } 45 }
53 46
54 protected: 47 protected:
55 CocoaTestHelper helper_;
56 scoped_nsobject<FindBarCocoaController> controller_; 48 scoped_nsobject<FindBarCocoaController> controller_;
57 }; 49 };
58 50
51 TEST_VIEW(FindBarCocoaControllerTest, [controller_ view])
52
59 TEST_F(FindBarCocoaControllerTest, ShowAndHide) { 53 TEST_F(FindBarCocoaControllerTest, ShowAndHide) {
60 NSView* findBarView = [controller_ findBarView]; 54 NSView* findBarView = [controller_ findBarView];
61 55
62 ASSERT_GT([findBarView frame].origin.y, 0); 56 ASSERT_GT([findBarView frame].origin.y, 0);
63 ASSERT_FALSE([controller_ isFindBarVisible]); 57 ASSERT_FALSE([controller_ isFindBarVisible]);
64 58
65 [controller_ showFindBar:NO]; 59 [controller_ showFindBar:NO];
66 EXPECT_EQ([findBarView frame].origin.y, 0); 60 EXPECT_EQ([findBarView frame].origin.y, 0);
67 EXPECT_TRUE([controller_ isFindBarVisible]); 61 EXPECT_TRUE([controller_ isFindBarVisible]);
68 62
(...skipping 29 matching lines...) Expand all
98 } 92 }
99 93
100 TEST_F(FindBarCocoaControllerTest, ResultLabelUpdatesCorrectly) { 94 TEST_F(FindBarCocoaControllerTest, ResultLabelUpdatesCorrectly) {
101 // TODO(rohitrao): Test this. It may involve creating some dummy 95 // TODO(rohitrao): Test this. It may involve creating some dummy
102 // FindNotificationDetails objects. 96 // FindNotificationDetails objects.
103 } 97 }
104 98
105 TEST_F(FindBarCocoaControllerTest, FindTextIsGlobal) { 99 TEST_F(FindBarCocoaControllerTest, FindTextIsGlobal) {
106 scoped_nsobject<FindBarCocoaController> otherController( 100 scoped_nsobject<FindBarCocoaController> otherController(
107 [[FindBarCocoaController alloc] init]); 101 [[FindBarCocoaController alloc] init]);
108 [helper_.contentView() addSubview:[otherController view]]; 102 [[test_window() contentView] addSubview:[otherController view]];
109 103
110 // 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
111 // text as well. 105 // text as well.
112 const NSString* kFindText = @"Respect to the man in the ice cream van"; 106 const NSString* kFindText = @"Respect to the man in the ice cream van";
113 [controller_ setFindText:kFindText]; 107 [controller_ setFindText:kFindText];
114 EXPECT_EQ( 108 EXPECT_EQ(
115 NSOrderedSame, 109 NSOrderedSame,
116 [[controller_ findText] compare:kFindText]); 110 [[controller_ findText] compare:kFindText]);
117 EXPECT_EQ( 111 EXPECT_EQ(
118 NSOrderedSame, 112 NSOrderedSame,
119 [[otherController.get() findText] compare:kFindText]); 113 [[otherController.get() findText] compare:kFindText]);
120 } 114 }
121 115
122 TEST_F(FindBarCocoaControllerTest, SettingFindTextUpdatesFindPboard) { 116 TEST_F(FindBarCocoaControllerTest, SettingFindTextUpdatesFindPboard) {
123 const NSString* kFindText = 117 const NSString* kFindText =
124 @"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";
125 [controller_ setFindText:kFindText]; 119 [controller_ setFindText:kFindText];
126 EXPECT_EQ( 120 EXPECT_EQ(
127 NSOrderedSame, 121 NSOrderedSame,
128 [[[FindPasteboard sharedInstance] findText] compare:kFindText]); 122 [[[FindPasteboard sharedInstance] findText] compare:kFindText]);
129 } 123 }
130 124
131 } // namespace 125 } // namespace
OLDNEW
« no previous file with comments | « chrome/browser/cocoa/event_utils_unittest.mm ('k') | chrome/browser/cocoa/find_bar_view_unittest.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698