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

Side by Side Diff: third_party/WebKit/Source/platform/fonts/OrientationIteratorTest.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/OrientationIterator.h" 5 #include "platform/fonts/OrientationIterator.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 OrientationIterator::RenderOrientation code; 14 OrientationIterator::RenderOrientation code;
15 }; 15 };
16 16
17 struct ExpectedRun { 17 struct ExpectedRun {
18 unsigned limit; 18 unsigned limit;
19 OrientationIterator::RenderOrientation renderOrientation; 19 OrientationIterator::RenderOrientation renderOrientation;
20 20
21 ExpectedRun(unsigned theLimit, 21 ExpectedRun(unsigned theLimit,
22 OrientationIterator::RenderOrientation theRenderOrientation) 22 OrientationIterator::RenderOrientation theRenderOrientation)
23 : limit(theLimit), renderOrientation(theRenderOrientation) {} 23 : limit(theLimit), renderOrientation(theRenderOrientation) {}
24 }; 24 };
25 25
26 class OrientationIteratorTest : public testing::Test { 26 class OrientationIteratorTest : public testing::Test {
27 protected: 27 protected:
28 void CheckRuns(const Vector<TestRun>& runs) { 28 void CheckRuns(const Vector<TestRun>& runs) {
29 String text(emptyString16Bit()); 29 String text(emptyString16Bit);
30 Vector<ExpectedRun> expect; 30 Vector<ExpectedRun> expect;
31 for (auto& run : runs) { 31 for (auto& run : runs) {
32 text.append(String::fromUTF8(run.text.c_str())); 32 text.append(String::fromUTF8(run.text.c_str()));
33 expect.push_back(ExpectedRun(text.length(), run.code)); 33 expect.push_back(ExpectedRun(text.length(), run.code));
34 } 34 }
35 OrientationIterator orientationIterator(text.characters16(), text.length(), 35 OrientationIterator orientationIterator(text.characters16(), text.length(),
36 FontOrientation::VerticalMixed); 36 FontOrientation::VerticalMixed);
37 VerifyRuns(&orientationIterator, expect); 37 VerifyRuns(&orientationIterator, expect);
38 } 38 }
39 39
(...skipping 13 matching lines...) Expand all
53 }; 53 };
54 54
55 // TODO(esprehn): WTF::Vector should allow initialization from a literal. 55 // TODO(esprehn): WTF::Vector should allow initialization from a literal.
56 #define CHECK_RUNS(...) \ 56 #define CHECK_RUNS(...) \
57 static const TestRun runsArray[] = __VA_ARGS__; \ 57 static const TestRun runsArray[] = __VA_ARGS__; \
58 Vector<TestRun> runs; \ 58 Vector<TestRun> runs; \
59 runs.append(runsArray, sizeof(runsArray) / sizeof(*runsArray)); \ 59 runs.append(runsArray, sizeof(runsArray) / sizeof(*runsArray)); \
60 CheckRuns(runs); 60 CheckRuns(runs);
61 61
62 TEST_F(OrientationIteratorTest, Empty) { 62 TEST_F(OrientationIteratorTest, Empty) {
63 String empty(emptyString16Bit()); 63 String empty(emptyString16Bit);
64 OrientationIterator orientationIterator(empty.characters16(), empty.length(), 64 OrientationIterator orientationIterator(empty.characters16(), empty.length(),
65 FontOrientation::VerticalMixed); 65 FontOrientation::VerticalMixed);
66 unsigned limit = 0; 66 unsigned limit = 0;
67 OrientationIterator::RenderOrientation orientation = 67 OrientationIterator::RenderOrientation orientation =
68 OrientationIterator::OrientationInvalid; 68 OrientationIterator::OrientationInvalid;
69 ASSERT(!orientationIterator.consume(&limit, &orientation)); 69 ASSERT(!orientationIterator.consume(&limit, &orientation));
70 ASSERT_EQ(limit, 0u); 70 ASSERT_EQ(limit, 0u);
71 ASSERT_EQ(orientation, OrientationIterator::OrientationInvalid); 71 ASSERT_EQ(orientation, OrientationIterator::OrientationInvalid);
72 } 72 }
73 73
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 CHECK_RUNS({{"Abc", OrientationIterator::OrientationRotateSideways}, 154 CHECK_RUNS({{"Abc", OrientationIterator::OrientationRotateSideways},
155 {"ほへと", OrientationIterator::OrientationKeep}, 155 {"ほへと", OrientationIterator::OrientationKeep},
156 {"Xyz", OrientationIterator::OrientationRotateSideways}}); 156 {"Xyz", OrientationIterator::OrientationRotateSideways}});
157 } 157 }
158 158
159 TEST_F(OrientationIteratorTest, JapaneseMahjonggMixed) { 159 TEST_F(OrientationIteratorTest, JapaneseMahjonggMixed) {
160 CHECK_RUNS({{"いろはに🀤ほへと", OrientationIterator::OrientationKeep}}); 160 CHECK_RUNS({{"いろはに🀤ほへと", OrientationIterator::OrientationKeep}});
161 } 161 }
162 162
163 } // namespace blink 163 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698