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

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

Issue 2668903003: Replace WTF::emptyString{16Bit}() with a static global (Closed)
Patch Set: Replace WTF::emptyString{16Bit}() with a static global Created 3 years, 10 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/SymbolsIterator.h" 5 #include "platform/fonts/SymbolsIterator.h"
6 6
7 #include "testing/gtest/include/gtest/gtest.h" 7 #include "testing/gtest/include/gtest/gtest.h"
8 #include <string> 8 #include <string>
9 9
10 namespace blink { 10 namespace blink {
11 11
12 struct TestRun { 12 struct TestRun {
13 std::string text; 13 std::string text;
14 FontFallbackPriority fontFallbackPriority; 14 FontFallbackPriority fontFallbackPriority;
15 }; 15 };
16 16
17 struct ExpectedRun { 17 struct ExpectedRun {
18 unsigned limit; 18 unsigned limit;
19 FontFallbackPriority fontFallbackPriority; 19 FontFallbackPriority fontFallbackPriority;
20 20
21 ExpectedRun(unsigned theLimit, FontFallbackPriority theFontFallbackPriority) 21 ExpectedRun(unsigned theLimit, FontFallbackPriority theFontFallbackPriority)
22 : limit(theLimit), fontFallbackPriority(theFontFallbackPriority) {} 22 : limit(theLimit), fontFallbackPriority(theFontFallbackPriority) {}
23 }; 23 };
24 24
25 class SymbolsIteratorTest : public testing::Test { 25 class SymbolsIteratorTest : public testing::Test {
26 protected: 26 protected:
27 void CheckRuns(const Vector<TestRun>& runs) { 27 void CheckRuns(const Vector<TestRun>& runs) {
28 String text(emptyString16Bit()); 28 String text(emptyString16Bit);
29 Vector<ExpectedRun> expect; 29 Vector<ExpectedRun> expect;
30 for (auto& run : runs) { 30 for (auto& run : runs) {
31 text.append(String::fromUTF8(run.text.c_str())); 31 text.append(String::fromUTF8(run.text.c_str()));
32 expect.push_back(ExpectedRun(text.length(), run.fontFallbackPriority)); 32 expect.push_back(ExpectedRun(text.length(), run.fontFallbackPriority));
33 } 33 }
34 SymbolsIterator symbolsIterator(text.characters16(), text.length()); 34 SymbolsIterator symbolsIterator(text.characters16(), text.length());
35 VerifyRuns(&symbolsIterator, expect); 35 VerifyRuns(&symbolsIterator, expect);
36 } 36 }
37 37
38 void VerifyRuns(SymbolsIterator* symbolsIterator, 38 void VerifyRuns(SymbolsIterator* symbolsIterator,
(...skipping 15 matching lines...) Expand all
54 #define DECLARE_RUNSVECTOR(...) \ 54 #define DECLARE_RUNSVECTOR(...) \
55 static const TestRun runsArray[] = __VA_ARGS__; \ 55 static const TestRun runsArray[] = __VA_ARGS__; \
56 Vector<TestRun> runs; \ 56 Vector<TestRun> runs; \
57 runs.append(runsArray, sizeof(runsArray) / sizeof(*runsArray)); 57 runs.append(runsArray, sizeof(runsArray) / sizeof(*runsArray));
58 58
59 #define CHECK_RUNS(...) \ 59 #define CHECK_RUNS(...) \
60 DECLARE_RUNSVECTOR(__VA_ARGS__); \ 60 DECLARE_RUNSVECTOR(__VA_ARGS__); \
61 CheckRuns(runs); 61 CheckRuns(runs);
62 62
63 TEST_F(SymbolsIteratorTest, Empty) { 63 TEST_F(SymbolsIteratorTest, Empty) {
64 String empty(emptyString16Bit()); 64 String empty(emptyString16Bit);
65 SymbolsIterator symbolsIterator(empty.characters16(), empty.length()); 65 SymbolsIterator symbolsIterator(empty.characters16(), empty.length());
66 unsigned limit = 0; 66 unsigned limit = 0;
67 FontFallbackPriority symbolsFont = FontFallbackPriority::Invalid; 67 FontFallbackPriority symbolsFont = FontFallbackPriority::Invalid;
68 ASSERT(!symbolsIterator.consume(&limit, &symbolsFont)); 68 ASSERT(!symbolsIterator.consume(&limit, &symbolsFont));
69 ASSERT_EQ(limit, 0u); 69 ASSERT_EQ(limit, 0u);
70 ASSERT_EQ(symbolsFont, FontFallbackPriority::Invalid); 70 ASSERT_EQ(symbolsFont, FontFallbackPriority::Invalid);
71 } 71 }
72 72
73 TEST_F(SymbolsIteratorTest, Space) { 73 TEST_F(SymbolsIteratorTest, Space) {
74 CHECK_RUNS({{" ", FontFallbackPriority::Text}}); 74 CHECK_RUNS({{" ", FontFallbackPriority::Text}});
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
206 TEST_F(SymbolsIteratorTest, Arrows) { 206 TEST_F(SymbolsIteratorTest, Arrows) {
207 CHECK_RUNS({{"x→←x←↑↓→", FontFallbackPriority::Text}}); 207 CHECK_RUNS({{"x→←x←↑↓→", FontFallbackPriority::Text}});
208 } 208 }
209 209
210 TEST_F(SymbolsIteratorTest, JudgePilot) { 210 TEST_F(SymbolsIteratorTest, JudgePilot) {
211 CHECK_RUNS({{"👨‍⚖️👩‍⚖️👨🏼‍⚖️👩🏼‍⚖️", 211 CHECK_RUNS({{"👨‍⚖️👩‍⚖️👨🏼‍⚖️👩🏼‍⚖️",
212 FontFallbackPriority::EmojiEmoji}}); 212 FontFallbackPriority::EmojiEmoji}});
213 } 213 }
214 214
215 } // namespace blink 215 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698