OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "chrome/browser/ui/cocoa/omnibox/omnibox_popup_view_mac.h" | 5 #import "chrome/browser/ui/cocoa/omnibox/omnibox_popup_view_mac.h" |
6 | 6 |
7 #include "base/memory/scoped_ptr.h" | 7 #include "base/memory/scoped_ptr.h" |
8 #include "base/sys_string_conversions.h" | 8 #include "base/sys_string_conversions.h" |
9 #include "base/utf_string_conversions.h" | 9 #include "base/utf_string_conversions.h" |
10 #include "chrome/browser/autocomplete/autocomplete.h" | 10 #include "chrome/browser/autocomplete/autocomplete.h" |
(...skipping 443 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
454 attributes:attributes]); | 454 attributes:attributes]); |
455 | 455 |
456 // Nothing happens if the space is really wide. | 456 // Nothing happens if the space is really wide. |
457 NSMutableAttributedString* ret = | 457 NSMutableAttributedString* ret = |
458 OmniboxPopupViewMac::ElideString(as, contents16, font_, kWide); | 458 OmniboxPopupViewMac::ElideString(as, contents16, font_, kWide); |
459 EXPECT_TRUE(ret == as); | 459 EXPECT_TRUE(ret == as); |
460 EXPECT_TRUE([[as string] isEqualToString:contents]); | 460 EXPECT_TRUE([[as string] isEqualToString:contents]); |
461 | 461 |
462 // When elided, result is the same as ElideText(). | 462 // When elided, result is the same as ElideText(). |
463 ret = OmniboxPopupViewMac::ElideString(as, contents16, font_, kNarrow); | 463 ret = OmniboxPopupViewMac::ElideString(as, contents16, font_, kNarrow); |
464 string16 elided = ui::ElideText(contents16, font_, kNarrow, false); | 464 string16 elided = ui::ElideText(contents16, font_, kNarrow, ui::ELIDE_AT_END); |
465 EXPECT_TRUE(ret == as); | 465 EXPECT_TRUE(ret == as); |
466 EXPECT_FALSE([[as string] isEqualToString:contents]); | 466 EXPECT_FALSE([[as string] isEqualToString:contents]); |
467 EXPECT_TRUE([[as string] isEqualToString:base::SysUTF16ToNSString(elided)]); | 467 EXPECT_TRUE([[as string] isEqualToString:base::SysUTF16ToNSString(elided)]); |
468 | 468 |
469 // When elided, result is the same as ElideText(). | 469 // When elided, result is the same as ElideText(). |
470 ret = OmniboxPopupViewMac::ElideString(as, contents16, font_, 0.0); | 470 ret = OmniboxPopupViewMac::ElideString(as, contents16, font_, 0.0); |
471 elided = ui::ElideText(contents16, font_, 0.0, false); | 471 elided = ui::ElideText(contents16, font_, 0.0, ui::ELIDE_AT_END); |
472 EXPECT_TRUE(ret == as); | 472 EXPECT_TRUE(ret == as); |
473 EXPECT_FALSE([[as string] isEqualToString:contents]); | 473 EXPECT_FALSE([[as string] isEqualToString:contents]); |
474 EXPECT_TRUE([[as string] isEqualToString:base::SysUTF16ToNSString(elided)]); | 474 EXPECT_TRUE([[as string] isEqualToString:base::SysUTF16ToNSString(elided)]); |
475 } | 475 } |
476 | 476 |
477 TEST_F(OmniboxPopupViewMacTest, MatchTextElide) { | 477 TEST_F(OmniboxPopupViewMacTest, MatchTextElide) { |
478 NSString* const contents = @"This is a test with long contents"; | 478 NSString* const contents = @"This is a test with long contents"; |
479 NSString* const description = @"That was a test"; | 479 NSString* const description = @"That was a test"; |
480 // Match "long". | 480 // Match "long". |
481 const NSUInteger runLength1 = 20, runLength2 = 4, runLength3 = 9; | 481 const NSUInteger runLength1 = 20, runLength2 = 4, runLength3 = 9; |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
543 // updates the model's selection from the matrix before returning. | 543 // updates the model's selection from the matrix before returning. |
544 // Could possibly test that via -select:. | 544 // Could possibly test that via -select:. |
545 | 545 |
546 // TODO(shess): Test that AutocompleteButtonCell returns the right | 546 // TODO(shess): Test that AutocompleteButtonCell returns the right |
547 // background colors for on, highlighted, and neither. | 547 // background colors for on, highlighted, and neither. |
548 | 548 |
549 // TODO(shess): Test that AutocompleteMatrixTarget can be initialized | 549 // TODO(shess): Test that AutocompleteMatrixTarget can be initialized |
550 // and then sends -select: to the view. | 550 // and then sends -select: to the view. |
551 | 551 |
552 } // namespace | 552 } // namespace |
OLD | NEW |