5#include <fuchsia/intl/cpp/fidl.h>
7#include "flutter/fml/icu_util.h"
8#include "gtest/gtest.h"
12using fuchsia::intl::CalendarId;
13using fuchsia::intl::LocaleId;
14using fuchsia::intl::Profile;
15using fuchsia::intl::TemperatureUnit;
16using fuchsia::intl::TimeZoneId;
21class FuchsiaIntlTest :
public testing::Test {
23 static void SetUpTestCase() {
24 testing::Test::SetUpTestCase();
31TEST_F(FuchsiaIntlTest, MakeLocalizationPlatformMessageData_SimpleLocale) {
33 profile.set_locales({LocaleId{.id =
"en-US"}});
34 const std::string expected =
35 R
"({"method":"setLocale","args":["en","US","",""]})";
37 ASSERT_EQ(expected, std::string(actual.GetMapping(),
38 actual.GetMapping() + actual.GetSize()));
41TEST_F(FuchsiaIntlTest, MakeLocalizationPlatformMessageData_OneLocale) {
44 .set_locales({LocaleId{.id =
"en-US-u-ca-gregory-fw-sun-hc-h12-ms-"
45 "ussystem-nu-latn-tz-usnyc"}})
46 .set_calendars({CalendarId{.id =
"und-u-gregory"}})
47 .set_time_zones({TimeZoneId{.id =
"America/New_York"}})
48 .set_temperature_unit(TemperatureUnit::FAHRENHEIT);
49 const std::string expected =
50 R
"({"method":"setLocale","args":["en","US","",""]})";
52 ASSERT_EQ(expected, std::string(actual.GetMapping(),
53 actual.GetMapping() + actual.GetSize()));
56TEST_F(FuchsiaIntlTest, MakeLocalizationPlatformMessageData_MultipleLocales) {
59 .set_locales({LocaleId{.id =
"en-US-u-ca-gregory-fw-sun-hc-h12-ms-"
60 "ussystem-nu-latn-tz-usnyc"},
61 LocaleId{.id =
"sl-Latn-IT-nedis"},
62 LocaleId{.id =
"zh-Hans"}, LocaleId{.id =
"sr-Cyrl-CS"}})
63 .set_calendars({CalendarId{.id =
"und-u-gregory"}})
64 .set_time_zones({TimeZoneId{.id =
"America/New_York"}})
65 .set_temperature_unit(TemperatureUnit::FAHRENHEIT);
66 const std::string expected =
67 R
"({"method":"setLocale","args":["en","US","","","sl","IT","Latn","nedis",)"
68 R"("zh","","Hans","","sr","CS","Cyrl",""]})";
70 ASSERT_EQ(expected, std::string(actual.GetMapping(),
71 actual.GetMapping() + actual.GetSize()));
TEST_F(DisplayListTest, Defaults)
fml::MallocMapping MakeLocalizationPlatformMessageData(const Profile &intl_profile)
void InitializeICU(const std::string &icu_data_path)