diff --git a/engine/src/flutter/shell/platform/darwin/ios/framework/Source/FlutterPlatformViews.mm b/engine/src/flutter/shell/platform/darwin/ios/framework/Source/FlutterPlatformViews.mm index 33ca14d9fa..3371191fa3 100644 --- a/engine/src/flutter/shell/platform/darwin/ios/framework/Source/FlutterPlatformViews.mm +++ b/engine/src/flutter/shell/platform/darwin/ios/framework/Source/FlutterPlatformViews.mm @@ -370,10 +370,13 @@ bool FlutterPlatformViewsController::SubmitFrame(GrContext* gr_context, for (int64_t view_id : composition_order_) { 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()); - canvas->flush(); - did_submit &= frame->Submit(); + // If frame is null, AcquireFrame already printed out an error message. + if (frame) { + SkCanvas* canvas = frame->SkiaCanvas(); + canvas->drawPicture(picture_recorders_[view_id]->finishRecordingAsPicture()); + canvas->flush(); + did_submit &= frame->Submit(); + } } picture_recorders_.clear(); if (composition_order_ == active_composition_order_) { @@ -398,6 +401,7 @@ bool FlutterPlatformViewsController::SubmitFrame(GrContext* gr_context, } else { [flutter_view addSubview:platform_view_root]; [flutter_view addSubview:overlay]; + overlay.frame = flutter_view.bounds; } active_composition_order_.push_back(view_id); diff --git a/engine/src/flutter/testing/scenario_app/ios/Scenarios/Scenarios.xcodeproj/project.pbxproj b/engine/src/flutter/testing/scenario_app/ios/Scenarios/Scenarios.xcodeproj/project.pbxproj index e667c4c886..389b44830d 100644 --- a/engine/src/flutter/testing/scenario_app/ios/Scenarios/Scenarios.xcodeproj/project.pbxproj +++ b/engine/src/flutter/testing/scenario_app/ios/Scenarios/Scenarios.xcodeproj/project.pbxproj @@ -10,6 +10,7 @@ 0A57B3BD2323C4BD00DD9521 /* ScreenBeforeFlutter.m in Sources */ = {isa = PBXBuildFile; fileRef = 0A57B3BC2323C4BD00DD9521 /* ScreenBeforeFlutter.m */; }; 0A57B3BF2323C74200DD9521 /* FlutterEngine+ScenariosTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 0A57B3BE2323C74200DD9521 /* FlutterEngine+ScenariosTest.m */; }; 0A57B3C22323D2D700DD9521 /* AppLifecycleTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 0A57B3C12323D2D700DD9521 /* AppLifecycleTests.m */; }; + 0D14A3FE239743190013D873 /* golden_platform_view_rotate_iPhone SE_simulator.png in Resources */ = {isa = PBXBuildFile; fileRef = 0D14A3FD239743190013D873 /* golden_platform_view_rotate_iPhone SE_simulator.png */; }; 0DB781EF22E931BE00E9B371 /* Flutter.framework in CopyFiles */ = {isa = PBXBuildFile; fileRef = 246B4E4522E3B61000073EBF /* Flutter.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; 0DB781F122E933E800E9B371 /* Flutter.framework in CopyFiles */ = {isa = PBXBuildFile; fileRef = 246B4E4522E3B61000073EBF /* Flutter.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; 0DB781FE22EA2C6D00E9B371 /* Flutter.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 246B4E4522E3B61000073EBF /* Flutter.framework */; }; @@ -102,6 +103,7 @@ 0A57B3BE2323C74200DD9521 /* FlutterEngine+ScenariosTest.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = "FlutterEngine+ScenariosTest.m"; sourceTree = ""; }; 0A57B3C02323C74D00DD9521 /* FlutterEngine+ScenariosTest.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "FlutterEngine+ScenariosTest.h"; sourceTree = ""; }; 0A57B3C12323D2D700DD9521 /* AppLifecycleTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppLifecycleTests.m; sourceTree = ""; }; + 0D14A3FD239743190013D873 /* golden_platform_view_rotate_iPhone SE_simulator.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "golden_platform_view_rotate_iPhone SE_simulator.png"; sourceTree = ""; }; 0DB781FC22EA2C0300E9B371 /* FlutterViewControllerTest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = FlutterViewControllerTest.m; sourceTree = ""; }; 244EA6CF230DBE8900B2D26E /* golden_platform_view_D21AP.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = golden_platform_view_D21AP.png; sourceTree = ""; }; 246B4E4122E3B5F700073EBF /* App.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; path = App.framework; sourceTree = ""; }; @@ -220,6 +222,7 @@ 248D76ED22E388380012F0C1 /* ScenariosUITests */ = { isa = PBXGroup; children = ( + 0D14A3FD239743190013D873 /* golden_platform_view_rotate_iPhone SE_simulator.png */, 59A97FD9236B984300B4C066 /* golden_platform_view_multiple_background_foreground_iPhone SE_simulator.png */, 59A97FD7236A49D300B4C066 /* golden_platform_view_multiple_iPhone SE_simulator.png */, 244EA6CF230DBE8900B2D26E /* golden_platform_view_D21AP.png */, @@ -377,6 +380,7 @@ buildActionMask = 2147483647; files = ( 6816DBAE2318696600A51400 /* golden_platform_view_cliprrect_iPhone SE_simulator.png in Resources */, + 0D14A3FE239743190013D873 /* golden_platform_view_rotate_iPhone SE_simulator.png in Resources */, 6816DBAB2318696600A51400 /* golden_platform_view_transform_iPhone SE_simulator.png in Resources */, 59A97FDA236B984300B4C066 /* golden_platform_view_multiple_background_foreground_iPhone SE_simulator.png in Resources */, 6816DBAA2318696600A51400 /* golden_platform_view_clippath_iPhone SE_simulator.png in Resources */, diff --git a/engine/src/flutter/testing/scenario_app/ios/Scenarios/Scenarios/AppDelegate.m b/engine/src/flutter/testing/scenario_app/ios/Scenarios/Scenarios/AppDelegate.m index 278f7916cf..86a601cc19 100644 --- a/engine/src/flutter/testing/scenario_app/ios/Scenarios/Scenarios/AppDelegate.m +++ b/engine/src/flutter/testing/scenario_app/ios/Scenarios/Scenarios/AppDelegate.m @@ -36,6 +36,7 @@ @"--platform-view-clippath" : @"platform_view_clippath", @"--platform-view-transform" : @"platform_view_transform", @"--platform-view-opacity" : @"platform_view_opacity", + @"--platform-view-rotate" : @"platform_view_rotate", }; __block NSString* goldenTestName = nil; [launchArgsMap diff --git a/engine/src/flutter/testing/scenario_app/ios/Scenarios/ScenariosUITests/GoldenImage.m b/engine/src/flutter/testing/scenario_app/ios/Scenarios/ScenariosUITests/GoldenImage.m index 6dbcd8e73e..e1b27c9bb8 100644 --- a/engine/src/flutter/testing/scenario_app/ios/Scenarios/ScenariosUITests/GoldenImage.m +++ b/engine/src/flutter/testing/scenario_app/ios/Scenarios/ScenariosUITests/GoldenImage.m @@ -67,11 +67,8 @@ CGContextDrawImage(contextB, CGRectMake(0, 0, widthA, heightA), imageRefB); CGContextRelease(contextB); - if (memcmp(rawA.mutableBytes, rawB.mutableBytes, size)) { - return NO; - } - - return YES; + BOOL isSame = memcmp(rawA.mutableBytes, rawB.mutableBytes, size) == 0; + return isSame; } NS_INLINE NSString* _platformName() { diff --git a/engine/src/flutter/testing/scenario_app/ios/Scenarios/ScenariosUITests/PlatformViewGoldenTestManager.m b/engine/src/flutter/testing/scenario_app/ios/Scenarios/ScenariosUITests/PlatformViewGoldenTestManager.m index cb3ac5f924..df7015afd9 100644 --- a/engine/src/flutter/testing/scenario_app/ios/Scenarios/ScenariosUITests/PlatformViewGoldenTestManager.m +++ b/engine/src/flutter/testing/scenario_app/ios/Scenarios/ScenariosUITests/PlatformViewGoldenTestManager.m @@ -3,6 +3,7 @@ // found in the LICENSE file. #import "PlatformViewGoldenTestManager.h" +#import @interface PlatformViewGoldenTestManager () @@ -31,6 +32,7 @@ NSDictionary* launchArgsMap; @"--platform-view-clippath" : @"platform_view_clippath", @"--platform-view-transform" : @"platform_view_transform", @"--platform-view-opacity" : @"platform_view_opacity", + @"--platform-view-rotate" : @"platform_view_rotate", }; }); _identifier = launchArgsMap[launchArg]; diff --git a/engine/src/flutter/testing/scenario_app/ios/Scenarios/ScenariosUITests/PlatformViewUITests.m b/engine/src/flutter/testing/scenario_app/ios/Scenarios/ScenariosUITests/PlatformViewUITests.m index 72c3c460de..1d23e3a064 100644 --- a/engine/src/flutter/testing/scenario_app/ios/Scenarios/ScenariosUITests/PlatformViewUITests.m +++ b/engine/src/flutter/testing/scenario_app/ios/Scenarios/ScenariosUITests/PlatformViewUITests.m @@ -150,3 +150,24 @@ } @end + +@interface PlatformViewRotation : GoldenPlatformViewTests +@end + +@implementation PlatformViewRotation +- (instancetype)initWithInvocation:(NSInvocation*)invocation { + PlatformViewGoldenTestManager* manager = + [[PlatformViewGoldenTestManager alloc] initWithLaunchArg:@"--platform-view-rotate"]; + return [super initWithManager:manager invocation:invocation]; +} + +- (void)tearDown { + XCUIDevice.sharedDevice.orientation = UIDeviceOrientationPortrait; + [super tearDown]; +} + +- (void)testPlatformView { + XCUIDevice.sharedDevice.orientation = UIDeviceOrientationLandscapeLeft; + [self checkGolden]; +} +@end diff --git a/engine/src/flutter/testing/scenario_app/ios/Scenarios/ScenariosUITests/golden_platform_view_rotate_iPhone SE_simulator.png b/engine/src/flutter/testing/scenario_app/ios/Scenarios/ScenariosUITests/golden_platform_view_rotate_iPhone SE_simulator.png new file mode 100644 index 0000000000..5281191b08 Binary files /dev/null and b/engine/src/flutter/testing/scenario_app/ios/Scenarios/ScenariosUITests/golden_platform_view_rotate_iPhone SE_simulator.png differ diff --git a/engine/src/flutter/testing/scenario_app/lib/main.dart b/engine/src/flutter/testing/scenario_app/lib/main.dart index 7a264b7000..f387bf4668 100644 --- a/engine/src/flutter/testing/scenario_app/lib/main.dart +++ b/engine/src/flutter/testing/scenario_app/lib/main.dart @@ -25,6 +25,7 @@ Map _scenarios = { 'platform_view_multiple': MultiPlatformViewScenario(window, firstId: 6, secondId: 7), 'platform_view_multiple_background_foreground': MultiPlatformViewBackgroundForegroundScenario(window, firstId: 8, secondId: 9), 'poppable_screen': PoppableScreenScenario(window), + 'platform_view_rotate': PlatformViewScenario(window, 'Rotate Platform View', id: 10), }; Scenario _currentScenario = _scenarios['animated_color_square'];