| Flutter iOS Embedder |

SemanticsObjectTest_mrc.mm
Go to the documentation of this file.
1 // Copyright 2013 The Flutter Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #import <OCMock/OCMock.h>
6 #import <XCTest/XCTest.h>
7
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
14 FLUTTER_ASSERT_NOT_ARC
15
16 @interface SemanticsObjectTestMRC : XCTestCase
17 @end
18
19 @implementation SemanticsObjectTestMRC
20
21 - (void)testAccessibilityHitTestSearchCanReturnPlatformView {
22 fml::WeakPtrFactory<flutter::AccessibilityBridgeIos> factory(
23 new flutter::MockAccessibilityBridge());
24 fml::WeakPtr<flutter::AccessibilityBridgeIos> bridge = factory.GetWeakPtr();
25 SemanticsObject* object0 = [[[SemanticsObject alloc] initWithBridge:bridge uid:0] autorelease];
26 SemanticsObject* object1 = [[[SemanticsObject alloc] initWithBridge:bridge uid:1] autorelease];
27 SemanticsObject* object3 = [[[SemanticsObject alloc] initWithBridge:bridge uid:3] autorelease];
28 FlutterTouchInterceptingView* platformView =
29 [[[FlutterTouchInterceptingView alloc] initWithFrame:CGRectMake(0, 0, 100, 100)] autorelease];
30 FlutterPlatformViewSemanticsContainer* platformViewSemanticsContainer =
31 [[[FlutterPlatformViewSemanticsContainer alloc] initWithBridge:bridge
32 uid:1
33 platformView:platformView] autorelease];
34
35 object0.children = @[ object1 ];
36 object0.childrenInHitTestOrder = @[ object1 ];
37 object1.children = @[ platformViewSemanticsContainer, object3 ];
38 object1.childrenInHitTestOrder = @[ platformViewSemanticsContainer, object3 ];
39
40 flutter::SemanticsNode node0;
41 node0.id = 0;
42 node0.rect = SkRect::MakeXYWH(0, 0, 200, 200);
43 node0.label = "0";
44 [object0 setSemanticsNode:&node0];
45
46 flutter::SemanticsNode node1;
47 node1.id = 1;
48 node1.rect = SkRect::MakeXYWH(0, 0, 200, 200);
49 node1.label = "1";
50 [object1 setSemanticsNode:&node1];
51
52 flutter::SemanticsNode node2;
53 node2.id = 2;
54 node2.rect = SkRect::MakeXYWH(0, 0, 100, 100);
55 node2.label = "2";
56 [platformViewSemanticsContainer setSemanticsNode:&node2];
57
58 flutter::SemanticsNode node3;
59 node3.id = 3;
60 node3.rect = SkRect::MakeXYWH(0, 0, 200, 200);
61 node3.label = "3";
62 [object3 setSemanticsNode:&node3];
63
64 CGPoint point = CGPointMake(10, 10);
65 id hitTestResult = [object0 _accessibilityHitTest:point withEvent:nil];
66
67 XCTAssertEqual(hitTestResult, platformView);
68 }
69
70 - (void)testFlutterPlatformViewSemanticsContainer {
71 fml::WeakPtrFactory<flutter::MockAccessibilityBridge> factory(
72 new flutter::MockAccessibilityBridge());
73 fml::WeakPtr<flutter::MockAccessibilityBridge> bridge = factory.GetWeakPtr();
74 FlutterTouchInterceptingView* platformView =
75 [[[FlutterTouchInterceptingView alloc] init] autorelease];
76 @autoreleasepool {
77 FlutterPlatformViewSemanticsContainer* container =
78 [[[FlutterPlatformViewSemanticsContainer alloc] initWithBridge:bridge
79 uid:1
80 platformView:platformView] autorelease];
81 XCTAssertEqualObjects(platformView.accessibilityContainer, container);
82 XCTAssertEqual(platformView.retainCount, 2u);
83 }
84 // Check if there's no more strong references to `platformView` after container and platformView
85 // are released.
86 XCTAssertEqual(platformView.retainCount, 1u);
87 }
88
89 @end
-[FlutterTouchInterceptingView accessibilityContainer]
id accessibilityContainer()
SemanticsObjectTestMocks.h
FLUTTER_ASSERT_NOT_ARC
Definition: VsyncWaiterIosTest.mm:15
-[SemanticsObject setSemanticsNode:]
void setSemanticsNode:(const flutter::SemanticsNode *NS_REQUIRES_SUPER)
Definition: SemanticsObject.mm:352
FlutterMacros.h
SemanticsObject::childrenInHitTestOrder
NSArray< SemanticsObject * > * childrenInHitTestOrder
Definition: SemanticsObject.h:73
-[SemanticsObject _accessibilityHitTest:withEvent:]
id _accessibilityHitTest:withEvent:(CGPoint point,[withEvent] UIEvent *event)
FlutterPlatformViews_Internal.h
SemanticsObject::children
NSArray< SemanticsObject * > * children
Definition: SemanticsObject.h:67
SemanticsObject.h
FlutterPlatformViewSemanticsContainer
Definition: SemanticsObject.h:168
FlutterTouchInterceptingView
Definition: FlutterPlatformViews.mm:961
FlutterTouchInterceptingView_Test.h
SemanticsObjectTestMRC
Definition: SemanticsObjectTest_mrc.mm:16
SemanticsObject
Definition: SemanticsObject.h:30