@@ -434,5 +434,52 @@ TEST(SettingsTest, FrameTimingSetsAndGetsProperly) {
434434 }
435435}
436436
437+ #if FLUTTER_RUNTIME_MODE == FLUTTER_RUNTIME_MODE_RELEASE
438+ TEST_F (ShellTest, ReportTimingsIsCalledSoonerInNonReleaseMode) {
439+ #else
440+ TEST_F (ShellTest, ReportTimingsIsCalledLaterInNonReleaseMode) {
441+ #endif
442+ fml::TimePoint start = fml::TimePoint::Now ();
443+ auto settings = CreateSettingsForFixture ();
444+ std::unique_ptr<Shell> shell = CreateShell (std::move (settings));
445+
446+ // Create the surface needed by rasterizer
447+ PlatformViewNotifyCreated (shell.get ());
448+
449+ auto configuration = RunConfiguration::InferFromSettings (settings);
450+ ASSERT_TRUE (configuration.IsValid ());
451+ configuration.SetEntrypoint (" reportTimingsMain" );
452+ fml::AutoResetWaitableEvent reportLatch;
453+ std::vector<int64_t > timestamps;
454+ auto nativeTimingCallback = [&reportLatch,
455+ ×tamps](Dart_NativeArguments args) {
456+ Dart_Handle exception = nullptr ;
457+ timestamps = tonic::DartConverter<std::vector<int64_t >>::FromArguments (
458+ args, 0 , exception);
459+ reportLatch.Signal ();
460+ };
461+ AddNativeCallback (" NativeReportTimingsCallback" ,
462+ CREATE_NATIVE_ENTRY (nativeTimingCallback));
463+ RunEngine (shell.get (), std::move (configuration));
464+
465+ PumpOneFrame (shell.get ());
466+
467+ reportLatch.Wait ();
468+ shell.reset ();
469+
470+ fml::TimePoint finish = fml::TimePoint::Now ();
471+ fml::TimeDelta ellapsed = finish - start;
472+
473+ #if FLUTTER_RUNTIME_MODE == FLUTTER_RUNTIME_MODE_RELEASE
474+ // Our batch time is 1000ms. Hopefully the 800ms limit is relaxed enough to
475+ // make it not too flaky.
476+ ASSERT_TRUE (ellapsed >= fml::TimeDelta::FromMilliseconds (800 ));
477+ #else
478+ // Our batch time is 100ms. Hopefully the 500ms limit is relaxed enough to
479+ // make it not too flaky.
480+ ASSERT_TRUE (ellapsed <= fml::TimeDelta::FromMilliseconds (500 ));
481+ #endif
482+ }
483+
437484} // namespace testing
438485} // namespace flutter
0 commit comments