diff options
author | pkasting@chromium.org <pkasting@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-03-30 00:19:18 +0000 |
---|---|---|
committer | pkasting@chromium.org <pkasting@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-03-30 00:19:18 +0000 |
commit | 66ee443252fd759c5e20cb93be1e90a732da0ebe (patch) | |
tree | 5ee39c6ee0c62c8feba5103836a36d28203b7b54 /chrome/browser/cocoa/autocomplete_text_field_cell_unittest.mm | |
parent | cbadedd7a2cdc20a745ff8b51922b2533169f7b0 (diff) | |
download | chromium_src-66ee443252fd759c5e20cb93be1e90a732da0ebe.zip chromium_src-66ee443252fd759c5e20cb93be1e90a732da0ebe.tar.gz chromium_src-66ee443252fd759c5e20cb93be1e90a732da0ebe.tar.bz2 |
Show the location bar icon (almost) all the time, and have its contents match what the user is doing.
There are a couple major moving parts here:
* Change AutocompletePopupModel::URLsForCurrentText() to InfoForCurrentText() and have it return an AutocompleteMatch, which callers can use to parse out whatever they want. I needed to get at the match type for the current text and found the proliferation of arguments here ridiculous. This had major ripple effects throughout the codebase, including changing the name and location of SearchVersusNavigateClassifier as it no longer had an "is_search" parameter directly, so the name became misleading and too narrow. I also ended up adding a null constructor for AutocompleteMatch because it was too cumbersome otherwise.
* Change the name of the "SecurityImageView" (or similar) to reflect its broader purpose, and plumb it to the edit to get an icon instead of to the toolbar model.
* Add an AutocompleteMatch::Type to icon mapping function, and use it not only in the new code but also to simplify showing the popup contents.
BUG=27570,39725
TEST=An icon should appear next to the address at all times. It should be a globe on non-secure pages, a magnifying glass on the NTP, and a match for whatever the user is typing as he types.
Review URL: http://codereview.chromium.org/1457002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@43025 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/cocoa/autocomplete_text_field_cell_unittest.mm')
-rw-r--r-- | chrome/browser/cocoa/autocomplete_text_field_cell_unittest.mm | 45 |
1 files changed, 25 insertions, 20 deletions
diff --git a/chrome/browser/cocoa/autocomplete_text_field_cell_unittest.mm b/chrome/browser/cocoa/autocomplete_text_field_cell_unittest.mm index c400162..60418a0 100644 --- a/chrome/browser/cocoa/autocomplete_text_field_cell_unittest.mm +++ b/chrome/browser/cocoa/autocomplete_text_field_cell_unittest.mm @@ -4,6 +4,7 @@ #import <Cocoa/Cocoa.h> +#include "app/resource_bundle.h" #include "base/scoped_nsobject.h" #import "chrome/browser/cocoa/autocomplete_text_field_cell.h" #import "chrome/browser/cocoa/cocoa_test_helper.h" @@ -44,7 +45,7 @@ class TestPageActionViewList : public LocationBarViewMac::PageActionViewList { class AutocompleteTextFieldCellTest : public CocoaTest { public: - AutocompleteTextFieldCellTest() : security_image_view_(NULL, NULL, NULL), + AutocompleteTextFieldCellTest() : location_icon_view_(NULL), page_action_views_() { // Make sure this is wide enough to play games with the cell // decorations. @@ -58,7 +59,7 @@ class AutocompleteTextFieldCellTest : public CocoaTest { [[AutocompleteTextFieldCell alloc] initTextCell:@"Testing"]); [cell setEditable:YES]; [cell setBordered:YES]; - [cell setSecurityImageView:&security_image_view_]; + [cell setLocationIconView:&location_icon_view_]; [cell setPageActionViewList:&page_action_views_]; [view_ setCell:cell.get()]; @@ -66,7 +67,7 @@ class AutocompleteTextFieldCellTest : public CocoaTest { } NSTextField* view_; - LocationBarViewMac::SecurityImageView security_image_view_; + LocationBarViewMac::LocationIconView location_icon_view_; TestPageActionViewList page_action_views_; }; @@ -200,9 +201,10 @@ TEST_F(AutocompleteTextFieldCellTest, TextFrame) { EXPECT_EQ(NSMaxX(bounds), NSMaxX(textFrame)); EXPECT_TRUE(NSContainsRect(cursorFrame, textFrame)); - // Security icon takes up space on the right - security_image_view_.SetImageShown(IDR_SECURE); - security_image_view_.SetVisible(true); + // Location icon takes up space on the right + location_icon_view_.SetImage( + ResourceBundle::GetSharedInstance().GetNSImageNamed(IDR_SECURE)); + location_icon_view_.SetVisible(true); textFrame = [cell textFrameForFrame:bounds]; EXPECT_FALSE(NSIsEmptyRect(textFrame)); @@ -265,8 +267,9 @@ TEST_F(AutocompleteTextFieldCellTest, DrawingRectForBounds) { EXPECT_TRUE(NSContainsRect(NSInsetRect(textFrame, 1, 1), drawingRect)); EXPECT_TRUE(NSEqualRects(drawingRect, originalDrawingRect)); - security_image_view_.SetImageShown(IDR_SECURE); - security_image_view_.SetVisible(true); + location_icon_view_.SetImage( + ResourceBundle::GetSharedInstance().GetNSImageNamed(IDR_SECURE)); + location_icon_view_.SetVisible(true); textFrame = [cell textFrameForFrame:bounds]; drawingRect = [cell drawingRectForBounds:bounds]; @@ -274,17 +277,18 @@ TEST_F(AutocompleteTextFieldCellTest, DrawingRectForBounds) { EXPECT_TRUE(NSContainsRect(NSInsetRect(textFrame, 1, 1), drawingRect)); } -// Test that the security icon is at the right side of the cell. -TEST_F(AutocompleteTextFieldCellTest, SecurityImageFrame) { +// Test that the location icon is at the right side of the cell. +TEST_F(AutocompleteTextFieldCellTest, LocationIconFrame) { AutocompleteTextFieldCell* cell = static_cast<AutocompleteTextFieldCell*>([view_ cell]); const NSRect bounds([view_ bounds]); - security_image_view_.SetImageShown(IDR_SECURE); + location_icon_view_.SetImage( + ResourceBundle::GetSharedInstance().GetNSImageNamed(IDR_SECURE)); - security_image_view_.SetVisible(false); + location_icon_view_.SetVisible(false); EXPECT_EQ(0u, [[cell layedOutIcons:bounds] count]); - security_image_view_.SetVisible(true); + location_icon_view_.SetVisible(true); NSArray* icons = [cell layedOutIcons:bounds]; ASSERT_EQ(1u, [icons count]); NSRect iconRect = [[icons objectAtIndex:0] rect]; @@ -303,7 +307,7 @@ TEST_F(AutocompleteTextFieldCellTest, SecurityImageFrame) { // Now add a label. NSFont* font = [NSFont controlContentFontOfSize:12.0]; NSColor* color = [NSColor blackColor]; - security_image_view_.SetLabel(@"Label", font, color); + location_icon_view_.SetLabel(@"Label", font, color); icons = [cell layedOutIcons:bounds]; ASSERT_EQ(1u, [icons count]); iconRect = [[icons objectAtIndex:0] rect]; @@ -320,7 +324,7 @@ TEST_F(AutocompleteTextFieldCellTest, SecurityImageFrame) { EXPECT_LE(NSMaxX(textFrame), NSMinX(iconRect)); // Make sure we clear correctly. - security_image_view_.SetVisible(false); + location_icon_view_.SetVisible(false); EXPECT_EQ(0u, [[cell layedOutIcons:bounds] count]); } @@ -347,7 +351,8 @@ TEST_F(AutocompleteTextFieldCellTest, PageActionImageFrame) { AutocompleteTextFieldCell* cell = static_cast<AutocompleteTextFieldCell*>([view_ cell]); const NSRect bounds([view_ bounds]); - security_image_view_.SetImageShown(IDR_SECURE); + location_icon_view_.SetImage( + ResourceBundle::GetSharedInstance().GetNSImageNamed(IDR_SECURE)); TestPageActionImageView page_action_view; // We'll assume that the extensions code enforces icons smaller than the @@ -365,13 +370,13 @@ TEST_F(AutocompleteTextFieldCellTest, PageActionImageFrame) { list.Add(&page_action_view2); [cell setPageActionViewList:&list]; - security_image_view_.SetVisible(false); + location_icon_view_.SetVisible(false); page_action_view.SetVisible(false); page_action_view2.SetVisible(false); EXPECT_TRUE(NSIsEmptyRect([cell pageActionFrameForIndex:0 inFrame:bounds])); EXPECT_TRUE(NSIsEmptyRect([cell pageActionFrameForIndex:1 inFrame:bounds])); - // One page action, no security icon. + // One page action, no lock icon. page_action_view.SetVisible(true); NSRect iconRect0 = [cell pageActionFrameForIndex:0 inFrame:bounds]; @@ -386,9 +391,9 @@ TEST_F(AutocompleteTextFieldCellTest, PageActionImageFrame) { NSRect textFrame = [cell textFrameForFrame:bounds]; EXPECT_LE(NSMaxX(textFrame), NSMinX(iconRect0)); - // Two page actions plus a security icon. + // Two page actions plus a lock icon. page_action_view2.SetVisible(true); - security_image_view_.SetVisible(true); + location_icon_view_.SetVisible(true); NSArray* icons = [cell layedOutIcons:bounds]; EXPECT_EQ(3u, [icons count]); iconRect0 = [cell pageActionFrameForIndex:0 inFrame:bounds]; |