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

Side by Side Diff: tests/html/fileapi_test.dart

Issue 12474007: Revert 20127 (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 9 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « sdk/lib/html/dartium/html_dartium.dart ('k') | tests/html/notifications_test.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 25 matching lines...) Expand all
36 }, expectation); 36 }, expectation);
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 options: {})
47 .catchError((e) { 48 .catchError((e) {
48 expect(e.error.code, equals(FileError.NOT_FOUND_ERR)); 49 expect(e.error.code, equals(FileError.NOT_FOUND_ERR));
49 }, test: (e) => e is FileError); 50 }, test: (e) => e is FileError);
50 }); 51 });
51 52
52 test('directoryCreate', () { 53 test('directoryCreate', () {
53 return fs.root.createDirectory( 54 return fs.root.getDirectory(
54 'directory3') 55 'directory3',
56 options: {'create': true})
55 .then((DirectoryEntry e) { 57 .then((DirectoryEntry e) {
56 expect(e.name, equals('directory3')); 58 expect(e.name, equals('directory3'));
57 }); 59 });
58 }); 60 });
59 } 61 }
60 }); 62 });
61 63
62 group('getFile', () { 64 group('getFile', () {
63 if (FileSystem.supported) { 65 if (FileSystem.supported) {
64 test('getFileSystem', getFileSystem); 66 test('getFileSystem', getFileSystem);
65 67
66 test('fileDoesntExist', () { 68 test('fileDoesntExist', () {
67 return fs.root.getFile( 69 return fs.root.getFile(
68 'file2') 70 'file2',
71 options: {})
69 .catchError((e) { 72 .catchError((e) {
70 expect(e.error.code, equals(FileError.NOT_FOUND_ERR)); 73 expect(e.error.code, equals(FileError.NOT_FOUND_ERR));
71 }, test: (e) => e is FileError); 74 }, test: (e) => e is FileError);
72 }); 75 });
73 76
74 test('fileCreate', () { 77 test('fileCreate', () {
75 return fs.root.createFile( 78 return fs.root.getFile(
76 'file4') 79 'file4',
80 options: {'create': true})
77 .then((FileEntry e) { 81 .then((FileEntry e) {
78 expect(e.name, equals('file4')); 82 expect(e.name, equals('file4'));
79 expect(e.isFile, isTrue); 83 expect(e.isFile, isTrue);
80 return e.getMetadata(); 84 return e.getMetadata();
81 }).then((Metadata metadata) { 85 }).then((Metadata metadata) {
82 var changeTime = metadata.modificationTime; 86 var changeTime = metadata.modificationTime;
83 // Upped because our Windows buildbots can sometimes be particularly 87 // Upped because our Windows buildbots can sometimes be particularly
84 // slow. 88 // slow.
85 expect(new DateTime.now().difference(changeTime).inMinutes, 89 expect(new DateTime.now().difference(changeTime).inMinutes,
86 lessThan(4)); 90 lessThan(4));
87 expect(metadata.size, equals(0)); 91 expect(metadata.size, equals(0));
88 }); 92 });
89 }); 93 });
90 } 94 }
91 }); 95 });
92 96
93 // Do the boilerplate to get several files and directories created to then 97 // Do the boilerplate to get several files and directories created to then
94 // test the functions that use those items. 98 // test the functions that use those items.
95 Future doDirSetup() { 99 Future doDirSetup() {
96 return fs.root.createFile( 100 return fs.root.getFile(
97 'file4') 101 'file4',
102 options: {'create': true})
98 .then((FileEntry file) { 103 .then((FileEntry file) {
99 return fs.root.createDirectory( 104 return fs.root.getDirectory(
100 'directory3') 105 'directory3',
106 options: {'create': true})
101 .then((DirectoryEntry dir) { 107 .then((DirectoryEntry dir) {
102 return new Future.immediate(new FileAndDir(file, dir)); 108 return new Future.immediate(new FileAndDir(file, dir));
103 }); 109 });
104 }); 110 });
105 } 111 }
106 112
107 group('directoryReader', () { 113 group('directoryReader', () {
108 if (FileSystem.supported) { 114 if (FileSystem.supported) {
109 test('getFileSystem', getFileSystem); 115 test('getFileSystem', getFileSystem);
110 116
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
144 }); 150 });
145 }); 151 });
146 152
147 test('moveTo', () { 153 test('moveTo', () {
148 return doDirSetup() 154 return doDirSetup()
149 .then((fileAndDir) { 155 .then((fileAndDir) {
150 return fileAndDir.file.moveTo(fileAndDir.dir, name: 'movedFile'); 156 return fileAndDir.file.moveTo(fileAndDir.dir, name: 'movedFile');
151 }).then((entry) { 157 }).then((entry) {
152 expect(entry.name, 'movedFile'); 158 expect(entry.name, 'movedFile');
153 expect(entry.fullPath, '/directory3/movedFile'); 159 expect(entry.fullPath, '/directory3/movedFile');
154 return fs.root.getFile('file4'); 160 return fs.root.getFile('file4', options: {'create': false});
155 }).catchError((e) { 161 }).catchError((e) {
156 expect(e.error.code, equals(FileError.NOT_FOUND_ERR)); 162 expect(e.error.code, equals(FileError.NOT_FOUND_ERR));
157 }, test: (e) => e is FileError); 163 }, test: (e) => e is FileError);
158 }); 164 });
159 165
160 test('remove', () { 166 test('remove', () {
161 return doDirSetup() 167 return doDirSetup()
162 .then((fileAndDir) { 168 .then((fileAndDir) {
163 return fileAndDir.file.remove().then((_) {}); 169 return fileAndDir.file.remove().then((_) {});
164 }); 170 });
(...skipping 24 matching lines...) Expand all
189 expect(fileObj.name, fileAndDir.file.name); 195 expect(fileObj.name, fileAndDir.file.name);
190 expect(fileObj.relativePath, ''); 196 expect(fileObj.relativePath, '');
191 expect(new DateTime.now().difference( 197 expect(new DateTime.now().difference(
192 fileObj.lastModifiedDate).inSeconds, lessThan(60)); 198 fileObj.lastModifiedDate).inSeconds, lessThan(60));
193 }); 199 });
194 }); 200 });
195 }); 201 });
196 } 202 }
197 }); 203 });
198 } 204 }
OLDNEW
« no previous file with comments | « sdk/lib/html/dartium/html_dartium.dart ('k') | tests/html/notifications_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698