@@ -43,15 +43,19 @@ class SurfaceMock : public Surface {
43
43
(override ));
44
44
};
45
45
46
- fml::RefPtr<fml::RasterThreadMerger> GetThreadMergerFromPlatformThread () {
47
- auto rasterizer_thread = new fml::Thread (" rasterizer" );
48
- auto rasterizer_queue_id =
49
- rasterizer_thread->GetTaskRunner ()->GetTaskQueueId ();
50
-
46
+ fml::RefPtr<fml::RasterThreadMerger> GetThreadMergerFromPlatformThread (
47
+ bool merged = false ) {
51
48
// Assume the current thread is the platform thread.
52
49
fml::MessageLoop::EnsureInitializedForCurrentThread ();
53
50
auto platform_queue_id = fml::MessageLoop::GetCurrentTaskQueueId ();
54
51
52
+ if (merged) {
53
+ return fml::MakeRefCounted<fml::RasterThreadMerger>(platform_queue_id,
54
+ platform_queue_id);
55
+ }
56
+ auto rasterizer_thread = new fml::Thread (" rasterizer" );
57
+ auto rasterizer_queue_id =
58
+ rasterizer_thread->GetTaskRunner ()->GetTaskQueueId ();
55
59
return fml::MakeRefCounted<fml::RasterThreadMerger>(platform_queue_id,
56
60
rasterizer_queue_id);
57
61
}
@@ -291,7 +295,9 @@ TEST(AndroidExternalViewEmbedder, SubmitFrame) {
291
295
};
292
296
auto embedder = std::make_unique<AndroidExternalViewEmbedder>(
293
297
android_context, jni_mock, surface_factory);
294
- auto raster_thread_merger = GetThreadMergerFromPlatformThread ();
298
+
299
+ auto raster_thread_merger =
300
+ GetThreadMergerFromPlatformThread (/* merged=*/ true );
295
301
296
302
// ------------------ First frame ------------------ //
297
303
{
@@ -309,6 +315,9 @@ TEST(AndroidExternalViewEmbedder, SubmitFrame) {
309
315
embedder->SubmitFrame (gr_context.get (), std::move (surface_frame));
310
316
// Submits frame if no Android view in the current frame.
311
317
EXPECT_TRUE (did_submit_frame);
318
+ // Doesn't resubmit frame.
319
+ auto postpreroll_result = embedder->PostPrerollAction (raster_thread_merger);
320
+ ASSERT_EQ (PostPrerollResult::kSuccess , postpreroll_result);
312
321
313
322
EXPECT_CALL (*jni_mock, FlutterViewEndFrame ());
314
323
embedder->EndFrame (/* should_resubmit_frame=*/ false , raster_thread_merger);
@@ -373,6 +382,9 @@ TEST(AndroidExternalViewEmbedder, SubmitFrame) {
373
382
embedder->SubmitFrame (gr_context.get (), std::move (surface_frame));
374
383
// Doesn't submit frame if there aren't Android views in the previous frame.
375
384
EXPECT_FALSE (did_submit_frame);
385
+ // Resubmits frame.
386
+ auto postpreroll_result = embedder->PostPrerollAction (raster_thread_merger);
387
+ ASSERT_EQ (PostPrerollResult::kResubmitFrame , postpreroll_result);
376
388
377
389
EXPECT_CALL (*jni_mock, FlutterViewEndFrame ());
378
390
embedder->EndFrame (/* should_resubmit_frame=*/ false , raster_thread_merger);
@@ -434,6 +446,9 @@ TEST(AndroidExternalViewEmbedder, SubmitFrame) {
434
446
embedder->SubmitFrame (gr_context.get (), std::move (surface_frame));
435
447
// Submits frame if there are Android views in the previous frame.
436
448
EXPECT_TRUE (did_submit_frame);
449
+ // Doesn't resubmit frame.
450
+ auto postpreroll_result = embedder->PostPrerollAction (raster_thread_merger);
451
+ ASSERT_EQ (PostPrerollResult::kSuccess , postpreroll_result);
437
452
438
453
EXPECT_CALL (*jni_mock, FlutterViewEndFrame ());
439
454
embedder->EndFrame (/* should_resubmit_frame=*/ false , raster_thread_merger);
0 commit comments