8 #include "flutter/fml/macros.h"
10 #include "flutter/shell/platform/windows/testing/mock_windows_proc_table.h"
11 #include "gtest/gtest.h"
18 std::vector<LanguageInfo> languages =
21 ASSERT_GE(languages.size(), 1);
23 EXPECT_GE(languages[0].language.size(), 2);
27 MockWindowsProcTable proc_table;
28 EXPECT_CALL(proc_table, GetThreadPreferredUILanguages)
30 [](DWORD flags, PULONG count, PZZWSTR languages, PULONG size) {
32 static const wchar_t lang[] = L
"en-US\0";
33 static const size_t lang_len =
sizeof(lang) /
sizeof(
wchar_t);
34 static const int cnt = 1;
35 if (languages ==
nullptr) {
38 }
else if (*size >= lang_len) {
39 memcpy(languages, lang, lang_len *
sizeof(
wchar_t));
45 ASSERT_GE(languages.size(), 1);
47 EXPECT_FALSE(languages[0].empty());
49 EXPECT_EQ(languages[0].size(), wcslen(languages[0].c_str()));
50 EXPECT_EQ(languages[0], L
"en-US");
53 TEST(SystemUtils, ParseLanguageNameGeneric) {
56 EXPECT_TRUE(info.
region.empty());
57 EXPECT_TRUE(info.
script.empty());
60 TEST(SystemUtils, ParseLanguageNameWithRegion) {
63 EXPECT_EQ(info.
region,
"HU");
64 EXPECT_TRUE(info.
script.empty());
67 TEST(SystemUtils, ParseLanguageNameWithScript) {
70 EXPECT_TRUE(info.
region.empty());
71 EXPECT_EQ(info.
script,
"Latn");
74 TEST(SystemUtils, ParseLanguageNameWithRegionAndScript) {
77 EXPECT_EQ(info.
region,
"UZ");
78 EXPECT_EQ(info.
script,
"Latn");
81 TEST(SystemUtils, ParseLanguageNameWithSuplementalLanguage) {
84 EXPECT_EQ(info.
region,
"US");
85 EXPECT_TRUE(info.
script.empty());
89 TEST(SystemUtils, ParseLanguageNameWithThreeCharacterLanguage) {
92 EXPECT_EQ(info.
region,
"ZZ");
93 EXPECT_TRUE(info.
script.empty());
101 TEST(SystemUtils, Prefer24HourTimeHandlesEmptyFormat) {
105 TEST(SystemUtils, Prefer24HourTimeHandles12Hour) {
109 TEST(SystemUtils, Prefer24HourTimeHandles24Hour) {