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

Unified Diff: third_party/WebKit/Source/platform/fonts/AcceptLanguagesResolverTest.cpp

Issue 1693563003: Take Accept-Language into account in CJK font fallback for Android/Win (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@aceept-lang
Patch Set: Fix non-Windows builds Created 4 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/platform/fonts/AcceptLanguagesResolverTest.cpp
diff --git a/third_party/WebKit/Source/platform/fonts/AcceptLanguagesResolverTest.cpp b/third_party/WebKit/Source/platform/fonts/AcceptLanguagesResolverTest.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..94f636ea060aced4948f79379f07dcf7b46e6f36
--- /dev/null
+++ b/third_party/WebKit/Source/platform/fonts/AcceptLanguagesResolverTest.cpp
@@ -0,0 +1,53 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "platform/fonts/AcceptLanguagesResolver.h"
+
+#include "testing/gtest/include/gtest/gtest.h"
+
+namespace blink {
+
+TEST(AcceptLanguagesResolverTest, AcceptLanguagesChanged)
+{
+ struct {
+ const char* acceptLanguages;
+ UScriptCode script;
+ const char* locale;
+ } tests[] = {
+ // Non-Han script cases.
+ { "", USCRIPT_COMMON, nullptr },
+ { "en-US", USCRIPT_COMMON, nullptr },
+ { ",en-US", USCRIPT_COMMON, nullptr },
+
+ // Single value cases.
+ { "ja-JP", USCRIPT_KATAKANA_OR_HIRAGANA, "ja-jp" },
+ { "ko-KR", USCRIPT_HANGUL, "ko-kr" },
+ { "zh-CN", USCRIPT_SIMPLIFIED_HAN, "zh-Hans" },
+ { "zh-HK", USCRIPT_TRADITIONAL_HAN, "zh-Hant" },
+ { "zh-TW", USCRIPT_TRADITIONAL_HAN, "zh-Hant" },
+
+ // Unusual combinations.
+ { "en-JP", USCRIPT_KATAKANA_OR_HIRAGANA, "ja-jp" },
+
+ // Han scripts not in the first item.
+ { "en-US,ja-JP", USCRIPT_KATAKANA_OR_HIRAGANA, "ja-jp" },
+ { "en-US,en-JP", USCRIPT_KATAKANA_OR_HIRAGANA, "ja-jp" },
+
+ // Multiple Han scripts. The first one wins.
+ { "ja-JP,zh-CN", USCRIPT_KATAKANA_OR_HIRAGANA, "ja-jp" },
+ { "zh-TW,ja-JP", USCRIPT_TRADITIONAL_HAN, "zh-Hant" },
+ };
+
+ for (auto& test : tests) {
+ AcceptLanguagesResolver::updateFromAcceptLanguages(test.acceptLanguages);
+
+ EXPECT_EQ(test.script, AcceptLanguagesResolver::preferredHanScript())
+ << test.acceptLanguages;
+ EXPECT_STREQ(test.locale,
+ AcceptLanguagesResolver::preferredHanSkFontMgrLocale())
+ << test.acceptLanguages;
+ }
+}
+
+} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698