From 40add55dc7bdcd410f8c395151e6d41c3ea777ed Mon Sep 17 00:00:00 2001 From: Chinmay Garde Date: Thu, 21 Nov 2024 15:03:18 -0800 Subject: [PATCH] [Impeller] Run simulator tests with Impeller enabled. 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/shell/platform/darwin/ios/framework/Source/FlutterEngineTest.mm b/shell/platform/darwin/ios/framework/Source/FlutterEngineTest.mm index 58bfbdf1605dc..d82993310d499 100644 --- a/shell/platform/darwin/ios/framework/Source/FlutterEngineTest.mm +++ b/shell/platform/darwin/ios/framework/Source/FlutterEngineTest.mm @@ -270,12 +270,13 @@ - (void)testSetHandlerAfterRun { 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 @@ - (void)testSetHandlerAfterRun { - (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 @@ - (void)testSpawnsShareGpuContext { 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 @@ - (void)testEnableSemanticsWhenFlutterViewAccessibilityDidCall { - (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 @@ - (void)testCanMergePlatformAndUIThread { - (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/shell/platform/darwin/ios/ios_context.mm b/shell/platform/darwin/ios/ios_context.mm index 762847e8af780..4bd87fe7fa5e1 100644 --- a/shell/platform/darwin/ios/ios_context.mm +++ b/shell/platform/darwin/ios/ios_context.mm @@ -56,6 +56,7 @@ } IOSRenderingBackend IOSContext::GetBackend() const { + // Overridden by Impeller subclasses. return IOSRenderingBackend::kSkia; } diff --git a/testing/ios/IosUnitTests/App/Info.plist b/testing/ios/IosUnitTests/App/Info.plist index 885a3b1804edf..e87b8d51863b9 100644 --- a/testing/ios/IosUnitTests/App/Info.plist +++ b/testing/ios/IosUnitTests/App/Info.plist @@ -46,8 +46,6 @@ FLTLeakDartVM - FLTEnableImpeller - FLTTraceSystrace FLTEnableDartProfiling