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

Side by Side Diff: third_party/WebKit/Source/platform/fonts/ScriptRunIteratorTest.cpp

Issue 2615813003: Migrate WTF::Vector::append() to ::push_back() [part 14 of N] (Closed)
Patch Set: rebase, small fix in FontSettings.h Created 3 years, 11 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 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 #include "platform/fonts/ScriptRunIterator.h" 5 #include "platform/fonts/ScriptRunIterator.h"
6 6
7 #include "testing/gtest/include/gtest/gtest.h" 7 #include "testing/gtest/include/gtest/gtest.h"
8 #include "wtf/Assertions.h" 8 #include "wtf/Assertions.h"
9 #include "wtf/Threading.h" 9 #include "wtf/Threading.h"
10 #include "wtf/text/WTFString.h" 10 #include "wtf/text/WTFString.h"
(...skipping 26 matching lines...) Expand all
37 } 37 }
38 38
39 void getScripts(UChar32 ch, Vector<UScriptCode>& dst) const override { 39 void getScripts(UChar32 ch, Vector<UScriptCode>& dst) const override {
40 ASSERT(ch >= kMockCharMin); 40 ASSERT(ch >= kMockCharMin);
41 ASSERT(ch < kMockCharLimit); 41 ASSERT(ch < kMockCharLimit);
42 42
43 int code = ch - kMockCharMin; 43 int code = ch - kMockCharMin;
44 dst.clear(); 44 dst.clear();
45 switch (code & kCodeSpecialMask) { 45 switch (code & kCodeSpecialMask) {
46 case kCodeSpecialCommon: 46 case kCodeSpecialCommon:
47 dst.append(USCRIPT_COMMON); 47 dst.push_back(USCRIPT_COMMON);
48 break; 48 break;
49 case kCodeSpecialInherited: 49 case kCodeSpecialInherited:
50 dst.append(USCRIPT_INHERITED); 50 dst.push_back(USCRIPT_INHERITED);
51 break; 51 break;
52 default: 52 default:
53 break; 53 break;
54 } 54 }
55 int listBits = kTable[code & kCodeListIndexMask]; 55 int listBits = kTable[code & kCodeListIndexMask];
56 if (dst.isEmpty() && listBits == 0) { 56 if (dst.isEmpty() && listBits == 0) {
57 dst.append(USCRIPT_UNKNOWN); 57 dst.push_back(USCRIPT_UNKNOWN);
58 return; 58 return;
59 } 59 }
60 while (listBits) { 60 while (listBits) {
61 switch (listBits & kListMask) { 61 switch (listBits & kListMask) {
62 case 0: 62 case 0:
63 break; 63 break;
64 case kLatin: 64 case kLatin:
65 dst.append(USCRIPT_LATIN); 65 dst.push_back(USCRIPT_LATIN);
66 break; 66 break;
67 case kHan: 67 case kHan:
68 dst.append(USCRIPT_HAN); 68 dst.push_back(USCRIPT_HAN);
69 break; 69 break;
70 case kGreek: 70 case kGreek:
71 dst.append(USCRIPT_GREEK); 71 dst.push_back(USCRIPT_GREEK);
72 break; 72 break;
73 } 73 }
74 listBits >>= kListShift; 74 listBits >>= kListShift;
75 } 75 }
76 } 76 }
77 77
78 UChar32 getPairedBracket(UChar32 ch) const override { 78 UChar32 getPairedBracket(UChar32 ch) const override {
79 switch (getPairedBracketType(ch)) { 79 switch (getPairedBracketType(ch)) {
80 case PairedBracketType::BracketTypeClose: 80 case PairedBracketType::BracketTypeClose:
81 return ch - kBracketDelta; 81 return ch - kBracketDelta;
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after
285 kGreek3 + kHan2 + kLatin, 285 kGreek3 + kHan2 + kLatin,
286 }; 286 };
287 287
288 class ScriptRunIteratorTest : public testing::Test { 288 class ScriptRunIteratorTest : public testing::Test {
289 protected: 289 protected:
290 void CheckRuns(const Vector<TestRun>& runs) { 290 void CheckRuns(const Vector<TestRun>& runs) {
291 String text(emptyString16Bit()); 291 String text(emptyString16Bit());
292 Vector<ExpectedRun> expect; 292 Vector<ExpectedRun> expect;
293 for (auto& run : runs) { 293 for (auto& run : runs) {
294 text.append(String::fromUTF8(run.text.c_str())); 294 text.append(String::fromUTF8(run.text.c_str()));
295 expect.append(ExpectedRun(text.length(), run.code)); 295 expect.push_back(ExpectedRun(text.length(), run.code));
296 } 296 }
297 ScriptRunIterator scriptRunIterator(text.characters16(), text.length()); 297 ScriptRunIterator scriptRunIterator(text.characters16(), text.length());
298 VerifyRuns(&scriptRunIterator, expect); 298 VerifyRuns(&scriptRunIterator, expect);
299 } 299 }
300 300
301 // FIXME crbug.com/527329 - CheckMockRuns should be replaced by finding 301 // FIXME crbug.com/527329 - CheckMockRuns should be replaced by finding
302 // suitable equivalent real codepoint sequences instead. 302 // suitable equivalent real codepoint sequences instead.
303 void CheckMockRuns(const Vector<TestRun>& runs) { 303 void CheckMockRuns(const Vector<TestRun>& runs) {
304 String text(emptyString16Bit()); 304 String text(emptyString16Bit());
305 Vector<ExpectedRun> expect; 305 Vector<ExpectedRun> expect;
306 for (const TestRun& run : runs) { 306 for (const TestRun& run : runs) {
307 text.append(MockScriptData::ToTestString(run.text)); 307 text.append(MockScriptData::ToTestString(run.text));
308 expect.append(ExpectedRun(text.length(), run.code)); 308 expect.push_back(ExpectedRun(text.length(), run.code));
309 } 309 }
310 310
311 ScriptRunIterator scriptRunIterator(text.characters16(), text.length(), 311 ScriptRunIterator scriptRunIterator(text.characters16(), text.length(),
312 MockScriptData::instance()); 312 MockScriptData::instance());
313 VerifyRuns(&scriptRunIterator, expect); 313 VerifyRuns(&scriptRunIterator, expect);
314 } 314 }
315 315
316 void VerifyRuns(ScriptRunIterator* scriptRunIterator, 316 void VerifyRuns(ScriptRunIterator* scriptRunIterator,
317 const Vector<ExpectedRun>& expect) { 317 const Vector<ExpectedRun>& expect) {
318 unsigned limit; 318 unsigned limit;
(...skipping 360 matching lines...) Expand 10 before | Expand all | Expand 10 after
679 } 679 }
680 } 680 }
681 } 681 }
682 682
683 // ZWJ is \u200D Cf (Format, other) and its script is inherited. I'm going to 683 // ZWJ is \u200D Cf (Format, other) and its script is inherited. I'm going to
684 // ignore this for now, as I think it shouldn't matter which run it ends up 684 // ignore this for now, as I think it shouldn't matter which run it ends up
685 // in. HarfBuzz needs to be able to use it as context and shape each 685 // in. HarfBuzz needs to be able to use it as context and shape each
686 // neighboring character appropriately no matter what run it got assigned to. 686 // neighboring character appropriately no matter what run it got assigned to.
687 687
688 } // namespace blink 688 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698