55// This file is hand-formatted.
66
77import 'dart:io' show Platform;
8+ import 'dart:ui' as ui;
89
910import 'package:flutter/material.dart' ;
1011import 'package:flutter_test/flutter_test.dart' ;
1112import 'package:rfw/formats.dart' show parseLibraryFile;
1213import 'package:rfw/rfw.dart' ;
1314
15+ final bool masterChannel =
16+ ! Platform .environment.containsKey ('CHANNEL' ) ||
17+ Platform .environment['CHANNEL' ] == 'master' ;
18+
1419// See Contributing section of README.md file.
15- final bool runGoldens = Platform .isLinux &&
16- (! Platform .environment.containsKey ('CHANNEL' ) ||
17- Platform .environment['CHANNEL' ] == 'master' );
20+ final bool runGoldens = Platform .isLinux && masterChannel;
1821
1922void main () {
2023 testWidgets ('String example' , (WidgetTester tester) async {
@@ -238,13 +241,17 @@ void main() {
238241 ..update (const LibraryName (< String > ['core' ]), createCoreWidgets ())
239242 ..update (const LibraryName (< String > ['test' ]), parseLibraryFile ('import core; widget root = SizedBox();' ));
240243 final DynamicContent data = DynamicContent ();
244+ final List <String > eventLog = < String > [];
241245 await tester.pumpWidget (
242246 Directionality (
243247 textDirection: TextDirection .rtl,
244248 child: RemoteWidget (
245249 runtime: runtime,
246250 data: data,
247251 widget: const FullyQualifiedWidgetName (LibraryName (< String > ['test' ]), 'root' ),
252+ onEvent: (String eventName, DynamicMap eventArguments) {
253+ eventLog.add ('$eventName $eventArguments ' );
254+ },
248255 ),
249256 ),
250257 );
@@ -256,6 +263,20 @@ void main() {
256263 insets: ArgumentDecoders .edgeInsets (source, < Object > ['insets' ]) ?? EdgeInsets .zero,
257264 );
258265 };
266+ ArgumentDecoders .gradientDecoders['custom' ] = (DataSource source, List <Object > key) {
267+ return const RadialGradient (
268+ center: Alignment (0.7 , - 0.6 ),
269+ radius: 0.2 ,
270+ colors: < Color > [ Color (0xFFFFFF00 ), Color (0xFF0099FF ) ],
271+ stops: < double > [0.4 , 1.0 ],
272+ );
273+ };
274+ ArgumentDecoders .shapeBorderDecoders['custom' ] = (DataSource source, List <Object > key) {
275+ return StarBorder (
276+ side: ArgumentDecoders .borderSide (source, < Object > [...key, 'side' ]) ?? const BorderSide (width: 2.0 , color: Color (0xFFFFFFFF )),
277+ points: source.v <double >(< Object > [...key, 'points' ]) ?? 5.0 ,
278+ );
279+ };
259280
260281 runtime.update (const LibraryName (< String > ['test' ]), parseLibraryFile ('''
261282 import core;
@@ -297,6 +318,7 @@ void main() {
297318 color: 0xFF8811FF,
298319 blendMode: "xor",
299320 },
321+ onError: event 'image-error-event' { },
300322 },
301323 gradient: {
302324 type: 'linear',
@@ -338,7 +360,7 @@ void main() {
338360 { type: 'continuous', borderRadius: [ { x: 60.0 }, { x: 80.0 }, { x: 0.0 }, { x: 20.0, y: 50.0 } ], side: { width: 10.0, color: 0xFFEEFF33 } },
339361 { type: 'rounded', borderRadius: [ { x: 20.0 } ], side: { width: 10.0, color: 0xFF00CCFF } },
340362 { type: 'stadium', side: { width: 10.0, color: 0xFF00FFFF } },
341- { type: 'custom', side: { width: 100 .0, color: 0xFFFF0000 } }, // should not render
363+ { type: 'custom', side: { width: 5 .0, color: 0xFFFFFF00 }, points: 6 }, // star
342364 ],
343365 gradient: {
344366 type: 'radial',
@@ -349,10 +371,13 @@ void main() {
349371 );
350372 ''' ));
351373 await tester.pump ();
374+ expect (eventLog, hasLength (1 ));
375+ expect (eventLog.first, startsWith ('image-error-event {exception: HTTP request failed, statusCode: 400, x-invalid:' ));
376+ eventLog.clear ();
352377 await expectLater (
353378 find.byType (RemoteWidget ),
354379 matchesGoldenFile ('goldens/argument_decoders_test.containers.png' ),
355- skip: 'https://github.com/flutter/flutter/issues/106205'
380+ skip: ! runGoldens,
356381 );
357382 expect (find.byType (DecoratedBox ), findsNWidgets (6 ));
358383 expect (
@@ -368,6 +393,16 @@ void main() {
368393 'opacity 1.0, FilterQuality.low)' ,
369394 );
370395
396+ ArgumentDecoders .colorFilterDecoders['custom' ] = (DataSource source, List <Object > key) {
397+ return const ColorFilter .mode (Color (0x12345678 ), BlendMode .xor);
398+ };
399+ ArgumentDecoders .maskFilterDecoders['custom' ] = (DataSource source, List <Object > key) {
400+ return const MaskFilter .blur (BlurStyle .outer, 0.5 );
401+ };
402+ ArgumentDecoders .shaderDecoders['custom' ] = (DataSource source, List <Object > key) {
403+ return ui.Gradient .linear (Offset .zero, const Offset (100.0 , 100.0 ), const < Color > [Color (0xFFFFFF00 ), Color (0xFF00FFFF )]);
404+ };
405+
371406 runtime.update (const LibraryName (< String > ['test' ]), parseLibraryFile ('''
372407 import core;
373408 widget root = Column(
@@ -428,7 +463,7 @@ void main() {
428463 await expectLater (
429464 find.byType (RemoteWidget ),
430465 matchesGoldenFile ('goldens/argument_decoders_test.text.png' ),
431- skip: 'https://github.com/flutter/flutter/issues/106205'
466+ skip: ! runGoldens,
432467 );
433468
434469 runtime.update (const LibraryName (< String > ['test' ]), parseLibraryFile ('''
@@ -451,7 +486,7 @@ void main() {
451486 await expectLater (
452487 find.byType (RemoteWidget ),
453488 matchesGoldenFile ('goldens/argument_decoders_test.gridview.fixed.png' ),
454- skip: 'https://github.com/flutter/flutter/issues/106205'
489+ skip: ! runGoldens,
455490 );
456491
457492 runtime.update (const LibraryName (< String > ['test' ]), parseLibraryFile ('''
@@ -474,7 +509,7 @@ void main() {
474509 await expectLater (
475510 find.byType (RemoteWidget ),
476511 matchesGoldenFile ('goldens/argument_decoders_test.gridview.max.png' ),
477- skip: 'https://github.com/flutter/flutter/issues/106205'
512+ skip: ! runGoldens,
478513 );
479514
480515 int sawGridDelegateDecoder = 0 ;
@@ -504,7 +539,9 @@ void main() {
504539 await expectLater (
505540 find.byType (RemoteWidget ),
506541 matchesGoldenFile ('goldens/argument_decoders_test.gridview.custom.png' ),
507- skip: 'https://github.com/flutter/flutter/issues/106205'
542+ skip: ! runGoldens,
508543 );
509- }, skip: ! runGoldens);
544+
545+ expect (eventLog, isEmpty);
546+ }, skip: ! masterChannel); // https://github.com/flutter/flutter/pull/129851
510547}
0 commit comments