Skip to content

Commit

Permalink
[Impeller] Run simulator tests with Impeller enabled.
Browse files Browse the repository at this point in the history
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 #56706
  • Loading branch information
chinmaygarde committed Nov 21, 2024
1 parent 764b91d commit 40add55
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 19 deletions.
26 changes: 9 additions & 17 deletions shell/platform/darwin/ios/framework/Source/FlutterEngineTest.mm
Original file line number Diff line number Diff line change
Expand Up @@ -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<flutter::PlatformMessage>("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<flutter::PlatformMessage>("foo", nullptr);
delegate.OnEngineHandlePlatformMessage(std::move(message));
latch.Signal();
});
latch.Wait();
[registrar.messenger setMessageHandlerOnChannel:@"foo"
binaryMessageHandler:^(NSData* message, FlutterBinaryReply reply) {
Expand All @@ -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"]) {
Expand Down Expand Up @@ -429,10 +427,6 @@ - (void)testSpawnsShareGpuContext {
std::shared_ptr<flutter::IOSContext> engine_context = [engine iosPlatformView]->GetIosContext();
std::shared_ptr<flutter::IOSContext> 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 {
Expand All @@ -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];
Expand All @@ -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];
Expand Down
1 change: 1 addition & 0 deletions shell/platform/darwin/ios/ios_context.mm
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
}

IOSRenderingBackend IOSContext::GetBackend() const {
// Overridden by Impeller subclasses.
return IOSRenderingBackend::kSkia;
}

Expand Down
2 changes: 0 additions & 2 deletions testing/ios/IosUnitTests/App/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,6 @@
</dict>
<key>FLTLeakDartVM</key>
<false/>
<key>FLTEnableImpeller</key>
<false/>
<key>FLTTraceSystrace</key>
<false/>
<key>FLTEnableDartProfiling</key>
Expand Down

0 comments on commit 40add55

Please sign in to comment.