5#import <OCMock/OCMock.h>
6#import <XCTest/XCTest.h>
8#import "flutter/shell/platform/darwin/common/framework/Headers/FlutterMacros.h"
9#import "flutter/shell/platform/darwin/ios/framework/Source/FlutterPlatformViews_Internal.h"
10#import "flutter/shell/platform/darwin/ios/framework/Source/FlutterTouchInterceptingView_Test.h"
11#import "flutter/shell/platform/darwin/ios/framework/Source/SemanticsObject.h"
12#import "flutter/shell/platform/darwin/ios/framework/Source/SemanticsObjectTestMocks.h"
13#import "flutter/shell/platform/darwin/ios/framework/Source/TextInputSemanticsObject.h"
29 XCTAssertNotNil(
object);
39 XCTAssertEqual(parent, child.
parent);
41 XCTAssertNil(child.
parent);
54 object1.
children = @[ object2, object3 ];
81 CGPoint point = CGPointMake(10, 10);
85 XCTAssertEqual(hitTestResult, object2);
98 object1.
children = @[ object2, object3 ];
121 CGPoint point = CGPointMake(10, 10);
124 XCTAssertNil(hitTestResult);
140 XCTAssertTrue(bridge->observations.size() == 1);
141 XCTAssertTrue(bridge->observations[0].id == 3);
158 XCTAssertTrue(bridge->observations.size() == 1);
159 XCTAssertTrue(bridge->observations[0].id == 3);
173 object1.
children = @[ object2, object3 ];
200 CGPoint point = CGPointMake(300, 300);
203 XCTAssertNil(hitTestResult);
215 XCTAssertNil(child1.
parent);
216 XCTAssertEqual(parent, child2.
parent);
217 XCTAssertEqualObjects(parent.
children, @[ child2 ]);
228 XCTAssertEqual([
object accessibilityTraits], UIAccessibilityTraitStaticText);
240 XCTAssertEqual(
object.isAccessibilityElement, YES);
251 XCTAssertEqual(
object.isAccessibilityElement, NO);
264 XCTAssertEqual([
object accessibilityTraits], UIAccessibilityTraitNone);
276 XCTAssertEqual([
object accessibilityTraits], UIAccessibilityTraitNone);
288 XCTAssertEqual([
object accessibilityTraits], UIAccessibilityTraitButton);
296 float transformScale = 0.5f;
297 float screenScale = [[bridge->view() window] screen].scale;
298 float effectivelyScale = transformScale / screenScale;
303 float scrollExtentMax = 500.0;
304 float scrollPosition = 150.0;
313 transformScale, 0, 0, 0, 0, transformScale, 0, 0, 0, 0, transformScale, 0, 0, 0, 0, 1.0};
322 XCTAssertEqualWithAccuracy(scrollView.frame.size.width,
w * effectivelyScale,
324 XCTAssertEqualWithAccuracy(scrollView.frame.size.height,
h * effectivelyScale,
327 XCTAssertEqualWithAccuracy(scrollView.contentSize.width,
w * effectivelyScale,
329 XCTAssertEqualWithAccuracy(scrollView.contentSize.height,
332 XCTAssertEqual(scrollView.contentOffset.x, 0);
333 XCTAssertEqualWithAccuracy(scrollView.contentOffset.y, scrollPosition * effectivelyScale,
342 float transformScale = 0.5f;
347 float scrollExtentMax = 500.0;
348 float scrollPosition = 150.0;
357 transformScale, 0, 0, 0, 0, transformScale, 0, 0, 0, 0, transformScale, 0, 0, 0, 0, 1.0};
362 XCTAssertNoThrow([scrollable accessibilityBridgeDidFinishUpdate]);
370 float transformScale = 0.5f;
371 float screenScale = [[bridge->view() window] screen].scale;
372 float effectivelyScale = transformScale / screenScale;
377 float scrollExtentMax = 500.0;
378 float scrollPosition = 150.0;
387 transformScale, 0, 0, 0, 0, transformScale, 0, 0, 0, 0, transformScale, 0, 0, 0, 0, 1.0};
396 XCTAssertEqualWithAccuracy(scrollView.frame.size.width,
w * effectivelyScale,
398 XCTAssertEqualWithAccuracy(scrollView.frame.size.height,
h * effectivelyScale,
401 XCTAssertEqualWithAccuracy(scrollView.contentSize.width, (
w + scrollExtentMax) * effectivelyScale,
403 XCTAssertEqualWithAccuracy(scrollView.contentSize.height,
h * effectivelyScale,
406 XCTAssertEqualWithAccuracy(scrollView.contentOffset.x, scrollPosition * effectivelyScale,
408 XCTAssertEqual(scrollView.contentOffset.y, 0);
416 float transformScale = 0.5f;
417 float screenScale = [[bridge->view() window] screen].scale;
418 float effectivelyScale = transformScale / screenScale;
423 float scrollExtentMax = INFINITY;
424 float scrollPosition = 150.0;
433 transformScale, 0, 0, 0, 0, transformScale, 0, 0, 0, 0, transformScale, 0, 0, 0, 0, 1.0};
441 XCTAssertEqualWithAccuracy(scrollView.frame.size.width,
w * effectivelyScale,
443 XCTAssertEqualWithAccuracy(scrollView.frame.size.height,
h * effectivelyScale,
446 XCTAssertEqualWithAccuracy(scrollView.contentSize.width,
w * effectivelyScale,
448 XCTAssertEqualWithAccuracy(scrollView.contentSize.height,
452 XCTAssertEqual(scrollView.contentOffset.x, 0);
453 XCTAssertEqualWithAccuracy(scrollView.contentOffset.y, scrollPosition * effectivelyScale,
462 float transformScale = 0.5f;
463 float screenScale = [[bridge->view() window] screen].scale;
464 float effectivelyScale = transformScale / screenScale;
469 float scrollExtentMax = std::nan(
"");
470 float scrollPosition = std::nan(
"");
479 transformScale, 0, 0, 0, 0, transformScale, 0, 0, 0, 0, transformScale, 0, 0, 0, 0, 1.0};
488 XCTAssertEqualWithAccuracy(scrollView.frame.size.width,
w * effectivelyScale,
490 XCTAssertEqualWithAccuracy(scrollView.frame.size.height,
h * effectivelyScale,
494 XCTAssertEqualWithAccuracy(scrollView.contentSize.width,
w * effectivelyScale,
496 XCTAssertEqualWithAccuracy(scrollView.contentSize.height,
h * effectivelyScale,
499 XCTAssertEqual(scrollView.contentOffset.x, 0);
500 XCTAssertEqual(scrollView.contentOffset.y, 0);
520 XCTAssertEqual([scrollView hitTest:CGPointMake(10, 10) withEvent:nil], nil);
541 XCTAssertTrue(scrollView.isAccessibilityElement);
543 XCTAssertFalse(scrollView.isAccessibilityElement);
557 XCTAssertTrue([
object.accessibilityIdentifier isEqualToString:
@"identifier"]);
570 node.
label =
"label";
571 node.
value =
"value";
581 XCTAssertTrue(scrollView.isAccessibilityElement);
583 [scrollView.accessibilityLabel isEqualToString:NSLocalizedString(
@"label",
@"test")]);
585 [scrollView.accessibilityValue isEqualToString:NSLocalizedString(
@"value",
@"test")]);
586 XCTAssertTrue([scrollView.accessibilityHint isEqualToString:NSLocalizedString(
@"hint",
@"test")]);
597 node.
label =
"label";
601 XCTAssertTrue(
object.isAccessibilityElement);
602 XCTAssertTrue([
object.accessibilityLabel isEqualToString:
@"label\ntooltip"]);
615 XCTAssertTrue(
object.accessibilityAttributedLabel == nil);
627 parent.
label =
"label";
628 parent.
value =
"value";
629 parent.
hint =
"hint";
636 node.
label =
"label";
637 node.
value =
"value";
652 parentObject.
children = @[ scrollable ];
655 XCTAssertTrue(scrollView.isAccessibilityElement);
679 XCTAssertFalse(scrollView.showsHorizontalScrollIndicator);
680 XCTAssertFalse(scrollView.showsVerticalScrollIndicator);
688 node.
label =
"label";
689 std::shared_ptr<flutter::SpellOutStringAttribute> attribute =
690 std::make_shared<flutter::SpellOutStringAttribute>();
691 attribute->start = 1;
695 node.
value =
"value";
696 attribute = std::make_shared<flutter::SpellOutStringAttribute>();
697 attribute->start = 2;
702 std::shared_ptr<flutter::LocaleStringAttribute> local_attribute =
703 std::make_shared<flutter::LocaleStringAttribute>();
704 local_attribute->start = 3;
705 local_attribute->end = 4;
707 local_attribute->locale =
"en-MX";
711 NSMutableAttributedString* expectedAttributedLabel =
712 [[NSMutableAttributedString alloc] initWithString:NSLocalizedString(@"label", @"test")];
713 NSDictionary* attributeDict = @{
714 UIAccessibilitySpeechAttributeSpellOut : @YES,
716 [expectedAttributedLabel setAttributes:attributeDict range:NSMakeRange(1, 1)];
718 [
object.accessibilityAttributedLabel isEqualToAttributedString:expectedAttributedLabel]);
720 NSMutableAttributedString* expectedAttributedValue =
721 [[NSMutableAttributedString alloc] initWithString:NSLocalizedString(@"value", @"test")];
723 UIAccessibilitySpeechAttributeSpellOut : @YES,
725 [expectedAttributedValue setAttributes:attributeDict range:NSMakeRange(2, 1)];
727 [
object.accessibilityAttributedValue isEqualToAttributedString:expectedAttributedValue]);
729 NSMutableAttributedString* expectedAttributedHint =
730 [[NSMutableAttributedString alloc] initWithString:NSLocalizedString(@"hint", @"test")];
732 UIAccessibilitySpeechAttributeLanguage :
@"en-MX",
734 [expectedAttributedHint setAttributes:attributeDict range:NSMakeRange(3, 1)];
736 [
object.accessibilityAttributedHint isEqualToAttributedString:expectedAttributedHint]);
746 XCTAssertFalse([
object nodeShouldTriggerAnnouncement:nil]);
752 XCTAssertTrue([
object nodeShouldTriggerAnnouncement:&node]);
756 XCTAssertFalse([
object nodeShouldTriggerAnnouncement:nil]);
759 XCTAssertFalse([
object nodeShouldTriggerAnnouncement:&node]);
764 updatedNode.
label =
"bar";
765 XCTAssertTrue([
object nodeShouldTriggerAnnouncement:&updatedNode]);
768 updatedNode.
flags = 0;
769 XCTAssertFalse([
object nodeShouldTriggerAnnouncement:&updatedNode]);
772 updatedNode.
label =
"foo";
774 XCTAssertTrue([
object nodeShouldTriggerAnnouncement:&node]);
793 XCTAssertTrue(bridge->observations.size() == 1);
794 XCTAssertTrue(bridge->observations[0].id == 1);
814 XCTAssertTrue(bridge->observations.size() == 1);
815 XCTAssertTrue(bridge->observations[0].id == 1);
834 UISwitch* nativeSwitch = [[UISwitch alloc] init];
835 nativeSwitch.on = YES;
837 XCTAssertEqual(
object.accessibilityTraits, nativeSwitch.accessibilityTraits);
838 XCTAssertEqualObjects(
object.accessibilityValue, nativeSwitch.accessibilityValue);
847 nativeSwitch.on = NO;
849 XCTAssertEqual(
object.accessibilityTraits, nativeSwitch.accessibilityTraits);
850 XCTAssertEqualObjects(
object.accessibilityValue, nativeSwitch.accessibilityValue);
867 XCTAssertTrue((
object.accessibilityTraits & UIAccessibilityTraitButton) > 0);
868 XCTAssertNil(
object.accessibilityValue);
885 UISwitch* nativeSwitch = [[UISwitch alloc] init];
886 nativeSwitch.on = YES;
887 nativeSwitch.enabled = NO;
889 XCTAssertEqual(
object.accessibilityTraits, nativeSwitch.accessibilityTraits);
890 XCTAssertEqualObjects(
object.accessibilityValue, nativeSwitch.accessibilityValue);
904 XCTAssertNil(weakObject);
915 parent.
label =
"label";
916 parent.
value =
"value";
917 parent.
hint =
"hint";
924 node.
label =
"label";
925 node.
value =
"value";
934 node2.
label =
"label";
935 node2.
value =
"value";
958 parentObject.
children = @[ scrollable, object2 ];
989 platformView:platformView];
993 object1.
children = @[ platformViewSemanticsContainer, object3 ];
1020 CGPoint point = CGPointMake(10, 10);
1023 XCTAssertEqual(hitTestResult, platformView);
1034 weakPlatformView = platformView;
1040 platformView:platformView];
1041 weakContainer = container;
1043 XCTAssertNotNil(weakPlatformView);
1044 XCTAssertNotNil(weakContainer);
1048 XCTAssertNotNil(weakPlatformView);
1049 XCTAssertNotNil(weakContainer);
1053 XCTAssertNil(weakPlatformView);
1054 XCTAssertNil(weakContainer);
1069 XCTAssertEqual([
object accessibilityTraits], UIAccessibilityTraitNone);
FLUTTER_ASSERT_ARC const float kFloatCompareEpsilon
constexpr float kScrollExtentMaxForInf
id accessibilityContainer()
bool isVoiceOverRunningValue
WeakPtr< T > GetWeakPtr() const
SemanticsObject * semanticsObject
void testAccessibilityHitTestOutOfRect()
void testSemanticsObjectDeallocated()
void testCanHandleNaNScrollExtentAndScrollPoisition()
void testVerticalFlutterScrollableSemanticsObject()
void testNodeWithImplicitScrollIsNotAnAccessibilityElementWhenItisNotHidden()
void testReplaceChildAtIndex()
void testFlutterPlatformViewSemanticsContainer()
void testAccessibilityScrollToVisible()
void testVerticalFlutterScrollableSemanticsObjectNoWindowDoesNotCrash()
void testShouldDispatchShowOnScreenActionForHeader()
void testTextInputSemanticsObject()
void testFlutterSemanticsObjectMergeTooltipToLabel()
void testFlutterScrollableSemanticsObjectHidesScrollBar()
void testFlutterSemanticsObjectReturnsNilContainerWhenBridgeIsNotAlive()
void testCanHandleInfiniteScrollExtent()
void testNodeWithImplicitScrollIsAnAccessibilityElementWhenItisHidden()
void testHorizontalFlutterScrollableSemanticsObject()
void testFlutterSwitchSemanticsObjectMatchesUISwitchDisabled()
void testPlainSemanticsObjectWithLabelHasStaticTextTrait()
void testFlutterScrollableSemanticsObjectIsHiddenWhenVoiceOverIsRunning()
void testSemanticsObjectBuildsAttributedString()
void testAccessibilityScrollToVisibleWithChild()
void testFlutterScrollableSemanticsObjectReturnsParentContainerIfNoChildren()
void testAccessibilityHitTestSearchCanReturnPlatformView()
void testFlutterSwitchSemanticsObjectMatchesUISwitch()
void testFlutterSemanticsObjectAttributedStringsDoNotCrashWhenEmpty()
void testShouldDispatchShowOnScreenActionForHidden()
void testFlutterSemanticsObjectHasIdentifier()
void testFlutterSemanticsObjectOfRadioButton()
void testIntresetingSemanticsObjectWithLabelHasStaticTextTrait()
void testShouldTriggerAnnouncement()
void testIntresetingSemanticsObjectWithLabelHasStaticTextTrait1()
void testIntresetingSemanticsObjectWithLabelHasStaticTextTrait2()
void testFlutterScrollableSemanticsObjectWithLabelValueHintIsNotHiddenWhenVoiceOverIsRunning()
void testFlutterScrollableSemanticsObjectIsNotHittestable()
void testAccessibilityHitTestFocusAtLeaf()
void testAccessibilityHitTestNoFocusableItem()
id _accessibilityHitTest:withEvent:(CGPoint point, [withEvent] UIEvent *event)
void accessibilityElementDidBecomeFocused()
NSArray< SemanticsObject * > * childrenInHitTestOrder
BOOL accessibilityScrollToVisibleWithChild:(id child)
BOOL accessibilityScrollToVisible()
void accessibilityBridgeDidFinishUpdate()
id accessibilityContainer()
NSArray< SemanticsObject * > * children
void replaceChildAtIndex:withChild:(NSInteger index,[withChild] SemanticsObject *child)
void setSemanticsNode:(const flutter::SemanticsNode *NS_REQUIRES_SUPER)
void setSemanticsNode:(const flutter::SemanticsNode *node)
@ kIsInMutuallyExclusiveGroup
const int kHorizontalScrollSemanticsActions
const int kVerticalScrollSemanticsActions
static constexpr SkRect MakeXYWH(float x, float y, float w, float h)
StringAttributes hintAttributes
StringAttributes valueAttributes
StringAttributes labelAttributes
std::vector< int32_t > childrenInTraversalOrder