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