Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit 55b28d3

Browse files
author
Chris Yang
committed
test
more comments
1 parent 4a90fbc commit 55b28d3

File tree

8 files changed

+98
-1
lines changed

8 files changed

+98
-1
lines changed

shell/platform/darwin/ios/framework/Source/FlutterPlatformViews_Internal.mm

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,11 @@ - (instancetype)initWithFrame:(CGRect)frame screenScale:(CGFloat)screenScale {
271271
return self;
272272
}
273273

274+
- (void)reset {
275+
paths_.clear();
276+
[self setNeedsDisplay];
277+
}
278+
274279
// In some scenarios, when we add this view as a maskView of the ChildClippingView, iOS added
275280
// this view as a subview of the ChildClippingView.
276281
// This results this view blocking touch events on the ChildClippingView.

testing/scenario_app/ios/Scenarios/Scenarios.xcodeproj/project.pbxproj

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
6816DB9E231750ED00A51400 /* GoldenPlatformViewTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 6816DB9D231750ED00A51400 /* GoldenPlatformViewTests.m */; };
3838
6816DBA12317573300A51400 /* GoldenImage.m in Sources */ = {isa = PBXBuildFile; fileRef = 6816DBA02317573300A51400 /* GoldenImage.m */; };
3939
6816DBA42318358200A51400 /* GoldenTestManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 6816DBA32318358200A51400 /* GoldenTestManager.m */; };
40+
682C5873299C182A00915E5C /* golden_platform_view_cliprect_after_moved_iPhone 8_16.0_simulator.png in Resources */ = {isa = PBXBuildFile; fileRef = 682C5872299C182A00915E5C /* golden_platform_view_cliprect_after_moved_iPhone 8_16.0_simulator.png */; };
4041
685B9F392977B73100B45442 /* golden_platform_view_large_cliprrect_with_transform_iPhone 8_16.0_simulator.png in Resources */ = {isa = PBXBuildFile; fileRef = 685B9F372977B73100B45442 /* golden_platform_view_large_cliprrect_with_transform_iPhone 8_16.0_simulator.png */; };
4142
685B9F3A2977B73100B45442 /* golden_platform_view_large_cliprrect_iPhone 8_16.0_simulator.png in Resources */ = {isa = PBXBuildFile; fileRef = 685B9F382977B73100B45442 /* golden_platform_view_large_cliprrect_iPhone 8_16.0_simulator.png */; };
4243
687AF8E9291EBDE0003912C7 /* golden_platform_view_clippath_with_transform_iPhone 8_16.0_simulator.png in Resources */ = {isa = PBXBuildFile; fileRef = 687AF8E8291EBDE0003912C7 /* golden_platform_view_clippath_with_transform_iPhone 8_16.0_simulator.png */; };
@@ -153,6 +154,7 @@
153154
6816DBA02317573300A51400 /* GoldenImage.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = GoldenImage.m; sourceTree = "<group>"; };
154155
6816DBA22318358200A51400 /* GoldenTestManager.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GoldenTestManager.h; sourceTree = "<group>"; };
155156
6816DBA32318358200A51400 /* GoldenTestManager.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = GoldenTestManager.m; sourceTree = "<group>"; };
157+
682C5872299C182A00915E5C /* golden_platform_view_cliprect_after_moved_iPhone 8_16.0_simulator.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "golden_platform_view_cliprect_after_moved_iPhone 8_16.0_simulator.png"; sourceTree = "<group>"; };
156158
685B9F372977B73100B45442 /* golden_platform_view_large_cliprrect_with_transform_iPhone 8_16.0_simulator.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "golden_platform_view_large_cliprrect_with_transform_iPhone 8_16.0_simulator.png"; sourceTree = "<group>"; };
157159
685B9F382977B73100B45442 /* golden_platform_view_large_cliprrect_iPhone 8_16.0_simulator.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "golden_platform_view_large_cliprrect_iPhone 8_16.0_simulator.png"; sourceTree = "<group>"; };
158160
687AF8E8291EBDE0003912C7 /* golden_platform_view_clippath_with_transform_iPhone 8_16.0_simulator.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "golden_platform_view_clippath_with_transform_iPhone 8_16.0_simulator.png"; sourceTree = "<group>"; };
@@ -300,6 +302,7 @@
300302
F7B464DC2759D02B00079189 /* Goldens */ = {
301303
isa = PBXGroup;
302304
children = (
305+
682C5872299C182A00915E5C /* golden_platform_view_cliprect_after_moved_iPhone 8_16.0_simulator.png */,
303306
685B9F382977B73100B45442 /* golden_platform_view_large_cliprrect_iPhone 8_16.0_simulator.png */,
304307
685B9F372977B73100B45442 /* golden_platform_view_large_cliprrect_with_transform_iPhone 8_16.0_simulator.png */,
305308
68D50041291ED8CD001ACFE1 /* golden_platform_view_cliprect_with_transform_iPhone 8_16.0_simulator.png */,
@@ -447,6 +450,7 @@
447450
isa = PBXResourcesBuildPhase;
448451
buildActionMask = 2147483647;
449452
files = (
453+
682C5873299C182A00915E5C /* golden_platform_view_cliprect_after_moved_iPhone 8_16.0_simulator.png in Resources */,
450454
68D50042291ED8CD001ACFE1 /* golden_platform_view_cliprect_with_transform_iPhone 8_16.0_simulator.png in Resources */,
451455
F7B464F62759D0A900079189 /* golden_non_full_screen_flutter_view_platform_view_iPhone 8_16.0_simulator.png in Resources */,
452456
F7B464F02759D0A900079189 /* golden_bogus_font_text_iPhone 8_16.0_simulator.png in Resources */,

testing/scenario_app/ios/Scenarios/Scenarios/AppDelegate.m

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,8 @@ - (BOOL)application:(UIApplication*)application
6666
@"--bogus-font-text" : @"bogus_font_text",
6767
@"--spawn-engine-works" : @"spawn_engine_works",
6868
@"--pointer-events" : @"pointer_events",
69-
@"--platform-view-scrolling-under-widget" : @"platform_view_scrolling_under_widget"
69+
@"--platform-view-scrolling-under-widget" : @"platform_view_scrolling_under_widget",
70+
@"--platform-view-cliprect-after-moved" : @"platform_view_cliprect_after_moved"
7071
};
7172
__block NSString* flutterViewControllerTestName = nil;
7273
[launchArgsMap

testing/scenario_app/ios/Scenarios/ScenariosUITests/GoldenTestManager.m

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ - (instancetype)initWithLaunchArg:(NSString*)launchArg {
4646
@"non_full_screen_flutter_view_platform_view",
4747
@"--bogus-font-text" : @"bogus_font_text",
4848
@"--spawn-engine-works" : @"spawn_engine_works",
49+
@"--platform-view-cliprect-after-moved" : @"platform_view_cliprect_after_moved",
4950
};
5051
});
5152
_identifier = launchArgsMap[launchArg];

testing/scenario_app/ios/Scenarios/ScenariosUITests/PlatformViewUITests.m

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,36 @@ - (void)testPlatformView {
9898

9999
@end
100100

101+
@interface PlatformViewMutationClipRectAfterMovedTests : GoldenPlatformViewTests
102+
103+
@end
104+
105+
@implementation PlatformViewMutationClipRectAfterMovedTests
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.",
123+
@(kSecondsToWaitForPlatformView));
124+
}
125+
126+
[self checkPlatformViewGolden];
127+
}
128+
129+
@end
130+
101131
@interface PlatformViewMutationClipRRectTests : GoldenPlatformViewTests
102132

103133
@end

testing/scenario_app/lib/src/platform_view.dart

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -573,6 +573,61 @@ class PlatformViewClipRectScenario extends Scenario with _BasePlatformViewScenar
573573
}
574574
}
575575

576+
/// Platform view with clip rect then the PlatformView is moved for 10 frames.
577+
///
578+
/// The clip rect moves with the same transform matrix with the PlatformView.
579+
class PlatformViewClipRectAfterMovedScenario extends Scenario with _BasePlatformViewScenarioMixin {
580+
/// Constructs a platform view with clip rect scenario.
581+
PlatformViewClipRectAfterMovedScenario(
582+
PlatformDispatcher dispatcher, {
583+
required this.id,
584+
}) : super(dispatcher);
585+
586+
/// The platform view identifier.
587+
final int id;
588+
589+
int _numberOfFrames = 0;
590+
591+
double _y = 100.0;
592+
593+
@override
594+
void onBeginFrame(Duration duration) {
595+
final Matrix4 translateMatrix = Matrix4.identity()..translate(0.0, _y);
596+
final SceneBuilder builder = SceneBuilder()
597+
..pushTransform(translateMatrix.storage)
598+
..pushClipRect(const Rect.fromLTRB(100, 100, 400, 400));
599+
600+
addPlatformView(
601+
_numberOfFrames == 10? 10000:id,
602+
dispatcher: dispatcher,
603+
sceneBuilder: builder,
604+
);
605+
606+
// Add a translucent rect that has the same size of PlatformView.
607+
final PictureRecorder recorder = PictureRecorder();
608+
final Canvas canvas = Canvas(recorder);
609+
canvas.drawRect(
610+
const Rect.fromLTWH(0, 0, 500, 500),
611+
Paint()..color = const Color(0x22FF0000),
612+
);
613+
final Picture picture = recorder.endRecording();
614+
builder.addPicture(Offset.zero, picture);
615+
616+
finishBuilder(builder);
617+
super.onBeginFrame(duration);
618+
}
619+
620+
@override
621+
void onDrawFrame() {
622+
if (_numberOfFrames < 10) {
623+
_numberOfFrames ++;
624+
_y -= 10;
625+
window.scheduleFrame();
626+
}
627+
super.onDrawFrame();
628+
}
629+
}
630+
576631
/// Platform view with clip rrect.
577632
class PlatformViewClipRRectScenario extends PlatformViewScenario {
578633
/// Constructs a platform view with clip rrect scenario.

testing/scenario_app/lib/src/scenarios.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ Map<String, ScenarioFactory> _scenarios = <String, ScenarioFactory>{
3232
'platform_view_max_overlays': () => PlatformViewMaxOverlaysScenario(PlatformDispatcher.instance, id: _viewId++),
3333
'platform_view_cliprect': () => PlatformViewClipRectScenario(PlatformDispatcher.instance, id: _viewId++),
3434
'platform_view_cliprect_with_transform': () => PlatformViewClipRectWithTransformScenario(PlatformDispatcher.instance, id: _viewId++),
35+
'platform_view_cliprect_after_moved': () => PlatformViewClipRectAfterMovedScenario(PlatformDispatcher.instance, id: _viewId++),
3536
'platform_view_cliprrect': () => PlatformViewClipRRectScenario(PlatformDispatcher.instance, id: _viewId++),
3637
'platform_view_large_cliprrect': () => PlatformViewLargeClipRRectScenario(PlatformDispatcher.instance, id: _viewId++),
3738
'platform_view_cliprrect_with_transform': () => PlatformViewClipRRectWithTransformScenario(PlatformDispatcher.instance, id: _viewId++),

0 commit comments

Comments
 (0)