Skip to content

Commit

Permalink
[image_picker_platform_interface] fix test asset file location (flutt…
Browse files Browse the repository at this point in the history
  • Loading branch information
Chris Yang authored and adsonpleal committed Feb 26, 2021
1 parent ca3b906 commit 06472f5
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 16 deletions.
15 changes: 3 additions & 12 deletions packages/cross_file/test/x_file_io_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand All @@ -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));
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 1.1.6

* Fix test asset file location.

## 1.1.5

* Update Flutter SDK constraint.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ description: A common platform interface for the image_picker plugin.
homepage: https://github.com/flutter/plugins/tree/master/packages/image_picker/image_picker_platform_interface
# NOTE: We strongly prefer non-breaking changes, even at the expense of a
# less-clean API. See https://flutter.dev/go/platform-interface-breaking-changes
version: 1.1.5
version: 1.1.6

dependencies:
flutter:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,17 @@ import 'dart:typed_data';
import 'package:flutter_test/flutter_test.dart';
import 'package:image_picker_platform_interface/image_picker_platform_interface.dart';

final pathPrefix =
Directory.current.path.endsWith('test') ? './assets/' : './test/assets/';
final path = pathPrefix + 'hello.txt';
final String expectedStringContents = 'Hello, world!';
final Uint8List bytes = utf8.encode(expectedStringContents);
final File textFile = File('./assets/hello.txt');
final Uint8List bytes = Uint8List.fromList(utf8.encode(expectedStringContents));
final File textFile = File(path);
final String textFilePath = textFile.path;

void main() {
group('Create with an objectUrl', () {
final pickedFile = PickedFile(textFilePath);
final PickedFile pickedFile = PickedFile(textFilePath);

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

0 comments on commit 06472f5

Please sign in to comment.