10#define FML_USED_ON_EMBEDDER
17#include <fuchsia/intl/cpp/fidl.h>
18#include <fuchsia/settings/cpp/fidl.h>
19#include <lib/sys/cpp/component_context.h>
21#include "flutter/fml/logging.h"
22#include "flutter/fml/synchronization/count_down_latch.h"
23#include "flutter/runtime/dart_vm.h"
24#include "flutter/shell/common/shell_test.h"
29using fuchsia::intl::TimeZoneId;
30using fuchsia::settings::Intl_Set_Result;
31using fuchsia::settings::IntlSettings;
55 EXPECT_EQ(status, ZX_OK);
61 fuchsia::settings::IntlSettings
settings;
62 settings.set_time_zone_id(TimeZoneId{.id = timezone_name});
65 ASSERT_EQ(status, ZX_OK);
69 const time_t timestamp =
time(
nullptr);
70 const struct tm* local_time = localtime(×tamp);
71 EXPECT_NE(local_time,
nullptr)
72 <<
"Could not get local time: errno=" << errno <<
": "
74 return std::string(local_time->tm_zone);
78 const time_t timestamp =
time(
nullptr);
79 const struct tm* local_time = localtime(×tamp);
80 EXPECT_NE(local_time,
nullptr)
81 <<
"Could not get local time: errno=" << errno <<
": "
83 char buffer[
sizeof(
"2020-08-26 14")];
85 strftime(
buffer,
sizeof(
buffer),
"%Y-%m-%d %H", local_time);
87 return std::string(
buffer);
93 ASSERT_EQ(expected,
settings.time_zone_id().id);
96 std::unique_ptr<sys::ComponentContext>
ctx_;
97 fuchsia::settings::IntlSyncPtr
intl_;
109 if (!
shell->IsSetup()) {
118 shell->GetTaskRunners().GetPlatformTaskRunner(), [
shell, &latch]() {
119 shell->GetPlatformView()->NotifyDestroyed();
134static void RunCoroutineWithRetry(
int retries,
138 for (; retries > 0; retries--) {
145 FML_LOG(INFO) <<
"Retries left: " << retries;
167#if defined(OS_FUCHSIA)
169 <<
"This test fails after the CF V2 migration. https://fxbug.dev/110019 ";
175 std::string dart_isolate_time_str;
177 dart_isolate_time_str =
184 bool continue_fixture =
true;
188 fixture_latch.
Wait();
190 args, continue_fixture);
193 auto settings = CreateSettingsForFixture();
195 configuration.SetEntrypoint(
"timezonesChange");
198 ASSERT_NE(
shell.get(),
nullptr);
200 RunEngine(
shell.get(), std::move(configuration));
205 SetTimezone(GetLocalTimezone());
206 AssertTimezone(GetLocalTimezone(), GetSettings());
207 std::string expected = GetLocalTime();
208 std::string actual =
"undefined";
209 RunCoroutineWithRetry(10, &fixture_latch, &latch, [&]() {
210 actual = dart_isolate_time_str;
211 FML_LOG(INFO) <<
"reference: " << expected <<
", actual: " << actual;
212 return expected == actual;
214 ASSERT_EQ(expected, actual)
215 <<
"The Dart isolate was expected to show the same time as the test "
216 <<
"fixture eventually, but that didn't happen after multiple retries.";
219 SetTimezone(
"America/New_York");
220 AssertTimezone(
"America/New_York", GetSettings());
221 RunCoroutineWithRetry(10, &fixture_latch, &latch, [&]() {
222 actual = dart_isolate_time_str;
223 FML_LOG(INFO) <<
"reference: " << expected <<
", actual: " << actual;
224 return expected != actual;
226 ASSERT_NE(expected, actual)
227 <<
"The Dart isolate was expected to show a time different from the test "
228 <<
"fixture eventually, but that didn't happen after multiple retries.";
232 SetTimezone(
"Europe/Amsterdam");
233 AssertTimezone(
"Europe/Amsterdam", GetSettings());
234 RunCoroutineWithRetry(10, &fixture_latch, &latch, [&]() {
235 actual = dart_isolate_time_str;
236 FML_LOG(INFO) <<
"reference: " << expected <<
", actual: " << actual;
237 return expected != actual;
239 ASSERT_NE(expected, actual)
240 <<
"The Dart isolate was expected to show a time different from the "
241 <<
"prior timezone eventually, but that didn't happen after multiple "
246 SetTimezone(
"America/New_York");
247 AssertTimezone(
"America/New_York", GetSettings());
248 RunCoroutineWithRetry(10, &fixture_latch, &latch, [&]() {
249 actual = dart_isolate_time_str;
250 FML_LOG(INFO) <<
"reference: " << expected <<
", actual: " << actual;
251 return expected != actual;
253 ASSERT_NE(expected, actual)
254 <<
"The Dart isolate was expected to show a time different from the "
255 <<
"prior timezone eventually, but that didn't happen after multiple "
260 continue_fixture =
false;
262 DestroyShell(std::move(
shell));
static RunConfiguration InferFromSettings(const Settings &settings, const fml::RefPtr< fml::TaskRunner > &io_worker=nullptr, IsolateLaunchType launch_type=IsolateLaunchType::kNewGroup)
Attempts to infer a run configuration from the settings object. This tries to create a run configurat...
std::string GetLocalTime()
void SetTimezone(const std::string &timezone_name)
fuchsia::settings::IntlSettings save_settings_
void AssertTimezone(const std::string &expected, const IntlSettings &settings)
std::unique_ptr< sys::ComponentContext > ctx_
fuchsia::settings::IntlSyncPtr intl_
IntlSettings GetSettings()
std::string GetLocalTimezone()
static void PlatformViewNotifyCreated(Shell *shell)
static void RunNowOrPostTask(const fml::RefPtr< fml::TaskRunner > &runner, const fml::closure &task)
DART_EXPORT Dart_Handle Dart_GetNativeArgument(Dart_NativeArguments args, int index)
G_BEGIN_DECLS G_MODULE_EXPORT FlValue * args
#define FML_LOG(severity)
Dart_NativeFunction function
sys::ComponentContext * ComponentContext()
TEST_F(DisplayListTest, Defaults)
static bool ValidateShell(Shell *shell)
DEF_SWITCHES_START aot vmservice shared library Name of the *so containing AOT compiled Dart assets for launching the service isolate vm snapshot The VM snapshot data that will be memory mapped as read only SnapshotAssetPath must be present isolate snapshot The isolate snapshot data that will be memory mapped as read only SnapshotAssetPath must be present cache dir Path to the cache directory This is different from the persistent_cache_path in embedder which is used for Skia shader cache icu native lib Path to the library file that exports the ICU data vm service The hostname IP address on which the Dart VM Service should be served If not defaults to or::depending on whether ipv6 is specified vm service A custom Dart VM Service port The default is to pick a randomly available open port disable vm Disable the Dart VM Service The Dart VM Service is never available in release mode disable vm service Disable mDNS Dart VM Service publication Bind to the IPv6 localhost address for the Dart VM Service Ignored if vm service host is set endless trace buffer
static double time(int loops, Benchmark *bench, Target *target)
#define CREATE_NATIVE_ENTRY(native_entry)