Skip to content
This repository was archived by the owner on Feb 22, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
test for stable
  • Loading branch information
Chris Yang committed Jan 26, 2021
commit 90727ff821fbd08633ab03032a1ffba0be1ab391
19 changes: 8 additions & 11 deletions packages/cross_file/test/x_file_io_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,6 @@ 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 = './test/assets/';
final path = pathPrefix + 'hello.txt';
final String expectedStringContents = 'Hello, world!';
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
Expand Up @@ -14,11 +14,18 @@ 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('./test/assets/hello.txt');
final String textFilePath = textFile.path;
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