diff --git a/shell/platform/darwin/ios/framework/Source/FlutterPlatformViews.mm b/shell/platform/darwin/ios/framework/Source/FlutterPlatformViews.mm index be8574eb30249a57b41813a4050b4563283b124f..128a7d68ae49f1425fc7ea49059108ec7abfe68b 100644 --- a/shell/platform/darwin/ios/framework/Source/FlutterPlatformViews.mm +++ b/shell/platform/darwin/ios/framework/Source/FlutterPlatformViews.mm @@ -368,7 +368,7 @@ bool FlutterPlatformViewsController::SubmitFrame(GrContext* gr_context, bool did_submit = true; for (int64_t view_id : composition_order_) { - EnsureOverlayInitialized(view_id, std::move(gl_context), gr_context); + EnsureOverlayInitialized(view_id, gl_context, gr_context); auto frame = overlays_[view_id]->surface->AcquireFrame(frame_size_); SkCanvas* canvas = frame->SkiaCanvas(); canvas->drawPicture(picture_recorders_[view_id]->finishRecordingAsPicture()); diff --git a/testing/scenario_app/ios/Scenarios/Scenarios.xcodeproj/project.pbxproj b/testing/scenario_app/ios/Scenarios/Scenarios.xcodeproj/project.pbxproj index a95587c1a7fd021c9cea8678fd6ffb87cd6c499d..622aeb7732c82eebac96b24bf36e268f37e8cf03 100644 --- a/testing/scenario_app/ios/Scenarios/Scenarios.xcodeproj/project.pbxproj +++ b/testing/scenario_app/ios/Scenarios/Scenarios.xcodeproj/project.pbxproj @@ -30,6 +30,7 @@ 24D47D1B230C79840069DD5E /* golden_platform_view_D211AP.png in Resources */ = {isa = PBXBuildFile; fileRef = 24D47D1A230C79840069DD5E /* golden_platform_view_D211AP.png */; }; 24D47D1D230CA2700069DD5E /* golden_platform_view_iPhone SE_simulator.png in Resources */ = {isa = PBXBuildFile; fileRef = 24D47D1C230CA2700069DD5E /* golden_platform_view_iPhone SE_simulator.png */; }; 24F1FB89230B4579005ACE7C /* TextPlatformView.m in Sources */ = {isa = PBXBuildFile; fileRef = 24F1FB87230B4579005ACE7C /* TextPlatformView.m */; }; + 59A97FD8236A49D300B4C066 /* golden_platform_view_multiple_iPhone SE_simulator.png in Resources */ = {isa = PBXBuildFile; fileRef = 59A97FD7236A49D300B4C066 /* golden_platform_view_multiple_iPhone SE_simulator.png */; }; 6816DB9E231750ED00A51400 /* GoldenPlatformViewTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 6816DB9D231750ED00A51400 /* GoldenPlatformViewTests.m */; }; 6816DBA12317573300A51400 /* GoldenImage.m in Sources */ = {isa = PBXBuildFile; fileRef = 6816DBA02317573300A51400 /* GoldenImage.m */; }; 6816DBA42318358200A51400 /* PlatformViewGoldenTestManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 6816DBA32318358200A51400 /* PlatformViewGoldenTestManager.m */; }; @@ -121,6 +122,7 @@ 24D47D1E230CA4480069DD5E /* README.md */ = {isa = PBXFileReference; lastKnownFileType = net.daringfireball.markdown; path = README.md; sourceTree = ""; }; 24F1FB87230B4579005ACE7C /* TextPlatformView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TextPlatformView.m; sourceTree = ""; }; 24F1FB88230B4579005ACE7C /* TextPlatformView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TextPlatformView.h; sourceTree = ""; }; + 59A97FD7236A49D300B4C066 /* golden_platform_view_multiple_iPhone SE_simulator.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "golden_platform_view_multiple_iPhone SE_simulator.png"; sourceTree = ""; }; 6816DB9C231750ED00A51400 /* GoldenPlatformViewTests.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GoldenPlatformViewTests.h; sourceTree = ""; }; 6816DB9D231750ED00A51400 /* GoldenPlatformViewTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = GoldenPlatformViewTests.m; sourceTree = ""; }; 6816DB9F2317573300A51400 /* GoldenImage.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GoldenImage.h; sourceTree = ""; }; @@ -216,6 +218,7 @@ 248D76ED22E388380012F0C1 /* ScenariosUITests */ = { isa = PBXGroup; children = ( + 59A97FD7236A49D300B4C066 /* golden_platform_view_multiple_iPhone SE_simulator.png */, 244EA6CF230DBE8900B2D26E /* golden_platform_view_D21AP.png */, 24D47D1C230CA2700069DD5E /* golden_platform_view_iPhone SE_simulator.png */, 24D47D1A230C79840069DD5E /* golden_platform_view_D211AP.png */, @@ -375,6 +378,7 @@ 6816DBAA2318696600A51400 /* golden_platform_view_clippath_iPhone SE_simulator.png in Resources */, 6816DBAD2318696600A51400 /* golden_platform_view_cliprect_iPhone SE_simulator.png in Resources */, 24D47D1B230C79840069DD5E /* golden_platform_view_D211AP.png in Resources */, + 59A97FD8236A49D300B4C066 /* golden_platform_view_multiple_iPhone SE_simulator.png in Resources */, 24D47D1D230CA2700069DD5E /* golden_platform_view_iPhone SE_simulator.png in Resources */, 244EA6D0230DBE8900B2D26E /* golden_platform_view_D21AP.png in Resources */, 6816DBAC2318696600A51400 /* golden_platform_view_opacity_iPhone SE_simulator.png in Resources */, diff --git a/testing/scenario_app/ios/Scenarios/Scenarios/AppDelegate.m b/testing/scenario_app/ios/Scenarios/Scenarios/AppDelegate.m index 205ce79384c9c710f77cc415b43f0ffff84fe768..a2a6da97133c3a0d824d91982f82ffdedf3153ce 100644 --- a/testing/scenario_app/ios/Scenarios/Scenarios/AppDelegate.m +++ b/testing/scenario_app/ios/Scenarios/Scenarios/AppDelegate.m @@ -28,6 +28,7 @@ // The launchArgsMap should match the one in the `PlatformVieGoldenTestManager`. NSDictionary* launchArgsMap = @{ @"--platform-view" : @"platform_view", + @"--platform-view-multiple" : @"platform_view_multiple", @"--platform-view-cliprect" : @"platform_view_cliprect", @"--platform-view-cliprrect" : @"platform_view_cliprrect", @"--platform-view-clippath" : @"platform_view_clippath", diff --git a/testing/scenario_app/ios/Scenarios/ScenariosUITests/PlatformViewGoldenTestManager.m b/testing/scenario_app/ios/Scenarios/ScenariosUITests/PlatformViewGoldenTestManager.m index 9e512d5234889560839155b81233d5889c6dc8b1..276514bc3933f8c5b78f898ecdc230ac0be783c9 100644 --- a/testing/scenario_app/ios/Scenarios/ScenariosUITests/PlatformViewGoldenTestManager.m +++ b/testing/scenario_app/ios/Scenarios/ScenariosUITests/PlatformViewGoldenTestManager.m @@ -23,6 +23,7 @@ NSDictionary* launchArgsMap; dispatch_once(&onceToken, ^{ launchArgsMap = @{ @"--platform-view" : @"platform_view", + @"--platform-view-multiple" : @"platform_view_multiple", @"--platform-view-cliprect" : @"platform_view_cliprect", @"--platform-view-cliprrect" : @"platform_view_cliprrect", @"--platform-view-clippath" : @"platform_view_clippath", diff --git a/testing/scenario_app/ios/Scenarios/ScenariosUITests/PlatformViewUITests.m b/testing/scenario_app/ios/Scenarios/ScenariosUITests/PlatformViewUITests.m index 00708ecc282f4c70b8ad75138bf7ef1eb84bbf42..53dbea11b950a846d5744b13d1bc5780e6b3b6de 100644 --- a/testing/scenario_app/ios/Scenarios/ScenariosUITests/PlatformViewUITests.m +++ b/testing/scenario_app/ios/Scenarios/ScenariosUITests/PlatformViewUITests.m @@ -22,6 +22,24 @@ @end +@interface MultiplePlatformViewsTest : GoldenPlatformViewTests + +@end + +@implementation MultiplePlatformViewsTest + +- (instancetype)initWithInvocation:(NSInvocation*)invocation { + PlatformViewGoldenTestManager* manager = + [[PlatformViewGoldenTestManager alloc] initWithLaunchArg:@"--platform-view-multiple"]; + return [super initWithManager:manager invocation:invocation]; +} + +- (void)testPlatformView { + [self checkGolden]; +} + +@end + // Clip Rect Tests @interface PlatformViewMutationClipRectTests : GoldenPlatformViewTests diff --git a/testing/scenario_app/ios/Scenarios/ScenariosUITests/golden_platform_view_multiple_iPhone SE_simulator.png b/testing/scenario_app/ios/Scenarios/ScenariosUITests/golden_platform_view_multiple_iPhone SE_simulator.png new file mode 100644 index 0000000000000000000000000000000000000000..f3176650205d4383b1c57b6b2b970fb03688607e Binary files /dev/null and b/testing/scenario_app/ios/Scenarios/ScenariosUITests/golden_platform_view_multiple_iPhone SE_simulator.png differ diff --git a/testing/scenario_app/lib/main.dart b/testing/scenario_app/lib/main.dart index bbc16454470aa2959d2a7417222faee18abf07d1..2eabb4f04764d2980307810e1eb02f9d30bd073f 100644 --- a/testing/scenario_app/lib/main.dart +++ b/testing/scenario_app/lib/main.dart @@ -22,6 +22,7 @@ Map _scenarios = { 'platform_view_clippath': PlatformViewClipPathScenario(window, 'PlatformViewClipPath', id: 3), 'platform_view_transform': PlatformViewTransformScenario(window, 'PlatformViewTransform', id: 4), 'platform_view_opacity': PlatformViewOpacityScenario(window, 'PlatformViewOpacity', id: 5), + 'platform_view_multiple': MultiPlatformViewScenario(window, firstId: 6, secondId: 7), 'poppable_screen': PoppableScreenScenario(window), }; diff --git a/testing/scenario_app/lib/src/platform_view.dart b/testing/scenario_app/lib/src/platform_view.dart index e24ef2b800a178692ef672000f2aaaf92641c8eb..3fda496819200398b269512115171eed08872e69 100644 --- a/testing/scenario_app/lib/src/platform_view.dart +++ b/testing/scenario_app/lib/src/platform_view.dart @@ -34,7 +34,7 @@ class PlatformViewScenario extends Scenario with _BasePlatformViewScenarioMixin PlatformViewScenario(Window window, String text, {int id = 0}) : assert(window != null), super(window) { - constructScenario(window, text, id); + createPlatformView(window, text, id); } @override @@ -47,13 +47,45 @@ class PlatformViewScenario extends Scenario with _BasePlatformViewScenarioMixin } } +/// Builds a scene with 2 platform views. +class MultiPlatformViewScenario extends Scenario with _BasePlatformViewScenarioMixin { + /// Creates the PlatformView scenario. + /// + /// The [window] parameter must not be null. + MultiPlatformViewScenario(Window window, {this.firstId, this.secondId}) + : assert(window != null), + super(window) { + createPlatformView(window, 'platform view 1', firstId); + createPlatformView(window, 'platform view 2', secondId); + } + + /// The platform view identifier to use for the first platform view. + final int firstId; + + /// The platform view identifier to use for the second platform view. + final int secondId; + + @override + void onBeginFrame(Duration duration) { + final SceneBuilder builder = SceneBuilder(); + + builder.pushOffset(0, 0); + + builder.pushOffset(0, 600); + _addPlatformViewtoScene(builder, firstId, 500, 500); + builder.pop(); + + finishBuilderByAddingPlatformViewAndPicture(builder, secondId); + } +} + /// Platform view with clip rect. class PlatformViewClipRectScenario extends Scenario with _BasePlatformViewScenarioMixin { /// Constructs a platform view with clip rect scenario. PlatformViewClipRectScenario(Window window, String text, {int id = 0}) : assert(window != null), super(window) { - constructScenario(window, text, id); + createPlatformView(window, text, id); } @override @@ -165,7 +197,7 @@ mixin _BasePlatformViewScenarioMixin on Scenario { /// It prepare a TextPlatformView so it can be added to the SceneBuilder in `onBeginFrame`. /// Call this method in the constructor of the platform view related scenarios /// to perform necessary set up. - void constructScenario(Window window, String text, int id) { + void createPlatformView(Window window, String text, int id) { const int _valueInt32 = 3; const int _valueFloat64 = 6; const int _valueString = 7; @@ -227,15 +259,19 @@ mixin _BasePlatformViewScenarioMixin on Scenario { ); } - // Add a platform view and a picture to the scene, then finish the `sceneBuilder`. - void finishBuilderByAddingPlatformViewAndPicture(SceneBuilder sceneBuilder, int viewId) { + void _addPlatformViewtoScene(SceneBuilder sceneBuilder, int viewId, double width, double height) { if (Platform.isIOS) { - sceneBuilder.addPlatformView(viewId, width: 500, height: 500); + sceneBuilder.addPlatformView(viewId, width: width, height: height); } else if (Platform.isAndroid && _textureId != null) { - sceneBuilder.addTexture(_textureId, offset: const Offset(150, 300), width: 500, height: 500); + sceneBuilder.addTexture(_textureId, offset: const Offset(150, 300), width: width, height: height); } else { throw UnsupportedError('Platform ${Platform.operatingSystem} is not supported'); } + } + + // Add a platform view and a picture to the scene, then finish the `sceneBuilder`. + void finishBuilderByAddingPlatformViewAndPicture(SceneBuilder sceneBuilder, int viewId) { + _addPlatformViewtoScene(sceneBuilder, viewId, 500, 500); final PictureRecorder recorder = PictureRecorder(); final Canvas canvas = Canvas(recorder); canvas.drawCircle(