Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(857)

Side by Side Diff: chrome/browser/cocoa/location_bar/autocomplete_text_field_cell_unittest.mm

Issue 3037005: Merge 52385 - [Mac] Bring back the omnibox globe for an encore.... (Closed) Base URL: svn://svn.chromium.org/chrome/branches/466/src/
Patch Set: Created 10 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | chrome/browser/cocoa/location_bar/location_icon_decoration.mm » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #include "base/scoped_nsobject.h" 8 #include "base/scoped_nsobject.h"
9 #import "chrome/browser/cocoa/cocoa_test_helper.h" 9 #import "chrome/browser/cocoa/cocoa_test_helper.h"
10 #import "chrome/browser/cocoa/location_bar/autocomplete_text_field_cell.h" 10 #import "chrome/browser/cocoa/location_bar/autocomplete_text_field_cell.h"
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 static_cast<AutocompleteTextFieldCell*>([view_ cell]); 110 static_cast<AutocompleteTextFieldCell*>([view_ cell]);
111 111
112 [cell setSearchHintString:@"Type to search" availableWidth:kWidth]; 112 [cell setSearchHintString:@"Type to search" availableWidth:kWidth];
113 [view_ display]; 113 [view_ display];
114 114
115 NSImage* image = [NSImage imageNamed:@"NSApplicationIcon"]; 115 NSImage* image = [NSImage imageNamed:@"NSApplicationIcon"];
116 [cell setKeywordHintPrefix:@"prefix" image:image suffix:@"suffix" 116 [cell setKeywordHintPrefix:@"prefix" image:image suffix:@"suffix"
117 availableWidth:kWidth]; 117 availableWidth:kWidth];
118 [view_ display]; 118 [view_ display];
119 119
120 // Load available decorations and try drawing. 120 // Load available decorations and try drawing. To make sure that
121 // they are actually drawn, check that |GetWidthForSpace()| doesn't
122 // indicate that they should be omitted.
123 const CGFloat kVeryWide = 1000.0;
124
121 SelectedKeywordDecoration selected_keyword_decoration([view_ font]); 125 SelectedKeywordDecoration selected_keyword_decoration([view_ font]);
122 selected_keyword_decoration.SetVisible(true); 126 selected_keyword_decoration.SetVisible(true);
123 selected_keyword_decoration.SetKeyword(std::wstring(L"Google"), false); 127 selected_keyword_decoration.SetKeyword(std::wstring(L"Google"), false);
124 [cell addLeftDecoration:&selected_keyword_decoration]; 128 [cell addLeftDecoration:&selected_keyword_decoration];
129 EXPECT_NE(selected_keyword_decoration.GetWidthForSpace(kVeryWide),
130 LocationBarDecoration::kOmittedWidth);
125 131
126 // TODO(shess): This really wants a |LocationBarViewMac|, but only a 132 // TODO(shess): This really wants a |LocationBarViewMac|, but only a
127 // few methods reference it, so this works well enough. But 133 // few methods reference it, so this works well enough. But
128 // something better would be nice. 134 // something better would be nice.
129 LocationIconDecoration location_icon_decoration(NULL); 135 LocationIconDecoration location_icon_decoration(NULL);
130 location_icon_decoration.SetVisible(true); 136 location_icon_decoration.SetVisible(true);
131 location_icon_decoration.SetImage([NSImage imageNamed:@"NSApplicationIcon"]); 137 location_icon_decoration.SetImage([NSImage imageNamed:@"NSApplicationIcon"]);
132 [cell addLeftDecoration:&location_icon_decoration]; 138 [cell addLeftDecoration:&location_icon_decoration];
139 EXPECT_NE(location_icon_decoration.GetWidthForSpace(kVeryWide),
140 LocationBarDecoration::kOmittedWidth);
133 141
134 EVBubbleDecoration ev_bubble_decoration(&location_icon_decoration, 142 EVBubbleDecoration ev_bubble_decoration(&location_icon_decoration,
135 [view_ font]); 143 [view_ font]);
136 ev_bubble_decoration.SetVisible(true); 144 ev_bubble_decoration.SetVisible(true);
137 ev_bubble_decoration.SetImage([NSImage imageNamed:@"NSApplicationIcon"]); 145 ev_bubble_decoration.SetImage([NSImage imageNamed:@"NSApplicationIcon"]);
138 ev_bubble_decoration.SetLabel(@"Application"); 146 ev_bubble_decoration.SetLabel(@"Application");
139 [cell addLeftDecoration:&ev_bubble_decoration]; 147 [cell addLeftDecoration:&ev_bubble_decoration];
148 EXPECT_NE(ev_bubble_decoration.GetWidthForSpace(kVeryWide),
149 LocationBarDecoration::kOmittedWidth);
140 150
141 // Make sure we're actually calling |DrawInFrame()|. 151 // Make sure we're actually calling |DrawInFrame()|.
142 StrictMock<MockDecoration> mock_decoration; 152 StrictMock<MockDecoration> mock_decoration;
143 mock_decoration.SetVisible(true); 153 mock_decoration.SetVisible(true);
144 [cell addLeftDecoration:&mock_decoration]; 154 [cell addLeftDecoration:&mock_decoration];
145 EXPECT_CALL(mock_decoration, DrawInFrame(_, _)); 155 EXPECT_CALL(mock_decoration, DrawInFrame(_, _));
156 EXPECT_NE(mock_decoration.GetWidthForSpace(kVeryWide),
157 LocationBarDecoration::kOmittedWidth);
146 158
147 [view_ display]; 159 [view_ display];
148 160
149 [cell clearDecorations]; 161 [cell clearDecorations];
150 } 162 }
151 163
152 TEST_F(AutocompleteTextFieldCellTest, ClearKeywordAndHint) { 164 TEST_F(AutocompleteTextFieldCellTest, ClearKeywordAndHint) {
153 AutocompleteTextFieldCell* cell = 165 AutocompleteTextFieldCell* cell =
154 static_cast<AutocompleteTextFieldCell*>([view_ cell]); 166 static_cast<AutocompleteTextFieldCell*>([view_ cell]);
155 EXPECT_FALSE([cell hintString]); 167 EXPECT_FALSE([cell hintString]);
(...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after
431 EXPECT_TRUE([[[cell hintString] string] hasPrefix:kHintPrefix]); 443 EXPECT_TRUE([[[cell hintString] string] hasPrefix:kHintPrefix]);
432 EXPECT_TRUE([[[cell hintString] string] hasSuffix:kHintSuffix]); 444 EXPECT_TRUE([[[cell hintString] string] hasSuffix:kHintSuffix]);
433 445
434 // Narrow width suppresses everything but the image. 446 // Narrow width suppresses everything but the image.
435 [cell setKeywordHintPrefix:kHintPrefix image:image suffix:kHintSuffix 447 [cell setKeywordHintPrefix:kHintPrefix image:image suffix:kHintSuffix
436 availableWidth:kNarrowWidth]; 448 availableWidth:kNarrowWidth];
437 EXPECT_EQ([[cell hintString] length], 1U); 449 EXPECT_EQ([[cell hintString] length], 1U);
438 } 450 }
439 451
440 } // namespace 452 } // namespace
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/cocoa/location_bar/location_icon_decoration.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698