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

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

Issue 1581011: [Mac] Magnifying glass in keyword-search bubble. (Closed)
Patch Set: Present for Rohit. 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
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 425 matching lines...) Expand 10 before | Expand all | Expand 10 after
436 436
437 // 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
438 // not enough room. 438 // not enough room.
439 TEST_F(AutocompleteTextFieldCellTest, UsesPartialKeywordIfNarrow) { 439 TEST_F(AutocompleteTextFieldCellTest, UsesPartialKeywordIfNarrow) {
440 AutocompleteTextFieldCell* cell = 440 AutocompleteTextFieldCell* cell =
441 static_cast<AutocompleteTextFieldCell*>([view_ cell]); 441 static_cast<AutocompleteTextFieldCell*>([view_ cell]);
442 442
443 const NSString* kFullString = @"Search Engine:"; 443 const NSString* kFullString = @"Search Engine:";
444 const NSString* kPartialString = @"Search Eng:"; 444 const NSString* kPartialString = @"Search Eng:";
445 445
446 // Wide width chooses the full string. 446 // Wide width chooses the full string, including an image on the
447 // left.
447 [cell setKeywordString:kFullString 448 [cell setKeywordString:kFullString
448 partialString:kPartialString 449 partialString:kPartialString
449 availableWidth:kWidth]; 450 availableWidth:kWidth];
450 EXPECT_TRUE([cell keywordString]); 451 EXPECT_TRUE([cell keywordString]);
452 EXPECT_TRUE([[[cell keywordString] string] hasSuffix:kFullString]);
453 EXPECT_TRUE([[cell keywordString] containsAttachments]);
454
455 // If not enough space to include the image, uses exactly the full
456 // string.
457 CGFloat allWidth = [[cell keywordString] size].width;
458 [cell setKeywordString:kFullString
459 partialString:kPartialString
460 availableWidth:allWidth - 5.0];
461 EXPECT_TRUE([cell keywordString]);
451 EXPECT_TRUE([[[cell keywordString] string] isEqualToString:kFullString]); 462 EXPECT_TRUE([[[cell keywordString] string] isEqualToString:kFullString]);
452 463
453 // Narrow width chooses the partial string. 464 // Narrow width chooses the partial string.
454 [cell setKeywordString:kFullString 465 [cell setKeywordString:kFullString
455 partialString:kPartialString 466 partialString:kPartialString
456 availableWidth:kNarrowWidth]; 467 availableWidth:kNarrowWidth];
457 EXPECT_TRUE([cell keywordString]); 468 EXPECT_TRUE([cell keywordString]);
458 EXPECT_TRUE([[[cell keywordString] string] isEqualToString:kPartialString]); 469 EXPECT_TRUE([[[cell keywordString] string] isEqualToString:kPartialString]);
459 470
460 // But not if there isn't one! 471 // But not if there isn't one!
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
501 EXPECT_TRUE([[[cell hintString] string] hasPrefix:kHintPrefix]); 512 EXPECT_TRUE([[[cell hintString] string] hasPrefix:kHintPrefix]);
502 EXPECT_TRUE([[[cell hintString] string] hasSuffix:kHintSuffix]); 513 EXPECT_TRUE([[[cell hintString] string] hasSuffix:kHintSuffix]);
503 514
504 // Narrow width suppresses everything but the image. 515 // Narrow width suppresses everything but the image.
505 [cell setKeywordHintPrefix:kHintPrefix image:image suffix:kHintSuffix 516 [cell setKeywordHintPrefix:kHintPrefix image:image suffix:kHintSuffix
506 availableWidth:kNarrowWidth]; 517 availableWidth:kNarrowWidth];
507 EXPECT_EQ([[cell hintString] length], 1U); 518 EXPECT_EQ([[cell hintString] length], 1U);
508 } 519 }
509 520
510 } // namespace 521 } // namespace
OLDNEW
« no previous file with comments | « chrome/browser/cocoa/autocomplete_text_field_cell.mm ('k') | chrome/browser/cocoa/location_bar_view_mac_unittest.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698