OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/text/Hyphenation.h" | 5 #include "platform/text/Hyphenation.h" |
6 | 6 |
7 #include "platform/Logging.h" | 7 #include "platform/Logging.h" |
8 #include "testing/gtest/include/gtest/gtest.h" | 8 #include "testing/gtest/include/gtest/gtest.h" |
9 | 9 |
10 namespace blink { | 10 namespace blink { |
11 | 11 |
12 class NoHyphenation : public Hyphenation { | 12 class NoHyphenation : public Hyphenation { |
13 public: | 13 public: |
14 size_t lastHyphenLocation(const StringView&, size_t beforeIndex, const Atomi
cString& locale) const override | 14 size_t lastHyphenLocation(const StringView&, size_t beforeIndex) const overr
ide |
15 { | 15 { |
16 return 0; | 16 return 0; |
17 } | 17 } |
18 }; | 18 }; |
19 | 19 |
20 TEST(HyphenationTest, GetHyphenation) | 20 TEST(HyphenationTest, GetHyphenation) |
21 { | 21 { |
22 RefPtr<Hyphenation> hyphenation = adoptRef(new NoHyphenation); | 22 RefPtr<Hyphenation> hyphenation = adoptRef(new NoHyphenation); |
23 Hyphenation::setForTesting("en-US", hyphenation); | 23 Hyphenation::setForTesting("en-US", hyphenation); |
24 EXPECT_EQ(hyphenation.get(), Hyphenation::get("en-US")); | 24 EXPECT_EQ(hyphenation.get(), Hyphenation::get("en-US")); |
25 | 25 |
26 Hyphenation::setForTesting("en-UK", nullptr); | 26 Hyphenation::setForTesting("en-UK", nullptr); |
27 EXPECT_EQ(nullptr, Hyphenation::get("en-UK")); | 27 EXPECT_EQ(nullptr, Hyphenation::get("en-UK")); |
28 | 28 |
29 Hyphenation::clearForTesting(); | 29 Hyphenation::clearForTesting(); |
30 } | 30 } |
31 | 31 |
32 TEST(HyphenationTest, GetHyphenationCaseFolding) | 32 TEST(HyphenationTest, GetHyphenationCaseFolding) |
33 { | 33 { |
34 RefPtr<Hyphenation> hyphenation = adoptRef(new NoHyphenation); | 34 RefPtr<Hyphenation> hyphenation = adoptRef(new NoHyphenation); |
35 Hyphenation::setForTesting("en-US", hyphenation); | 35 Hyphenation::setForTesting("en-US", hyphenation); |
36 EXPECT_EQ(hyphenation, Hyphenation::get("en-US")); | 36 EXPECT_EQ(hyphenation, Hyphenation::get("en-US")); |
37 EXPECT_EQ(hyphenation, Hyphenation::get("en-us")); | 37 EXPECT_EQ(hyphenation, Hyphenation::get("en-us")); |
38 | 38 |
39 Hyphenation::clearForTesting(); | 39 Hyphenation::clearForTesting(); |
40 } | 40 } |
41 | 41 |
42 } // namespace blink | 42 } // namespace blink |
OLD | NEW |