From 4f66f1333f43327ae1c7f07b4f29b088899557df Mon Sep 17 00:00:00 2001 From: gaaclarke <30870216+gaaclarke@users.noreply.github.com> Date: Fri, 25 Oct 2024 10:04:57 -0700 Subject: [PATCH] Wide gamut framework gradient test (#153976) issue: https://github.com/flutter/flutter/issues/127855 depends on https://github.com/flutter/engine/pull/54748 being rolled into the framework --- .../integration_test/app_test.dart | 40 +++++++ .../wide_gamut_test/lib/main.dart | 106 +++++++++++++++++- 2 files changed, 144 insertions(+), 2 deletions(-) diff --git a/dev/integration_tests/wide_gamut_test/integration_test/app_test.dart b/dev/integration_tests/wide_gamut_test/integration_test/app_test.dart index a120d1c2ae..5a562df674 100644 --- a/dev/integration_tests/wide_gamut_test/integration_test/app_test.dart +++ b/dev/integration_tests/wide_gamut_test/integration_test/app_test.dart @@ -175,5 +175,45 @@ void main() { await channel.invokeMethod('test') as List; expect(_findColor(result, _deepRed), isTrue); }); + + testWidgets('draw wide gamut linear gradient works', (WidgetTester tester) async { + app.run(app.Setup.linearGradient); + await tester.pumpAndSettle(const Duration(seconds: 2)); + + const MethodChannel channel = MethodChannel('flutter/screenshot'); + final List result = + await channel.invokeMethod('test') as List; + expect(_findColor(result, _deepRed), isTrue); + }); + + testWidgets('draw wide gamut radial gradient works', (WidgetTester tester) async { + app.run(app.Setup.radialGradient); + await tester.pumpAndSettle(const Duration(seconds: 2)); + + const MethodChannel channel = MethodChannel('flutter/screenshot'); + final List result = + await channel.invokeMethod('test') as List; + expect(_findColor(result, _deepRed), isTrue); + }); + + testWidgets('draw wide gamut conical gradient works', (WidgetTester tester) async { + app.run(app.Setup.conicalGradient); + await tester.pumpAndSettle(const Duration(seconds: 2)); + + const MethodChannel channel = MethodChannel('flutter/screenshot'); + final List result = + await channel.invokeMethod('test') as List; + expect(_findColor(result, _deepRed), isTrue); + }); + + testWidgets('draw wide gamut sweep gradient works', (WidgetTester tester) async { + app.run(app.Setup.sweepGradient); + await tester.pumpAndSettle(const Duration(seconds: 2)); + + const MethodChannel channel = MethodChannel('flutter/screenshot'); + final List result = + await channel.invokeMethod('test') as List; + expect(_findColor(result, _deepRed), isTrue); + }); }); } diff --git a/dev/integration_tests/wide_gamut_test/lib/main.dart b/dev/integration_tests/wide_gamut_test/lib/main.dart index 3d7d035098..bfd5a70fb2 100644 --- a/dev/integration_tests/wide_gamut_test/lib/main.dart +++ b/dev/integration_tests/wide_gamut_test/lib/main.dart @@ -137,7 +137,7 @@ const String _displayP3Logo = 'gr3yrjmlwqXLjmWw1O2I5Wmp9Xxjyh+AVIZ6ADIAqcwClakzeMgApDILVKbO4CED' 'kMosUJk6g4dUBuRfvf1am9VRqzYAAAAASUVORK5CYII='; -void main() => run(Setup.container); +void main() => run(Setup.sweepGradient); enum Setup { none, @@ -146,6 +146,10 @@ enum Setup { blur, drawnImage, container, + linearGradient, + radialGradient, + conicalGradient, + sweepGradient, } void run(Setup setup) { @@ -265,7 +269,14 @@ class _MyHomePageState extends State { _loadImage().then((ui.Image? value) => setState(() { _image = value; })); case Setup.drawnImage: _drawImage().then((ui.Image? value) => setState(() { _image = value; })); - case Setup.image || Setup.blur || Setup.none || Setup.container: + case Setup.image || + Setup.blur || + Setup.none || + Setup.container || + Setup.linearGradient || + Setup.radialGradient || + Setup.conicalGradient || + Setup.sweepGradient: break; } super.initState(); @@ -308,6 +319,97 @@ class _MyHomePageState extends State { green: 0, blue: 0, colorSpace: ui.ColorSpace.displayP3)); + case Setup.linearGradient: + imageWidget = Container( + width: 100, + height: 100, + decoration: const BoxDecoration( + gradient: LinearGradient( + begin: Alignment.topLeft, + end: Alignment.bottomRight, + colors: [ + Color.from( + alpha: 1, + red: 1, + green: 0, + blue: 0, + colorSpace: ui.ColorSpace.displayP3), + Color.from( + alpha: 1, + red: 0, + green: 1, + blue: 0, + colorSpace: ui.ColorSpace.displayP3)], + ), + ), + ); + case Setup.radialGradient: + imageWidget = Container( + width: 100, + height: 100, + decoration: const BoxDecoration( + gradient: RadialGradient( + colors: [ + Color.from( + alpha: 1, + red: 1, + green: 0, + blue: 0, + colorSpace: ui.ColorSpace.displayP3), + Color.from( + alpha: 1, + red: 0, + green: 1, + blue: 0, + colorSpace: ui.ColorSpace.displayP3)], + ), + ), + ); + case Setup.conicalGradient: + imageWidget = Container( + width: 100, + height: 100, + decoration: const BoxDecoration( + gradient: RadialGradient( + focal: Alignment(0.2, 0.2), + colors: [ + Color.from( + alpha: 1, + red: 1, + green: 0, + blue: 0, + colorSpace: ui.ColorSpace.displayP3), + Color.from( + alpha: 1, + red: 0, + green: 1, + blue: 0, + colorSpace: ui.ColorSpace.displayP3)], + ), + ), + ); + case Setup.sweepGradient: + imageWidget = Container( + width: 100, + height: 100, + decoration: const BoxDecoration( + gradient: SweepGradient( + colors: [ + Color.from( + alpha: 1, + red: 1, + green: 0, + blue: 0, + colorSpace: ui.ColorSpace.displayP3), + Color.from( + alpha: 1, + red: 0, + green: 1, + blue: 0, + colorSpace: ui.ColorSpace.displayP3)], + ), + ), + ); } return Scaffold(