Skip to content
This repository was archived by the owner on Feb 22, 2023. It is now read-only.

Commit 98d87d0

Browse files
author
Chris Yang
authored
[image_picker_platform_interface] fix test asset file location (#3467)
1 parent ca99211 commit 98d87d0

File tree

4 files changed

+14
-16
lines changed

4 files changed

+14
-16
lines changed

packages/cross_file/test/x_file_io_test.dart

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,8 @@ import 'dart:typed_data';
1111
import 'package:flutter_test/flutter_test.dart';
1212
import 'package:cross_file/cross_file.dart';
1313

14-
// Please note that executing this test with command
15-
// `flutter test test/x_file_io_test.dart` will set the directory
16-
// to ./file_selector_platform_interface.
17-
//
18-
// This will cause our hello.txt file to be not be found. Please
19-
// execute this test with `flutter test` or change the path prefix
20-
// to ./test/assets/
21-
//
22-
// https://github.com/flutter/flutter/issues/20907
23-
24-
final pathPrefix = './assets/';
14+
final pathPrefix =
15+
Directory.current.path.endsWith('test') ? './assets/' : './test/assets/';
2516
final path = pathPrefix + 'hello.txt';
2617
final String expectedStringContents = 'Hello, world!';
2718
final Uint8List bytes = Uint8List.fromList(utf8.encode(expectedStringContents));
@@ -30,7 +21,7 @@ final String textFilePath = textFile.path;
3021

3122
void main() {
3223
group('Create with a path', () {
33-
final file = XFile(textFilePath);
24+
final XFile file = XFile(textFilePath);
3425

3526
test('Can be read as a string', () async {
3627
expect(await file.readAsString(), equals(expectedStringContents));

packages/image_picker/image_picker_platform_interface/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 1.1.6
2+
3+
* Fix test asset file location.
4+
15
## 1.1.5
26

37
* Update Flutter SDK constraint.

packages/image_picker/image_picker_platform_interface/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ description: A common platform interface for the image_picker plugin.
33
homepage: https://github.com/flutter/plugins/tree/master/packages/image_picker/image_picker_platform_interface
44
# NOTE: We strongly prefer non-breaking changes, even at the expense of a
55
# less-clean API. See https://flutter.dev/go/platform-interface-breaking-changes
6-
version: 1.1.5
6+
version: 1.1.6
77

88
dependencies:
99
flutter:

packages/image_picker/image_picker_platform_interface/test/picked_file_io_test.dart

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,17 @@ import 'dart:typed_data';
1111
import 'package:flutter_test/flutter_test.dart';
1212
import 'package:image_picker_platform_interface/image_picker_platform_interface.dart';
1313

14+
final pathPrefix =
15+
Directory.current.path.endsWith('test') ? './assets/' : './test/assets/';
16+
final path = pathPrefix + 'hello.txt';
1417
final String expectedStringContents = 'Hello, world!';
15-
final Uint8List bytes = utf8.encode(expectedStringContents);
16-
final File textFile = File('./assets/hello.txt');
18+
final Uint8List bytes = Uint8List.fromList(utf8.encode(expectedStringContents));
19+
final File textFile = File(path);
1720
final String textFilePath = textFile.path;
1821

1922
void main() {
2023
group('Create with an objectUrl', () {
21-
final pickedFile = PickedFile(textFilePath);
24+
final PickedFile pickedFile = PickedFile(textFilePath);
2225

2326
test('Can be read as a string', () async {
2427
expect(await pickedFile.readAsString(), equals(expectedStringContents));

0 commit comments

Comments
 (0)