Skip to content

Commit 1b0dc61

Browse files
authored
Stopped mocking the a flutter engine to make sure we delete the (flutter#23013)
FlutterViewController.
1 parent 7bdaf37 commit 1b0dc61

File tree

1 file changed

+16
-9
lines changed

1 file changed

+16
-9
lines changed

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

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -101,15 +101,22 @@ - (void)testViewDidDisappearDoesPauseEngineWhenIsTheViewController {
101101
}
102102

103103
- (void)testBinaryMessenger {
104-
id engine = OCMClassMock([FlutterEngine class]);
105-
FlutterViewController* vc = [[FlutterViewController alloc] initWithEngine:engine
106-
nibName:nil
107-
bundle:nil];
108-
XCTAssertNotNil(vc);
109-
id messenger = OCMProtocolMock(@protocol(FlutterBinaryMessenger));
110-
OCMStub([engine binaryMessenger]).andReturn(messenger);
111-
XCTAssertEqual(vc.binaryMessenger, messenger);
112-
OCMVerify([engine binaryMessenger]);
104+
__weak FlutterViewController* weakVC;
105+
@autoreleasepool {
106+
id engine = OCMClassMock([FlutterEngine class]);
107+
FlutterViewController* vc = [[FlutterViewController alloc] initWithEngine:engine
108+
nibName:nil
109+
bundle:nil];
110+
XCTAssertNotNil(vc);
111+
weakVC = vc;
112+
id messenger = OCMProtocolMock(@protocol(FlutterBinaryMessenger));
113+
OCMStub([engine binaryMessenger]).andReturn(messenger);
114+
XCTAssertEqual(vc.binaryMessenger, messenger);
115+
OCMVerify([engine binaryMessenger]);
116+
// This had to be added to make sure the view controller is deleted.
117+
[engine stopMocking];
118+
}
119+
XCTAssertNil(weakVC);
113120
}
114121

115122
#pragma mark - Platform Brightness

0 commit comments

Comments
 (0)