| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 <ApplicationServices/ApplicationServices.h> | 5 #import <ApplicationServices/ApplicationServices.h> |
| 6 #import <Cocoa/Cocoa.h> | 6 #import <Cocoa/Cocoa.h> |
| 7 | 7 |
| 8 #include "base/mac/foundation_util.h" | 8 #include "base/mac/foundation_util.h" |
| 9 #include "base/mac/scoped_nsobject.h" | 9 #include "base/mac/scoped_nsobject.h" |
| 10 #import "chrome/browser/ui/cocoa/cocoa_test_helper.h" | 10 #import "chrome/browser/ui/cocoa/cocoa_test_helper.h" |
| (...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 236 | 236 |
| 237 // Test drawing, mostly to ensure nothing leaks or crashes. | 237 // Test drawing, mostly to ensure nothing leaks or crashes. |
| 238 TEST_F(AutocompleteTextFieldTest, Display) { | 238 TEST_F(AutocompleteTextFieldTest, Display) { |
| 239 [field_ display]; | 239 [field_ display]; |
| 240 | 240 |
| 241 // Test focussed drawing. | 241 // Test focussed drawing. |
| 242 [test_window() makePretendKeyWindowAndSetFirstResponder:field_]; | 242 [test_window() makePretendKeyWindowAndSetFirstResponder:field_]; |
| 243 [field_ display]; | 243 [field_ display]; |
| 244 } | 244 } |
| 245 | 245 |
| 246 // Test setting gray text, mostly to ensure nothing leaks or crashes. | |
| 247 TEST_F(AutocompleteTextFieldTest, GrayText) { | |
| 248 [field_ display]; | |
| 249 EXPECT_FALSE([field_ needsDisplay]); | |
| 250 [field_ setGrayTextAutocompletion:@"foo" textColor:[NSColor redColor]]; | |
| 251 EXPECT_TRUE([field_ needsDisplay]); | |
| 252 [field_ display]; | |
| 253 } | |
| 254 | |
| 255 TEST_F(AutocompleteTextFieldObserverTest, FlagsChanged) { | 246 TEST_F(AutocompleteTextFieldObserverTest, FlagsChanged) { |
| 256 InSequence dummy; // Call mock in exactly the order specified. | 247 InSequence dummy; // Call mock in exactly the order specified. |
| 257 | 248 |
| 258 // Test without Control key down, but some other modifier down. | 249 // Test without Control key down, but some other modifier down. |
| 259 EXPECT_CALL(field_observer_, OnControlKeyChanged(false)); | 250 EXPECT_CALL(field_observer_, OnControlKeyChanged(false)); |
| 260 [field_ flagsChanged:KeyDownEventWithFlags(NSShiftKeyMask)]; | 251 [field_ flagsChanged:KeyDownEventWithFlags(NSShiftKeyMask)]; |
| 261 | 252 |
| 262 // Test with Control key down. | 253 // Test with Control key down. |
| 263 EXPECT_CALL(field_observer_, OnControlKeyChanged(true)); | 254 EXPECT_CALL(field_observer_, OnControlKeyChanged(true)); |
| 264 [field_ flagsChanged:KeyDownEventWithFlags(NSControlKeyMask)]; | 255 [field_ flagsChanged:KeyDownEventWithFlags(NSControlKeyMask)]; |
| (...skipping 668 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 933 base::scoped_nsobject<AutocompleteTextField> pin([field_ retain]); | 924 base::scoped_nsobject<AutocompleteTextField> pin([field_ retain]); |
| 934 [field_ removeFromSuperview]; | 925 [field_ removeFromSuperview]; |
| 935 [test_window() resignKeyWindow]; | 926 [test_window() resignKeyWindow]; |
| 936 | 927 |
| 937 [[test_window() contentView] addSubview:field_]; | 928 [[test_window() contentView] addSubview:field_]; |
| 938 EXPECT_CALL(field_observer_, ClosePopup()); | 929 EXPECT_CALL(field_observer_, ClosePopup()); |
| 939 [test_window() resignKeyWindow]; | 930 [test_window() resignKeyWindow]; |
| 940 } | 931 } |
| 941 | 932 |
| 942 } // namespace | 933 } // namespace |
| OLD | NEW |