Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
PlatformViewUITests.m
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
6
7static const NSInteger kSecondsToWaitForPlatformView = 30;
8
10
11@end
12
13@implementation PlatformViewUITests
14
15- (instancetype)initWithInvocation:(NSInvocation*)invocation {
16 GoldenTestManager* manager = [[GoldenTestManager alloc] initWithLaunchArg:@"--platform-view"];
17 return [super initWithManager:manager invocation:invocation];
18}
19
20- (void)testPlatformView {
22}
23
24@end
25
27
28@end
29
31
32- (instancetype)initWithInvocation:(NSInvocation*)invocation {
33 GoldenTestManager* manager =
34 [[GoldenTestManager alloc] initWithLaunchArg:@"--non-full-screen-flutter-view-platform-view"];
35 return [super initWithManager:manager invocation:invocation];
36}
37
38- (void)testPlatformView {
40}
41
42@end
43
45
46@end
47
48@implementation MultiplePlatformViewsTest
49
50- (instancetype)initWithInvocation:(NSInvocation*)invocation {
51 GoldenTestManager* manager =
52 [[GoldenTestManager alloc] initWithLaunchArg:@"--platform-view-multiple"];
53 return [super initWithManager:manager invocation:invocation];
54}
55
56- (void)testPlatformView {
58}
59
60@end
61
63
64@end
65
67
68- (instancetype)initWithInvocation:(NSInvocation*)invocation {
69 GoldenTestManager* manager = [[GoldenTestManager alloc]
70 initWithLaunchArg:@"--platform-view-multiple-background-foreground"];
71 return [super initWithManager:manager invocation:invocation];
72}
73
74- (void)testPlatformView {
75 [[XCUIDevice sharedDevice] pressButton:XCUIDeviceButtonHome];
76 [self.application activate];
78}
79
80@end
81
82// Clip Rect Tests
84
85@end
86
88
89- (instancetype)initWithInvocation:(NSInvocation*)invocation {
90 GoldenTestManager* manager =
91 [[GoldenTestManager alloc] initWithLaunchArg:@"--platform-view-cliprect"];
92 return [super initWithManager:manager invocation:invocation];
93}
94
95- (void)testPlatformView {
97}
98
99@end
100
102
103@end
104
106
107- (instancetype)initWithInvocation:(NSInvocation*)invocation {
108 GoldenTestManager* manager =
109 [[GoldenTestManager alloc] initWithLaunchArg:@"--platform-view-cliprect-after-moved"];
110 return [super initWithManager:manager invocation:invocation];
111}
112
113- (void)testPlatformView {
114 // This test needs to wait for several frames for the PlatformView to settle to
115 // the correct position. The PlatformView accessiblity is set to platform_view[10000] when it is
116 // ready.
117 XCUIElement* element = self.application.otherElements[@"platform_view[10000]"];
118 BOOL exists = [element waitForExistenceWithTimeout:kSecondsToWaitForPlatformView];
119 if (!exists) {
120 XCTFail(@"It took longer than %@ second to find the platform view."
121 @"There might be issues with the platform view's construction,"
122 @"or with how the scenario is built.",
124 }
125
127}
128
129@end
130
132
133@end
134
136
137- (instancetype)initWithInvocation:(NSInvocation*)invocation {
138 GoldenTestManager* manager =
139 [[GoldenTestManager alloc] initWithLaunchArg:@"--platform-view-cliprrect"];
140 return [super initWithManager:manager invocation:invocation];
141}
142
143- (void)testPlatformView {
145}
146
147@end
148
150
151@end
152
154
155- (instancetype)initWithInvocation:(NSInvocation*)invocation {
156 GoldenTestManager* manager =
157 [[GoldenTestManager alloc] initWithLaunchArg:@"--platform-view-large-cliprrect"];
158 return [super initWithManager:manager invocation:invocation];
159}
160
161- (void)testPlatformView {
163}
164
165@end
166
168
169@end
170
172
173- (instancetype)initWithInvocation:(NSInvocation*)invocation {
174 GoldenTestManager* manager =
175 [[GoldenTestManager alloc] initWithLaunchArg:@"--platform-view-clippath"];
176 return [super initWithManager:manager invocation:invocation];
177}
178
179- (void)testPlatformView {
181}
182
183@end
184
186
187@end
188
190
191- (instancetype)initWithInvocation:(NSInvocation*)invocation {
192 GoldenTestManager* manager =
193 [[GoldenTestManager alloc] initWithLaunchArg:@"--platform-view-cliprect-with-transform"];
194 return [super initWithManager:manager invocation:invocation];
195}
196
197- (void)testPlatformView {
199}
200
201@end
202
204
205@end
206
208
209- (instancetype)initWithInvocation:(NSInvocation*)invocation {
210 GoldenTestManager* manager =
211 [[GoldenTestManager alloc] initWithLaunchArg:@"--platform-view-cliprrect-with-transform"];
212 return [super initWithManager:manager invocation:invocation];
213}
214
215- (void)testPlatformView {
217}
218
219@end
220
222
223@end
224
226
227- (instancetype)initWithInvocation:(NSInvocation*)invocation {
228 GoldenTestManager* manager = [[GoldenTestManager alloc]
229 initWithLaunchArg:@"--platform-view-large-cliprrect-with-transform"];
230 return [super initWithManager:manager invocation:invocation];
231}
232
233- (void)testPlatformView {
235}
236
237@end
238
240
241@end
242
244
245- (instancetype)initWithInvocation:(NSInvocation*)invocation {
246 GoldenTestManager* manager =
247 [[GoldenTestManager alloc] initWithLaunchArg:@"--platform-view-clippath-with-transform"];
248 return [super initWithManager:manager invocation:invocation];
249}
250
251- (void)testPlatformView {
253}
254
255@end
256
258
259@end
260
261@implementation TwoPlatformViewClipRectTests
262
263- (instancetype)initWithInvocation:(NSInvocation*)invocation {
264 GoldenTestManager* manager =
265 [[GoldenTestManager alloc] initWithLaunchArg:@"--two-platform-view-clip-rect"];
266 return [super initWithManager:manager invocation:invocation];
267}
268
269- (void)testPlatformView {
271}
272
273@end
274
276
277@end
278
279@implementation TwoPlatformViewClipRRectTests
280
281- (instancetype)initWithInvocation:(NSInvocation*)invocation {
282 GoldenTestManager* manager =
283 [[GoldenTestManager alloc] initWithLaunchArg:@"--two-platform-view-clip-rrect"];
284 return [super initWithManager:manager invocation:invocation];
285}
286
287- (void)testPlatformView {
289}
290
291@end
292
294
295@end
296
297@implementation TwoPlatformViewClipPathTests
298
299- (instancetype)initWithInvocation:(NSInvocation*)invocation {
300 GoldenTestManager* manager =
301 [[GoldenTestManager alloc] initWithLaunchArg:@"--two-platform-view-clip-path"];
302 return [super initWithManager:manager invocation:invocation];
303}
304
305- (void)testPlatformView {
307}
308
309@end
310
312
313@end
314
316
317- (instancetype)initWithInvocation:(NSInvocation*)invocation {
318 GoldenTestManager* manager =
319 [[GoldenTestManager alloc] initWithLaunchArg:@"--platform-view-transform"];
320 return [super initWithManager:manager invocation:invocation];
321}
322
323- (void)testPlatformView {
325}
326
327@end
328
330
331@end
332
334
335- (instancetype)initWithInvocation:(NSInvocation*)invocation {
336 GoldenTestManager* manager =
337 [[GoldenTestManager alloc] initWithLaunchArg:@"--platform-view-opacity"];
338 return [super initWithManager:manager invocation:invocation];
339}
340
341- (void)testPlatformView {
343}
344
345@end
346
348
349@end
350
352
353- (instancetype)initWithInvocation:(NSInvocation*)invocation {
354 GoldenTestManager* manager =
355 [[GoldenTestManager alloc] initWithLaunchArg:@"--platform-view-with-other-backdrop-filter"];
356 return [super initWithManager:manager invocation:invocation];
357}
358
359- (void)testPlatformView {
361}
362
363@end
364
366
367@end
368
370
371- (instancetype)initWithInvocation:(NSInvocation*)invocation {
372 GoldenTestManager* manager = [[GoldenTestManager alloc]
373 initWithLaunchArg:@"--two-platform-views-with-other-backdrop-filter"];
374 return [super initWithManager:manager invocation:invocation];
375}
376
377- (void)testPlatformView {
378 // (TODO)cyanglaz: remove the threshold adjustment after all the ci migrates to macOS13.
379 // https://github.com/flutter/flutter/issues/133207
380 if ([NSProcessInfo processInfo].operatingSystemVersion.majorVersion >= 13) {
381 self.rmseThreadhold = 0.7;
382 }
384}
385
386@end
387
389
390@end
391
393
394- (instancetype)initWithInvocation:(NSInvocation*)invocation {
395 GoldenTestManager* manager = [[GoldenTestManager alloc]
396 initWithLaunchArg:@"--platform-view-with-negative-backdrop-filter"];
397 return [super initWithManager:manager invocation:invocation];
398}
399
400- (void)testPlatformView {
402}
403
404@end
405
407@end
408
409@implementation PlatformViewRotation
410- (instancetype)initWithInvocation:(NSInvocation*)invocation {
411 GoldenTestManager* manager =
412 [[GoldenTestManager alloc] initWithLaunchArg:@"--platform-view-rotate"];
413 return [super initWithManager:manager invocation:invocation];
414}
415
416- (void)tearDown {
417 XCUIDevice.sharedDevice.orientation = UIDeviceOrientationPortrait;
418 [super tearDown];
419}
420
421- (void)testPlatformView {
422 XCUIDevice.sharedDevice.orientation = UIDeviceOrientationLandscapeLeft;
424}
425
426@end
427
429
430@end
431
433
434- (void)setUp {
435 self.continueAfterFailure = NO;
436}
437
438- (void)testPlatformViewWithContinuousTexture {
439 XCUIApplication* app = [[XCUIApplication alloc] init];
440 app.launchArguments =
441 @[ @"--platform-view-with-continuous-texture", @"--with-continuous-texture" ];
442 [app launch];
443
444 XCUIElement* platformView = app.textViews.firstMatch;
445 BOOL exists = [platformView waitForExistenceWithTimeout:kSecondsToWaitForPlatformView];
446 if (!exists) {
447 XCTFail(@"It took longer than %@ second to find the platform view."
448 @"There might be issues with the platform view's construction,"
449 @"or with how the scenario is built.",
451 }
452
453 XCTAssertNotNil(platformView);
454}
455
456@end
457
458@interface PlatformViewScrollingUnderWidget : XCTestCase
459
460@end
461
463
464- (void)setUp {
465 [super setUp];
466 self.continueAfterFailure = NO;
467}
468
469- (void)testPlatformViewScrollingUnderWidget {
470 XCUIApplication* app = [[XCUIApplication alloc] init];
471 app.launchArguments =
472 @[ @"--platform-view-scrolling-under-widget", @"--with-continuous-texture" ];
473 [app launch];
474
475 XCUIElement* platformView = app.textViews.firstMatch;
476 BOOL exists = [platformView waitForExistenceWithTimeout:kSecondsToWaitForPlatformView];
477 if (!exists) {
478 XCTFail(@"It took longer than %@ second to find the platform view."
479 @"There might be issues with the platform view's construction,"
480 @"or with how the scenario is built.",
482 }
483
484 // Wait and let the scenario app scroll a bit.
485 XCTWaiterResult waitResult = [XCTWaiter
486 waitForExpectations:@[ [[XCTestExpectation alloc] initWithDescription:@"Wait for 5 seconds"] ]
487 timeout:5];
488 // If the waiter is not interrupted, we know the app is in a valid state after timeout, thus the
489 // test passes.
490 XCTAssert(waitResult != XCTWaiterResultInterrupted);
491}
492
493@end
494
495@interface PlatformViewWithClipsScrolling : XCTestCase
496
497@end
498
499@implementation PlatformViewWithClipsScrolling
500
501- (void)setUp {
502 [super setUp];
503 self.continueAfterFailure = NO;
504}
505
506- (void)testPlatformViewsWithClipsScrolling {
507 XCUIApplication* app = [[XCUIApplication alloc] init];
508 app.launchArguments =
509 @[ @"--platform-views-with-clips-scrolling", @"platform_views_with_clips_scrolling" ];
510 [app launch];
511
512 XCUIElement* platformView = app.textViews.firstMatch;
513 BOOL exists = [platformView waitForExistenceWithTimeout:kSecondsToWaitForPlatformView];
514 if (!exists) {
515 XCTFail(@"It took longer than %@ second to find the platform view."
516 @"There might be issues with the platform view's construction,"
517 @"or with how the scenario is built.",
519 }
520
521 // Wait and let the scenario app scroll a bit.
522 XCTWaiterResult waitResult = [XCTWaiter
523 waitForExpectations:@[ [[XCTestExpectation alloc] initWithDescription:@"Wait for 5 seconds"] ]
524 timeout:5];
525 // If the waiter is not interrupted, we know the app is in a valid state after timeout, thus the
526 // test passes.
527 XCTAssert(waitResult != XCTWaiterResultInterrupted);
528}
529
530@end
static const NSInteger kSecondsToWaitForPlatformView
static const NSInteger kSecondsToWaitForPlatformView
instancetype initWithManager:invocation:(GoldenTestManager *manager,[invocation] NSInvocation *invocation)
int BOOL