[Ios] move flutter_test_ios_mrc unittests to arc (flutter/engine#48162)

Move all tests in flutter_test_ios_mrc to arc

Part of https://github.com/flutter/flutter/issues/137801

Changes mostly involves trivial mrc to arc changes. non-trivial changes are commented inline. 

[C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
This commit is contained in:
Chris Yang
2023-11-17 12:26:16 -08:00
committed by GitHub
parent 21b2df9815
commit e7f47ca25d
15 changed files with 459 additions and 602 deletions

View File

@@ -4525,7 +4525,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
@@ -4576,7 +4575,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
@@ -4587,7 +4585,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
@@ -7318,7 +7315,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
@@ -7369,7 +7365,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
@@ -7380,7 +7375,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

View File

@@ -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",

View File

@@ -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 {

View File

@@ -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 () <FlutterTextInputDelegate>
@end
@@ -430,4 +444,30 @@ FLUTTER_ASSERT_ARC
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<flutter::IOSContext> engine_context = [engine iosPlatformView]->GetIosContext();
std::shared_ptr<flutter::IOSContext> 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

View File

@@ -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 <OCMock/OCMock.h>
#import <XCTest/XCTest.h>
#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<flutter::IOSContext> engine_context = [engine iosPlatformView]->GetIosContext();
std::shared_ptr<flutter::IOSContext> 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

View File

@@ -173,7 +173,7 @@ UIViewController* FlutterPlatformViewsController::getFlutterViewController() {
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 @@ void FlutterPlatformViewsController::OnMethodCall(FlutterMethodCall* call, Flutt
}
}
void FlutterPlatformViewsController::OnCreate(FlutterMethodCall* call, FlutterResult& result) {
void FlutterPlatformViewsController::OnCreate(FlutterMethodCall* call, FlutterResult result) {
NSDictionary<NSString*, id>* args = [call arguments];
int64_t viewId = [args[@"id"] longLongValue];
@@ -252,7 +252,7 @@ void FlutterPlatformViewsController::OnCreate(FlutterMethodCall* call, FlutterRe
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 @@ void FlutterPlatformViewsController::OnDispose(FlutterMethodCall* call, FlutterR
}
void FlutterPlatformViewsController::OnAcceptGesture(FlutterMethodCall* call,
FlutterResult& result) {
FlutterResult result) {
NSDictionary<NSString*, id>* args = [call arguments];
int64_t viewId = [args[@"id"] longLongValue];
@@ -286,7 +286,7 @@ void FlutterPlatformViewsController::OnAcceptGesture(FlutterMethodCall* call,
}
void FlutterPlatformViewsController::OnRejectGesture(FlutterMethodCall* call,
FlutterResult& result) {
FlutterResult result) {
NSDictionary<NSString*, id>* args = [call arguments];
int64_t viewId = [args[@"id"] longLongValue];

View File

@@ -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 @@ const float kFloatCompareEpsilon = 0.001;
- (void)dealloc {
gMockPlatformView = nil;
[super dealloc];
}
@end
@@ -66,12 +66,6 @@ const float kFloatCompareEpsilon = 0.001;
self.viewCreated = YES;
}
- (void)dealloc {
[_view release];
_view = nil;
[super dealloc];
}
@end
@interface FlutterPlatformViewsTestMockFlutterPlatformFactory
@@ -82,7 +76,7 @@ const float kFloatCompareEpsilon = 0.001;
- (NSObject<FlutterPlatformView>*)createWithFrame:(CGRect)frame
viewIdentifier:(int64_t)viewId
arguments:(id _Nullable)args {
return [[[FlutterPlatformViewsTestMockFlutterPlatformView alloc] init] autorelease];
return [[FlutterPlatformViewsTestMockFlutterPlatformView alloc] init];
}
@end
@@ -158,7 +152,7 @@ fml::RefPtr<fml::TaskRunner> CreateNewThread(const std::string& name) {
/*is_gpu_disabled_jsync_switch=*/std::make_shared<fml::SyncSwitch>());
FlutterPlatformViewsTestMockFlutterPlatformFactory* factory =
[[[FlutterPlatformViewsTestMockFlutterPlatformFactory alloc] init] autorelease];
[[FlutterPlatformViewsTestMockFlutterPlatformFactory alloc] init];
flutterPlatformViewsController->RegisterViewFactory(
factory, @"MockFlutterPlatformView",
FlutterPlatformViewGestureRecognizersBlockingPolicyEager);
@@ -169,7 +163,7 @@ fml::RefPtr<fml::TaskRunner> CreateNewThread(const std::string& name) {
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;
@@ -216,7 +210,7 @@ fml::RefPtr<fml::TaskRunner> CreateNewThread(const std::string& name) {
/*is_gpu_disabled_jsync_switch=*/std::make_shared<fml::SyncSwitch>());
FlutterPlatformViewsTestMockFlutterPlatformFactory* factory =
[[[FlutterPlatformViewsTestMockFlutterPlatformFactory alloc] init] autorelease];
[[FlutterPlatformViewsTestMockFlutterPlatformFactory alloc] init];
flutterPlatformViewsController->RegisterViewFactory(
factory, @"MockFlutterPlatformView",
FlutterPlatformViewGestureRecognizersBlockingPolicyEager);
@@ -233,8 +227,8 @@ fml::RefPtr<fml::TaskRunner> CreateNewThread(const std::string& name) {
- (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]);
@@ -272,7 +266,7 @@ fml::RefPtr<fml::TaskRunner> CreateNewThread(const std::string& name) {
/*is_gpu_disabled_jsync_switch=*/std::make_shared<fml::SyncSwitch>());
FlutterPlatformViewsTestMockFlutterPlatformFactory* factory =
[[[FlutterPlatformViewsTestMockFlutterPlatformFactory alloc] init] autorelease];
[[FlutterPlatformViewsTestMockFlutterPlatformFactory alloc] init];
flutterPlatformViewsController->RegisterViewFactory(
factory, @"MockFlutterPlatformView",
FlutterPlatformViewGestureRecognizersBlockingPolicyEager);
@@ -286,7 +280,7 @@ fml::RefPtr<fml::TaskRunner> CreateNewThread(const std::string& name) {
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;
@@ -346,7 +340,7 @@ fml::RefPtr<fml::TaskRunner> CreateNewThread(const std::string& name) {
/*is_gpu_disabled_jsync_switch=*/std::make_shared<fml::SyncSwitch>());
FlutterPlatformViewsTestMockFlutterPlatformFactory* factory =
[[[FlutterPlatformViewsTestMockFlutterPlatformFactory alloc] init] autorelease];
[[FlutterPlatformViewsTestMockFlutterPlatformFactory alloc] init];
flutterPlatformViewsController->RegisterViewFactory(
factory, @"MockFlutterPlatformView",
FlutterPlatformViewGestureRecognizersBlockingPolicyEager);
@@ -360,7 +354,7 @@ fml::RefPtr<fml::TaskRunner> CreateNewThread(const std::string& name) {
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;
@@ -420,7 +414,7 @@ fml::RefPtr<fml::TaskRunner> CreateNewThread(const std::string& name) {
/*is_gpu_disabled_jsync_switch=*/std::make_shared<fml::SyncSwitch>());
FlutterPlatformViewsTestMockFlutterPlatformFactory* factory =
[[[FlutterPlatformViewsTestMockFlutterPlatformFactory alloc] init] autorelease];
[[FlutterPlatformViewsTestMockFlutterPlatformFactory alloc] init];
flutterPlatformViewsController->RegisterViewFactory(
factory, @"MockFlutterPlatformView",
FlutterPlatformViewGestureRecognizersBlockingPolicyEager);
@@ -434,7 +428,7 @@ fml::RefPtr<fml::TaskRunner> CreateNewThread(const std::string& name) {
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;
@@ -495,7 +489,7 @@ fml::RefPtr<fml::TaskRunner> CreateNewThread(const std::string& name) {
/*is_gpu_disabled_jsync_switch=*/std::make_shared<fml::SyncSwitch>());
FlutterPlatformViewsTestMockFlutterPlatformFactory* factory =
[[[FlutterPlatformViewsTestMockFlutterPlatformFactory alloc] init] autorelease];
[[FlutterPlatformViewsTestMockFlutterPlatformFactory alloc] init];
flutterPlatformViewsController->RegisterViewFactory(
factory, @"MockFlutterPlatformView",
FlutterPlatformViewGestureRecognizersBlockingPolicyEager);
@@ -509,7 +503,7 @@ fml::RefPtr<fml::TaskRunner> CreateNewThread(const std::string& name) {
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;
@@ -533,7 +527,7 @@ fml::RefPtr<fml::TaskRunner> CreateNewThread(const std::string& name) {
[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;
@@ -566,7 +560,7 @@ fml::RefPtr<fml::TaskRunner> CreateNewThread(const std::string& name) {
[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;
@@ -610,7 +604,7 @@ fml::RefPtr<fml::TaskRunner> CreateNewThread(const std::string& name) {
/*is_gpu_disabled_jsync_switch=*/std::make_shared<fml::SyncSwitch>());
FlutterPlatformViewsTestMockFlutterPlatformFactory* factory =
[[[FlutterPlatformViewsTestMockFlutterPlatformFactory alloc] init] autorelease];
[[FlutterPlatformViewsTestMockFlutterPlatformFactory alloc] init];
flutterPlatformViewsController->RegisterViewFactory(
factory, @"MockFlutterPlatformView",
FlutterPlatformViewGestureRecognizersBlockingPolicyEager);
@@ -624,7 +618,7 @@ fml::RefPtr<fml::TaskRunner> CreateNewThread(const std::string& name) {
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;
@@ -650,7 +644,7 @@ fml::RefPtr<fml::TaskRunner> CreateNewThread(const std::string& name) {
[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;
@@ -681,7 +675,7 @@ fml::RefPtr<fml::TaskRunner> CreateNewThread(const std::string& name) {
[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;
@@ -749,7 +743,7 @@ fml::RefPtr<fml::TaskRunner> CreateNewThread(const std::string& name) {
/*is_gpu_disabled_jsync_switch=*/std::make_shared<fml::SyncSwitch>());
FlutterPlatformViewsTestMockFlutterPlatformFactory* factory =
[[[FlutterPlatformViewsTestMockFlutterPlatformFactory alloc] init] autorelease];
[[FlutterPlatformViewsTestMockFlutterPlatformFactory alloc] init];
flutterPlatformViewsController->RegisterViewFactory(
factory, @"MockFlutterPlatformView",
FlutterPlatformViewGestureRecognizersBlockingPolicyEager);
@@ -763,7 +757,7 @@ fml::RefPtr<fml::TaskRunner> CreateNewThread(const std::string& name) {
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;
@@ -789,7 +783,7 @@ fml::RefPtr<fml::TaskRunner> CreateNewThread(const std::string& name) {
[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;
@@ -829,7 +823,7 @@ fml::RefPtr<fml::TaskRunner> CreateNewThread(const std::string& name) {
[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;
@@ -1028,7 +1022,7 @@ fml::RefPtr<fml::TaskRunner> CreateNewThread(const std::string& name) {
/*is_gpu_disabled_jsync_switch=*/std::make_shared<fml::SyncSwitch>());
FlutterPlatformViewsTestMockFlutterPlatformFactory* factory =
[[[FlutterPlatformViewsTestMockFlutterPlatformFactory alloc] init] autorelease];
[[FlutterPlatformViewsTestMockFlutterPlatformFactory alloc] init];
flutterPlatformViewsController->RegisterViewFactory(
factory, @"MockFlutterPlatformView",
FlutterPlatformViewGestureRecognizersBlockingPolicyEager);
@@ -1042,7 +1036,7 @@ fml::RefPtr<fml::TaskRunner> CreateNewThread(const std::string& name) {
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;
@@ -1227,29 +1221,29 @@ fml::RefPtr<fml::TaskRunner> CreateNewThread(const std::string& name) {
// 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"]) {
@@ -1263,16 +1257,16 @@ fml::RefPtr<fml::TaskRunner> CreateNewThread(const std::string& name) {
}
}
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"]) {
@@ -1287,19 +1281,19 @@ fml::RefPtr<fml::TaskRunner> CreateNewThread(const std::string& name) {
}
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"]) {
@@ -1330,7 +1324,7 @@ fml::RefPtr<fml::TaskRunner> CreateNewThread(const std::string& name) {
/*is_gpu_disabled_jsync_switch=*/std::make_shared<fml::SyncSwitch>());
FlutterPlatformViewsTestMockFlutterPlatformFactory* factory =
[[[FlutterPlatformViewsTestMockFlutterPlatformFactory alloc] init] autorelease];
[[FlutterPlatformViewsTestMockFlutterPlatformFactory alloc] init];
flutterPlatformViewsController->RegisterViewFactory(
factory, @"MockFlutterPlatformView",
FlutterPlatformViewGestureRecognizersBlockingPolicyEager);
@@ -1344,7 +1338,7 @@ fml::RefPtr<fml::TaskRunner> CreateNewThread(const std::string& name) {
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;
@@ -1388,7 +1382,7 @@ fml::RefPtr<fml::TaskRunner> CreateNewThread(const std::string& name) {
/*is_gpu_disabled_jsync_switch=*/std::make_shared<fml::SyncSwitch>());
FlutterPlatformViewsTestMockFlutterPlatformFactory* factory =
[[[FlutterPlatformViewsTestMockFlutterPlatformFactory alloc] init] autorelease];
[[FlutterPlatformViewsTestMockFlutterPlatformFactory alloc] init];
flutterPlatformViewsController->RegisterViewFactory(
factory, @"MockFlutterPlatformView",
FlutterPlatformViewGestureRecognizersBlockingPolicyEager);
@@ -1402,7 +1396,7 @@ fml::RefPtr<fml::TaskRunner> CreateNewThread(const std::string& name) {
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;
@@ -1484,7 +1478,7 @@ fml::RefPtr<fml::TaskRunner> CreateNewThread(const std::string& name) {
/*is_gpu_disabled_jsync_switch=*/std::make_shared<fml::SyncSwitch>());
FlutterPlatformViewsTestMockFlutterPlatformFactory* factory =
[[[FlutterPlatformViewsTestMockFlutterPlatformFactory alloc] init] autorelease];
[[FlutterPlatformViewsTestMockFlutterPlatformFactory alloc] init];
flutterPlatformViewsController->RegisterViewFactory(
factory, @"MockFlutterPlatformView",
FlutterPlatformViewGestureRecognizersBlockingPolicyEager);
@@ -1498,7 +1492,7 @@ fml::RefPtr<fml::TaskRunner> CreateNewThread(const std::string& name) {
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;
@@ -1557,7 +1551,7 @@ fml::RefPtr<fml::TaskRunner> CreateNewThread(const std::string& name) {
/*is_gpu_disabled_jsync_switch=*/std::make_shared<fml::SyncSwitch>());
FlutterPlatformViewsTestMockFlutterPlatformFactory* factory =
[[[FlutterPlatformViewsTestMockFlutterPlatformFactory alloc] init] autorelease];
[[FlutterPlatformViewsTestMockFlutterPlatformFactory alloc] init];
flutterPlatformViewsController->RegisterViewFactory(
factory, @"MockFlutterPlatformView",
FlutterPlatformViewGestureRecognizersBlockingPolicyEager);
@@ -1571,7 +1565,7 @@ fml::RefPtr<fml::TaskRunner> CreateNewThread(const std::string& name) {
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;
@@ -1626,7 +1620,7 @@ fml::RefPtr<fml::TaskRunner> CreateNewThread(const std::string& name) {
/*is_gpu_disabled_jsync_switch=*/std::make_shared<fml::SyncSwitch>());
FlutterPlatformViewsTestMockFlutterPlatformFactory* factory =
[[[FlutterPlatformViewsTestMockFlutterPlatformFactory alloc] init] autorelease];
[[FlutterPlatformViewsTestMockFlutterPlatformFactory alloc] init];
flutterPlatformViewsController->RegisterViewFactory(
factory, @"MockFlutterPlatformView",
FlutterPlatformViewGestureRecognizersBlockingPolicyEager);
@@ -1640,7 +1634,7 @@ fml::RefPtr<fml::TaskRunner> CreateNewThread(const std::string& name) {
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;
@@ -1694,7 +1688,7 @@ fml::RefPtr<fml::TaskRunner> CreateNewThread(const std::string& name) {
/*is_gpu_disabled_jsync_switch=*/std::make_shared<fml::SyncSwitch>());
FlutterPlatformViewsTestMockFlutterPlatformFactory* factory =
[[[FlutterPlatformViewsTestMockFlutterPlatformFactory alloc] init] autorelease];
[[FlutterPlatformViewsTestMockFlutterPlatformFactory alloc] init];
flutterPlatformViewsController->RegisterViewFactory(
factory, @"MockFlutterPlatformView",
FlutterPlatformViewGestureRecognizersBlockingPolicyEager);
@@ -1708,7 +1702,7 @@ fml::RefPtr<fml::TaskRunner> CreateNewThread(const std::string& name) {
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;
@@ -1769,7 +1763,7 @@ fml::RefPtr<fml::TaskRunner> CreateNewThread(const std::string& name) {
/*is_gpu_disabled_jsync_switch=*/std::make_shared<fml::SyncSwitch>());
FlutterPlatformViewsTestMockFlutterPlatformFactory* factory =
[[[FlutterPlatformViewsTestMockFlutterPlatformFactory alloc] init] autorelease];
[[FlutterPlatformViewsTestMockFlutterPlatformFactory alloc] init];
flutterPlatformViewsController->RegisterViewFactory(
factory, @"MockFlutterPlatformView",
FlutterPlatformViewGestureRecognizersBlockingPolicyEager);
@@ -1783,7 +1777,7 @@ fml::RefPtr<fml::TaskRunner> CreateNewThread(const std::string& name) {
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;
@@ -1844,7 +1838,7 @@ fml::RefPtr<fml::TaskRunner> CreateNewThread(const std::string& name) {
/*is_gpu_disabled_jsync_switch=*/std::make_shared<fml::SyncSwitch>());
FlutterPlatformViewsTestMockFlutterPlatformFactory* factory =
[[[FlutterPlatformViewsTestMockFlutterPlatformFactory alloc] init] autorelease];
[[FlutterPlatformViewsTestMockFlutterPlatformFactory alloc] init];
flutterPlatformViewsController->RegisterViewFactory(
factory, @"MockFlutterPlatformView",
FlutterPlatformViewGestureRecognizersBlockingPolicyEager);
@@ -1858,7 +1852,7 @@ fml::RefPtr<fml::TaskRunner> CreateNewThread(const std::string& name) {
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;
@@ -1920,7 +1914,7 @@ fml::RefPtr<fml::TaskRunner> CreateNewThread(const std::string& name) {
/*is_gpu_disabled_jsync_switch=*/std::make_shared<fml::SyncSwitch>());
FlutterPlatformViewsTestMockFlutterPlatformFactory* factory =
[[[FlutterPlatformViewsTestMockFlutterPlatformFactory alloc] init] autorelease];
[[FlutterPlatformViewsTestMockFlutterPlatformFactory alloc] init];
flutterPlatformViewsController->RegisterViewFactory(
factory, @"MockFlutterPlatformView",
FlutterPlatformViewGestureRecognizersBlockingPolicyEager);
@@ -1952,14 +1946,14 @@ fml::RefPtr<fml::TaskRunner> CreateNewThread(const std::string& name) {
}
// 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];
@@ -1986,7 +1980,7 @@ fml::RefPtr<fml::TaskRunner> CreateNewThread(const std::string& name) {
/*is_gpu_disabled_jsync_switch=*/std::make_shared<fml::SyncSwitch>());
FlutterPlatformViewsTestMockFlutterPlatformFactory* factory =
[[[FlutterPlatformViewsTestMockFlutterPlatformFactory alloc] init] autorelease];
[[FlutterPlatformViewsTestMockFlutterPlatformFactory alloc] init];
flutterPlatformViewsController->RegisterViewFactory(
factory, @"MockFlutterPlatformView",
FlutterPlatformViewGestureRecognizersBlockingPolicyEager);
@@ -2021,7 +2015,7 @@ fml::RefPtr<fml::TaskRunner> CreateNewThread(const std::string& name) {
// ***** 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]);
@@ -2029,23 +2023,23 @@ fml::RefPtr<fml::TaskRunner> CreateNewThread(const std::string& name) {
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]);
@@ -2055,7 +2049,7 @@ fml::RefPtr<fml::TaskRunner> CreateNewThread(const std::string& name) {
// ***** 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]);
@@ -2063,23 +2057,23 @@ fml::RefPtr<fml::TaskRunner> CreateNewThread(const std::string& name) {
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]);
@@ -2109,7 +2103,7 @@ fml::RefPtr<fml::TaskRunner> CreateNewThread(const std::string& name) {
/*is_gpu_disabled_jsync_switch=*/std::make_shared<fml::SyncSwitch>());
FlutterPlatformViewsTestMockFlutterPlatformFactory* factory =
[[[FlutterPlatformViewsTestMockFlutterPlatformFactory alloc] init] autorelease];
[[FlutterPlatformViewsTestMockFlutterPlatformFactory alloc] init];
flutterPlatformViewsController->RegisterViewFactory(
factory, @"MockFlutterPlatformView",
FlutterPlatformViewGestureRecognizersBlockingPolicyEager);
@@ -2222,7 +2216,7 @@ fml::RefPtr<fml::TaskRunner> CreateNewThread(const std::string& name) {
/*is_gpu_disabled_jsync_switch=*/std::make_shared<fml::SyncSwitch>());
FlutterPlatformViewsTestMockFlutterPlatformFactory* factory =
[[[FlutterPlatformViewsTestMockFlutterPlatformFactory alloc] init] autorelease];
[[FlutterPlatformViewsTestMockFlutterPlatformFactory alloc] init];
flutterPlatformViewsController->RegisterViewFactory(
factory, @"MockFlutterPlatformView",
FlutterPlatformViewGestureRecognizersBlockingPolicyEager);
@@ -2286,7 +2280,7 @@ fml::RefPtr<fml::TaskRunner> CreateNewThread(const std::string& name) {
/*is_gpu_disabled_jsync_switch=*/std::make_shared<fml::SyncSwitch>());
FlutterPlatformViewsTestMockFlutterPlatformFactory* factory =
[[[FlutterPlatformViewsTestMockFlutterPlatformFactory alloc] init] autorelease];
[[FlutterPlatformViewsTestMockFlutterPlatformFactory alloc] init];
flutterPlatformViewsController->RegisterViewFactory(
factory, @"MockFlutterPlatformView",
FlutterPlatformViewGestureRecognizersBlockingPolicyEager);
@@ -2349,11 +2343,11 @@ fml::RefPtr<fml::TaskRunner> CreateNewThread(const std::string& name) {
/*worker_task_runner=*/nil,
/*is_gpu_disabled_jsync_switch=*/std::make_shared<fml::SyncSwitch>());
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);
@@ -2401,11 +2395,11 @@ fml::RefPtr<fml::TaskRunner> CreateNewThread(const std::string& name) {
/*worker_task_runner=*/nil,
/*is_gpu_disabled_jsync_switch=*/std::make_shared<fml::SyncSwitch>());
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);
@@ -2459,11 +2453,11 @@ fml::RefPtr<fml::TaskRunner> CreateNewThread(const std::string& name) {
/*worker_task_runner=*/nil,
/*is_gpu_disabled_jsync_switch=*/std::make_shared<fml::SyncSwitch>());
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);
@@ -2559,11 +2553,11 @@ fml::RefPtr<fml::TaskRunner> CreateNewThread(const std::string& name) {
/*worker_task_runner=*/nil,
/*is_gpu_disabled_jsync_switch=*/std::make_shared<fml::SyncSwitch>());
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);
@@ -2659,11 +2653,11 @@ fml::RefPtr<fml::TaskRunner> CreateNewThread(const std::string& name) {
/*worker_task_runner=*/nil,
/*is_gpu_disabled_jsync_switch=*/std::make_shared<fml::SyncSwitch>());
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);
@@ -2723,8 +2717,8 @@ fml::RefPtr<fml::TaskRunner> CreateNewThread(const std::string& name) {
- (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];
@@ -2737,10 +2731,10 @@ fml::RefPtr<fml::TaskRunner> CreateNewThread(const std::string& name) {
- (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];
@@ -2754,8 +2748,7 @@ fml::RefPtr<fml::TaskRunner> CreateNewThread(const std::string& name) {
}
- (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];
@@ -2772,8 +2765,7 @@ fml::RefPtr<fml::TaskRunner> CreateNewThread(const std::string& name) {
}
- (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];
@@ -2782,18 +2774,14 @@ fml::RefPtr<fml::TaskRunner> CreateNewThread(const std::string& name) {
}
- (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 {
@@ -2816,7 +2804,7 @@ fml::RefPtr<fml::TaskRunner> CreateNewThread(const std::string& name) {
/*is_gpu_disabled_jsync_switch=*/std::make_shared<fml::SyncSwitch>());
FlutterPlatformViewsTestMockFlutterPlatformFactory* factory =
[[[FlutterPlatformViewsTestMockFlutterPlatformFactory alloc] init] autorelease];
[[FlutterPlatformViewsTestMockFlutterPlatformFactory alloc] init];
flutterPlatformViewsController->RegisterViewFactory(
factory, @"MockFlutterPlatformView",
FlutterPlatformViewGestureRecognizersBlockingPolicyEager);
@@ -2829,7 +2817,7 @@ fml::RefPtr<fml::TaskRunner> CreateNewThread(const std::string& name) {
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;
@@ -2900,7 +2888,7 @@ fml::RefPtr<fml::TaskRunner> CreateNewThread(const std::string& name) {
/*is_gpu_disabled_jsync_switch=*/std::make_shared<fml::SyncSwitch>());
FlutterPlatformViewsTestMockFlutterPlatformFactory* factory =
[[[FlutterPlatformViewsTestMockFlutterPlatformFactory alloc] init] autorelease];
[[FlutterPlatformViewsTestMockFlutterPlatformFactory alloc] init];
flutterPlatformViewsController->RegisterViewFactory(
factory, @"MockFlutterPlatformView",
FlutterPlatformViewGestureRecognizersBlockingPolicyEager);
@@ -2923,7 +2911,7 @@ fml::RefPtr<fml::TaskRunner> CreateNewThread(const std::string& name) {
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;
@@ -3001,11 +2989,11 @@ fml::RefPtr<fml::TaskRunner> CreateNewThread(const std::string& name) {
/*worker_task_runner=*/nil,
/*is_gpu_disabled_jsync_switch=*/std::make_shared<fml::SyncSwitch>());
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);
@@ -3112,7 +3100,7 @@ fml::RefPtr<fml::TaskRunner> CreateNewThread(const std::string& name) {
/*is_gpu_disabled_jsync_switch=*/std::make_shared<fml::SyncSwitch>());
FlutterPlatformViewsTestMockFlutterPlatformFactory* factory =
[[[FlutterPlatformViewsTestMockFlutterPlatformFactory alloc] init] autorelease];
[[FlutterPlatformViewsTestMockFlutterPlatformFactory alloc] init];
flutterPlatformViewsController->RegisterViewFactory(
factory, @"MockFlutterPlatformView",
FlutterPlatformViewGestureRecognizersBlockingPolicyEager);
@@ -3123,7 +3111,7 @@ fml::RefPtr<fml::TaskRunner> CreateNewThread(const std::string& name) {
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;
@@ -3154,7 +3142,7 @@ fml::RefPtr<fml::TaskRunner> CreateNewThread(const std::string& name) {
flutterPlatformViewsController->SubmitFrame(nullptr, nullptr, std::move(mock_surface));
UIView* someView = [[[UIView alloc] init] autorelease];
UIView* someView = [[UIView alloc] init];
[mockFlutterView addSubview:someView];
flutterPlatformViewsController->Reset();
@@ -3163,9 +3151,8 @@ fml::RefPtr<fml::TaskRunner> CreateNewThread(const std::string& name) {
}
- (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);
}

View File

@@ -261,7 +261,7 @@ class FlutterPlatformViewsController {
const std::shared_ptr<IOSContext>& ios_context,
std::unique_ptr<SurfaceFrame> 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<int64_t, std::vector<std::shared_ptr<FlutterPlatformViewLayer>>>;
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();

View File

@@ -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 @@ extern NSNotificationName const FlutterViewControllerWillDealloc;
@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 @@ extern NSNotificationName const FlutterViewControllerWillDealloc;
- (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 @@ extern NSNotificationName const FlutterViewControllerWillDealloc;
- (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 @@ extern NSNotificationName const FlutterViewControllerWillDealloc;
[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

View File

@@ -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 <OCMock/OCMock.h>
#import <XCTest/XCTest.h>
#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

View File

@@ -4,9 +4,12 @@
#import <XCTest/XCTest.h>
#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 <FlutterViewEngineDelegate>
@property(nonatomic) BOOL callbackCalled;
@property(nonatomic, assign) BOOL isUsingImpeller;
@@ -43,26 +46,23 @@
@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)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);

View File

@@ -6,6 +6,8 @@
#import <XCTest/XCTest.h>
#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 @@ FLUTTER_ASSERT_ARC
XCTAssertNil(object2.accessibilityContainer);
}
- (void)testAccessibilityHitTestSearchCanReturnPlatformView {
fml::WeakPtrFactory<flutter::AccessibilityBridgeIos> factory(
new flutter::MockAccessibilityBridge());
fml::WeakPtr<flutter::AccessibilityBridgeIos> 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<flutter::MockAccessibilityBridge> factory(
new flutter::MockAccessibilityBridge());
fml::WeakPtr<flutter::MockAccessibilityBridge> 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

View File

@@ -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 <OCMock/OCMock.h>
#import <XCTest/XCTest.h>
#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<flutter::AccessibilityBridgeIos> factory(
new flutter::MockAccessibilityBridge());
fml::WeakPtr<flutter::AccessibilityBridgeIos> 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<flutter::MockAccessibilityBridge> factory(
new flutter::MockAccessibilityBridge());
fml::WeakPtr<flutter::MockAccessibilityBridge> 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

View File

@@ -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 @@ static MockPlatformView* gMockPlatformView = nil;
- (void)dealloc {
gMockPlatformView = nil;
[super dealloc];
}
@end
@@ -50,12 +50,6 @@ static MockPlatformView* gMockPlatformView = nil;
return self;
}
- (void)dealloc {
[_view release];
_view = nil;
[super dealloc];
}
@end
@interface MockFlutterPlatformFactory : NSObject <FlutterPlatformViewFactory>
@@ -65,7 +59,7 @@ static MockPlatformView* gMockPlatformView = nil;
- (NSObject<FlutterPlatformView>*)createWithFrame:(CGRect)frame
viewIdentifier:(int64_t)viewId
arguments:(id _Nullable)args {
return [[[MockFlutterPlatformView alloc] init] autorelease];
return [[MockFlutterPlatformView alloc] init];
}
@end
@@ -298,7 +292,7 @@ fml::RefPtr<fml::TaskRunner> CreateNewThread(const std::string& name) {
std::string label = "some label";
flutterPlatformViewsController->SetFlutterView(mockFlutterView);
MockFlutterPlatformFactory* factory = [[[MockFlutterPlatformFactory alloc] init] autorelease];
MockFlutterPlatformFactory* factory = [[MockFlutterPlatformFactory alloc] init];
flutterPlatformViewsController->RegisterViewFactory(
factory, @"MockFlutterPlatformView",
FlutterPlatformViewGestureRecognizersBlockingPolicyEager);
@@ -354,7 +348,7 @@ fml::RefPtr<fml::TaskRunner> CreateNewThread(const std::string& name) {
/*worker_task_runner=*/nil,
/*is_gpu_disabled_sync_switch=*/std::make_shared<fml::SyncSwitch>());
MockFlutterPlatformFactory* factory = [[[MockFlutterPlatformFactory alloc] init] autorelease];
MockFlutterPlatformFactory* factory = [[MockFlutterPlatformFactory alloc] init];
flutterPlatformViewsController->RegisterViewFactory(
factory, @"MockFlutterPlatformView",
FlutterPlatformViewGestureRecognizersBlockingPolicyEager);
@@ -378,7 +372,6 @@ fml::RefPtr<fml::TaskRunner> CreateNewThread(const std::string& name) {
XCTAssertNil(gMockPlatformView);
XCTAssertNil(flutterViewController.viewIfLoaded);
[flutterViewController deregisterNotifications];
[flutterViewController release];
}
- (void)testReplacedSemanticsDoesNotCleanupChildren {
@@ -649,7 +642,7 @@ fml::RefPtr<fml::TaskRunner> CreateNewThread(const std::string& name) {
OCMStub([mockFlutterViewController view]).andReturn(mockFlutterView);
NSMutableArray<NSDictionary<NSString*, id>*>* accessibility_notifications =
[[[NSMutableArray alloc] init] autorelease];
[[NSMutableArray alloc] init];
auto ios_delegate = std::make_unique<flutter::MockIosDelegate>();
ios_delegate->on_PostAccessibilityNotification_ =
[accessibility_notifications](UIAccessibilityNotifications notification, id argument) {
@@ -768,7 +761,7 @@ fml::RefPtr<fml::TaskRunner> CreateNewThread(const std::string& name) {
OCMStub([mockFlutterViewController view]).andReturn(mockFlutterView);
NSMutableArray<NSDictionary<NSString*, id>*>* accessibility_notifications =
[[[NSMutableArray alloc] init] autorelease];
[[NSMutableArray alloc] init];
auto ios_delegate = std::make_unique<flutter::MockIosDelegate>();
ios_delegate->on_PostAccessibilityNotification_ =
[accessibility_notifications](UIAccessibilityNotifications notification, id argument) {
@@ -854,7 +847,7 @@ fml::RefPtr<fml::TaskRunner> CreateNewThread(const std::string& name) {
OCMStub([mockFlutterViewController view]).andReturn(mockFlutterView);
NSMutableArray<NSDictionary<NSString*, id>*>* accessibility_notifications =
[[[NSMutableArray alloc] init] autorelease];
[[NSMutableArray alloc] init];
auto ios_delegate = std::make_unique<flutter::MockIosDelegate>();
ios_delegate->on_PostAccessibilityNotification_ =
[accessibility_notifications](UIAccessibilityNotifications notification, id argument) {
@@ -931,7 +924,7 @@ fml::RefPtr<fml::TaskRunner> CreateNewThread(const std::string& name) {
OCMStub([mockFlutterViewController view]).andReturn(mockFlutterView);
NSMutableArray<NSDictionary<NSString*, id>*>* accessibility_notifications =
[[[NSMutableArray alloc] init] autorelease];
[[NSMutableArray alloc] init];
auto ios_delegate = std::make_unique<flutter::MockIosDelegate>();
ios_delegate->on_PostAccessibilityNotification_ =
[accessibility_notifications](UIAccessibilityNotifications notification, id argument) {
@@ -1066,7 +1059,7 @@ fml::RefPtr<fml::TaskRunner> CreateNewThread(const std::string& name) {
OCMStub([mockFlutterViewController view]).andReturn(mockFlutterView);
NSMutableArray<NSDictionary<NSString*, id>*>* accessibility_notifications =
[[[NSMutableArray alloc] init] autorelease];
[[NSMutableArray alloc] init];
auto ios_delegate = std::make_unique<flutter::MockIosDelegate>();
ios_delegate->on_PostAccessibilityNotification_ =
[accessibility_notifications](UIAccessibilityNotifications notification, id argument) {
@@ -1165,7 +1158,7 @@ fml::RefPtr<fml::TaskRunner> CreateNewThread(const std::string& name) {
OCMStub([mockFlutterViewController view]).andReturn(mockFlutterView);
NSMutableArray<NSDictionary<NSString*, id>*>* accessibility_notifications =
[[[NSMutableArray alloc] init] autorelease];
[[NSMutableArray alloc] init];
auto ios_delegate = std::make_unique<flutter::MockIosDelegate>();
ios_delegate->on_PostAccessibilityNotification_ =
[accessibility_notifications](UIAccessibilityNotifications notification, id argument) {
@@ -1253,7 +1246,7 @@ fml::RefPtr<fml::TaskRunner> CreateNewThread(const std::string& name) {
OCMStub([mockFlutterViewController view]).andReturn(mockFlutterView);
NSMutableArray<NSDictionary<NSString*, id>*>* accessibility_notifications =
[[[NSMutableArray alloc] init] autorelease];
[[NSMutableArray alloc] init];
auto ios_delegate = std::make_unique<flutter::MockIosDelegate>();
ios_delegate->on_PostAccessibilityNotification_ =
[accessibility_notifications](UIAccessibilityNotifications notification, id argument) {
@@ -1347,7 +1340,7 @@ fml::RefPtr<fml::TaskRunner> CreateNewThread(const std::string& name) {
OCMStub([mockFlutterViewController view]).andReturn(mockFlutterView);
NSMutableArray<NSDictionary<NSString*, id>*>* accessibility_notifications =
[[[NSMutableArray alloc] init] autorelease];
[[NSMutableArray alloc] init];
auto ios_delegate = std::make_unique<flutter::MockIosDelegate>();
ios_delegate->on_PostAccessibilityNotification_ =
[accessibility_notifications](UIAccessibilityNotifications notification, id argument) {
@@ -1393,7 +1386,7 @@ fml::RefPtr<fml::TaskRunner> CreateNewThread(const std::string& name) {
OCMStub([mockFlutterViewController view]).andReturn(mockFlutterView);
NSMutableArray<NSDictionary<NSString*, id>*>* accessibility_notifications =
[[[NSMutableArray alloc] init] autorelease];
[[NSMutableArray alloc] init];
auto ios_delegate = std::make_unique<flutter::MockIosDelegate>();
ios_delegate->on_PostAccessibilityNotification_ =
[accessibility_notifications](UIAccessibilityNotifications notification, id argument) {
@@ -1465,7 +1458,7 @@ fml::RefPtr<fml::TaskRunner> CreateNewThread(const std::string& name) {
OCMStub([mockFlutterViewController view]).andReturn(mockFlutterView);
NSMutableArray<NSDictionary<NSString*, id>*>* accessibility_notifications =
[[[NSMutableArray alloc] init] autorelease];
[[NSMutableArray alloc] init];
auto ios_delegate = std::make_unique<flutter::MockIosDelegate>();
ios_delegate->on_PostAccessibilityNotification_ =
[accessibility_notifications](UIAccessibilityNotifications notification, id argument) {
@@ -1536,7 +1529,7 @@ fml::RefPtr<fml::TaskRunner> CreateNewThread(const std::string& name) {
OCMStub([mockFlutterViewController view]).andReturn(mockFlutterView);
NSMutableArray<NSDictionary<NSString*, id>*>* accessibility_notifications =
[[[NSMutableArray alloc] init] autorelease];
[[NSMutableArray alloc] init];
auto ios_delegate = std::make_unique<flutter::MockIosDelegate>();
ios_delegate->on_PostAccessibilityNotification_ =
[accessibility_notifications](UIAccessibilityNotifications notification, id argument) {
@@ -1613,7 +1606,7 @@ fml::RefPtr<fml::TaskRunner> CreateNewThread(const std::string& name) {
OCMStub([mockFlutterViewController view]).andReturn(mockFlutterView);
NSMutableArray<NSDictionary<NSString*, id>*>* accessibility_notifications =
[[[NSMutableArray alloc] init] autorelease];
[[NSMutableArray alloc] init];
auto ios_delegate = std::make_unique<flutter::MockIosDelegate>();
ios_delegate->on_PostAccessibilityNotification_ =
[accessibility_notifications](UIAccessibilityNotifications notification, id argument) {
@@ -1692,7 +1685,7 @@ fml::RefPtr<fml::TaskRunner> CreateNewThread(const std::string& name) {
OCMStub([mockFlutterViewController view]).andReturn(mockFlutterView);
NSMutableArray<NSDictionary<NSString*, id>*>* accessibility_notifications =
[[[NSMutableArray alloc] init] autorelease];
[[NSMutableArray alloc] init];
auto ios_delegate = std::make_unique<flutter::MockIosDelegate>();
ios_delegate->on_PostAccessibilityNotification_ =
[accessibility_notifications](UIAccessibilityNotifications notification, id argument) {
@@ -1767,7 +1760,7 @@ fml::RefPtr<fml::TaskRunner> CreateNewThread(const std::string& name) {
OCMStub([mockFlutterViewController view]).andReturn(mockFlutterView);
NSMutableArray<NSDictionary<NSString*, id>*>* accessibility_notifications =
[[[NSMutableArray alloc] init] autorelease];
[[NSMutableArray alloc] init];
auto ios_delegate = std::make_unique<flutter::MockIosDelegate>();
ios_delegate->on_PostAccessibilityNotification_ =
[accessibility_notifications](UIAccessibilityNotifications notification, id argument) {
@@ -1845,7 +1838,7 @@ fml::RefPtr<fml::TaskRunner> CreateNewThread(const std::string& name) {
std::string label = "some label";
NSMutableArray<NSDictionary<NSString*, id>*>* accessibility_notifications =
[[[NSMutableArray alloc] init] autorelease];
[[NSMutableArray alloc] init];
auto ios_delegate = std::make_unique<flutter::MockIosDelegate>();
ios_delegate->on_PostAccessibilityNotification_ =
[accessibility_notifications](UIAccessibilityNotifications notification, id argument) {
@@ -1903,7 +1896,7 @@ fml::RefPtr<fml::TaskRunner> CreateNewThread(const std::string& name) {
OCMStub([mockFlutterViewController view]).andReturn(mockFlutterView);
NSMutableArray<NSDictionary<NSString*, id>*>* accessibility_notifications =
[[[NSMutableArray alloc] init] autorelease];
[[NSMutableArray alloc] init];
auto ios_delegate = std::make_unique<flutter::MockIosDelegate>();
ios_delegate->on_PostAccessibilityNotification_ =
[accessibility_notifications](UIAccessibilityNotifications notification, id argument) {
@@ -1967,7 +1960,7 @@ fml::RefPtr<fml::TaskRunner> CreateNewThread(const std::string& name) {
OCMStub([mockFlutterViewController view]).andReturn(mockFlutterView);
NSMutableArray<NSDictionary<NSString*, id>*>* accessibility_notifications =
[[[NSMutableArray alloc] init] autorelease];
[[NSMutableArray alloc] init];
auto ios_delegate = std::make_unique<flutter::MockIosDelegate>();
ios_delegate->on_PostAccessibilityNotification_ =
[accessibility_notifications](UIAccessibilityNotifications notification, id argument) {
@@ -2085,8 +2078,7 @@ fml::RefPtr<fml::TaskRunner> CreateNewThread(const std::string& name) {
FlutterSemanticsScrollView* flutterSemanticsScrollView;
@autoreleasepool {
FlutterScrollableSemanticsObject* semanticsObject =
[[[FlutterScrollableSemanticsObject alloc] initWithBridge:bridge->GetWeakPtr()
uid:1234] autorelease];
[[FlutterScrollableSemanticsObject alloc] initWithBridge:bridge->GetWeakPtr() uid:1234];
flutterSemanticsScrollView = semanticsObject.nativeAccessibility;
}

View File

@@ -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;