| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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> | 5 #import <Cocoa/Cocoa.h> |
| 6 | 6 |
| 7 #import "base/mac/cocoa_protocols.h" | 7 #import "base/mac/cocoa_protocols.h" |
| 8 #include "base/scoped_nsobject.h" | 8 #include "base/scoped_nsobject.h" |
| 9 #import "chrome/browser/ui/cocoa/location_bar/autocomplete_text_field.h" | 9 #import "chrome/browser/ui/cocoa/location_bar/autocomplete_text_field.h" |
| 10 #import "chrome/browser/ui/cocoa/location_bar/autocomplete_text_field_cell.h" | 10 #import "chrome/browser/ui/cocoa/location_bar/autocomplete_text_field_cell.h" |
| (...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 324 | 324 |
| 325 EXPECT_CALL(field_observer_, OnSetFocus(false)); | 325 EXPECT_CALL(field_observer_, OnSetFocus(false)); |
| 326 // Becoming first responder doesn't begin editing. | 326 // Becoming first responder doesn't begin editing. |
| 327 [test_window() makePretendKeyWindowAndSetFirstResponder:field_]; | 327 [test_window() makePretendKeyWindowAndSetFirstResponder:field_]; |
| 328 const NSRect baseEditorFrame = EditorFrame(); | 328 const NSRect baseEditorFrame = EditorFrame(); |
| 329 NSTextView* editor = static_cast<NSTextView*>([field_ currentEditor]); | 329 NSTextView* editor = static_cast<NSTextView*>([field_ currentEditor]); |
| 330 EXPECT_TRUE(nil != editor); | 330 EXPECT_TRUE(nil != editor); |
| 331 | 331 |
| 332 // This should begin editing and indicate a change. | 332 // This should begin editing and indicate a change. |
| 333 EXPECT_CALL(field_observer_, OnDidBeginEditing()); | 333 EXPECT_CALL(field_observer_, OnDidBeginEditing()); |
| 334 EXPECT_CALL(field_observer_, OnBeforeChange()); |
| 334 EXPECT_CALL(field_observer_, OnDidChange()); | 335 EXPECT_CALL(field_observer_, OnDidChange()); |
| 335 [editor shouldChangeTextInRange:NSMakeRange(0, 0) replacementString:@""]; | 336 [editor shouldChangeTextInRange:NSMakeRange(0, 0) replacementString:@""]; |
| 336 [editor didChangeText]; | 337 [editor didChangeText]; |
| 337 | 338 |
| 338 // No messages to |field_observer_| when the frame actually changes. | 339 // No messages to |field_observer_| when the frame actually changes. |
| 339 mock_left_decoration_.SetVisible(true); | 340 mock_left_decoration_.SetVisible(true); |
| 340 [field_ resetFieldEditorFrameIfNeeded]; | 341 [field_ resetFieldEditorFrameIfNeeded]; |
| 341 EXPECT_FALSE(NSEqualRects(baseEditorFrame, EditorFrame())); | 342 EXPECT_FALSE(NSEqualRects(baseEditorFrame, EditorFrame())); |
| 342 } | 343 } |
| 343 | 344 |
| (...skipping 398 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 742 .WillRepeatedly(ReturnArg<0>()); | 743 .WillRepeatedly(ReturnArg<0>()); |
| 743 | 744 |
| 744 EXPECT_CALL(field_observer_, OnSetFocus(false)); | 745 EXPECT_CALL(field_observer_, OnSetFocus(false)); |
| 745 // Becoming first responder doesn't begin editing. | 746 // Becoming first responder doesn't begin editing. |
| 746 [test_window() makePretendKeyWindowAndSetFirstResponder:field_]; | 747 [test_window() makePretendKeyWindowAndSetFirstResponder:field_]; |
| 747 NSTextView* editor = static_cast<NSTextView*>([field_ currentEditor]); | 748 NSTextView* editor = static_cast<NSTextView*>([field_ currentEditor]); |
| 748 EXPECT_TRUE(nil != editor); | 749 EXPECT_TRUE(nil != editor); |
| 749 | 750 |
| 750 // This should begin editing and indicate a change. | 751 // This should begin editing and indicate a change. |
| 751 EXPECT_CALL(field_observer_, OnDidBeginEditing()); | 752 EXPECT_CALL(field_observer_, OnDidBeginEditing()); |
| 753 EXPECT_CALL(field_observer_, OnBeforeChange()); |
| 752 EXPECT_CALL(field_observer_, OnDidChange()); | 754 EXPECT_CALL(field_observer_, OnDidChange()); |
| 753 [editor shouldChangeTextInRange:NSMakeRange(0, 0) replacementString:@""]; | 755 [editor shouldChangeTextInRange:NSMakeRange(0, 0) replacementString:@""]; |
| 754 [editor didChangeText]; | 756 [editor didChangeText]; |
| 755 | 757 |
| 756 // Further changes don't send the begin message. | 758 // Further changes don't send the begin message. |
| 759 EXPECT_CALL(field_observer_, OnBeforeChange()); |
| 757 EXPECT_CALL(field_observer_, OnDidChange()); | 760 EXPECT_CALL(field_observer_, OnDidChange()); |
| 758 [editor shouldChangeTextInRange:NSMakeRange(0, 0) replacementString:@""]; | 761 [editor shouldChangeTextInRange:NSMakeRange(0, 0) replacementString:@""]; |
| 759 [editor didChangeText]; | 762 [editor didChangeText]; |
| 760 | 763 |
| 761 // -doCommandBySelector: should forward to observer via |field_|. | 764 // -doCommandBySelector: should forward to observer via |field_|. |
| 762 // TODO(shess): Test with a fake arrow-key event? | 765 // TODO(shess): Test with a fake arrow-key event? |
| 763 const SEL cmd = @selector(moveDown:); | 766 const SEL cmd = @selector(moveDown:); |
| 764 EXPECT_CALL(field_observer_, OnDoCommandBySelector(cmd)) | 767 EXPECT_CALL(field_observer_, OnDoCommandBySelector(cmd)) |
| 765 .WillOnce(Return(true)); | 768 .WillOnce(Return(true)); |
| 766 [editor doCommandBySelector:cmd]; | 769 [editor doCommandBySelector:cmd]; |
| (...skipping 16 matching lines...) Expand all Loading... |
| 783 scoped_nsobject<AutocompleteTextField> pin([field_ retain]); | 786 scoped_nsobject<AutocompleteTextField> pin([field_ retain]); |
| 784 [field_ removeFromSuperview]; | 787 [field_ removeFromSuperview]; |
| 785 [test_window() resignKeyWindow]; | 788 [test_window() resignKeyWindow]; |
| 786 | 789 |
| 787 [[test_window() contentView] addSubview:field_]; | 790 [[test_window() contentView] addSubview:field_]; |
| 788 EXPECT_CALL(field_observer_, ClosePopup()); | 791 EXPECT_CALL(field_observer_, ClosePopup()); |
| 789 [test_window() resignKeyWindow]; | 792 [test_window() resignKeyWindow]; |
| 790 } | 793 } |
| 791 | 794 |
| 792 } // namespace | 795 } // namespace |
| OLD | NEW |