Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(158)

Unified Diff: tests/html/fileapi_test.dart

Issue 2771453003: Format all tests. (Closed)
Patch Set: Format files Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: tests/html/fileapi_test.dart
diff --git a/tests/html/fileapi_test.dart b/tests/html/fileapi_test.dart
index edc6fa26fa7d596c32eb3621afd5cb8bc923f993..4c36c53e71c0ad689af95e9971862f6e0c1469e8 100644
--- a/tests/html/fileapi_test.dart
+++ b/tests/html/fileapi_test.dart
@@ -1,4 +1,5 @@
library fileapi;
+
import 'package:unittest/unittest.dart';
import 'package:unittest/html_individual_config.dart';
import 'dart:html';
@@ -22,10 +23,9 @@ main() {
});
getFileSystem() {
- return window.requestFileSystem(100)
- .then((FileSystem fileSystem) {
- fs = fileSystem;
- });
+ return window.requestFileSystem(100).then((FileSystem fileSystem) {
+ fs = fileSystem;
+ });
}
group('unsupported_throws', () {
@@ -42,20 +42,16 @@ main() {
test('getFileSystem', getFileSystem);
test('directoryDoesntExist', () {
- return fs.root.getDirectory(
- 'directory2')
- .catchError((error) {
- expect(error.code, equals(FileError.NOT_FOUND_ERR));
- }, test: (e) => e is FileError);
- });
+ return fs.root.getDirectory('directory2').catchError((error) {
+ expect(error.code, equals(FileError.NOT_FOUND_ERR));
+ }, test: (e) => e is FileError);
+ });
test('directoryCreate', () {
- return fs.root.createDirectory(
- 'directory3')
- .then((DirectoryEntry e) {
- expect(e.name, equals('directory3'));
- });
+ return fs.root.createDirectory('directory3').then((DirectoryEntry e) {
+ expect(e.name, equals('directory3'));
});
+ });
}
});
@@ -64,44 +60,38 @@ main() {
test('getFileSystem', getFileSystem);
test('fileDoesntExist', () {
- return fs.root.getFile(
- 'file2')
- .catchError((error) {
- expect(error.code, equals(FileError.NOT_FOUND_ERR));
- }, test: (e) => e is FileError);
+ return fs.root.getFile('file2').catchError((error) {
+ expect(error.code, equals(FileError.NOT_FOUND_ERR));
+ }, test: (e) => e is FileError);
});
test('fileCreate', () {
- return fs.root.createFile(
- 'file4')
- .then((FileEntry e) {
- expect(e.name, equals('file4'));
- expect(e.isFile, isTrue);
- return e.getMetadata();
- }).then((Metadata metadata) {
- var changeTime = metadata.modificationTime;
- // Upped because our Windows buildbots can sometimes be particularly
- // slow.
- expect(new DateTime.now().difference(changeTime).inMinutes,
- lessThan(4));
- expect(metadata.size, equals(0));
- });
+ return fs.root.createFile('file4').then((FileEntry e) {
+ expect(e.name, equals('file4'));
+ expect(e.isFile, isTrue);
+ return e.getMetadata();
+ }).then((Metadata metadata) {
+ var changeTime = metadata.modificationTime;
+ // Upped because our Windows buildbots can sometimes be particularly
+ // slow.
+ expect(
+ new DateTime.now().difference(changeTime).inMinutes, lessThan(4));
+ expect(metadata.size, equals(0));
});
+ });
}
});
// Do the boilerplate to get several files and directories created to then
// test the functions that use those items.
Future doDirSetup(String testName) {
- return fs.root.createFile(
- 'file_$testName')
- .then((FileEntry file) {
- return fs.root.createDirectory(
- 'dir_$testName')
- .then((DirectoryEntry dir) {
- return new Future.value(new FileAndDir(file, dir));
- });
- });
+ return fs.root.createFile('file_$testName').then((FileEntry file) {
+ return fs.root
+ .createDirectory('dir_$testName')
+ .then((DirectoryEntry dir) {
+ return new Future.value(new FileAndDir(file, dir));
+ });
+ });
}
group('directoryReader', () {
@@ -109,13 +99,12 @@ main() {
test('getFileSystem', getFileSystem);
test('readEntries', () {
- return doDirSetup('readEntries')
- .then((fileAndDir) {
- var reader = fileAndDir.dir.createReader();
- return reader.readEntries();
- }).then((entries) {
- expect(entries is List, true);
- });
+ return doDirSetup('readEntries').then((fileAndDir) {
+ var reader = fileAndDir.dir.createReader();
+ return reader.readEntries();
+ }).then((entries) {
+ expect(entries is List, true);
+ });
});
}
});
@@ -125,43 +114,39 @@ main() {
test('getFileSystem', getFileSystem);
test('copyTo', () {
- return doDirSetup('copyTo')
- .then((fileAndDir) {
- return fileAndDir.file.copyTo(fileAndDir.dir, name: 'copiedFile');
- }).then((entry) {
- expect(entry.isFile, true);
- expect(entry.name, 'copiedFile');
- });
+ return doDirSetup('copyTo').then((fileAndDir) {
+ return fileAndDir.file.copyTo(fileAndDir.dir, name: 'copiedFile');
+ }).then((entry) {
+ expect(entry.isFile, true);
+ expect(entry.name, 'copiedFile');
+ });
});
test('getParent', () {
- return doDirSetup('getParent')
- .then((fileAndDir) {
- return fileAndDir.file.getParent();
- }).then((entry) {
- expect(entry.name, '');
- expect(entry.isFile, false);
- });
+ return doDirSetup('getParent').then((fileAndDir) {
+ return fileAndDir.file.getParent();
+ }).then((entry) {
+ expect(entry.name, '');
+ expect(entry.isFile, false);
+ });
});
test('moveTo', () {
- return doDirSetup('moveTo')
- .then((fileAndDir) {
- return fileAndDir.file.moveTo(fileAndDir.dir, name: 'movedFile');
- }).then((entry) {
- expect(entry.name, 'movedFile');
- expect(entry.fullPath, '/dir_moveTo/movedFile');
- return fs.root.getFile('file4');
- }).catchError((error) {
- expect(error.code, equals(FileError.NOT_FOUND_ERR));
- }, test: (e) => e is FileError);
+ return doDirSetup('moveTo').then((fileAndDir) {
+ return fileAndDir.file.moveTo(fileAndDir.dir, name: 'movedFile');
+ }).then((entry) {
+ expect(entry.name, 'movedFile');
+ expect(entry.fullPath, '/dir_moveTo/movedFile');
+ return fs.root.getFile('file4');
+ }).catchError((error) {
+ expect(error.code, equals(FileError.NOT_FOUND_ERR));
+ }, test: (e) => e is FileError);
});
test('remove', () {
- return doDirSetup('remove')
- .then((fileAndDir) {
- return fileAndDir.file.remove().then((_) {});
- });
+ return doDirSetup('remove').then((fileAndDir) {
+ return fileAndDir.file.remove().then((_) {});
+ });
});
}
});
@@ -171,27 +156,27 @@ main() {
test('getFileSystem', getFileSystem);
test('createWriter', () {
- return doDirSetup('createWriter')
- .then((fileAndDir) {
- return fileAndDir.file.createWriter();
- }).then((writer) {
- expect(writer.position, 0);
- expect(writer.readyState, FileWriter.INIT);
- expect(writer.length, 0);
- });
+ return doDirSetup('createWriter').then((fileAndDir) {
+ return fileAndDir.file.createWriter();
+ }).then((writer) {
+ expect(writer.position, 0);
+ expect(writer.readyState, FileWriter.INIT);
+ expect(writer.length, 0);
+ });
});
test('file', () {
- return doDirSetup('file')
- .then((fileAndDir) {
- return fileAndDir.file.file()
- .then((fileObj) {
- expect(fileObj.name, fileAndDir.file.name);
- expect(fileObj.relativePath, '');
- expect(new DateTime.now().difference(
- fileObj.lastModifiedDate).inSeconds, lessThan(60));
- });
+ return doDirSetup('file').then((fileAndDir) {
+ return fileAndDir.file.file().then((fileObj) {
+ expect(fileObj.name, fileAndDir.file.name);
+ expect(fileObj.relativePath, '');
+ expect(
+ new DateTime.now()
+ .difference(fileObj.lastModifiedDate)
+ .inSeconds,
+ lessThan(60));
});
+ });
});
}
});

Powered by Google App Engine
This is Rietveld 408576698