@@ -1848,7 +1848,7 @@ TEST_F(ShellTest, CanScheduleFrameFromPlatform) {
18481848 ASSERT_TRUE (shell->IsSetup ());
18491849
18501850 auto configuration = RunConfiguration::InferFromSettings (settings);
1851- configuration.SetEntrypoint (" canScheduleFrameFromPlatform " );
1851+ configuration.SetEntrypoint (" onBeginFrameWithNotifyNativeMain " );
18521852 RunEngine (shell.get (), std::move (configuration));
18531853
18541854 // Wait for the application to attach the listener.
@@ -1861,6 +1861,50 @@ TEST_F(ShellTest, CanScheduleFrameFromPlatform) {
18611861 DestroyShell (std::move (shell), std::move (task_runners));
18621862}
18631863
1864+ TEST_F (ShellTest, SecondaryVsyncCallbackShouldBeCalledAfterVsyncCallback) {
1865+ bool is_on_begin_frame_called = false ;
1866+ bool is_secondary_callback_called = false ;
1867+ Settings settings = CreateSettingsForFixture ();
1868+ TaskRunners task_runners = GetTaskRunnersForFixture ();
1869+ fml::AutoResetWaitableEvent latch;
1870+ AddNativeCallback (
1871+ " NotifyNative" ,
1872+ CREATE_NATIVE_ENTRY ([&](Dart_NativeArguments args) { latch.Signal (); }));
1873+ fml::CountDownLatch count_down_latch (2 );
1874+ AddNativeCallback (" NativeOnBeginFrame" ,
1875+ CREATE_NATIVE_ENTRY ([&](Dart_NativeArguments args) {
1876+ EXPECT_FALSE (is_on_begin_frame_called);
1877+ EXPECT_FALSE (is_secondary_callback_called);
1878+ is_on_begin_frame_called = true ;
1879+ count_down_latch.CountDown ();
1880+ }));
1881+ std::unique_ptr<Shell> shell =
1882+ CreateShell (std::move (settings), std::move (task_runners));
1883+ ASSERT_TRUE (shell->IsSetup ());
1884+
1885+ auto configuration = RunConfiguration::InferFromSettings (settings);
1886+ configuration.SetEntrypoint (" onBeginFrameWithNotifyNativeMain" );
1887+ RunEngine (shell.get (), std::move (configuration));
1888+
1889+ // Wait for the application to attach the listener.
1890+ latch.Wait ();
1891+
1892+ fml::TaskRunner::RunNowOrPostTask (
1893+ shell->GetTaskRunners ().GetUITaskRunner (), [&]() {
1894+ shell->GetEngine ()->ScheduleSecondaryVsyncCallback (0 , [&]() {
1895+ EXPECT_TRUE (is_on_begin_frame_called);
1896+ EXPECT_FALSE (is_secondary_callback_called);
1897+ is_secondary_callback_called = true ;
1898+ count_down_latch.CountDown ();
1899+ });
1900+ shell->GetEngine ()->ScheduleFrame ();
1901+ });
1902+ count_down_latch.Wait ();
1903+ EXPECT_TRUE (is_on_begin_frame_called);
1904+ EXPECT_TRUE (is_secondary_callback_called);
1905+ DestroyShell (std::move (shell), std::move (task_runners));
1906+ }
1907+
18641908static void LogSkData (sk_sp<SkData> data, const char * title) {
18651909 FML_LOG (ERROR ) << " ---------- " << title;
18661910 std::ostringstream ostr;
0 commit comments