5#import <XCTest/XCTest.h>
16 self.continueAfterFailure = NO;
20 XCUIApplication*
app = [[XCUIApplication alloc] init];
21 app.launchArguments = @[ @"--gesture-reject-after-touches-ended" ];
24 NSPredicate* predicateToFindPlatformView =
25 [NSPredicate predicateWithBlock:^BOOL(id _Nullable evaluatedObject,
26 NSDictionary<NSString*, id>* _Nullable bindings) {
27 XCUIElement* element = evaluatedObject;
28 return [element.identifier hasPrefix:@"platform_view"];
30 XCUIElement* textView =
31 [app.otherElements elementMatchingPredicate:predicateToFindPlatformView].textViews.firstMatch;
33 NSLog(
@"%@",
app.debugDescription);
34 XCTFail(
@"Failed due to not able to find any textView with %@ seconds",
38 XCTAssertNotNil(textView);
39 XCTAssertEqualObjects(textView.label,
@"");
41 NSPredicate* predicate =
42 [NSPredicate predicateWithFormat:@"label == %@", @"-gestureTouchesBegan-gestureTouchesEnded"];
43 XCTNSPredicateExpectation* exception =
44 [[XCTNSPredicateExpectation alloc] initWithPredicate:predicate object:textView];
47 [
self waitForExpectations:@[ exception ] timeout:kSecondsToWaitForPlatformView];
48 XCTAssertEqualObjects(textView.label,
@"-gestureTouchesBegan-gestureTouchesEnded");
52 XCUIApplication*
app = [[XCUIApplication alloc] init];
53 app.launchArguments = @[ @"--gesture-reject-eager" ];
56 NSPredicate* predicateToFindPlatformView =
57 [NSPredicate predicateWithBlock:^BOOL(id _Nullable evaluatedObject,
58 NSDictionary<NSString*, id>* _Nullable bindings) {
59 XCUIElement* element = evaluatedObject;
60 return [element.identifier hasPrefix:@"platform_view"];
62 XCUIElement* textView =
63 [app.otherElements elementMatchingPredicate:predicateToFindPlatformView].textViews.firstMatch;
65 NSLog(
@"%@",
app.debugDescription);
66 XCTFail(
@"Failed due to not able to find any textView with %@ seconds",
70 XCTAssertNotNil(textView);
71 XCTAssertEqualObjects(textView.label,
@"");
73 NSPredicate* predicate =
74 [NSPredicate predicateWithBlock:^BOOL(id _Nullable evaluatedObject,
75 NSDictionary<NSString*, id>* _Nullable bindings) {
76 XCUIElement* view = (XCUIElement*)evaluatedObject;
77 return [view.label containsString:@"-gestureTouchesBegan"];
79 XCTNSPredicateExpectation* exception =
80 [[XCTNSPredicateExpectation alloc] initWithPredicate:predicate object:textView];
83 [
self waitForExpectations:@[ exception ] timeout:kSecondsToWaitForPlatformView];
84 XCTAssertTrue([textView.label containsString:
@"-gestureTouchesBegan"]);
88 XCUIApplication*
app = [[XCUIApplication alloc] init];
89 app.launchArguments = @[ @"--gesture-accept" ];
92 NSPredicate* predicateToFindPlatformView =
93 [NSPredicate predicateWithBlock:^BOOL(id _Nullable evaluatedObject,
94 NSDictionary<NSString*, id>* _Nullable bindings) {
95 XCUIElement* element = evaluatedObject;
96 return [element.identifier hasPrefix:@"platform_view"];
98 XCUIElement* textView =
99 [app.otherElements elementMatchingPredicate:predicateToFindPlatformView].textViews.firstMatch;
101 NSLog(
@"%@",
app.debugDescription);
102 XCTFail(
@"Failed due to not able to find any textView with %@ seconds",
106 XCTAssertNotNil(textView);
107 XCTAssertEqualObjects(textView.label,
@"");
109 NSPredicate* predicate = [NSPredicate
110 predicateWithFormat:@"label == %@",
111 @"-gestureTouchesBegan-gestureTouchesEnded-platformViewTapped"];
112 XCTNSPredicateExpectation* exception =
113 [[XCTNSPredicateExpectation alloc] initWithPredicate:predicate object:textView];
117 [
self waitForExpectations:@[ exception ] timeout:kSecondsToWaitForPlatformView];
118 XCTAssertEqualObjects(textView.label,
119 @"-gestureTouchesBegan-gestureTouchesEnded-platformViewTapped");
123 XCUIApplication*
app = [[XCUIApplication alloc] init];
124 app.launchArguments = @[ @"--gesture-accept", @"--maskview-blocking" ];
127 NSPredicate* predicateToFindPlatformView =
128 [NSPredicate predicateWithBlock:^BOOL(id _Nullable evaluatedObject,
129 NSDictionary<NSString*, id>* _Nullable bindings) {
130 XCUIElement* element = evaluatedObject;
131 return [element.identifier hasPrefix:@"platform_view"];
133 XCUIElement* textView =
134 [app.otherElements elementMatchingPredicate:predicateToFindPlatformView].textViews.firstMatch;
136 NSLog(
@"%@",
app.debugDescription);
137 XCTFail(
@"Failed due to not able to find any platformView with %@ seconds",
141 XCTAssertNotNil(textView);
142 XCTAssertEqualObjects(textView.label,
@"");
144 NSPredicate* predicate = [NSPredicate
145 predicateWithFormat:@"label == %@",
146 @"-gestureTouchesBegan-gestureTouchesEnded-platformViewTapped"];
147 XCTNSPredicateExpectation* exception =
148 [[XCTNSPredicateExpectation alloc] initWithPredicate:predicate object:textView];
150 XCUICoordinate* coordinate =
152 point:CGVectorMake(textView.frame.origin.x + 10,
153 textView.frame.origin.y + 10)];
156 [
self waitForExpectations:@[ exception ] timeout:kSecondsToWaitForPlatformView];
157 XCTAssertEqualObjects(textView.label,
158 @"-gestureTouchesBegan-gestureTouchesEnded-platformViewTapped");
161- (XCUICoordinate*)getNormalizedCoordinate:(XCUIApplication*)
app point:(CGVector)vector {
162 XCUICoordinate* appZero = [app coordinateWithNormalizedOffset:CGVectorMake(0, 0)];
163 XCUICoordinate* coordinate = [appZero coordinateWithOffset:vector];
168 XCUIApplication*
app = [[XCUIApplication alloc] init];
169 app.launchArguments = @[ @"--gesture-accept-with-overlapping-platform-views" ];
172 XCUIElement* foreground =
app.otherElements[@"platform_view[0]"];
173 XCTAssertEqual(foreground.frame.origin.x, 50);
174 XCTAssertEqual(foreground.frame.origin.y, 50);
175 XCTAssertEqual(foreground.frame.size.width, 50);
176 XCTAssertEqual(foreground.frame.size.height, 50);
179 XCUIElement* background =
app.otherElements[@"platform_view[1]"];
180 XCTAssertEqual(background.frame.origin.x, 0);
181 XCTAssertEqual(background.frame.origin.y, 0);
182 XCTAssertEqual(background.frame.size.width, 150);
183 XCTAssertEqual(background.frame.size.height, 150);
186 XCUIElement* textView = foreground.textViews.firstMatch;
187 XCTAssertTrue(textView.exists);
189 XCTAssertTrue(foreground.isHittable);
192 XCTAssertEqualObjects(textView.label,
193 @"-gestureTouchesBegan-gestureTouchesEnded-platformViewTapped");