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 "chrome/browser/autocomplete/autocomplete_popup_view_mac.h" | 5 #import "chrome/browser/autocomplete/autocomplete_popup_view_mac.h" |
6 | 6 |
7 #include "app/text_elider.h" | |
8 #include "base/scoped_ptr.h" | 7 #include "base/scoped_ptr.h" |
9 #include "base/sys_string_conversions.h" | 8 #include "base/sys_string_conversions.h" |
10 #include "base/utf_string_conversions.h" | 9 #include "base/utf_string_conversions.h" |
11 #include "chrome/browser/autocomplete/autocomplete.h" | 10 #include "chrome/browser/autocomplete/autocomplete.h" |
12 #include "testing/platform_test.h" | 11 #include "testing/platform_test.h" |
| 12 #include "ui/base/text/text_elider.h" |
13 | 13 |
14 namespace { | 14 namespace { |
15 | 15 |
16 const float kLargeWidth = 10000; | 16 const float kLargeWidth = 10000; |
17 | 17 |
18 class AutocompletePopupViewMacTest : public PlatformTest { | 18 class AutocompletePopupViewMacTest : public PlatformTest { |
19 public: | 19 public: |
20 AutocompletePopupViewMacTest() {} | 20 AutocompletePopupViewMacTest() {} |
21 | 21 |
22 virtual void SetUp() { | 22 virtual void SetUp() { |
(...skipping 431 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 AutocompletePopupViewMac::ElideString(as, wideContents, font_, kWide); | 458 AutocompletePopupViewMac::ElideString(as, wideContents, 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 = AutocompletePopupViewMac::ElideString(as, wideContents, font_, kNarrow); | 463 ret = AutocompletePopupViewMac::ElideString(as, wideContents, font_, kNarrow); |
464 std::wstring elided(UTF16ToWideHack(ElideText(WideToUTF16Hack( | 464 std::wstring elided(UTF16ToWideHack(ui::ElideText(WideToUTF16Hack( |
465 wideContents), font_, kNarrow, false))); | 465 wideContents), font_, kNarrow, false))); |
466 EXPECT_TRUE(ret == as); | 466 EXPECT_TRUE(ret == as); |
467 EXPECT_FALSE([[as string] isEqualToString:contents]); | 467 EXPECT_FALSE([[as string] isEqualToString:contents]); |
468 EXPECT_TRUE([[as string] isEqualToString:base::SysWideToNSString(elided)]); | 468 EXPECT_TRUE([[as string] isEqualToString:base::SysWideToNSString(elided)]); |
469 | 469 |
470 // When elided, result is the same as ElideText(). | 470 // When elided, result is the same as ElideText(). |
471 ret = AutocompletePopupViewMac::ElideString(as, wideContents, font_, 0.0); | 471 ret = AutocompletePopupViewMac::ElideString(as, wideContents, font_, 0.0); |
472 elided = UTF16ToWideHack(ElideText(WideToUTF16Hack(wideContents), font_, | 472 elided = UTF16ToWideHack(ui::ElideText(WideToUTF16Hack(wideContents), font_, |
473 0.0, false)); | 473 0.0, false)); |
474 EXPECT_TRUE(ret == as); | 474 EXPECT_TRUE(ret == as); |
475 EXPECT_FALSE([[as string] isEqualToString:contents]); | 475 EXPECT_FALSE([[as string] isEqualToString:contents]); |
476 EXPECT_TRUE([[as string] isEqualToString:base::SysWideToNSString(elided)]); | 476 EXPECT_TRUE([[as string] isEqualToString:base::SysWideToNSString(elided)]); |
477 } | 477 } |
478 | 478 |
479 TEST_F(AutocompletePopupViewMacTest, MatchTextElide) { | 479 TEST_F(AutocompletePopupViewMacTest, MatchTextElide) { |
480 NSString* const contents = @"This is a test with long contents"; | 480 NSString* const contents = @"This is a test with long contents"; |
481 NSString* const description = @"That was a test"; | 481 NSString* const description = @"That was a test"; |
482 // Match "long". | 482 // Match "long". |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
545 // updates the model's selection from the matrix before returning. | 545 // updates the model's selection from the matrix before returning. |
546 // Could possibly test that via -select:. | 546 // Could possibly test that via -select:. |
547 | 547 |
548 // TODO(shess): Test that AutocompleteButtonCell returns the right | 548 // TODO(shess): Test that AutocompleteButtonCell returns the right |
549 // background colors for on, highlighted, and neither. | 549 // background colors for on, highlighted, and neither. |
550 | 550 |
551 // TODO(shess): Test that AutocompleteMatrixTarget can be initialized | 551 // TODO(shess): Test that AutocompleteMatrixTarget can be initialized |
552 // and then sends -select: to the view. | 552 // and then sends -select: to the view. |
553 | 553 |
554 } // namespace | 554 } // namespace |
OLD | NEW |