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

Support accessibility back gesture to pop route from view controller #51241

Merged
merged 3 commits into from
Mar 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2104,6 +2104,15 @@ - (int32_t)accessibilityFlags {
return flags;
}

- (BOOL)accessibilityPerformEscape {
FlutterMethodChannel* navigationChannel = [_engine.get() navigationChannel];
if (navigationChannel) {
[self popRoute];
return YES;
}
return NO;
}

+ (BOOL)accessibilityIsOnOffSwitchLabelsEnabled {
if (@available(iOS 13, *)) {
return UIAccessibilityIsOnOffSwitchLabelsEnabled();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1365,6 +1365,22 @@ - (void)testItReportsAccessibilityOnOffSwitchLabelsFlagSet {
XCTAssert((flags & (int32_t)flutter::AccessibilityFeatureFlag::kOnOffSwitchLabels) != 0);
}

- (void)testAccessibilityPerformEscapePopsRoute {
FlutterEngine* mockEngine = OCMPartialMock([[FlutterEngine alloc] init]);
[mockEngine createShell:@"" libraryURI:@"" initialRoute:nil];
id mockNavigationChannel = OCMClassMock([FlutterMethodChannel class]);
OCMStub([mockEngine navigationChannel]).andReturn(mockNavigationChannel);

FlutterViewController* viewController = [[FlutterViewController alloc] initWithEngine:mockEngine
nibName:nil
bundle:nil];
XCTAssertTrue([viewController accessibilityPerformEscape]);

OCMVerify([mockNavigationChannel invokeMethod:@"popRoute" arguments:nil]);

[mockNavigationChannel stopMocking];
}

- (void)testPerformOrientationUpdateForcesOrientationChange {
[self orientationTestWithOrientationUpdate:UIInterfaceOrientationMaskPortrait
currentOrientation:UIInterfaceOrientationLandscapeLeft
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@
0AC232F724BA71D300A85907 /* FlutterEngineTest.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = FlutterEngineTest.mm; sourceTree = "<group>"; };
0AC2330324BA71D300A85907 /* accessibility_bridge_test.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = accessibility_bridge_test.mm; sourceTree = "<group>"; };
0AC2330B24BA71D300A85907 /* FlutterTextInputPluginTest.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = FlutterTextInputPluginTest.mm; sourceTree = "<group>"; };
0AC2330F24BA71D300A85907 /* FlutterBinaryMessengerRelayTest.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = FlutterBinaryMessengerRelayTest.mm; sourceTree = "<group>"; };
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FlutterBinaryMessengerRelayTest is no longer in the iOS directory and is tested in common #44395

0AC2331024BA71D300A85907 /* connection_collection_test.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = connection_collection_test.mm; sourceTree = "<group>"; };
0AC2331224BA71D300A85907 /* FlutterEnginePlatformViewTest.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = FlutterEnginePlatformViewTest.mm; sourceTree = "<group>"; };
0AC2331924BA71D300A85907 /* FlutterPluginAppLifeCycleDelegateTest.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = FlutterPluginAppLifeCycleDelegateTest.mm; sourceTree = "<group>"; };
Expand All @@ -72,7 +71,6 @@
3DD7D38C27D2B81000DA365C /* FlutterUndoManagerPluginTest.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = FlutterUndoManagerPluginTest.mm; sourceTree = "<group>"; };
689EC1E2281B30D3008FEB58 /* FlutterSpellCheckPluginTest.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = FlutterSpellCheckPluginTest.mm; sourceTree = "<group>"; };
68B6091227F62F990036AC78 /* VsyncWaiterIosTest.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = VsyncWaiterIosTest.mm; sourceTree = "<group>"; };
73F12C22288F92FF00AFC3A6 /* FlutterViewControllerTest_mrc.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = FlutterViewControllerTest_mrc.mm; sourceTree = "<group>"; };
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed in #48162

D2D361A52B234EAC0018964E /* FlutterMetalLayerTest.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = FlutterMetalLayerTest.mm; sourceTree = "<group>"; };
F7521D7226BB671E005F15C5 /* libios_test_flutter.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libios_test_flutter.dylib; path = "../../../../out/$(FLUTTER_ENGINE)/libios_test_flutter.dylib"; sourceTree = "<group>"; };
F7521D7526BB673E005F15C5 /* libocmock_shared.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libocmock_shared.dylib; path = "../../../../out/$(FLUTTER_ENGINE)/libocmock_shared.dylib"; sourceTree = "<group>"; };
Expand Down Expand Up @@ -109,12 +107,10 @@
0AC232F724BA71D300A85907 /* FlutterEngineTest.mm */,
0AC2330324BA71D300A85907 /* accessibility_bridge_test.mm */,
0AC2330B24BA71D300A85907 /* FlutterTextInputPluginTest.mm */,
0AC2330F24BA71D300A85907 /* FlutterBinaryMessengerRelayTest.mm */,
0AC2331024BA71D300A85907 /* connection_collection_test.mm */,
0AC2331224BA71D300A85907 /* FlutterEnginePlatformViewTest.mm */,
0AC2331924BA71D300A85907 /* FlutterPluginAppLifeCycleDelegateTest.mm */,
0AC2332124BA71D300A85907 /* FlutterViewControllerTest.mm */,
73F12C22288F92FF00AFC3A6 /* FlutterViewControllerTest_mrc.mm */,
D2D361A52B234EAC0018964E /* FlutterMetalLayerTest.mm */,
);
name = Source;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
FLUTTER_ENGINE[arch=x86_64]=ios_debug_sim_unopt
FLUTTER_ENGINE[arch=arm64]=ios_debug_sim_unopt_arm64
FLUTTER_ENGINE=ios_debug_sim_unopt
FLUTTER_ENGINE=ios_debug_sim_unopt_arm64
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are more folks running these tests on ARM Macs now than x64.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does the previous 2 line do anything? is it supposed to pick the right engine based on which mac you are running on?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The previous two lines were my attempt at picking the right engine for you #39213, but it doesn't work because at one of the point it's used the ARCH is unknown 😞