| 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 #include "app/resource_bundle.h" | 7 #include "app/resource_bundle.h" |
| 8 #import "base/cocoa_protocols_mac.h" | 8 #import "base/cocoa_protocols_mac.h" |
| 9 #include "base/scoped_nsobject.h" | 9 #include "base/scoped_nsobject.h" |
| 10 #import "chrome/browser/cocoa/autocomplete_text_field.h" | 10 #import "chrome/browser/cocoa/autocomplete_text_field.h" |
| (...skipping 563 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 574 [NSApp postEvent:upEvent3 atStart:YES]; | 574 [NSApp postEvent:upEvent3 atStart:YES]; |
| 575 [field_ mouseDown:downEvent3]; | 575 [field_ mouseDown:downEvent3]; |
| 576 EXPECT_TRUE([field_ currentEditor]); | 576 EXPECT_TRUE([field_ currentEditor]); |
| 577 | 577 |
| 578 // Selected the first word. | 578 // Selected the first word. |
| 579 const NSRange selectedRange([[field_ currentEditor] selectedRange]); | 579 const NSRange selectedRange([[field_ currentEditor] selectedRange]); |
| 580 EXPECT_EQ(selectedRange.location, 0U); | 580 EXPECT_EQ(selectedRange.location, 0U); |
| 581 EXPECT_EQ(selectedRange.length, [[field_ stringValue] length]); | 581 EXPECT_EQ(selectedRange.length, [[field_ stringValue] length]); |
| 582 } | 582 } |
| 583 | 583 |
| 584 // Clicking the location icon should call its OnMousePressed. | 584 // Clicking the security icon should call its OnMousePressed. |
| 585 TEST_F(AutocompleteTextFieldObserverTest, LocationIconMouseDown) { | 585 TEST_F(AutocompleteTextFieldTest, LocationIconMouseDown) { |
| 586 AutocompleteTextFieldCell* cell = [field_ autocompleteTextFieldCell]; | 586 AutocompleteTextFieldCell* cell = [field_ autocompleteTextFieldCell]; |
| 587 | 587 |
| 588 MockLocationIconView location_icon_view(NULL); | 588 MockLocationIconView location_icon_view(NULL); |
| 589 [cell setLocationIconView:&location_icon_view]; | 589 [cell setLocationIconView:&location_icon_view]; |
| 590 location_icon_view.SetImage( | 590 location_icon_view.SetImage( |
| 591 ResourceBundle::GetSharedInstance().GetNSImageNamed(IDR_SECURE)); | 591 ResourceBundle::GetSharedInstance().GetNSImageNamed(IDR_SECURE)); |
| 592 location_icon_view.SetVisible(true); | 592 location_icon_view.SetVisible(true); |
| 593 | 593 |
| 594 NSRect iconFrame([cell locationIconFrameForFrame:[field_ bounds]]); | 594 NSRect iconFrame([cell locationIconFrameForFrame:[field_ bounds]]); |
| 595 NSPoint location(NSMakePoint(NSMidX(iconFrame), NSMidY(iconFrame))); | 595 NSPoint location(NSMakePoint(NSMidX(iconFrame), NSMidY(iconFrame))); |
| 596 NSEvent* event(Event(field_, location, NSLeftMouseDown, 1)); | 596 NSEvent* event(Event(field_, location, NSLeftMouseDown, 1)); |
| 597 | 597 |
| 598 [field_ mouseDown:event]; | 598 [field_ mouseDown:event]; |
| 599 EXPECT_TRUE(location_icon_view.mouse_was_pressed_); | 599 EXPECT_TRUE(location_icon_view.mouse_was_pressed_); |
| 600 } | 600 } |
| 601 | 601 |
| 602 // Clicking a Page Action icon should call its OnMousePressed. | 602 // Clicking a Page Action icon should call its OnMousePressed. |
| 603 TEST_F(AutocompleteTextFieldObserverTest, PageActionMouseDown) { | 603 TEST_F(AutocompleteTextFieldTest, PageActionMouseDown) { |
| 604 AutocompleteTextFieldCell* cell = [field_ autocompleteTextFieldCell]; | 604 AutocompleteTextFieldCell* cell = [field_ autocompleteTextFieldCell]; |
| 605 | 605 |
| 606 MockLocationIconView location_icon_view(NULL); | 606 MockLocationIconView location_icon_view(NULL); |
| 607 location_icon_view.SetImage( | 607 location_icon_view.SetImage( |
| 608 ResourceBundle::GetSharedInstance().GetNSImageNamed(IDR_SECURE)); | 608 ResourceBundle::GetSharedInstance().GetNSImageNamed(IDR_SECURE)); |
| 609 [cell setLocationIconView:&location_icon_view]; | 609 [cell setLocationIconView:&location_icon_view]; |
| 610 | 610 |
| 611 MockPageActionImageView page_action_view; | 611 MockPageActionImageView page_action_view; |
| 612 NSImage* image = [NSImage imageNamed:@"NSApplicationIcon"]; | 612 NSImage* image = [NSImage imageNamed:@"NSApplicationIcon"]; |
| 613 page_action_view.SetImage(image); | 613 page_action_view.SetImage(image); |
| (...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 854 scoped_nsobject<AutocompleteTextField> pin([field_ retain]); | 854 scoped_nsobject<AutocompleteTextField> pin([field_ retain]); |
| 855 [field_ removeFromSuperview]; | 855 [field_ removeFromSuperview]; |
| 856 [test_window() resignKeyWindow]; | 856 [test_window() resignKeyWindow]; |
| 857 | 857 |
| 858 [[test_window() contentView] addSubview:field_]; | 858 [[test_window() contentView] addSubview:field_]; |
| 859 EXPECT_CALL(field_observer_, OnDidResignKey()); | 859 EXPECT_CALL(field_observer_, OnDidResignKey()); |
| 860 [test_window() resignKeyWindow]; | 860 [test_window() resignKeyWindow]; |
| 861 } | 861 } |
| 862 | 862 |
| 863 } // namespace | 863 } // namespace |
| OLD | NEW |