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 570 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
581 EXPECT_EQ(selectedRange.length, [[field_ stringValue] length]); | 581 EXPECT_EQ(selectedRange.length, [[field_ stringValue] length]); |
582 } | 582 } |
583 | 583 |
584 // Clicking the security icon should call its OnMousePressed. | 584 // Clicking the security icon should call its OnMousePressed. |
585 TEST_F(AutocompleteTextFieldTest, 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( |
| 592 IDR_OMNIBOX_HTTPS_VALID)); |
592 location_icon_view.SetVisible(true); | 593 location_icon_view.SetVisible(true); |
593 | 594 |
594 NSRect iconFrame([cell locationIconFrameForFrame:[field_ bounds]]); | 595 NSRect iconFrame([cell locationIconFrameForFrame:[field_ bounds]]); |
595 NSPoint location(NSMakePoint(NSMidX(iconFrame), NSMidY(iconFrame))); | 596 NSPoint location(NSMakePoint(NSMidX(iconFrame), NSMidY(iconFrame))); |
596 NSEvent* event(Event(field_, location, NSLeftMouseDown, 1)); | 597 NSEvent* event(Event(field_, location, NSLeftMouseDown, 1)); |
597 | 598 |
598 [field_ mouseDown:event]; | 599 [field_ mouseDown:event]; |
599 EXPECT_TRUE(location_icon_view.mouse_was_pressed_); | 600 EXPECT_TRUE(location_icon_view.mouse_was_pressed_); |
600 } | 601 } |
601 | 602 |
602 // Clicking a Page Action icon should call its OnMousePressed. | 603 // Clicking a Page Action icon should call its OnMousePressed. |
603 TEST_F(AutocompleteTextFieldTest, PageActionMouseDown) { | 604 TEST_F(AutocompleteTextFieldTest, PageActionMouseDown) { |
604 AutocompleteTextFieldCell* cell = [field_ autocompleteTextFieldCell]; | 605 AutocompleteTextFieldCell* cell = [field_ autocompleteTextFieldCell]; |
605 | 606 |
606 MockLocationIconView location_icon_view(NULL); | 607 MockLocationIconView location_icon_view(NULL); |
607 location_icon_view.SetImage( | 608 location_icon_view.SetImage( |
608 ResourceBundle::GetSharedInstance().GetNSImageNamed(IDR_SECURE)); | 609 ResourceBundle::GetSharedInstance().GetNSImageNamed( |
| 610 IDR_OMNIBOX_HTTPS_VALID)); |
609 [cell setLocationIconView:&location_icon_view]; | 611 [cell setLocationIconView:&location_icon_view]; |
610 | 612 |
611 MockPageActionImageView page_action_view; | 613 MockPageActionImageView page_action_view; |
612 NSImage* image = [NSImage imageNamed:@"NSApplicationIcon"]; | 614 NSImage* image = [NSImage imageNamed:@"NSApplicationIcon"]; |
613 page_action_view.SetImage(image); | 615 page_action_view.SetImage(image); |
614 | 616 |
615 MockPageActionImageView page_action_view2; | 617 MockPageActionImageView page_action_view2; |
616 page_action_view2.SetImage(image); | 618 page_action_view2.SetImage(image); |
617 | 619 |
618 TestPageActionViewList list; | 620 TestPageActionViewList list; |
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
854 scoped_nsobject<AutocompleteTextField> pin([field_ retain]); | 856 scoped_nsobject<AutocompleteTextField> pin([field_ retain]); |
855 [field_ removeFromSuperview]; | 857 [field_ removeFromSuperview]; |
856 [test_window() resignKeyWindow]; | 858 [test_window() resignKeyWindow]; |
857 | 859 |
858 [[test_window() contentView] addSubview:field_]; | 860 [[test_window() contentView] addSubview:field_]; |
859 EXPECT_CALL(field_observer_, OnDidResignKey()); | 861 EXPECT_CALL(field_observer_, OnDidResignKey()); |
860 [test_window() resignKeyWindow]; | 862 [test_window() resignKeyWindow]; |
861 } | 863 } |
862 | 864 |
863 } // namespace | 865 } // namespace |
OLD | NEW |