25 {
26 auto settings = CreateSettingsForFixture();
27
33 );
34
35 auto message_latch = std::make_shared<fml::AutoResetWaitableEvent>();
36
37 std::unique_ptr<Shell> shell = CreateShell(settings, task_runners);
38 ASSERT_TRUE(shell->IsSetup());
39
40 auto call_hook = [](Dart_NativeArguments
args) {
41 Dart_Handle hook_name = Dart_GetNativeArgument(
args, 0);
43
44 Dart_Handle ui_library = Dart_LookupLibrary(
tonic::ToDart(
"dart:ui"));
46
47 Dart_Handle hook = Dart_GetField(ui_library, hook_name);
49
50 Dart_Handle arg_count_handle = Dart_GetNativeArgument(
args, 1);
52
53 int64_t arg_count;
54 Dart_IntegerToInt64(arg_count_handle, &arg_count);
55
56 std::vector<Dart_Handle> hook_args;
57 for (
int i = 0; i < static_cast<int>(arg_count);
i++) {
58 hook_args.push_back(Dart_GetNativeArgument(
args, 2 +
i));
60 }
61
62 Dart_Handle hook_result =
63 Dart_InvokeClosure(hook, hook_args.size(), hook_args.data());
65 };
66
67 auto finished = [&message_latch](Dart_NativeArguments
args) {
68 message_latch->Signal();
69 };
72
73 auto configuration = RunConfiguration::InferFromSettings(settings);
74 configuration.SetEntrypoint("hooksTests");
75
76 shell->RunEngine(std::move(configuration), [](auto result) {
77 ASSERT_EQ(result, Engine::RunStatus::Success);
78 });
79
80 message_latch->Wait();
81 DestroyShell(std::move(shell), task_runners);
82}
83
84}
85}
86
87
G_BEGIN_DECLS G_MODULE_EXPORT FlValue * args
#define CHECK_DART_ERROR(name)
fml::RefPtr< fml::TaskRunner > CreateNewThread(const std::string &name)
fml::RefPtr< fml::TaskRunner > GetCurrentTaskRunner()
std::string GetCurrentTestName()
Gets the name of the currently running test. This is useful in generating logs or assets based on tes...
Dart_Handle ToDart(const T &object)
#define CREATE_NATIVE_ENTRY(native_entry)