5#import <XCTest/XCTest.h>
16 self.continueAfterFailure = NO;
24- (void)testNoOverlay {
25 XCUIApplication* app = [[XCUIApplication alloc] init];
26 app.launchArguments = @[ @"--platform-view-no-overlay-intersection" ];
29 XCUIElement*
platform_view = app.otherElements[@"platform_view[0]"];
30 XCTAssertTrue([
platform_view waitForExistenceWithTimeout:1.0]);
36 XCUIElement* overlay = app.otherElements[@"platform_view[0].overlay[0]"];
37 XCTAssertFalse(overlay.exists);
46- (void)testOneOverlay {
47 XCUIApplication* app = [[XCUIApplication alloc] init];
48 app.launchArguments = @[ @"--platform-view" ];
51 XCUIElement*
platform_view = app.otherElements[@"platform_view[0]"];
52 XCTAssertTrue([
platform_view waitForExistenceWithTimeout:1.0]);
58 XCUIElement* overlay = app.otherElements[@"platform_view[0].overlay[0]"];
59 XCTAssertTrue(overlay.exists);
60 XCTAssertEqual(overlay.frame.origin.x, 150);
61 XCTAssertEqual(overlay.frame.origin.y, 150);
62 XCTAssertEqual(overlay.frame.size.width, 50);
63 XCTAssertEqual(overlay.frame.size.height, 50);
65 XCUIElement* overlayView = app.otherElements[@"platform_view[0].overlay_view[0]"];
66 XCTAssertTrue(overlayView.exists);
68 XCTAssertEqualWithAccuracy(overlayView.frame.origin.x, app.frame.origin.x,
kCompareAccuracy);
69 XCTAssertEqualWithAccuracy(overlayView.frame.origin.y, app.frame.origin.x,
kCompareAccuracy);
70 XCTAssertEqualWithAccuracy(overlayView.frame.size.width, app.frame.size.width,
kCompareAccuracy);
71 XCTAssertEqualWithAccuracy(overlayView.frame.size.height, app.frame.size.height,
80- (void)testOneOverlayPartialIntersection {
81 XCUIApplication* app = [[XCUIApplication alloc] init];
82 app.launchArguments = @[ @"--platform-view-partial-intersection" ];
85 XCUIElement*
platform_view = app.otherElements[@"platform_view[0]"];
86 XCTAssertTrue([
platform_view waitForExistenceWithTimeout:1.0]);
92 XCUIElement* overlay = app.otherElements[@"platform_view[0].overlay[0]"];
93 XCTAssertTrue(overlay.exists);
94 XCTAssertEqual(overlay.frame.origin.x, 200);
95 XCTAssertEqual(overlay.frame.origin.y, 245);
96 XCTAssertEqual(overlay.frame.size.width, 50);
98 XCTAssertEqual(overlay.frame.size.height, 5);
100 XCUIElement* overlayView = app.otherElements[@"platform_view[0].overlay_view[0]"];
101 XCTAssertTrue(overlayView.exists);
103 XCTAssertEqualWithAccuracy(overlayView.frame.origin.x, app.frame.origin.x,
kCompareAccuracy);
104 XCTAssertEqualWithAccuracy(overlayView.frame.origin.y, app.frame.origin.x,
kCompareAccuracy);
105 XCTAssertEqualWithAccuracy(overlayView.frame.size.width, app.frame.size.width,
kCompareAccuracy);
106 XCTAssertEqualWithAccuracy(overlayView.frame.size.height, app.frame.size.height,
117- (void)testTwoIntersectingOverlays {
118 XCUIApplication* app = [[XCUIApplication alloc] init];
119 app.launchArguments = @[ @"--platform-view-two-intersecting-overlays" ];
122 XCUIElement*
platform_view = app.otherElements[@"platform_view[0]"];
123 XCTAssertTrue([
platform_view waitForExistenceWithTimeout:1.0]);
129 XCUIElement* overlay = app.otherElements[@"platform_view[0].overlay[0]"];
130 XCTAssertTrue(overlay.exists);
131 XCTAssertEqual(overlay.frame.origin.x, 150);
132 XCTAssertEqual(overlay.frame.origin.y, 150);
133 XCTAssertEqual(overlay.frame.size.width, 75);
134 XCTAssertEqual(overlay.frame.size.height, 75);
136 XCTAssertFalse(app.otherElements[
@"platform_view[0].overlay[1]"].exists);
146- (void)testOneOverlayAndTwoIntersectingOverlays {
147 XCUIApplication* app = [[XCUIApplication alloc] init];
148 app.launchArguments = @[ @"--platform-view-one-overlay-two-intersecting-overlays" ];
151 XCUIElement*
platform_view = app.otherElements[@"platform_view[0]"];
152 XCTAssertTrue([
platform_view waitForExistenceWithTimeout:1.0]);
158 XCUIElement* overlay1 = app.otherElements[@"platform_view[0].overlay[0]"];
159 XCTAssertTrue(overlay1.exists);
160 XCTAssertEqual(overlay1.frame.origin.x, 75);
161 XCTAssertEqual(overlay1.frame.origin.y, 150);
162 XCTAssertEqual(overlay1.frame.size.width, 150);
163 XCTAssertEqual(overlay1.frame.size.height, 100);
167 XCTAssertFalse(app.otherElements[
@"platform_view[0].overlay[1]"].exists);
169 XCUIElement* overlayView0 = app.otherElements[@"platform_view[0].overlay_view[0]"];
170 XCTAssertTrue(overlayView0.exists);
172 XCTAssertEqualWithAccuracy(overlayView0.frame.origin.x, app.frame.origin.x,
kCompareAccuracy);
173 XCTAssertEqualWithAccuracy(overlayView0.frame.origin.y, app.frame.origin.x,
kCompareAccuracy);
174 XCTAssertEqualWithAccuracy(overlayView0.frame.size.width, app.frame.size.width,
kCompareAccuracy);
175 XCTAssertEqualWithAccuracy(overlayView0.frame.size.height, app.frame.size.height,
186- (void)testMultiplePlatformViewsWithoutOverlays {
187 XCUIApplication* app = [[XCUIApplication alloc] init];
188 app.launchArguments = @[ @"--platform-view-multiple-without-overlays" ];
191 XCUIElement* platform_view1 = app.otherElements[@"platform_view[0]"];
192 XCTAssertTrue([platform_view1 waitForExistenceWithTimeout:1.0]);
193 XCTAssertEqual(platform_view1.frame.origin.x, 0);
194 XCTAssertEqual(platform_view1.frame.origin.y, 300);
195 XCTAssertEqual(platform_view1.frame.size.width, 250);
196 XCTAssertEqual(platform_view1.frame.size.height, 250);
198 XCUIElement* platform_view2 = app.otherElements[@"platform_view[1]"];
199 XCTAssertTrue(platform_view2.exists);
200 XCTAssertEqual(platform_view2.frame.origin.x, 0);
201 XCTAssertEqual(platform_view2.frame.origin.y, 0);
202 XCTAssertEqual(platform_view2.frame.size.width, 250);
203 XCTAssertEqual(platform_view2.frame.size.height, 250);
205 XCTAssertFalse(app.otherElements[
@"platform_view[0].overlay[0]"].exists);
206 XCTAssertFalse(app.otherElements[
@"platform_view[1].overlay[0]"].exists);
207 XCTAssertFalse(app.otherElements[
@"platform_view[0].overlay_view[0]"].exists);
208 XCTAssertFalse(app.otherElements[
@"platform_view[1].overlay_view[0]"].exists);
218- (void)testMultiplePlatformViewsWithOverlays {
219 XCUIApplication* app = [[XCUIApplication alloc] init];
220 app.launchArguments = @[ @"--platform-view-multiple-background-foreground" ];
223 XCUIElement* platform_view1 = app.otherElements[@"platform_view[0]"];
224 XCTAssertTrue([platform_view1 waitForExistenceWithTimeout:1.0]);
225 XCTAssertEqual(platform_view1.frame.origin.x, 25);
226 XCTAssertEqual(platform_view1.frame.origin.y, 300);
227 XCTAssertEqual(platform_view1.frame.size.width, 250);
228 XCTAssertEqual(platform_view1.frame.size.height, 250);
230 XCUIElement* platform_view2 = app.otherElements[@"platform_view[1]"];
231 XCTAssertTrue(platform_view2.exists);
232 XCTAssertEqual(platform_view2.frame.origin.x, 25);
233 XCTAssertEqual(platform_view2.frame.origin.y, 0);
234 XCTAssertEqual(platform_view2.frame.size.width, 250);
235 XCTAssertEqual(platform_view2.frame.size.height, 250);
237 XCUIElement* overlay1 = app.otherElements[@"platform_view[1].overlay[0]"];
238 XCTAssertTrue(overlay1.exists);
239 XCTAssertEqual(overlay1.frame.origin.x, 25);
240 XCTAssertEqual(overlay1.frame.origin.y, 0);
241 XCTAssertEqual(overlay1.frame.size.width, 225);
242 XCTAssertEqual(overlay1.frame.size.height, 500);
244 XCUIElement* overlayView0 = app.otherElements[@"platform_view[1].overlay_view[0]"];
245 XCTAssertTrue(overlayView0.exists);
247 XCTAssertEqualWithAccuracy(overlayView0.frame.origin.x, app.frame.origin.x,
kCompareAccuracy);
248 XCTAssertEqualWithAccuracy(overlayView0.frame.origin.y, app.frame.origin.x,
kCompareAccuracy);
249 XCTAssertEqualWithAccuracy(overlayView0.frame.size.width, app.frame.size.width,
kCompareAccuracy);
250 XCTAssertEqualWithAccuracy(overlayView0.frame.size.height, app.frame.size.height,
262- (void)testPlatformViewsMaxOverlays {
263 XCUIApplication* app = [[XCUIApplication alloc] init];
264 app.launchArguments = @[ @"--platform-view-max-overlays" ];
267 XCUIElement*
platform_view = app.otherElements[@"platform_view[0]"];
268 XCTAssertTrue([
platform_view waitForExistenceWithTimeout:1.0]);
274 XCUIElement* overlay = app.otherElements[@"platform_view[0].overlay[0]"];
275 XCTAssertTrue(overlay.exists);
276 XCTAssertFalse(app.otherElements[
@"platform_view[0].overlay[1]"].exists);
277 XCTAssertTrue(CGRectContainsRect(
platform_view.frame, overlay.frame));
279 XCUIElement* overlayView0 = app.otherElements[@"platform_view[0].overlay_view[0]"];
280 XCTAssertTrue(overlayView0.exists);
282 XCTAssertEqualWithAccuracy(overlayView0.frame.origin.x, app.frame.origin.x,
kCompareAccuracy);
283 XCTAssertEqualWithAccuracy(overlayView0.frame.origin.y, app.frame.origin.x,
kCompareAccuracy);
284 XCTAssertEqualWithAccuracy(overlayView0.frame.size.width, app.frame.size.width,
kCompareAccuracy);
285 XCTAssertEqualWithAccuracy(overlayView0.frame.size.height, app.frame.size.height,
288 XCUIElement* overlayView1 = app.otherElements[@"platform_view[0].overlay_view[1]"];
289 XCTAssertFalse(overlayView1.exists);
300- (void)testPlatformViewsWithAdjacentSurroundingLayersAndFractionalCoordinate {
301 XCUIApplication* app = [[XCUIApplication alloc] init];
302 app.launchArguments = @[ @"--platform-view-surrounding-layers-fractional-coordinate" ];
305 XCUIElement*
platform_view = app.otherElements[@"platform_view[0]"];
306 XCTAssertTrue([
platform_view waitForExistenceWithTimeout:1.0]);
308 CGFloat scale = [UIScreen mainScreen].scale;
312 XCTAssertEqual(
platform_view.frame.size.height * scale, 100);
314 XCUIElement* overlay = app.otherElements[@"platform_view[0].overlay[0]"];
315 XCTAssertFalse(overlay.exists);
326- (void)testPlatformViewsWithPartialIntersectionAndFractionalCoordinate {
327 XCUIApplication* app = [[XCUIApplication alloc] init];
328 app.launchArguments = @[ @"--platform-view-partial-intersection-fractional-coordinate" ];
331 XCUIElement*
platform_view = app.otherElements[@"platform_view[0]"];
332 XCTAssertTrue([
platform_view waitForExistenceWithTimeout:1.0]);
334 CGFloat scale = [UIScreen mainScreen].scale;
338 XCTAssertEqual(
platform_view.frame.size.height * scale, 100);
340 XCUIElement* overlay = app.otherElements[@"platform_view[0].overlay[0]"];
341 XCTAssert(overlay.exists);
344 XCTAssertEqual(CGRectGetMaxX(overlay.frame) * scale, 101);
345 XCTAssertEqual(CGRectGetMaxY(overlay.frame) * scale, 101);