From daa09b9a6409f6f7ab5affa78b36798be1a13976 Mon Sep 17 00:00:00 2001 From: Chinmay Garde Date: Thu, 21 Nov 2024 15:48:59 -0800 Subject: [PATCH] [Impeller] Run simulator tests with Impeller enabled. (flutter/engine#56740) The Info.plist override was missed earlier. The main changes to the tests are due to the UI thread merge with the platform thread. The amendment to the "spawn" API are due to the fact that the assertions checked for the presence of GrDirectContext which will never exist with Impeller. Unblocks https://github.com/flutter/engine/pull/56706 --- .../ios/framework/Source/FlutterEngineTest.mm | 26 +++++++------------ .../shell/platform/darwin/ios/ios_context.mm | 1 + .../testing/ios/IosUnitTests/App/Info.plist | 2 -- 3 files changed, 10 insertions(+), 19 deletions(-) diff --git a/engine/src/flutter/shell/platform/darwin/ios/framework/Source/FlutterEngineTest.mm b/engine/src/flutter/shell/platform/darwin/ios/framework/Source/FlutterEngineTest.mm index 58bfbdf160..d82993310d 100644 --- a/engine/src/flutter/shell/platform/darwin/ios/framework/Source/FlutterEngineTest.mm +++ b/engine/src/flutter/shell/platform/darwin/ios/framework/Source/FlutterEngineTest.mm @@ -270,12 +270,13 @@ FLUTTER_ASSERT_ARC fml::AutoResetWaitableEvent latch; [engine run]; flutter::Shell& shell = engine.shell; - engine.shell.GetTaskRunners().GetUITaskRunner()->PostTask([&latch, &shell] { - flutter::Engine::Delegate& delegate = shell; - auto message = std::make_unique("foo", nullptr); - delegate.OnEngineHandlePlatformMessage(std::move(message)); - latch.Signal(); - }); + fml::TaskRunner::RunNowOrPostTask( + engine.shell.GetTaskRunners().GetUITaskRunner(), [&latch, &shell] { + flutter::Engine::Delegate& delegate = shell; + auto message = std::make_unique("foo", nullptr); + delegate.OnEngineHandlePlatformMessage(std::move(message)); + latch.Signal(); + }); latch.Wait(); [registrar.messenger setMessageHandlerOnChannel:@"foo" binaryMessageHandler:^(NSData* message, FlutterBinaryReply reply) { @@ -287,14 +288,11 @@ FLUTTER_ASSERT_ARC - (void)testThreadPrioritySetCorrectly { XCTestExpectation* prioritiesSet = [self expectationWithDescription:@"prioritiesSet"]; - prioritiesSet.expectedFulfillmentCount = 3; + prioritiesSet.expectedFulfillmentCount = 2; IMP mockSetThreadPriority = imp_implementationWithBlock(^(NSThread* thread, double threadPriority) { - if ([thread.name hasSuffix:@".ui"]) { - XCTAssertEqual(threadPriority, 1.0); - [prioritiesSet fulfill]; - } else if ([thread.name hasSuffix:@".raster"]) { + if ([thread.name hasSuffix:@".raster"]) { XCTAssertEqual(threadPriority, 1.0); [prioritiesSet fulfill]; } else if ([thread.name hasSuffix:@".io"]) { @@ -429,10 +427,6 @@ FLUTTER_ASSERT_ARC std::shared_ptr engine_context = [engine iosPlatformView]->GetIosContext(); std::shared_ptr spawn_context = [spawn iosPlatformView]->GetIosContext(); XCTAssertEqual(engine_context, spawn_context); - // If this assert fails it means we may be using the software. For software rendering, this is - // expected to be nullptr. - XCTAssertTrue(engine_context->GetMainContext() != nullptr); - XCTAssertEqual(engine_context->GetMainContext(), spawn_context->GetMainContext()); } - (void)testEnableSemanticsWhenFlutterViewAccessibilityDidCall { @@ -445,7 +439,6 @@ FLUTTER_ASSERT_ARC - (void)testCanMergePlatformAndUIThread { #if defined(TARGET_IPHONE_SIMULATOR) && TARGET_IPHONE_SIMULATOR auto settings = FLTDefaultSettingsForBundle(); - settings.enable_impeller = true; FlutterDartProject* project = [[FlutterDartProject alloc] initWithSettings:settings]; FlutterEngine* engine = [[FlutterEngine alloc] initWithName:@"foobar" project:project]; [engine run]; @@ -458,7 +451,6 @@ FLUTTER_ASSERT_ARC - (void)testCanUnMergePlatformAndUIThread { #if defined(TARGET_IPHONE_SIMULATOR) && TARGET_IPHONE_SIMULATOR auto settings = FLTDefaultSettingsForBundle(); - settings.enable_impeller = true; settings.merged_platform_ui_thread = false; FlutterDartProject* project = [[FlutterDartProject alloc] initWithSettings:settings]; FlutterEngine* engine = [[FlutterEngine alloc] initWithName:@"foobar" project:project]; diff --git a/engine/src/flutter/shell/platform/darwin/ios/ios_context.mm b/engine/src/flutter/shell/platform/darwin/ios/ios_context.mm index 762847e8af..4bd87fe7fa 100644 --- a/engine/src/flutter/shell/platform/darwin/ios/ios_context.mm +++ b/engine/src/flutter/shell/platform/darwin/ios/ios_context.mm @@ -56,6 +56,7 @@ std::unique_ptr IOSContext::Create( } IOSRenderingBackend IOSContext::GetBackend() const { + // Overridden by Impeller subclasses. return IOSRenderingBackend::kSkia; } diff --git a/engine/src/flutter/testing/ios/IosUnitTests/App/Info.plist b/engine/src/flutter/testing/ios/IosUnitTests/App/Info.plist index 885a3b1804..e87b8d5186 100644 --- a/engine/src/flutter/testing/ios/IosUnitTests/App/Info.plist +++ b/engine/src/flutter/testing/ios/IosUnitTests/App/Info.plist @@ -46,8 +46,6 @@ FLTLeakDartVM - FLTEnableImpeller - FLTTraceSystrace FLTEnableDartProfiling