Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Chris Yang committed Aug 1, 2023
1 parent 1473eb1 commit c1d3fd0
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 49 deletions.
28 changes: 4 additions & 24 deletions shell/platform/darwin/ios/framework/Source/SemanticsObject.mm
Original file line number Diff line number Diff line change
Expand Up @@ -93,12 +93,6 @@ CGRect ConvertRectToGlobal(SemanticsObject* reference, CGRect local_rect) {

} // namespace

@interface NSObject (FlutterSemantics)

- (id)_accessibilityHitTest:(CGPoint)point withEvent:(UIEvent*)event;

@end

@interface FlutterSwitchSemanticsObject ()
@property(nonatomic, readonly) UISwitch* nativeSwitch;
@end
Expand Down Expand Up @@ -578,13 +572,7 @@ - (id)search:(CGPoint)point {
// IOS 16. Overrides this method to focus the first eligiable semantics
// object in hit test order.
- (id)_accessibilityHitTest:(CGPoint)point withEvent:(UIEvent*)event {
id hittest = [self search:point];
if (![hittest isKindOfClass:[SemanticsObject class]]) {
// If hittest result is not a SemanticsObject (e.g. PlatformView),
// call the default hittest method to find the hittest result inside the "hittest".
return [(NSObject*)hittest _accessibilityHitTest:point withEvent:event];
}
return hittest;
return [self search:point];
}

// iOS calls this method when this item is swipe-to-focusd in VoiceOver.
Expand Down Expand Up @@ -890,17 +878,9 @@ - (void)dealloc {
[super dealloc];
}

- (id)nativeAccessibility {
return _platformView;
}

- (id)_accessibilityHitTest:(CGPoint)point withEvent:(UIEvent*)event {
return [_platformView _accessibilityHitTest:point withEvent:event];
}

- (BOOL)isFocusable {
return YES;
}
// - (id)nativeAccessibility {
// return _platformView;
// }

- (BOOL)isAccessibilityElement {
return NO;
Expand Down
28 changes: 3 additions & 25 deletions shell/platform/darwin/ios/framework/Source/SemanticsObjectTest.mm
Original file line number Diff line number Diff line change
Expand Up @@ -89,23 +89,6 @@ void AccessibilityObjectDidLoseFocus(int32_t id) override {}
} // namespace
} // namespace flutter

@interface FakePlatformView : UIView

@property(nonatomic, strong, readonly) UIView* subview;

@end

@implementation FakePlatformView

- (id)_accessibilityHitTest:(CGPoint)point withEvent:(UIEvent*)event {
if (_subview) {
_subview = [[UIView alloc] init];
}
return _subview;
}

@end

@interface SemanticsObjectTest : XCTestCase
@end

Expand Down Expand Up @@ -220,15 +203,14 @@ - (void)testAccessibilityHitTestNoFocusableItem {
XCTAssertNil(hitTestResult);
}

- (void)testAccessibilityHitTestSearchPlatformViewSubtree {
- (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];
FakePlatformView* platformView =
[[FakePlatformView alloc] initWithFrame:CGRectMake(0, 0, 100, 100)];
UIView* platformView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 100, 100)];
FlutterPlatformViewSemanticsContainer* platformViewSemanticsContainer =
[[FlutterPlatformViewSemanticsContainer alloc] initWithBridge:bridge
uid:1
Expand Down Expand Up @@ -264,13 +246,9 @@ - (void)testAccessibilityHitTestSearchPlatformViewSubtree {
[object3 setSemanticsNode:&node3];

CGPoint point = CGPointMake(10, 10);
// id partialMockPlatformView = OCMPartialMock(platformView);
// OCMStub([partialMockPlatformView _accessibilityHitTest:point
// withEvent:nil]).andReturn(subView);
id hitTestResult = [object0 _accessibilityHitTest:point withEvent:nil];

// Focus to object2 because it's the first object in hit test order
XCTAssertEqual(hitTestResult, platformView.subview);
XCTAssertEqual(hitTestResult, platformView);
}

- (void)testAccessibilityScrollToVisible {
Expand Down

0 comments on commit c1d3fd0

Please sign in to comment.