From 383a993501566b76f2603ffe33c9717b7b22145a Mon Sep 17 00:00:00 2001 From: Chris Yang Date: Thu, 9 Nov 2023 09:24:39 -0800 Subject: [PATCH 1/4] draft --- shell/platform/darwin/ios/BUILD.gn | 5 +- .../Source/FlutterEngineGroupTest.mm | 202 ++++++++--------- .../Source/FlutterEnginePlatformViewTest.mm | 2 +- .../ios/framework/Source/FlutterEngineTest.mm | 41 ++++ .../framework/Source/FlutterEngineTest_mrc.mm | 66 ------ .../Source/FlutterPlatformPluginTest.mm | 44 ++-- .../Source/FlutterViewControllerTest.mm | 167 ++++++++++++++ .../Source/FlutterViewControllerTest_mrc.mm | 203 ------------------ .../framework/Source/SemanticsObjectTest.mm | 52 +++++ .../Source/SemanticsObjectTest_mrc.mm | 49 ----- 10 files changed, 387 insertions(+), 444 deletions(-) delete mode 100644 shell/platform/darwin/ios/framework/Source/FlutterEngineTest_mrc.mm delete mode 100644 shell/platform/darwin/ios/framework/Source/FlutterViewControllerTest_mrc.mm diff --git a/shell/platform/darwin/ios/BUILD.gn b/shell/platform/darwin/ios/BUILD.gn index 93bbe44130748..831d20eec88dc 100644 --- a/shell/platform/darwin/ios/BUILD.gn +++ b/shell/platform/darwin/ios/BUILD.gn @@ -234,11 +234,8 @@ source_set("ios_test_flutter_mrc") { # See details in https://github.com/flutter/flutter/issues/128958. cflags_objcc = [ "-Wno-unguarded-availability-new" ] sources = [ - "framework/Source/FlutterEnginePlatformViewTest.mm", - "framework/Source/FlutterEngineTest_mrc.mm", "framework/Source/FlutterPlatformViewsTest.mm", "framework/Source/FlutterTouchInterceptingView_Test.h", - "framework/Source/FlutterViewControllerTest_mrc.mm", "framework/Source/FlutterViewTest.mm", "framework/Source/SemanticsObjectTestMocks.h", "framework/Source/SemanticsObjectTest_mrc.mm", @@ -294,6 +291,8 @@ shared_library("ios_test_flutter") { "//build/config:symbol_visibility_hidden", ] sources = [ + "framework/Source/FlutterPlatformPluginTest.mm", + "framework/Source/FlutterEnginePlatformViewTest.mm", "framework/Source/FlutterAppDelegateTest.mm", "framework/Source/FlutterChannelKeyResponderTest.mm", "framework/Source/FlutterDartProjectTest.mm", diff --git a/shell/platform/darwin/ios/framework/Source/FlutterEngineGroupTest.mm b/shell/platform/darwin/ios/framework/Source/FlutterEngineGroupTest.mm index 77929ea6b4c20..297fa3bb0568c 100644 --- a/shell/platform/darwin/ios/framework/Source/FlutterEngineGroupTest.mm +++ b/shell/platform/darwin/ios/framework/Source/FlutterEngineGroupTest.mm @@ -20,125 +20,125 @@ @interface FlutterEngineGroupTest : XCTestCase @implementation FlutterEngineGroupTest - (void)testMake { - FlutterEngineGroup* group = [[FlutterEngineGroup alloc] initWithName:@"foo" project:nil]; - FlutterEngine* engine = [group makeEngineWithEntrypoint:nil libraryURI:nil]; - XCTAssertNotNil(engine); + FlutterEngineGroup* group = [[FlutterEngineGroup alloc] initWithName:@"foo" project:nil]; + FlutterEngine* engine = [group makeEngineWithEntrypoint:nil libraryURI:nil]; + XCTAssertNotNil(engine); } - (void)testSpawn { - FlutterEngineGroup* group = [[FlutterEngineGroup alloc] initWithName:@"foo" project:nil]; - FlutterEngine* spawner = [group makeEngineWithEntrypoint:nil libraryURI:nil]; - spawner.isGpuDisabled = YES; - FlutterEngine* spawnee = [group makeEngineWithEntrypoint:nil libraryURI:nil]; - XCTAssertNotNil(spawner); - XCTAssertNotNil(spawnee); - XCTAssertEqual(&spawner.threadHost, &spawnee.threadHost); - XCTAssertEqual(spawner.isGpuDisabled, spawnee.isGpuDisabled); + FlutterEngineGroup* group = [[FlutterEngineGroup alloc] initWithName:@"foo" project:nil]; + FlutterEngine* spawner = [group makeEngineWithEntrypoint:nil libraryURI:nil]; + spawner.isGpuDisabled = YES; + FlutterEngine* spawnee = [group makeEngineWithEntrypoint:nil libraryURI:nil]; + XCTAssertNotNil(spawner); + XCTAssertNotNil(spawnee); + XCTAssertEqual(&spawner.threadHost, &spawnee.threadHost); + XCTAssertEqual(spawner.isGpuDisabled, spawnee.isGpuDisabled); } - (void)testDeleteLastEngine { - FlutterEngineGroup* group = [[FlutterEngineGroup alloc] initWithName:@"foo" project:nil]; - @autoreleasepool { - FlutterEngine* spawner = [group makeEngineWithEntrypoint:nil libraryURI:nil]; - XCTAssertNotNil(spawner); - } - FlutterEngine* spawnee = [group makeEngineWithEntrypoint:nil libraryURI:nil]; - XCTAssertNotNil(spawnee); + FlutterEngineGroup* group = [[FlutterEngineGroup alloc] initWithName:@"foo" project:nil]; + @autoreleasepool { + FlutterEngine* spawner = [group makeEngineWithEntrypoint:nil libraryURI:nil]; + XCTAssertNotNil(spawner); + } + FlutterEngine* spawnee = [group makeEngineWithEntrypoint:nil libraryURI:nil]; + XCTAssertNotNil(spawnee); } - (void)testCustomEntrypoint { - FlutterEngineGroup* group = OCMPartialMock([[FlutterEngineGroup alloc] initWithName:@"foo" - project:nil]); - FlutterEngine* mockEngine = OCMClassMock([FlutterEngine class]); - OCMStub([group makeEngine]).andReturn(mockEngine); - OCMStub([mockEngine spawnWithEntrypoint:[OCMArg any] - libraryURI:[OCMArg any] - initialRoute:[OCMArg any] - entrypointArgs:[OCMArg any]]) - .andReturn(OCMClassMock([FlutterEngine class])); - FlutterEngine* spawner = [group makeEngineWithEntrypoint:@"firstEntrypoint" - libraryURI:@"firstLibraryURI"]; - XCTAssertNotNil(spawner); - OCMVerify([spawner runWithEntrypoint:@"firstEntrypoint" - libraryURI:@"firstLibraryURI" - initialRoute:nil - entrypointArgs:nil]); - - FlutterEngine* spawnee = [group makeEngineWithEntrypoint:@"secondEntrypoint" - libraryURI:@"secondLibraryURI"]; - XCTAssertNotNil(spawnee); - OCMVerify([spawner spawnWithEntrypoint:@"secondEntrypoint" - libraryURI:@"secondLibraryURI" - initialRoute:nil - entrypointArgs:nil]); + FlutterEngineGroup* group = OCMPartialMock([[FlutterEngineGroup alloc] initWithName:@"foo" + project:nil]); + FlutterEngine* mockEngine = OCMClassMock([FlutterEngine class]); + OCMStub([group makeEngine]).andReturn(mockEngine); + OCMStub([mockEngine spawnWithEntrypoint:[OCMArg any] + libraryURI:[OCMArg any] + initialRoute:[OCMArg any] + entrypointArgs:[OCMArg any]]) + .andReturn(OCMClassMock([FlutterEngine class])); + FlutterEngine* spawner = [group makeEngineWithEntrypoint:@"firstEntrypoint" + libraryURI:@"firstLibraryURI"]; + XCTAssertNotNil(spawner); + OCMVerify([spawner runWithEntrypoint:@"firstEntrypoint" + libraryURI:@"firstLibraryURI" + initialRoute:nil + entrypointArgs:nil]); + + FlutterEngine* spawnee = [group makeEngineWithEntrypoint:@"secondEntrypoint" + libraryURI:@"secondLibraryURI"]; + XCTAssertNotNil(spawnee); + OCMVerify([spawner spawnWithEntrypoint:@"secondEntrypoint" + libraryURI:@"secondLibraryURI" + initialRoute:nil + entrypointArgs:nil]); } - (void)testCustomInitialRoute { - FlutterEngineGroup* group = OCMPartialMock([[FlutterEngineGroup alloc] initWithName:@"foo" - project:nil]); - FlutterEngine* mockEngine = OCMClassMock([FlutterEngine class]); - OCMStub([group makeEngine]).andReturn(mockEngine); - OCMStub([mockEngine spawnWithEntrypoint:[OCMArg any] - libraryURI:[OCMArg any] - initialRoute:[OCMArg any] - entrypointArgs:[OCMArg any]]) - .andReturn(OCMClassMock([FlutterEngine class])); - FlutterEngine* spawner = [group makeEngineWithEntrypoint:nil libraryURI:nil initialRoute:@"foo"]; - XCTAssertNotNil(spawner); - OCMVerify([spawner runWithEntrypoint:nil libraryURI:nil initialRoute:@"foo" entrypointArgs:nil]); - - FlutterEngine* spawnee = [group makeEngineWithEntrypoint:nil libraryURI:nil initialRoute:@"bar"]; - XCTAssertNotNil(spawnee); - OCMVerify([spawner spawnWithEntrypoint:nil - libraryURI:nil - initialRoute:@"bar" - entrypointArgs:nil]); + FlutterEngineGroup* group = OCMPartialMock([[FlutterEngineGroup alloc] initWithName:@"foo" + project:nil]); + FlutterEngine* mockEngine = OCMClassMock([FlutterEngine class]); + OCMStub([group makeEngine]).andReturn(mockEngine); + OCMStub([mockEngine spawnWithEntrypoint:[OCMArg any] + libraryURI:[OCMArg any] + initialRoute:[OCMArg any] + entrypointArgs:[OCMArg any]]) + .andReturn(OCMClassMock([FlutterEngine class])); + FlutterEngine* spawner = [group makeEngineWithEntrypoint:nil libraryURI:nil initialRoute:@"foo"]; + XCTAssertNotNil(spawner); + OCMVerify([spawner runWithEntrypoint:nil libraryURI:nil initialRoute:@"foo" entrypointArgs:nil]); + + FlutterEngine* spawnee = [group makeEngineWithEntrypoint:nil libraryURI:nil initialRoute:@"bar"]; + XCTAssertNotNil(spawnee); + OCMVerify([spawner spawnWithEntrypoint:nil + libraryURI:nil + initialRoute:@"bar" + entrypointArgs:nil]); } - (void)testCustomEntrypointArgs { - FlutterEngineGroup* group = OCMPartialMock([[FlutterEngineGroup alloc] initWithName:@"foo" - project:nil]); - FlutterEngine* mockEngine = OCMClassMock([FlutterEngine class]); - OCMStub([group makeEngine]).andReturn(mockEngine); - OCMStub([mockEngine spawnWithEntrypoint:[OCMArg any] - libraryURI:[OCMArg any] - initialRoute:[OCMArg any] - entrypointArgs:[OCMArg any]]) - .andReturn(OCMClassMock([FlutterEngine class])); - FlutterEngineGroupOptions* firstOptions = [[FlutterEngineGroupOptions alloc] init]; - NSArray* firstEntrypointArgs = @[ @"foo", @"first" ]; - firstOptions.entrypointArgs = firstEntrypointArgs; - FlutterEngine* spawner = [group makeEngineWithOptions:firstOptions]; - XCTAssertNotNil(spawner); - OCMVerify([spawner runWithEntrypoint:nil - libraryURI:nil - initialRoute:nil - entrypointArgs:firstEntrypointArgs]); - - NSArray* secondEntrypointArgs = @[ @"bar", @"second" ]; - FlutterEngineGroupOptions* secondOptions = [[FlutterEngineGroupOptions alloc] init]; - secondOptions.entrypointArgs = secondEntrypointArgs; - FlutterEngine* spawnee = [group makeEngineWithOptions:secondOptions]; - XCTAssertNotNil(spawnee); - OCMVerify([spawner spawnWithEntrypoint:nil - libraryURI:nil - initialRoute:nil - entrypointArgs:secondEntrypointArgs]); + FlutterEngineGroup* group = OCMPartialMock([[FlutterEngineGroup alloc] initWithName:@"foo" + project:nil]); + FlutterEngine* mockEngine = OCMClassMock([FlutterEngine class]); + OCMStub([group makeEngine]).andReturn(mockEngine); + OCMStub([mockEngine spawnWithEntrypoint:[OCMArg any] + libraryURI:[OCMArg any] + initialRoute:[OCMArg any] + entrypointArgs:[OCMArg any]]) + .andReturn(OCMClassMock([FlutterEngine class])); + FlutterEngineGroupOptions* firstOptions = [[FlutterEngineGroupOptions alloc] init]; + NSArray* firstEntrypointArgs = @[ @"foo", @"first" ]; + firstOptions.entrypointArgs = firstEntrypointArgs; + FlutterEngine* spawner = [group makeEngineWithOptions:firstOptions]; + XCTAssertNotNil(spawner); + OCMVerify([spawner runWithEntrypoint:nil + libraryURI:nil + initialRoute:nil + entrypointArgs:firstEntrypointArgs]); + + NSArray* secondEntrypointArgs = @[ @"bar", @"second" ]; + FlutterEngineGroupOptions* secondOptions = [[FlutterEngineGroupOptions alloc] init]; + secondOptions.entrypointArgs = secondEntrypointArgs; + FlutterEngine* spawnee = [group makeEngineWithOptions:secondOptions]; + XCTAssertNotNil(spawnee); + OCMVerify([spawner spawnWithEntrypoint:nil + libraryURI:nil + initialRoute:nil + entrypointArgs:secondEntrypointArgs]); } - (void)testReleasesProjectOnDealloc { - __weak FlutterDartProject* weakProject; - @autoreleasepool { - FlutterDartProject* mockProject = OCMClassMock([FlutterDartProject class]); - FlutterEngineGroup* group = [[FlutterEngineGroup alloc] initWithName:@"foo" - project:mockProject]; - XCTAssertNotNil(group); - weakProject = mockProject; - XCTAssertNotNil(weakProject); - group = nil; - mockProject = nil; - } - XCTAssertNil(weakProject); + __weak FlutterDartProject* weakProject; + @autoreleasepool { + FlutterDartProject* mockProject = OCMClassMock([FlutterDartProject class]); + FlutterEngineGroup* group = [[FlutterEngineGroup alloc] initWithName:@"foo" + project:mockProject]; + XCTAssertNotNil(group); + weakProject = mockProject; + XCTAssertNotNil(weakProject); + group = nil; + mockProject = nil; + } + XCTAssertNil(weakProject); } @end diff --git a/shell/platform/darwin/ios/framework/Source/FlutterEnginePlatformViewTest.mm b/shell/platform/darwin/ios/framework/Source/FlutterEnginePlatformViewTest.mm index 51c76156b4f98..50e479baa356e 100644 --- a/shell/platform/darwin/ios/framework/Source/FlutterEnginePlatformViewTest.mm +++ b/shell/platform/darwin/ios/framework/Source/FlutterEnginePlatformViewTest.mm @@ -13,7 +13,7 @@ #import "flutter/shell/platform/darwin/ios/framework/Source/FlutterEngine_Internal.h" #import "flutter/shell/platform/darwin/ios/platform_view_ios.h" -FLUTTER_ASSERT_NOT_ARC +FLUTTER_ASSERT_ARC namespace flutter { namespace { diff --git a/shell/platform/darwin/ios/framework/Source/FlutterEngineTest.mm b/shell/platform/darwin/ios/framework/Source/FlutterEngineTest.mm index 9a64083b1d280..b748ace53722d 100644 --- a/shell/platform/darwin/ios/framework/Source/FlutterEngineTest.mm +++ b/shell/platform/darwin/ios/framework/Source/FlutterEngineTest.mm @@ -15,9 +15,23 @@ #import "flutter/shell/platform/darwin/ios/framework/Source/FlutterDartProject_Internal.h" #import "flutter/shell/platform/darwin/ios/framework/Source/FlutterEngine_Test.h" #import "flutter/shell/platform/darwin/ios/framework/Source/FlutterTextInputPlugin.h" +#import "flutter/shell/platform/darwin/ios/framework/Source/FlutterEngine_Internal.h" +#import "flutter/shell/platform/darwin/ios/platform_view_ios.h" FLUTTER_ASSERT_ARC +@interface FlutterEngineSpy : FlutterEngine +@property(nonatomic) BOOL ensureSemanticsEnabledCalled; +@end + +@implementation FlutterEngineSpy + +- (void)ensureSemanticsEnabled { + _ensureSemanticsEnabledCalled = YES; +} + +@end + @interface FlutterEngine () @end @@ -430,4 +444,31 @@ - (void)testLifeCycleNotificationWillEnterForeground { XCTAssertFalse(switch_value); } +- (void)testSpawnsShareGpuContext { + FlutterEngine* engine = [[FlutterEngine alloc] initWithName:@"foobar"]; + [engine run]; + FlutterEngine* spawn = [engine spawnWithEntrypoint:nil + libraryURI:nil + initialRoute:nil + entrypointArgs:nil]; + XCTAssertNotNil(spawn); + XCTAssertTrue([engine iosPlatformView] != nullptr); + XCTAssertTrue([spawn iosPlatformView] != nullptr); + 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 { + FlutterEngineSpy* engine = [[FlutterEngineSpy alloc] initWithName:@"foobar"]; + engine.ensureSemanticsEnabledCalled = NO; + [engine flutterViewAccessibilityDidCall]; + XCTAssertTrue(engine.ensureSemanticsEnabledCalled); +} + + @end diff --git a/shell/platform/darwin/ios/framework/Source/FlutterEngineTest_mrc.mm b/shell/platform/darwin/ios/framework/Source/FlutterEngineTest_mrc.mm deleted file mode 100644 index 35ad2c4c21bbb..0000000000000 --- a/shell/platform/darwin/ios/framework/Source/FlutterEngineTest_mrc.mm +++ /dev/null @@ -1,66 +0,0 @@ -// 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/common/framework/Headers/FlutterMacros.h" -#import "flutter/shell/platform/darwin/ios/framework/Source/FlutterEngine_Internal.h" -#import "flutter/shell/platform/darwin/ios/framework/Source/FlutterEngine_Test.h" -#import "flutter/shell/platform/darwin/ios/platform_view_ios.h" - -FLUTTER_ASSERT_NOT_ARC - -@interface FlutterEngineSpy : FlutterEngine -@property(nonatomic) BOOL ensureSemanticsEnabledCalled; -@end - -@implementation FlutterEngineSpy - -- (void)ensureSemanticsEnabled { - _ensureSemanticsEnabledCalled = YES; -} - -@end - -@interface FlutterEngineTest_mrc : XCTestCase -@end - -@implementation FlutterEngineTest_mrc - -- (void)setUp { -} - -- (void)tearDown { -} - -- (void)testSpawnsShareGpuContext { - FlutterEngine* engine = [[FlutterEngine alloc] initWithName:@"foobar"]; - [engine run]; - FlutterEngine* spawn = [engine spawnWithEntrypoint:nil - libraryURI:nil - initialRoute:nil - entrypointArgs:nil]; - XCTAssertNotNil(spawn); - XCTAssertTrue([engine iosPlatformView] != nullptr); - XCTAssertTrue([spawn iosPlatformView] != nullptr); - 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()); - [engine release]; -} - -- (void)testEnableSemanticsWhenFlutterViewAccessibilityDidCall { - FlutterEngineSpy* engine = [[FlutterEngineSpy alloc] initWithName:@"foobar"]; - engine.ensureSemanticsEnabledCalled = NO; - [engine flutterViewAccessibilityDidCall]; - XCTAssertTrue(engine.ensureSemanticsEnabledCalled); - [engine release]; -} - -@end diff --git a/shell/platform/darwin/ios/framework/Source/FlutterPlatformPluginTest.mm b/shell/platform/darwin/ios/framework/Source/FlutterPlatformPluginTest.mm index 894e1f30cd5e1..0c5dface26b01 100644 --- a/shell/platform/darwin/ios/framework/Source/FlutterPlatformPluginTest.mm +++ b/shell/platform/darwin/ios/framework/Source/FlutterPlatformPluginTest.mm @@ -41,13 +41,15 @@ - (void)testSearchWebInvokedWithEscapedTerm { std::make_unique>(engine); [engine runWithEntrypoint:nil]; - XCTestExpectation* invokeExpectation = - [self expectationWithDescription:@"Web search launched with escaped search term"]; FlutterPlatformPlugin* plugin = [[FlutterPlatformPlugin alloc] initWithEngine:_weakFactory->GetWeakNSObject()]; FlutterPlatformPlugin* mockPlugin = OCMPartialMock(plugin); + FlutterPlatformPlugin* plugin = + [[FlutterPlatformPlugin alloc] initWithEngine:[engine getWeakPtr]]; + FlutterPlatformPlugin* mockPlugin = OCMPartialMock(plugin); + FlutterMethodCall* methodCall = [FlutterMethodCall methodCallWithMethodName:@"SearchWeb.invoke" arguments:@"Testing Word!"]; @@ -213,25 +215,25 @@ - (void)testClipboardSetDataToNullDoNotCrash { FlutterPlatformPlugin* plugin = [[FlutterPlatformPlugin alloc] initWithEngine:_weakFactory->GetWeakNSObject()]; - XCTestExpectation* setStringExpectation = [self expectationWithDescription:@"setData"]; - FlutterResult resultSet = ^(id result) { - [setStringExpectation fulfill]; - }; - FlutterMethodCall* methodCallSet = - [FlutterMethodCall methodCallWithMethodName:@"Clipboard.setData" - arguments:@{@"text" : [NSNull null]}]; - [plugin handleMethodCall:methodCallSet result:resultSet]; - - XCTestExpectation* getDataExpectation = [self expectationWithDescription:@"getData"]; - FlutterResult result = ^(id result) { - XCTAssertEqualObjects(result[@"text"], @"null"); - [getDataExpectation fulfill]; - }; - FlutterMethodCall* methodCall = [FlutterMethodCall methodCallWithMethodName:@"Clipboard.getData" - arguments:@"text/plain"]; - [plugin handleMethodCall:methodCall result:result]; - [self waitForExpectationsWithTimeout:1 handler:nil]; -} +// XCTestExpectation* setStringExpectation = [self expectationWithDescription:@"setData"]; +// FlutterResult resultSet = ^(id result) { +// [setStringExpectation fulfill]; +// }; +// FlutterMethodCall* methodCallSet = +// [FlutterMethodCall methodCallWithMethodName:@"Clipboard.setData" +// arguments:@{@"text" : [NSNull null]}]; +// [plugin handleMethodCall:methodCallSet result:resultSet]; + +// XCTestExpectation* getDataExpectation = [self expectationWithDescription:@"getData"]; +// FlutterResult result = ^(id result) { +// XCTAssertEqualObjects(result[@"text"], @"null"); +// [getDataExpectation fulfill]; +// }; +// FlutterMethodCall* methodCall = [FlutterMethodCall methodCallWithMethodName:@"Clipboard.getData" +// arguments:@"text/plain"]; +// [plugin handleMethodCall:methodCall result:result]; +// [self waitForExpectationsWithTimeout:1 handler:nil]; +// } - (void)testPopSystemNavigator { FlutterEngine* engine = [[FlutterEngine alloc] initWithName:@"test" project:nil]; diff --git a/shell/platform/darwin/ios/framework/Source/FlutterViewControllerTest.mm b/shell/platform/darwin/ios/framework/Source/FlutterViewControllerTest.mm index 35ffaac68bfbe..0fed180dcd067 100644 --- a/shell/platform/darwin/ios/framework/Source/FlutterViewControllerTest.mm +++ b/shell/platform/darwin/ios/framework/Source/FlutterViewControllerTest.mm @@ -19,6 +19,7 @@ #import "flutter/shell/platform/darwin/ios/framework/Source/UIViewController+FlutterScreenAndSceneIfLoaded.h" #import "flutter/shell/platform/embedder/embedder.h" #import "flutter/third_party/spring_animation/spring_animation.h" +#import "flutter/shell/platform/darwin/ios/framework/Source/vsync_waiter_ios.h" FLUTTER_ASSERT_ARC @@ -122,6 +123,9 @@ @interface FlutterViewController (Tests) @property(nonatomic, assign) double targetViewInsetBottom; @property(nonatomic, assign) BOOL isKeyboardInOrTransitioningFromBackground; @property(nonatomic, assign) BOOL keyboardAnimationIsShowing; +@property(nonatomic, strong) VSyncClient* keyboardAnimationVSyncClient; +@property(nonatomic, strong) VSyncClient* touchRateCorrectionVSyncClient; + - (void)createTouchRateCorrectionVSyncClientIfNeeded; - (void)surfaceUpdated:(BOOL)appeared; @@ -160,6 +164,7 @@ - (void)sceneWillResignActive:(NSNotification*)notification API_AVAILABLE(ios(13 - (void)sceneWillDisconnect:(NSNotification*)notification API_AVAILABLE(ios(13.0)); - (void)sceneDidEnterBackground:(NSNotification*)notification API_AVAILABLE(ios(13.0)); - (void)sceneWillEnterForeground:(NSNotification*)notification API_AVAILABLE(ios(13.0)); +- (void)triggerTouchRateCorrectionIfNeeded:(NSSet*)touches; @end @interface FlutterViewControllerTest : XCTestCase @@ -169,6 +174,18 @@ @interface FlutterViewControllerTest : XCTestCase - (void)sendMessage:(id _Nullable)message reply:(FlutterReply _Nullable)callback; @end +@interface UITouch () + +@property(nonatomic, readwrite) UITouchPhase phase; + +@end + +@interface VSyncClient (Testing) + +- (CADisplayLink*)getDisplayLink; + +@end + @implementation FlutterViewControllerTest - (void)setUp { @@ -2016,4 +2033,154 @@ - (void)testLifeCycleNotificationCancelledInvalidResumed { [self waitForExpectationsWithTimeout:5.0 handler:nil]; } + +- (void)testSetupKeyboardAnimationVsyncClientWillCreateNewVsyncClientForFlutterViewController { + id bundleMock = OCMPartialMock([NSBundle mainBundle]); + OCMStub([bundleMock objectForInfoDictionaryKey:@"CADisableMinimumFrameDurationOnPhone"]) + .andReturn(@YES); + id mockDisplayLinkManager = [OCMockObject mockForClass:[DisplayLinkManager class]]; + double maxFrameRate = 120; + [[[mockDisplayLinkManager stub] andReturnValue:@(maxFrameRate)] displayRefreshRate]; + FlutterEngine* engine = [[FlutterEngine alloc] init]; + [engine runWithEntrypoint:nil]; + FlutterViewController* viewController = + [[FlutterViewController alloc] initWithEngine:engine nibName:nil bundle:nil]; + FlutterKeyboardAnimationCallback callback = ^(fml::TimePoint targetTime) { + }; + [viewController setUpKeyboardAnimationVsyncClient:callback]; + XCTAssertNotNil(viewController.keyboardAnimationVSyncClient); + CADisplayLink* link = [viewController.keyboardAnimationVSyncClient getDisplayLink]; + XCTAssertNotNil(link); + if (@available(iOS 15.0, *)) { + XCTAssertEqual(link.preferredFrameRateRange.maximum, maxFrameRate); + XCTAssertEqual(link.preferredFrameRateRange.preferred, maxFrameRate); + XCTAssertEqual(link.preferredFrameRateRange.minimum, maxFrameRate / 2); + } else { + XCTAssertEqual(link.preferredFramesPerSecond, maxFrameRate); + } +} + +- (void) + testCreateTouchRateCorrectionVSyncClientWillCreateVsyncClientWhenRefreshRateIsLargerThan60HZ { + id mockDisplayLinkManager = [OCMockObject mockForClass:[DisplayLinkManager class]]; + double maxFrameRate = 120; + [[[mockDisplayLinkManager stub] andReturnValue:@(maxFrameRate)] displayRefreshRate]; + FlutterEngine* engine = [[FlutterEngine alloc] init]; + [engine runWithEntrypoint:nil]; + FlutterViewController* viewController = + [[FlutterViewController alloc] initWithEngine:engine nibName:nil bundle:nil]; + [viewController createTouchRateCorrectionVSyncClientIfNeeded]; + XCTAssertNotNil(viewController.touchRateCorrectionVSyncClient); +} + +- (void)testCreateTouchRateCorrectionVSyncClientWillNotCreateNewVSyncClientWhenClientAlreadyExists { + id mockDisplayLinkManager = [OCMockObject mockForClass:[DisplayLinkManager class]]; + double maxFrameRate = 120; + [[[mockDisplayLinkManager stub] andReturnValue:@(maxFrameRate)] displayRefreshRate]; + + FlutterEngine* engine = [[FlutterEngine alloc] init]; + [engine runWithEntrypoint:nil]; + FlutterViewController* viewController = + [[FlutterViewController alloc] initWithEngine:engine nibName:nil bundle:nil]; + [viewController createTouchRateCorrectionVSyncClientIfNeeded]; + VSyncClient* clientBefore = viewController.touchRateCorrectionVSyncClient; + XCTAssertNotNil(clientBefore); + + [viewController createTouchRateCorrectionVSyncClientIfNeeded]; + VSyncClient* clientAfter = viewController.touchRateCorrectionVSyncClient; + XCTAssertNotNil(clientAfter); + + XCTAssertTrue(clientBefore == clientAfter); +} + +- (void)testCreateTouchRateCorrectionVSyncClientWillNotCreateVsyncClientWhenRefreshRateIs60HZ { + id mockDisplayLinkManager = [OCMockObject mockForClass:[DisplayLinkManager class]]; + double maxFrameRate = 60; + [[[mockDisplayLinkManager stub] andReturnValue:@(maxFrameRate)] displayRefreshRate]; + FlutterEngine* engine = [[FlutterEngine alloc] init]; + [engine runWithEntrypoint:nil]; + FlutterViewController* viewController = + [[FlutterViewController alloc] initWithEngine:engine nibName:nil bundle:nil]; + [viewController createTouchRateCorrectionVSyncClientIfNeeded]; + XCTAssertNil(viewController.touchRateCorrectionVSyncClient); +} + +- (void)testTriggerTouchRateCorrectionVSyncClientCorrectly { + id mockDisplayLinkManager = [OCMockObject mockForClass:[DisplayLinkManager class]]; + double maxFrameRate = 120; + [[[mockDisplayLinkManager stub] andReturnValue:@(maxFrameRate)] displayRefreshRate]; + FlutterEngine* engine = [[FlutterEngine alloc] init]; + [engine runWithEntrypoint:nil]; + FlutterViewController* viewController = + [[FlutterViewController alloc] initWithEngine:engine nibName:nil bundle:nil]; + [viewController loadView]; + [viewController viewDidLoad]; + + VSyncClient* client = viewController.touchRateCorrectionVSyncClient; + CADisplayLink* link = [client getDisplayLink]; + + UITouch* fakeTouchBegan = [[UITouch alloc] init]; + fakeTouchBegan.phase = UITouchPhaseBegan; + + UITouch* fakeTouchMove = [[UITouch alloc] init]; + fakeTouchMove.phase = UITouchPhaseMoved; + + UITouch* fakeTouchEnd = [[UITouch alloc] init]; + fakeTouchEnd.phase = UITouchPhaseEnded; + + UITouch* fakeTouchCancelled = [[UITouch alloc] init]; + fakeTouchCancelled.phase = UITouchPhaseCancelled; + + [viewController + triggerTouchRateCorrectionIfNeeded:[[NSSet alloc] initWithObjects:fakeTouchBegan, nil]]; + XCTAssertFalse(link.isPaused); + + [viewController + triggerTouchRateCorrectionIfNeeded:[[NSSet alloc] initWithObjects:fakeTouchEnd, nil]]; + XCTAssertTrue(link.isPaused); + + [viewController + triggerTouchRateCorrectionIfNeeded:[[NSSet alloc] initWithObjects:fakeTouchMove, nil]]; + XCTAssertFalse(link.isPaused); + + [viewController + triggerTouchRateCorrectionIfNeeded:[[NSSet alloc] initWithObjects:fakeTouchCancelled, nil]]; + XCTAssertTrue(link.isPaused); + + [viewController + triggerTouchRateCorrectionIfNeeded:[[NSSet alloc] + initWithObjects:fakeTouchBegan, fakeTouchEnd, nil]]; + XCTAssertFalse(link.isPaused); + + [viewController + triggerTouchRateCorrectionIfNeeded:[[NSSet alloc] + initWithObjects:fakeTouchEnd, fakeTouchCancelled, nil]]; + XCTAssertTrue(link.isPaused); + + [viewController + triggerTouchRateCorrectionIfNeeded:[[NSSet alloc] + initWithObjects:fakeTouchMove, fakeTouchEnd, nil]]; + XCTAssertFalse(link.isPaused); +} + +- (void)testFlutterViewControllerStartKeyboardAnimationWillCreateVsyncClientCorrectly { + FlutterEngine* engine = [[FlutterEngine alloc] init]; + [engine runWithEntrypoint:nil]; + FlutterViewController* viewController = + [[FlutterViewController alloc] initWithEngine:engine nibName:nil bundle:nil]; + viewController.targetViewInsetBottom = 100; + [viewController startKeyBoardAnimation:0.25]; + XCTAssertNotNil(viewController.keyboardAnimationVSyncClient); +} + +- (void) + testSetupKeyboardAnimationVsyncClientWillNotCreateNewVsyncClientWhenKeyboardAnimationCallbackIsNil { + FlutterEngine* engine = [[FlutterEngine alloc] init]; + [engine runWithEntrypoint:nil]; + FlutterViewController* viewController = + [[FlutterViewController alloc] initWithEngine:engine nibName:nil bundle:nil]; + [viewController setUpKeyboardAnimationVsyncClient:nil]; + XCTAssertNil(viewController.keyboardAnimationVSyncClient); +} + @end diff --git a/shell/platform/darwin/ios/framework/Source/FlutterViewControllerTest_mrc.mm b/shell/platform/darwin/ios/framework/Source/FlutterViewControllerTest_mrc.mm deleted file mode 100644 index c0bd4ea9afe92..0000000000000 --- a/shell/platform/darwin/ios/framework/Source/FlutterViewControllerTest_mrc.mm +++ /dev/null @@ -1,203 +0,0 @@ -// 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/common/framework/Headers/FlutterMacros.h" -#import "flutter/shell/platform/darwin/ios/framework/Headers/FlutterViewController.h" -#import "flutter/shell/platform/darwin/ios/framework/Source/FlutterViewController_Internal.h" -#import "flutter/shell/platform/darwin/ios/framework/Source/vsync_waiter_ios.h" - -FLUTTER_ASSERT_NOT_ARC - -@interface UITouch () - -@property(nonatomic, readwrite) UITouchPhase phase; - -@end - -@interface VSyncClient (Testing) - -- (CADisplayLink*)getDisplayLink; - -@end - -@interface FlutterViewController (Testing) - -@property(nonatomic, assign) double targetViewInsetBottom; -@property(nonatomic, retain) VSyncClient* keyboardAnimationVSyncClient; - -@property(nonatomic, retain) VSyncClient* touchRateCorrectionVSyncClient; - -- (void)createTouchRateCorrectionVSyncClientIfNeeded; -- (void)setUpKeyboardAnimationVsyncClient: - (FlutterKeyboardAnimationCallback)keyboardAnimationCallback; -- (void)startKeyBoardAnimation:(NSTimeInterval)duration; -- (void)triggerTouchRateCorrectionIfNeeded:(NSSet*)touches; - -@end - -@interface FlutterViewControllerTest_mrc : XCTestCase -@end - -@implementation FlutterViewControllerTest_mrc - -- (void)testSetupKeyboardAnimationVsyncClientWillCreateNewVsyncClientForFlutterViewController { - id bundleMock = OCMPartialMock([NSBundle mainBundle]); - OCMStub([bundleMock objectForInfoDictionaryKey:@"CADisableMinimumFrameDurationOnPhone"]) - .andReturn(@YES); - id mockDisplayLinkManager = [OCMockObject mockForClass:[DisplayLinkManager class]]; - double maxFrameRate = 120; - [[[mockDisplayLinkManager stub] andReturnValue:@(maxFrameRate)] displayRefreshRate]; - FlutterEngine* engine = [[[FlutterEngine alloc] init] autorelease]; - [engine runWithEntrypoint:nil]; - FlutterViewController* viewController = - [[[FlutterViewController alloc] initWithEngine:engine nibName:nil bundle:nil] autorelease]; - FlutterKeyboardAnimationCallback callback = ^(fml::TimePoint targetTime) { - }; - [viewController setUpKeyboardAnimationVsyncClient:callback]; - XCTAssertNotNil(viewController.keyboardAnimationVSyncClient); - CADisplayLink* link = [viewController.keyboardAnimationVSyncClient getDisplayLink]; - XCTAssertNotNil(link); - if (@available(iOS 15.0, *)) { - XCTAssertEqual(link.preferredFrameRateRange.maximum, maxFrameRate); - XCTAssertEqual(link.preferredFrameRateRange.preferred, maxFrameRate); - XCTAssertEqual(link.preferredFrameRateRange.minimum, maxFrameRate / 2); - } else { - XCTAssertEqual(link.preferredFramesPerSecond, maxFrameRate); - } -} - -- (void) - testCreateTouchRateCorrectionVSyncClientWillCreateVsyncClientWhenRefreshRateIsLargerThan60HZ { - id mockDisplayLinkManager = [OCMockObject mockForClass:[DisplayLinkManager class]]; - double maxFrameRate = 120; - [[[mockDisplayLinkManager stub] andReturnValue:@(maxFrameRate)] displayRefreshRate]; - FlutterEngine* engine = [[[FlutterEngine alloc] init] autorelease]; - [engine runWithEntrypoint:nil]; - FlutterViewController* viewController = - [[[FlutterViewController alloc] initWithEngine:engine nibName:nil bundle:nil] autorelease]; - [viewController createTouchRateCorrectionVSyncClientIfNeeded]; - XCTAssertNotNil(viewController.touchRateCorrectionVSyncClient); -} - -- (void)testCreateTouchRateCorrectionVSyncClientWillNotCreateNewVSyncClientWhenClientAlreadyExists { - id mockDisplayLinkManager = [OCMockObject mockForClass:[DisplayLinkManager class]]; - double maxFrameRate = 120; - [[[mockDisplayLinkManager stub] andReturnValue:@(maxFrameRate)] displayRefreshRate]; - - FlutterEngine* engine = [[[FlutterEngine alloc] init] autorelease]; - [engine runWithEntrypoint:nil]; - FlutterViewController* viewController = - [[[FlutterViewController alloc] initWithEngine:engine nibName:nil bundle:nil] autorelease]; - [viewController createTouchRateCorrectionVSyncClientIfNeeded]; - VSyncClient* clientBefore = viewController.touchRateCorrectionVSyncClient; - XCTAssertNotNil(clientBefore); - - [viewController createTouchRateCorrectionVSyncClientIfNeeded]; - VSyncClient* clientAfter = viewController.touchRateCorrectionVSyncClient; - XCTAssertNotNil(clientAfter); - - XCTAssertTrue(clientBefore == clientAfter); -} - -- (void)testCreateTouchRateCorrectionVSyncClientWillNotCreateVsyncClientWhenRefreshRateIs60HZ { - id mockDisplayLinkManager = [OCMockObject mockForClass:[DisplayLinkManager class]]; - double maxFrameRate = 60; - [[[mockDisplayLinkManager stub] andReturnValue:@(maxFrameRate)] displayRefreshRate]; - FlutterEngine* engine = [[[FlutterEngine alloc] init] autorelease]; - [engine runWithEntrypoint:nil]; - FlutterViewController* viewController = - [[[FlutterViewController alloc] initWithEngine:engine nibName:nil bundle:nil] autorelease]; - [viewController createTouchRateCorrectionVSyncClientIfNeeded]; - XCTAssertNil(viewController.touchRateCorrectionVSyncClient); -} - -- (void)testTriggerTouchRateCorrectionVSyncClientCorrectly { - id mockDisplayLinkManager = [OCMockObject mockForClass:[DisplayLinkManager class]]; - double maxFrameRate = 120; - [[[mockDisplayLinkManager stub] andReturnValue:@(maxFrameRate)] displayRefreshRate]; - FlutterEngine* engine = [[[FlutterEngine alloc] init] autorelease]; - [engine runWithEntrypoint:nil]; - FlutterViewController* viewController = - [[[FlutterViewController alloc] initWithEngine:engine nibName:nil bundle:nil] autorelease]; - [viewController loadView]; - [viewController viewDidLoad]; - - VSyncClient* client = viewController.touchRateCorrectionVSyncClient; - CADisplayLink* link = [client getDisplayLink]; - - UITouch* fakeTouchBegan = [[[UITouch alloc] init] autorelease]; - fakeTouchBegan.phase = UITouchPhaseBegan; - - UITouch* fakeTouchMove = [[[UITouch alloc] init] autorelease]; - fakeTouchMove.phase = UITouchPhaseMoved; - - UITouch* fakeTouchEnd = [[[UITouch alloc] init] autorelease]; - fakeTouchEnd.phase = UITouchPhaseEnded; - - UITouch* fakeTouchCancelled = [[[UITouch alloc] init] autorelease]; - fakeTouchCancelled.phase = UITouchPhaseCancelled; - - [viewController - triggerTouchRateCorrectionIfNeeded:[[[NSSet alloc] initWithObjects:fakeTouchBegan, nil] - autorelease]]; - XCTAssertFalse(link.isPaused); - - [viewController - triggerTouchRateCorrectionIfNeeded:[[[NSSet alloc] initWithObjects:fakeTouchEnd, nil] - autorelease]]; - XCTAssertTrue(link.isPaused); - - [viewController - triggerTouchRateCorrectionIfNeeded:[[[NSSet alloc] initWithObjects:fakeTouchMove, nil] - autorelease]]; - XCTAssertFalse(link.isPaused); - - [viewController - triggerTouchRateCorrectionIfNeeded:[[[NSSet alloc] initWithObjects:fakeTouchCancelled, nil] - autorelease]]; - XCTAssertTrue(link.isPaused); - - [viewController - triggerTouchRateCorrectionIfNeeded:[[[NSSet alloc] - initWithObjects:fakeTouchBegan, fakeTouchEnd, nil] - autorelease]]; - XCTAssertFalse(link.isPaused); - - [viewController - triggerTouchRateCorrectionIfNeeded:[[[NSSet alloc] - initWithObjects:fakeTouchEnd, fakeTouchCancelled, nil] - autorelease]]; - XCTAssertTrue(link.isPaused); - - [viewController - triggerTouchRateCorrectionIfNeeded:[[[NSSet alloc] - initWithObjects:fakeTouchMove, fakeTouchEnd, nil] - autorelease]]; - XCTAssertFalse(link.isPaused); -} - -- (void)testFlutterViewControllerStartKeyboardAnimationWillCreateVsyncClientCorrectly { - FlutterEngine* engine = [[[FlutterEngine alloc] init] autorelease]; - [engine runWithEntrypoint:nil]; - FlutterViewController* viewController = - [[[FlutterViewController alloc] initWithEngine:engine nibName:nil bundle:nil] autorelease]; - viewController.targetViewInsetBottom = 100; - [viewController startKeyBoardAnimation:0.25]; - XCTAssertNotNil(viewController.keyboardAnimationVSyncClient); -} - -- (void) - testSetupKeyboardAnimationVsyncClientWillNotCreateNewVsyncClientWhenKeyboardAnimationCallbackIsNil { - FlutterEngine* engine = [[[FlutterEngine alloc] init] autorelease]; - [engine runWithEntrypoint:nil]; - FlutterViewController* viewController = - [[[FlutterViewController alloc] initWithEngine:engine nibName:nil bundle:nil] autorelease]; - [viewController setUpKeyboardAnimationVsyncClient:nil]; - XCTAssertNil(viewController.keyboardAnimationVSyncClient); -} - -@end diff --git a/shell/platform/darwin/ios/framework/Source/SemanticsObjectTest.mm b/shell/platform/darwin/ios/framework/Source/SemanticsObjectTest.mm index 3d7f2cdf0163e..3306386307a76 100644 --- a/shell/platform/darwin/ios/framework/Source/SemanticsObjectTest.mm +++ b/shell/platform/darwin/ios/framework/Source/SemanticsObjectTest.mm @@ -8,6 +8,9 @@ #import "flutter/shell/platform/darwin/common/framework/Headers/FlutterMacros.h" #import "flutter/shell/platform/darwin/ios/framework/Source/SemanticsObject.h" #import "flutter/shell/platform/darwin/ios/framework/Source/SemanticsObjectTestMocks.h" +#import "flutter/shell/platform/darwin/ios/framework/Source/FlutterTouchInterceptingView_Test.h" +#import "flutter/shell/platform/darwin/ios/framework/Source/FlutterPlatformViews_Internal.h" +#import "flutter/shell/platform/darwin/ios/framework/Source/SemanticsObjectTestMocks.h" FLUTTER_ASSERT_ARC @@ -922,4 +925,53 @@ - (void)testFlutterSemanticsObjectReturnsNilContainerWhenBridgeIsNotAlive { XCTAssertNil(object2.accessibilityContainer); } +- (void)testAccessibilityHitTestSearchCanReturnPlatformView { + fml::WeakPtrFactory factory( + new flutter::MockAccessibilityBridge()); + fml::WeakPtr bridge = factory.GetWeakPtr(); + SemanticsObject* object0 = [[SemanticsObject alloc] initWithBridge:bridge uid:0]; + SemanticsObject* object1 = [[SemanticsObject alloc] initWithBridge:bridge uid:1]; + SemanticsObject* object3 = [[SemanticsObject alloc] initWithBridge:bridge uid:3]; + FlutterTouchInterceptingView* platformView = + [[FlutterTouchInterceptingView alloc] initWithFrame:CGRectMake(0, 0, 100, 100)]; + FlutterPlatformViewSemanticsContainer* platformViewSemanticsContainer = + [[FlutterPlatformViewSemanticsContainer alloc] initWithBridge:bridge + uid:1 + platformView:platformView]; + + object0.children = @[ object1 ]; + object0.childrenInHitTestOrder = @[ object1 ]; + object1.children = @[ platformViewSemanticsContainer, object3 ]; + object1.childrenInHitTestOrder = @[ platformViewSemanticsContainer, object3 ]; + + flutter::SemanticsNode node0; + node0.id = 0; + node0.rect = SkRect::MakeXYWH(0, 0, 200, 200); + node0.label = "0"; + [object0 setSemanticsNode:&node0]; + + flutter::SemanticsNode node1; + node1.id = 1; + node1.rect = SkRect::MakeXYWH(0, 0, 200, 200); + node1.label = "1"; + [object1 setSemanticsNode:&node1]; + + flutter::SemanticsNode node2; + node2.id = 2; + node2.rect = SkRect::MakeXYWH(0, 0, 100, 100); + node2.label = "2"; + [platformViewSemanticsContainer setSemanticsNode:&node2]; + + flutter::SemanticsNode node3; + node3.id = 3; + node3.rect = SkRect::MakeXYWH(0, 0, 200, 200); + node3.label = "3"; + [object3 setSemanticsNode:&node3]; + + CGPoint point = CGPointMake(10, 10); + id hitTestResult = [object0 _accessibilityHitTest:point withEvent:nil]; + + XCTAssertEqual(hitTestResult, platformView); +} + @end diff --git a/shell/platform/darwin/ios/framework/Source/SemanticsObjectTest_mrc.mm b/shell/platform/darwin/ios/framework/Source/SemanticsObjectTest_mrc.mm index 0567e37c0e30e..32c1b30fc39c3 100644 --- a/shell/platform/darwin/ios/framework/Source/SemanticsObjectTest_mrc.mm +++ b/shell/platform/darwin/ios/framework/Source/SemanticsObjectTest_mrc.mm @@ -18,55 +18,6 @@ @interface SemanticsObjectTestMRC : XCTestCase @implementation SemanticsObjectTestMRC -- (void)testAccessibilityHitTestSearchCanReturnPlatformView { - fml::WeakPtrFactory factory( - new flutter::MockAccessibilityBridge()); - fml::WeakPtr bridge = factory.GetWeakPtr(); - SemanticsObject* object0 = [[[SemanticsObject alloc] initWithBridge:bridge uid:0] autorelease]; - SemanticsObject* object1 = [[[SemanticsObject alloc] initWithBridge:bridge uid:1] autorelease]; - SemanticsObject* object3 = [[[SemanticsObject alloc] initWithBridge:bridge uid:3] autorelease]; - FlutterTouchInterceptingView* platformView = - [[[FlutterTouchInterceptingView alloc] initWithFrame:CGRectMake(0, 0, 100, 100)] autorelease]; - FlutterPlatformViewSemanticsContainer* platformViewSemanticsContainer = - [[[FlutterPlatformViewSemanticsContainer alloc] initWithBridge:bridge - uid:1 - platformView:platformView] autorelease]; - - object0.children = @[ object1 ]; - object0.childrenInHitTestOrder = @[ object1 ]; - object1.children = @[ platformViewSemanticsContainer, object3 ]; - object1.childrenInHitTestOrder = @[ platformViewSemanticsContainer, object3 ]; - - flutter::SemanticsNode node0; - node0.id = 0; - node0.rect = SkRect::MakeXYWH(0, 0, 200, 200); - node0.label = "0"; - [object0 setSemanticsNode:&node0]; - - flutter::SemanticsNode node1; - node1.id = 1; - node1.rect = SkRect::MakeXYWH(0, 0, 200, 200); - node1.label = "1"; - [object1 setSemanticsNode:&node1]; - - flutter::SemanticsNode node2; - node2.id = 2; - node2.rect = SkRect::MakeXYWH(0, 0, 100, 100); - node2.label = "2"; - [platformViewSemanticsContainer setSemanticsNode:&node2]; - - flutter::SemanticsNode node3; - node3.id = 3; - node3.rect = SkRect::MakeXYWH(0, 0, 200, 200); - node3.label = "3"; - [object3 setSemanticsNode:&node3]; - - CGPoint point = CGPointMake(10, 10); - id hitTestResult = [object0 _accessibilityHitTest:point withEvent:nil]; - - XCTAssertEqual(hitTestResult, platformView); -} - - (void)testFlutterPlatformViewSemanticsContainer { fml::WeakPtrFactory factory( new flutter::MockAccessibilityBridge()); From 8a6dc12aaaaa430b3be80528cb72277c5bd7ead7 Mon Sep 17 00:00:00 2001 From: Chris Yang Date: Thu, 16 Nov 2023 15:50:40 -0800 Subject: [PATCH 2/4] move mrc ios tests to arc --- ci/licenses_golden/licenses_flutter | 2 - shell/platform/darwin/ios/BUILD.gn | 60 +---- .../Source/FlutterEngineGroupTest.mm | 202 +++++++------- .../ios/framework/Source/FlutterEngineTest.mm | 3 +- .../Source/FlutterPlatformPluginTest.mm | 44 ++- .../framework/Source/FlutterPlatformViews.mm | 2 +- .../Source/FlutterPlatformViewsTest.mm | 252 +++++++++--------- .../Source/FlutterPlatformViews_Internal.h | 2 +- .../Source/FlutterViewControllerTest.mm | 43 +-- .../ios/framework/Source/FlutterViewTest.mm | 17 +- .../framework/Source/SemanticsObjectTest.mm | 29 +- .../Source/SemanticsObjectTest_mrc.mm | 40 --- .../Source/accessibility_bridge_test.mm | 54 ++-- .../ios/platform_message_handler_ios_test.mm | 3 - 14 files changed, 331 insertions(+), 422 deletions(-) delete mode 100644 shell/platform/darwin/ios/framework/Source/SemanticsObjectTest_mrc.mm diff --git a/ci/licenses_golden/licenses_flutter b/ci/licenses_golden/licenses_flutter index c679184313659..25f5888f8cbd3 100644 --- a/ci/licenses_golden/licenses_flutter +++ b/ci/licenses_golden/licenses_flutter @@ -4579,7 +4579,6 @@ ORIGIN: ../../../flutter/shell/platform/darwin/ios/framework/Source/SemanticsObj ORIGIN: ../../../flutter/shell/platform/darwin/ios/framework/Source/SemanticsObject.mm + ../../../flutter/LICENSE ORIGIN: ../../../flutter/shell/platform/darwin/ios/framework/Source/SemanticsObjectTest.mm + ../../../flutter/LICENSE ORIGIN: ../../../flutter/shell/platform/darwin/ios/framework/Source/SemanticsObjectTestMocks.h + ../../../flutter/LICENSE -ORIGIN: ../../../flutter/shell/platform/darwin/ios/framework/Source/SemanticsObjectTest_mrc.mm + ../../../flutter/LICENSE ORIGIN: ../../../flutter/shell/platform/darwin/ios/framework/Source/UIViewController+FlutterScreenAndSceneIfLoaded.h + ../../../flutter/LICENSE ORIGIN: ../../../flutter/shell/platform/darwin/ios/framework/Source/UIViewController+FlutterScreenAndSceneIfLoaded.mm + ../../../flutter/LICENSE ORIGIN: ../../../flutter/shell/platform/darwin/ios/framework/Source/UIViewController_FlutterScreenAndSceneIfLoadedTest.mm + ../../../flutter/LICENSE @@ -7364,7 +7363,6 @@ FILE: ../../../flutter/shell/platform/darwin/ios/framework/Source/SemanticsObjec FILE: ../../../flutter/shell/platform/darwin/ios/framework/Source/SemanticsObject.mm FILE: ../../../flutter/shell/platform/darwin/ios/framework/Source/SemanticsObjectTest.mm FILE: ../../../flutter/shell/platform/darwin/ios/framework/Source/SemanticsObjectTestMocks.h -FILE: ../../../flutter/shell/platform/darwin/ios/framework/Source/SemanticsObjectTest_mrc.mm FILE: ../../../flutter/shell/platform/darwin/ios/framework/Source/UIViewController+FlutterScreenAndSceneIfLoaded.h FILE: ../../../flutter/shell/platform/darwin/ios/framework/Source/UIViewController+FlutterScreenAndSceneIfLoaded.mm FILE: ../../../flutter/shell/platform/darwin/ios/framework/Source/UIViewController_FlutterScreenAndSceneIfLoadedTest.mm diff --git a/shell/platform/darwin/ios/BUILD.gn b/shell/platform/darwin/ios/BUILD.gn index 831d20eec88dc..37ad31f2288cc 100644 --- a/shell/platform/darwin/ios/BUILD.gn +++ b/shell/platform/darwin/ios/BUILD.gn @@ -74,6 +74,9 @@ source_set("flutter_framework_source") { deps = [] sources = [ + # iOS embedder is migrating to ARC. + # New files are highly encouraged to be in ARC. + # To add new files in ARC, add them to the `flutter_framework_source_arc` target. "framework/Source/FlutterAppDelegate.mm", "framework/Source/FlutterCallbackCache.mm", "framework/Source/FlutterCallbackCache_Internal.h", @@ -219,53 +222,6 @@ source_set("flutter_framework_source") { platform_frameworks_path = rebase_path("$ios_sdk_path/../../Library/Frameworks/") -# For tests that rely on manual reference counting. -source_set("ios_test_flutter_mrc") { - visibility = [ ":*" ] - cflags = [ - "-fvisibility=default", - "-F$platform_frameworks_path", - "-mios-simulator-version-min=$ios_testing_deployment_target", - ] - - # XCode 15 beta has a bug where iOS 17 API usage is not guarded. - # This bug results engine build failure since the engine treats warnings as errors. - # The `-Wno-unguarded-availability-new` can be removed when the XCode bug is fixed. - # See details in https://github.com/flutter/flutter/issues/128958. - cflags_objcc = [ "-Wno-unguarded-availability-new" ] - sources = [ - "framework/Source/FlutterPlatformViewsTest.mm", - "framework/Source/FlutterTouchInterceptingView_Test.h", - "framework/Source/FlutterViewTest.mm", - "framework/Source/SemanticsObjectTestMocks.h", - "framework/Source/SemanticsObjectTest_mrc.mm", - "framework/Source/accessibility_bridge_test.mm", - "platform_message_handler_ios_test.mm", - ] - deps = [ - ":flutter_framework_source", - ":flutter_framework_source_arc", - "//flutter/common:common", - "//flutter/lib/ui:ui", - "//flutter/shell/common:common", - "//flutter/shell/platform/darwin/common:framework_common", - "//flutter/shell/platform/embedder:embedder_as_internal_library", - "//flutter/skia", - "//flutter/third_party/rapidjson", - "//flutter/third_party/tonic", - "//flutter/third_party/txt", - "//third_party/ocmock:ocmock_shared", - ] - - if (shell_enable_vulkan) { - deps += [ "//flutter/vulkan" ] - } - - if (darwin_extension_safe) { - defines = [ "APPLICATION_EXTENSION_API_ONLY=1" ] - } -} - shared_library("ios_test_flutter") { testonly = true visibility = [ "*" ] @@ -291,36 +247,40 @@ shared_library("ios_test_flutter") { "//build/config:symbol_visibility_hidden", ] sources = [ - "framework/Source/FlutterPlatformPluginTest.mm", - "framework/Source/FlutterEnginePlatformViewTest.mm", "framework/Source/FlutterAppDelegateTest.mm", "framework/Source/FlutterChannelKeyResponderTest.mm", "framework/Source/FlutterDartProjectTest.mm", "framework/Source/FlutterEmbedderKeyResponderTest.mm", "framework/Source/FlutterEngineGroupTest.mm", + "framework/Source/FlutterEnginePlatformViewTest.mm", "framework/Source/FlutterEngineTest.mm", "framework/Source/FlutterFakeKeyEvents.h", "framework/Source/FlutterFakeKeyEvents.mm", "framework/Source/FlutterKeyboardManagerTest.mm", "framework/Source/FlutterPlatformPluginTest.mm", + "framework/Source/FlutterPlatformViewsTest.mm", "framework/Source/FlutterPluginAppLifeCycleDelegateTest.mm", "framework/Source/FlutterRestorationPluginTest.mm", "framework/Source/FlutterSpellCheckPluginTest.mm", "framework/Source/FlutterTextInputPluginTest.mm", "framework/Source/FlutterTextureRegistryRelayTest.mm", + "framework/Source/FlutterTouchInterceptingView_Test.h", "framework/Source/FlutterUndoManagerPluginTest.mm", "framework/Source/FlutterViewControllerTest.mm", + "framework/Source/FlutterViewTest.mm", "framework/Source/SemanticsObjectTest.mm", + "framework/Source/SemanticsObjectTestMocks.h", "framework/Source/UIViewController_FlutterScreenAndSceneIfLoadedTest.mm", "framework/Source/VsyncWaiterIosTest.mm", + "framework/Source/accessibility_bridge_test.mm", "framework/Source/connection_collection_test.mm", + "platform_message_handler_ios_test.mm", ] deps = [ ":flutter_framework", ":flutter_framework_source", ":flutter_framework_source_arc", ":ios_gpu_configuration", - ":ios_test_flutter_mrc", "//flutter/common:common", "//flutter/lib/ui:ui", "//flutter/shell/platform/darwin/common:framework_common", diff --git a/shell/platform/darwin/ios/framework/Source/FlutterEngineGroupTest.mm b/shell/platform/darwin/ios/framework/Source/FlutterEngineGroupTest.mm index 297fa3bb0568c..77929ea6b4c20 100644 --- a/shell/platform/darwin/ios/framework/Source/FlutterEngineGroupTest.mm +++ b/shell/platform/darwin/ios/framework/Source/FlutterEngineGroupTest.mm @@ -20,125 +20,125 @@ @interface FlutterEngineGroupTest : XCTestCase @implementation FlutterEngineGroupTest - (void)testMake { - FlutterEngineGroup* group = [[FlutterEngineGroup alloc] initWithName:@"foo" project:nil]; - FlutterEngine* engine = [group makeEngineWithEntrypoint:nil libraryURI:nil]; - XCTAssertNotNil(engine); + FlutterEngineGroup* group = [[FlutterEngineGroup alloc] initWithName:@"foo" project:nil]; + FlutterEngine* engine = [group makeEngineWithEntrypoint:nil libraryURI:nil]; + XCTAssertNotNil(engine); } - (void)testSpawn { - FlutterEngineGroup* group = [[FlutterEngineGroup alloc] initWithName:@"foo" project:nil]; - FlutterEngine* spawner = [group makeEngineWithEntrypoint:nil libraryURI:nil]; - spawner.isGpuDisabled = YES; - FlutterEngine* spawnee = [group makeEngineWithEntrypoint:nil libraryURI:nil]; - XCTAssertNotNil(spawner); - XCTAssertNotNil(spawnee); - XCTAssertEqual(&spawner.threadHost, &spawnee.threadHost); - XCTAssertEqual(spawner.isGpuDisabled, spawnee.isGpuDisabled); + FlutterEngineGroup* group = [[FlutterEngineGroup alloc] initWithName:@"foo" project:nil]; + FlutterEngine* spawner = [group makeEngineWithEntrypoint:nil libraryURI:nil]; + spawner.isGpuDisabled = YES; + FlutterEngine* spawnee = [group makeEngineWithEntrypoint:nil libraryURI:nil]; + XCTAssertNotNil(spawner); + XCTAssertNotNil(spawnee); + XCTAssertEqual(&spawner.threadHost, &spawnee.threadHost); + XCTAssertEqual(spawner.isGpuDisabled, spawnee.isGpuDisabled); } - (void)testDeleteLastEngine { - FlutterEngineGroup* group = [[FlutterEngineGroup alloc] initWithName:@"foo" project:nil]; - @autoreleasepool { - FlutterEngine* spawner = [group makeEngineWithEntrypoint:nil libraryURI:nil]; - XCTAssertNotNil(spawner); - } - FlutterEngine* spawnee = [group makeEngineWithEntrypoint:nil libraryURI:nil]; - XCTAssertNotNil(spawnee); + FlutterEngineGroup* group = [[FlutterEngineGroup alloc] initWithName:@"foo" project:nil]; + @autoreleasepool { + FlutterEngine* spawner = [group makeEngineWithEntrypoint:nil libraryURI:nil]; + XCTAssertNotNil(spawner); + } + FlutterEngine* spawnee = [group makeEngineWithEntrypoint:nil libraryURI:nil]; + XCTAssertNotNil(spawnee); } - (void)testCustomEntrypoint { - FlutterEngineGroup* group = OCMPartialMock([[FlutterEngineGroup alloc] initWithName:@"foo" - project:nil]); - FlutterEngine* mockEngine = OCMClassMock([FlutterEngine class]); - OCMStub([group makeEngine]).andReturn(mockEngine); - OCMStub([mockEngine spawnWithEntrypoint:[OCMArg any] - libraryURI:[OCMArg any] - initialRoute:[OCMArg any] - entrypointArgs:[OCMArg any]]) - .andReturn(OCMClassMock([FlutterEngine class])); - FlutterEngine* spawner = [group makeEngineWithEntrypoint:@"firstEntrypoint" - libraryURI:@"firstLibraryURI"]; - XCTAssertNotNil(spawner); - OCMVerify([spawner runWithEntrypoint:@"firstEntrypoint" - libraryURI:@"firstLibraryURI" - initialRoute:nil - entrypointArgs:nil]); - - FlutterEngine* spawnee = [group makeEngineWithEntrypoint:@"secondEntrypoint" - libraryURI:@"secondLibraryURI"]; - XCTAssertNotNil(spawnee); - OCMVerify([spawner spawnWithEntrypoint:@"secondEntrypoint" - libraryURI:@"secondLibraryURI" - initialRoute:nil - entrypointArgs:nil]); + FlutterEngineGroup* group = OCMPartialMock([[FlutterEngineGroup alloc] initWithName:@"foo" + project:nil]); + FlutterEngine* mockEngine = OCMClassMock([FlutterEngine class]); + OCMStub([group makeEngine]).andReturn(mockEngine); + OCMStub([mockEngine spawnWithEntrypoint:[OCMArg any] + libraryURI:[OCMArg any] + initialRoute:[OCMArg any] + entrypointArgs:[OCMArg any]]) + .andReturn(OCMClassMock([FlutterEngine class])); + FlutterEngine* spawner = [group makeEngineWithEntrypoint:@"firstEntrypoint" + libraryURI:@"firstLibraryURI"]; + XCTAssertNotNil(spawner); + OCMVerify([spawner runWithEntrypoint:@"firstEntrypoint" + libraryURI:@"firstLibraryURI" + initialRoute:nil + entrypointArgs:nil]); + + FlutterEngine* spawnee = [group makeEngineWithEntrypoint:@"secondEntrypoint" + libraryURI:@"secondLibraryURI"]; + XCTAssertNotNil(spawnee); + OCMVerify([spawner spawnWithEntrypoint:@"secondEntrypoint" + libraryURI:@"secondLibraryURI" + initialRoute:nil + entrypointArgs:nil]); } - (void)testCustomInitialRoute { - FlutterEngineGroup* group = OCMPartialMock([[FlutterEngineGroup alloc] initWithName:@"foo" - project:nil]); - FlutterEngine* mockEngine = OCMClassMock([FlutterEngine class]); - OCMStub([group makeEngine]).andReturn(mockEngine); - OCMStub([mockEngine spawnWithEntrypoint:[OCMArg any] - libraryURI:[OCMArg any] - initialRoute:[OCMArg any] - entrypointArgs:[OCMArg any]]) - .andReturn(OCMClassMock([FlutterEngine class])); - FlutterEngine* spawner = [group makeEngineWithEntrypoint:nil libraryURI:nil initialRoute:@"foo"]; - XCTAssertNotNil(spawner); - OCMVerify([spawner runWithEntrypoint:nil libraryURI:nil initialRoute:@"foo" entrypointArgs:nil]); - - FlutterEngine* spawnee = [group makeEngineWithEntrypoint:nil libraryURI:nil initialRoute:@"bar"]; - XCTAssertNotNil(spawnee); - OCMVerify([spawner spawnWithEntrypoint:nil - libraryURI:nil - initialRoute:@"bar" - entrypointArgs:nil]); + FlutterEngineGroup* group = OCMPartialMock([[FlutterEngineGroup alloc] initWithName:@"foo" + project:nil]); + FlutterEngine* mockEngine = OCMClassMock([FlutterEngine class]); + OCMStub([group makeEngine]).andReturn(mockEngine); + OCMStub([mockEngine spawnWithEntrypoint:[OCMArg any] + libraryURI:[OCMArg any] + initialRoute:[OCMArg any] + entrypointArgs:[OCMArg any]]) + .andReturn(OCMClassMock([FlutterEngine class])); + FlutterEngine* spawner = [group makeEngineWithEntrypoint:nil libraryURI:nil initialRoute:@"foo"]; + XCTAssertNotNil(spawner); + OCMVerify([spawner runWithEntrypoint:nil libraryURI:nil initialRoute:@"foo" entrypointArgs:nil]); + + FlutterEngine* spawnee = [group makeEngineWithEntrypoint:nil libraryURI:nil initialRoute:@"bar"]; + XCTAssertNotNil(spawnee); + OCMVerify([spawner spawnWithEntrypoint:nil + libraryURI:nil + initialRoute:@"bar" + entrypointArgs:nil]); } - (void)testCustomEntrypointArgs { - FlutterEngineGroup* group = OCMPartialMock([[FlutterEngineGroup alloc] initWithName:@"foo" - project:nil]); - FlutterEngine* mockEngine = OCMClassMock([FlutterEngine class]); - OCMStub([group makeEngine]).andReturn(mockEngine); - OCMStub([mockEngine spawnWithEntrypoint:[OCMArg any] - libraryURI:[OCMArg any] - initialRoute:[OCMArg any] - entrypointArgs:[OCMArg any]]) - .andReturn(OCMClassMock([FlutterEngine class])); - FlutterEngineGroupOptions* firstOptions = [[FlutterEngineGroupOptions alloc] init]; - NSArray* firstEntrypointArgs = @[ @"foo", @"first" ]; - firstOptions.entrypointArgs = firstEntrypointArgs; - FlutterEngine* spawner = [group makeEngineWithOptions:firstOptions]; - XCTAssertNotNil(spawner); - OCMVerify([spawner runWithEntrypoint:nil - libraryURI:nil - initialRoute:nil - entrypointArgs:firstEntrypointArgs]); - - NSArray* secondEntrypointArgs = @[ @"bar", @"second" ]; - FlutterEngineGroupOptions* secondOptions = [[FlutterEngineGroupOptions alloc] init]; - secondOptions.entrypointArgs = secondEntrypointArgs; - FlutterEngine* spawnee = [group makeEngineWithOptions:secondOptions]; - XCTAssertNotNil(spawnee); - OCMVerify([spawner spawnWithEntrypoint:nil - libraryURI:nil - initialRoute:nil - entrypointArgs:secondEntrypointArgs]); + FlutterEngineGroup* group = OCMPartialMock([[FlutterEngineGroup alloc] initWithName:@"foo" + project:nil]); + FlutterEngine* mockEngine = OCMClassMock([FlutterEngine class]); + OCMStub([group makeEngine]).andReturn(mockEngine); + OCMStub([mockEngine spawnWithEntrypoint:[OCMArg any] + libraryURI:[OCMArg any] + initialRoute:[OCMArg any] + entrypointArgs:[OCMArg any]]) + .andReturn(OCMClassMock([FlutterEngine class])); + FlutterEngineGroupOptions* firstOptions = [[FlutterEngineGroupOptions alloc] init]; + NSArray* firstEntrypointArgs = @[ @"foo", @"first" ]; + firstOptions.entrypointArgs = firstEntrypointArgs; + FlutterEngine* spawner = [group makeEngineWithOptions:firstOptions]; + XCTAssertNotNil(spawner); + OCMVerify([spawner runWithEntrypoint:nil + libraryURI:nil + initialRoute:nil + entrypointArgs:firstEntrypointArgs]); + + NSArray* secondEntrypointArgs = @[ @"bar", @"second" ]; + FlutterEngineGroupOptions* secondOptions = [[FlutterEngineGroupOptions alloc] init]; + secondOptions.entrypointArgs = secondEntrypointArgs; + FlutterEngine* spawnee = [group makeEngineWithOptions:secondOptions]; + XCTAssertNotNil(spawnee); + OCMVerify([spawner spawnWithEntrypoint:nil + libraryURI:nil + initialRoute:nil + entrypointArgs:secondEntrypointArgs]); } - (void)testReleasesProjectOnDealloc { - __weak FlutterDartProject* weakProject; - @autoreleasepool { - FlutterDartProject* mockProject = OCMClassMock([FlutterDartProject class]); - FlutterEngineGroup* group = [[FlutterEngineGroup alloc] initWithName:@"foo" - project:mockProject]; - XCTAssertNotNil(group); - weakProject = mockProject; - XCTAssertNotNil(weakProject); - group = nil; - mockProject = nil; - } - XCTAssertNil(weakProject); + __weak FlutterDartProject* weakProject; + @autoreleasepool { + FlutterDartProject* mockProject = OCMClassMock([FlutterDartProject class]); + FlutterEngineGroup* group = [[FlutterEngineGroup alloc] initWithName:@"foo" + project:mockProject]; + XCTAssertNotNil(group); + weakProject = mockProject; + XCTAssertNotNil(weakProject); + group = nil; + mockProject = nil; + } + XCTAssertNil(weakProject); } @end diff --git a/shell/platform/darwin/ios/framework/Source/FlutterEngineTest.mm b/shell/platform/darwin/ios/framework/Source/FlutterEngineTest.mm index b748ace53722d..e0153800ed7a4 100644 --- a/shell/platform/darwin/ios/framework/Source/FlutterEngineTest.mm +++ b/shell/platform/darwin/ios/framework/Source/FlutterEngineTest.mm @@ -13,9 +13,9 @@ #import "flutter/shell/platform/darwin/common/framework/Headers/FlutterMacros.h" #import "flutter/shell/platform/darwin/common/framework/Source/FlutterBinaryMessengerRelay.h" #import "flutter/shell/platform/darwin/ios/framework/Source/FlutterDartProject_Internal.h" +#import "flutter/shell/platform/darwin/ios/framework/Source/FlutterEngine_Internal.h" #import "flutter/shell/platform/darwin/ios/framework/Source/FlutterEngine_Test.h" #import "flutter/shell/platform/darwin/ios/framework/Source/FlutterTextInputPlugin.h" -#import "flutter/shell/platform/darwin/ios/framework/Source/FlutterEngine_Internal.h" #import "flutter/shell/platform/darwin/ios/platform_view_ios.h" FLUTTER_ASSERT_ARC @@ -470,5 +470,4 @@ - (void)testEnableSemanticsWhenFlutterViewAccessibilityDidCall { XCTAssertTrue(engine.ensureSemanticsEnabledCalled); } - @end diff --git a/shell/platform/darwin/ios/framework/Source/FlutterPlatformPluginTest.mm b/shell/platform/darwin/ios/framework/Source/FlutterPlatformPluginTest.mm index 0c5dface26b01..894e1f30cd5e1 100644 --- a/shell/platform/darwin/ios/framework/Source/FlutterPlatformPluginTest.mm +++ b/shell/platform/darwin/ios/framework/Source/FlutterPlatformPluginTest.mm @@ -41,15 +41,13 @@ - (void)testSearchWebInvokedWithEscapedTerm { std::make_unique>(engine); [engine runWithEntrypoint:nil]; + XCTestExpectation* invokeExpectation = + [self expectationWithDescription:@"Web search launched with escaped search term"]; FlutterPlatformPlugin* plugin = [[FlutterPlatformPlugin alloc] initWithEngine:_weakFactory->GetWeakNSObject()]; FlutterPlatformPlugin* mockPlugin = OCMPartialMock(plugin); - FlutterPlatformPlugin* plugin = - [[FlutterPlatformPlugin alloc] initWithEngine:[engine getWeakPtr]]; - FlutterPlatformPlugin* mockPlugin = OCMPartialMock(plugin); - FlutterMethodCall* methodCall = [FlutterMethodCall methodCallWithMethodName:@"SearchWeb.invoke" arguments:@"Testing Word!"]; @@ -215,25 +213,25 @@ - (void)testClipboardSetDataToNullDoNotCrash { FlutterPlatformPlugin* plugin = [[FlutterPlatformPlugin alloc] initWithEngine:_weakFactory->GetWeakNSObject()]; -// XCTestExpectation* setStringExpectation = [self expectationWithDescription:@"setData"]; -// FlutterResult resultSet = ^(id result) { -// [setStringExpectation fulfill]; -// }; -// FlutterMethodCall* methodCallSet = -// [FlutterMethodCall methodCallWithMethodName:@"Clipboard.setData" -// arguments:@{@"text" : [NSNull null]}]; -// [plugin handleMethodCall:methodCallSet result:resultSet]; - -// XCTestExpectation* getDataExpectation = [self expectationWithDescription:@"getData"]; -// FlutterResult result = ^(id result) { -// XCTAssertEqualObjects(result[@"text"], @"null"); -// [getDataExpectation fulfill]; -// }; -// FlutterMethodCall* methodCall = [FlutterMethodCall methodCallWithMethodName:@"Clipboard.getData" -// arguments:@"text/plain"]; -// [plugin handleMethodCall:methodCall result:result]; -// [self waitForExpectationsWithTimeout:1 handler:nil]; -// } + XCTestExpectation* setStringExpectation = [self expectationWithDescription:@"setData"]; + FlutterResult resultSet = ^(id result) { + [setStringExpectation fulfill]; + }; + FlutterMethodCall* methodCallSet = + [FlutterMethodCall methodCallWithMethodName:@"Clipboard.setData" + arguments:@{@"text" : [NSNull null]}]; + [plugin handleMethodCall:methodCallSet result:resultSet]; + + XCTestExpectation* getDataExpectation = [self expectationWithDescription:@"getData"]; + FlutterResult result = ^(id result) { + XCTAssertEqualObjects(result[@"text"], @"null"); + [getDataExpectation fulfill]; + }; + FlutterMethodCall* methodCall = [FlutterMethodCall methodCallWithMethodName:@"Clipboard.getData" + arguments:@"text/plain"]; + [plugin handleMethodCall:methodCall result:result]; + [self waitForExpectationsWithTimeout:1 handler:nil]; +} - (void)testPopSystemNavigator { FlutterEngine* engine = [[FlutterEngine alloc] initWithName:@"test" project:nil]; diff --git a/shell/platform/darwin/ios/framework/Source/FlutterPlatformViews.mm b/shell/platform/darwin/ios/framework/Source/FlutterPlatformViews.mm index da76b2e107eaa..a3d623d6b6133 100644 --- a/shell/platform/darwin/ios/framework/Source/FlutterPlatformViews.mm +++ b/shell/platform/darwin/ios/framework/Source/FlutterPlatformViews.mm @@ -173,7 +173,7 @@ static bool ClipRRectContainsPlatformViewBoundingRect(const SkRRect& clip_rrect, return flutter_view_controller_.get(); } -void FlutterPlatformViewsController::OnMethodCall(FlutterMethodCall* call, FlutterResult& result) { +void FlutterPlatformViewsController::OnMethodCall(FlutterMethodCall* call, FlutterResult result) { if ([[call method] isEqualToString:@"create"]) { OnCreate(call, result); } else if ([[call method] isEqualToString:@"dispose"]) { diff --git a/shell/platform/darwin/ios/framework/Source/FlutterPlatformViewsTest.mm b/shell/platform/darwin/ios/framework/Source/FlutterPlatformViewsTest.mm index c55111136df9b..556077134aefb 100644 --- a/shell/platform/darwin/ios/framework/Source/FlutterPlatformViewsTest.mm +++ b/shell/platform/darwin/ios/framework/Source/FlutterPlatformViewsTest.mm @@ -15,9 +15,9 @@ #import "flutter/shell/platform/darwin/ios/framework/Source/FlutterViewController_Internal.h" #import "flutter/shell/platform/darwin/ios/platform_view_ios.h" -FLUTTER_ASSERT_NOT_ARC +FLUTTER_ASSERT_ARC @class FlutterPlatformViewsTestMockPlatformView; -static FlutterPlatformViewsTestMockPlatformView* gMockPlatformView = nil; +__weak static FlutterPlatformViewsTestMockPlatformView* gMockPlatformView = nil; const float kFloatCompareEpsilon = 0.001; @interface FlutterPlatformViewsTestMockPlatformView : UIView @@ -34,7 +34,6 @@ - (instancetype)init { - (void)dealloc { gMockPlatformView = nil; - [super dealloc]; } @end @@ -66,12 +65,6 @@ - (void)checkViewCreatedOnce { self.viewCreated = YES; } -- (void)dealloc { - [_view release]; - _view = nil; - [super dealloc]; -} - @end @interface FlutterPlatformViewsTestMockFlutterPlatformFactory @@ -82,7 +75,7 @@ @implementation FlutterPlatformViewsTestMockFlutterPlatformFactory - (NSObject*)createWithFrame:(CGRect)frame viewIdentifier:(int64_t)viewId arguments:(id _Nullable)args { - return [[[FlutterPlatformViewsTestMockFlutterPlatformView alloc] init] autorelease]; + return [[FlutterPlatformViewsTestMockFlutterPlatformView alloc] init]; } @end @@ -156,7 +149,7 @@ - (void)testFlutterViewOnlyCreateOnceInOneFrame { /*is_gpu_disabled_sync_switch=*/nil); FlutterPlatformViewsTestMockFlutterPlatformFactory* factory = - [[[FlutterPlatformViewsTestMockFlutterPlatformFactory alloc] init] autorelease]; + [[FlutterPlatformViewsTestMockFlutterPlatformFactory alloc] init]; flutterPlatformViewsController->RegisterViewFactory( factory, @"MockFlutterPlatformView", FlutterPlatformViewGestureRecognizersBlockingPolicyEager); @@ -167,7 +160,7 @@ - (void)testFlutterViewOnlyCreateOnceInOneFrame { methodCallWithMethodName:@"create" arguments:@{@"id" : @2, @"viewType" : @"MockFlutterPlatformView"}], result); - UIView* mockFlutterView = [[[UIView alloc] initWithFrame:CGRectMake(0, 0, 500, 500)] autorelease]; + UIView* mockFlutterView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 500, 500)]; flutterPlatformViewsController->SetFlutterView(mockFlutterView); // Create embedded view params flutter::MutatorsStack stack; @@ -212,7 +205,7 @@ - (void)testCanCreatePlatformViewWithoutFlutterView { /*is_gpu_disabled_sync_switch=*/nil); FlutterPlatformViewsTestMockFlutterPlatformFactory* factory = - [[[FlutterPlatformViewsTestMockFlutterPlatformFactory alloc] init] autorelease]; + [[FlutterPlatformViewsTestMockFlutterPlatformFactory alloc] init]; flutterPlatformViewsController->RegisterViewFactory( factory, @"MockFlutterPlatformView", FlutterPlatformViewGestureRecognizersBlockingPolicyEager); @@ -229,8 +222,8 @@ - (void)testCanCreatePlatformViewWithoutFlutterView { - (void)testChildClippingViewHitTests { ChildClippingView* childClippingView = - [[[ChildClippingView alloc] initWithFrame:CGRectMake(0, 0, 500, 500)] autorelease]; - UIView* childView = [[[UIView alloc] initWithFrame:CGRectMake(100, 100, 100, 100)] autorelease]; + [[ChildClippingView alloc] initWithFrame:CGRectMake(0, 0, 500, 500)]; + UIView* childView = [[UIView alloc] initWithFrame:CGRectMake(100, 100, 100, 100)]; [childClippingView addSubview:childView]; XCTAssertFalse([childClippingView pointInside:CGPointMake(50, 50) withEvent:nil]); @@ -266,7 +259,7 @@ - (void)testApplyBackdropFilter { /*is_gpu_disabled_sync_switch=*/nil); FlutterPlatformViewsTestMockFlutterPlatformFactory* factory = - [[[FlutterPlatformViewsTestMockFlutterPlatformFactory alloc] init] autorelease]; + [[FlutterPlatformViewsTestMockFlutterPlatformFactory alloc] init]; flutterPlatformViewsController->RegisterViewFactory( factory, @"MockFlutterPlatformView", FlutterPlatformViewGestureRecognizersBlockingPolicyEager); @@ -280,7 +273,7 @@ - (void)testApplyBackdropFilter { XCTAssertNotNil(gMockPlatformView); - UIView* mockFlutterView = [[[UIView alloc] initWithFrame:CGRectMake(0, 0, 10, 10)] autorelease]; + UIView* mockFlutterView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 10, 10)]; flutterPlatformViewsController->SetFlutterView(mockFlutterView); // Create embedded view params flutter::MutatorsStack stack; @@ -338,7 +331,7 @@ - (void)testApplyBackdropFilterWithCorrectFrame { /*is_gpu_disabled_sync_switch=*/nil); FlutterPlatformViewsTestMockFlutterPlatformFactory* factory = - [[[FlutterPlatformViewsTestMockFlutterPlatformFactory alloc] init] autorelease]; + [[FlutterPlatformViewsTestMockFlutterPlatformFactory alloc] init]; flutterPlatformViewsController->RegisterViewFactory( factory, @"MockFlutterPlatformView", FlutterPlatformViewGestureRecognizersBlockingPolicyEager); @@ -352,7 +345,7 @@ - (void)testApplyBackdropFilterWithCorrectFrame { XCTAssertNotNil(gMockPlatformView); - UIView* mockFlutterView = [[[UIView alloc] initWithFrame:CGRectMake(0, 0, 10, 10)] autorelease]; + UIView* mockFlutterView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 10, 10)]; flutterPlatformViewsController->SetFlutterView(mockFlutterView); // Create embedded view params flutter::MutatorsStack stack; @@ -410,7 +403,7 @@ - (void)testApplyMultipleBackdropFilters { /*is_gpu_disabled_sync_switch=*/nil); FlutterPlatformViewsTestMockFlutterPlatformFactory* factory = - [[[FlutterPlatformViewsTestMockFlutterPlatformFactory alloc] init] autorelease]; + [[FlutterPlatformViewsTestMockFlutterPlatformFactory alloc] init]; flutterPlatformViewsController->RegisterViewFactory( factory, @"MockFlutterPlatformView", FlutterPlatformViewGestureRecognizersBlockingPolicyEager); @@ -424,7 +417,7 @@ - (void)testApplyMultipleBackdropFilters { XCTAssertNotNil(gMockPlatformView); - UIView* mockFlutterView = [[[UIView alloc] initWithFrame:CGRectMake(0, 0, 10, 10)] autorelease]; + UIView* mockFlutterView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 10, 10)]; flutterPlatformViewsController->SetFlutterView(mockFlutterView); // Create embedded view params flutter::MutatorsStack stack; @@ -483,7 +476,7 @@ - (void)testAddBackdropFilters { /*is_gpu_disabled_sync_switch=*/nil); FlutterPlatformViewsTestMockFlutterPlatformFactory* factory = - [[[FlutterPlatformViewsTestMockFlutterPlatformFactory alloc] init] autorelease]; + [[FlutterPlatformViewsTestMockFlutterPlatformFactory alloc] init]; flutterPlatformViewsController->RegisterViewFactory( factory, @"MockFlutterPlatformView", FlutterPlatformViewGestureRecognizersBlockingPolicyEager); @@ -497,7 +490,7 @@ - (void)testAddBackdropFilters { XCTAssertNotNil(gMockPlatformView); - UIView* mockFlutterView = [[[UIView alloc] initWithFrame:CGRectMake(0, 0, 10, 10)] autorelease]; + UIView* mockFlutterView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 10, 10)]; flutterPlatformViewsController->SetFlutterView(mockFlutterView); // Create embedded view params flutter::MutatorsStack stack; @@ -521,7 +514,7 @@ - (void)testAddBackdropFilters { [mockFlutterView setNeedsLayout]; [mockFlutterView layoutIfNeeded]; - NSMutableArray* originalVisualEffectViews = [[[NSMutableArray alloc] init] autorelease]; + NSMutableArray* originalVisualEffectViews = [[NSMutableArray alloc] init]; for (UIView* subview in childClippingView.subviews) { if (![subview isKindOfClass:[UIVisualEffectView class]]) { continue; @@ -554,7 +547,7 @@ - (void)testAddBackdropFilters { [mockFlutterView setNeedsLayout]; [mockFlutterView layoutIfNeeded]; - NSMutableArray* newVisualEffectViews = [[[NSMutableArray alloc] init] autorelease]; + NSMutableArray* newVisualEffectViews = [[NSMutableArray alloc] init]; for (UIView* subview in childClippingView.subviews) { if (![subview isKindOfClass:[UIVisualEffectView class]]) { continue; @@ -596,7 +589,7 @@ - (void)testRemoveBackdropFilters { /*is_gpu_disabled_sync_switch=*/nil); FlutterPlatformViewsTestMockFlutterPlatformFactory* factory = - [[[FlutterPlatformViewsTestMockFlutterPlatformFactory alloc] init] autorelease]; + [[FlutterPlatformViewsTestMockFlutterPlatformFactory alloc] init]; flutterPlatformViewsController->RegisterViewFactory( factory, @"MockFlutterPlatformView", FlutterPlatformViewGestureRecognizersBlockingPolicyEager); @@ -610,7 +603,7 @@ - (void)testRemoveBackdropFilters { XCTAssertNotNil(gMockPlatformView); - UIView* mockFlutterView = [[[UIView alloc] initWithFrame:CGRectMake(0, 0, 10, 10)] autorelease]; + UIView* mockFlutterView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 10, 10)]; flutterPlatformViewsController->SetFlutterView(mockFlutterView); // Create embedded view params flutter::MutatorsStack stack; @@ -636,7 +629,7 @@ - (void)testRemoveBackdropFilters { [mockFlutterView setNeedsLayout]; [mockFlutterView layoutIfNeeded]; - NSMutableArray* originalVisualEffectViews = [[[NSMutableArray alloc] init] autorelease]; + NSMutableArray* originalVisualEffectViews = [[NSMutableArray alloc] init]; for (UIView* subview in childClippingView.subviews) { if (![subview isKindOfClass:[UIVisualEffectView class]]) { continue; @@ -667,7 +660,7 @@ - (void)testRemoveBackdropFilters { [mockFlutterView setNeedsLayout]; [mockFlutterView layoutIfNeeded]; - NSMutableArray* newVisualEffectViews = [[[NSMutableArray alloc] init] autorelease]; + NSMutableArray* newVisualEffectViews = [[NSMutableArray alloc] init]; for (UIView* subview in childClippingView.subviews) { if (![subview isKindOfClass:[UIVisualEffectView class]]) { continue; @@ -733,7 +726,7 @@ - (void)testEditBackdropFilters { /*is_gpu_disabled_sync_switch=*/nil); FlutterPlatformViewsTestMockFlutterPlatformFactory* factory = - [[[FlutterPlatformViewsTestMockFlutterPlatformFactory alloc] init] autorelease]; + [[FlutterPlatformViewsTestMockFlutterPlatformFactory alloc] init]; flutterPlatformViewsController->RegisterViewFactory( factory, @"MockFlutterPlatformView", FlutterPlatformViewGestureRecognizersBlockingPolicyEager); @@ -747,7 +740,7 @@ - (void)testEditBackdropFilters { XCTAssertNotNil(gMockPlatformView); - UIView* mockFlutterView = [[[UIView alloc] initWithFrame:CGRectMake(0, 0, 10, 10)] autorelease]; + UIView* mockFlutterView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 10, 10)]; flutterPlatformViewsController->SetFlutterView(mockFlutterView); // Create embedded view params flutter::MutatorsStack stack; @@ -773,7 +766,7 @@ - (void)testEditBackdropFilters { [mockFlutterView setNeedsLayout]; [mockFlutterView layoutIfNeeded]; - NSMutableArray* originalVisualEffectViews = [[[NSMutableArray alloc] init] autorelease]; + NSMutableArray* originalVisualEffectViews = [[NSMutableArray alloc] init]; for (UIView* subview in childClippingView.subviews) { if (![subview isKindOfClass:[UIVisualEffectView class]]) { continue; @@ -813,7 +806,7 @@ - (void)testEditBackdropFilters { [mockFlutterView setNeedsLayout]; [mockFlutterView layoutIfNeeded]; - NSMutableArray* newVisualEffectViews = [[[NSMutableArray alloc] init] autorelease]; + NSMutableArray* newVisualEffectViews = [[NSMutableArray alloc] init]; for (UIView* subview in childClippingView.subviews) { if (![subview isKindOfClass:[UIVisualEffectView class]]) { continue; @@ -1010,7 +1003,7 @@ - (void)testApplyBackdropFilterNotDlBlurImageFilter { /*is_gpu_disabled_sync_switch=*/nil); FlutterPlatformViewsTestMockFlutterPlatformFactory* factory = - [[[FlutterPlatformViewsTestMockFlutterPlatformFactory alloc] init] autorelease]; + [[FlutterPlatformViewsTestMockFlutterPlatformFactory alloc] init]; flutterPlatformViewsController->RegisterViewFactory( factory, @"MockFlutterPlatformView", FlutterPlatformViewGestureRecognizersBlockingPolicyEager); @@ -1024,7 +1017,7 @@ - (void)testApplyBackdropFilterNotDlBlurImageFilter { XCTAssertNotNil(gMockPlatformView); - UIView* mockFlutterView = [[[UIView alloc] initWithFrame:CGRectMake(0, 0, 10, 10)] autorelease]; + UIView* mockFlutterView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 10, 10)]; flutterPlatformViewsController->SetFlutterView(mockFlutterView); // Create embedded view params flutter::MutatorsStack stack; @@ -1209,29 +1202,29 @@ - (void)testApplyBackdropFilterCorrectAPI { // The gaussianBlur filter is extracted from UIVisualEffectView. // Each test requires a new PlatformViewFilter // Valid UIVisualEffectView API - UIVisualEffectView* visualEffectView = [[[UIVisualEffectView alloc] - initWithEffect:[UIBlurEffect effectWithStyle:UIBlurEffectStyleLight]] autorelease]; + UIVisualEffectView* visualEffectView = [[UIVisualEffectView alloc] + initWithEffect:[UIBlurEffect effectWithStyle:UIBlurEffectStyleLight]]; PlatformViewFilter* platformViewFilter = - [[[PlatformViewFilter alloc] initWithFrame:CGRectMake(0, 0, 10, 10) - blurRadius:5 - visualEffectView:visualEffectView] autorelease]; + [[PlatformViewFilter alloc] initWithFrame:CGRectMake(0, 0, 10, 10) + blurRadius:5 + visualEffectView:visualEffectView]; XCTAssertNotNil(platformViewFilter); } - (void)testApplyBackdropFilterAPIChangedInvalidUIVisualEffectView { [PlatformViewFilter resetPreparation]; - UIVisualEffectView* visualEffectView = [[[UIVisualEffectView alloc] init] autorelease]; + UIVisualEffectView* visualEffectView = [[UIVisualEffectView alloc] init]; PlatformViewFilter* platformViewFilter = - [[[PlatformViewFilter alloc] initWithFrame:CGRectMake(0, 0, 10, 10) - blurRadius:5 - visualEffectView:visualEffectView] autorelease]; + [[PlatformViewFilter alloc] initWithFrame:CGRectMake(0, 0, 10, 10) + blurRadius:5 + visualEffectView:visualEffectView]; XCTAssertNil(platformViewFilter); } - (void)testApplyBackdropFilterAPIChangedNoGaussianBlurFilter { [PlatformViewFilter resetPreparation]; - UIVisualEffectView* editedUIVisualEffectView = [[[UIVisualEffectView alloc] - initWithEffect:[UIBlurEffect effectWithStyle:UIBlurEffectStyleLight]] autorelease]; + UIVisualEffectView* editedUIVisualEffectView = [[UIVisualEffectView alloc] + initWithEffect:[UIBlurEffect effectWithStyle:UIBlurEffectStyleLight]]; NSArray* subviews = editedUIVisualEffectView.subviews; for (UIView* view in subviews) { if ([NSStringFromClass([view class]) hasSuffix:@"BackdropView"]) { @@ -1245,16 +1238,16 @@ - (void)testApplyBackdropFilterAPIChangedNoGaussianBlurFilter { } } PlatformViewFilter* platformViewFilter = - [[[PlatformViewFilter alloc] initWithFrame:CGRectMake(0, 0, 10, 10) - blurRadius:5 - visualEffectView:editedUIVisualEffectView] autorelease]; + [[PlatformViewFilter alloc] initWithFrame:CGRectMake(0, 0, 10, 10) + blurRadius:5 + visualEffectView:editedUIVisualEffectView]; XCTAssertNil(platformViewFilter); } - (void)testApplyBackdropFilterAPIChangedInvalidInputRadius { [PlatformViewFilter resetPreparation]; - UIVisualEffectView* editedUIVisualEffectView = [[[UIVisualEffectView alloc] - initWithEffect:[UIBlurEffect effectWithStyle:UIBlurEffectStyleLight]] autorelease]; + UIVisualEffectView* editedUIVisualEffectView = [[UIVisualEffectView alloc] + initWithEffect:[UIBlurEffect effectWithStyle:UIBlurEffectStyleLight]]; NSArray* subviews = editedUIVisualEffectView.subviews; for (UIView* view in subviews) { if ([NSStringFromClass([view class]) hasSuffix:@"BackdropView"]) { @@ -1269,19 +1262,19 @@ - (void)testApplyBackdropFilterAPIChangedInvalidInputRadius { } PlatformViewFilter* platformViewFilter = - [[[PlatformViewFilter alloc] initWithFrame:CGRectMake(0, 0, 10, 10) - blurRadius:5 - visualEffectView:editedUIVisualEffectView] autorelease]; + [[PlatformViewFilter alloc] initWithFrame:CGRectMake(0, 0, 10, 10) + blurRadius:5 + visualEffectView:editedUIVisualEffectView]; XCTAssertNil(platformViewFilter); } - (void)testBackdropFilterVisualEffectSubviewBackgroundColor { - UIVisualEffectView* visualEffectView = [[[UIVisualEffectView alloc] - initWithEffect:[UIBlurEffect effectWithStyle:UIBlurEffectStyleLight]] autorelease]; + UIVisualEffectView* visualEffectView = [[UIVisualEffectView alloc] + initWithEffect:[UIBlurEffect effectWithStyle:UIBlurEffectStyleLight]]; PlatformViewFilter* platformViewFilter = - [[[PlatformViewFilter alloc] initWithFrame:CGRectMake(0, 0, 10, 10) - blurRadius:5 - visualEffectView:visualEffectView] autorelease]; + [[PlatformViewFilter alloc] initWithFrame:CGRectMake(0, 0, 10, 10) + blurRadius:5 + visualEffectView:visualEffectView]; CGColorRef visualEffectSubviewBackgroundColor = nil; for (UIView* view in [platformViewFilter backdropFilterView].subviews) { if ([NSStringFromClass([view class]) hasSuffix:@"VisualEffectSubview"]) { @@ -1310,7 +1303,7 @@ - (void)testCompositePlatformView { /*is_gpu_disabled_sync_switch=*/nil); FlutterPlatformViewsTestMockFlutterPlatformFactory* factory = - [[[FlutterPlatformViewsTestMockFlutterPlatformFactory alloc] init] autorelease]; + [[FlutterPlatformViewsTestMockFlutterPlatformFactory alloc] init]; flutterPlatformViewsController->RegisterViewFactory( factory, @"MockFlutterPlatformView", FlutterPlatformViewGestureRecognizersBlockingPolicyEager); @@ -1324,7 +1317,7 @@ - (void)testCompositePlatformView { XCTAssertNotNil(gMockPlatformView); - UIView* mockFlutterView = [[[UIView alloc] initWithFrame:CGRectMake(0, 0, 500, 500)] autorelease]; + UIView* mockFlutterView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 500, 500)]; flutterPlatformViewsController->SetFlutterView(mockFlutterView); // Create embedded view params flutter::MutatorsStack stack; @@ -1366,7 +1359,7 @@ - (void)testBackdropFilterCorrectlyPushedAndReset { /*is_gpu_disabled_sync_switch=*/nil); FlutterPlatformViewsTestMockFlutterPlatformFactory* factory = - [[[FlutterPlatformViewsTestMockFlutterPlatformFactory alloc] init] autorelease]; + [[FlutterPlatformViewsTestMockFlutterPlatformFactory alloc] init]; flutterPlatformViewsController->RegisterViewFactory( factory, @"MockFlutterPlatformView", FlutterPlatformViewGestureRecognizersBlockingPolicyEager); @@ -1380,7 +1373,7 @@ - (void)testBackdropFilterCorrectlyPushedAndReset { XCTAssertNotNil(gMockPlatformView); - UIView* mockFlutterView = [[[UIView alloc] initWithFrame:CGRectMake(0, 0, 10, 10)] autorelease]; + UIView* mockFlutterView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 10, 10)]; flutterPlatformViewsController->SetFlutterView(mockFlutterView); // Create embedded view params flutter::MutatorsStack stack; @@ -1460,7 +1453,7 @@ - (void)testChildClippingViewShouldBeTheBoundingRectOfPlatformView { /*is_gpu_disabled_sync_switch=*/nil); FlutterPlatformViewsTestMockFlutterPlatformFactory* factory = - [[[FlutterPlatformViewsTestMockFlutterPlatformFactory alloc] init] autorelease]; + [[FlutterPlatformViewsTestMockFlutterPlatformFactory alloc] init]; flutterPlatformViewsController->RegisterViewFactory( factory, @"MockFlutterPlatformView", FlutterPlatformViewGestureRecognizersBlockingPolicyEager); @@ -1474,7 +1467,7 @@ - (void)testChildClippingViewShouldBeTheBoundingRectOfPlatformView { XCTAssertNotNil(gMockPlatformView); - UIView* mockFlutterView = [[[UIView alloc] initWithFrame:CGRectMake(0, 0, 500, 500)] autorelease]; + UIView* mockFlutterView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 500, 500)]; flutterPlatformViewsController->SetFlutterView(mockFlutterView); // Create embedded view params flutter::MutatorsStack stack; @@ -1531,7 +1524,7 @@ - (void)testClipsDoNotInterceptWithPlatformViewShouldNotAddMaskView { /*is_gpu_disabled_sync_switch=*/nil); FlutterPlatformViewsTestMockFlutterPlatformFactory* factory = - [[[FlutterPlatformViewsTestMockFlutterPlatformFactory alloc] init] autorelease]; + [[FlutterPlatformViewsTestMockFlutterPlatformFactory alloc] init]; flutterPlatformViewsController->RegisterViewFactory( factory, @"MockFlutterPlatformView", FlutterPlatformViewGestureRecognizersBlockingPolicyEager); @@ -1545,7 +1538,7 @@ - (void)testClipsDoNotInterceptWithPlatformViewShouldNotAddMaskView { XCTAssertNotNil(gMockPlatformView); - UIView* mockFlutterView = [[[UIView alloc] initWithFrame:CGRectMake(0, 0, 30, 30)] autorelease]; + UIView* mockFlutterView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 30, 30)]; flutterPlatformViewsController->SetFlutterView(mockFlutterView); // Create embedded view params. flutter::MutatorsStack stack; @@ -1598,7 +1591,7 @@ - (void)testClipRRectOnlyHasCornersInterceptWithPlatformViewShouldAddMaskView { /*is_gpu_disabled_sync_switch=*/nil); FlutterPlatformViewsTestMockFlutterPlatformFactory* factory = - [[[FlutterPlatformViewsTestMockFlutterPlatformFactory alloc] init] autorelease]; + [[FlutterPlatformViewsTestMockFlutterPlatformFactory alloc] init]; flutterPlatformViewsController->RegisterViewFactory( factory, @"MockFlutterPlatformView", FlutterPlatformViewGestureRecognizersBlockingPolicyEager); @@ -1612,7 +1605,7 @@ - (void)testClipRRectOnlyHasCornersInterceptWithPlatformViewShouldAddMaskView { XCTAssertNotNil(gMockPlatformView); - UIView* mockFlutterView = [[[UIView alloc] initWithFrame:CGRectMake(0, 0, 30, 30)] autorelease]; + UIView* mockFlutterView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 30, 30)]; flutterPlatformViewsController->SetFlutterView(mockFlutterView); // Create embedded view params flutter::MutatorsStack stack; @@ -1664,7 +1657,7 @@ - (void)testClipRect { /*is_gpu_disabled_sync_switch=*/nil); FlutterPlatformViewsTestMockFlutterPlatformFactory* factory = - [[[FlutterPlatformViewsTestMockFlutterPlatformFactory alloc] init] autorelease]; + [[FlutterPlatformViewsTestMockFlutterPlatformFactory alloc] init]; flutterPlatformViewsController->RegisterViewFactory( factory, @"MockFlutterPlatformView", FlutterPlatformViewGestureRecognizersBlockingPolicyEager); @@ -1678,7 +1671,7 @@ - (void)testClipRect { XCTAssertNotNil(gMockPlatformView); - UIView* mockFlutterView = [[[UIView alloc] initWithFrame:CGRectMake(0, 0, 10, 10)] autorelease]; + UIView* mockFlutterView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 10, 10)]; flutterPlatformViewsController->SetFlutterView(mockFlutterView); // Create embedded view params flutter::MutatorsStack stack; @@ -1737,7 +1730,7 @@ - (void)testClipRRect { /*is_gpu_disabled_sync_switch=*/nil); FlutterPlatformViewsTestMockFlutterPlatformFactory* factory = - [[[FlutterPlatformViewsTestMockFlutterPlatformFactory alloc] init] autorelease]; + [[FlutterPlatformViewsTestMockFlutterPlatformFactory alloc] init]; flutterPlatformViewsController->RegisterViewFactory( factory, @"MockFlutterPlatformView", FlutterPlatformViewGestureRecognizersBlockingPolicyEager); @@ -1751,7 +1744,7 @@ - (void)testClipRRect { XCTAssertNotNil(gMockPlatformView); - UIView* mockFlutterView = [[[UIView alloc] initWithFrame:CGRectMake(0, 0, 10, 10)] autorelease]; + UIView* mockFlutterView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 10, 10)]; flutterPlatformViewsController->SetFlutterView(mockFlutterView); // Create embedded view params flutter::MutatorsStack stack; @@ -1810,7 +1803,7 @@ - (void)testClipPath { /*is_gpu_disabled_sync_switch=*/nil); FlutterPlatformViewsTestMockFlutterPlatformFactory* factory = - [[[FlutterPlatformViewsTestMockFlutterPlatformFactory alloc] init] autorelease]; + [[FlutterPlatformViewsTestMockFlutterPlatformFactory alloc] init]; flutterPlatformViewsController->RegisterViewFactory( factory, @"MockFlutterPlatformView", FlutterPlatformViewGestureRecognizersBlockingPolicyEager); @@ -1824,7 +1817,7 @@ - (void)testClipPath { XCTAssertNotNil(gMockPlatformView); - UIView* mockFlutterView = [[[UIView alloc] initWithFrame:CGRectMake(0, 0, 10, 10)] autorelease]; + UIView* mockFlutterView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 10, 10)]; flutterPlatformViewsController->SetFlutterView(mockFlutterView); // Create embedded view params flutter::MutatorsStack stack; @@ -1884,7 +1877,7 @@ - (void)testSetFlutterViewControllerAfterCreateCanStillDispatchTouchEvents { /*is_gpu_disabled_sync_switch=*/nil); FlutterPlatformViewsTestMockFlutterPlatformFactory* factory = - [[[FlutterPlatformViewsTestMockFlutterPlatformFactory alloc] init] autorelease]; + [[FlutterPlatformViewsTestMockFlutterPlatformFactory alloc] init]; flutterPlatformViewsController->RegisterViewFactory( factory, @"MockFlutterPlatformView", FlutterPlatformViewGestureRecognizersBlockingPolicyEager); @@ -1916,14 +1909,14 @@ - (void)testSetFlutterViewControllerAfterCreateCanStillDispatchTouchEvents { } // Before setting flutter view controller, events are not dispatched. - NSSet* touches1 = [[[NSSet alloc] init] autorelease]; + NSSet* touches1 = [[NSSet alloc] init]; id event1 = OCMClassMock([UIEvent class]); id mockFlutterViewContoller = OCMClassMock([FlutterViewController class]); [forwardGectureRecognizer touchesBegan:touches1 withEvent:event1]; OCMReject([mockFlutterViewContoller touchesBegan:touches1 withEvent:event1]); // Set flutter view controller allows events to be dispatched. - NSSet* touches2 = [[[NSSet alloc] init] autorelease]; + NSSet* touches2 = [[NSSet alloc] init]; id event2 = OCMClassMock([UIEvent class]); flutterPlatformViewsController->SetFlutterViewController(mockFlutterViewContoller); [forwardGectureRecognizer touchesBegan:touches2 withEvent:event2]; @@ -1948,7 +1941,7 @@ - (void)testSetFlutterViewControllerInTheMiddleOfTouchEventShouldStillAllowGestu /*is_gpu_disabled_sync_switch=*/nil); FlutterPlatformViewsTestMockFlutterPlatformFactory* factory = - [[[FlutterPlatformViewsTestMockFlutterPlatformFactory alloc] init] autorelease]; + [[FlutterPlatformViewsTestMockFlutterPlatformFactory alloc] init]; flutterPlatformViewsController->RegisterViewFactory( factory, @"MockFlutterPlatformView", FlutterPlatformViewGestureRecognizersBlockingPolicyEager); @@ -1983,7 +1976,7 @@ - (void)testSetFlutterViewControllerInTheMiddleOfTouchEventShouldStillAllowGestu // ***** Sequence 1, finishing touch event with touchEnded ***** // flutterPlatformViewsController->SetFlutterViewController(mockFlutterViewContoller); - NSSet* touches1 = [[[NSSet alloc] init] autorelease]; + NSSet* touches1 = [[NSSet alloc] init]; id event1 = OCMClassMock([UIEvent class]); [forwardGectureRecognizer touchesBegan:touches1 withEvent:event1]; OCMVerify([mockFlutterViewContoller touchesBegan:touches1 withEvent:event1]); @@ -1991,23 +1984,23 @@ - (void)testSetFlutterViewControllerInTheMiddleOfTouchEventShouldStillAllowGestu flutterPlatformViewsController->SetFlutterViewController(nil); // Allow the touch events to finish - NSSet* touches2 = [[[NSSet alloc] init] autorelease]; + NSSet* touches2 = [[NSSet alloc] init]; id event2 = OCMClassMock([UIEvent class]); [forwardGectureRecognizer touchesMoved:touches2 withEvent:event2]; OCMVerify([mockFlutterViewContoller touchesMoved:touches2 withEvent:event2]); - NSSet* touches3 = [[[NSSet alloc] init] autorelease]; + NSSet* touches3 = [[NSSet alloc] init]; id event3 = OCMClassMock([UIEvent class]); [forwardGectureRecognizer touchesEnded:touches3 withEvent:event3]; OCMVerify([mockFlutterViewContoller touchesEnded:touches3 withEvent:event3]); // Now the 2nd touch sequence should not be allowed. - NSSet* touches4 = [[[NSSet alloc] init] autorelease]; + NSSet* touches4 = [[NSSet alloc] init]; id event4 = OCMClassMock([UIEvent class]); [forwardGectureRecognizer touchesBegan:touches4 withEvent:event4]; OCMReject([mockFlutterViewContoller touchesBegan:touches4 withEvent:event4]); - NSSet* touches5 = [[[NSSet alloc] init] autorelease]; + NSSet* touches5 = [[NSSet alloc] init]; id event5 = OCMClassMock([UIEvent class]); [forwardGectureRecognizer touchesEnded:touches5 withEvent:event5]; OCMReject([mockFlutterViewContoller touchesEnded:touches5 withEvent:event5]); @@ -2017,7 +2010,7 @@ - (void)testSetFlutterViewControllerInTheMiddleOfTouchEventShouldStillAllowGestu // ***** Sequence 2, finishing touch event with touchCancelled ***** // flutterPlatformViewsController->SetFlutterViewController(mockFlutterViewContoller); - NSSet* touches1 = [[[NSSet alloc] init] autorelease]; + NSSet* touches1 = [[NSSet alloc] init]; id event1 = OCMClassMock([UIEvent class]); [forwardGectureRecognizer touchesBegan:touches1 withEvent:event1]; OCMVerify([mockFlutterViewContoller touchesBegan:touches1 withEvent:event1]); @@ -2025,23 +2018,23 @@ - (void)testSetFlutterViewControllerInTheMiddleOfTouchEventShouldStillAllowGestu flutterPlatformViewsController->SetFlutterViewController(nil); // Allow the touch events to finish - NSSet* touches2 = [[[NSSet alloc] init] autorelease]; + NSSet* touches2 = [[NSSet alloc] init]; id event2 = OCMClassMock([UIEvent class]); [forwardGectureRecognizer touchesMoved:touches2 withEvent:event2]; OCMVerify([mockFlutterViewContoller touchesMoved:touches2 withEvent:event2]); - NSSet* touches3 = [[[NSSet alloc] init] autorelease]; + NSSet* touches3 = [[NSSet alloc] init]; id event3 = OCMClassMock([UIEvent class]); [forwardGectureRecognizer touchesCancelled:touches3 withEvent:event3]; OCMVerify([mockFlutterViewContoller forceTouchesCancelled:touches3]); // Now the 2nd touch sequence should not be allowed. - NSSet* touches4 = [[[NSSet alloc] init] autorelease]; + NSSet* touches4 = [[NSSet alloc] init]; id event4 = OCMClassMock([UIEvent class]); [forwardGectureRecognizer touchesBegan:touches4 withEvent:event4]; OCMReject([mockFlutterViewContoller touchesBegan:touches4 withEvent:event4]); - NSSet* touches5 = [[[NSSet alloc] init] autorelease]; + NSSet* touches5 = [[NSSet alloc] init]; id event5 = OCMClassMock([UIEvent class]); [forwardGectureRecognizer touchesEnded:touches5 withEvent:event5]; OCMReject([mockFlutterViewContoller touchesEnded:touches5 withEvent:event5]); @@ -2069,7 +2062,7 @@ - (void)testSetFlutterViewControllerInTheMiddleOfTouchEventShouldStillAllowGestu /*is_gpu_disabled_sync_switch=*/nil); FlutterPlatformViewsTestMockFlutterPlatformFactory* factory = - [[[FlutterPlatformViewsTestMockFlutterPlatformFactory alloc] init] autorelease]; + [[FlutterPlatformViewsTestMockFlutterPlatformFactory alloc] init]; flutterPlatformViewsController->RegisterViewFactory( factory, @"MockFlutterPlatformView", FlutterPlatformViewGestureRecognizersBlockingPolicyEager); @@ -2180,7 +2173,7 @@ - (void)testFlutterPlatformViewTouchesCancelledEventAreForcedToBeCancelled { /*is_gpu_disabled_sync_switch=*/nil); FlutterPlatformViewsTestMockFlutterPlatformFactory* factory = - [[[FlutterPlatformViewsTestMockFlutterPlatformFactory alloc] init] autorelease]; + [[FlutterPlatformViewsTestMockFlutterPlatformFactory alloc] init]; flutterPlatformViewsController->RegisterViewFactory( factory, @"MockFlutterPlatformView", FlutterPlatformViewGestureRecognizersBlockingPolicyEager); @@ -2242,7 +2235,7 @@ - (void)testFlutterPlatformViewControllerSubmitFrameWithoutFlutterViewNotCrashin /*is_gpu_disabled_sync_switch=*/nil); FlutterPlatformViewsTestMockFlutterPlatformFactory* factory = - [[[FlutterPlatformViewsTestMockFlutterPlatformFactory alloc] init] autorelease]; + [[FlutterPlatformViewsTestMockFlutterPlatformFactory alloc] init]; flutterPlatformViewsController->RegisterViewFactory( factory, @"MockFlutterPlatformView", FlutterPlatformViewGestureRecognizersBlockingPolicyEager); @@ -2303,11 +2296,11 @@ - (void)testFlutterPlatformViewControllerSubmitFrameWithoutFlutterViewNotCrashin /*worker_task_runner=*/nil, /*is_gpu_disabled_sync_switch=*/nil); - UIView* mockFlutterView = [[[UIView alloc] initWithFrame:CGRectMake(0, 0, 500, 500)] autorelease]; + UIView* mockFlutterView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 500, 500)]; flutterPlatformViewsController->SetFlutterView(mockFlutterView); FlutterPlatformViewsTestMockFlutterPlatformFactory* factory = - [[[FlutterPlatformViewsTestMockFlutterPlatformFactory alloc] init] autorelease]; + [[FlutterPlatformViewsTestMockFlutterPlatformFactory alloc] init]; flutterPlatformViewsController->RegisterViewFactory( factory, @"MockFlutterPlatformView", FlutterPlatformViewGestureRecognizersBlockingPolicyEager); @@ -2353,11 +2346,11 @@ - (void)testFlutterPlatformViewControllerBeginFrameShouldResetCompisitionOrder { /*worker_task_runner=*/nil, /*is_gpu_disabled_sync_switch=*/nil); - UIView* mockFlutterView = [[[UIView alloc] initWithFrame:CGRectMake(0, 0, 500, 500)] autorelease]; + UIView* mockFlutterView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 500, 500)]; flutterPlatformViewsController->SetFlutterView(mockFlutterView); FlutterPlatformViewsTestMockFlutterPlatformFactory* factory = - [[[FlutterPlatformViewsTestMockFlutterPlatformFactory alloc] init] autorelease]; + [[FlutterPlatformViewsTestMockFlutterPlatformFactory alloc] init]; flutterPlatformViewsController->RegisterViewFactory( factory, @"MockFlutterPlatformView", FlutterPlatformViewGestureRecognizersBlockingPolicyEager); @@ -2409,11 +2402,11 @@ - (void)testFlutterPlatformViewControllerBeginFrameShouldResetCompisitionOrder { /*worker_task_runner=*/nil, /*is_gpu_disabled_sync_switch=*/nil); - UIView* mockFlutterView = [[[UIView alloc] initWithFrame:CGRectMake(0, 0, 500, 500)] autorelease]; + UIView* mockFlutterView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 500, 500)]; flutterPlatformViewsController->SetFlutterView(mockFlutterView); FlutterPlatformViewsTestMockFlutterPlatformFactory* factory = - [[[FlutterPlatformViewsTestMockFlutterPlatformFactory alloc] init] autorelease]; + [[FlutterPlatformViewsTestMockFlutterPlatformFactory alloc] init]; flutterPlatformViewsController->RegisterViewFactory( factory, @"MockFlutterPlatformView", FlutterPlatformViewGestureRecognizersBlockingPolicyEager); @@ -2507,11 +2500,11 @@ - (void)testFlutterPlatformViewControllerBeginFrameShouldResetCompisitionOrder { /*worker_task_runner=*/nil, /*is_gpu_disabled_sync_switch=*/nil); - UIView* mockFlutterView = [[[UIView alloc] initWithFrame:CGRectMake(0, 0, 500, 500)] autorelease]; + UIView* mockFlutterView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 500, 500)]; flutterPlatformViewsController->SetFlutterView(mockFlutterView); FlutterPlatformViewsTestMockFlutterPlatformFactory* factory = - [[[FlutterPlatformViewsTestMockFlutterPlatformFactory alloc] init] autorelease]; + [[FlutterPlatformViewsTestMockFlutterPlatformFactory alloc] init]; flutterPlatformViewsController->RegisterViewFactory( factory, @"MockFlutterPlatformView", FlutterPlatformViewGestureRecognizersBlockingPolicyEager); @@ -2605,11 +2598,11 @@ - (void)testThreadMergeAtEndFrame { /*worker_task_runner=*/nil, /*is_gpu_disabled_sync_switch=*/nil); - UIView* mockFlutterView = [[[UIView alloc] initWithFrame:CGRectMake(0, 0, 500, 500)] autorelease]; + UIView* mockFlutterView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 500, 500)]; flutterPlatformViewsController->SetFlutterView(mockFlutterView); FlutterPlatformViewsTestMockFlutterPlatformFactory* factory = - [[[FlutterPlatformViewsTestMockFlutterPlatformFactory alloc] init] autorelease]; + [[FlutterPlatformViewsTestMockFlutterPlatformFactory alloc] init]; flutterPlatformViewsController->RegisterViewFactory( factory, @"MockFlutterPlatformView", FlutterPlatformViewGestureRecognizersBlockingPolicyEager); @@ -2669,8 +2662,8 @@ - (int)alphaOfPoint:(CGPoint)point onView:(UIView*)view { - (void)testHasFirstResponderInViewHierarchySubtree_viewItselfBecomesFirstResponder { // For view to become the first responder, it must be a descendant of a UIWindow - UIWindow* window = [[[UIWindow alloc] init] autorelease]; - UITextField* textField = [[[UITextField alloc] init] autorelease]; + UIWindow* window = [[UIWindow alloc] init]; + UITextField* textField = [[UITextField alloc] init]; [window addSubview:textField]; [textField becomeFirstResponder]; @@ -2683,10 +2676,10 @@ - (void)testHasFirstResponderInViewHierarchySubtree_viewItselfBecomesFirstRespon - (void)testHasFirstResponderInViewHierarchySubtree_descendantViewBecomesFirstResponder { // For view to become the first responder, it must be a descendant of a UIWindow - UIWindow* window = [[[UIWindow alloc] init] autorelease]; - UIView* view = [[[UIView alloc] init] autorelease]; - UIView* childView = [[[UIView alloc] init] autorelease]; - UITextField* textField = [[[UITextField alloc] init] autorelease]; + UIWindow* window = [[UIWindow alloc] init]; + UIView* view = [[UIView alloc] init]; + UIView* childView = [[UIView alloc] init]; + UITextField* textField = [[UITextField alloc] init]; [window addSubview:view]; [view addSubview:childView]; [childView addSubview:textField]; @@ -2700,8 +2693,7 @@ - (void)testHasFirstResponderInViewHierarchySubtree_descendantViewBecomesFirstRe } - (void)testFlutterClippingMaskViewPoolReuseViewsAfterRecycle { - FlutterClippingMaskViewPool* pool = - [[[FlutterClippingMaskViewPool alloc] initWithCapacity:2] autorelease]; + FlutterClippingMaskViewPool* pool = [[FlutterClippingMaskViewPool alloc] initWithCapacity:2]; FlutterClippingMaskView* view1 = [pool getMaskViewWithFrame:CGRectZero]; FlutterClippingMaskView* view2 = [pool getMaskViewWithFrame:CGRectZero]; [pool insertViewToPoolIfNeeded:view1]; @@ -2718,8 +2710,7 @@ - (void)testFlutterClippingMaskViewPoolReuseViewsAfterRecycle { } - (void)testFlutterClippingMaskViewPoolAllocsNewMaskViewsAfterReachingCapacity { - FlutterClippingMaskViewPool* pool = - [[[FlutterClippingMaskViewPool alloc] initWithCapacity:2] autorelease]; + FlutterClippingMaskViewPool* pool = [[FlutterClippingMaskViewPool alloc] initWithCapacity:2]; FlutterClippingMaskView* view1 = [pool getMaskViewWithFrame:CGRectZero]; FlutterClippingMaskView* view2 = [pool getMaskViewWithFrame:CGRectZero]; FlutterClippingMaskView* view3 = [pool getMaskViewWithFrame:CGRectZero]; @@ -2728,18 +2719,14 @@ - (void)testFlutterClippingMaskViewPoolAllocsNewMaskViewsAfterReachingCapacity { } - (void)testMaskViewsReleasedWhenPoolIsReleased { - UIView* retainedView; + __weak UIView* weakView; @autoreleasepool { - FlutterClippingMaskViewPool* pool = - [[[FlutterClippingMaskViewPool alloc] initWithCapacity:2] autorelease]; + FlutterClippingMaskViewPool* pool = [[FlutterClippingMaskViewPool alloc] initWithCapacity:2]; FlutterClippingMaskView* view = [pool getMaskViewWithFrame:CGRectZero]; - retainedView = [view retain]; - XCTAssertGreaterThan(retainedView.retainCount, 1u); + weakView = view; + XCTAssertNotNil(weakView); } - // The only retain left is our manual retain called inside the autorelease pool, meaning the - // maskViews are dealloc'd. - XCTAssertEqual(retainedView.retainCount, 1u); - [retainedView release]; + XCTAssertNil(weakView); } - (void)testClipMaskViewIsReused { @@ -2760,7 +2747,7 @@ - (void)testClipMaskViewIsReused { /*is_gpu_disabled_sync_switch=*/nil); FlutterPlatformViewsTestMockFlutterPlatformFactory* factory = - [[[FlutterPlatformViewsTestMockFlutterPlatformFactory alloc] init] autorelease]; + [[FlutterPlatformViewsTestMockFlutterPlatformFactory alloc] init]; flutterPlatformViewsController->RegisterViewFactory( factory, @"MockFlutterPlatformView", FlutterPlatformViewGestureRecognizersBlockingPolicyEager); @@ -2773,7 +2760,7 @@ - (void)testClipMaskViewIsReused { result); XCTAssertNotNil(gMockPlatformView); - UIView* mockFlutterView = [[[UIView alloc] initWithFrame:CGRectMake(0, 0, 10, 10)] autorelease]; + UIView* mockFlutterView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 10, 10)]; flutterPlatformViewsController->SetFlutterView(mockFlutterView); // Create embedded view params flutter::MutatorsStack stack1; @@ -2842,7 +2829,7 @@ - (void)testDifferentClipMaskViewIsUsedForEachView { /*is_gpu_disabled_sync_switch=*/nil); FlutterPlatformViewsTestMockFlutterPlatformFactory* factory = - [[[FlutterPlatformViewsTestMockFlutterPlatformFactory alloc] init] autorelease]; + [[FlutterPlatformViewsTestMockFlutterPlatformFactory alloc] init]; flutterPlatformViewsController->RegisterViewFactory( factory, @"MockFlutterPlatformView", FlutterPlatformViewGestureRecognizersBlockingPolicyEager); @@ -2865,7 +2852,7 @@ - (void)testDifferentClipMaskViewIsUsedForEachView { UIView* view2 = gMockPlatformView; XCTAssertNotNil(gMockPlatformView); - UIView* mockFlutterView = [[[UIView alloc] initWithFrame:CGRectMake(0, 0, 10, 10)] autorelease]; + UIView* mockFlutterView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 10, 10)]; flutterPlatformViewsController->SetFlutterView(mockFlutterView); // Create embedded view params flutter::MutatorsStack stack1; @@ -2941,11 +2928,11 @@ - (void)testDisposingViewInCompositionOrderDoNotCrash { /*worker_task_runner=*/nil, /*is_gpu_disabled_sync_switch=*/nil); - UIView* mockFlutterView = [[[UIView alloc] initWithFrame:CGRectMake(0, 0, 500, 500)] autorelease]; + UIView* mockFlutterView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 500, 500)]; flutterPlatformViewsController->SetFlutterView(mockFlutterView); FlutterPlatformViewsTestMockFlutterPlatformFactory* factory = - [[[FlutterPlatformViewsTestMockFlutterPlatformFactory alloc] init] autorelease]; + [[FlutterPlatformViewsTestMockFlutterPlatformFactory alloc] init]; flutterPlatformViewsController->RegisterViewFactory( factory, @"MockFlutterPlatformView", FlutterPlatformViewGestureRecognizersBlockingPolicyEager); @@ -3050,7 +3037,7 @@ - (void)testOnlyPlatformViewsAreRemovedWhenReset { /*is_gpu_disabled_sync_switch=*/nil); FlutterPlatformViewsTestMockFlutterPlatformFactory* factory = - [[[FlutterPlatformViewsTestMockFlutterPlatformFactory alloc] init] autorelease]; + [[FlutterPlatformViewsTestMockFlutterPlatformFactory alloc] init]; flutterPlatformViewsController->RegisterViewFactory( factory, @"MockFlutterPlatformView", FlutterPlatformViewGestureRecognizersBlockingPolicyEager); @@ -3061,7 +3048,7 @@ - (void)testOnlyPlatformViewsAreRemovedWhenReset { methodCallWithMethodName:@"create" arguments:@{@"id" : @2, @"viewType" : @"MockFlutterPlatformView"}], result); - UIView* mockFlutterView = [[[UIView alloc] initWithFrame:CGRectMake(0, 0, 500, 500)] autorelease]; + UIView* mockFlutterView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 500, 500)]; flutterPlatformViewsController->SetFlutterView(mockFlutterView); // Create embedded view params flutter::MutatorsStack stack; @@ -3092,7 +3079,7 @@ - (void)testOnlyPlatformViewsAreRemovedWhenReset { flutterPlatformViewsController->SubmitFrame(nullptr, nullptr, std::move(mock_surface)); - UIView* someView = [[[UIView alloc] init] autorelease]; + UIView* someView = [[UIView alloc] init]; [mockFlutterView addSubview:someView]; flutterPlatformViewsController->Reset(); @@ -3101,9 +3088,8 @@ - (void)testOnlyPlatformViewsAreRemovedWhenReset { } - (void)testFlutterTouchInterceptingViewLinksToAccessibilityContainer { - FlutterTouchInterceptingView* touchInteceptorView = - [[[FlutterTouchInterceptingView alloc] init] autorelease]; - NSObject* container = [[[NSObject alloc] init] autorelease]; + FlutterTouchInterceptingView* touchInteceptorView = [[FlutterTouchInterceptingView alloc] init]; + NSObject* container = [[NSObject alloc] init]; [touchInteceptorView setFlutterAccessibilityContainer:container]; XCTAssertEqualObjects([touchInteceptorView accessibilityContainer], container); } diff --git a/shell/platform/darwin/ios/framework/Source/FlutterPlatformViews_Internal.h b/shell/platform/darwin/ios/framework/Source/FlutterPlatformViews_Internal.h index e18569868115f..6621cd5e06c0f 100644 --- a/shell/platform/darwin/ios/framework/Source/FlutterPlatformViews_Internal.h +++ b/shell/platform/darwin/ios/framework/Source/FlutterPlatformViews_Internal.h @@ -261,7 +261,7 @@ class FlutterPlatformViewsController { const std::shared_ptr& ios_context, std::unique_ptr frame); - void OnMethodCall(FlutterMethodCall* call, FlutterResult& result); + void OnMethodCall(FlutterMethodCall* call, FlutterResult result); // Returns the platform view id if the platform view (or any of its descendant view) is the first // responder. Returns -1 if no such platform view is found. diff --git a/shell/platform/darwin/ios/framework/Source/FlutterViewControllerTest.mm b/shell/platform/darwin/ios/framework/Source/FlutterViewControllerTest.mm index 0fed180dcd067..a68a55287fb42 100644 --- a/shell/platform/darwin/ios/framework/Source/FlutterViewControllerTest.mm +++ b/shell/platform/darwin/ios/framework/Source/FlutterViewControllerTest.mm @@ -17,9 +17,9 @@ #import "flutter/shell/platform/darwin/ios/framework/Source/FlutterTextInputPlugin.h" #import "flutter/shell/platform/darwin/ios/framework/Source/FlutterViewController_Internal.h" #import "flutter/shell/platform/darwin/ios/framework/Source/UIViewController+FlutterScreenAndSceneIfLoaded.h" +#import "flutter/shell/platform/darwin/ios/framework/Source/vsync_waiter_ios.h" #import "flutter/shell/platform/embedder/embedder.h" #import "flutter/third_party/spring_animation/spring_animation.h" -#import "flutter/shell/platform/darwin/ios/framework/Source/vsync_waiter_ios.h" FLUTTER_ASSERT_ARC @@ -126,7 +126,6 @@ @interface FlutterViewController (Tests) @property(nonatomic, strong) VSyncClient* keyboardAnimationVSyncClient; @property(nonatomic, strong) VSyncClient* touchRateCorrectionVSyncClient; - - (void)createTouchRateCorrectionVSyncClientIfNeeded; - (void)surfaceUpdated:(BOOL)appeared; - (void)performOrientationUpdate:(UIInterfaceOrientationMask)new_preferences; @@ -2033,7 +2032,6 @@ - (void)testLifeCycleNotificationCancelledInvalidResumed { [self waitForExpectationsWithTimeout:5.0 handler:nil]; } - - (void)testSetupKeyboardAnimationVsyncClientWillCreateNewVsyncClientForFlutterViewController { id bundleMock = OCMPartialMock([NSBundle mainBundle]); OCMStub([bundleMock objectForInfoDictionaryKey:@"CADisableMinimumFrameDurationOnPhone"]) @@ -2043,8 +2041,9 @@ - (void)testSetupKeyboardAnimationVsyncClientWillCreateNewVsyncClientForFlutterV [[[mockDisplayLinkManager stub] andReturnValue:@(maxFrameRate)] displayRefreshRate]; FlutterEngine* engine = [[FlutterEngine alloc] init]; [engine runWithEntrypoint:nil]; - FlutterViewController* viewController = - [[FlutterViewController alloc] initWithEngine:engine nibName:nil bundle:nil]; + FlutterViewController* viewController = [[FlutterViewController alloc] initWithEngine:engine + nibName:nil + bundle:nil]; FlutterKeyboardAnimationCallback callback = ^(fml::TimePoint targetTime) { }; [viewController setUpKeyboardAnimationVsyncClient:callback]; @@ -2067,8 +2066,9 @@ - (void)testSetupKeyboardAnimationVsyncClientWillCreateNewVsyncClientForFlutterV [[[mockDisplayLinkManager stub] andReturnValue:@(maxFrameRate)] displayRefreshRate]; FlutterEngine* engine = [[FlutterEngine alloc] init]; [engine runWithEntrypoint:nil]; - FlutterViewController* viewController = - [[FlutterViewController alloc] initWithEngine:engine nibName:nil bundle:nil]; + FlutterViewController* viewController = [[FlutterViewController alloc] initWithEngine:engine + nibName:nil + bundle:nil]; [viewController createTouchRateCorrectionVSyncClientIfNeeded]; XCTAssertNotNil(viewController.touchRateCorrectionVSyncClient); } @@ -2080,8 +2080,9 @@ - (void)testCreateTouchRateCorrectionVSyncClientWillNotCreateNewVSyncClientWhenC FlutterEngine* engine = [[FlutterEngine alloc] init]; [engine runWithEntrypoint:nil]; - FlutterViewController* viewController = - [[FlutterViewController alloc] initWithEngine:engine nibName:nil bundle:nil]; + FlutterViewController* viewController = [[FlutterViewController alloc] initWithEngine:engine + nibName:nil + bundle:nil]; [viewController createTouchRateCorrectionVSyncClientIfNeeded]; VSyncClient* clientBefore = viewController.touchRateCorrectionVSyncClient; XCTAssertNotNil(clientBefore); @@ -2099,8 +2100,9 @@ - (void)testCreateTouchRateCorrectionVSyncClientWillNotCreateVsyncClientWhenRefr [[[mockDisplayLinkManager stub] andReturnValue:@(maxFrameRate)] displayRefreshRate]; FlutterEngine* engine = [[FlutterEngine alloc] init]; [engine runWithEntrypoint:nil]; - FlutterViewController* viewController = - [[FlutterViewController alloc] initWithEngine:engine nibName:nil bundle:nil]; + FlutterViewController* viewController = [[FlutterViewController alloc] initWithEngine:engine + nibName:nil + bundle:nil]; [viewController createTouchRateCorrectionVSyncClientIfNeeded]; XCTAssertNil(viewController.touchRateCorrectionVSyncClient); } @@ -2111,8 +2113,9 @@ - (void)testTriggerTouchRateCorrectionVSyncClientCorrectly { [[[mockDisplayLinkManager stub] andReturnValue:@(maxFrameRate)] displayRefreshRate]; FlutterEngine* engine = [[FlutterEngine alloc] init]; [engine runWithEntrypoint:nil]; - FlutterViewController* viewController = - [[FlutterViewController alloc] initWithEngine:engine nibName:nil bundle:nil]; + FlutterViewController* viewController = [[FlutterViewController alloc] initWithEngine:engine + nibName:nil + bundle:nil]; [viewController loadView]; [viewController viewDidLoad]; @@ -2153,8 +2156,8 @@ - (void)testTriggerTouchRateCorrectionVSyncClientCorrectly { XCTAssertFalse(link.isPaused); [viewController - triggerTouchRateCorrectionIfNeeded:[[NSSet alloc] - initWithObjects:fakeTouchEnd, fakeTouchCancelled, nil]]; + triggerTouchRateCorrectionIfNeeded:[[NSSet alloc] initWithObjects:fakeTouchEnd, + fakeTouchCancelled, nil]]; XCTAssertTrue(link.isPaused); [viewController @@ -2166,8 +2169,9 @@ - (void)testTriggerTouchRateCorrectionVSyncClientCorrectly { - (void)testFlutterViewControllerStartKeyboardAnimationWillCreateVsyncClientCorrectly { FlutterEngine* engine = [[FlutterEngine alloc] init]; [engine runWithEntrypoint:nil]; - FlutterViewController* viewController = - [[FlutterViewController alloc] initWithEngine:engine nibName:nil bundle:nil]; + FlutterViewController* viewController = [[FlutterViewController alloc] initWithEngine:engine + nibName:nil + bundle:nil]; viewController.targetViewInsetBottom = 100; [viewController startKeyBoardAnimation:0.25]; XCTAssertNotNil(viewController.keyboardAnimationVSyncClient); @@ -2177,8 +2181,9 @@ - (void)testFlutterViewControllerStartKeyboardAnimationWillCreateVsyncClientCorr testSetupKeyboardAnimationVsyncClientWillNotCreateNewVsyncClientWhenKeyboardAnimationCallbackIsNil { FlutterEngine* engine = [[FlutterEngine alloc] init]; [engine runWithEntrypoint:nil]; - FlutterViewController* viewController = - [[FlutterViewController alloc] initWithEngine:engine nibName:nil bundle:nil]; + FlutterViewController* viewController = [[FlutterViewController alloc] initWithEngine:engine + nibName:nil + bundle:nil]; [viewController setUpKeyboardAnimationVsyncClient:nil]; XCTAssertNil(viewController.keyboardAnimationVSyncClient); } diff --git a/shell/platform/darwin/ios/framework/Source/FlutterViewTest.mm b/shell/platform/darwin/ios/framework/Source/FlutterViewTest.mm index b5a0c1002961a..3becc69678a07 100644 --- a/shell/platform/darwin/ios/framework/Source/FlutterViewTest.mm +++ b/shell/platform/darwin/ios/framework/Source/FlutterViewTest.mm @@ -43,26 +43,23 @@ @interface FlutterViewTest : XCTestCase @implementation FlutterViewTest - (void)testFlutterViewEnableSemanticsWhenIsAccessibilityElementIsCalled { - FakeDelegate* delegate = [[[FakeDelegate alloc] init] autorelease]; - FlutterView* view = [[[FlutterView alloc] initWithDelegate:delegate opaque:NO - enableWideGamut:NO] autorelease]; + FakeDelegate* delegate = [[FakeDelegate alloc] init]; + FlutterView* view = [[FlutterView alloc] initWithDelegate:delegate opaque:NO enableWideGamut:NO]; delegate.callbackCalled = NO; XCTAssertFalse(view.isAccessibilityElement); XCTAssertTrue(delegate.callbackCalled); } - (void)testFlutterViewBackgroundColorIsNotNil { - FakeDelegate* delegate = [[[FakeDelegate alloc] init] autorelease]; - FlutterView* view = [[[FlutterView alloc] initWithDelegate:delegate opaque:NO - enableWideGamut:NO] autorelease]; + FakeDelegate* delegate = [[FakeDelegate alloc] init]; + FlutterView* view = [[FlutterView alloc] initWithDelegate:delegate opaque:NO enableWideGamut:NO]; XCTAssertNotNil(view.backgroundColor); } - (void)testIgnoreWideColorWithoutImpeller { - FakeDelegate* delegate = [[[FakeDelegate alloc] init] autorelease]; + FakeDelegate* delegate = [[FakeDelegate alloc] init]; delegate.isUsingImpeller = NO; - FlutterView* view = [[[FlutterView alloc] initWithDelegate:delegate opaque:NO - enableWideGamut:YES] autorelease]; + FlutterView* view = [[FlutterView alloc] initWithDelegate:delegate opaque:NO enableWideGamut:YES]; [view layoutSubviews]; XCTAssertTrue([view.layer isKindOfClass:NSClassFromString(@"CAMetalLayer")]); CAMetalLayer* layer = (CAMetalLayer*)view.layer; @@ -70,7 +67,7 @@ - (void)testIgnoreWideColorWithoutImpeller { } - (void)testLayerScalesMatchScreenAfterLayoutSubviews { - FakeDelegate* delegate = [[[FakeDelegate alloc] init] autorelease]; + FakeDelegate* delegate = [[FakeDelegate alloc] init]; FlutterView* view = [[FlutterView alloc] initWithDelegate:delegate opaque:NO enableWideGamut:NO]; view.layer.contentsScale = CGFloat(-99.0); view.layer.rasterizationScale = CGFloat(-99.0); diff --git a/shell/platform/darwin/ios/framework/Source/SemanticsObjectTest.mm b/shell/platform/darwin/ios/framework/Source/SemanticsObjectTest.mm index 3306386307a76..c0e90db785559 100644 --- a/shell/platform/darwin/ios/framework/Source/SemanticsObjectTest.mm +++ b/shell/platform/darwin/ios/framework/Source/SemanticsObjectTest.mm @@ -6,10 +6,9 @@ #import #import "flutter/shell/platform/darwin/common/framework/Headers/FlutterMacros.h" -#import "flutter/shell/platform/darwin/ios/framework/Source/SemanticsObject.h" -#import "flutter/shell/platform/darwin/ios/framework/Source/SemanticsObjectTestMocks.h" -#import "flutter/shell/platform/darwin/ios/framework/Source/FlutterTouchInterceptingView_Test.h" #import "flutter/shell/platform/darwin/ios/framework/Source/FlutterPlatformViews_Internal.h" +#import "flutter/shell/platform/darwin/ios/framework/Source/FlutterTouchInterceptingView_Test.h" +#import "flutter/shell/platform/darwin/ios/framework/Source/SemanticsObject.h" #import "flutter/shell/platform/darwin/ios/framework/Source/SemanticsObjectTestMocks.h" FLUTTER_ASSERT_ARC @@ -936,8 +935,8 @@ - (void)testAccessibilityHitTestSearchCanReturnPlatformView { [[FlutterTouchInterceptingView alloc] initWithFrame:CGRectMake(0, 0, 100, 100)]; FlutterPlatformViewSemanticsContainer* platformViewSemanticsContainer = [[FlutterPlatformViewSemanticsContainer alloc] initWithBridge:bridge - uid:1 - platformView:platformView]; + uid:1 + platformView:platformView]; object0.children = @[ object1 ]; object0.childrenInHitTestOrder = @[ object1 ]; @@ -974,4 +973,24 @@ - (void)testAccessibilityHitTestSearchCanReturnPlatformView { XCTAssertEqual(hitTestResult, platformView); } +- (void)testFlutterPlatformViewSemanticsContainer { + fml::WeakPtrFactory factory( + new flutter::MockAccessibilityBridge()); + fml::WeakPtr bridge = factory.GetWeakPtr(); + __weak FlutterTouchInterceptingView* weakPlatformView; + @autoreleasepool { + FlutterTouchInterceptingView* platformView = [[FlutterTouchInterceptingView alloc] init]; + weakPlatformView = platformView; + FlutterPlatformViewSemanticsContainer* container = + [[FlutterPlatformViewSemanticsContainer alloc] initWithBridge:bridge + uid:1 + platformView:platformView]; + XCTAssertEqualObjects(platformView.accessibilityContainer, container); + XCTAssertNotNil(weakPlatformView); + } + // Check if there's no more strong references to `platformView` after container and platformView + // are released. + XCTAssertNil(weakPlatformView); +} + @end diff --git a/shell/platform/darwin/ios/framework/Source/SemanticsObjectTest_mrc.mm b/shell/platform/darwin/ios/framework/Source/SemanticsObjectTest_mrc.mm deleted file mode 100644 index 32c1b30fc39c3..0000000000000 --- a/shell/platform/darwin/ios/framework/Source/SemanticsObjectTest_mrc.mm +++ /dev/null @@ -1,40 +0,0 @@ -// 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/common/framework/Headers/FlutterMacros.h" -#import "flutter/shell/platform/darwin/ios/framework/Source/FlutterPlatformViews_Internal.h" -#import "flutter/shell/platform/darwin/ios/framework/Source/FlutterTouchInterceptingView_Test.h" -#import "flutter/shell/platform/darwin/ios/framework/Source/SemanticsObject.h" -#import "flutter/shell/platform/darwin/ios/framework/Source/SemanticsObjectTestMocks.h" - -FLUTTER_ASSERT_NOT_ARC - -@interface SemanticsObjectTestMRC : XCTestCase -@end - -@implementation SemanticsObjectTestMRC - -- (void)testFlutterPlatformViewSemanticsContainer { - fml::WeakPtrFactory factory( - new flutter::MockAccessibilityBridge()); - fml::WeakPtr bridge = factory.GetWeakPtr(); - FlutterTouchInterceptingView* platformView = - [[[FlutterTouchInterceptingView alloc] init] autorelease]; - @autoreleasepool { - FlutterPlatformViewSemanticsContainer* container = - [[[FlutterPlatformViewSemanticsContainer alloc] initWithBridge:bridge - uid:1 - platformView:platformView] autorelease]; - XCTAssertEqualObjects(platformView.accessibilityContainer, container); - XCTAssertEqual(platformView.retainCount, 2u); - } - // Check if there's no more strong references to `platformView` after container and platformView - // are released. - XCTAssertEqual(platformView.retainCount, 1u); -} - -@end diff --git a/shell/platform/darwin/ios/framework/Source/accessibility_bridge_test.mm b/shell/platform/darwin/ios/framework/Source/accessibility_bridge_test.mm index 5b75abf8a4b6b..c536366f39de4 100644 --- a/shell/platform/darwin/ios/framework/Source/accessibility_bridge_test.mm +++ b/shell/platform/darwin/ios/framework/Source/accessibility_bridge_test.mm @@ -14,9 +14,8 @@ #import "flutter/shell/platform/darwin/ios/framework/Source/accessibility_bridge.h" #import "flutter/shell/platform/darwin/ios/platform_view_ios.h" -FLUTTER_ASSERT_NOT_ARC @class MockPlatformView; -static MockPlatformView* gMockPlatformView = nil; +__weak static MockPlatformView* gMockPlatformView = nil; @interface MockPlatformView : UIView @end @@ -32,7 +31,6 @@ - (instancetype)init { - (void)dealloc { gMockPlatformView = nil; - [super dealloc]; } @end @@ -50,12 +48,6 @@ - (instancetype)init { return self; } -- (void)dealloc { - [_view release]; - _view = nil; - [super dealloc]; -} - @end @interface MockFlutterPlatformFactory : NSObject @@ -65,7 +57,7 @@ @implementation MockFlutterPlatformFactory - (NSObject*)createWithFrame:(CGRect)frame viewIdentifier:(int64_t)viewId arguments:(id _Nullable)args { - return [[[MockFlutterPlatformView alloc] init] autorelease]; + return [[MockFlutterPlatformView alloc] init]; } @end @@ -288,7 +280,7 @@ - (void)testSemanticsDeallocated { std::string label = "some label"; flutterPlatformViewsController->SetFlutterView(mockFlutterView); - MockFlutterPlatformFactory* factory = [[[MockFlutterPlatformFactory alloc] init] autorelease]; + MockFlutterPlatformFactory* factory = [[MockFlutterPlatformFactory alloc] init]; flutterPlatformViewsController->RegisterViewFactory( factory, @"MockFlutterPlatformView", FlutterPlatformViewGestureRecognizersBlockingPolicyEager); @@ -342,7 +334,7 @@ - (void)testSemanticsDeallocatedWithoutLoadingView { /*worker_task_runner=*/nil, /*is_gpu_disabled_sync_switch=*/nil); - MockFlutterPlatformFactory* factory = [[[MockFlutterPlatformFactory alloc] init] autorelease]; + MockFlutterPlatformFactory* factory = [[MockFlutterPlatformFactory alloc] init]; flutterPlatformViewsController->RegisterViewFactory( factory, @"MockFlutterPlatformView", FlutterPlatformViewGestureRecognizersBlockingPolicyEager); @@ -366,7 +358,6 @@ - (void)testSemanticsDeallocatedWithoutLoadingView { XCTAssertNil(gMockPlatformView); XCTAssertNil(flutterViewController.viewIfLoaded); [flutterViewController deregisterNotifications]; - [flutterViewController release]; } - (void)testReplacedSemanticsDoesNotCleanupChildren { @@ -629,7 +620,7 @@ - (void)testAnnouncesRouteChanges { OCMStub([mockFlutterViewController view]).andReturn(mockFlutterView); NSMutableArray*>* accessibility_notifications = - [[[NSMutableArray alloc] init] autorelease]; + [[NSMutableArray alloc] init]; auto ios_delegate = std::make_unique(); ios_delegate->on_PostAccessibilityNotification_ = [accessibility_notifications](UIAccessibilityNotifications notification, id argument) { @@ -744,7 +735,7 @@ - (void)testLayoutChangeWithNonAccessibilityElement { OCMStub([mockFlutterViewController view]).andReturn(mockFlutterView); NSMutableArray*>* accessibility_notifications = - [[[NSMutableArray alloc] init] autorelease]; + [[NSMutableArray alloc] init]; auto ios_delegate = std::make_unique(); ios_delegate->on_PostAccessibilityNotification_ = [accessibility_notifications](UIAccessibilityNotifications notification, id argument) { @@ -828,7 +819,7 @@ - (void)testLayoutChangeDoesCallNativeAccessibility { OCMStub([mockFlutterViewController view]).andReturn(mockFlutterView); NSMutableArray*>* accessibility_notifications = - [[[NSMutableArray alloc] init] autorelease]; + [[NSMutableArray alloc] init]; auto ios_delegate = std::make_unique(); ios_delegate->on_PostAccessibilityNotification_ = [accessibility_notifications](UIAccessibilityNotifications notification, id argument) { @@ -903,7 +894,7 @@ - (void)testLayoutChangeDoesCallNativeAccessibilityWhenFocusChanged { OCMStub([mockFlutterViewController view]).andReturn(mockFlutterView); NSMutableArray*>* accessibility_notifications = - [[[NSMutableArray alloc] init] autorelease]; + [[NSMutableArray alloc] init]; auto ios_delegate = std::make_unique(); ios_delegate->on_PostAccessibilityNotification_ = [accessibility_notifications](UIAccessibilityNotifications notification, id argument) { @@ -1034,7 +1025,7 @@ - (void)testAnnouncesRouteChangesAndLayoutChangeInOneUpdate { OCMStub([mockFlutterViewController view]).andReturn(mockFlutterView); NSMutableArray*>* accessibility_notifications = - [[[NSMutableArray alloc] init] autorelease]; + [[NSMutableArray alloc] init]; auto ios_delegate = std::make_unique(); ios_delegate->on_PostAccessibilityNotification_ = [accessibility_notifications](UIAccessibilityNotifications notification, id argument) { @@ -1131,7 +1122,7 @@ - (void)testAnnouncesRouteChangesWhenAddAdditionalRoute { OCMStub([mockFlutterViewController view]).andReturn(mockFlutterView); NSMutableArray*>* accessibility_notifications = - [[[NSMutableArray alloc] init] autorelease]; + [[NSMutableArray alloc] init]; auto ios_delegate = std::make_unique(); ios_delegate->on_PostAccessibilityNotification_ = [accessibility_notifications](UIAccessibilityNotifications notification, id argument) { @@ -1217,7 +1208,7 @@ - (void)testAnnouncesRouteChangesRemoveRouteInMiddle { OCMStub([mockFlutterViewController view]).andReturn(mockFlutterView); NSMutableArray*>* accessibility_notifications = - [[[NSMutableArray alloc] init] autorelease]; + [[NSMutableArray alloc] init]; auto ios_delegate = std::make_unique(); ios_delegate->on_PostAccessibilityNotification_ = [accessibility_notifications](UIAccessibilityNotifications notification, id argument) { @@ -1309,7 +1300,7 @@ - (void)testHandleEvent { OCMStub([mockFlutterViewController view]).andReturn(mockFlutterView); NSMutableArray*>* accessibility_notifications = - [[[NSMutableArray alloc] init] autorelease]; + [[NSMutableArray alloc] init]; auto ios_delegate = std::make_unique(); ios_delegate->on_PostAccessibilityNotification_ = [accessibility_notifications](UIAccessibilityNotifications notification, id argument) { @@ -1353,7 +1344,7 @@ - (void)testAnnouncesRouteChangesWhenNoNamesRoute { OCMStub([mockFlutterViewController view]).andReturn(mockFlutterView); NSMutableArray*>* accessibility_notifications = - [[[NSMutableArray alloc] init] autorelease]; + [[NSMutableArray alloc] init]; auto ios_delegate = std::make_unique(); ios_delegate->on_PostAccessibilityNotification_ = [accessibility_notifications](UIAccessibilityNotifications notification, id argument) { @@ -1423,7 +1414,7 @@ - (void)testAnnouncesLayoutChangeWithNilIfLastFocusIsRemoved { OCMStub([mockFlutterViewController view]).andReturn(mockFlutterView); NSMutableArray*>* accessibility_notifications = - [[[NSMutableArray alloc] init] autorelease]; + [[NSMutableArray alloc] init]; auto ios_delegate = std::make_unique(); ios_delegate->on_PostAccessibilityNotification_ = [accessibility_notifications](UIAccessibilityNotifications notification, id argument) { @@ -1492,7 +1483,7 @@ - (void)testAnnouncesLayoutChangeWithTheSameItemFocused { OCMStub([mockFlutterViewController view]).andReturn(mockFlutterView); NSMutableArray*>* accessibility_notifications = - [[[NSMutableArray alloc] init] autorelease]; + [[NSMutableArray alloc] init]; auto ios_delegate = std::make_unique(); ios_delegate->on_PostAccessibilityNotification_ = [accessibility_notifications](UIAccessibilityNotifications notification, id argument) { @@ -1567,7 +1558,7 @@ - (void)testAnnouncesLayoutChangeWhenFocusMovedOutside { OCMStub([mockFlutterViewController view]).andReturn(mockFlutterView); NSMutableArray*>* accessibility_notifications = - [[[NSMutableArray alloc] init] autorelease]; + [[NSMutableArray alloc] init]; auto ios_delegate = std::make_unique(); ios_delegate->on_PostAccessibilityNotification_ = [accessibility_notifications](UIAccessibilityNotifications notification, id argument) { @@ -1644,7 +1635,7 @@ - (void)testAnnouncesScrollChangeWithLastFocused { OCMStub([mockFlutterViewController view]).andReturn(mockFlutterView); NSMutableArray*>* accessibility_notifications = - [[[NSMutableArray alloc] init] autorelease]; + [[NSMutableArray alloc] init]; auto ios_delegate = std::make_unique(); ios_delegate->on_PostAccessibilityNotification_ = [accessibility_notifications](UIAccessibilityNotifications notification, id argument) { @@ -1717,7 +1708,7 @@ - (void)testAnnouncesScrollChangeDoesCallNativeAccessibility { OCMStub([mockFlutterViewController view]).andReturn(mockFlutterView); NSMutableArray*>* accessibility_notifications = - [[[NSMutableArray alloc] init] autorelease]; + [[NSMutableArray alloc] init]; auto ios_delegate = std::make_unique(); ios_delegate->on_PostAccessibilityNotification_ = [accessibility_notifications](UIAccessibilityNotifications notification, id argument) { @@ -1793,7 +1784,7 @@ - (void)testAnnouncesIgnoresRouteChangesWhenModal { std::string label = "some label"; NSMutableArray*>* accessibility_notifications = - [[[NSMutableArray alloc] init] autorelease]; + [[NSMutableArray alloc] init]; auto ios_delegate = std::make_unique(); ios_delegate->on_PostAccessibilityNotification_ = [accessibility_notifications](UIAccessibilityNotifications notification, id argument) { @@ -1849,7 +1840,7 @@ - (void)testAnnouncesIgnoresLayoutChangeWhenModal { OCMStub([mockFlutterViewController view]).andReturn(mockFlutterView); NSMutableArray*>* accessibility_notifications = - [[[NSMutableArray alloc] init] autorelease]; + [[NSMutableArray alloc] init]; auto ios_delegate = std::make_unique(); ios_delegate->on_PostAccessibilityNotification_ = [accessibility_notifications](UIAccessibilityNotifications notification, id argument) { @@ -1911,7 +1902,7 @@ - (void)testAnnouncesIgnoresScrollChangeWhenModal { OCMStub([mockFlutterViewController view]).andReturn(mockFlutterView); NSMutableArray*>* accessibility_notifications = - [[[NSMutableArray alloc] init] autorelease]; + [[NSMutableArray alloc] init]; auto ios_delegate = std::make_unique(); ios_delegate->on_PostAccessibilityNotification_ = [accessibility_notifications](UIAccessibilityNotifications notification, id argument) { @@ -2025,8 +2016,7 @@ - (void)testFlutterSemanticsScrollViewManagedObjectLifecycleCorrectly { FlutterSemanticsScrollView* flutterSemanticsScrollView; @autoreleasepool { FlutterScrollableSemanticsObject* semanticsObject = - [[[FlutterScrollableSemanticsObject alloc] initWithBridge:bridge->GetWeakPtr() - uid:1234] autorelease]; + [[FlutterScrollableSemanticsObject alloc] initWithBridge:bridge->GetWeakPtr() uid:1234]; flutterSemanticsScrollView = semanticsObject.nativeAccessibility; } diff --git a/shell/platform/darwin/ios/platform_message_handler_ios_test.mm b/shell/platform/darwin/ios/platform_message_handler_ios_test.mm index c1988bc2158f4..7b6d1931e5d60 100644 --- a/shell/platform/darwin/ios/platform_message_handler_ios_test.mm +++ b/shell/platform/darwin/ios/platform_message_handler_ios_test.mm @@ -12,9 +12,6 @@ #import "flutter/lib/ui/window/platform_message.h" #import "flutter/lib/ui/window/platform_message_response.h" #import "flutter/shell/common/thread_host.h" -#import "flutter/shell/platform/darwin/common/framework/Headers/FlutterMacros.h" - -FLUTTER_ASSERT_NOT_ARC namespace { using namespace flutter; From 4a831e359262af279d91aa5a28fd4369c97b7437 Mon Sep 17 00:00:00 2001 From: Chris Yang Date: Thu, 16 Nov 2023 15:52:13 -0800 Subject: [PATCH 3/4] update license --- ci/licenses_golden/licenses_flutter | 4 ---- 1 file changed, 4 deletions(-) diff --git a/ci/licenses_golden/licenses_flutter b/ci/licenses_golden/licenses_flutter index 25f5888f8cbd3..1f3ba6bd10df0 100644 --- a/ci/licenses_golden/licenses_flutter +++ b/ci/licenses_golden/licenses_flutter @@ -4517,7 +4517,6 @@ ORIGIN: ../../../flutter/shell/platform/darwin/ios/framework/Source/FlutterEngin ORIGIN: ../../../flutter/shell/platform/darwin/ios/framework/Source/FlutterEngineGroupTest.mm + ../../../flutter/LICENSE ORIGIN: ../../../flutter/shell/platform/darwin/ios/framework/Source/FlutterEnginePlatformViewTest.mm + ../../../flutter/LICENSE ORIGIN: ../../../flutter/shell/platform/darwin/ios/framework/Source/FlutterEngineTest.mm + ../../../flutter/LICENSE -ORIGIN: ../../../flutter/shell/platform/darwin/ios/framework/Source/FlutterEngineTest_mrc.mm + ../../../flutter/LICENSE ORIGIN: ../../../flutter/shell/platform/darwin/ios/framework/Source/FlutterEngine_Internal.h + ../../../flutter/LICENSE ORIGIN: ../../../flutter/shell/platform/darwin/ios/framework/Source/FlutterEngine_Test.h + ../../../flutter/LICENSE ORIGIN: ../../../flutter/shell/platform/darwin/ios/framework/Source/FlutterFakeKeyEvents.h + ../../../flutter/LICENSE @@ -4568,7 +4567,6 @@ ORIGIN: ../../../flutter/shell/platform/darwin/ios/framework/Source/FlutterView. ORIGIN: ../../../flutter/shell/platform/darwin/ios/framework/Source/FlutterView.mm + ../../../flutter/LICENSE ORIGIN: ../../../flutter/shell/platform/darwin/ios/framework/Source/FlutterViewController.mm + ../../../flutter/LICENSE ORIGIN: ../../../flutter/shell/platform/darwin/ios/framework/Source/FlutterViewControllerTest.mm + ../../../flutter/LICENSE -ORIGIN: ../../../flutter/shell/platform/darwin/ios/framework/Source/FlutterViewControllerTest_mrc.mm + ../../../flutter/LICENSE ORIGIN: ../../../flutter/shell/platform/darwin/ios/framework/Source/FlutterViewController_Internal.h + ../../../flutter/LICENSE ORIGIN: ../../../flutter/shell/platform/darwin/ios/framework/Source/FlutterViewResponder.h + ../../../flutter/LICENSE ORIGIN: ../../../flutter/shell/platform/darwin/ios/framework/Source/FlutterViewTest.mm + ../../../flutter/LICENSE @@ -7301,7 +7299,6 @@ FILE: ../../../flutter/shell/platform/darwin/ios/framework/Source/FlutterEngineG FILE: ../../../flutter/shell/platform/darwin/ios/framework/Source/FlutterEngineGroupTest.mm FILE: ../../../flutter/shell/platform/darwin/ios/framework/Source/FlutterEnginePlatformViewTest.mm FILE: ../../../flutter/shell/platform/darwin/ios/framework/Source/FlutterEngineTest.mm -FILE: ../../../flutter/shell/platform/darwin/ios/framework/Source/FlutterEngineTest_mrc.mm FILE: ../../../flutter/shell/platform/darwin/ios/framework/Source/FlutterEngine_Internal.h FILE: ../../../flutter/shell/platform/darwin/ios/framework/Source/FlutterEngine_Test.h FILE: ../../../flutter/shell/platform/darwin/ios/framework/Source/FlutterFakeKeyEvents.h @@ -7352,7 +7349,6 @@ 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.mm -FILE: ../../../flutter/shell/platform/darwin/ios/framework/Source/FlutterViewControllerTest_mrc.mm FILE: ../../../flutter/shell/platform/darwin/ios/framework/Source/FlutterViewController_Internal.h FILE: ../../../flutter/shell/platform/darwin/ios/framework/Source/FlutterViewResponder.h FILE: ../../../flutter/shell/platform/darwin/ios/framework/Source/FlutterViewTest.mm From 32284e24be677756d43b42df82ba4033c8281fbb Mon Sep 17 00:00:00 2001 From: Chris Yang Date: Fri, 17 Nov 2023 11:42:44 -0800 Subject: [PATCH 4/4] reivew --- .../darwin/ios/framework/Source/FlutterPlatformViews.mm | 8 ++++---- .../ios/framework/Source/FlutterPlatformViewsTest.mm | 1 + .../ios/framework/Source/FlutterPlatformViews_Internal.h | 8 ++++---- .../darwin/ios/framework/Source/FlutterViewTest.mm | 3 +++ .../ios/framework/Source/accessibility_bridge_test.mm | 2 ++ .../darwin/ios/platform_message_handler_ios_test.mm | 3 +++ 6 files changed, 17 insertions(+), 8 deletions(-) diff --git a/shell/platform/darwin/ios/framework/Source/FlutterPlatformViews.mm b/shell/platform/darwin/ios/framework/Source/FlutterPlatformViews.mm index a3d623d6b6133..004fe7eb31b38 100644 --- a/shell/platform/darwin/ios/framework/Source/FlutterPlatformViews.mm +++ b/shell/platform/darwin/ios/framework/Source/FlutterPlatformViews.mm @@ -187,7 +187,7 @@ static bool ClipRRectContainsPlatformViewBoundingRect(const SkRRect& clip_rrect, } } -void FlutterPlatformViewsController::OnCreate(FlutterMethodCall* call, FlutterResult& result) { +void FlutterPlatformViewsController::OnCreate(FlutterMethodCall* call, FlutterResult result) { NSDictionary* args = [call arguments]; int64_t viewId = [args[@"id"] longLongValue]; @@ -252,7 +252,7 @@ static bool ClipRRectContainsPlatformViewBoundingRect(const SkRRect& clip_rrect, result(nil); } -void FlutterPlatformViewsController::OnDispose(FlutterMethodCall* call, FlutterResult& result) { +void FlutterPlatformViewsController::OnDispose(FlutterMethodCall* call, FlutterResult result) { NSNumber* arg = [call arguments]; int64_t viewId = [arg longLongValue]; @@ -268,7 +268,7 @@ static bool ClipRRectContainsPlatformViewBoundingRect(const SkRRect& clip_rrect, } void FlutterPlatformViewsController::OnAcceptGesture(FlutterMethodCall* call, - FlutterResult& result) { + FlutterResult result) { NSDictionary* args = [call arguments]; int64_t viewId = [args[@"id"] longLongValue]; @@ -286,7 +286,7 @@ static bool ClipRRectContainsPlatformViewBoundingRect(const SkRRect& clip_rrect, } void FlutterPlatformViewsController::OnRejectGesture(FlutterMethodCall* call, - FlutterResult& result) { + FlutterResult result) { NSDictionary* args = [call arguments]; int64_t viewId = [args[@"id"] longLongValue]; diff --git a/shell/platform/darwin/ios/framework/Source/FlutterPlatformViewsTest.mm b/shell/platform/darwin/ios/framework/Source/FlutterPlatformViewsTest.mm index 556077134aefb..132474658e14a 100644 --- a/shell/platform/darwin/ios/framework/Source/FlutterPlatformViewsTest.mm +++ b/shell/platform/darwin/ios/framework/Source/FlutterPlatformViewsTest.mm @@ -16,6 +16,7 @@ #import "flutter/shell/platform/darwin/ios/platform_view_ios.h" FLUTTER_ASSERT_ARC + @class FlutterPlatformViewsTestMockPlatformView; __weak static FlutterPlatformViewsTestMockPlatformView* gMockPlatformView = nil; const float kFloatCompareEpsilon = 0.001; diff --git a/shell/platform/darwin/ios/framework/Source/FlutterPlatformViews_Internal.h b/shell/platform/darwin/ios/framework/Source/FlutterPlatformViews_Internal.h index 6621cd5e06c0f..f3a384a89edbf 100644 --- a/shell/platform/darwin/ios/framework/Source/FlutterPlatformViews_Internal.h +++ b/shell/platform/darwin/ios/framework/Source/FlutterPlatformViews_Internal.h @@ -279,10 +279,10 @@ class FlutterPlatformViewsController { using LayersMap = std::map>>; - void OnCreate(FlutterMethodCall* call, FlutterResult& result); - void OnDispose(FlutterMethodCall* call, FlutterResult& result); - void OnAcceptGesture(FlutterMethodCall* call, FlutterResult& result); - void OnRejectGesture(FlutterMethodCall* call, FlutterResult& result); + void OnCreate(FlutterMethodCall* call, FlutterResult result); + void OnDispose(FlutterMethodCall* call, FlutterResult result); + void OnAcceptGesture(FlutterMethodCall* call, FlutterResult result); + void OnRejectGesture(FlutterMethodCall* call, FlutterResult result); // Dispose the views in `views_to_dispose_`. void DisposeViews(); diff --git a/shell/platform/darwin/ios/framework/Source/FlutterViewTest.mm b/shell/platform/darwin/ios/framework/Source/FlutterViewTest.mm index 3becc69678a07..e1c1846873fac 100644 --- a/shell/platform/darwin/ios/framework/Source/FlutterViewTest.mm +++ b/shell/platform/darwin/ios/framework/Source/FlutterViewTest.mm @@ -4,9 +4,12 @@ #import +#import "flutter/shell/platform/darwin/common/framework/Headers/FlutterMacros.h" #import "flutter/shell/platform/darwin/ios/framework/Source/FlutterEngine_Internal.h" #import "flutter/shell/platform/darwin/ios/framework/Source/FlutterView.h" +FLUTTER_ASSERT_ARC + @interface FakeDelegate : NSObject @property(nonatomic) BOOL callbackCalled; @property(nonatomic, assign) BOOL isUsingImpeller; diff --git a/shell/platform/darwin/ios/framework/Source/accessibility_bridge_test.mm b/shell/platform/darwin/ios/framework/Source/accessibility_bridge_test.mm index c536366f39de4..baebe55dbbe6c 100644 --- a/shell/platform/darwin/ios/framework/Source/accessibility_bridge_test.mm +++ b/shell/platform/darwin/ios/framework/Source/accessibility_bridge_test.mm @@ -14,6 +14,8 @@ #import "flutter/shell/platform/darwin/ios/framework/Source/accessibility_bridge.h" #import "flutter/shell/platform/darwin/ios/platform_view_ios.h" +FLUTTER_ASSERT_ARC + @class MockPlatformView; __weak static MockPlatformView* gMockPlatformView = nil; diff --git a/shell/platform/darwin/ios/platform_message_handler_ios_test.mm b/shell/platform/darwin/ios/platform_message_handler_ios_test.mm index 7b6d1931e5d60..85560e5df7143 100644 --- a/shell/platform/darwin/ios/platform_message_handler_ios_test.mm +++ b/shell/platform/darwin/ios/platform_message_handler_ios_test.mm @@ -12,6 +12,9 @@ #import "flutter/lib/ui/window/platform_message.h" #import "flutter/lib/ui/window/platform_message_response.h" #import "flutter/shell/common/thread_host.h" +#import "flutter/shell/platform/darwin/common/framework/Headers/FlutterMacros.h" + +FLUTTER_ASSERT_ARC namespace { using namespace flutter;