| OLD | NEW |
| 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 #include "base/strings/string_util.h" | 5 #include "base/strings/string_util.h" |
| 6 #include "base/strings/sys_string_conversions.h" | 6 #include "base/strings/sys_string_conversions.h" |
| 7 #include "chrome/browser/ui/browser_window.h" | 7 #include "chrome/browser/ui/browser_window.h" |
| 8 #import "chrome/browser/ui/cocoa/cocoa_test_helper.h" | 8 #import "chrome/browser/ui/cocoa/cocoa_test_helper.h" |
| 9 #import "chrome/browser/ui/cocoa/find_bar/find_bar_cocoa_controller.h" | 9 #import "chrome/browser/ui/cocoa/find_bar/find_bar_cocoa_controller.h" |
| 10 #import "chrome/browser/ui/cocoa/find_bar/find_bar_text_field.h" | 10 #import "chrome/browser/ui/cocoa/find_bar/find_bar_text_field.h" |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 46 controller_.reset([[FindBarCocoaController alloc] initWithBrowser:nil]); | 46 controller_.reset([[FindBarCocoaController alloc] initWithBrowser:nil]); |
| 47 [[test_window() contentView] addSubview:[controller_ view]]; | 47 [[test_window() contentView] addSubview:[controller_ view]]; |
| 48 } | 48 } |
| 49 | 49 |
| 50 virtual void TearDown() { | 50 virtual void TearDown() { |
| 51 CocoaTest::TearDown(); | 51 CocoaTest::TearDown(); |
| 52 [controller_ stopAnimation]; | 52 [controller_ stopAnimation]; |
| 53 } | 53 } |
| 54 | 54 |
| 55 protected: | 55 protected: |
| 56 scoped_nsobject<FindBarCocoaController> controller_; | 56 base::scoped_nsobject<FindBarCocoaController> controller_; |
| 57 }; | 57 }; |
| 58 | 58 |
| 59 TEST_VIEW(FindBarCocoaControllerTest, [controller_ view]) | 59 TEST_VIEW(FindBarCocoaControllerTest, [controller_ view]) |
| 60 | 60 |
| 61 TEST_F(FindBarCocoaControllerTest, ImagesLoadedProperly) { | 61 TEST_F(FindBarCocoaControllerTest, ImagesLoadedProperly) { |
| 62 EXPECT_TRUE([[[controller_ nextButton] image] isValid]); | 62 EXPECT_TRUE([[[controller_ nextButton] image] isValid]); |
| 63 EXPECT_TRUE([[[controller_ previousButton] image] isValid]); | 63 EXPECT_TRUE([[[controller_ previousButton] image] isValid]); |
| 64 } | 64 } |
| 65 | 65 |
| 66 TEST_F(FindBarCocoaControllerTest, ShowAndHide) { | 66 TEST_F(FindBarCocoaControllerTest, ShowAndHide) { |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 103 NSOrderedSame, | 103 NSOrderedSame, |
| 104 [[findTextField stringValue] compare:kFindText]); | 104 [[findTextField stringValue] compare:kFindText]); |
| 105 } | 105 } |
| 106 | 106 |
| 107 TEST_F(FindBarCocoaControllerTest, ResultLabelUpdatesCorrectly) { | 107 TEST_F(FindBarCocoaControllerTest, ResultLabelUpdatesCorrectly) { |
| 108 // TODO(rohitrao): Test this. It may involve creating some dummy | 108 // TODO(rohitrao): Test this. It may involve creating some dummy |
| 109 // FindNotificationDetails objects. | 109 // FindNotificationDetails objects. |
| 110 } | 110 } |
| 111 | 111 |
| 112 TEST_F(FindBarCocoaControllerTest, FindTextIsGlobal) { | 112 TEST_F(FindBarCocoaControllerTest, FindTextIsGlobal) { |
| 113 scoped_nsobject<FindBarCocoaController> otherController( | 113 base::scoped_nsobject<FindBarCocoaController> otherController( |
| 114 [[FindBarCocoaController alloc] initWithBrowser:nil]); | 114 [[FindBarCocoaController alloc] initWithBrowser:nil]); |
| 115 [[test_window() contentView] addSubview:[otherController view]]; | 115 [[test_window() contentView] addSubview:[otherController view]]; |
| 116 | 116 |
| 117 // Setting the text in one controller should update the other controller's | 117 // Setting the text in one controller should update the other controller's |
| 118 // text as well. | 118 // text as well. |
| 119 NSString* const kFindText = @"Respect to the man in the ice cream van"; | 119 NSString* const kFindText = @"Respect to the man in the ice cream van"; |
| 120 [controller_ setFindText:kFindText]; | 120 [controller_ setFindText:kFindText]; |
| 121 EXPECT_EQ( | 121 EXPECT_EQ( |
| 122 NSOrderedSame, | 122 NSOrderedSame, |
| 123 [[controller_ findText] compare:kFindText]); | 123 [[controller_ findText] compare:kFindText]); |
| 124 EXPECT_EQ( | 124 EXPECT_EQ( |
| 125 NSOrderedSame, | 125 NSOrderedSame, |
| 126 [[otherController.get() findText] compare:kFindText]); | 126 [[otherController.get() findText] compare:kFindText]); |
| 127 } | 127 } |
| 128 | 128 |
| 129 TEST_F(FindBarCocoaControllerTest, SettingFindTextUpdatesFindPboard) { | 129 TEST_F(FindBarCocoaControllerTest, SettingFindTextUpdatesFindPboard) { |
| 130 NSString* const kFindText = | 130 NSString* const kFindText = |
| 131 @"It's not a bird, it's not a plane, it must be Dave who's on the train"; | 131 @"It's not a bird, it's not a plane, it must be Dave who's on the train"; |
| 132 [controller_ setFindText:kFindText]; | 132 [controller_ setFindText:kFindText]; |
| 133 EXPECT_EQ( | 133 EXPECT_EQ( |
| 134 NSOrderedSame, | 134 NSOrderedSame, |
| 135 [[[FindPasteboard sharedInstance] findText] compare:kFindText]); | 135 [[[FindPasteboard sharedInstance] findText] compare:kFindText]); |
| 136 } | 136 } |
| 137 | 137 |
| 138 } // namespace | 138 } // namespace |
| OLD | NEW |