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

Side by Side Diff: third_party/WebKit/Source/platform/text/BidiResolverTest.cpp

Issue 2385283002: reflow comments in platform/{testing,text} (Closed)
Patch Set: idunnolol Created 4 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2013 Google Inc. All rights reserved. 2 * Copyright (C) 2013 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 bool hasStrongDirectionality; 71 bool hasStrongDirectionality;
72 String data(entry.text, entry.length); 72 String data(entry.text, entry.length);
73 TextRun run(data); 73 TextRun run(data);
74 TextDirection direction = 74 TextDirection direction =
75 determineParagraphDirectionality(run, &hasStrongDirectionality); 75 determineParagraphDirectionality(run, &hasStrongDirectionality);
76 EXPECT_EQ(entry.expectedStrong, hasStrongDirectionality); 76 EXPECT_EQ(entry.expectedStrong, hasStrongDirectionality);
77 EXPECT_EQ(entry.expectedDirection, direction); 77 EXPECT_EQ(entry.expectedDirection, direction);
78 } 78 }
79 79
80 TEST(BidiResolver, ParagraphDirectionSurrogates) { 80 TEST(BidiResolver, ParagraphDirectionSurrogates) {
81 const TestData testData[] = { 81 const TestData testData[] = {// Test strong RTL, non-BMP. (U+10858 Imperial
82 // Test strong RTL, non-BMP. (U+10858 Imperial Aramaic number one, strong RTL) 82 // Aramaic number one, strong RTL)
83 {{0xD802, 0xDC58}, 2, RTL, true}, 83 {{0xD802, 0xDC58}, 2, RTL, true},
84 84
85 // Test strong LTR, non-BMP. (U+1D15F Musical symbol quarter note, strong LTR) 85 // Test strong LTR, non-BMP. (U+1D15F Musical
86 {{0xD834, 0xDD5F}, 2, LTR, true}, 86 // symbol quarter note, strong LTR)
87 {{0xD834, 0xDD5F}, 2, LTR, true},
87 88
88 // Test broken surrogate: valid leading, invalid trail. (Lead of U+10858, space) 89 // Test broken surrogate: valid leading, invalid
89 {{0xD802, ' '}, 2, LTR, false}, 90 // trail. (Lead of U+10858, space)
91 {{0xD802, ' '}, 2, LTR, false},
90 92
91 // Test broken surrogate: invalid leading. (Trail of U+10858, U+05D0 Hebre w Alef) 93 // Test broken surrogate: invalid leading. (Trail
92 {{0xDC58, 0x05D0}, 2, RTL, true}, 94 // of U+10858, U+05D0 Hebrew Alef)
95 {{0xDC58, 0x05D0}, 2, RTL, true},
93 96
94 // Test broken surrogate: valid leading, invalid trail/valid lead, valid t rail. 97 // Test broken surrogate: valid leading, invalid
95 {{0xD802, 0xD802, 0xDC58}, 3, RTL, true}, 98 // trail/valid lead, valid trail.
99 {{0xD802, 0xD802, 0xDC58}, 3, RTL, true},
96 100
97 // Test broken surrogate: valid leading, no trail (string too short). (Lea d of U+10858) 101 // Test broken surrogate: valid leading, no trail
98 {{0xD802, 0xDC58}, 1, LTR, false}, 102 // (string too short). (Lead of U+10858)
103 {{0xD802, 0xDC58}, 1, LTR, false},
99 104
100 // Test broken surrogate: trail appearing before lead. (U+10858 units reve rsed) 105 // Test broken surrogate: trail appearing before
101 {{0xDC58, 0xD802}, 2, LTR, false}}; 106 // lead. (U+10858 units reversed)
107 {{0xDC58, 0xD802}, 2, LTR, false}};
102 for (size_t i = 0; i < WTF_ARRAY_LENGTH(testData); ++i) 108 for (size_t i = 0; i < WTF_ARRAY_LENGTH(testData); ++i)
103 testDirectionality(testData[i]); 109 testDirectionality(testData[i]);
104 } 110 }
105 111
106 class BidiTestRunner { 112 class BidiTestRunner {
107 public: 113 public:
108 BidiTestRunner() 114 BidiTestRunner()
109 : m_testsRun(0), 115 : m_testsRun(0),
110 m_testsSkipped(0), 116 m_testsSkipped(0),
111 m_ignoredCharFailures(0), 117 m_ignoredCharFailures(0),
(...skipping 12 matching lines...) Expand all
124 size_t m_testsRun; 130 size_t m_testsRun;
125 size_t m_testsSkipped; 131 size_t m_testsSkipped;
126 std::set<UChar> m_skippedCodePoints; 132 std::set<UChar> m_skippedCodePoints;
127 size_t m_ignoredCharFailures; 133 size_t m_ignoredCharFailures;
128 size_t m_levelFailures; 134 size_t m_levelFailures;
129 size_t m_orderFailures; 135 size_t m_orderFailures;
130 }; 136 };
131 137
132 // Blink's UBA does not filter out control characters, etc. Maybe it should? 138 // Blink's UBA does not filter out control characters, etc. Maybe it should?
133 // Instead it depends on later layers of Blink to simply ignore them. 139 // Instead it depends on later layers of Blink to simply ignore them.
134 // This function helps us emulate that to be compatible with BidiTest.txt expect ations. 140 // This function helps us emulate that to be compatible with BidiTest.txt
141 // expectations.
135 static bool isNonRenderedCodePoint(UChar c) { 142 static bool isNonRenderedCodePoint(UChar c) {
136 // The tests also expect us to ignore soft-hyphen. 143 // The tests also expect us to ignore soft-hyphen.
137 if (c == 0xAD) 144 if (c == 0xAD)
138 return true; 145 return true;
139 // Control characters are not rendered: 146 // Control characters are not rendered:
140 return c >= 0x202A && c <= 0x202E; 147 return c >= 0x202A && c <= 0x202E;
141 // But it seems to expect LRI, etc. to be rendered!? 148 // But it seems to expect LRI, etc. to be rendered!?
142 } 149 }
143 150
144 std::string diffString(const std::vector<int>& actual, 151 std::string diffString(const std::vector<int>& actual,
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
194 std::ostringstream errorContext; 201 std::ostringstream errorContext;
195 errorContext << ", line " << lineNumber << " \"" << line << "\""; 202 errorContext << ", line " << lineNumber << " \"" << line << "\"";
196 errorContext << " context: " 203 errorContext << " context: "
197 << bidi_test::nameFromParagraphDirection(paragraphDirection); 204 << bidi_test::nameFromParagraphDirection(paragraphDirection);
198 205
199 std::vector<int> actualOrder; 206 std::vector<int> actualOrder;
200 std::vector<int> actualLevels; 207 std::vector<int> actualLevels;
201 actualLevels.assign(input.size(), -1); 208 actualLevels.assign(input.size(), -1);
202 BidiCharacterRun* run = runs.firstRun(); 209 BidiCharacterRun* run = runs.firstRun();
203 while (run) { 210 while (run) {
204 // Blink's UBA just makes runs, the actual ordering of the display of charac ters 211 // Blink's UBA just makes runs, the actual ordering of the display of
205 // is handled later in our pipeline, so we fake it here: 212 // characters is handled later in our pipeline, so we fake it here:
206 bool reversed = run->reversed(false); 213 bool reversed = run->reversed(false);
207 ASSERT(run->stop() >= run->start()); 214 ASSERT(run->stop() >= run->start());
208 size_t length = run->stop() - run->start(); 215 size_t length = run->stop() - run->start();
209 for (size_t i = 0; i < length; i++) { 216 for (size_t i = 0; i < length; i++) {
210 int inputIndex = reversed ? run->stop() - i - 1 : run->start() + i; 217 int inputIndex = reversed ? run->stop() - i - 1 : run->start() + i;
211 if (!isNonRenderedCodePoint(input[inputIndex])) 218 if (!isNonRenderedCodePoint(input[inputIndex]))
212 actualOrder.push_back(inputIndex); 219 actualOrder.push_back(inputIndex);
213 // BidiTest.txt gives expected level data in the order of the original inp ut. 220 // BidiTest.txt gives expected level data in the order of the original
221 // input.
214 actualLevels[inputIndex] = run->level(); 222 actualLevels[inputIndex] = run->level();
215 } 223 }
216 run = run->next(); 224 run = run->next();
217 } 225 }
218 226
219 if (expectedOrder.size() != actualOrder.size()) { 227 if (expectedOrder.size() != actualOrder.size()) {
220 m_ignoredCharFailures++; 228 m_ignoredCharFailures++;
221 EXPECT_EQ(expectedOrder.size(), actualOrder.size()) << errorContext.str(); 229 EXPECT_EQ(expectedOrder.size(), actualOrder.size()) << errorContext.str();
222 } else if (expectedOrder != actualOrder) { 230 } else if (expectedOrder != actualOrder) {
223 m_orderFailures++; 231 m_orderFailures++;
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
283 // The unittest harness only pays attention to GTest output, so we verify 291 // The unittest harness only pays attention to GTest output, so we verify
284 // that the tests behaved as expected: 292 // that the tests behaved as expected:
285 EXPECT_EQ(352098u, runner.m_testsRun); 293 EXPECT_EQ(352098u, runner.m_testsRun);
286 EXPECT_EQ(418143u, runner.m_testsSkipped); 294 EXPECT_EQ(418143u, runner.m_testsSkipped);
287 EXPECT_EQ(0u, runner.m_ignoredCharFailures); 295 EXPECT_EQ(0u, runner.m_ignoredCharFailures);
288 EXPECT_EQ(44882u, runner.m_levelFailures); 296 EXPECT_EQ(44882u, runner.m_levelFailures);
289 EXPECT_EQ(19151u, runner.m_orderFailures); 297 EXPECT_EQ(19151u, runner.m_orderFailures);
290 } 298 }
291 299
292 } // namespace blink 300 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/platform/text/BidiResolver.h ('k') | third_party/WebKit/Source/platform/text/BidiTestHarness.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698