| 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 #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 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 53 | 53 |
| 54 scoped_nsobject<NSTextField> view( | 54 scoped_nsobject<NSTextField> view( |
| 55 [[NSTextField alloc] initWithFrame:frame]); | 55 [[NSTextField alloc] initWithFrame:frame]); |
| 56 view_ = view.get(); | 56 view_ = view.get(); |
| 57 | 57 |
| 58 scoped_nsobject<AutocompleteTextFieldCell> cell( | 58 scoped_nsobject<AutocompleteTextFieldCell> cell( |
| 59 [[AutocompleteTextFieldCell alloc] initTextCell:@"Testing"]); | 59 [[AutocompleteTextFieldCell alloc] initTextCell:@"Testing"]); |
| 60 [cell setEditable:YES]; | 60 [cell setEditable:YES]; |
| 61 [cell setBordered:YES]; | 61 [cell setBordered:YES]; |
| 62 [cell setLocationIconView:&location_icon_view_]; | 62 [cell setLocationIconView:&location_icon_view_]; |
| 63 [cell setSecurityLabelView:&security_label_view_]; |
| 63 [cell setPageActionViewList:&page_action_views_]; | 64 [cell setPageActionViewList:&page_action_views_]; |
| 64 [view_ setCell:cell.get()]; | 65 [view_ setCell:cell.get()]; |
| 65 | 66 |
| 66 [[test_window() contentView] addSubview:view_]; | 67 [[test_window() contentView] addSubview:view_]; |
| 67 } | 68 } |
| 68 | 69 |
| 69 NSTextField* view_; | 70 NSTextField* view_; |
| 70 LocationBarViewMac::LocationIconView location_icon_view_; | 71 LocationBarViewMac::LocationIconView location_icon_view_; |
| 72 LocationBarViewMac::LocationBarImageView security_label_view_; |
| 71 TestPageActionViewList page_action_views_; | 73 TestPageActionViewList page_action_views_; |
| 72 }; | 74 }; |
| 73 | 75 |
| 74 // Basic view tests (AddRemove, Display). | 76 // Basic view tests (AddRemove, Display). |
| 75 TEST_VIEW(AutocompleteTextFieldCellTest, view_); | 77 TEST_VIEW(AutocompleteTextFieldCellTest, view_); |
| 76 | 78 |
| 77 // Test drawing, mostly to ensure nothing leaks or crashes. | 79 // Test drawing, mostly to ensure nothing leaks or crashes. |
| 78 TEST_F(AutocompleteTextFieldCellTest, FocusedDisplay) { | 80 TEST_F(AutocompleteTextFieldCellTest, FocusedDisplay) { |
| 79 [view_ display]; | 81 [view_ display]; |
| 80 | 82 |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 194 | 196 |
| 195 // Text frame should take everything over again on reset. | 197 // Text frame should take everything over again on reset. |
| 196 [cell clearKeywordAndHint]; | 198 [cell clearKeywordAndHint]; |
| 197 textFrame = [cell textFrameForFrame:bounds]; | 199 textFrame = [cell textFrameForFrame:bounds]; |
| 198 EXPECT_FALSE(NSIsEmptyRect(textFrame)); | 200 EXPECT_FALSE(NSIsEmptyRect(textFrame)); |
| 199 EXPECT_TRUE(NSContainsRect(bounds, textFrame)); | 201 EXPECT_TRUE(NSContainsRect(bounds, textFrame)); |
| 200 EXPECT_EQ(NSMinX(bounds), NSMinX(textFrame)); | 202 EXPECT_EQ(NSMinX(bounds), NSMinX(textFrame)); |
| 201 EXPECT_EQ(NSMaxX(bounds), NSMaxX(textFrame)); | 203 EXPECT_EQ(NSMaxX(bounds), NSMaxX(textFrame)); |
| 202 EXPECT_TRUE(NSContainsRect(cursorFrame, textFrame)); | 204 EXPECT_TRUE(NSContainsRect(cursorFrame, textFrame)); |
| 203 | 205 |
| 204 // Location icon takes up space on the right | 206 // Location icon takes up space on the left |
| 205 location_icon_view_.SetImage( | 207 location_icon_view_.SetImage( |
| 206 ResourceBundle::GetSharedInstance().GetNSImageNamed(IDR_SECURE)); | 208 ResourceBundle::GetSharedInstance().GetNSImageNamed(IDR_SECURE)); |
| 207 location_icon_view_.SetVisible(true); | 209 location_icon_view_.SetVisible(true); |
| 208 | 210 |
| 209 textFrame = [cell textFrameForFrame:bounds]; | 211 textFrame = [cell textFrameForFrame:bounds]; |
| 210 EXPECT_FALSE(NSIsEmptyRect(textFrame)); | 212 EXPECT_FALSE(NSIsEmptyRect(textFrame)); |
| 211 EXPECT_TRUE(NSContainsRect(bounds, textFrame)); | 213 EXPECT_TRUE(NSContainsRect(bounds, textFrame)); |
| 212 EXPECT_LT(NSMaxX(textFrame), NSMaxX(bounds)); | 214 EXPECT_GT(NSMinX(textFrame), NSMinX(bounds)); |
| 213 EXPECT_TRUE(NSContainsRect(cursorFrame, textFrame)); | 215 EXPECT_TRUE(NSContainsRect(cursorFrame, textFrame)); |
| 214 | 216 |
| 215 // Search hint text takes precedence over the hint icon; the text frame | 217 // Search hint text takes precedence over the hint icon; the text frame |
| 216 // should be smaller in order to accomodate the text that is wider than | 218 // should be smaller in order to accomodate the text that is wider than |
| 217 // the icon. | 219 // the icon. |
| 218 [cell setSearchHintString:@"Search hint" availableWidth:kWidth]; | 220 [cell setSearchHintString:@"Search hint" availableWidth:kWidth]; |
| 219 NSRect textFrameWithHintText = [cell textFrameForFrame:bounds]; | 221 NSRect textFrameWithHintText = [cell textFrameForFrame:bounds]; |
| 220 EXPECT_TRUE(NSContainsRect(textFrame, textFrameWithHintText)); | 222 EXPECT_TRUE(NSContainsRect(textFrame, textFrameWithHintText)); |
| 221 EXPECT_LT(NSWidth(textFrameWithHintText), NSWidth(textFrame)); | 223 EXPECT_LT(NSWidth(textFrameWithHintText), NSWidth(textFrame)); |
| 222 } | 224 } |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 278 } | 280 } |
| 279 | 281 |
| 280 // Test that the location icon is at the right side of the cell. | 282 // Test that the location icon is at the right side of the cell. |
| 281 TEST_F(AutocompleteTextFieldCellTest, LocationIconFrame) { | 283 TEST_F(AutocompleteTextFieldCellTest, LocationIconFrame) { |
| 282 AutocompleteTextFieldCell* cell = | 284 AutocompleteTextFieldCell* cell = |
| 283 static_cast<AutocompleteTextFieldCell*>([view_ cell]); | 285 static_cast<AutocompleteTextFieldCell*>([view_ cell]); |
| 284 const NSRect bounds([view_ bounds]); | 286 const NSRect bounds([view_ bounds]); |
| 285 location_icon_view_.SetImage( | 287 location_icon_view_.SetImage( |
| 286 ResourceBundle::GetSharedInstance().GetNSImageNamed(IDR_SECURE)); | 288 ResourceBundle::GetSharedInstance().GetNSImageNamed(IDR_SECURE)); |
| 287 | 289 |
| 288 location_icon_view_.SetVisible(false); | 290 location_icon_view_.SetVisible(true); |
| 291 const NSRect iconRect = [cell locationIconFrameForFrame:bounds]; |
| 292 EXPECT_FALSE(NSIsEmptyRect(iconRect)); |
| 293 EXPECT_TRUE(NSContainsRect(bounds, iconRect)); |
| 294 |
| 295 // Location icon should be left of |drawingRect|. |
| 296 const NSRect drawingRect = [cell drawingRectForBounds:bounds]; |
| 297 EXPECT_GT(NSMinX(drawingRect), NSMinX(iconRect)); |
| 298 |
| 299 // Location icon should be left of |textFrame|. |
| 300 const NSRect textFrame = [cell textFrameForFrame:bounds]; |
| 301 EXPECT_GT(NSMinX(textFrame), NSMinX(iconRect)); |
| 302 } |
| 303 |
| 304 // Test that security label floats to right. |
| 305 TEST_F(AutocompleteTextFieldCellTest, SecurityLabelFrame) { |
| 306 AutocompleteTextFieldCell* cell = |
| 307 static_cast<AutocompleteTextFieldCell*>([view_ cell]); |
| 308 const NSRect bounds([view_ bounds]); |
| 309 |
| 310 // No label shows nothing, regardless of visibility setting. |
| 311 security_label_view_.SetVisible(false); |
| 312 EXPECT_EQ(0u, [[cell layedOutIcons:bounds] count]); |
| 313 security_label_view_.SetVisible(true); |
| 289 EXPECT_EQ(0u, [[cell layedOutIcons:bounds] count]); | 314 EXPECT_EQ(0u, [[cell layedOutIcons:bounds] count]); |
| 290 | 315 |
| 291 location_icon_view_.SetVisible(true); | 316 NSFont* font = [NSFont controlContentFontOfSize:12.0]; |
| 317 NSColor* color = [NSColor blackColor]; |
| 318 security_label_view_.SetLabel(@"Label", font, color); |
| 292 NSArray* icons = [cell layedOutIcons:bounds]; | 319 NSArray* icons = [cell layedOutIcons:bounds]; |
| 293 ASSERT_EQ(1u, [icons count]); | 320 ASSERT_EQ(1u, [icons count]); |
| 294 NSRect iconRect = [[icons objectAtIndex:0] rect]; | 321 const NSRect iconRect = [[icons objectAtIndex:0] rect]; |
| 295 | 322 |
| 296 EXPECT_FALSE(NSIsEmptyRect(iconRect)); | 323 EXPECT_FALSE(NSIsEmptyRect(iconRect)); |
| 297 EXPECT_TRUE(NSContainsRect(bounds, iconRect)); | 324 EXPECT_TRUE(NSContainsRect(bounds, iconRect)); |
| 298 | 325 |
| 299 // Make sure we are right of the |drawingRect|. | 326 // Make sure we are right of the |drawingRect|. |
| 300 NSRect drawingRect = [cell drawingRectForBounds:bounds]; | 327 const NSRect drawingRect = [cell drawingRectForBounds:bounds]; |
| 301 EXPECT_LE(NSMaxX(drawingRect), NSMinX(iconRect)); | 328 EXPECT_LE(NSMaxX(drawingRect), NSMinX(iconRect)); |
| 302 | 329 |
| 303 // Make sure we're right of the |textFrame|. | 330 // Make sure we're right of the |textFrame|. |
| 304 NSRect textFrame = [cell textFrameForFrame:bounds]; | 331 const NSRect textFrame = [cell textFrameForFrame:bounds]; |
| 305 EXPECT_LE(NSMaxX(textFrame), NSMinX(iconRect)); | 332 EXPECT_LE(NSMaxX(textFrame), NSMinX(iconRect)); |
| 306 | 333 |
| 307 // Now add a label. | 334 // Can be marked not visible even with a label. |
| 308 NSFont* font = [NSFont controlContentFontOfSize:12.0]; | 335 security_label_view_.SetVisible(false); |
| 309 NSColor* color = [NSColor blackColor]; | |
| 310 location_icon_view_.SetLabel(@"Label", font, color); | |
| 311 icons = [cell layedOutIcons:bounds]; | |
| 312 ASSERT_EQ(1u, [icons count]); | |
| 313 iconRect = [[icons objectAtIndex:0] rect]; | |
| 314 | |
| 315 EXPECT_FALSE(NSIsEmptyRect(iconRect)); | |
| 316 EXPECT_TRUE(NSContainsRect(bounds, iconRect)); | |
| 317 | |
| 318 // Make sure we are right of the |drawingRect|. | |
| 319 drawingRect = [cell drawingRectForBounds:bounds]; | |
| 320 EXPECT_LE(NSMaxX(drawingRect), NSMinX(iconRect)); | |
| 321 | |
| 322 // Make sure we're right of the |textFrame|. | |
| 323 textFrame = [cell textFrameForFrame:bounds]; | |
| 324 EXPECT_LE(NSMaxX(textFrame), NSMinX(iconRect)); | |
| 325 | |
| 326 // Make sure we clear correctly. | |
| 327 location_icon_view_.SetVisible(false); | |
| 328 EXPECT_EQ(0u, [[cell layedOutIcons:bounds] count]); | 336 EXPECT_EQ(0u, [[cell layedOutIcons:bounds] count]); |
| 329 } | 337 } |
| 330 | 338 |
| 331 // Test Page Action counts. | 339 // Test Page Action counts. |
| 332 TEST_F(AutocompleteTextFieldCellTest, PageActionCount) { | 340 TEST_F(AutocompleteTextFieldCellTest, PageActionCount) { |
| 333 AutocompleteTextFieldCell* cell = | 341 AutocompleteTextFieldCell* cell = |
| 334 static_cast<AutocompleteTextFieldCell*>([view_ cell]); | 342 static_cast<AutocompleteTextFieldCell*>([view_ cell]); |
| 335 | 343 |
| 336 TestPageActionImageView page_action_view; | 344 TestPageActionImageView page_action_view; |
| 337 TestPageActionImageView page_action_view2; | 345 TestPageActionImageView page_action_view2; |
| 338 | 346 |
| 339 TestPageActionViewList list; | 347 TestPageActionViewList list; |
| 340 [cell setPageActionViewList:&list]; | 348 [cell setPageActionViewList:&list]; |
| 341 | 349 |
| 342 EXPECT_EQ(0u, [cell pageActionCount]); | 350 EXPECT_EQ(0u, [cell pageActionCount]); |
| 343 list.Add(&page_action_view); | 351 list.Add(&page_action_view); |
| 344 EXPECT_EQ(1u, [cell pageActionCount]); | 352 EXPECT_EQ(1u, [cell pageActionCount]); |
| 345 list.Add(&page_action_view2); | 353 list.Add(&page_action_view2); |
| 346 EXPECT_EQ(2u, [cell pageActionCount]); | 354 EXPECT_EQ(2u, [cell pageActionCount]); |
| 347 } | 355 } |
| 348 | 356 |
| 349 // Test that Page Action icons are properly placed. | 357 // Test that Page Action icons are properly placed. |
| 350 TEST_F(AutocompleteTextFieldCellTest, PageActionImageFrame) { | 358 TEST_F(AutocompleteTextFieldCellTest, PageActionImageFrame) { |
| 351 AutocompleteTextFieldCell* cell = | 359 AutocompleteTextFieldCell* cell = |
| 352 static_cast<AutocompleteTextFieldCell*>([view_ cell]); | 360 static_cast<AutocompleteTextFieldCell*>([view_ cell]); |
| 353 const NSRect bounds([view_ bounds]); | 361 const NSRect bounds([view_ bounds]); |
| 354 location_icon_view_.SetImage( | 362 |
| 355 ResourceBundle::GetSharedInstance().GetNSImageNamed(IDR_SECURE)); | 363 NSFont* font = [NSFont controlContentFontOfSize:12.0]; |
| 364 NSColor* color = [NSColor blackColor]; |
| 365 security_label_view_.SetLabel(@"Label", font, color); |
| 356 | 366 |
| 357 TestPageActionImageView page_action_view; | 367 TestPageActionImageView page_action_view; |
| 358 // We'll assume that the extensions code enforces icons smaller than the | 368 // We'll assume that the extensions code enforces icons smaller than the |
| 359 // location bar. | 369 // location bar. |
| 360 NSImage* image = [[[NSImage alloc] | 370 NSImage* image = [[[NSImage alloc] |
| 361 initWithSize:NSMakeSize(NSHeight(bounds) - 4, NSHeight(bounds) - 4)] | 371 initWithSize:NSMakeSize(NSHeight(bounds) - 4, NSHeight(bounds) - 4)] |
| 362 autorelease]; | 372 autorelease]; |
| 363 page_action_view.SetImage(image); | 373 page_action_view.SetImage(image); |
| 364 | 374 |
| 365 TestPageActionImageView page_action_view2; | 375 TestPageActionImageView page_action_view2; |
| 366 page_action_view2.SetImage(image); | 376 page_action_view2.SetImage(image); |
| 367 | 377 |
| 368 TestPageActionViewList list; | 378 TestPageActionViewList list; |
| 369 list.Add(&page_action_view); | 379 list.Add(&page_action_view); |
| 370 list.Add(&page_action_view2); | 380 list.Add(&page_action_view2); |
| 371 [cell setPageActionViewList:&list]; | 381 [cell setPageActionViewList:&list]; |
| 372 | 382 |
| 373 location_icon_view_.SetVisible(false); | 383 security_label_view_.SetVisible(false); |
| 374 page_action_view.SetVisible(false); | 384 page_action_view.SetVisible(false); |
| 375 page_action_view2.SetVisible(false); | 385 page_action_view2.SetVisible(false); |
| 376 EXPECT_TRUE(NSIsEmptyRect([cell pageActionFrameForIndex:0 inFrame:bounds])); | 386 EXPECT_TRUE(NSIsEmptyRect([cell pageActionFrameForIndex:0 inFrame:bounds])); |
| 377 EXPECT_TRUE(NSIsEmptyRect([cell pageActionFrameForIndex:1 inFrame:bounds])); | 387 EXPECT_TRUE(NSIsEmptyRect([cell pageActionFrameForIndex:1 inFrame:bounds])); |
| 378 | 388 |
| 379 // One page action, no lock icon. | 389 // One page action, no lock icon. |
| 380 page_action_view.SetVisible(true); | 390 page_action_view.SetVisible(true); |
| 381 NSRect iconRect0 = [cell pageActionFrameForIndex:0 inFrame:bounds]; | 391 NSRect iconRect0 = [cell pageActionFrameForIndex:0 inFrame:bounds]; |
| 382 | 392 |
| 383 EXPECT_FALSE(NSIsEmptyRect(iconRect0)); | 393 EXPECT_FALSE(NSIsEmptyRect(iconRect0)); |
| 384 EXPECT_TRUE(NSContainsRect(bounds, iconRect0)); | 394 EXPECT_TRUE(NSContainsRect(bounds, iconRect0)); |
| 385 | 395 |
| 386 // Make sure we are right of the |drawingRect|. | 396 // Make sure we are right of the |drawingRect|. |
| 387 NSRect drawingRect = [cell drawingRectForBounds:bounds]; | 397 NSRect drawingRect = [cell drawingRectForBounds:bounds]; |
| 388 EXPECT_LE(NSMaxX(drawingRect), NSMinX(iconRect0)); | 398 EXPECT_LE(NSMaxX(drawingRect), NSMinX(iconRect0)); |
| 389 | 399 |
| 390 // Make sure we're right of the |textFrame|. | 400 // Make sure we're right of the |textFrame|. |
| 391 NSRect textFrame = [cell textFrameForFrame:bounds]; | 401 NSRect textFrame = [cell textFrameForFrame:bounds]; |
| 392 EXPECT_LE(NSMaxX(textFrame), NSMinX(iconRect0)); | 402 EXPECT_LE(NSMaxX(textFrame), NSMinX(iconRect0)); |
| 393 | 403 |
| 394 // Two page actions plus a lock icon. | 404 // Two page actions plus a security label. |
| 395 page_action_view2.SetVisible(true); | 405 page_action_view2.SetVisible(true); |
| 396 location_icon_view_.SetVisible(true); | 406 security_label_view_.SetVisible(true); |
| 397 NSArray* icons = [cell layedOutIcons:bounds]; | 407 NSArray* icons = [cell layedOutIcons:bounds]; |
| 398 EXPECT_EQ(3u, [icons count]); | 408 ASSERT_EQ(3u, [icons count]); |
| 409 |
| 410 // TODO(shess): page-action list is inverted from -layedOutIcons: |
| 411 // Yes, this is confusing, fix it. |
| 399 iconRect0 = [cell pageActionFrameForIndex:0 inFrame:bounds]; | 412 iconRect0 = [cell pageActionFrameForIndex:0 inFrame:bounds]; |
| 400 NSRect iconRect1 = [cell pageActionFrameForIndex:1 inFrame:bounds]; | 413 NSRect iconRect1 = [cell pageActionFrameForIndex:1 inFrame:bounds]; |
| 401 NSRect lockRect = [[icons objectAtIndex:0] rect]; | 414 NSRect labelRect = [[icons objectAtIndex:0] rect]; |
| 402 | 415 |
| 403 EXPECT_TRUE(NSEqualRects(iconRect0, [[icons objectAtIndex:1] rect])); | 416 EXPECT_TRUE(NSEqualRects(iconRect0, [[icons objectAtIndex:2] rect])); |
| 404 EXPECT_TRUE(NSEqualRects(iconRect1, [[icons objectAtIndex:2] rect])); | 417 EXPECT_TRUE(NSEqualRects(iconRect1, [[icons objectAtIndex:1] rect])); |
| 405 | 418 |
| 406 // Make sure they're all in the expected order, and right of the |drawingRect| | 419 // Make sure they're all in the expected order, and right of the |drawingRect| |
| 407 // and |textFrame|. | 420 // and |textFrame|. |
| 408 drawingRect = [cell drawingRectForBounds:bounds]; | 421 drawingRect = [cell drawingRectForBounds:bounds]; |
| 409 textFrame = [cell textFrameForFrame:bounds]; | 422 textFrame = [cell textFrameForFrame:bounds]; |
| 410 | 423 |
| 411 EXPECT_FALSE(NSIsEmptyRect(iconRect0)); | 424 EXPECT_FALSE(NSIsEmptyRect(iconRect0)); |
| 412 EXPECT_TRUE(NSContainsRect(bounds, iconRect0)); | 425 EXPECT_TRUE(NSContainsRect(bounds, iconRect0)); |
| 413 EXPECT_FALSE(NSIsEmptyRect(iconRect1)); | 426 EXPECT_FALSE(NSIsEmptyRect(iconRect1)); |
| 414 EXPECT_TRUE(NSContainsRect(bounds, iconRect1)); | 427 EXPECT_TRUE(NSContainsRect(bounds, iconRect1)); |
| 415 EXPECT_FALSE(NSIsEmptyRect(lockRect)); | 428 EXPECT_FALSE(NSIsEmptyRect(labelRect)); |
| 416 EXPECT_TRUE(NSContainsRect(bounds, lockRect)); | 429 EXPECT_TRUE(NSContainsRect(bounds, labelRect)); |
| 417 | 430 |
| 418 EXPECT_LE(NSMaxX(drawingRect), NSMinX(iconRect1)); | 431 EXPECT_LE(NSMaxX(drawingRect), NSMinX(iconRect1)); |
| 419 EXPECT_LE(NSMaxX(textFrame), NSMinX(iconRect1)); | 432 EXPECT_LE(NSMaxX(textFrame), NSMinX(iconRect1)); |
| 420 EXPECT_LE(NSMaxX(iconRect1), NSMinX(iconRect0)); | 433 EXPECT_LE(NSMaxX(iconRect1), NSMinX(iconRect0)); |
| 421 EXPECT_LE(NSMaxX(iconRect0), NSMinX(lockRect)); | 434 EXPECT_LE(NSMaxX(labelRect), NSMinX(iconRect0)); |
| 422 } | 435 } |
| 423 | 436 |
| 424 // Test that the cell correctly chooses the partial keyword if there's | 437 // Test that the cell correctly chooses the partial keyword if there's |
| 425 // not enough room. | 438 // not enough room. |
| 426 TEST_F(AutocompleteTextFieldCellTest, UsesPartialKeywordIfNarrow) { | 439 TEST_F(AutocompleteTextFieldCellTest, UsesPartialKeywordIfNarrow) { |
| 427 AutocompleteTextFieldCell* cell = | 440 AutocompleteTextFieldCell* cell = |
| 428 static_cast<AutocompleteTextFieldCell*>([view_ cell]); | 441 static_cast<AutocompleteTextFieldCell*>([view_ cell]); |
| 429 | 442 |
| 430 const NSString* kFullString = @"Search Engine:"; | 443 const NSString* kFullString = @"Search Engine:"; |
| 431 const NSString* kPartialString = @"Search Eng:"; | 444 const NSString* kPartialString = @"Search Eng:"; |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 488 EXPECT_TRUE([[[cell hintString] string] hasPrefix:kHintPrefix]); | 501 EXPECT_TRUE([[[cell hintString] string] hasPrefix:kHintPrefix]); |
| 489 EXPECT_TRUE([[[cell hintString] string] hasSuffix:kHintSuffix]); | 502 EXPECT_TRUE([[[cell hintString] string] hasSuffix:kHintSuffix]); |
| 490 | 503 |
| 491 // Narrow width suppresses everything but the image. | 504 // Narrow width suppresses everything but the image. |
| 492 [cell setKeywordHintPrefix:kHintPrefix image:image suffix:kHintSuffix | 505 [cell setKeywordHintPrefix:kHintPrefix image:image suffix:kHintSuffix |
| 493 availableWidth:kNarrowWidth]; | 506 availableWidth:kNarrowWidth]; |
| 494 EXPECT_EQ([[cell hintString] length], 1U); | 507 EXPECT_EQ([[cell hintString] length], 1U); |
| 495 } | 508 } |
| 496 | 509 |
| 497 } // namespace | 510 } // namespace |
| OLD | NEW |