@@ -59,15 +59,15 @@ Future<void> testExecutable(FutureOr<void> Function() testMain, {String? namePre
59
59
if (FlutterPostSubmitFileComparator .isForEnvironment (platform)) {
60
60
goldenFileComparator = await FlutterPostSubmitFileComparator .fromLocalFileComparator (
61
61
localFileComparator: goldenFileComparator as LocalFileComparator ,
62
- platform,
62
+ platform: platform ,
63
63
namePrefix: namePrefix,
64
64
log: print,
65
65
fs: fs,
66
66
);
67
67
} else if (FlutterPreSubmitFileComparator .isForEnvironment (platform)) {
68
68
goldenFileComparator = await FlutterPreSubmitFileComparator .fromLocalFileComparator (
69
69
localFileComparator: goldenFileComparator as LocalFileComparator ,
70
- platform,
70
+ platform: platform ,
71
71
namePrefix: namePrefix,
72
72
log: print,
73
73
fs: fs,
@@ -78,14 +78,15 @@ Future<void> testExecutable(FutureOr<void> Function() testMain, {String? namePre
78
78
'Golden file testing is not executed on Cirrus, or LUCI environments '
79
79
'outside of flutter/flutter, or in test shards that are not configured '
80
80
'for using goldctl.' ,
81
+ platform: platform,
81
82
namePrefix: namePrefix,
82
83
log: print,
83
84
fs: fs,
84
85
);
85
86
} else {
86
87
goldenFileComparator = await FlutterLocalFileComparator .fromLocalFileComparator (
87
88
localFileComparator: goldenFileComparator as LocalFileComparator ,
88
- platform,
89
+ platform: platform ,
89
90
log: print,
90
91
fs: fs,
91
92
);
@@ -133,15 +134,12 @@ abstract class FlutterGoldenFileComparator extends GoldenFileComparator {
133
134
/// information and files for interacting with the [skiaClient] . When testing
134
135
/// locally, the [basedir] will also contain any diffs from failed tests, or
135
136
/// goldens generated from newly introduced tests.
136
- ///
137
- /// The [platform] parameter is useful in tests, where the default
138
- /// platform can be replaced by a mock instance.
139
137
@visibleForTesting
140
138
FlutterGoldenFileComparator (
141
139
this .basedir,
142
140
this .skiaClient, {
143
141
required this .fs,
144
- this .platform = const LocalPlatform () ,
142
+ required this .platform,
145
143
this .namePrefix,
146
144
required this .log,
147
145
});
@@ -157,8 +155,8 @@ abstract class FlutterGoldenFileComparator extends GoldenFileComparator {
157
155
/// The file system used to perform file access.
158
156
final FileSystem fs;
159
157
160
- /// A wrapper for the [dart:io.Platform] API.
161
- @visibleForTesting
158
+ /// The environment (current working directory, identity of the OS,
159
+ /// environment variables, etc).
162
160
final Platform platform;
163
161
164
162
/// The prefix that is added to all golden names.
@@ -186,8 +184,8 @@ abstract class FlutterGoldenFileComparator extends GoldenFileComparator {
186
184
@protected
187
185
@visibleForTesting
188
186
static Directory getBaseDirectory (
189
- LocalFileComparator defaultComparator,
190
- Platform platform, {
187
+ LocalFileComparator defaultComparator, {
188
+ required Platform platform,
191
189
String ? suffix,
192
190
required FileSystem fs,
193
191
}) {
@@ -260,13 +258,13 @@ class FlutterPostSubmitFileComparator extends FlutterGoldenFileComparator {
260
258
/// Creates a [FlutterPostSubmitFileComparator] that will test golden file
261
259
/// images against Skia Gold.
262
260
///
263
- /// The [fs] and [platform] parameters are useful in tests, where the default
264
- /// file system and platform can be replaced by mock instances.
261
+ /// The [fs] parameter is useful in tests, where the default
262
+ /// file system can be replaced by mock instances.
265
263
FlutterPostSubmitFileComparator (
266
264
super .basedir,
267
265
super .skiaClient, {
268
266
required super .fs,
269
- super .platform,
267
+ required super .platform,
270
268
super .namePrefix,
271
269
required super .log,
272
270
});
@@ -275,27 +273,32 @@ class FlutterPostSubmitFileComparator extends FlutterGoldenFileComparator {
275
273
/// path resolution of the provided `localFileComparator` .
276
274
///
277
275
/// The [goldens] parameter is visible for testing purposes only.
278
- static Future <FlutterPostSubmitFileComparator > fromLocalFileComparator (
279
- final Platform platform, {
276
+ static Future <FlutterPostSubmitFileComparator > fromLocalFileComparator ({
280
277
SkiaGoldClient ? goldens,
281
278
required LocalFileComparator localFileComparator,
279
+ required Platform platform,
282
280
String ? namePrefix,
283
281
required LogCallback log,
284
282
required FileSystem fs,
285
283
}) async {
286
284
final Directory baseDirectory = FlutterGoldenFileComparator .getBaseDirectory (
287
285
localFileComparator,
288
- platform,
286
+ platform: platform ,
289
287
suffix: 'flutter_goldens_postsubmit.' ,
290
288
fs: fs,
291
289
);
292
290
baseDirectory.createSync (recursive: true );
293
291
294
- goldens ?? = SkiaGoldClient (baseDirectory, log: log);
292
+ goldens ?? = SkiaGoldClient (
293
+ baseDirectory,
294
+ log: log,
295
+ platform: platform,
296
+ );
295
297
await goldens.auth ();
296
298
return FlutterPostSubmitFileComparator (
297
299
baseDirectory.uri,
298
300
goldens,
301
+ platform: platform,
299
302
namePrefix: namePrefix,
300
303
log: log,
301
304
fs: fs,
@@ -342,13 +345,13 @@ class FlutterPreSubmitFileComparator extends FlutterGoldenFileComparator {
342
345
/// Creates a [FlutterPreSubmitFileComparator] that will test golden file
343
346
/// images against baselines requested from Flutter Gold.
344
347
///
345
- /// The [fs] and [platform] parameters are useful in tests, where the default
346
- /// file system and platform can be replaced by mock instances.
348
+ /// The [fs] parameter is useful in tests, where the default
349
+ /// file system can be replaced by mock instances.
347
350
FlutterPreSubmitFileComparator (
348
351
super .basedir,
349
352
super .skiaClient, {
350
353
required super .fs,
351
- super .platform,
354
+ required super .platform,
352
355
super .namePrefix,
353
356
required super .log,
354
357
});
@@ -357,18 +360,18 @@ class FlutterPreSubmitFileComparator extends FlutterGoldenFileComparator {
357
360
/// relative path resolution of the default [goldenFileComparator] .
358
361
///
359
362
/// The [goldens] parameter is visible for testing purposes only.
360
- static Future <FlutterGoldenFileComparator > fromLocalFileComparator (
361
- final Platform platform, {
363
+ static Future <FlutterGoldenFileComparator > fromLocalFileComparator ({
362
364
SkiaGoldClient ? goldens,
363
365
required LocalFileComparator localFileComparator,
366
+ required Platform platform,
364
367
Directory ? testBasedir,
365
368
String ? namePrefix,
366
369
required LogCallback log,
367
370
required FileSystem fs,
368
371
}) async {
369
372
final Directory baseDirectory = testBasedir ?? FlutterGoldenFileComparator .getBaseDirectory (
370
373
localFileComparator,
371
- platform,
374
+ platform: platform ,
372
375
suffix: 'flutter_goldens_presubmit.' ,
373
376
fs: fs,
374
377
);
@@ -377,12 +380,17 @@ class FlutterPreSubmitFileComparator extends FlutterGoldenFileComparator {
377
380
baseDirectory.createSync (recursive: true );
378
381
}
379
382
380
- goldens ?? = SkiaGoldClient (baseDirectory, log: log);
383
+ goldens ?? = SkiaGoldClient (
384
+ baseDirectory,
385
+ platform: platform,
386
+ log: log,
387
+ );
381
388
382
389
await goldens.auth ();
383
390
return FlutterPreSubmitFileComparator (
384
391
baseDirectory.uri,
385
- goldens, platform: platform,
392
+ goldens,
393
+ platform: platform,
386
394
namePrefix: namePrefix,
387
395
log: log,
388
396
fs: fs,
@@ -439,6 +447,7 @@ class FlutterSkippingFileComparator extends FlutterGoldenFileComparator {
439
447
super .skiaClient,
440
448
this .reason, {
441
449
super .namePrefix,
450
+ required super .platform,
442
451
required super .log,
443
452
required super .fs,
444
453
});
@@ -452,16 +461,22 @@ class FlutterSkippingFileComparator extends FlutterGoldenFileComparator {
452
461
String reason, {
453
462
required LocalFileComparator localFileComparator,
454
463
String ? namePrefix,
464
+ required Platform platform,
455
465
required LogCallback log,
456
466
required FileSystem fs,
457
467
}) {
458
468
final Uri basedir = localFileComparator.basedir;
459
- final SkiaGoldClient skiaClient = SkiaGoldClient (fs.directory (basedir), log: log);
469
+ final SkiaGoldClient skiaClient = SkiaGoldClient (
470
+ fs.directory (basedir),
471
+ platform: platform,
472
+ log: log,
473
+ );
460
474
return FlutterSkippingFileComparator (
461
475
basedir,
462
476
skiaClient,
463
477
reason,
464
478
namePrefix: namePrefix,
479
+ platform: platform,
465
480
log: log,
466
481
fs: fs,
467
482
);
@@ -519,13 +534,13 @@ class FlutterLocalFileComparator extends FlutterGoldenFileComparator with LocalC
519
534
/// Creates a [FlutterLocalFileComparator] that will test golden file
520
535
/// images against baselines requested from Flutter Gold.
521
536
///
522
- /// The [fs] and [platform] parameters are useful in tests, where the default
523
- /// file system and platform can be replaced by mock instances.
537
+ /// The [fs] parameter is useful in tests, where the default
538
+ /// file system can be replaced by mock instances.
524
539
FlutterLocalFileComparator (
525
540
super .basedir,
526
541
super .skiaClient, {
527
542
required super .fs,
528
- super .platform,
543
+ required super .platform,
529
544
required super .log,
530
545
});
531
546
@@ -534,25 +549,29 @@ class FlutterLocalFileComparator extends FlutterGoldenFileComparator with LocalC
534
549
///
535
550
/// The [goldens] and [baseDirectory] parameters are
536
551
/// visible for testing purposes only.
537
- static Future <FlutterGoldenFileComparator > fromLocalFileComparator (
538
- final Platform platform, {
552
+ static Future <FlutterGoldenFileComparator > fromLocalFileComparator ({
539
553
SkiaGoldClient ? goldens,
540
554
required LocalFileComparator localFileComparator,
555
+ required Platform platform,
541
556
Directory ? baseDirectory,
542
557
required LogCallback log,
543
558
required FileSystem fs,
544
559
}) async {
545
560
baseDirectory ?? = FlutterGoldenFileComparator .getBaseDirectory (
546
561
localFileComparator,
547
- platform,
562
+ platform: platform ,
548
563
fs: fs,
549
564
);
550
565
551
566
if (! baseDirectory.existsSync ()) {
552
567
baseDirectory.createSync (recursive: true );
553
568
}
554
569
555
- goldens ?? = SkiaGoldClient (baseDirectory, log: log);
570
+ goldens ?? = SkiaGoldClient (
571
+ baseDirectory,
572
+ platform: platform,
573
+ log: log,
574
+ );
556
575
try {
557
576
// Check if we can reach Gold.
558
577
await goldens.getExpectationForTest ('' );
@@ -562,6 +581,7 @@ class FlutterLocalFileComparator extends FlutterGoldenFileComparator with LocalC
562
581
goldens,
563
582
'OSError occurred, could not reach Gold. '
564
583
'Switching to FlutterSkippingGoldenFileComparator.' ,
584
+ platform: platform,
565
585
log: log,
566
586
fs: fs,
567
587
);
@@ -571,6 +591,7 @@ class FlutterLocalFileComparator extends FlutterGoldenFileComparator with LocalC
571
591
goldens,
572
592
'SocketException occurred, could not reach Gold. '
573
593
'Switching to FlutterSkippingGoldenFileComparator.' ,
594
+ platform: platform,
574
595
log: log,
575
596
fs: fs,
576
597
);
@@ -580,6 +601,7 @@ class FlutterLocalFileComparator extends FlutterGoldenFileComparator with LocalC
580
601
goldens,
581
602
'FormatException occurred, could not reach Gold. '
582
603
'Switching to FlutterSkippingGoldenFileComparator.' ,
604
+ platform: platform,
583
605
log: log,
584
606
fs: fs,
585
607
);
@@ -588,6 +610,7 @@ class FlutterLocalFileComparator extends FlutterGoldenFileComparator with LocalC
588
610
return FlutterLocalFileComparator (
589
611
baseDirectory.uri,
590
612
goldens,
613
+ platform: platform,
591
614
log: log,
592
615
fs: fs,
593
616
);
0 commit comments