| OLD | NEW |
| 1 library fileapi; | 1 library fileapi; |
| 2 import '../../pkg/unittest/lib/unittest.dart'; | 2 import '../../pkg/unittest/lib/unittest.dart'; |
| 3 import '../../pkg/unittest/lib/html_individual_config.dart'; | 3 import '../../pkg/unittest/lib/html_individual_config.dart'; |
| 4 import 'dart:html'; | 4 import 'dart:html'; |
| 5 import 'dart:async'; | 5 import 'dart:async'; |
| 6 | 6 |
| 7 class FileAndDir { | 7 class FileAndDir { |
| 8 FileEntry file; | 8 FileEntry file; |
| 9 DirectoryEntry dir; | 9 DirectoryEntry dir; |
| 10 FileAndDir(this.file, this.dir); | 10 FileAndDir(this.file, this.dir); |
| (...skipping 26 matching lines...) Expand all Loading... |
| 37 }); | 37 }); |
| 38 }); | 38 }); |
| 39 | 39 |
| 40 group('getDirectory', () { | 40 group('getDirectory', () { |
| 41 if (FileSystem.supported) { | 41 if (FileSystem.supported) { |
| 42 test('getFileSystem', getFileSystem); | 42 test('getFileSystem', getFileSystem); |
| 43 | 43 |
| 44 test('directoryDoesntExist', () { | 44 test('directoryDoesntExist', () { |
| 45 return fs.root.getDirectory( | 45 return fs.root.getDirectory( |
| 46 'directory2') | 46 'directory2') |
| 47 .catchError((e) { | 47 .catchError((error) { |
| 48 expect(e.error.code, equals(FileError.NOT_FOUND_ERR)); | 48 expect(error.code, equals(FileError.NOT_FOUND_ERR)); |
| 49 }, test: (e) => e is FileError); | 49 }, test: (e) => e is FileError); |
| 50 }); | 50 }); |
| 51 | 51 |
| 52 test('directoryCreate', () { | 52 test('directoryCreate', () { |
| 53 return fs.root.createDirectory( | 53 return fs.root.createDirectory( |
| 54 'directory3') | 54 'directory3') |
| 55 .then((DirectoryEntry e) { | 55 .then((DirectoryEntry e) { |
| 56 expect(e.name, equals('directory3')); | 56 expect(e.name, equals('directory3')); |
| 57 }); | 57 }); |
| 58 }); | 58 }); |
| 59 } | 59 } |
| 60 }); | 60 }); |
| 61 | 61 |
| 62 group('getFile', () { | 62 group('getFile', () { |
| 63 if (FileSystem.supported) { | 63 if (FileSystem.supported) { |
| 64 test('getFileSystem', getFileSystem); | 64 test('getFileSystem', getFileSystem); |
| 65 | 65 |
| 66 test('fileDoesntExist', () { | 66 test('fileDoesntExist', () { |
| 67 return fs.root.getFile( | 67 return fs.root.getFile( |
| 68 'file2') | 68 'file2') |
| 69 .catchError((e) { | 69 .catchError((error) { |
| 70 expect(e.error.code, equals(FileError.NOT_FOUND_ERR)); | 70 expect(error.code, equals(FileError.NOT_FOUND_ERR)); |
| 71 }, test: (e) => e is FileError); | 71 }, test: (e) => e is FileError); |
| 72 }); | 72 }); |
| 73 | 73 |
| 74 test('fileCreate', () { | 74 test('fileCreate', () { |
| 75 return fs.root.createFile( | 75 return fs.root.createFile( |
| 76 'file4') | 76 'file4') |
| 77 .then((FileEntry e) { | 77 .then((FileEntry e) { |
| 78 expect(e.name, equals('file4')); | 78 expect(e.name, equals('file4')); |
| 79 expect(e.isFile, isTrue); | 79 expect(e.isFile, isTrue); |
| 80 return e.getMetadata(); | 80 return e.getMetadata(); |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 145 }); | 145 }); |
| 146 | 146 |
| 147 test('moveTo', () { | 147 test('moveTo', () { |
| 148 return doDirSetup() | 148 return doDirSetup() |
| 149 .then((fileAndDir) { | 149 .then((fileAndDir) { |
| 150 return fileAndDir.file.moveTo(fileAndDir.dir, name: 'movedFile'); | 150 return fileAndDir.file.moveTo(fileAndDir.dir, name: 'movedFile'); |
| 151 }).then((entry) { | 151 }).then((entry) { |
| 152 expect(entry.name, 'movedFile'); | 152 expect(entry.name, 'movedFile'); |
| 153 expect(entry.fullPath, '/directory3/movedFile'); | 153 expect(entry.fullPath, '/directory3/movedFile'); |
| 154 return fs.root.getFile('file4'); | 154 return fs.root.getFile('file4'); |
| 155 }).catchError((e) { | 155 }).catchError((error) { |
| 156 expect(e.error.code, equals(FileError.NOT_FOUND_ERR)); | 156 expect(error.code, equals(FileError.NOT_FOUND_ERR)); |
| 157 }, test: (e) => e is FileError); | 157 }, test: (e) => e is FileError); |
| 158 }); | 158 }); |
| 159 | 159 |
| 160 test('remove', () { | 160 test('remove', () { |
| 161 return doDirSetup() | 161 return doDirSetup() |
| 162 .then((fileAndDir) { | 162 .then((fileAndDir) { |
| 163 return fileAndDir.file.remove().then((_) {}); | 163 return fileAndDir.file.remove().then((_) {}); |
| 164 }); | 164 }); |
| 165 }); | 165 }); |
| 166 } | 166 } |
| (...skipping 22 matching lines...) Expand all Loading... |
| 189 expect(fileObj.name, fileAndDir.file.name); | 189 expect(fileObj.name, fileAndDir.file.name); |
| 190 expect(fileObj.relativePath, ''); | 190 expect(fileObj.relativePath, ''); |
| 191 expect(new DateTime.now().difference( | 191 expect(new DateTime.now().difference( |
| 192 fileObj.lastModifiedDate).inSeconds, lessThan(60)); | 192 fileObj.lastModifiedDate).inSeconds, lessThan(60)); |
| 193 }); | 193 }); |
| 194 }); | 194 }); |
| 195 }); | 195 }); |
| 196 } | 196 } |
| 197 }); | 197 }); |
| 198 } | 198 } |
| OLD | NEW |