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

Side by Side Diff: ui/gfx/text_elider_unittest.cc

Issue 1223153003: Move JoinString to the base namespace (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: windows Created 5 years, 5 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
« no previous file with comments | « ui/gfx/font_render_params_linux.cc ('k') | ui/gl/gl_context.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 // Unit tests for eliding and formatting utility functions. 5 // Unit tests for eliding and formatting utility functions.
6 6
7 #include "ui/gfx/text_elider.h" 7 #include "ui/gfx/text_elider.h"
8 8
9 #include <vector> 9 #include <vector>
10 10
(...skipping 650 matching lines...) Expand 10 before | Expand all | Expand 10 after
661 for (size_t i = 0; i < arraysize(cases); ++i) { 661 for (size_t i = 0; i < arraysize(cases); ++i) {
662 std::vector<base::string16> lines; 662 std::vector<base::string16> lines;
663 EXPECT_EQ(cases[i].truncated_y ? INSUFFICIENT_SPACE_VERTICAL : 0, 663 EXPECT_EQ(cases[i].truncated_y ? INSUFFICIENT_SPACE_VERTICAL : 0,
664 ElideRectangleText(UTF8ToUTF16(cases[i].input), 664 ElideRectangleText(UTF8ToUTF16(cases[i].input),
665 font_list, 665 font_list,
666 cases[i].available_pixel_width, 666 cases[i].available_pixel_width,
667 cases[i].available_pixel_height, 667 cases[i].available_pixel_height,
668 TRUNCATE_LONG_WORDS, 668 TRUNCATE_LONG_WORDS,
669 &lines)); 669 &lines));
670 if (cases[i].output) { 670 if (cases[i].output) {
671 const std::string result = UTF16ToUTF8(JoinString(lines, '|')); 671 const std::string result =
672 UTF16ToUTF8(base::JoinString(lines, ASCIIToUTF16("|")));
672 EXPECT_EQ(cases[i].output, result) << "Case " << i << " failed!"; 673 EXPECT_EQ(cases[i].output, result) << "Case " << i << " failed!";
673 } else { 674 } else {
674 EXPECT_TRUE(lines.empty()) << "Case " << i << " failed!"; 675 EXPECT_TRUE(lines.empty()) << "Case " << i << " failed!";
675 } 676 }
676 } 677 }
677 } 678 }
678 679
679 // TODO(338784): Enable this on android. 680 // TODO(338784): Enable this on android.
680 #if defined(OS_ANDROID) 681 #if defined(OS_ANDROID)
681 #define MAYBE_ElideRectangleTextPunctuation \ 682 #define MAYBE_ElideRectangleTextPunctuation \
(...skipping 26 matching lines...) Expand all
708 const WordWrapBehavior wrap_behavior = 709 const WordWrapBehavior wrap_behavior =
709 (cases[i].wrap_words ? WRAP_LONG_WORDS : TRUNCATE_LONG_WORDS); 710 (cases[i].wrap_words ? WRAP_LONG_WORDS : TRUNCATE_LONG_WORDS);
710 EXPECT_EQ(cases[i].truncated_x ? INSUFFICIENT_SPACE_HORIZONTAL : 0, 711 EXPECT_EQ(cases[i].truncated_x ? INSUFFICIENT_SPACE_HORIZONTAL : 0,
711 ElideRectangleText(UTF8ToUTF16(cases[i].input), 712 ElideRectangleText(UTF8ToUTF16(cases[i].input),
712 font_list, 713 font_list,
713 cases[i].available_pixel_width, 714 cases[i].available_pixel_width,
714 cases[i].available_pixel_height, 715 cases[i].available_pixel_height,
715 wrap_behavior, 716 wrap_behavior,
716 &lines)); 717 &lines));
717 if (cases[i].output) { 718 if (cases[i].output) {
718 const std::string result = UTF16ToUTF8(JoinString(lines, '|')); 719 const std::string result =
720 UTF16ToUTF8(base::JoinString(lines, base::ASCIIToUTF16("|")));
719 EXPECT_EQ(cases[i].output, result) << "Case " << i << " failed!"; 721 EXPECT_EQ(cases[i].output, result) << "Case " << i << " failed!";
720 } else { 722 } else {
721 EXPECT_TRUE(lines.empty()) << "Case " << i << " failed!"; 723 EXPECT_TRUE(lines.empty()) << "Case " << i << " failed!";
722 } 724 }
723 } 725 }
724 } 726 }
725 727
726 // TODO(338784): Enable this on android. 728 // TODO(338784): Enable this on android.
727 #if defined(OS_ANDROID) 729 #if defined(OS_ANDROID)
728 #define MAYBE_ElideRectangleTextLongWords DISABLED_ElideRectangleTextLongWords 730 #define MAYBE_ElideRectangleTextLongWords DISABLED_ElideRectangleTextLongWords
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
777 std::vector<base::string16> lines; 779 std::vector<base::string16> lines;
778 EXPECT_EQ(cases[i].truncated_x ? INSUFFICIENT_SPACE_HORIZONTAL : 0, 780 EXPECT_EQ(cases[i].truncated_x ? INSUFFICIENT_SPACE_HORIZONTAL : 0,
779 ElideRectangleText(UTF8ToUTF16(cases[i].input), 781 ElideRectangleText(UTF8ToUTF16(cases[i].input),
780 font_list, 782 font_list,
781 cases[i].available_pixel_width, 783 cases[i].available_pixel_width,
782 kAvailableHeight, 784 kAvailableHeight,
783 cases[i].wrap_behavior, 785 cases[i].wrap_behavior,
784 &lines)); 786 &lines));
785 std::string expected_output(cases[i].output); 787 std::string expected_output(cases[i].output);
786 base::ReplaceSubstringsAfterOffset(&expected_output, 0, "...", kEllipsis); 788 base::ReplaceSubstringsAfterOffset(&expected_output, 0, "...", kEllipsis);
787 const std::string result = UTF16ToUTF8(JoinString(lines, '|')); 789 const std::string result =
790 UTF16ToUTF8(base::JoinString(lines, base::ASCIIToUTF16("|")));
788 EXPECT_EQ(expected_output, result) << "Case " << i << " failed!"; 791 EXPECT_EQ(expected_output, result) << "Case " << i << " failed!";
789 } 792 }
790 } 793 }
791 794
792 // This test is to make sure that the width of each wrapped line does not 795 // This test is to make sure that the width of each wrapped line does not
793 // exceed the available width. On some platform like Mac, this test used to 796 // exceed the available width. On some platform like Mac, this test used to
794 // fail because the truncated integer width is returned for the string 797 // fail because the truncated integer width is returned for the string
795 // and the accumulation of the truncated values causes the elide function 798 // and the accumulation of the truncated values causes the elide function
796 // to wrap incorrectly. 799 // to wrap incorrectly.
797 // TODO(338784): Enable this on android. 800 // TODO(338784): Enable this on android.
(...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after
1111 // Test adds ... at right spot within a word. 1114 // Test adds ... at right spot within a word.
1112 EXPECT_EQ(L"f\x2026", UTF16ToWide(TruncateString(string, 2, 1115 EXPECT_EQ(L"f\x2026", UTF16ToWide(TruncateString(string, 2,
1113 CHARACTER_BREAK))); 1116 CHARACTER_BREAK)));
1114 1117
1115 // Test removes trailing whitespace if break falls between words. 1118 // Test removes trailing whitespace if break falls between words.
1116 EXPECT_EQ(L"foooooey\x2026", UTF16ToWide(TruncateString(string, 12, 1119 EXPECT_EQ(L"foooooey\x2026", UTF16ToWide(TruncateString(string, 12,
1117 CHARACTER_BREAK))); 1120 CHARACTER_BREAK)));
1118 } 1121 }
1119 1122
1120 } // namespace gfx 1123 } // namespace gfx
OLDNEW
« no previous file with comments | « ui/gfx/font_render_params_linux.cc ('k') | ui/gl/gl_context.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698