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

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

Issue 1145473006: Disable failing TextEliderTest.* and FontListTest.* (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 7 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_list_unittest.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 <vector> 9 #include <vector>
10 10
(...skipping 821 matching lines...) Expand 10 before | Expand all | Expand 10 after
832 SetFontRenderParamsDeviceScaleFactor(1.25f); 832 SetFontRenderParamsDeviceScaleFactor(1.25f);
833 #define WIDTH(x) GetStringWidthF(UTF8ToUTF16(x), font_list) 833 #define WIDTH(x) GetStringWidthF(UTF8ToUTF16(x), font_list)
834 EXPECT_EQ(WIDTH("The administrator for this account has"), 834 EXPECT_EQ(WIDTH("The administrator for this account has"),
835 WIDTH("The ") + WIDTH("administrator ") + WIDTH("for ") + 835 WIDTH("The ") + WIDTH("administrator ") + WIDTH("for ") +
836 WIDTH("this ") + WIDTH("account ") + WIDTH("has")); 836 WIDTH("this ") + WIDTH("account ") + WIDTH("has"));
837 #undef WIDTH 837 #undef WIDTH
838 SetFontRenderParamsDeviceScaleFactor(1.0f); 838 SetFontRenderParamsDeviceScaleFactor(1.0f);
839 } 839 }
840 #endif // OS_CHROMEOS 840 #endif // OS_CHROMEOS
841 841
842 TEST(TextEliderTest, ElideRectangleString) { 842 // TODO(338784): Enable this on android.
843 #if defined(OS_ANDROID)
844 #define MAYBE_ElideRectangleString DISABLED_ElideRectangleString
845 #else
846 #define MAYBE_ElideRectangleString ElideRectangleString
847 #endif
848 TEST(TextEliderTest, MAYBE_ElideRectangleString) {
843 struct TestData { 849 struct TestData {
844 const char* input; 850 const char* input;
845 int max_rows; 851 int max_rows;
846 int max_cols; 852 int max_cols;
847 bool result; 853 bool result;
848 const char* output; 854 const char* output;
849 } cases[] = { 855 } cases[] = {
850 { "", 0, 0, false, "" }, 856 { "", 0, 0, false, "" },
851 { "", 1, 1, false, "" }, 857 { "", 1, 1, false, "" },
852 { "Hi, my name is\nTom", 0, 0, true, "..." }, 858 { "Hi, my name is\nTom", 0, 0, true, "..." },
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
915 base::string16 output; 921 base::string16 output;
916 for (size_t i = 0; i < arraysize(cases); ++i) { 922 for (size_t i = 0; i < arraysize(cases); ++i) {
917 EXPECT_EQ(cases[i].result, 923 EXPECT_EQ(cases[i].result,
918 ElideRectangleString(UTF8ToUTF16(cases[i].input), 924 ElideRectangleString(UTF8ToUTF16(cases[i].input),
919 cases[i].max_rows, cases[i].max_cols, 925 cases[i].max_rows, cases[i].max_cols,
920 true, &output)); 926 true, &output));
921 EXPECT_EQ(cases[i].output, UTF16ToUTF8(output)); 927 EXPECT_EQ(cases[i].output, UTF16ToUTF8(output));
922 } 928 }
923 } 929 }
924 930
925 TEST(TextEliderTest, ElideRectangleStringNotStrict) { 931 // TODO(338784): Enable this on android.
932 #if defined(OS_ANDROID)
933 #define MAYBE_ElideRectangleStringNotStrict \
934 DISABLED_ElideRectangleStringNotStrict
935 #else
936 #define MAYBE_ElideRectangleStringNotStrict ElideRectangleStringNotStrict
937 #endif
938 TEST(TextEliderTest, MAYBE_ElideRectangleStringNotStrict) {
926 struct TestData { 939 struct TestData {
927 const char* input; 940 const char* input;
928 int max_rows; 941 int max_rows;
929 int max_cols; 942 int max_cols;
930 bool result; 943 bool result;
931 const char* output; 944 const char* output;
932 } cases[] = { 945 } cases[] = {
933 { "", 0, 0, false, "" }, 946 { "", 0, 0, false, "" },
934 { "", 1, 1, false, "" }, 947 { "", 1, 1, false, "" },
935 { "Hi, my name_is\nDick", 0, 0, true, "..." }, 948 { "Hi, my name_is\nDick", 0, 0, true, "..." },
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
997 base::string16 output; 1010 base::string16 output;
998 for (size_t i = 0; i < arraysize(cases); ++i) { 1011 for (size_t i = 0; i < arraysize(cases); ++i) {
999 EXPECT_EQ(cases[i].result, 1012 EXPECT_EQ(cases[i].result,
1000 ElideRectangleString(UTF8ToUTF16(cases[i].input), 1013 ElideRectangleString(UTF8ToUTF16(cases[i].input),
1001 cases[i].max_rows, cases[i].max_cols, 1014 cases[i].max_rows, cases[i].max_cols,
1002 false, &output)); 1015 false, &output));
1003 EXPECT_EQ(cases[i].output, UTF16ToUTF8(output)); 1016 EXPECT_EQ(cases[i].output, UTF16ToUTF8(output));
1004 } 1017 }
1005 } 1018 }
1006 1019
1007 TEST(TextEliderTest, ElideRectangleWide16) { 1020 // TODO(338784): Enable this on android.
1021 #if defined(OS_ANDROID)
1022 #define MAYBE_ElideRectangleWide16 DISABLED_ElideRectangleWide16
1023 #else
1024 #define MAYBE_ElideRectangleWide16 ElideRectangleWide16
1025 #endif
1026 TEST(TextEliderTest, MAYBE_ElideRectangleWide16) {
1008 // Two greek words separated by space. 1027 // Two greek words separated by space.
1009 const base::string16 str(WideToUTF16( 1028 const base::string16 str(WideToUTF16(
1010 L"\x03a0\x03b1\x03b3\x03ba\x03cc\x03c3\x03bc\x03b9" 1029 L"\x03a0\x03b1\x03b3\x03ba\x03cc\x03c3\x03bc\x03b9"
1011 L"\x03bf\x03c2\x0020\x0399\x03c3\x03c4\x03cc\x03c2")); 1030 L"\x03bf\x03c2\x0020\x0399\x03c3\x03c4\x03cc\x03c2"));
1012 const base::string16 out1(WideToUTF16( 1031 const base::string16 out1(WideToUTF16(
1013 L"\x03a0\x03b1\x03b3\x03ba\n" 1032 L"\x03a0\x03b1\x03b3\x03ba\n"
1014 L"\x03cc\x03c3\x03bc\x03b9\n" 1033 L"\x03cc\x03c3\x03bc\x03b9\n"
1015 L"...")); 1034 L"..."));
1016 const base::string16 out2(WideToUTF16( 1035 const base::string16 out2(WideToUTF16(
1017 L"\x03a0\x03b1\x03b3\x03ba\x03cc\x03c3\x03bc\x03b9\x03bf\x03c2\x0020\n" 1036 L"\x03a0\x03b1\x03b3\x03ba\x03cc\x03c3\x03bc\x03b9\x03bf\x03c2\x0020\n"
1018 L"\x0399\x03c3\x03c4\x03cc\x03c2")); 1037 L"\x0399\x03c3\x03c4\x03cc\x03c2"));
1019 base::string16 output; 1038 base::string16 output;
1020 EXPECT_TRUE(ElideRectangleString(str, 2, 4, true, &output)); 1039 EXPECT_TRUE(ElideRectangleString(str, 2, 4, true, &output));
1021 EXPECT_EQ(out1, output); 1040 EXPECT_EQ(out1, output);
1022 EXPECT_FALSE(ElideRectangleString(str, 2, 12, true, &output)); 1041 EXPECT_FALSE(ElideRectangleString(str, 2, 12, true, &output));
1023 EXPECT_EQ(out2, output); 1042 EXPECT_EQ(out2, output);
1024 } 1043 }
1025 1044
1026 TEST(TextEliderTest, ElideRectangleWide32) { 1045 // TODO(338784): Enable this on android.
1046 #if defined(OS_ANDROID)
1047 #define MAYBE_ElideRectangleWide32 DISABLED_ElideRectangleWide32
1048 #else
1049 #define MAYBE_ElideRectangleWide32 ElideRectangleWide32
1050 #endif
1051 TEST(TextEliderTest, MAYBE_ElideRectangleWide32) {
1027 // Four U+1D49C MATHEMATICAL SCRIPT CAPITAL A followed by space "aaaaa". 1052 // Four U+1D49C MATHEMATICAL SCRIPT CAPITAL A followed by space "aaaaa".
1028 const base::string16 str(UTF8ToUTF16( 1053 const base::string16 str(UTF8ToUTF16(
1029 "\xF0\x9D\x92\x9C\xF0\x9D\x92\x9C\xF0\x9D\x92\x9C\xF0\x9D\x92\x9C" 1054 "\xF0\x9D\x92\x9C\xF0\x9D\x92\x9C\xF0\x9D\x92\x9C\xF0\x9D\x92\x9C"
1030 " aaaaa")); 1055 " aaaaa"));
1031 const base::string16 out(UTF8ToUTF16( 1056 const base::string16 out(UTF8ToUTF16(
1032 "\xF0\x9D\x92\x9C\xF0\x9D\x92\x9C\xF0\x9D\x92\x9C\n" 1057 "\xF0\x9D\x92\x9C\xF0\x9D\x92\x9C\xF0\x9D\x92\x9C\n"
1033 "\xF0\x9D\x92\x9C \naaa\n...")); 1058 "\xF0\x9D\x92\x9C \naaa\n..."));
1034 base::string16 output; 1059 base::string16 output;
1035 EXPECT_TRUE(ElideRectangleString(str, 3, 3, true, &output)); 1060 EXPECT_TRUE(ElideRectangleString(str, 3, 3, true, &output));
1036 EXPECT_EQ(out, output); 1061 EXPECT_EQ(out, output);
1037 } 1062 }
1038 1063
1039 TEST(TextEliderTest, TruncateString) { 1064 // TODO(338784): Enable this on android.
1065 #if defined(OS_ANDROID)
1066 #define MAYBE_TruncateString DISABLED_TruncateString
1067 #else
1068 #define MAYBE_TruncateString TruncateString
1069 #endif
1070 TEST(TextEliderTest, MAYBE_TruncateString) {
1040 base::string16 string = ASCIIToUTF16("foooooey bxxxar baz"); 1071 base::string16 string = ASCIIToUTF16("foooooey bxxxar baz");
1041 1072
1042 // Tests that apply to both break behaviors: 1073 // Tests that apply to both break behaviors:
1043 1074
1044 // Make sure it doesn't modify the string if length > string length. 1075 // Make sure it doesn't modify the string if length > string length.
1045 EXPECT_EQ(string, TruncateString(string, 100, WORD_BREAK)); 1076 EXPECT_EQ(string, TruncateString(string, 100, WORD_BREAK));
1046 EXPECT_EQ(string, TruncateString(string, 100, CHARACTER_BREAK)); 1077 EXPECT_EQ(string, TruncateString(string, 100, CHARACTER_BREAK));
1047 1078
1048 // Test no characters. 1079 // Test no characters.
1049 EXPECT_EQ(L"", UTF16ToWide(TruncateString(string, 0, WORD_BREAK))); 1080 EXPECT_EQ(L"", UTF16ToWide(TruncateString(string, 0, WORD_BREAK)));
(...skipping 30 matching lines...) Expand all
1080 // Test adds ... at right spot within a word. 1111 // Test adds ... at right spot within a word.
1081 EXPECT_EQ(L"f\x2026", UTF16ToWide(TruncateString(string, 2, 1112 EXPECT_EQ(L"f\x2026", UTF16ToWide(TruncateString(string, 2,
1082 CHARACTER_BREAK))); 1113 CHARACTER_BREAK)));
1083 1114
1084 // Test removes trailing whitespace if break falls between words. 1115 // Test removes trailing whitespace if break falls between words.
1085 EXPECT_EQ(L"foooooey\x2026", UTF16ToWide(TruncateString(string, 12, 1116 EXPECT_EQ(L"foooooey\x2026", UTF16ToWide(TruncateString(string, 12,
1086 CHARACTER_BREAK))); 1117 CHARACTER_BREAK)));
1087 } 1118 }
1088 1119
1089 } // namespace gfx 1120 } // namespace gfx
OLDNEW
« no previous file with comments | « ui/gfx/font_list_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698