| 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/LayoutLocale.h" | 5 #include "platform/LayoutLocale.h" |
| 6 | 6 |
| 7 #include "testing/gtest/include/gtest/gtest.h" | 7 #include "testing/gtest/include/gtest/gtest.h" |
| 8 | 8 |
| 9 namespace blink { | 9 namespace blink { |
| 10 | 10 |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 94 {"en-JP", USCRIPT_LATIN, true, USCRIPT_KATAKANA_OR_HIRAGANA}, | 94 {"en-JP", USCRIPT_LATIN, true, USCRIPT_KATAKANA_OR_HIRAGANA}, |
| 95 {"en-KR", USCRIPT_LATIN, true, USCRIPT_HANGUL}, | 95 {"en-KR", USCRIPT_LATIN, true, USCRIPT_HANGUL}, |
| 96 | 96 |
| 97 // Multiple regions are invalid, but it can still give hints for the font | 97 // Multiple regions are invalid, but it can still give hints for the font |
| 98 // selection. | 98 // selection. |
| 99 {"en-US-JP", USCRIPT_LATIN, true, USCRIPT_KATAKANA_OR_HIRAGANA}, | 99 {"en-US-JP", USCRIPT_LATIN, true, USCRIPT_KATAKANA_OR_HIRAGANA}, |
| 100 }; | 100 }; |
| 101 | 101 |
| 102 for (const auto& test : tests) { | 102 for (const auto& test : tests) { |
| 103 RefPtr<LayoutLocale> locale = LayoutLocale::CreateForTesting(test.locale); | 103 RefPtr<LayoutLocale> locale = LayoutLocale::CreateForTesting(test.locale); |
| 104 EXPECT_EQ(test.script, locale->Script()) << test.locale; | 104 EXPECT_EQ(test.script, locale->GetScript()) << test.locale; |
| 105 EXPECT_EQ(test.has_script_for_han, locale->HasScriptForHan()) | 105 EXPECT_EQ(test.has_script_for_han, locale->HasScriptForHan()) |
| 106 << test.locale; | 106 << test.locale; |
| 107 if (!test.has_script_for_han) | 107 if (!test.has_script_for_han) { |
| 108 EXPECT_EQ(USCRIPT_SIMPLIFIED_HAN, locale->ScriptForHan()) << test.locale; | 108 EXPECT_EQ(USCRIPT_SIMPLIFIED_HAN, locale->GetScriptForHan()) |
| 109 else if (test.script_for_han) | 109 << test.locale; |
| 110 EXPECT_EQ(test.script_for_han, locale->ScriptForHan()) << test.locale; | 110 } else if (test.script_for_han) { |
| 111 else | 111 EXPECT_EQ(test.script_for_han, locale->GetScriptForHan()) << test.locale; |
| 112 EXPECT_EQ(test.script, locale->ScriptForHan()) << test.locale; | 112 } else { |
| 113 EXPECT_EQ(test.script, locale->GetScriptForHan()) << test.locale; |
| 114 } |
| 113 } | 115 } |
| 114 } | 116 } |
| 115 | 117 |
| 116 TEST(LayoutLocaleTest, BreakKeyword) { | 118 TEST(LayoutLocaleTest, BreakKeyword) { |
| 117 struct { | 119 struct { |
| 118 const char* expected; | 120 const char* expected; |
| 119 const char* locale; | 121 const char* locale; |
| 120 LineBreakIteratorMode mode; | 122 LineBreakIteratorMode mode; |
| 121 } tests[] = { | 123 } tests[] = { |
| 122 {nullptr, nullptr, LineBreakIteratorMode::kDefault}, | 124 {nullptr, nullptr, LineBreakIteratorMode::kDefault}, |
| (...skipping 18 matching lines...) Expand all Loading... |
| 141 "en@x=", "en@lb=xyz", "en@ =", | 143 "en@x=", "en@lb=xyz", "en@ =", |
| 142 }; | 144 }; |
| 143 for (const auto& test : tests) { | 145 for (const auto& test : tests) { |
| 144 RefPtr<LayoutLocale> locale = LayoutLocale::CreateForTesting(test); | 146 RefPtr<LayoutLocale> locale = LayoutLocale::CreateForTesting(test); |
| 145 EXPECT_EQ(test, | 147 EXPECT_EQ(test, |
| 146 locale->LocaleWithBreakKeyword(LineBreakIteratorMode::kNormal)); | 148 locale->LocaleWithBreakKeyword(LineBreakIteratorMode::kNormal)); |
| 147 } | 149 } |
| 148 } | 150 } |
| 149 | 151 |
| 150 } // namespace blink | 152 } // namespace blink |
| OLD | NEW |