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

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

Issue 92253003: Attempting to de-flake the fileapi_test (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years 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 | « no previous file | tests/html/html.status » ('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 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
85 expect(new DateTime.now().difference(changeTime).inMinutes, 85 expect(new DateTime.now().difference(changeTime).inMinutes,
86 lessThan(4)); 86 lessThan(4));
87 expect(metadata.size, equals(0)); 87 expect(metadata.size, equals(0));
88 }); 88 });
89 }); 89 });
90 } 90 }
91 }); 91 });
92 92
93 // Do the boilerplate to get several files and directories created to then 93 // Do the boilerplate to get several files and directories created to then
94 // test the functions that use those items. 94 // test the functions that use those items.
95 Future doDirSetup() { 95 Future doDirSetup(String testName) {
96 return fs.root.createFile( 96 return fs.root.createFile(
97 'file4') 97 'file_$testName')
98 .then((FileEntry file) { 98 .then((FileEntry file) {
99 return fs.root.createDirectory( 99 return fs.root.createDirectory(
100 'directory3') 100 'dir_$testName')
101 .then((DirectoryEntry dir) { 101 .then((DirectoryEntry dir) {
102 return new Future.value(new FileAndDir(file, dir)); 102 return new Future.value(new FileAndDir(file, dir));
103 }); 103 });
104 }); 104 });
105 } 105 }
106 106
107 group('directoryReader', () { 107 group('directoryReader', () {
108 if (FileSystem.supported) { 108 if (FileSystem.supported) {
109 test('getFileSystem', getFileSystem); 109 test('getFileSystem', getFileSystem);
110 110
111 test('readEntries', () { 111 test('readEntries', () {
112 return doDirSetup() 112 return doDirSetup('readEntries')
113 .then((fileAndDir) { 113 .then((fileAndDir) {
114 var reader = fileAndDir.dir.createReader(); 114 var reader = fileAndDir.dir.createReader();
115 return reader.readEntries(); 115 return reader.readEntries();
116 }).then((entries) { 116 }).then((entries) {
117 expect(entries is List, true); 117 expect(entries is List, true);
118 }); 118 });
119 }); 119 });
120 } 120 }
121 }); 121 });
122 122
123 group('entry', () { 123 group('entry', () {
124 if (FileSystem.supported) { 124 if (FileSystem.supported) {
125 test('getFileSystem', getFileSystem); 125 test('getFileSystem', getFileSystem);
126 126
127 test('copyTo', () { 127 test('copyTo', () {
128 return doDirSetup() 128 return doDirSetup('copyTo')
129 .then((fileAndDir) { 129 .then((fileAndDir) {
130 return fileAndDir.file.copyTo(fileAndDir.dir, name: 'copiedFile'); 130 return fileAndDir.file.copyTo(fileAndDir.dir, name: 'copiedFile');
131 }).then((entry) { 131 }).then((entry) {
132 expect(entry.isFile, true); 132 expect(entry.isFile, true);
133 expect(entry.name, 'copiedFile'); 133 expect(entry.name, 'copiedFile');
134 }); 134 });
135 }); 135 });
136 136
137 test('getParent', () { 137 test('getParent', () {
138 return doDirSetup() 138 return doDirSetup('getParent')
139 .then((fileAndDir) { 139 .then((fileAndDir) {
140 return fileAndDir.file.getParent(); 140 return fileAndDir.file.getParent();
141 }).then((entry) { 141 }).then((entry) {
142 expect(entry.name, ''); 142 expect(entry.name, '');
143 expect(entry.isFile, false); 143 expect(entry.isFile, false);
144 }); 144 });
145 }); 145 });
146 146
147 test('moveTo', () { 147 test('moveTo', () {
148 return doDirSetup() 148 return doDirSetup('moveTo')
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, '/dir_moveTo/movedFile');
154 return fs.root.getFile('file4'); 154 return fs.root.getFile('file4');
155 }).catchError((error) { 155 }).catchError((error) {
156 expect(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('remove')
162 .then((fileAndDir) { 162 .then((fileAndDir) {
163 return fileAndDir.file.remove().then((_) {}); 163 return fileAndDir.file.remove().then((_) {});
164 }); 164 });
165 }); 165 });
166 } 166 }
167 }); 167 });
168 168
169 group('fileEntry', () { 169 group('fileEntry', () {
170 if (FileSystem.supported) { 170 if (FileSystem.supported) {
171 test('getFileSystem', getFileSystem); 171 test('getFileSystem', getFileSystem);
172 172
173 test('createWriter', () { 173 test('createWriter', () {
174 return doDirSetup() 174 return doDirSetup('createWriter')
175 .then((fileAndDir) { 175 .then((fileAndDir) {
176 return fileAndDir.file.createWriter(); 176 return fileAndDir.file.createWriter();
177 }).then((writer) { 177 }).then((writer) {
178 expect(writer.position, 0); 178 expect(writer.position, 0);
179 expect(writer.readyState, FileWriter.INIT); 179 expect(writer.readyState, FileWriter.INIT);
180 expect(writer.length, 0); 180 expect(writer.length, 0);
181 }); 181 });
182 }); 182 });
183 183
184 test('file', () { 184 test('file', () {
185 return doDirSetup() 185 return doDirSetup('file')
186 .then((fileAndDir) { 186 .then((fileAndDir) {
187 return fileAndDir.file.file() 187 return fileAndDir.file.file()
188 .then((fileObj) { 188 .then((fileObj) {
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 }
OLDNEW
« no previous file with comments | « no previous file | tests/html/html.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698