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
101// Clip Rect Tests
103
104@end
105
107
108- (instancetype)initWithInvocation:(NSInvocation*)invocation {
109 GoldenTestManager* manager =
110 [[GoldenTestManager alloc] initWithLaunchArg:@"--platform-view-cliprect-multiple-clips"];
111 return [super initWithManager:manager invocation:invocation];
112}
113
114- (void)testPlatformView {
116}
117
118@end
119
121
122@end
123
125
126- (instancetype)initWithInvocation:(NSInvocation*)invocation {
127 GoldenTestManager* manager =
128 [[GoldenTestManager alloc] initWithLaunchArg:@"--platform-view-cliprect-after-moved"];
129 return [super initWithManager:manager invocation:invocation];
130}
131
132- (void)testPlatformView {
133 // This test needs to wait for several frames for the PlatformView to settle to
134 // the correct position. The PlatformView accessiblity is set to platform_view[10000] when it is
135 // ready.
136 XCUIElement* element = self.application.otherElements[@"platform_view[10000]"];
137 BOOL exists = [element waitForExistenceWithTimeout:kSecondsToWaitForPlatformView];
138 if (!exists) {
139 XCTFail(@"It took longer than %@ second to find the platform view."
140 @"There might be issues with the platform view's construction,"
141 @"or with how the scenario is built.",
143 }
144
146}
147
148@end
149
151
152@end
153
155
156- (instancetype)initWithInvocation:(NSInvocation*)invocation {
157 GoldenTestManager* manager = [[GoldenTestManager alloc]
158 initWithLaunchArg:@"--platform-view-cliprect-after-moved-multiple-clips"];
159 return [super initWithManager:manager invocation:invocation];
160}
161
162- (void)testPlatformView {
163 // This test needs to wait for several frames for the PlatformView to settle to
164 // the correct position. The PlatformView accessiblity is set to platform_view[10000] when it is
165 // ready.
166 XCUIElement* element = self.application.otherElements[@"platform_view[10000]"];
167 BOOL exists = [element waitForExistenceWithTimeout:kSecondsToWaitForPlatformView];
168 if (!exists) {
169 XCTFail(@"It took longer than %@ second to find the platform view."
170 @"There might be issues with the platform view's construction,"
171 @"or with how the scenario is built.",
173 }
174
176}
177
178@end
179
181
182@end
183
185
186- (instancetype)initWithInvocation:(NSInvocation*)invocation {
187 GoldenTestManager* manager =
188 [[GoldenTestManager alloc] initWithLaunchArg:@"--platform-view-cliprrect"];
189 return [super initWithManager:manager invocation:invocation];
190}
191
192- (void)testPlatformView {
194}
195
196@end
197
199
200@end
201
203
204- (instancetype)initWithInvocation:(NSInvocation*)invocation {
205 GoldenTestManager* manager =
206 [[GoldenTestManager alloc] initWithLaunchArg:@"--platform-view-cliprrect-multiple-clips"];
207 return [super initWithManager:manager invocation:invocation];
208}
209
210- (void)testPlatformView {
212}
213
214@end
215
217
218@end
219
221
222- (instancetype)initWithInvocation:(NSInvocation*)invocation {
223 GoldenTestManager* manager =
224 [[GoldenTestManager alloc] initWithLaunchArg:@"--platform-view-large-cliprrect"];
225 return [super initWithManager:manager invocation:invocation];
226}
227
228- (void)testPlatformView {
230}
231
232@end
233
235
236@end
237
239
240- (instancetype)initWithInvocation:(NSInvocation*)invocation {
241 GoldenTestManager* manager = [[GoldenTestManager alloc]
242 initWithLaunchArg:@"--platform-view-large-cliprrect-multiple-clips"];
243 return [super initWithManager:manager invocation:invocation];
244}
245
246- (void)testPlatformView {
248}
249
250@end
251
253
254@end
255
257
258- (instancetype)initWithInvocation:(NSInvocation*)invocation {
259 GoldenTestManager* manager =
260 [[GoldenTestManager alloc] initWithLaunchArg:@"--platform-view-clippath"];
261 return [super initWithManager:manager invocation:invocation];
262}
263
264- (void)testPlatformView {
266}
267
268@end
269
271
272@end
273
275
276- (instancetype)initWithInvocation:(NSInvocation*)invocation {
277 GoldenTestManager* manager =
278 [[GoldenTestManager alloc] initWithLaunchArg:@"--platform-view-clippath-multiple-clips"];
279 return [super initWithManager:manager invocation:invocation];
280}
281
282- (void)testPlatformView {
284}
285
286@end
287
289
290@end
291
293
294- (instancetype)initWithInvocation:(NSInvocation*)invocation {
295 GoldenTestManager* manager =
296 [[GoldenTestManager alloc] initWithLaunchArg:@"--platform-view-cliprect-with-transform"];
297 return [super initWithManager:manager invocation:invocation];
298}
299
300- (void)testPlatformView {
302}
303
304@end
305
307
308@end
309
311
312- (instancetype)initWithInvocation:(NSInvocation*)invocation {
313 GoldenTestManager* manager = [[GoldenTestManager alloc]
314 initWithLaunchArg:@"--platform-view-cliprect-with-transform-multiple-clips"];
315 return [super initWithManager:manager invocation:invocation];
316}
317
318- (void)testPlatformView {
320}
321
322@end
323
325
326@end
327
329
330- (instancetype)initWithInvocation:(NSInvocation*)invocation {
331 GoldenTestManager* manager =
332 [[GoldenTestManager alloc] initWithLaunchArg:@"--platform-view-cliprrect-with-transform"];
333 return [super initWithManager:manager invocation:invocation];
334}
335
336- (void)testPlatformView {
338}
339
340@end
341
343
344@end
345
347
348- (instancetype)initWithInvocation:(NSInvocation*)invocation {
349 GoldenTestManager* manager = [[GoldenTestManager alloc]
350 initWithLaunchArg:@"--platform-view-cliprrect-with-transform-multiple-clips"];
351 return [super initWithManager:manager invocation:invocation];
352}
353
354- (void)testPlatformView {
356}
357
358@end
359
361
362@end
363
365
366- (instancetype)initWithInvocation:(NSInvocation*)invocation {
367 GoldenTestManager* manager = [[GoldenTestManager alloc]
368 initWithLaunchArg:@"--platform-view-large-cliprrect-with-transform"];
369 return [super initWithManager:manager invocation:invocation];
370}
371
372- (void)testPlatformView {
374}
375
376@end
377
380
381@end
382
384
385- (instancetype)initWithInvocation:(NSInvocation*)invocation {
386 GoldenTestManager* manager = [[GoldenTestManager alloc]
387 initWithLaunchArg:@"--platform-view-large-cliprrect-with-transform-multiple-clips"];
388 return [super initWithManager:manager invocation:invocation];
389}
390
391- (void)testPlatformView {
392 [self checkPlatformViewGolden];
393}
394
395@end
396
398
399@end
400
402
403- (instancetype)initWithInvocation:(NSInvocation*)invocation {
404 GoldenTestManager* manager =
405 [[GoldenTestManager alloc] initWithLaunchArg:@"--platform-view-clippath-with-transform"];
406 return [super initWithManager:manager invocation:invocation];
407}
408
409- (void)testPlatformView {
411}
412
413@end
414
416
417@end
418
420
421- (instancetype)initWithInvocation:(NSInvocation*)invocation {
422 GoldenTestManager* manager = [[GoldenTestManager alloc]
423 initWithLaunchArg:@"--platform-view-clippath-with-transform-multiple-clips"];
424 return [super initWithManager:manager invocation:invocation];
425}
426
427- (void)testPlatformView {
429}
430
431@end
432
434
435@end
436
437@implementation TwoPlatformViewClipRectTests
438
439- (instancetype)initWithInvocation:(NSInvocation*)invocation {
440 GoldenTestManager* manager =
441 [[GoldenTestManager alloc] initWithLaunchArg:@"--two-platform-view-clip-rect"];
442 return [super initWithManager:manager invocation:invocation];
443}
444
445- (void)testPlatformView {
447}
448
449@end
450
452
453@end
454
456
457- (instancetype)initWithInvocation:(NSInvocation*)invocation {
458 GoldenTestManager* manager =
459 [[GoldenTestManager alloc] initWithLaunchArg:@"--two-platform-view-clip-rect-multiple-clips"];
460 return [super initWithManager:manager invocation:invocation];
461}
462
463- (void)testPlatformView {
465}
466
467@end
468
470
471@end
472
473@implementation TwoPlatformViewClipRRectTests
474
475- (instancetype)initWithInvocation:(NSInvocation*)invocation {
476 GoldenTestManager* manager =
477 [[GoldenTestManager alloc] initWithLaunchArg:@"--two-platform-view-clip-rrect"];
478 return [super initWithManager:manager invocation:invocation];
479}
480
481- (void)testPlatformView {
483}
484
485@end
486
488
489@end
490
492
493- (instancetype)initWithInvocation:(NSInvocation*)invocation {
494 GoldenTestManager* manager = [[GoldenTestManager alloc]
495 initWithLaunchArg:@"--two-platform-view-clip-rrect-multiple-clips"];
496 return [super initWithManager:manager invocation:invocation];
497}
498
499- (void)testPlatformView {
501}
502
503@end
504
506
507@end
508
509@implementation TwoPlatformViewClipPathTests
510
511- (instancetype)initWithInvocation:(NSInvocation*)invocation {
512 GoldenTestManager* manager =
513 [[GoldenTestManager alloc] initWithLaunchArg:@"--two-platform-view-clip-path"];
514 return [super initWithManager:manager invocation:invocation];
515}
516
517- (void)testPlatformView {
519}
520
521@end
522
524
525@end
526
528
529- (instancetype)initWithInvocation:(NSInvocation*)invocation {
530 GoldenTestManager* manager =
531 [[GoldenTestManager alloc] initWithLaunchArg:@"--two-platform-view-clip-path-multiple-clips"];
532 return [super initWithManager:manager invocation:invocation];
533}
534
535- (void)testPlatformView {
537}
538
539@end
540
542
543@end
544
546
547- (instancetype)initWithInvocation:(NSInvocation*)invocation {
548 GoldenTestManager* manager =
549 [[GoldenTestManager alloc] initWithLaunchArg:@"--platform-view-transform"];
550 return [super initWithManager:manager invocation:invocation];
551}
552
553- (void)testPlatformView {
555}
556
557@end
558
560
561@end
562
564
565- (instancetype)initWithInvocation:(NSInvocation*)invocation {
566 GoldenTestManager* manager =
567 [[GoldenTestManager alloc] initWithLaunchArg:@"--platform-view-opacity"];
568 return [super initWithManager:manager invocation:invocation];
569}
570
571- (void)testPlatformView {
573}
574
575@end
576
578
579@end
580
582
583- (instancetype)initWithInvocation:(NSInvocation*)invocation {
584 GoldenTestManager* manager =
585 [[GoldenTestManager alloc] initWithLaunchArg:@"--platform-view-with-other-backdrop-filter"];
586 return [super initWithManager:manager invocation:invocation];
587}
588
589- (void)testPlatformView {
590 // This is increased to account for the usage of gaussian blur which doesn't
591 // converge into golden images.
592 // https://github.com/flutter/flutter/issues/168497
593 self.rmseThreadhold = 0.7;
595}
596
597@end
598
600
601@end
602
604
605- (instancetype)initWithInvocation:(NSInvocation*)invocation {
606 GoldenTestManager* manager = [[GoldenTestManager alloc]
607 initWithLaunchArg:@"--two-platform-views-with-other-backdrop-filter"];
608 return [super initWithManager:manager invocation:invocation];
609}
610
611- (void)testPlatformView {
612 // This is increased to account for the usage of gaussian blur which doesn't
613 // converge into golden images.
614 // https://github.com/flutter/flutter/issues/168497
615 self.rmseThreadhold = 1.5;
617}
618
619@end
620
622
623@end
624
626
627- (instancetype)initWithInvocation:(NSInvocation*)invocation {
628 GoldenTestManager* manager = [[GoldenTestManager alloc]
629 initWithLaunchArg:@"--platform-view-with-negative-backdrop-filter"];
630 return [super initWithManager:manager invocation:invocation];
631}
632
633- (void)testPlatformView {
634 // This is increased to account for the usage of gaussian blur which doesn't
635 // converge into golden images.
636 // https://github.com/flutter/flutter/issues/168497
637 self.rmseThreadhold = 1.0;
639}
640
641@end
642
644@end
645
646@implementation PlatformViewRotation
647- (instancetype)initWithInvocation:(NSInvocation*)invocation {
648 GoldenTestManager* manager =
649 [[GoldenTestManager alloc] initWithLaunchArg:@"--platform-view-rotate"];
650 return [super initWithManager:manager invocation:invocation];
651}
652
653- (void)tearDown {
654 XCUIDevice.sharedDevice.orientation = UIDeviceOrientationPortrait;
655 [super tearDown];
656}
657
658- (void)testPlatformView {
659 XCUIDevice.sharedDevice.orientation = UIDeviceOrientationLandscapeLeft;
661}
662
663@end
664
666
667@end
668
670
671- (void)setUp {
672 self.continueAfterFailure = NO;
673}
674
675- (void)testPlatformViewWithContinuousTexture {
676 XCUIApplication* app = [[XCUIApplication alloc] init];
677 app.launchArguments =
678 @[ @"--platform-view-with-continuous-texture", @"--with-continuous-texture" ];
679 [app launch];
680
681 XCUIElement* platformView = app.textViews.firstMatch;
682 BOOL exists = [platformView waitForExistenceWithTimeout:kSecondsToWaitForPlatformView];
683 if (!exists) {
684 XCTFail(@"It took longer than %@ second to find the platform view."
685 @"There might be issues with the platform view's construction,"
686 @"or with how the scenario is built.",
688 }
689
690 XCTAssertNotNil(platformView);
691}
692
693@end
694
695@interface PlatformViewScrollingUnderWidget : XCTestCase
696
697@end
698
700
701- (void)setUp {
702 [super setUp];
703 self.continueAfterFailure = NO;
704}
705
706- (void)testPlatformViewScrollingUnderWidget {
707 XCUIApplication* app = [[XCUIApplication alloc] init];
708 app.launchArguments =
709 @[ @"--platform-view-scrolling-under-widget", @"--with-continuous-texture" ];
710 [app launch];
711
712 XCUIElement* platformView = app.textViews.firstMatch;
713 BOOL exists = [platformView waitForExistenceWithTimeout:kSecondsToWaitForPlatformView];
714 if (!exists) {
715 XCTFail(@"It took longer than %@ second to find the platform view."
716 @"There might be issues with the platform view's construction,"
717 @"or with how the scenario is built.",
719 }
720
721 // Wait and let the scenario app scroll a bit.
722 XCTWaiterResult waitResult = [XCTWaiter
723 waitForExpectations:@[ [[XCTestExpectation alloc] initWithDescription:@"Wait for 5 seconds"] ]
724 timeout:5];
725 // If the waiter is not interrupted, we know the app is in a valid state after timeout, thus the
726 // test passes.
727 XCTAssert(waitResult != XCTWaiterResultInterrupted);
728}
729
730@end
731
732@interface PlatformViewWithClipsScrolling : XCTestCase
733
734@end
735
736@implementation PlatformViewWithClipsScrolling
737
738- (void)setUp {
739 [super setUp];
740 self.continueAfterFailure = NO;
741}
742
743- (void)testPlatformViewsWithClipsScrolling {
744 XCUIApplication* app = [[XCUIApplication alloc] init];
745 app.launchArguments =
746 @[ @"--platform-views-with-clips-scrolling", @"platform_views_with_clips_scrolling" ];
747 [app launch];
748
749 XCUIElement* platformView = app.textViews.firstMatch;
750 BOOL exists = [platformView waitForExistenceWithTimeout:kSecondsToWaitForPlatformView];
751 if (!exists) {
752 XCTFail(@"It took longer than %@ second to find the platform view."
753 @"There might be issues with the platform view's construction,"
754 @"or with how the scenario is built.",
756 }
757
758 // Wait and let the scenario app scroll a bit.
759 XCTWaiterResult waitResult = [XCTWaiter
760 waitForExpectations:@[ [[XCTestExpectation alloc] initWithDescription:@"Wait for 5 seconds"] ]
761 timeout:5];
762 // If the waiter is not interrupted, we know the app is in a valid state after timeout, thus the
763 // test passes.
764 XCTAssert(waitResult != XCTWaiterResultInterrupted);
765}
766
767@end
768
770
771@end
772
774
775- (void)setUp {
776 [super setUp];
777 self.continueAfterFailure = NO;
778}
779
780- (void)testPlatformViewsWithClipsScrolling {
781 XCUIApplication* app = [[XCUIApplication alloc] init];
782 app.launchArguments = @[
783 @"--platform-views-with-clips-scrolling", @"platform_views_with_clips_scrolling-multiple-clips"
784 ];
785 [app launch];
786
787 XCUIElement* platformView = app.textViews.firstMatch;
788 BOOL exists = [platformView waitForExistenceWithTimeout:kSecondsToWaitForPlatformView];
789 if (!exists) {
790 XCTFail(@"It took longer than %@ second to find the platform view."
791 @"There might be issues with the platform view's construction,"
792 @"or with how the scenario is built.",
794 }
795
796 // Wait and let the scenario app scroll a bit.
797 XCTWaiterResult waitResult = [XCTWaiter
798 waitForExpectations:@[ [[XCTestExpectation alloc] initWithDescription:@"Wait for 5 seconds"] ]
799 timeout:5];
800 // If the waiter is not interrupted, we know the app is in a valid state after timeout, thus the
801 // test passes.
802 XCTAssert(waitResult != XCTWaiterResultInterrupted);
803}
804
805@end
static const NSInteger kSecondsToWaitForPlatformView
static const NSInteger kSecondsToWaitForPlatformView
instancetype initWithManager:invocation:(GoldenTestManager *manager,[invocation] NSInvocation *invocation)
int BOOL