@@ -120,7 +120,7 @@ class MockRuntimeDelegate : public RuntimeDelegate {
120120 public:
121121 MOCK_METHOD (std::string, DefaultRouteName, (), (override ));
122122 MOCK_METHOD (void , ScheduleFrame, (bool ), (override ));
123- MOCK_METHOD (void , EndWarmUpFrame , (), (override ));
123+ MOCK_METHOD (void , OnAllViewsRendered , (), (override ));
124124 MOCK_METHOD (void ,
125125 Render,
126126 (int64_t , std::unique_ptr<flutter::LayerTree>, float ),
@@ -679,6 +679,64 @@ TEST_F(EngineTest, AnimatorAcceptsMultipleRenders) {
679679 draw_latch.Wait ();
680680}
681681
682+ TEST_F (EngineTest, AnimatorSubmitsSingleViewBeforeDrawFrameEnds) {
683+ MockAnimatorDelegate animator_delegate;
684+ std::unique_ptr<EngineContext> engine_context;
685+
686+ std::shared_ptr<PlatformMessageHandler> platform_message_handler =
687+ std::make_shared<MockPlatformMessageHandler>();
688+ EXPECT_CALL (delegate_, GetPlatformMessageHandler)
689+ .WillOnce (ReturnRef (platform_message_handler));
690+
691+ static bool rasterization_started = false ;
692+ EXPECT_CALL (animator_delegate, OnAnimatorDraw)
693+ .WillOnce (Invoke ([](const std::shared_ptr<FramePipeline>& pipeline) {
694+ rasterization_started = true ;
695+ auto status = pipeline->Consume ([&](std::unique_ptr<FrameItem> item) {
696+ EXPECT_EQ (item->layer_tree_tasks .size (), 1u );
697+ EXPECT_EQ (item->layer_tree_tasks [0 ]->view_id , kFlutterImplicitViewId );
698+ });
699+ EXPECT_EQ (status, PipelineConsumeResult::Done);
700+ }));
701+ EXPECT_CALL (animator_delegate, OnAnimatorBeginFrame)
702+ .WillRepeatedly (Invoke ([&engine_context](fml::TimePoint frame_target_time,
703+ uint64_t frame_number) {
704+ engine_context->EngineTaskSync ([&](Engine& engine) {
705+ engine.BeginFrame (frame_target_time, frame_number);
706+ });
707+ }));
708+
709+ std::unique_ptr<Animator> animator;
710+ PostSync (task_runners_.GetUITaskRunner (),
711+ [&animator, &animator_delegate, &task_runners = task_runners_] {
712+ animator = std::make_unique<Animator>(
713+ animator_delegate, task_runners,
714+ static_cast <std::unique_ptr<VsyncWaiter>>(
715+ std::make_unique<testing::ConstantFiringVsyncWaiter>(
716+ task_runners)));
717+ });
718+
719+ native_latch.Reset ();
720+ // The native_latch is signaled at the end of handleDrawFrame.
721+ AddNativeCallback (" NotifyNative" , [](auto args) {
722+ EXPECT_EQ (rasterization_started, true );
723+ native_latch.Signal ();
724+ });
725+
726+ engine_context = EngineContext::Create (delegate_, settings_, task_runners_,
727+ std::move (animator));
728+
729+ engine_context->EngineTaskSync ([](Engine& engine) {
730+ engine.AddView (kFlutterImplicitViewId , ViewportMetrics{1.0 , 10 , 10 , 1 , 0 });
731+ });
732+
733+ auto configuration = RunConfiguration::InferFromSettings (settings_);
734+ configuration.SetEntrypoint (" renderSingleViewAndCallAfterOnDrawFrame" );
735+ engine_context->Run (std::move (configuration));
736+
737+ native_latch.Wait ();
738+ }
739+
682740// The animator should submit to the pipeline the implicit view rendered in a
683741// warm up frame if there's already a continuation (i.e. Animator::BeginFrame
684742// has been called)
0 commit comments