5 #import <OCMock/OCMock.h>
6 #import <XCTest/XCTest.h>
24 UIFocusItemScrollableContainer>
37 fml::WeakPtrFactory<flutter::AccessibilityBridgeIos> factory(
39 fml::WeakPtr<flutter::AccessibilityBridgeIos> bridge = factory.GetWeakPtr();
41 XCTAssertNotNil(
object);
44 - (void)testUIFocusSystemMethodsDoNotCrashWhenBridgeIsDead {
45 fml::WeakPtr<flutter::AccessibilityBridgeIos> bridge;
48 auto mock_bridge = std::make_unique<flutter::testing::MockAccessibilityBridge>();
49 fml::WeakPtrFactory<flutter::AccessibilityBridgeIos> factory(mock_bridge.get());
50 bridge = factory.GetWeakPtr();
55 XCTAssertNil([
object parentFocusEnvironment]);
56 XCTAssertNil([
object coordinateSpace]);
57 XCTAssertTrue(CGRectEqualToRect([
object frame], CGRectZero));
60 - (void)testSetChildren {
61 fml::WeakPtrFactory<flutter::AccessibilityBridgeIos> factory(
63 fml::WeakPtr<flutter::AccessibilityBridgeIos> bridge = factory.GetWeakPtr();
67 XCTAssertEqual(parent, child.
parent);
69 XCTAssertNil(child.
parent);
72 - (void)testOldParentDoesNotDetachReparentedChild {
73 fml::WeakPtrFactory<flutter::AccessibilityBridgeIos> factory(
75 fml::WeakPtr<flutter::AccessibilityBridgeIos> bridge = factory.GetWeakPtr();
88 XCTAssertEqual(child.
parent, newParent);
91 - (void)testSetChildrenInHitTestOrderDoesNotModifyParent {
92 fml::WeakPtrFactory<flutter::AccessibilityBridgeIos> factory(
94 fml::WeakPtr<flutter::AccessibilityBridgeIos> bridge = factory.GetWeakPtr();
99 traversalParent.
children = @[ child ];
100 XCTAssertEqual(child.
parent, traversalParent);
103 XCTAssertEqual(child.
parent, traversalParent);
106 XCTAssertEqual(child.
parent, traversalParent);
109 - (void)testAccessibilityHitTestFocusAtLeaf {
110 fml::WeakPtrFactory<flutter::AccessibilityBridgeIos> factory(
112 fml::WeakPtr<flutter::AccessibilityBridgeIos> bridge = factory.GetWeakPtr();
119 object1.
children = @[ object2, object3 ];
122 flutter::SemanticsNode node0;
124 node0.rect = SkRect::MakeXYWH(0, 0, 200, 200);
128 flutter::SemanticsNode node1;
130 node1.rect = SkRect::MakeXYWH(0, 0, 200, 200);
134 flutter::SemanticsNode node2;
136 node2.rect = SkRect::MakeXYWH(0, 0, 100, 100);
140 flutter::SemanticsNode node3;
142 node3.rect = SkRect::MakeXYWH(0, 0, 200, 200);
146 CGPoint point = CGPointMake(10, 10);
150 XCTAssertEqual(hitTestResult, object2);
153 - (void)testAccessibilityHitTestNoFocusableItem {
154 fml::WeakPtrFactory<flutter::AccessibilityBridgeIos> factory(
156 fml::WeakPtr<flutter::AccessibilityBridgeIos> bridge = factory.GetWeakPtr();
163 object1.
children = @[ object2, object3 ];
166 flutter::SemanticsNode node0;
168 node0.rect = SkRect::MakeXYWH(0, 0, 200, 200);
171 flutter::SemanticsNode node1;
173 node1.rect = SkRect::MakeXYWH(0, 0, 200, 200);
176 flutter::SemanticsNode node2;
178 node2.rect = SkRect::MakeXYWH(0, 0, 100, 100);
181 flutter::SemanticsNode node3;
183 node3.rect = SkRect::MakeXYWH(0, 0, 200, 200);
186 CGPoint point = CGPointMake(10, 10);
189 XCTAssertNil(hitTestResult);
192 - (void)testAccessibilityScrollToVisible {
193 fml::WeakPtrFactory<flutter::testing::MockAccessibilityBridge> factory(
195 fml::WeakPtr<flutter::testing::MockAccessibilityBridge> bridge = factory.GetWeakPtr();
198 flutter::SemanticsNode node3;
200 node3.rect = SkRect::MakeXYWH(0, 0, 200, 200);
205 XCTAssertTrue(bridge->observations.size() == 1);
206 XCTAssertTrue(bridge->observations[0].id == 3);
207 XCTAssertTrue(bridge->observations[0].action == flutter::SemanticsAction::kShowOnScreen);
210 - (void)testFlutterScrollableSemanticsObjectIsNotAccessibilityElementWhenVoiceOverIsRunning {
213 fml::WeakPtrFactory<flutter::AccessibilityBridgeIos> factory(mock);
214 fml::WeakPtr<flutter::AccessibilityBridgeIos> bridge = factory.GetWeakPtr();
216 flutter::SemanticsNode node;
217 node.flags.hasImplicitScrolling =
true;
219 node.actions = flutter::kHorizontalScrollSemanticsActions |
220 static_cast<int32_t
>(flutter::SemanticsAction::kCustomAction);
222 node.rect = SkRect::MakeXYWH(0, 0, 100, 200);
223 node.scrollExtentMax = 100.0;
224 node.scrollPosition = 0.0;
233 XCTAssertFalse(scrollView.isAccessibilityElement);
236 - (void)testAccessibilityScrollToVisibleWithChild {
237 fml::WeakPtrFactory<flutter::testing::MockAccessibilityBridge> factory(
239 fml::WeakPtr<flutter::testing::MockAccessibilityBridge> bridge = factory.GetWeakPtr();
242 flutter::SemanticsNode node3;
244 node3.rect = SkRect::MakeXYWH(0, 0, 200, 200);
249 XCTAssertTrue(bridge->observations.size() == 1);
250 XCTAssertTrue(bridge->observations[0].id == 3);
251 XCTAssertTrue(bridge->observations[0].action == flutter::SemanticsAction::kShowOnScreen);
254 - (void)testAccessibilityHitTestOutOfRect {
255 fml::WeakPtrFactory<flutter::AccessibilityBridgeIos> factory(
257 fml::WeakPtr<flutter::AccessibilityBridgeIos> bridge = factory.GetWeakPtr();
264 object1.
children = @[ object2, object3 ];
267 flutter::SemanticsNode node0;
269 node0.rect = SkRect::MakeXYWH(0, 0, 200, 200);
273 flutter::SemanticsNode node1;
275 node1.rect = SkRect::MakeXYWH(0, 0, 200, 200);
279 flutter::SemanticsNode node2;
281 node2.rect = SkRect::MakeXYWH(0, 0, 100, 100);
285 flutter::SemanticsNode node3;
287 node3.rect = SkRect::MakeXYWH(0, 0, 200, 200);
291 CGPoint point = CGPointMake(300, 300);
294 XCTAssertNil(hitTestResult);
297 - (void)testReplaceChildAtIndex {
298 fml::WeakPtrFactory<flutter::AccessibilityBridgeIos> factory(
300 fml::WeakPtr<flutter::AccessibilityBridgeIos> bridge = factory.GetWeakPtr();
306 XCTAssertNil(child1.
parent);
307 XCTAssertEqual(parent, child2.
parent);
308 XCTAssertEqualObjects(parent.
children, @[ child2 ]);
311 - (void)testPlainSemanticsObjectWithLabelHasStaticTextTrait {
312 fml::WeakPtrFactory<flutter::AccessibilityBridgeIos> factory(
314 fml::WeakPtr<flutter::AccessibilityBridgeIos> bridge = factory.GetWeakPtr();
315 flutter::SemanticsNode node;
319 XCTAssertEqual([
object accessibilityTraits], UIAccessibilityTraitStaticText);
322 - (void)testPlainSemanticsObjectWithHeadingLevelHasHeaderTrait {
323 fml::WeakPtrFactory<flutter::AccessibilityBridgeIos> factory(
325 fml::WeakPtr<flutter::AccessibilityBridgeIos> bridge = factory.GetWeakPtr();
326 flutter::SemanticsNode node;
327 node.headingLevel = 2;
330 XCTAssertTrue(([
object accessibilityTraits] & UIAccessibilityTraitHeader) > 0);
333 - (void)testNodeWithImplicitScrollIsAnAccessibilityElementWhenItisHidden {
334 fml::WeakPtrFactory<flutter::AccessibilityBridgeIos> factory(
336 fml::WeakPtr<flutter::AccessibilityBridgeIos> bridge = factory.GetWeakPtr();
337 flutter::SemanticsNode node;
339 node.flags.hasImplicitScrolling =
true;
340 node.flags.isHidden =
true;
343 XCTAssertEqual(
object.isAccessibilityElement, YES);
346 - (void)testNodeWithImplicitScrollIsNotAnAccessibilityElementWhenItisNotHidden {
347 fml::WeakPtrFactory<flutter::AccessibilityBridgeIos> factory(
349 fml::WeakPtr<flutter::AccessibilityBridgeIos> bridge = factory.GetWeakPtr();
350 flutter::SemanticsNode node;
351 node.flags.hasImplicitScrolling =
true;
354 XCTAssertEqual(
object.isAccessibilityElement, NO);
357 - (void)testIntresetingSemanticsObjectWithLabelHasStaticTextTrait {
358 fml::WeakPtrFactory<flutter::AccessibilityBridgeIos> factory(
360 fml::WeakPtr<flutter::AccessibilityBridgeIos> bridge = factory.GetWeakPtr();
361 flutter::SemanticsNode node;
367 XCTAssertEqual([
object accessibilityTraits], UIAccessibilityTraitNone);
370 - (void)testIntresetingSemanticsObjectWithLabelHasStaticTextTrait1 {
371 fml::WeakPtrFactory<flutter::AccessibilityBridgeIos> factory(
373 fml::WeakPtr<flutter::AccessibilityBridgeIos> bridge = factory.GetWeakPtr();
374 flutter::SemanticsNode node;
376 node.flags.isTextField =
true;
379 XCTAssertEqual([
object accessibilityTraits], UIAccessibilityTraitNone);
382 - (void)testIntresetingSemanticsObjectWithLabelHasStaticTextTrait2 {
383 fml::WeakPtrFactory<flutter::AccessibilityBridgeIos> factory(
385 fml::WeakPtr<flutter::AccessibilityBridgeIos> bridge = factory.GetWeakPtr();
386 flutter::SemanticsNode node;
389 node.flags.isButton =
true;
392 XCTAssertEqual([
object accessibilityTraits], UIAccessibilityTraitButton);
395 - (void)testVerticalFlutterScrollableSemanticsObject {
396 fml::WeakPtrFactory<flutter::AccessibilityBridgeIos> factory(
398 fml::WeakPtr<flutter::AccessibilityBridgeIos> bridge = factory.GetWeakPtr();
400 float transformScale = 0.5f;
401 float screenScale = [[bridge->view() window] screen].scale;
402 float effectivelyScale = transformScale / screenScale;
407 float scrollExtentMax = 500.0;
408 float scrollPosition = 150.0;
410 flutter::SemanticsNode node;
411 node.flags.hasImplicitScrolling =
true;
412 node.actions = flutter::kVerticalScrollSemanticsActions;
413 node.rect = SkRect::MakeXYWH(x, y, w, h);
414 node.scrollExtentMax = scrollExtentMax;
415 node.scrollPosition = scrollPosition;
417 transformScale, 0, 0, 0, 0, transformScale, 0, 0, 0, 0, transformScale, 0, 0, 0, 0, 1.0};
424 XCTAssertEqualWithAccuracy(scrollView.frame.origin.x, x * effectivelyScale,
kFloatCompareEpsilon);
425 XCTAssertEqualWithAccuracy(scrollView.frame.origin.y, y * effectivelyScale,
kFloatCompareEpsilon);
426 XCTAssertEqualWithAccuracy(scrollView.frame.size.width, w * effectivelyScale,
428 XCTAssertEqualWithAccuracy(scrollView.frame.size.height, h * effectivelyScale,
431 XCTAssertEqualWithAccuracy(scrollView.contentSize.width, w * effectivelyScale,
433 XCTAssertEqualWithAccuracy(scrollView.contentSize.height,
436 XCTAssertEqual(scrollView.contentOffset.x, 0);
437 XCTAssertEqualWithAccuracy(scrollView.contentOffset.y, scrollPosition * effectivelyScale,
441 - (void)testVerticalFlutterScrollableSemanticsObjectNoWindowDoesNotCrash {
442 fml::WeakPtrFactory<flutter::AccessibilityBridgeIos> factory(
444 fml::WeakPtr<flutter::AccessibilityBridgeIos> bridge = factory.GetWeakPtr();
446 float transformScale = 0.5f;
451 float scrollExtentMax = 500.0;
452 float scrollPosition = 150.0;
454 flutter::SemanticsNode node;
455 node.flags.hasImplicitScrolling =
true;
456 node.actions = flutter::kVerticalScrollSemanticsActions;
457 node.rect = SkRect::MakeXYWH(x, y, w, h);
458 node.scrollExtentMax = scrollExtentMax;
459 node.scrollPosition = scrollPosition;
461 transformScale, 0, 0, 0, 0, transformScale, 0, 0, 0, 0, transformScale, 0, 0, 0, 0, 1.0};
466 XCTAssertNoThrow([scrollable accessibilityBridgeDidFinishUpdate]);
469 - (void)testHorizontalFlutterScrollableSemanticsObject {
470 fml::WeakPtrFactory<flutter::AccessibilityBridgeIos> factory(
472 fml::WeakPtr<flutter::AccessibilityBridgeIos> bridge = factory.GetWeakPtr();
474 float transformScale = 0.5f;
475 float screenScale = [[bridge->view() window] screen].scale;
476 float effectivelyScale = transformScale / screenScale;
481 float scrollExtentMax = 500.0;
482 float scrollPosition = 150.0;
484 flutter::SemanticsNode node;
485 node.flags.hasImplicitScrolling =
true;
486 node.actions = flutter::kHorizontalScrollSemanticsActions;
487 node.rect = SkRect::MakeXYWH(x, y, w, h);
488 node.scrollExtentMax = scrollExtentMax;
489 node.scrollPosition = scrollPosition;
491 transformScale, 0, 0, 0, 0, transformScale, 0, 0, 0, 0, transformScale, 0, 0, 0, 0, 1.0};
498 XCTAssertEqualWithAccuracy(scrollView.frame.origin.x, x * effectivelyScale,
kFloatCompareEpsilon);
499 XCTAssertEqualWithAccuracy(scrollView.frame.origin.y, y * effectivelyScale,
kFloatCompareEpsilon);
500 XCTAssertEqualWithAccuracy(scrollView.frame.size.width, w * effectivelyScale,
502 XCTAssertEqualWithAccuracy(scrollView.frame.size.height, h * effectivelyScale,
505 XCTAssertEqualWithAccuracy(scrollView.contentSize.width, (w + scrollExtentMax) * effectivelyScale,
507 XCTAssertEqualWithAccuracy(scrollView.contentSize.height, h * effectivelyScale,
510 XCTAssertEqualWithAccuracy(scrollView.contentOffset.x, scrollPosition * effectivelyScale,
512 XCTAssertEqual(scrollView.contentOffset.y, 0);
515 - (void)testCanHandleInfiniteScrollExtent {
516 fml::WeakPtrFactory<flutter::AccessibilityBridgeIos> factory(
518 fml::WeakPtr<flutter::AccessibilityBridgeIos> bridge = factory.GetWeakPtr();
520 float transformScale = 0.5f;
521 float screenScale = [[bridge->view() window] screen].scale;
522 float effectivelyScale = transformScale / screenScale;
527 float scrollExtentMax = INFINITY;
528 float scrollPosition = 150.0;
530 flutter::SemanticsNode node;
531 node.flags.hasImplicitScrolling =
true;
532 node.actions = flutter::kVerticalScrollSemanticsActions;
533 node.rect = SkRect::MakeXYWH(x, y, w, h);
534 node.scrollExtentMax = scrollExtentMax;
535 node.scrollPosition = scrollPosition;
537 transformScale, 0, 0, 0, 0, transformScale, 0, 0, 0, 0, transformScale, 0, 0, 0, 0, 1.0};
543 XCTAssertEqualWithAccuracy(scrollView.frame.origin.x, x * effectivelyScale,
kFloatCompareEpsilon);
544 XCTAssertEqualWithAccuracy(scrollView.frame.origin.y, y * effectivelyScale,
kFloatCompareEpsilon);
545 XCTAssertEqualWithAccuracy(scrollView.frame.size.width, w * effectivelyScale,
547 XCTAssertEqualWithAccuracy(scrollView.frame.size.height, h * effectivelyScale,
550 XCTAssertEqualWithAccuracy(scrollView.contentSize.width, w * effectivelyScale,
552 XCTAssertEqualWithAccuracy(scrollView.contentSize.height,
556 XCTAssertEqual(scrollView.contentOffset.x, 0);
557 XCTAssertEqualWithAccuracy(scrollView.contentOffset.y, scrollPosition * effectivelyScale,
561 - (void)testCanHandleNaNScrollExtentAndScrollPoisition {
562 fml::WeakPtrFactory<flutter::AccessibilityBridgeIos> factory(
564 fml::WeakPtr<flutter::AccessibilityBridgeIos> bridge = factory.GetWeakPtr();
566 float transformScale = 0.5f;
567 float screenScale = [[bridge->view() window] screen].scale;
568 float effectivelyScale = transformScale / screenScale;
573 float scrollExtentMax = std::nan(
"");
574 float scrollPosition = std::nan(
"");
576 flutter::SemanticsNode node;
577 node.flags.hasImplicitScrolling =
true;
578 node.actions = flutter::kVerticalScrollSemanticsActions;
579 node.rect = SkRect::MakeXYWH(x, y, w, h);
580 node.scrollExtentMax = scrollExtentMax;
581 node.scrollPosition = scrollPosition;
583 transformScale, 0, 0, 0, 0, transformScale, 0, 0, 0, 0, transformScale, 0, 0, 0, 0, 1.0};
590 XCTAssertEqualWithAccuracy(scrollView.frame.origin.x, x * effectivelyScale,
kFloatCompareEpsilon);
591 XCTAssertEqualWithAccuracy(scrollView.frame.origin.y, y * effectivelyScale,
kFloatCompareEpsilon);
592 XCTAssertEqualWithAccuracy(scrollView.frame.size.width, w * effectivelyScale,
594 XCTAssertEqualWithAccuracy(scrollView.frame.size.height, h * effectivelyScale,
598 XCTAssertEqualWithAccuracy(scrollView.contentSize.width, w * effectivelyScale,
600 XCTAssertEqualWithAccuracy(scrollView.contentSize.height, h * effectivelyScale,
603 XCTAssertEqual(scrollView.contentOffset.x, 0);
604 XCTAssertEqual(scrollView.contentOffset.y, 0);
607 - (void)testFlutterScrollableSemanticsObjectIsNotHittestable {
608 fml::WeakPtrFactory<flutter::AccessibilityBridgeIos> factory(
610 fml::WeakPtr<flutter::AccessibilityBridgeIos> bridge = factory.GetWeakPtr();
612 flutter::SemanticsNode node;
613 node.flags.hasImplicitScrolling =
true;
614 node.actions = flutter::kHorizontalScrollSemanticsActions;
615 node.rect = SkRect::MakeXYWH(0, 0, 100, 200);
616 node.scrollExtentMax = 100.0;
617 node.scrollPosition = 0.0;
624 XCTAssertEqual([scrollView hitTest:CGPointMake(10, 10) withEvent:nil], nil);
627 - (void)testFlutterScrollableSemanticsObjectIsHiddenWhenVoiceOverIsRunning {
630 fml::WeakPtrFactory<flutter::AccessibilityBridgeIos> factory(mock);
631 fml::WeakPtr<flutter::AccessibilityBridgeIos> bridge = factory.GetWeakPtr();
633 flutter::SemanticsNode node;
634 node.flags.hasImplicitScrolling =
true;
635 node.actions = flutter::kHorizontalScrollSemanticsActions;
636 node.rect = SkRect::MakeXYWH(0, 0, 100, 200);
637 node.scrollExtentMax = 100.0;
638 node.scrollPosition = 0.0;
645 XCTAssertTrue(scrollView.isAccessibilityElement);
647 XCTAssertFalse(scrollView.isAccessibilityElement);
650 - (void)testFlutterSemanticsObjectHasIdentifier {
653 fml::WeakPtrFactory<flutter::AccessibilityBridgeIos> factory(mock);
654 fml::WeakPtr<flutter::AccessibilityBridgeIos> bridge = factory.GetWeakPtr();
656 flutter::SemanticsNode node;
657 node.identifier =
"identifier";
661 XCTAssertTrue([
object.accessibilityIdentifier isEqualToString:
@"identifier"]);
664 - (void)testFlutterSemanticsObjectHasLocale {
667 fml::WeakPtrFactory<flutter::AccessibilityBridgeIos> factory(mock);
668 fml::WeakPtr<flutter::AccessibilityBridgeIos> bridge = factory.GetWeakPtr();
670 flutter::SemanticsNode node;
671 node.locale =
"es-MX";
675 XCTAssertTrue([
object.accessibilityLanguage isEqualToString:
@"es-MX"]);
678 - (void)testFlutterSemanticsObjectUseDefaultLocale {
681 fml::WeakPtrFactory<flutter::AccessibilityBridgeIos> factory(mock);
682 fml::WeakPtr<flutter::AccessibilityBridgeIos> bridge = factory.GetWeakPtr();
684 flutter::SemanticsNode node;
689 XCTAssertTrue([
object.accessibilityLanguage isEqualToString:
@"es-MX"]);
692 - (void)testFlutterSemanticsObjectPrioritizedSectionLocale {
695 fml::WeakPtrFactory<flutter::AccessibilityBridgeIos> factory(mock);
696 fml::WeakPtr<flutter::AccessibilityBridgeIos> bridge = factory.GetWeakPtr();
698 flutter::SemanticsNode node;
701 node.locale =
"zh-TW";
706 XCTAssertTrue([
object.accessibilityLanguage isEqualToString:
@"zh-TW"]);
709 - (void)testFlutterSemanticsObjectLocaleNil {
712 fml::WeakPtrFactory<flutter::AccessibilityBridgeIos> factory(mock);
713 fml::WeakPtr<flutter::AccessibilityBridgeIos> bridge = factory.GetWeakPtr();
715 flutter::SemanticsNode node;
719 XCTAssertTrue(
object.accessibilityLanguage == nil);
722 - (void)testFlutterScrollableSemanticsObjectWithLabelValueHintIsNotHiddenWhenVoiceOverIsRunning {
725 fml::WeakPtrFactory<flutter::AccessibilityBridgeIos> factory(mock);
726 fml::WeakPtr<flutter::AccessibilityBridgeIos> bridge = factory.GetWeakPtr();
728 flutter::SemanticsNode node;
729 node.flags.hasImplicitScrolling =
true;
730 node.actions = flutter::kHorizontalScrollSemanticsActions;
731 node.rect = SkRect::MakeXYWH(0, 0, 100, 200);
732 node.label =
"label";
733 node.value =
"value";
735 node.scrollExtentMax = 100.0;
736 node.scrollPosition = 0.0;
743 XCTAssertTrue(scrollView.isAccessibilityElement);
745 [scrollView.accessibilityLabel isEqualToString:NSLocalizedString(
@"label",
@"test")]);
747 [scrollView.accessibilityValue isEqualToString:NSLocalizedString(
@"value",
@"test")]);
748 XCTAssertTrue([scrollView.accessibilityHint isEqualToString:NSLocalizedString(
@"hint",
@"test")]);
751 - (void)testFlutterSemanticsObjectMergeTooltipToLabel {
754 fml::WeakPtrFactory<flutter::AccessibilityBridgeIos> factory(mock);
755 fml::WeakPtr<flutter::AccessibilityBridgeIos> bridge = factory.GetWeakPtr();
757 flutter::SemanticsNode node;
758 node.rect = SkRect::MakeXYWH(0, 0, 100, 200);
759 node.label =
"label";
760 node.tooltip =
"tooltip";
763 XCTAssertTrue(
object.isAccessibilityElement);
764 XCTAssertTrue([
object.accessibilityLabel isEqualToString:
@"label\ntooltip"]);
767 - (void)testSemanticsObjectContainerAccessibilityFrameCoversEntireScreen {
770 fml::WeakPtrFactory<flutter::AccessibilityBridgeIos> factory(mock);
771 fml::WeakPtr<flutter::AccessibilityBridgeIos> bridge = factory.GetWeakPtr();
773 flutter::SemanticsNode parent;
775 parent.actions =
static_cast<int32_t
>(flutter::SemanticsAction::kTap);
777 flutter::SemanticsNode child;
779 child.actions =
static_cast<int32_t
>(flutter::SemanticsAction::kTap);
780 child.rect = SkRect::MakeXYWH(0, 0, 100, 100);
781 parent.childrenInTraversalOrder.push_back(1);
791 parentObject.
children = @[ childObject ];
798 XCTAssertTrue(childObject.accessibilityRespondsToUserInteraction);
799 XCTAssertTrue(CGRectEqualToRect(container.accessibilityFrame, UIScreen.mainScreen.bounds));
802 - (void)testSemanticsObjectContainerAccessibilityFrameUsesScreenOfBridgeViewWindow {
805 fml::WeakPtrFactory<flutter::AccessibilityBridgeIos> factory(mock);
806 fml::WeakPtr<flutter::AccessibilityBridgeIos> bridge = factory.GetWeakPtr();
808 flutter::SemanticsNode parent;
811 flutter::SemanticsNode child;
813 child.rect = SkRect::MakeXYWH(0, 0, 100, 100);
814 parent.childrenInTraversalOrder.push_back(1);
822 parentObject.
children = @[ childObject ];
826 CGRect screenBounds = CGRectMake(0, 0, 951, 669);
827 UIScreen* mockScreen = OCMClassMock([UIScreen
class]);
828 OCMStub([mockScreen bounds]).andDo(^(NSInvocation* invocation) {
829 CGRect bounds = screenBounds;
830 [invocation setReturnValue:&bounds];
832 UIWindowScene* mockWindowScene = OCMClassMock([UIWindowScene
class]);
833 OCMStub([mockWindowScene screen]).andReturn(mockScreen);
834 UIWindow* mockWindow = OCMPartialMock(mock->
view().window);
835 OCMStub([mockWindow windowScene]).andReturn(mockWindowScene);
839 XCTAssertTrue(CGRectEqualToRect(container.accessibilityFrame, screenBounds));
841 [(id)mockWindow stopMocking];
844 - (void)testRootSemanticsObjectContainerAccessibilityContainerIsBridgeView {
847 fml::WeakPtrFactory<flutter::AccessibilityBridgeIos> factory(mock);
848 fml::WeakPtr<flutter::AccessibilityBridgeIos> bridge = factory.GetWeakPtr();
850 flutter::SemanticsNode root;
860 XCTAssertEqual(container.accessibilityContainer, mock->
view());
863 - (void)testBridgeViewIsNilWhileBridgeIsAliveAndViewIsNotLoaded {
866 fml::WeakPtrFactory<flutter::AccessibilityBridgeIos> factory(mock);
867 fml::WeakPtr<flutter::AccessibilityBridgeIos> bridge = factory.GetWeakPtr();
869 flutter::SemanticsNode root;
871 root.rect = SkRect::MakeXYWH(0, 0, 100, 100);
877 XCTAssertNotNil(mock->
view());
878 XCTAssertTrue(rootObject.
bridge !=
nullptr);
880 XCTAssertTrue(CGRectEqualToRect(rootObject.accessibilityFrame, CGRectZero));
884 XCTAssertNotNil(container);
885 XCTAssertNil(container.accessibilityContainer);
888 - (void)testChildSemanticsObjectContainerAccessibilityContainerIsParentContainer {
891 fml::WeakPtrFactory<flutter::AccessibilityBridgeIos> factory(mock);
892 fml::WeakPtr<flutter::AccessibilityBridgeIos> bridge = factory.GetWeakPtr();
894 flutter::SemanticsNode root;
896 root.childrenInTraversalOrder.push_back(1);
898 flutter::SemanticsNode child;
900 child.childrenInTraversalOrder.push_back(2);
902 flutter::SemanticsNode grandchild;
917 rootObject.
children = @[ childObject ];
918 childObject.
children = @[ grandchildObject ];
925 XCTAssertEqual(childContainer.accessibilityContainer, rootContainer);
928 - (void)testFlutterSemanticsObjectAttributedStringsDoNotCrashWhenEmpty {
931 fml::WeakPtrFactory<flutter::AccessibilityBridgeIos> factory(mock);
932 fml::WeakPtr<flutter::AccessibilityBridgeIos> bridge = factory.GetWeakPtr();
934 flutter::SemanticsNode node;
935 node.rect = SkRect::MakeXYWH(0, 0, 100, 200);
938 XCTAssertTrue(
object.accessibilityAttributedLabel == nil);
941 - (void)testFlutterScrollableSemanticsObjectReturnsParentContainerIfNoChildren {
944 fml::WeakPtrFactory<flutter::AccessibilityBridgeIos> factory(mock);
945 fml::WeakPtr<flutter::AccessibilityBridgeIos> bridge = factory.GetWeakPtr();
947 flutter::SemanticsNode parent;
949 parent.rect = SkRect::MakeXYWH(0, 0, 100, 200);
950 parent.label =
"label";
951 parent.value =
"value";
952 parent.hint =
"hint";
954 flutter::SemanticsNode node;
956 node.flags.hasImplicitScrolling =
true;
957 node.actions = flutter::kHorizontalScrollSemanticsActions;
958 node.rect = SkRect::MakeXYWH(0, 0, 100, 200);
959 node.label =
"label";
960 node.value =
"value";
962 node.scrollExtentMax = 100.0;
963 node.scrollPosition = 0.0;
964 parent.childrenInTraversalOrder.push_back(1);
975 parentObject.
children = @[ scrollable ];
978 XCTAssertTrue(scrollView.isAccessibilityElement);
984 - (void)testFlutterScrollableSemanticsObjectNoScrollBarOrContentInsets {
985 fml::WeakPtrFactory<flutter::AccessibilityBridgeIos> factory(
987 fml::WeakPtr<flutter::AccessibilityBridgeIos> bridge = factory.GetWeakPtr();
989 flutter::SemanticsNode node;
990 node.flags.hasImplicitScrolling =
true;
991 node.actions = flutter::kHorizontalScrollSemanticsActions;
992 node.rect = SkRect::MakeXYWH(0, 0, 100, 200);
993 node.scrollExtentMax = 100.0;
994 node.scrollPosition = 0.0;
1002 XCTAssertFalse(scrollView.showsHorizontalScrollIndicator);
1003 XCTAssertFalse(scrollView.showsVerticalScrollIndicator);
1004 XCTAssertEqual(scrollView.contentInsetAdjustmentBehavior,
1005 UIScrollViewContentInsetAdjustmentNever);
1006 XCTAssertTrue(UIEdgeInsetsEqualToEdgeInsets(scrollView.contentInset, UIEdgeInsetsZero));
1009 - (void)testSemanticsObjectBuildsAttributedString {
1010 fml::WeakPtrFactory<flutter::AccessibilityBridgeIos> factory(
1012 fml::WeakPtr<flutter::AccessibilityBridgeIos> bridge = factory.GetWeakPtr();
1013 flutter::SemanticsNode node;
1014 node.label =
"label";
1015 std::shared_ptr<flutter::SpellOutStringAttribute> attribute =
1016 std::make_shared<flutter::SpellOutStringAttribute>();
1017 attribute->start = 1;
1019 attribute->type = flutter::StringAttributeType::kSpellOut;
1020 node.labelAttributes.push_back(attribute);
1021 node.value =
"value";
1022 attribute = std::make_shared<flutter::SpellOutStringAttribute>();
1023 attribute->start = 2;
1025 attribute->type = flutter::StringAttributeType::kSpellOut;
1026 node.valueAttributes.push_back(attribute);
1028 std::shared_ptr<flutter::LocaleStringAttribute> local_attribute =
1029 std::make_shared<flutter::LocaleStringAttribute>();
1030 local_attribute->start = 3;
1031 local_attribute->end = 4;
1032 local_attribute->type = flutter::StringAttributeType::kLocale;
1033 local_attribute->locale =
"en-MX";
1034 node.hintAttributes.push_back(local_attribute);
1037 NSMutableAttributedString* expectedAttributedLabel =
1038 [[NSMutableAttributedString alloc] initWithString:NSLocalizedString(@"label", @"test")];
1039 NSDictionary* attributeDict = @{
1040 UIAccessibilitySpeechAttributeSpellOut : @YES,
1042 [expectedAttributedLabel setAttributes:attributeDict range:NSMakeRange(1, 1)];
1044 [
object.accessibilityAttributedLabel isEqualToAttributedString:expectedAttributedLabel]);
1046 NSMutableAttributedString* expectedAttributedValue =
1047 [[NSMutableAttributedString alloc] initWithString:NSLocalizedString(@"value", @"test")];
1049 UIAccessibilitySpeechAttributeSpellOut : @YES,
1051 [expectedAttributedValue setAttributes:attributeDict range:NSMakeRange(2, 1)];
1053 [
object.accessibilityAttributedValue isEqualToAttributedString:expectedAttributedValue]);
1055 NSMutableAttributedString* expectedAttributedHint =
1056 [[NSMutableAttributedString alloc] initWithString:NSLocalizedString(@"hint", @"test")];
1058 UIAccessibilitySpeechAttributeLanguage :
@"en-MX",
1060 [expectedAttributedHint setAttributes:attributeDict range:NSMakeRange(3, 1)];
1062 [
object.accessibilityAttributedHint isEqualToAttributedString:expectedAttributedHint]);
1065 - (void)testShouldTriggerAnnouncement {
1066 fml::WeakPtrFactory<flutter::AccessibilityBridgeIos> factory(
1068 fml::WeakPtr<flutter::AccessibilityBridgeIos> bridge = factory.GetWeakPtr();
1072 XCTAssertFalse([
object nodeShouldTriggerAnnouncement:nil]);
1075 flutter::SemanticsNode node;
1076 node.flags.isLiveRegion =
true;
1078 XCTAssertTrue([
object nodeShouldTriggerAnnouncement:&node]);
1082 XCTAssertFalse([
object nodeShouldTriggerAnnouncement:nil]);
1085 XCTAssertFalse([
object nodeShouldTriggerAnnouncement:&node]);
1088 flutter::SemanticsNode updatedNode;
1089 updatedNode.flags.isLiveRegion =
true;
1090 updatedNode.label =
"bar";
1091 XCTAssertTrue([
object nodeShouldTriggerAnnouncement:&updatedNode]);
1094 updatedNode.flags = flutter::SemanticsFlags{};
1095 XCTAssertFalse([
object nodeShouldTriggerAnnouncement:&updatedNode]);
1098 updatedNode.label =
"foo";
1100 XCTAssertTrue([
object nodeShouldTriggerAnnouncement:&node]);
1103 - (void)testShouldDispatchShowOnScreenActionForHeader {
1104 fml::WeakPtrFactory<flutter::testing::MockAccessibilityBridge> factory(
1106 fml::WeakPtr<flutter::testing::MockAccessibilityBridge> bridge = factory.GetWeakPtr();
1110 flutter::SemanticsNode node;
1111 node.flags.isHeader =
true;
1117 [object accessibilityElementDidBecomeFocused];
1119 XCTAssertTrue(bridge->observations.size() == 1);
1120 XCTAssertTrue(bridge->observations[0].id == 1);
1121 XCTAssertTrue(bridge->observations[0].action == flutter::SemanticsAction::kShowOnScreen);
1124 - (void)testShouldDispatchShowOnScreenActionForHidden {
1125 fml::WeakPtrFactory<flutter::testing::MockAccessibilityBridge> factory(
1127 fml::WeakPtr<flutter::testing::MockAccessibilityBridge> bridge = factory.GetWeakPtr();
1131 flutter::SemanticsNode node;
1132 node.flags.isHidden =
true;
1138 [object accessibilityElementDidBecomeFocused];
1140 XCTAssertTrue(bridge->observations.size() == 1);
1141 XCTAssertTrue(bridge->observations[0].id == 1);
1142 XCTAssertTrue(bridge->observations[0].action == flutter::SemanticsAction::kShowOnScreen);
1145 - (void)testFlutterSwitchSemanticsObjectMatchesUISwitch {
1146 fml::WeakPtrFactory<flutter::testing::MockAccessibilityBridge> factory(
1148 fml::WeakPtr<flutter::testing::MockAccessibilityBridge> bridge = factory.GetWeakPtr();
1153 flutter::SemanticsNode node;
1154 node.flags.isToggled = flutter::SemanticsTristate::kTrue;
1155 node.flags.isEnabled = flutter::SemanticsTristate::kTrue;
1159 UISwitch* nativeSwitch = [[UISwitch alloc] init];
1160 nativeSwitch.on = YES;
1162 XCTAssertEqual(
object.accessibilityTraits, nativeSwitch.accessibilityTraits);
1163 XCTAssertEqualObjects(
object.accessibilityValue, nativeSwitch.accessibilityValue);
1166 flutter::SemanticsNode update;
1167 update.flags.isToggled = flutter::SemanticsTristate::kFalse;
1168 update.flags.isEnabled = flutter::SemanticsTristate::kTrue;
1170 update.label =
"foo";
1173 nativeSwitch.on = NO;
1175 XCTAssertEqual(
object.accessibilityTraits, nativeSwitch.accessibilityTraits);
1176 XCTAssertEqualObjects(
object.accessibilityValue, nativeSwitch.accessibilityValue);
1179 - (void)testFlutterSemanticsObjectOfRadioButton {
1180 fml::WeakPtrFactory<flutter::testing::MockAccessibilityBridge> factory(
1182 fml::WeakPtr<flutter::testing::MockAccessibilityBridge> bridge = factory.GetWeakPtr();
1186 flutter::SemanticsNode node;
1187 node.flags.isInMutuallyExclusiveGroup =
true;
1188 node.flags.isChecked = flutter::SemanticsCheckState::kFalse;
1189 node.flags.isEnabled = flutter::SemanticsTristate::kTrue;
1192 XCTAssertTrue((
object.accessibilityTraits & UIAccessibilityTraitButton) > 0);
1193 XCTAssertNil(
object.accessibilityValue);
1196 - (void)testFlutterSwitchSemanticsObjectMatchesUISwitchDisabled {
1197 fml::WeakPtrFactory<flutter::testing::MockAccessibilityBridge> factory(
1199 fml::WeakPtr<flutter::testing::MockAccessibilityBridge> bridge = factory.GetWeakPtr();
1204 flutter::SemanticsNode node;
1205 node.flags.isToggled = flutter::SemanticsTristate::kTrue;
1209 UISwitch* nativeSwitch = [[UISwitch alloc] init];
1210 nativeSwitch.on = YES;
1211 nativeSwitch.enabled = NO;
1213 XCTAssertEqual(
object.accessibilityTraits, nativeSwitch.accessibilityTraits);
1214 XCTAssertEqualObjects(
object.accessibilityValue, nativeSwitch.accessibilityValue);
1217 - (void)testSemanticsObjectDeallocated {
1218 fml::WeakPtrFactory<flutter::AccessibilityBridgeIos> factory(
1220 fml::WeakPtr<flutter::AccessibilityBridgeIos> bridge = factory.GetWeakPtr();
1228 XCTAssertNil(weakObject);
1231 - (void)testFlutterSemanticsObjectReturnsNilContainerWhenBridgeIsNotAlive {
1236 flutter::SemanticsNode parent;
1238 parent.rect = SkRect::MakeXYWH(0, 0, 100, 200);
1239 parent.label =
"label";
1240 parent.value =
"value";
1241 parent.hint =
"hint";
1243 flutter::SemanticsNode node;
1245 node.flags.hasImplicitScrolling =
true;
1246 node.actions = flutter::kHorizontalScrollSemanticsActions;
1247 node.rect = SkRect::MakeXYWH(0, 0, 100, 200);
1248 node.label =
"label";
1249 node.value =
"value";
1251 node.scrollExtentMax = 100.0;
1252 node.scrollPosition = 0.0;
1253 parent.childrenInTraversalOrder.push_back(1);
1255 flutter::SemanticsNode node2;
1257 node2.rect = SkRect::MakeXYWH(0, 0, 100, 200);
1258 node2.label =
"label";
1259 node2.value =
"value";
1260 node2.hint =
"hint";
1261 node2.scrollExtentMax = 100.0;
1262 node2.scrollPosition = 0.0;
1263 parent.childrenInTraversalOrder.push_back(2);
1269 fml::WeakPtrFactory<flutter::AccessibilityBridgeIos> factory(mock);
1270 fml::WeakPtr<flutter::AccessibilityBridgeIos> bridge = factory.GetWeakPtr();
1282 parentObject.
children = @[ scrollable, object2 ];
1297 XCTAssertNil(scrollable.accessibilityContainer);
1298 XCTAssertNil(object2.accessibilityContainer);
1301 - (void)testAccessibilityHitTestSearchCanReturnPlatformView {
1302 fml::WeakPtrFactory<flutter::AccessibilityBridgeIos> factory(
1304 fml::WeakPtr<flutter::AccessibilityBridgeIos> bridge = factory.GetWeakPtr();
1313 platformView:platformView];
1317 object1.
children = @[ platformViewSemanticsContainer, object3 ];
1320 flutter::SemanticsNode node0;
1322 node0.rect = SkRect::MakeXYWH(0, 0, 200, 200);
1326 flutter::SemanticsNode node1;
1328 node1.rect = SkRect::MakeXYWH(0, 0, 200, 200);
1332 flutter::SemanticsNode node2;
1334 node2.rect = SkRect::MakeXYWH(0, 0, 100, 100);
1338 flutter::SemanticsNode node3;
1340 node3.rect = SkRect::MakeXYWH(0, 0, 200, 200);
1344 CGPoint point = CGPointMake(10, 10);
1347 XCTAssertEqual(hitTestResult, platformView);
1350 - (void)testFlutterPlatformViewSemanticsContainer {
1351 fml::WeakPtrFactory<flutter::testing::MockAccessibilityBridge> factory(
1353 fml::WeakPtr<flutter::testing::MockAccessibilityBridge> bridge = factory.GetWeakPtr();
1358 weakPlatformView = platformView;
1364 platformView:platformView];
1365 weakContainer = container;
1367 XCTAssertNotNil(weakPlatformView);
1368 XCTAssertNotNil(weakContainer);
1372 XCTAssertNotNil(weakPlatformView);
1373 XCTAssertNotNil(weakContainer);
1377 XCTAssertNil(weakPlatformView);
1378 XCTAssertNil(weakContainer);
1381 - (void)testTextInputSemanticsObject {
1382 fml::WeakPtrFactory<flutter::AccessibilityBridgeIos> factory(
1384 fml::WeakPtr<flutter::AccessibilityBridgeIos> bridge = factory.GetWeakPtr();
1386 flutter::SemanticsNode node;
1388 node.flags.isTextField =
true;
1389 node.flags.isReadOnly =
true;
1393 XCTAssertEqual([
object accessibilityTraits], UIAccessibilityTraitNone);
1396 - (void)testTextInputSemanticsObject_canPerformAction {
1397 fml::WeakPtrFactory<flutter::AccessibilityBridgeIos> factory(
1399 fml::WeakPtr<flutter::AccessibilityBridgeIos> bridge = factory.GetWeakPtr();
1401 flutter::SemanticsNode node;
1403 node.flags.isTextField =
true;
1404 node.flags.isReadOnly =
true;
1409 id textInputSurrogate = OCMClassMock([UIResponder
class]);
1410 id partialSemanticsObject = OCMPartialMock(
object);
1411 OCMStub([partialSemanticsObject textInputSurrogate]).andReturn(textInputSurrogate);
1413 OCMExpect([textInputSurrogate canPerformAction:[OCMArg anySelector] withSender:OCMOCK_ANY])
1415 XCTAssertTrue([partialSemanticsObject canPerformAction:
@selector(copy:) withSender:nil]);
1417 OCMExpect([textInputSurrogate canPerformAction:[OCMArg anySelector] withSender:OCMOCK_ANY])
1419 XCTAssertFalse([partialSemanticsObject canPerformAction:
@selector(copy:) withSender:nil]);
1422 - (void)testTextInputSemanticsObject_editActions {
1423 fml::WeakPtrFactory<flutter::AccessibilityBridgeIos> factory(
1425 fml::WeakPtr<flutter::AccessibilityBridgeIos> bridge = factory.GetWeakPtr();
1427 flutter::SemanticsNode node;
1430 node.flags.isTextField =
true;
1431 node.flags.isReadOnly =
true;
1436 id textInputSurrogate = OCMClassMock([UIResponder
class]);
1437 id partialSemanticsObject = OCMPartialMock(
object);
1438 OCMStub([partialSemanticsObject textInputSurrogate]).andReturn(textInputSurrogate);
1440 XCTestExpectation* copyExpectation =
1441 [
self expectationWithDescription:@"Surrogate's copy method is called."];
1442 XCTestExpectation* cutExpectation =
1443 [
self expectationWithDescription:@"Surrogate's cut method is called."];
1444 XCTestExpectation* pasteExpectation =
1445 [
self expectationWithDescription:@"Surrogate's paste method is called."];
1446 XCTestExpectation* selectAllExpectation =
1447 [
self expectationWithDescription:@"Surrogate's selectAll method is called."];
1448 XCTestExpectation* deleteExpectation =
1449 [
self expectationWithDescription:@"Surrogate's delete method is called."];
1451 OCMStub([textInputSurrogate copy:OCMOCK_ANY]).andDo(^(NSInvocation* invocation) {
1452 [copyExpectation fulfill];
1454 OCMStub([textInputSurrogate cut:OCMOCK_ANY]).andDo(^(NSInvocation* invocation) {
1455 [cutExpectation fulfill];
1457 OCMStub([textInputSurrogate paste:OCMOCK_ANY]).andDo(^(NSInvocation* invocation) {
1458 [pasteExpectation fulfill];
1460 OCMStub([textInputSurrogate selectAll:OCMOCK_ANY]).andDo(^(NSInvocation* invocation) {
1461 [selectAllExpectation fulfill];
1463 OCMStub([textInputSurrogate
delete:OCMOCK_ANY]).andDo(^(NSInvocation* invocation) {
1464 [deleteExpectation fulfill];
1467 [partialSemanticsObject copy:nil];
1468 [partialSemanticsObject cut:nil];
1469 [partialSemanticsObject paste:nil];
1470 [partialSemanticsObject selectAll:nil];
1471 [partialSemanticsObject delete:nil];
1473 [
self waitForExpectationsWithTimeout:1 handler:nil];
1476 - (void)testSliderSemanticsObject {
1477 fml::WeakPtrFactory<flutter::AccessibilityBridgeIos> factory(
1479 fml::WeakPtr<flutter::AccessibilityBridgeIos> bridge = factory.GetWeakPtr();
1481 flutter::SemanticsNode node;
1482 node.flags.isSlider =
true;
1486 XCTAssertEqual([
object accessibilityActivate], YES);
1489 - (void)testUIFocusItemConformance {
1490 fml::WeakPtrFactory<flutter::AccessibilityBridgeIos> factory(
1492 fml::WeakPtr<flutter::AccessibilityBridgeIos> bridge = factory.GetWeakPtr();
1498 XCTAssertTrue([parent.parentFocusEnvironment isKindOfClass:[UIView
class]]);
1499 XCTAssertEqual(child.parentFocusEnvironment, child.
parent);
1502 flutter::SemanticsNode childNode;
1503 childNode.flags.isHidden =
true;
1504 childNode.actions =
static_cast<int32_t
>(flutter::SemanticsAction::kTap);
1506 XCTAssertFalse(child.canBecomeFocused);
1507 childNode.flags = flutter::SemanticsFlags{};
1509 XCTAssertTrue(child.canBecomeFocused);
1510 childNode.actions = 0;
1512 XCTAssertFalse(child.canBecomeFocused);
1514 CGFloat scale = ((bridge->view().window.screen ?: UIScreen.mainScreen)).scale;
1516 childNode.rect = SkRect::MakeXYWH(0, 0, 100 * scale, 100 * scale);
1518 flutter::SemanticsNode parentNode;
1519 parentNode.rect = SkRect::MakeXYWH(0, 0, 200, 200);
1522 XCTAssertTrue(CGRectEqualToRect(child.frame, CGRectMake(0, 0, 100, 100)));
1525 - (void)testUIFocusItemContainerConformance {
1526 fml::WeakPtrFactory<flutter::AccessibilityBridgeIos> factory(
1528 fml::WeakPtr<flutter::AccessibilityBridgeIos> bridge = factory.GetWeakPtr();
1535 NSArray<id<UIFocusItem>>* itemsInRect = [parent focusItemsInRect:CGRectMake(0, 0, 100, 100)];
1536 XCTAssertEqual(itemsInRect.count, (
unsigned long)2);
1537 XCTAssertTrue([itemsInRect containsObject:child1]);
1538 XCTAssertTrue([itemsInRect containsObject:child2]);
1541 - (void)testUIFocusItemScrollableContainerConformance {
1542 fml::WeakPtrFactory<flutter::AccessibilityBridgeIos> factory(
1544 fml::WeakPtr<flutter::testing::MockAccessibilityBridge> bridge = factory.GetWeakPtr();
1549 CGPoint p = CGPointMake(123.0, 456.0);
1550 [scrollable.scrollView scrollViewWillEndDragging:scrollable.scrollView
1551 withVelocity:CGPointZero
1552 targetContentOffset:&p];
1554 [scrollable.scrollView scrollViewDidEndDecelerating:scrollable.scrollView];
1555 XCTAssertEqual(bridge->observations.size(), (
size_t)1);
1556 XCTAssertEqual(bridge->observations[0].id, 5);
1557 XCTAssertEqual(bridge->observations[0].action, flutter::SemanticsAction::kScrollToOffset);
1559 std::vector<uint8_t> args = bridge->observations[0].args;
1560 XCTAssertEqual(args.size(), 3 *
sizeof(CGFloat));
1562 NSData* encoded = [NSData dataWithBytes:args.data() length:args.size()];
1564 CGPoint point = CGPointZero;
1565 memcpy(&point, decoded.
data.bytes, decoded.
data.length);
1566 XCTAssertTrue(CGPointEqualToPoint(point, p));
1569 - (void)testUIFocusItemScrollableContainerNoFeedbackLoops {
1570 fml::WeakPtrFactory<flutter::AccessibilityBridgeIos> factory(
1572 fml::WeakPtr<flutter::testing::MockAccessibilityBridge> bridge = factory.GetWeakPtr();
1577 const CGPoint p = CGPointMake(0.0, 456.0);
1579 bridge->observations.clear();
1581 const SkScalar scrollPosition = p.y + 0.0000000000000001;
1582 flutter::SemanticsNode node;
1583 node.flags.hasImplicitScrolling =
true;
1584 node.actions = flutter::kVerticalScrollSemanticsActions;
1585 node.rect = SkRect::MakeXYWH(0, 0, 100, 200);
1586 node.scrollExtentMax = 10000;
1587 node.scrollPosition = scrollPosition;
1588 node.transform = {1.0, 0, 0, 0, 0, 1.0, 0, 0, 0, 0, 1.0, 0, 0, scrollPosition, 0, 1.0};
1592 XCTAssertEqual(bridge->observations.size(), (
size_t)0);
constexpr NS_ASSUME_NONNULL_BEGIN int32_t kRootNodeId
constexpr float kScrollExtentMaxForInf
FLUTTER_ASSERT_ARC const float kFloatCompareEpsilon
UIView< UITextInput > * textInputSurrogate()
id accessibilityContainer()
UIView * view() const override
bool isVoiceOverRunningValue
SemanticsObject * semanticsObject
id _accessibilityHitTest:withEvent:(CGPoint point,[withEvent] UIEvent *event)
NSArray< SemanticsObject * > * children
nullable UIView * bridgeView()
NSArray< SemanticsObject * > * childrenInHitTestOrder
BOOL accessibilityScrollToVisibleWithChild:(id child)
void accessibilityBridgeDidFinishUpdate()
nullable flutter::AccessibilityBridgeIos * bridge()
BOOL accessibilityScrollToVisible()
void replaceChildAtIndex:withChild:(NSInteger index,[withChild] SemanticsObject *child)
void setSemanticsNode:(const flutter::SemanticsNode *NS_REQUIRES_SUPER)
instancetype sharedInstance()