Skip to content

Commit

Permalink
Verify boolean in callbacks
Browse files Browse the repository at this point in the history
  • Loading branch information
dkwingsmt committed Sep 8, 2023
1 parent 6bf8fd4 commit f3baa41
Showing 1 changed file with 14 additions and 15 deletions.
29 changes: 14 additions & 15 deletions lib/ui/window/platform_configuration_unittests.cc
Original file line number Diff line number Diff line change
Expand Up @@ -505,16 +505,15 @@ TEST_F(PlatformConfigurationTest, OutOfScopeRenderCallsTriggersAssertion) {
// Render should not be called.
EXPECT_CALL(client, Render).Times(0);

bool unfulfilled_assertion = true;
auto finish_latch = std::make_shared<fml::AutoResetWaitableEvent>();
AddNativeCallback(
"ReportBoolResult",
CREATE_NATIVE_ENTRY(
([finish_latch, &unfulfilled_assertion](Dart_NativeArguments args) {
unfulfilled_assertion = tonic::DartConverter<bool>::FromDart(
Dart_GetNativeArgument(args, 0));
finish_latch->Signal();
})));
CREATE_NATIVE_ENTRY(([finish_latch](Dart_NativeArguments args) {
bool unfulfilled_assertion = tonic::DartConverter<bool>::FromDart(
Dart_GetNativeArgument(args, 0));
ASSERT_FALSE(unfulfilled_assertion);
finish_latch->Signal();
})));

auto runtime_controller_context =
RuntimeControllerContext::Create(settings, task_runners, client);
Expand All @@ -532,7 +531,6 @@ TEST_F(PlatformConfigurationTest, OutOfScopeRenderCallsTriggersAssertion) {

// Wait for the Dart main function to end.
finish_latch->Wait();
ASSERT_FALSE(unfulfilled_assertion);
}

TEST_F(PlatformConfigurationTest, DuplicateRenderCallsTriggersAssertion) {
Expand All @@ -553,14 +551,15 @@ TEST_F(PlatformConfigurationTest, DuplicateRenderCallsTriggersAssertion) {
finish_latch->Signal();
})));

bool unfulfilled_assertion = true;
auto verify_latch = std::make_shared<fml::AutoResetWaitableEvent>();
AddNativeCallback(
"ReportBoolResult",
CREATE_NATIVE_ENTRY(
([finish_latch, &unfulfilled_assertion](Dart_NativeArguments args) {
unfulfilled_assertion = tonic::DartConverter<bool>::FromDart(
Dart_GetNativeArgument(args, 0));
})));
CREATE_NATIVE_ENTRY(([verify_latch](Dart_NativeArguments args) {
bool unfulfilled_assertion = tonic::DartConverter<bool>::FromDart(
Dart_GetNativeArgument(args, 0));
ASSERT_FALSE(unfulfilled_assertion);
verify_latch->Signal();
})));

auto runtime_controller_context =
RuntimeControllerContext::Create(settings, task_runners, client);
Expand All @@ -585,7 +584,7 @@ TEST_F(PlatformConfigurationTest, DuplicateRenderCallsTriggersAssertion) {
[](RuntimeController& runtime_controller) {
runtime_controller.BeginFrame(fml::TimePoint::Now(), 0);
});
ASSERT_FALSE(unfulfilled_assertion);
verify_latch->Wait();
}

} // namespace testing
Expand Down

0 comments on commit f3baa41

Please sign in to comment.