35 engine.semanticsEnabled = YES;
46 root.
label =
"accessibility";
55 bridge->AddFlutterSemanticsNodeUpdate(root);
57 bridge->CommitUpdates();
59 auto root_platform_node_delegate = bridge->GetFlutterPlatformNodeDelegateFromID(0).lock();
61 NSAccessibilityElement* native_accessibility =
62 root_platform_node_delegate->GetNativeViewAccessible();
63 std::string
value = [native_accessibility.accessibilityValue UTF8String];
64 EXPECT_TRUE(
value ==
"accessibility");
65 EXPECT_EQ(native_accessibility.accessibilityRole, NSAccessibilityStaticTextRole);
66 EXPECT_EQ([native_accessibility.accessibilityChildren count], 0u);
73 engine.semanticsEnabled = YES;
87 root.
value =
"selectable text";
94 bridge->AddFlutterSemanticsNodeUpdate(root);
96 bridge->CommitUpdates();
98 auto root_platform_node_delegate = bridge->GetFlutterPlatformNodeDelegateFromID(0).lock();
100 NSAccessibilityElement* native_accessibility =
101 root_platform_node_delegate->GetNativeViewAccessible();
102 std::string
value = [native_accessibility.accessibilityValue UTF8String];
103 EXPECT_EQ(
value,
"selectable text");
104 EXPECT_EQ(native_accessibility.accessibilityRole, NSAccessibilityStaticTextRole);
105 EXPECT_EQ([native_accessibility.accessibilityChildren count], 0u);
106 NSRange selection = native_accessibility.accessibilitySelectedTextRange;
107 EXPECT_EQ(selection.location, 1u);
108 EXPECT_EQ(selection.length, 2u);
109 std::string selected_text = [native_accessibility.accessibilitySelectedText UTF8String];
110 EXPECT_EQ(selected_text,
"el");
116 engine.semanticsEnabled = YES;
130 root.
value =
"selectable text";
137 bridge->AddFlutterSemanticsNodeUpdate(root);
139 bridge->CommitUpdates();
141 auto root_platform_node_delegate = bridge->GetFlutterPlatformNodeDelegateFromID(0).lock();
143 NSAccessibilityElement* native_accessibility =
144 root_platform_node_delegate->GetNativeViewAccessible();
145 NSRange selection = native_accessibility.accessibilitySelectedTextRange;
146 EXPECT_TRUE(selection.location == NSNotFound);
147 EXPECT_EQ(selection.length, 0u);
158 NSWindow*
window = [[NSWindow alloc] initWithContentRect:NSMakeRect(0, 0, 800, 600)
159 styleMask:NSBorderlessWindowMask
160 backing:NSBackingStoreBuffered
164 engine.semanticsEnabled = YES;
178 int32_t children[] = {1};
182 bridge->AddFlutterSemanticsNodeUpdate(root);
186 child1.
flags2 = &child_flags;
188 child1.
label =
"child 1";
197 bridge->AddFlutterSemanticsNodeUpdate(child1);
199 bridge->CommitUpdates();
201 auto root_platform_node_delegate = bridge->GetFlutterPlatformNodeDelegateFromID(1).lock();
210 const uint8_t*
data,
size_t data_length) {
219 root_platform_node_delegate->AccessibilityPerformAction(action_data);
222 EXPECT_EQ(called_id, 1u);
224 [
engine setViewController:nil];
237 engine.textInputPlugin.string =
@"textfield";
239 NSWindow*
window = [[NSWindow alloc] initWithContentRect:NSMakeRect(0, 0, 800, 600)
240 styleMask:NSBorderlessWindowMask
241 backing:NSBackingStoreBuffered
244 engine.semanticsEnabled = YES;
262 int32_t children[] = {1};
266 root.
rect = {0, 0, 100, 100};
267 root.
transform = {1, 0, 0, 0, 1, 0, 0, 0, 1};
268 bridge->AddFlutterSemanticsNodeUpdate(root);
270 double rectSize = 50;
271 double transformFactor = 0.5;
275 child1.
flags2 = &child_flags;
280 child1.
value =
"textfield";
289 child1.
rect = {0, 0, rectSize, rectSize};
290 child1.
transform = {transformFactor, 0, 0, 0, transformFactor, 0, 0, 0, 1};
291 bridge->AddFlutterSemanticsNodeUpdate(child1);
293 bridge->CommitUpdates();
295 auto child_platform_node_delegate = bridge->GetFlutterPlatformNodeDelegateFromID(1).lock();
297 id native_accessibility = child_platform_node_delegate->GetNativeViewAccessible();
298 EXPECT_EQ([native_accessibility isKindOfClass:[
FlutterTextField class]], YES);
302 CGRect scaledBounds = [
view convertRectToBacking:
view.bounds];
303 CGSize scaledSize = scaledBounds.size;
304 double pixelRatio =
view.bounds.size.width == 0 ? 1 : scaledSize.width /
view.bounds.size.width;
306 double expectedFrameSize = rectSize * transformFactor / pixelRatio;
307 EXPECT_EQ(NSEqualRects(native_text_field.frame, NSMakeRect(0, 600 - expectedFrameSize,
308 expectedFrameSize, expectedFrameSize)),
311 [native_text_field startEditing];
312 EXPECT_EQ([native_text_field.stringValue isEqualToString:
@"textfield"], YES);
321 NSWindow*
window = [[NSWindow alloc] initWithContentRect:NSMakeRect(0, 0, 800, 600)
322 styleMask:NSBorderlessWindowMask
323 backing:NSBackingStoreBuffered
326 engine.semanticsEnabled = YES;
343 int32_t children[] = {1};
347 root.
rect = {0, 0, 100, 100};
348 root.
transform = {1, 0, 0, 0, 1, 0, 0, 0, 1};
349 bridge->AddFlutterSemanticsNodeUpdate(root);
351 double rectSize = 50;
352 double transformFactor = 0.5;
356 child1.
flags2 = &child_flags;
362 child1.
value =
"textfield";
371 child1.
rect = {0, 0, rectSize, rectSize};
372 child1.
transform = {transformFactor, 0, 0, 0, transformFactor, 0, 0, 0, 1};
373 bridge->AddFlutterSemanticsNodeUpdate(child1);
375 bridge->CommitUpdates();
377 auto child_platform_node_delegate = bridge->GetFlutterPlatformNodeDelegateFromID(1).lock();
379 id native_accessibility = child_platform_node_delegate->GetNativeViewAccessible();
380 EXPECT_TRUE([[native_accessibility className] isEqualToString:
@"AXPlatformNodeCocoa"]);
385 child1.
flags2 = &child_flags_updated_1;
386 bridge->AddFlutterSemanticsNodeUpdate(child1);
387 bridge->CommitUpdates();
389 native_accessibility = child_platform_node_delegate->GetNativeViewAccessible();
393 child1.
flags2 = &child_flags_updated_2;
394 bridge->AddFlutterSemanticsNodeUpdate(child1);
395 bridge->CommitUpdates();
397 native_accessibility = child_platform_node_delegate->GetNativeViewAccessible();
398 EXPECT_TRUE([[native_accessibility className] isEqualToString:
@"AXPlatformNodeCocoa"]);