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

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

Issue 1560015: Replace omnibox icons with new set that are all the same size (19x19).... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 10 years, 8 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
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/autocomplete_text_field_cell.h" 9 #import "chrome/browser/cocoa/autocomplete_text_field_cell.h"
10 #import "chrome/browser/cocoa/cocoa_test_helper.h" 10 #import "chrome/browser/cocoa/cocoa_test_helper.h"
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after
198 [cell clearKeywordAndHint]; 198 [cell clearKeywordAndHint];
199 textFrame = [cell textFrameForFrame:bounds]; 199 textFrame = [cell textFrameForFrame:bounds];
200 EXPECT_FALSE(NSIsEmptyRect(textFrame)); 200 EXPECT_FALSE(NSIsEmptyRect(textFrame));
201 EXPECT_TRUE(NSContainsRect(bounds, textFrame)); 201 EXPECT_TRUE(NSContainsRect(bounds, textFrame));
202 EXPECT_EQ(NSMinX(bounds), NSMinX(textFrame)); 202 EXPECT_EQ(NSMinX(bounds), NSMinX(textFrame));
203 EXPECT_EQ(NSMaxX(bounds), NSMaxX(textFrame)); 203 EXPECT_EQ(NSMaxX(bounds), NSMaxX(textFrame));
204 EXPECT_TRUE(NSContainsRect(cursorFrame, textFrame)); 204 EXPECT_TRUE(NSContainsRect(cursorFrame, textFrame));
205 205
206 // Location icon takes up space on the left 206 // Location icon takes up space on the left
207 location_icon_view_.SetImage( 207 location_icon_view_.SetImage(
208 ResourceBundle::GetSharedInstance().GetNSImageNamed(IDR_SECURE)); 208 ResourceBundle::GetSharedInstance().GetNSImageNamed(
209 IDR_OMNIBOX_HTTPS_VALID));
209 location_icon_view_.SetVisible(true); 210 location_icon_view_.SetVisible(true);
210 211
211 textFrame = [cell textFrameForFrame:bounds]; 212 textFrame = [cell textFrameForFrame:bounds];
212 EXPECT_FALSE(NSIsEmptyRect(textFrame)); 213 EXPECT_FALSE(NSIsEmptyRect(textFrame));
213 EXPECT_TRUE(NSContainsRect(bounds, textFrame)); 214 EXPECT_TRUE(NSContainsRect(bounds, textFrame));
214 EXPECT_GT(NSMinX(textFrame), NSMinX(bounds)); 215 EXPECT_GT(NSMinX(textFrame), NSMinX(bounds));
215 EXPECT_TRUE(NSContainsRect(cursorFrame, textFrame)); 216 EXPECT_TRUE(NSContainsRect(cursorFrame, textFrame));
216 217
217 // Search hint text takes precedence over the hint icon; the text frame 218 // Search hint text takes precedence over the hint icon; the text frame
218 // should be smaller in order to accomodate the text that is wider than 219 // should be smaller in order to accomodate the text that is wider than
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
263 EXPECT_TRUE(NSContainsRect(NSInsetRect(textFrame, 1, 1), drawingRect)); 264 EXPECT_TRUE(NSContainsRect(NSInsetRect(textFrame, 1, 1), drawingRect));
264 265
265 [cell clearKeywordAndHint]; 266 [cell clearKeywordAndHint];
266 textFrame = [cell textFrameForFrame:bounds]; 267 textFrame = [cell textFrameForFrame:bounds];
267 drawingRect = [cell drawingRectForBounds:bounds]; 268 drawingRect = [cell drawingRectForBounds:bounds];
268 EXPECT_FALSE(NSIsEmptyRect(drawingRect)); 269 EXPECT_FALSE(NSIsEmptyRect(drawingRect));
269 EXPECT_TRUE(NSContainsRect(NSInsetRect(textFrame, 1, 1), drawingRect)); 270 EXPECT_TRUE(NSContainsRect(NSInsetRect(textFrame, 1, 1), drawingRect));
270 EXPECT_TRUE(NSEqualRects(drawingRect, originalDrawingRect)); 271 EXPECT_TRUE(NSEqualRects(drawingRect, originalDrawingRect));
271 272
272 location_icon_view_.SetImage( 273 location_icon_view_.SetImage(
273 ResourceBundle::GetSharedInstance().GetNSImageNamed(IDR_SECURE)); 274 ResourceBundle::GetSharedInstance().GetNSImageNamed(
275 IDR_OMNIBOX_HTTPS_VALID));
274 location_icon_view_.SetVisible(true); 276 location_icon_view_.SetVisible(true);
275 277
276 textFrame = [cell textFrameForFrame:bounds]; 278 textFrame = [cell textFrameForFrame:bounds];
277 drawingRect = [cell drawingRectForBounds:bounds]; 279 drawingRect = [cell drawingRectForBounds:bounds];
278 EXPECT_FALSE(NSIsEmptyRect(drawingRect)); 280 EXPECT_FALSE(NSIsEmptyRect(drawingRect));
279 EXPECT_TRUE(NSContainsRect(NSInsetRect(textFrame, 1, 1), drawingRect)); 281 EXPECT_TRUE(NSContainsRect(NSInsetRect(textFrame, 1, 1), drawingRect));
280 } 282 }
281 283
282 // Test that the location icon is at the right side of the cell. 284 // Test that the location icon is at the right side of the cell.
283 TEST_F(AutocompleteTextFieldCellTest, LocationIconFrame) { 285 TEST_F(AutocompleteTextFieldCellTest, LocationIconFrame) {
284 AutocompleteTextFieldCell* cell = 286 AutocompleteTextFieldCell* cell =
285 static_cast<AutocompleteTextFieldCell*>([view_ cell]); 287 static_cast<AutocompleteTextFieldCell*>([view_ cell]);
286 const NSRect bounds([view_ bounds]); 288 const NSRect bounds([view_ bounds]);
287 location_icon_view_.SetImage( 289 location_icon_view_.SetImage(
288 ResourceBundle::GetSharedInstance().GetNSImageNamed(IDR_SECURE)); 290 ResourceBundle::GetSharedInstance().GetNSImageNamed(
291 IDR_OMNIBOX_HTTPS_VALID));
289 292
290 location_icon_view_.SetVisible(true); 293 location_icon_view_.SetVisible(true);
291 const NSRect iconRect = [cell locationIconFrameForFrame:bounds]; 294 const NSRect iconRect = [cell locationIconFrameForFrame:bounds];
292 EXPECT_FALSE(NSIsEmptyRect(iconRect)); 295 EXPECT_FALSE(NSIsEmptyRect(iconRect));
293 EXPECT_TRUE(NSContainsRect(bounds, iconRect)); 296 EXPECT_TRUE(NSContainsRect(bounds, iconRect));
294 297
295 // Location icon should be left of |drawingRect|. 298 // Location icon should be left of |drawingRect|.
296 const NSRect drawingRect = [cell drawingRectForBounds:bounds]; 299 const NSRect drawingRect = [cell drawingRectForBounds:bounds];
297 EXPECT_GT(NSMinX(drawingRect), NSMinX(iconRect)); 300 EXPECT_GT(NSMinX(drawingRect), NSMinX(iconRect));
298 301
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after
512 EXPECT_TRUE([[[cell hintString] string] hasPrefix:kHintPrefix]); 515 EXPECT_TRUE([[[cell hintString] string] hasPrefix:kHintPrefix]);
513 EXPECT_TRUE([[[cell hintString] string] hasSuffix:kHintSuffix]); 516 EXPECT_TRUE([[[cell hintString] string] hasSuffix:kHintSuffix]);
514 517
515 // Narrow width suppresses everything but the image. 518 // Narrow width suppresses everything but the image.
516 [cell setKeywordHintPrefix:kHintPrefix image:image suffix:kHintSuffix 519 [cell setKeywordHintPrefix:kHintPrefix image:image suffix:kHintSuffix
517 availableWidth:kNarrowWidth]; 520 availableWidth:kNarrowWidth];
518 EXPECT_EQ([[cell hintString] length], 1U); 521 EXPECT_EQ([[cell hintString] length], 1U);
519 } 522 }
520 523
521 } // namespace 524 } // namespace
OLDNEW
« no previous file with comments | « chrome/browser/cocoa/autocomplete_text_field_cell.mm ('k') | chrome/browser/cocoa/autocomplete_text_field_unittest.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698