testImageReader method
Reader to read a golden image from Cloud Storage.
Implementation
Future<Uint8List?> testImageReader({
required TestDeviceInfo deviceInfo,
required String imageId,
String? suiteName,
required String testName,
int? testVersion,
}) async {
final goldenId = GoldenTestImages.createId(
deviceInfo: deviceInfo,
suiteName: suiteName,
testName: testName,
);
GoldenTestImages? golden;
if (_currentGoldenTestImages?.id == goldenId) {
golden = _currentGoldenTestImages;
} else {
final actualCollectionPath = '${testCollectionPath ?? 'tests'}/goldens';
final name = '$goldenId.json';
final data = await downloadTextFile([actualCollectionPath, name]);
final goldenJson = json.decode(data);
golden = GoldenTestImages.fromDynamic(goldenJson);
}
Uint8List? image;
if (golden != null) {
final hash = golden.goldenHashes![imageId];
image = await downloadImage(hash);
}
return image;
}