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

[image_picker_platform_interface] fix test asset file location #3467

Merged
merged 3 commits into from
Jan 26, 2021
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 9 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,7 @@ 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 = './test/assets/';
final path = pathPrefix + 'hello.txt';
final String expectedStringContents = 'Hello, world!';
final Uint8List bytes = Uint8List.fromList(utf8.encode(expectedStringContents));
Expand All @@ -30,7 +20,14 @@ final String textFilePath = textFile.path;

void main() {
group('Create with a path', () {
final file = XFile(textFilePath);
XFile file;
if (Directory(textFilePath).existsSync()) {
file = XFile(textFilePath);
} else {
// TODO(cyanglaz): remove this alternative file location when https://github.com/flutter/flutter/commit/22f170042746ff253997236f6350ecb7403cf3b1
// lands on stable.
file = XFile(File('./assets/hello.txt').path);
}

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 @@ -13,12 +13,19 @@ import 'package:image_picker_platform_interface/image_picker_platform_interface.

final String expectedStringContents = 'Hello, world!';
final Uint8List bytes = utf8.encode(expectedStringContents);
final File textFile = File('./assets/hello.txt');
final String textFilePath = textFile.path;
final File textFile = File('./test/assets/hello.txt');
String textFilePath = textFile.path;

void main() {
group('Create with an objectUrl', () {
final pickedFile = PickedFile(textFilePath);
PickedFile pickedFile;
if (Directory(textFilePath).existsSync()) {
pickedFile = PickedFile(textFilePath);
} else {
// TODO(cyanglaz): remove this alternative file location when https://github.com/flutter/flutter/commit/22f170042746ff253997236f6350ecb7403cf3b1
// lands on stable.
pickedFile = PickedFile(File('./assets/hello.txt').path);
}

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