| OLD | NEW |
| 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> | 5 #import <Cocoa/Cocoa.h> |
| 6 | 6 |
| 7 #import "base/cocoa_protocols_mac.h" | 7 #import "base/cocoa_protocols_mac.h" |
| 8 #include "base/scoped_nsobject.h" | 8 #include "base/scoped_nsobject.h" |
| 9 #import "chrome/browser/cocoa/autocomplete_text_field.h" | 9 #import "chrome/browser/cocoa/autocomplete_text_field.h" |
| 10 #import "chrome/browser/cocoa/autocomplete_text_field_cell.h" | 10 #import "chrome/browser/cocoa/autocomplete_text_field_cell.h" |
| (...skipping 543 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 554 [NSApp postEvent:upEvent3 atStart:YES]; | 554 [NSApp postEvent:upEvent3 atStart:YES]; |
| 555 [field_ mouseDown:downEvent3]; | 555 [field_ mouseDown:downEvent3]; |
| 556 EXPECT_TRUE([field_ currentEditor]); | 556 EXPECT_TRUE([field_ currentEditor]); |
| 557 | 557 |
| 558 // Selected the first word. | 558 // Selected the first word. |
| 559 const NSRange selectedRange([[field_ currentEditor] selectedRange]); | 559 const NSRange selectedRange([[field_ currentEditor] selectedRange]); |
| 560 EXPECT_EQ(selectedRange.location, 0U); | 560 EXPECT_EQ(selectedRange.location, 0U); |
| 561 EXPECT_EQ(selectedRange.length, [[field_ stringValue] length]); | 561 EXPECT_EQ(selectedRange.length, [[field_ stringValue] length]); |
| 562 } | 562 } |
| 563 | 563 |
| 564 // Clicking the security icon should call its OnMousePressed. |
| 564 TEST_F(AutocompleteTextFieldObserverTest, SecurityIconMouseDown) { | 565 TEST_F(AutocompleteTextFieldObserverTest, SecurityIconMouseDown) { |
| 565 AutocompleteTextFieldCell* cell = [field_ autocompleteTextFieldCell]; | 566 AutocompleteTextFieldCell* cell = [field_ autocompleteTextFieldCell]; |
| 566 | 567 |
| 567 MockSecurityImageView security_image_view(NULL, NULL); | 568 MockSecurityImageView security_image_view(NULL, NULL); |
| 568 [cell setSecurityImageView:&security_image_view]; | 569 [cell setSecurityImageView:&security_image_view]; |
| 569 security_image_view.SetImageShown( | 570 security_image_view.SetImageShown( |
| 570 LocationBarViewMac::SecurityImageView::LOCK); | 571 LocationBarViewMac::SecurityImageView::LOCK); |
| 571 security_image_view.SetVisible(true); | 572 security_image_view.SetVisible(true); |
| 572 | 573 |
| 573 NSRect iconFrame([cell securityImageFrameForFrame:[field_ bounds]]); | 574 NSRect iconFrame([cell securityImageFrameForFrame:[field_ bounds]]); |
| 574 NSPoint location(NSMakePoint(NSMidX(iconFrame), NSMidY(iconFrame))); | 575 NSPoint location(NSMakePoint(NSMidX(iconFrame), NSMidY(iconFrame))); |
| 575 NSEvent* event(Event(field_, location, NSLeftMouseDown, 1)); | 576 NSEvent* event(Event(field_, location, NSLeftMouseDown, 1)); |
| 576 | 577 |
| 577 EXPECT_CALL(security_image_view, OnMousePressed()); | 578 EXPECT_CALL(security_image_view, OnMousePressed()); |
| 578 [field_ mouseDown:event]; | 579 [field_ mouseDown:event]; |
| 579 } | 580 } |
| 580 | 581 |
| 582 // Clicking a Page Action icon should call its OnMousePressed. |
| 581 TEST_F(AutocompleteTextFieldObserverTest, PageActionMouseDown) { | 583 TEST_F(AutocompleteTextFieldObserverTest, PageActionMouseDown) { |
| 582 AutocompleteTextFieldCell* cell = [field_ autocompleteTextFieldCell]; | 584 AutocompleteTextFieldCell* cell = [field_ autocompleteTextFieldCell]; |
| 583 | 585 |
| 584 MockSecurityImageView security_image_view(NULL, NULL); | 586 MockSecurityImageView security_image_view(NULL, NULL); |
| 585 security_image_view.SetImageShown( | 587 security_image_view.SetImageShown( |
| 586 LocationBarViewMac::SecurityImageView::LOCK); | 588 LocationBarViewMac::SecurityImageView::LOCK); |
| 587 [cell setSecurityImageView:&security_image_view]; | 589 [cell setSecurityImageView:&security_image_view]; |
| 588 | 590 |
| 589 MockPageActionImageView page_action_view; | 591 MockPageActionImageView page_action_view; |
| 590 NSImage* image = [NSImage imageNamed:@"NSApplicationIcon"]; | 592 NSImage* image = [NSImage imageNamed:@"NSApplicationIcon"]; |
| (...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 783 scoped_nsobject<AutocompleteTextField> pin([field_ retain]); | 785 scoped_nsobject<AutocompleteTextField> pin([field_ retain]); |
| 784 [field_ removeFromSuperview]; | 786 [field_ removeFromSuperview]; |
| 785 [test_window() resignKeyWindow]; | 787 [test_window() resignKeyWindow]; |
| 786 | 788 |
| 787 [[test_window() contentView] addSubview:field_]; | 789 [[test_window() contentView] addSubview:field_]; |
| 788 EXPECT_CALL(field_observer_, OnDidResignKey()); | 790 EXPECT_CALL(field_observer_, OnDidResignKey()); |
| 789 [test_window() resignKeyWindow]; | 791 [test_window() resignKeyWindow]; |
| 790 } | 792 } |
| 791 | 793 |
| 792 } // namespace | 794 } // namespace |
| OLD | NEW |