diff --git a/engine/src/flutter/ci/licenses_golden/licenses_flutter b/engine/src/flutter/ci/licenses_golden/licenses_flutter index 06b0d17ac1..019b322b24 100644 --- a/engine/src/flutter/ci/licenses_golden/licenses_flutter +++ b/engine/src/flutter/ci/licenses_golden/licenses_flutter @@ -719,6 +719,7 @@ FILE: ../../../flutter/shell/platform/darwin/ios/framework/Source/FlutterUmbrell FILE: ../../../flutter/shell/platform/darwin/ios/framework/Source/FlutterView.h FILE: ../../../flutter/shell/platform/darwin/ios/framework/Source/FlutterView.mm FILE: ../../../flutter/shell/platform/darwin/ios/framework/Source/FlutterViewController.mm +FILE: ../../../flutter/shell/platform/darwin/ios/framework/Source/FlutterViewControllerTest.m FILE: ../../../flutter/shell/platform/darwin/ios/framework/Source/FlutterViewController_Internal.h FILE: ../../../flutter/shell/platform/darwin/ios/framework/Source/accessibility_bridge.h FILE: ../../../flutter/shell/platform/darwin/ios/framework/Source/accessibility_bridge.mm diff --git a/engine/src/flutter/shell/platform/darwin/ios/framework/Headers/FlutterViewController.h b/engine/src/flutter/shell/platform/darwin/ios/framework/Headers/FlutterViewController.h index 1d3f16dcc5..90588ac9f9 100644 --- a/engine/src/flutter/shell/platform/darwin/ios/framework/Headers/FlutterViewController.h +++ b/engine/src/flutter/shell/platform/darwin/ios/framework/Headers/FlutterViewController.h @@ -168,11 +168,9 @@ FLUTTER_EXPORT * The `FlutterBinaryMessenger` associated with this FlutterViewController (used for communicating * with channels). * - * @deprecated Since |FlutterViewController| just forwards binary messenger calls to the - * |FlutterEngine|, just use the FlutterEngine.binaryMessenger. + * This is just a convenient way to get the |FlutterEngine|'s binary messenger. */ -@property(nonatomic, readonly) NSObject* binaryMessenger - __attribute__((deprecated)); +@property(nonatomic, readonly) NSObject* binaryMessenger; @end diff --git a/engine/src/flutter/shell/platform/darwin/ios/framework/Source/FlutterViewController.mm b/engine/src/flutter/shell/platform/darwin/ios/framework/Source/FlutterViewController.mm index 99c1920e4e..0a7ac0f66c 100644 --- a/engine/src/flutter/shell/platform/darwin/ios/framework/Source/FlutterViewController.mm +++ b/engine/src/flutter/shell/platform/darwin/ios/framework/Source/FlutterViewController.mm @@ -25,6 +25,9 @@ NSNotificationName const FlutterSemanticsUpdateNotification = @"FlutterSemanticsUpdate"; +// This is left a FlutterBinaryMessenger privately for now to give people a chance to notice the +// change. Unfortunately unless you have Werror turned on, incompatible pointers as arguments are +// just a warning. @interface FlutterViewController () @end @@ -44,7 +47,6 @@ NSNotificationName const FlutterSemanticsUpdateNotification = @"FlutterSemantics BOOL _viewOpaque; BOOL _engineNeedsLaunch; NSMutableSet* _ongoingTouches; - FlutterBinaryMessengerRelay* _binaryMessenger; } #pragma mark - Manage and override all designated initializers @@ -55,7 +57,6 @@ NSNotificationName const FlutterSemanticsUpdateNotification = @"FlutterSemantics NSAssert(engine != nil, @"Engine is required"); self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]; if (self) { - _binaryMessenger = [[FlutterBinaryMessengerRelay alloc] initWithParent:self]; _viewOpaque = YES; _engine.reset([engine retain]); _engineNeedsLaunch = NO; @@ -75,7 +76,6 @@ NSNotificationName const FlutterSemanticsUpdateNotification = @"FlutterSemantics bundle:(NSBundle*)nibBundleOrNil { self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]; if (self) { - _binaryMessenger = [[FlutterBinaryMessengerRelay alloc] initWithParent:self]; _viewOpaque = YES; _weakFactory = std::make_unique>(self); _engine.reset([[FlutterEngine alloc] initWithName:@"io.flutter" @@ -474,8 +474,6 @@ NSNotificationName const FlutterSemanticsUpdateNotification = @"FlutterSemantics } - (void)dealloc { - _binaryMessenger.parent = nil; - [_binaryMessenger release]; [_engine.get() notifyViewControllerDeallocated]; [[NSNotificationCenter defaultCenter] removeObserver:self]; [super dealloc]; @@ -1003,7 +1001,7 @@ constexpr CGFloat kStandardStatusBarHeight = 20.0; } - (NSObject*)binaryMessenger { - return _binaryMessenger; + return _engine.get().binaryMessenger; } #pragma mark - FlutterBinaryMessenger diff --git a/engine/src/flutter/shell/platform/darwin/ios/framework/Source/FlutterViewControllerTest.m b/engine/src/flutter/shell/platform/darwin/ios/framework/Source/FlutterViewControllerTest.m new file mode 100644 index 0000000000..928a551059 --- /dev/null +++ b/engine/src/flutter/shell/platform/darwin/ios/framework/Source/FlutterViewControllerTest.m @@ -0,0 +1,26 @@ +// Copyright 2013 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#import +#import +#import "flutter/shell/platform/darwin/ios/framework/Headers/FlutterViewController.h" + +@interface FlutterViewControllerTest : XCTestCase +@end + +@implementation FlutterViewControllerTest + +- (void)testBinaryMessenger { + id engine = OCMClassMock([FlutterEngine class]); + FlutterViewController* vc = [[FlutterViewController alloc] initWithEngine:engine + nibName:nil + bundle:nil]; + XCTAssertNotNil(vc); + id messenger = OCMProtocolMock(@protocol(FlutterBinaryMessenger)); + OCMStub([engine binaryMessenger]).andReturn(messenger); + XCTAssertEqual(vc.binaryMessenger, messenger); + OCMVerify([engine binaryMessenger]); +} + +@end diff --git a/engine/src/flutter/testing/ios/IosUnitTests/IosUnitTests.xcodeproj/project.pbxproj b/engine/src/flutter/testing/ios/IosUnitTests/IosUnitTests.xcodeproj/project.pbxproj index 189ce85499..ddcb900774 100644 --- a/engine/src/flutter/testing/ios/IosUnitTests/IosUnitTests.xcodeproj/project.pbxproj +++ b/engine/src/flutter/testing/ios/IosUnitTests/IosUnitTests.xcodeproj/project.pbxproj @@ -7,6 +7,7 @@ objects = { /* Begin PBXBuildFile section */ + 0D17A5C022D78FCD0057279F /* FlutterViewControllerTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 0D17A5BF22D78FCD0057279F /* FlutterViewControllerTest.m */; }; 0D52D3BD22C566D50011DEBD /* FlutterBinaryMessengerRelayTest.mm in Sources */ = {isa = PBXBuildFile; fileRef = 0D52D3B622C566D50011DEBD /* FlutterBinaryMessengerRelayTest.mm */; settings = {COMPILER_FLAGS = "-fobjc-arc"; }; }; 0D6AB6B622BB05E100EEE540 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 0D6AB6B522BB05E100EEE540 /* AppDelegate.m */; }; 0D6AB6B922BB05E100EEE540 /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 0D6AB6B822BB05E100EEE540 /* ViewController.m */; }; @@ -72,6 +73,7 @@ /* End PBXContainerItemProxy section */ /* Begin PBXFileReference section */ + 0D17A5BF22D78FCD0057279F /* FlutterViewControllerTest.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = FlutterViewControllerTest.m; sourceTree = ""; }; 0D52D3B622C566D50011DEBD /* FlutterBinaryMessengerRelayTest.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = FlutterBinaryMessengerRelayTest.mm; sourceTree = ""; }; 0D6AB6B122BB05E100EEE540 /* IosUnitTests.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = IosUnitTests.app; sourceTree = BUILT_PRODUCTS_DIR; }; 0D6AB6B422BB05E100EEE540 /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; @@ -160,6 +162,7 @@ children = ( 0D52D3B622C566D50011DEBD /* FlutterBinaryMessengerRelayTest.mm */, 0D6AB6E722BB40CF00EEE540 /* FlutterEngineTest.mm */, + 0D17A5BF22D78FCD0057279F /* FlutterViewControllerTest.m */, ); name = Source; path = ../../../../shell/platform/darwin/ios/framework/Source; @@ -369,6 +372,7 @@ buildActionMask = 2147483647; files = ( 0D6AB6EB22BB40E700EEE540 /* FlutterEngineTest.mm in Sources */, + 0D17A5C022D78FCD0057279F /* FlutterViewControllerTest.m in Sources */, 0D52D3BD22C566D50011DEBD /* FlutterBinaryMessengerRelayTest.mm in Sources */, ); runOnlyForDeploymentPostprocessing = 0;