| 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/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" |
| 11 #import "chrome/browser/cocoa/autocomplete_text_field_editor.h" | 11 #import "chrome/browser/cocoa/autocomplete_text_field_editor.h" |
| 12 #import "chrome/browser/cocoa/autocomplete_text_field_unittest_helper.h" | 12 #import "chrome/browser/cocoa/autocomplete_text_field_unittest_helper.h" |
| 13 #import "chrome/browser/cocoa/cocoa_test_helper.h" | 13 #import "chrome/browser/cocoa/cocoa_test_helper.h" |
| 14 #include "grit/theme_resources.h" |
| 14 #include "testing/gmock/include/gmock/gmock.h" | 15 #include "testing/gmock/include/gmock/gmock.h" |
| 15 #include "testing/gtest/include/gtest/gtest.h" | 16 #include "testing/gtest/include/gtest/gtest.h" |
| 16 #include "testing/platform_test.h" | 17 #include "testing/platform_test.h" |
| 17 | 18 |
| 18 using ::testing::InSequence; | 19 using ::testing::InSequence; |
| 19 using ::testing::Return; | 20 using ::testing::Return; |
| 20 using ::testing::StrictMock; | 21 using ::testing::StrictMock; |
| 21 | 22 |
| 22 namespace { | 23 namespace { |
| 23 class MockSecurityImageView : public LocationBarViewMac::SecurityImageView { | 24 class MockSecurityImageView : public LocationBarViewMac::SecurityImageView { |
| (...skipping 550 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 574 EXPECT_EQ(selectedRange.location, 0U); | 575 EXPECT_EQ(selectedRange.location, 0U); |
| 575 EXPECT_EQ(selectedRange.length, [[field_ stringValue] length]); | 576 EXPECT_EQ(selectedRange.length, [[field_ stringValue] length]); |
| 576 } | 577 } |
| 577 | 578 |
| 578 // Clicking the security icon should call its OnMousePressed. | 579 // Clicking the security icon should call its OnMousePressed. |
| 579 TEST_F(AutocompleteTextFieldObserverTest, SecurityIconMouseDown) { | 580 TEST_F(AutocompleteTextFieldObserverTest, SecurityIconMouseDown) { |
| 580 AutocompleteTextFieldCell* cell = [field_ autocompleteTextFieldCell]; | 581 AutocompleteTextFieldCell* cell = [field_ autocompleteTextFieldCell]; |
| 581 | 582 |
| 582 MockSecurityImageView security_image_view(NULL, NULL, NULL); | 583 MockSecurityImageView security_image_view(NULL, NULL, NULL); |
| 583 [cell setSecurityImageView:&security_image_view]; | 584 [cell setSecurityImageView:&security_image_view]; |
| 584 security_image_view.SetImageShown( | 585 security_image_view.SetImageShown(IDR_SECURE); |
| 585 LocationBarViewMac::SecurityImageView::LOCK); | |
| 586 security_image_view.SetVisible(true); | 586 security_image_view.SetVisible(true); |
| 587 | 587 |
| 588 NSRect iconFrame([cell securityImageFrameForFrame:[field_ bounds]]); | 588 NSRect iconFrame([cell securityImageFrameForFrame:[field_ bounds]]); |
| 589 NSPoint location(NSMakePoint(NSMidX(iconFrame), NSMidY(iconFrame))); | 589 NSPoint location(NSMakePoint(NSMidX(iconFrame), NSMidY(iconFrame))); |
| 590 NSEvent* event(Event(field_, location, NSLeftMouseDown, 1)); | 590 NSEvent* event(Event(field_, location, NSLeftMouseDown, 1)); |
| 591 | 591 |
| 592 [field_ mouseDown:event]; | 592 [field_ mouseDown:event]; |
| 593 EXPECT_TRUE(security_image_view.mouse_was_pressed_); | 593 EXPECT_TRUE(security_image_view.mouse_was_pressed_); |
| 594 } | 594 } |
| 595 | 595 |
| 596 // Clicking a Page Action icon should call its OnMousePressed. | 596 // Clicking a Page Action icon should call its OnMousePressed. |
| 597 TEST_F(AutocompleteTextFieldObserverTest, PageActionMouseDown) { | 597 TEST_F(AutocompleteTextFieldObserverTest, PageActionMouseDown) { |
| 598 AutocompleteTextFieldCell* cell = [field_ autocompleteTextFieldCell]; | 598 AutocompleteTextFieldCell* cell = [field_ autocompleteTextFieldCell]; |
| 599 | 599 |
| 600 MockSecurityImageView security_image_view(NULL, NULL, NULL); | 600 MockSecurityImageView security_image_view(NULL, NULL, NULL); |
| 601 security_image_view.SetImageShown( | 601 security_image_view.SetImageShown(IDR_SECURE); |
| 602 LocationBarViewMac::SecurityImageView::LOCK); | |
| 603 [cell setSecurityImageView:&security_image_view]; | 602 [cell setSecurityImageView:&security_image_view]; |
| 604 | 603 |
| 605 MockPageActionImageView page_action_view; | 604 MockPageActionImageView page_action_view; |
| 606 NSImage* image = [NSImage imageNamed:@"NSApplicationIcon"]; | 605 NSImage* image = [NSImage imageNamed:@"NSApplicationIcon"]; |
| 607 page_action_view.SetImage(image); | 606 page_action_view.SetImage(image); |
| 608 | 607 |
| 609 MockPageActionImageView page_action_view2; | 608 MockPageActionImageView page_action_view2; |
| 610 page_action_view2.SetImage(image); | 609 page_action_view2.SetImage(image); |
| 611 | 610 |
| 612 TestPageActionViewList list; | 611 TestPageActionViewList list; |
| (...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 799 scoped_nsobject<AutocompleteTextField> pin([field_ retain]); | 798 scoped_nsobject<AutocompleteTextField> pin([field_ retain]); |
| 800 [field_ removeFromSuperview]; | 799 [field_ removeFromSuperview]; |
| 801 [test_window() resignKeyWindow]; | 800 [test_window() resignKeyWindow]; |
| 802 | 801 |
| 803 [[test_window() contentView] addSubview:field_]; | 802 [[test_window() contentView] addSubview:field_]; |
| 804 EXPECT_CALL(field_observer_, OnDidResignKey()); | 803 EXPECT_CALL(field_observer_, OnDidResignKey()); |
| 805 [test_window() resignKeyWindow]; | 804 [test_window() resignKeyWindow]; |
| 806 } | 805 } |
| 807 | 806 |
| 808 } // namespace | 807 } // namespace |
| OLD | NEW |