Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit 5b2cc9d

Browse files
author
Chris Yang
authored
Fix iOS unittests leak in shared.invoke method channel that causes crash (#45416)
Fixes flutter/flutter#133776 "The crash is due to testShareScreenInvoked presents the activityViewController, which prevents the engineViewController to be dealloc'd in the test: https://github.com/flutter/engine/blob/main/shell/platform/darwin/ios/framework/Source/FlutterPlatformPlugin.mm#L161C4-L161C24" This fix stubbing the presentViewController call, which prevents the viewController being alloc'd, thus preventing the leak. It is probably sufficient for this test. [C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
1 parent 4da0350 commit 5b2cc9d

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

shell/platform/darwin/ios/framework/Source/FlutterPlatformPluginTest.mm

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,10 @@ - (void)testShareScreenInvoked {
139139
FlutterViewController* engineViewController =
140140
[[[FlutterViewController alloc] initWithEngine:engine nibName:nil bundle:nil] autorelease];
141141
FlutterViewController* mockEngineViewController = OCMPartialMock(engineViewController);
142+
OCMStub([mockEngineViewController
143+
presentViewController:[OCMArg isKindOfClass:[UIActivityViewController class]]
144+
animated:YES
145+
completion:nil]);
142146

143147
FlutterPlatformPlugin* plugin =
144148
[[[FlutterPlatformPlugin alloc] initWithEngine:_weakFactory->GetWeakPtr()] autorelease];

0 commit comments

Comments
 (0)