testImageReader method

Future<Uint8List?> testImageReader({
  1. required TestDeviceInfo deviceInfo,
  2. required String imageId,
  3. String? suiteName,
  4. required String testName,
  5. int? testVersion,
})

When running on a non-web platform this will read the images from the file system using the imagePath.

Implementation

Future<Uint8List?> testImageReader({
  required TestDeviceInfo deviceInfo,
  required String imageId,
  String? suiteName,
  required String testName,
  int? testVersion,
}) async {
  Uint8List? image;

  if (kIsWeb) {
    _logger.warning(
      '[IoTestStore] -- testImageReader not supported on web',
    );
  } else {
    var path = imagePath;

    if (suiteName?.isNotEmpty == true) {
      path = '${path}/_Suite_${suiteName}_';
    } else {
      path = '$path/';
    }

    path = '${path}Test_${testName}_$imageId.png';

    try {
      image = File(path).readAsBytesSync();
    } catch (e) {
      // no_op
    }
  }

  return image;
}