[image_picker_platform_interface] fix test asset file location (#3467)

This commit is contained in:
Chris Yang
2021-01-26 14:17:07 -08:00
committed by GitHub
parent 519abf9b5b
commit 897887f82e

View File

@ -11,17 +11,8 @@ import 'dart:typed_data';
import 'package:flutter_test/flutter_test.dart';
import 'package:cross_file/cross_file.dart';
// Please note that executing this test with command
// `flutter test test/x_file_io_test.dart` will set the directory
// to ./file_selector_platform_interface.
//
// This will cause our hello.txt file to be not be found. Please
// execute this test with `flutter test` or change the path prefix
// to ./test/assets/
//
// https://github.com/flutter/flutter/issues/20907
final pathPrefix = './assets/';
final pathPrefix =
Directory.current.path.endsWith('test') ? './assets/' : './test/assets/';
final path = pathPrefix + 'hello.txt';
final String expectedStringContents = 'Hello, world!';
final Uint8List bytes = Uint8List.fromList(utf8.encode(expectedStringContents));
@ -30,7 +21,7 @@ final String textFilePath = textFile.path;
void main() {
group('Create with a path', () {
final file = XFile(textFilePath);
final XFile file = XFile(textFilePath);
test('Can be read as a string', () async {
expect(await file.readAsString(), equals(expectedStringContents));