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

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

Issue 614103007: Error in popup on Link (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: For testing Created 6 years, 2 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/text_elider.cc ('k') | no next file » | 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 "base/files/file_path.h" 9 #include "base/files/file_path.h"
10 #include "base/i18n/rtl.h" 10 #include "base/i18n/rtl.h"
(...skipping 658 matching lines...) Expand 10 before | Expand all | Expand 10 after
669 font_list, 669 font_list,
670 kAvailableWidth, 670 kAvailableWidth,
671 kAvailableHeight, 671 kAvailableHeight,
672 WRAP_LONG_WORDS, 672 WRAP_LONG_WORDS,
673 &lines)); 673 &lines));
674 ASSERT_EQ(2u, lines.size()); 674 ASSERT_EQ(2u, lines.size());
675 EXPECT_LE(GetStringWidthF(lines[0], font_list), kAvailableWidth); 675 EXPECT_LE(GetStringWidthF(lines[0], font_list), kAvailableWidth);
676 EXPECT_LE(GetStringWidthF(lines[1], font_list), kAvailableWidth); 676 EXPECT_LE(GetStringWidthF(lines[1], font_list), kAvailableWidth);
677 } 677 }
678 678
679 TEST(TextEliderTest, ElideRectangleTextCheckBreaking) {
680 FontList font_list;
681 font_list = FontList("Noto Sans UI,ui-sans, 12px");
682 #define WIDTH(x) GetStringWidthF(UTF8ToUTF16(x), font_list)
683
684 EXPECT_EQ(WIDTH("The administrator for this account has"),
685 WIDTH("The ") +
686 WIDTH("administrator ") +
687 WIDTH("for ") +
688 WIDTH("this ") +
689 WIDTH("account ") +
690 WIDTH("has"));
691 #undef W
692 }
693
679 TEST(TextEliderTest, ElideRectangleString) { 694 TEST(TextEliderTest, ElideRectangleString) {
680 struct TestData { 695 struct TestData {
681 const char* input; 696 const char* input;
682 int max_rows; 697 int max_rows;
683 int max_cols; 698 int max_cols;
684 bool result; 699 bool result;
685 const char* output; 700 const char* output;
686 } cases[] = { 701 } cases[] = {
687 { "", 0, 0, false, "" }, 702 { "", 0, 0, false, "" },
688 { "", 1, 1, false, "" }, 703 { "", 1, 1, false, "" },
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after
917 // Test adds ... at right spot within a word. 932 // Test adds ... at right spot within a word.
918 EXPECT_EQ(L"f\x2026", UTF16ToWide(TruncateString(string, 2, 933 EXPECT_EQ(L"f\x2026", UTF16ToWide(TruncateString(string, 2,
919 CHARACTER_BREAK))); 934 CHARACTER_BREAK)));
920 935
921 // Test removes trailing whitespace if break falls between words. 936 // Test removes trailing whitespace if break falls between words.
922 EXPECT_EQ(L"foooooey\x2026", UTF16ToWide(TruncateString(string, 12, 937 EXPECT_EQ(L"foooooey\x2026", UTF16ToWide(TruncateString(string, 12,
923 CHARACTER_BREAK))); 938 CHARACTER_BREAK)));
924 } 939 }
925 940
926 } // namespace gfx 941 } // namespace gfx
OLDNEW
« no previous file with comments | « ui/gfx/text_elider.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698