Unverified Commit 389ebd46 authored by Jonah Williams's avatar Jonah Williams Committed by GitHub

Wide gamut and platform view integration test. (#138837)

In https://github.com/flutter/engine/pull/48190 I discovered that overlay surfaces were not constructed with wide gamut settings. This adds a test that will fail until this is fixed.
parent 397fd25b
...@@ -166,6 +166,15 @@ void main() { ...@@ -166,6 +166,15 @@ void main() {
app.run(app.Setup.drawnImage); app.run(app.Setup.drawnImage);
await tester.pumpAndSettle(const Duration(seconds: 2)); await tester.pumpAndSettle(const Duration(seconds: 2));
const MethodChannel channel = MethodChannel('flutter/screenshot');
final List<Object?> result =
await channel.invokeMethod('test') as List<Object?>;
expect(_findColor(result, <double>[0.0, 1.0, 0.0]), isTrue);
});
testWidgets('draw image with wide gamut works ontop of platform view with blur', (WidgetTester tester) async {
app.run(app.Setup.drawnImageAndPlatformView);
await tester.pumpAndSettle(const Duration(seconds: 2));
const MethodChannel channel = MethodChannel('flutter/screenshot'); const MethodChannel channel = MethodChannel('flutter/screenshot');
final List<Object?> result = final List<Object?> result =
await channel.invokeMethod('test') as List<Object?>; await channel.invokeMethod('test') as List<Object?>;
......
// Copyright 2014 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import UIKit
import Flutter
@UIApplicationMain
@objc class AppDelegate: FlutterAppDelegate {
override func application(
_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
) -> Bool {
GeneratedPluginRegistrant.register(with: self)
var registrar = self.registrar(forPlugin: "plugin-name")
let factory = FLNativeViewFactory(messenger: registrar!.messenger())
self.registrar(forPlugin: "<plugin-name>")!.register(
factory,
withId: "<dummy-view>")
return super.application(application, didFinishLaunchingWithOptions: launchOptions)
}
}
// Copyright 2014 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import Foundation
import Flutter
import UIKit
class FLNativeViewFactory: NSObject, FlutterPlatformViewFactory {
private var messenger: FlutterBinaryMessenger
init(messenger: FlutterBinaryMessenger) {
self.messenger = messenger
super.init()
}
func create(
withFrame frame: CGRect,
viewIdentifier viewId: Int64,
arguments args: Any?
) -> FlutterPlatformView {
return FLNativeView(
frame: frame,
viewIdentifier: viewId,
arguments: args,
binaryMessenger: messenger)
}
public func createArgsCodec() -> FlutterMessageCodec & NSObjectProtocol {
return FlutterStandardMessageCodec.sharedInstance()
}
}
class SolidColorView: UIView {
override init(frame: CGRect) {
super.init(frame: frame)
setupView()
}
required init?(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
setupView()
}
private func setupView() {
backgroundColor = .blue
}
}
class FLNativeView: NSObject, FlutterPlatformView {
private var view: UIView
init(
frame: CGRect,
viewIdentifier viewId: Int64,
arguments args: Any?,
binaryMessenger messenger: FlutterBinaryMessenger?
) {
view = SolidColorView()
super.init()
}
func view() -> UIView {
return view
}
}
...@@ -145,6 +145,7 @@ enum Setup { ...@@ -145,6 +145,7 @@ enum Setup {
canvasSaveLayer, canvasSaveLayer,
blur, blur,
drawnImage, drawnImage,
drawnImageAndPlatformView
} }
void run(Setup setup) { void run(Setup setup) {
...@@ -244,6 +245,19 @@ Future<ui.Image> _loadImage() async { ...@@ -244,6 +245,19 @@ Future<ui.Image> _loadImage() async {
return (await codec.getNextFrame()).image; return (await codec.getNextFrame()).image;
} }
class DummyPlatformView extends StatelessWidget {
const DummyPlatformView({super.key});
@override
Widget build(BuildContext context) {
return const SizedBox(
width: 400,
height: 400,
child: UiKitView(viewType: '<dummy-view>'),
);
}
}
class MyHomePage extends StatefulWidget { class MyHomePage extends StatefulWidget {
const MyHomePage(this.setup, {super.key, required this.title}); const MyHomePage(this.setup, {super.key, required this.title});
...@@ -285,6 +299,14 @@ class _MyHomePageState extends State<MyHomePage> { ...@@ -285,6 +299,14 @@ class _MyHomePageState extends State<MyHomePage> {
imageWidget = Image.memory(base64Decode(_displayP3Logo)); imageWidget = Image.memory(base64Decode(_displayP3Logo));
case Setup.drawnImage: case Setup.drawnImage:
imageWidget = CustomPaint(painter: _SaveLayerDrawer(_image)); imageWidget = CustomPaint(painter: _SaveLayerDrawer(_image));
case Setup.drawnImageAndPlatformView:
imageWidget = Stack(
children: <Widget>[
const DummyPlatformView(),
Image.memory(base64Decode(_displayP3Logo)),
BackdropFilter(filter: ui.ImageFilter.blur(sigmaX: 6, sigmaY: 6), child: const SizedBox(width: 400, height: 400)),
],
);
case Setup.canvasSaveLayer: case Setup.canvasSaveLayer:
imageWidget = CustomPaint(painter: _SaveLayerDrawer(_image)); imageWidget = CustomPaint(painter: _SaveLayerDrawer(_image));
case Setup.blur: case Setup.blur:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment