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

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

Issue 10886017: Fixing up file API tests to run (or fail) appropriately. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Fixing bad merge. Created 8 years, 3 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 | « 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/unittest.dart'); 2 #import('../../pkg/unittest/unittest.dart');
3 #import('../../pkg/unittest/html_config.dart'); 3 #import('../../pkg/unittest/html_config.dart');
4 #import('dart:html'); 4 #import('dart:html');
5 5
6 void fail(message) {
7 guardAsync(() {
8 Expect.fail(message);
9 });
10 }
11
12 DOMFileSystem fs;
13
6 main() { 14 main() {
7 useHtmlConfiguration(); 15 useHtmlConfiguration();
8 window.webkitRequestFileSystem(Window.TEMPORARY, 100, (fs) { 16 test('getFileSystem', () {
9 // FIXME: add types to callback arguments after migration to wrapperless dar t:html. 17 window.webkitRequestFileSystem(Window.TEMPORARY, 100, expectAsync1(
18 (DOMFileSystem fileSystem) {
19 fs = fileSystem;
20 }),
21 (e) {
22 fail('Got file error: ${e.code}');
23 });
24 });
25 group('getDirectory', () {
10 26
11 test('getDirectory', () { 27 test('directoryDoesntExist', () {
12 expect(() => fs.root.getDirectory('directory1', {'x': true}, (e) {}),
13 throws);
14
15 fs.root.getDirectory( 28 fs.root.getDirectory(
16 'directory2', 29 'directory2',
17 options: {}, 30 options: {},
18 successCallback: expectAsync1((e) { 31 successCallback: (e) {
19 expect(false, 'Should not be reached'); 32 fail('Should not be reached');
20 }, count:0), 33 },
21 errorCallback: expectAsync1((e) { 34 errorCallback: expectAsync1((FileError e) {
22 expect(e.code, equals(FileError.NOT_FOUND_ERR)); 35 expect(e.code, equals(FileError.NOT_FOUND_ERR));
23 })); 36 }));
37 });
24 38
39 test('directoryCreate', () {
25 fs.root.getDirectory( 40 fs.root.getDirectory(
26 'directory3', 41 'directory3',
27 options: {'create': true}, 42 options: {'create': true},
28 successCallback: expectAsync1((e) { 43 successCallback: expectAsync1((DirectoryEntry e) {
29 expect(e.name, equals('directory3')); 44 expect(e.name, equals('directory3'));
30 }), 45 }),
31 errorCallback: expectAsync1((e) { 46 errorCallback: (e) {
32 expect(false, 'Got file error: ${e.code}'); 47 fail('Got file error: ${e.code}');
33 }, count:0)); 48 });
49 });
50 });
51
52 group('getFile', () {
53
54 test('fileDoesntExist', () {
55 fs.root.getFile(
56 'file2',
57 options: {},
58 successCallback: (e) {
59 fail('Should not be reached');
60 },
61 errorCallback: expectAsync1((FileError e) {
62 expect(e.code, equals(FileError.NOT_FOUND_ERR));
63 }));
34 }); 64 });
35 65
36 test('getFile', () { 66 test('fileCreate', () {
37 expect(() => fs.root.getFile('file1', {'x': true}, (e) {}), throws); 67 fs.root.getFile(
38 68 'file4',
39 fs.root.getDirectory(
40 'file2',
41 options: {},
42 successCallback: expectAsync1((e) {
43 expect(false, 'Should not be reached');
44 }, count:0),
45 errorCallback: expectAsync1((e) {
46 expect(e.code, equals(FileError.NOT_FOUND_ERR));
47 }));
48
49 fs.root.getDirectory(
50 'file3',
51 options: {'create': true}, 69 options: {'create': true},
52 successCallback: expectAsync1((e) { 70 successCallback: expectAsync1((FileEntry e) {
53 expect(e.name, equals('file3')); 71 expect(e.name, equals('file4'));
72 expect(e.isFile, equals(true));
54 }), 73 }),
55 errorCallback: expectAsync1((e) { 74 errorCallback: (e) {
56 expect(false, 'Got file error: ${e.code}'); 75 fail('Got file error: ${e.code}');
57 }, count:0)); 76 });
58 }); 77 });
59 }); 78 });
60 } 79 }
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