diff --git a/ci/licenses_golden/licenses_flutter b/ci/licenses_golden/licenses_flutter index c679184313659..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 @@ -4579,7 +4577,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 @@ -7302,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 @@ -7353,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 @@ -7364,7 +7359,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 93bbe44130748..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,56 +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/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", - "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 = [ "*" ] @@ -299,29 +252,35 @@ shared_library("ios_test_flutter") { "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/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..e0153800ed7a4 100644 --- a/shell/platform/darwin/ios/framework/Source/FlutterEngineTest.mm +++ b/shell/platform/darwin/ios/framework/Source/FlutterEngineTest.mm @@ -13,11 +13,25 @@ #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/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,30 @@ - (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/FlutterPlatformViews.mm b/shell/platform/darwin/ios/framework/Source/FlutterPlatformViews.mm index da76b2e107eaa..004fe7eb31b38 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"]) { @@ -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 c55111136df9b..132474658e14a 100644 --- a/shell/platform/darwin/ios/framework/Source/FlutterPlatformViewsTest.mm +++ b/shell/platform/darwin/ios/framework/Source/FlutterPlatformViewsTest.mm @@ -15,9 +15,10 @@ #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 +35,6 @@ - (instancetype)init { - (void)dealloc { gMockPlatformView = nil; - [super dealloc]; } @end @@ -66,12 +66,6 @@ - (void)checkViewCreatedOnce { self.viewCreated = YES; } -- (void)dealloc { - [_view release]; - _view = nil; - [super dealloc]; -} - @end @interface FlutterPlatformViewsTestMockFlutterPlatformFactory @@ -82,7 +76,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 +150,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 +161,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 +206,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 +223,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 +260,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 +274,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 +332,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 +346,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 +404,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 +418,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 +477,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 +491,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 +515,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 +548,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 +590,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 +604,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 +630,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 +661,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 +727,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 +741,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 +767,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 +807,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 +1004,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 +1018,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 +1203,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 +1239,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 +1263,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 +1304,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 +1318,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 +1360,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 +1374,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 +1454,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 +1468,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 +1525,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 +1539,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 +1592,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 +1606,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 +1658,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 +1672,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 +1731,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 +1745,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 +1804,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 +1818,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 +1878,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 +1910,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 +1942,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 +1977,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 +1985,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 +2011,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 +2019,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 +2063,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 +2174,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 +2236,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 +2297,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 +2347,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 +2403,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 +2501,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 +2599,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 +2663,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 +2677,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 +2694,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 +2711,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 +2720,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 +2748,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 +2761,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 +2830,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 +2853,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 +2929,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 +3038,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 +3049,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 +3080,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 +3089,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..f3a384a89edbf 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. @@ -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/FlutterViewControllerTest.mm b/shell/platform/darwin/ios/framework/Source/FlutterViewControllerTest.mm index 35ffaac68bfbe..a68a55287fb42 100644 --- a/shell/platform/darwin/ios/framework/Source/FlutterViewControllerTest.mm +++ b/shell/platform/darwin/ios/framework/Source/FlutterViewControllerTest.mm @@ -17,6 +17,7 @@ #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" @@ -122,6 +123,8 @@ @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 +163,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 +173,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 +2032,160 @@ - (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/FlutterViewTest.mm b/shell/platform/darwin/ios/framework/Source/FlutterViewTest.mm index b5a0c1002961a..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; @@ -43,26 +46,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 +70,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 3d7f2cdf0163e..c0e90db785559 100644 --- a/shell/platform/darwin/ios/framework/Source/SemanticsObjectTest.mm +++ b/shell/platform/darwin/ios/framework/Source/SemanticsObjectTest.mm @@ -6,6 +6,8 @@ #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" @@ -922,4 +924,73 @@ - (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); +} + +- (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 0567e37c0e30e..0000000000000 --- a/shell/platform/darwin/ios/framework/Source/SemanticsObjectTest_mrc.mm +++ /dev/null @@ -1,89 +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)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()); - 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..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,9 +14,10 @@ #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 +FLUTTER_ASSERT_ARC + @class MockPlatformView; -static MockPlatformView* gMockPlatformView = nil; +__weak static MockPlatformView* gMockPlatformView = nil; @interface MockPlatformView : UIView @end @@ -32,7 +33,6 @@ - (instancetype)init { - (void)dealloc { gMockPlatformView = nil; - [super dealloc]; } @end @@ -50,12 +50,6 @@ - (instancetype)init { return self; } -- (void)dealloc { - [_view release]; - _view = nil; - [super dealloc]; -} - @end @interface MockFlutterPlatformFactory : NSObject @@ -65,7 +59,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 +282,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 +336,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 +360,6 @@ - (void)testSemanticsDeallocatedWithoutLoadingView { XCTAssertNil(gMockPlatformView); XCTAssertNil(flutterViewController.viewIfLoaded); [flutterViewController deregisterNotifications]; - [flutterViewController release]; } - (void)testReplacedSemanticsDoesNotCleanupChildren { @@ -629,7 +622,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 +737,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 +821,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 +896,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 +1027,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 +1124,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 +1210,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 +1302,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 +1346,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 +1416,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 +1485,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 +1560,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 +1637,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 +1710,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 +1786,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 +1842,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 +1904,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 +2018,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..85560e5df7143 100644 --- a/shell/platform/darwin/ios/platform_message_handler_ios_test.mm +++ b/shell/platform/darwin/ios/platform_message_handler_ios_test.mm @@ -14,7 +14,7 @@ #import "flutter/shell/common/thread_host.h" #import "flutter/shell/platform/darwin/common/framework/Headers/FlutterMacros.h" -FLUTTER_ASSERT_NOT_ARC +FLUTTER_ASSERT_ARC namespace { using namespace flutter;