Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit 1427b9c

Browse files
author
Chris Yang
authored
[Ios] move flutter_test_ios_mrc unittests to arc (#48162)
Move all tests in flutter_test_ios_mrc to arc Part of flutter/flutter#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
1 parent 141a01c commit 1427b9c

15 files changed

+459
-602
lines changed

ci/licenses_golden/licenses_flutter

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4525,7 +4525,6 @@ ORIGIN: ../../../flutter/shell/platform/darwin/ios/framework/Source/FlutterEngin
45254525
ORIGIN: ../../../flutter/shell/platform/darwin/ios/framework/Source/FlutterEngineGroupTest.mm + ../../../flutter/LICENSE
45264526
ORIGIN: ../../../flutter/shell/platform/darwin/ios/framework/Source/FlutterEnginePlatformViewTest.mm + ../../../flutter/LICENSE
45274527
ORIGIN: ../../../flutter/shell/platform/darwin/ios/framework/Source/FlutterEngineTest.mm + ../../../flutter/LICENSE
4528-
ORIGIN: ../../../flutter/shell/platform/darwin/ios/framework/Source/FlutterEngineTest_mrc.mm + ../../../flutter/LICENSE
45294528
ORIGIN: ../../../flutter/shell/platform/darwin/ios/framework/Source/FlutterEngine_Internal.h + ../../../flutter/LICENSE
45304529
ORIGIN: ../../../flutter/shell/platform/darwin/ios/framework/Source/FlutterEngine_Test.h + ../../../flutter/LICENSE
45314530
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.
45764575
ORIGIN: ../../../flutter/shell/platform/darwin/ios/framework/Source/FlutterView.mm + ../../../flutter/LICENSE
45774576
ORIGIN: ../../../flutter/shell/platform/darwin/ios/framework/Source/FlutterViewController.mm + ../../../flutter/LICENSE
45784577
ORIGIN: ../../../flutter/shell/platform/darwin/ios/framework/Source/FlutterViewControllerTest.mm + ../../../flutter/LICENSE
4579-
ORIGIN: ../../../flutter/shell/platform/darwin/ios/framework/Source/FlutterViewControllerTest_mrc.mm + ../../../flutter/LICENSE
45804578
ORIGIN: ../../../flutter/shell/platform/darwin/ios/framework/Source/FlutterViewController_Internal.h + ../../../flutter/LICENSE
45814579
ORIGIN: ../../../flutter/shell/platform/darwin/ios/framework/Source/FlutterViewResponder.h + ../../../flutter/LICENSE
45824580
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
45874585
ORIGIN: ../../../flutter/shell/platform/darwin/ios/framework/Source/SemanticsObject.mm + ../../../flutter/LICENSE
45884586
ORIGIN: ../../../flutter/shell/platform/darwin/ios/framework/Source/SemanticsObjectTest.mm + ../../../flutter/LICENSE
45894587
ORIGIN: ../../../flutter/shell/platform/darwin/ios/framework/Source/SemanticsObjectTestMocks.h + ../../../flutter/LICENSE
4590-
ORIGIN: ../../../flutter/shell/platform/darwin/ios/framework/Source/SemanticsObjectTest_mrc.mm + ../../../flutter/LICENSE
45914588
ORIGIN: ../../../flutter/shell/platform/darwin/ios/framework/Source/UIViewController+FlutterScreenAndSceneIfLoaded.h + ../../../flutter/LICENSE
45924589
ORIGIN: ../../../flutter/shell/platform/darwin/ios/framework/Source/UIViewController+FlutterScreenAndSceneIfLoaded.mm + ../../../flutter/LICENSE
45934590
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
73187315
FILE: ../../../flutter/shell/platform/darwin/ios/framework/Source/FlutterEngineGroupTest.mm
73197316
FILE: ../../../flutter/shell/platform/darwin/ios/framework/Source/FlutterEnginePlatformViewTest.mm
73207317
FILE: ../../../flutter/shell/platform/darwin/ios/framework/Source/FlutterEngineTest.mm
7321-
FILE: ../../../flutter/shell/platform/darwin/ios/framework/Source/FlutterEngineTest_mrc.mm
73227318
FILE: ../../../flutter/shell/platform/darwin/ios/framework/Source/FlutterEngine_Internal.h
73237319
FILE: ../../../flutter/shell/platform/darwin/ios/framework/Source/FlutterEngine_Test.h
73247320
FILE: ../../../flutter/shell/platform/darwin/ios/framework/Source/FlutterFakeKeyEvents.h
@@ -7369,7 +7365,6 @@ FILE: ../../../flutter/shell/platform/darwin/ios/framework/Source/FlutterView.h
73697365
FILE: ../../../flutter/shell/platform/darwin/ios/framework/Source/FlutterView.mm
73707366
FILE: ../../../flutter/shell/platform/darwin/ios/framework/Source/FlutterViewController.mm
73717367
FILE: ../../../flutter/shell/platform/darwin/ios/framework/Source/FlutterViewControllerTest.mm
7372-
FILE: ../../../flutter/shell/platform/darwin/ios/framework/Source/FlutterViewControllerTest_mrc.mm
73737368
FILE: ../../../flutter/shell/platform/darwin/ios/framework/Source/FlutterViewController_Internal.h
73747369
FILE: ../../../flutter/shell/platform/darwin/ios/framework/Source/FlutterViewResponder.h
73757370
FILE: ../../../flutter/shell/platform/darwin/ios/framework/Source/FlutterViewTest.mm
@@ -7380,7 +7375,6 @@ FILE: ../../../flutter/shell/platform/darwin/ios/framework/Source/SemanticsObjec
73807375
FILE: ../../../flutter/shell/platform/darwin/ios/framework/Source/SemanticsObject.mm
73817376
FILE: ../../../flutter/shell/platform/darwin/ios/framework/Source/SemanticsObjectTest.mm
73827377
FILE: ../../../flutter/shell/platform/darwin/ios/framework/Source/SemanticsObjectTestMocks.h
7383-
FILE: ../../../flutter/shell/platform/darwin/ios/framework/Source/SemanticsObjectTest_mrc.mm
73847378
FILE: ../../../flutter/shell/platform/darwin/ios/framework/Source/UIViewController+FlutterScreenAndSceneIfLoaded.h
73857379
FILE: ../../../flutter/shell/platform/darwin/ios/framework/Source/UIViewController+FlutterScreenAndSceneIfLoaded.mm
73867380
FILE: ../../../flutter/shell/platform/darwin/ios/framework/Source/UIViewController_FlutterScreenAndSceneIfLoadedTest.mm

shell/platform/darwin/ios/BUILD.gn

Lines changed: 10 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,9 @@ source_set("flutter_framework_source") {
7474
deps = []
7575

7676
sources = [
77+
# iOS embedder is migrating to ARC.
78+
# New files are highly encouraged to be in ARC.
79+
# To add new files in ARC, add them to the `flutter_framework_source_arc` target.
7780
"framework/Source/FlutterAppDelegate.mm",
7881
"framework/Source/FlutterCallbackCache.mm",
7982
"framework/Source/FlutterCallbackCache_Internal.h",
@@ -219,56 +222,6 @@ source_set("flutter_framework_source") {
219222
platform_frameworks_path =
220223
rebase_path("$ios_sdk_path/../../Library/Frameworks/")
221224

222-
# For tests that rely on manual reference counting.
223-
source_set("ios_test_flutter_mrc") {
224-
visibility = [ ":*" ]
225-
cflags = [
226-
"-fvisibility=default",
227-
"-F$platform_frameworks_path",
228-
"-mios-simulator-version-min=$ios_testing_deployment_target",
229-
]
230-
231-
# XCode 15 beta has a bug where iOS 17 API usage is not guarded.
232-
# This bug results engine build failure since the engine treats warnings as errors.
233-
# The `-Wno-unguarded-availability-new` can be removed when the XCode bug is fixed.
234-
# See details in https://github.com/flutter/flutter/issues/128958.
235-
cflags_objcc = [ "-Wno-unguarded-availability-new" ]
236-
sources = [
237-
"framework/Source/FlutterEnginePlatformViewTest.mm",
238-
"framework/Source/FlutterEngineTest_mrc.mm",
239-
"framework/Source/FlutterPlatformViewsTest.mm",
240-
"framework/Source/FlutterTouchInterceptingView_Test.h",
241-
"framework/Source/FlutterViewControllerTest_mrc.mm",
242-
"framework/Source/FlutterViewTest.mm",
243-
"framework/Source/SemanticsObjectTestMocks.h",
244-
"framework/Source/SemanticsObjectTest_mrc.mm",
245-
"framework/Source/accessibility_bridge_test.mm",
246-
"platform_message_handler_ios_test.mm",
247-
]
248-
deps = [
249-
":flutter_framework_source",
250-
":flutter_framework_source_arc",
251-
"//flutter/common:common",
252-
"//flutter/lib/ui:ui",
253-
"//flutter/shell/common:common",
254-
"//flutter/shell/platform/darwin/common:framework_common",
255-
"//flutter/shell/platform/embedder:embedder_as_internal_library",
256-
"//flutter/skia",
257-
"//flutter/third_party/rapidjson",
258-
"//flutter/third_party/tonic",
259-
"//flutter/third_party/txt",
260-
"//third_party/ocmock:ocmock_shared",
261-
]
262-
263-
if (shell_enable_vulkan) {
264-
deps += [ "//flutter/vulkan" ]
265-
}
266-
267-
if (darwin_extension_safe) {
268-
defines = [ "APPLICATION_EXTENSION_API_ONLY=1" ]
269-
}
270-
}
271-
272225
shared_library("ios_test_flutter") {
273226
testonly = true
274227
visibility = [ "*" ]
@@ -299,29 +252,35 @@ shared_library("ios_test_flutter") {
299252
"framework/Source/FlutterDartProjectTest.mm",
300253
"framework/Source/FlutterEmbedderKeyResponderTest.mm",
301254
"framework/Source/FlutterEngineGroupTest.mm",
255+
"framework/Source/FlutterEnginePlatformViewTest.mm",
302256
"framework/Source/FlutterEngineTest.mm",
303257
"framework/Source/FlutterFakeKeyEvents.h",
304258
"framework/Source/FlutterFakeKeyEvents.mm",
305259
"framework/Source/FlutterKeyboardManagerTest.mm",
306260
"framework/Source/FlutterPlatformPluginTest.mm",
261+
"framework/Source/FlutterPlatformViewsTest.mm",
307262
"framework/Source/FlutterPluginAppLifeCycleDelegateTest.mm",
308263
"framework/Source/FlutterRestorationPluginTest.mm",
309264
"framework/Source/FlutterSpellCheckPluginTest.mm",
310265
"framework/Source/FlutterTextInputPluginTest.mm",
311266
"framework/Source/FlutterTextureRegistryRelayTest.mm",
267+
"framework/Source/FlutterTouchInterceptingView_Test.h",
312268
"framework/Source/FlutterUndoManagerPluginTest.mm",
313269
"framework/Source/FlutterViewControllerTest.mm",
270+
"framework/Source/FlutterViewTest.mm",
314271
"framework/Source/SemanticsObjectTest.mm",
272+
"framework/Source/SemanticsObjectTestMocks.h",
315273
"framework/Source/UIViewController_FlutterScreenAndSceneIfLoadedTest.mm",
316274
"framework/Source/VsyncWaiterIosTest.mm",
275+
"framework/Source/accessibility_bridge_test.mm",
317276
"framework/Source/connection_collection_test.mm",
277+
"platform_message_handler_ios_test.mm",
318278
]
319279
deps = [
320280
":flutter_framework",
321281
":flutter_framework_source",
322282
":flutter_framework_source_arc",
323283
":ios_gpu_configuration",
324-
":ios_test_flutter_mrc",
325284
"//flutter/common:common",
326285
"//flutter/lib/ui:ui",
327286
"//flutter/shell/platform/darwin/common:framework_common",

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
#import "flutter/shell/platform/darwin/ios/framework/Source/FlutterEngine_Internal.h"
1414
#import "flutter/shell/platform/darwin/ios/platform_view_ios.h"
1515

16-
FLUTTER_ASSERT_NOT_ARC
16+
FLUTTER_ASSERT_ARC
1717

1818
namespace flutter {
1919
namespace {

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

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,25 @@
1313
#import "flutter/shell/platform/darwin/common/framework/Headers/FlutterMacros.h"
1414
#import "flutter/shell/platform/darwin/common/framework/Source/FlutterBinaryMessengerRelay.h"
1515
#import "flutter/shell/platform/darwin/ios/framework/Source/FlutterDartProject_Internal.h"
16+
#import "flutter/shell/platform/darwin/ios/framework/Source/FlutterEngine_Internal.h"
1617
#import "flutter/shell/platform/darwin/ios/framework/Source/FlutterEngine_Test.h"
1718
#import "flutter/shell/platform/darwin/ios/framework/Source/FlutterTextInputPlugin.h"
19+
#import "flutter/shell/platform/darwin/ios/platform_view_ios.h"
1820

1921
FLUTTER_ASSERT_ARC
2022

23+
@interface FlutterEngineSpy : FlutterEngine
24+
@property(nonatomic) BOOL ensureSemanticsEnabledCalled;
25+
@end
26+
27+
@implementation FlutterEngineSpy
28+
29+
- (void)ensureSemanticsEnabled {
30+
_ensureSemanticsEnabledCalled = YES;
31+
}
32+
33+
@end
34+
2135
@interface FlutterEngine () <FlutterTextInputDelegate>
2236

2337
@end
@@ -430,4 +444,30 @@ - (void)testLifeCycleNotificationWillEnterForeground {
430444
XCTAssertFalse(switch_value);
431445
}
432446

447+
- (void)testSpawnsShareGpuContext {
448+
FlutterEngine* engine = [[FlutterEngine alloc] initWithName:@"foobar"];
449+
[engine run];
450+
FlutterEngine* spawn = [engine spawnWithEntrypoint:nil
451+
libraryURI:nil
452+
initialRoute:nil
453+
entrypointArgs:nil];
454+
XCTAssertNotNil(spawn);
455+
XCTAssertTrue([engine iosPlatformView] != nullptr);
456+
XCTAssertTrue([spawn iosPlatformView] != nullptr);
457+
std::shared_ptr<flutter::IOSContext> engine_context = [engine iosPlatformView]->GetIosContext();
458+
std::shared_ptr<flutter::IOSContext> spawn_context = [spawn iosPlatformView]->GetIosContext();
459+
XCTAssertEqual(engine_context, spawn_context);
460+
// If this assert fails it means we may be using the software. For software rendering, this is
461+
// expected to be nullptr.
462+
XCTAssertTrue(engine_context->GetMainContext() != nullptr);
463+
XCTAssertEqual(engine_context->GetMainContext(), spawn_context->GetMainContext());
464+
}
465+
466+
- (void)testEnableSemanticsWhenFlutterViewAccessibilityDidCall {
467+
FlutterEngineSpy* engine = [[FlutterEngineSpy alloc] initWithName:@"foobar"];
468+
engine.ensureSemanticsEnabledCalled = NO;
469+
[engine flutterViewAccessibilityDidCall];
470+
XCTAssertTrue(engine.ensureSemanticsEnabledCalled);
471+
}
472+
433473
@end

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

Lines changed: 0 additions & 66 deletions
This file was deleted.

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ static bool ClipRRectContainsPlatformViewBoundingRect(const SkRRect& clip_rrect,
173173
return flutter_view_controller_.get();
174174
}
175175

176-
void FlutterPlatformViewsController::OnMethodCall(FlutterMethodCall* call, FlutterResult& result) {
176+
void FlutterPlatformViewsController::OnMethodCall(FlutterMethodCall* call, FlutterResult result) {
177177
if ([[call method] isEqualToString:@"create"]) {
178178
OnCreate(call, result);
179179
} else if ([[call method] isEqualToString:@"dispose"]) {
@@ -187,7 +187,7 @@ static bool ClipRRectContainsPlatformViewBoundingRect(const SkRRect& clip_rrect,
187187
}
188188
}
189189

190-
void FlutterPlatformViewsController::OnCreate(FlutterMethodCall* call, FlutterResult& result) {
190+
void FlutterPlatformViewsController::OnCreate(FlutterMethodCall* call, FlutterResult result) {
191191
NSDictionary<NSString*, id>* args = [call arguments];
192192

193193
int64_t viewId = [args[@"id"] longLongValue];
@@ -252,7 +252,7 @@ static bool ClipRRectContainsPlatformViewBoundingRect(const SkRRect& clip_rrect,
252252
result(nil);
253253
}
254254

255-
void FlutterPlatformViewsController::OnDispose(FlutterMethodCall* call, FlutterResult& result) {
255+
void FlutterPlatformViewsController::OnDispose(FlutterMethodCall* call, FlutterResult result) {
256256
NSNumber* arg = [call arguments];
257257
int64_t viewId = [arg longLongValue];
258258

@@ -268,7 +268,7 @@ static bool ClipRRectContainsPlatformViewBoundingRect(const SkRRect& clip_rrect,
268268
}
269269

270270
void FlutterPlatformViewsController::OnAcceptGesture(FlutterMethodCall* call,
271-
FlutterResult& result) {
271+
FlutterResult result) {
272272
NSDictionary<NSString*, id>* args = [call arguments];
273273
int64_t viewId = [args[@"id"] longLongValue];
274274

@@ -286,7 +286,7 @@ static bool ClipRRectContainsPlatformViewBoundingRect(const SkRRect& clip_rrect,
286286
}
287287

288288
void FlutterPlatformViewsController::OnRejectGesture(FlutterMethodCall* call,
289-
FlutterResult& result) {
289+
FlutterResult result) {
290290
NSDictionary<NSString*, id>* args = [call arguments];
291291
int64_t viewId = [args[@"id"] longLongValue];
292292

0 commit comments

Comments
 (0)