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

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

Issue 11888013: Adding support checks for FileSystem APIs and making APIs not webkit-specific. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Fixing test. Created 7 years, 11 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/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_config.dart'; 3 import '../../pkg/unittest/lib/html_individual_config.dart';
4 import 'dart:html'; 4 import 'dart:html';
5 5
6 void fail(message) { 6 void fail(message) {
7 guardAsync(() { 7 guardAsync(() {
8 expect(false, isTrue, reason: message); 8 expect(false, isTrue, reason: message);
9 }); 9 });
10 } 10 }
11 11
12 FileSystem fs; 12 FileSystem fs;
13 13
14 main() { 14 main() {
15 useHtmlConfiguration(); 15 useHtmlIndividualConfiguration();
16 test('getFileSystem', () {
17 window.webkitRequestFileSystem(Window.TEMPORARY, 100, expectAsync1(
18 (FileSystem fileSystem) {
19 fs = fileSystem;
20 }),
21 (e) {
22 fail('Got file error: ${e.code}');
23 });
24 });
25 group('getDirectory', () {
26 16
27 test('directoryDoesntExist', () { 17 group('supported', () {
28 fs.root.getDirectory( 18 test('supported', () {
29 'directory2', 19 expect(FileSystem.supported, true);
30 options: {},
31 successCallback: (e) {
32 fail('Should not be reached');
33 },
34 errorCallback: expectAsync1((FileError e) {
35 expect(e.code, equals(FileError.NOT_FOUND_ERR));
36 }));
37 });
38
39 test('directoryCreate', () {
40 fs.root.getDirectory(
41 'directory3',
42 options: {'create': true},
43 successCallback: expectAsync1((DirectoryEntry e) {
44 expect(e.name, equals('directory3'));
45 }),
46 errorCallback: (e) {
47 fail('Got file error: ${e.code}');
48 });
49 }); 20 });
50 }); 21 });
51 22
23 getFileSystem() {
24 window.requestFileSystem(Window.TEMPORARY, 100,
25 expectAsync1((FileSystem fileSystem) {
26 fs = fileSystem;
27 }),
28 (e) {
29 fail('Got file error: ${e.code}');
30 });
31 }
32
33 group('unsupported throws', () {
34 test('requestFileSystem', () {
35 var expectation = FileSystem.supported ? returnsNormally : throws;
36 expect(() {
37 window.requestFileSystem(Window.TEMPORARY, 100, (_) {}, (_) {});
38 }, expectation);
39 });
40 });
41
42 group('getDirectory', () {
43 if (FileSystem.supported) {
44 test('getFileSystem', getFileSystem);
45
46 test('directoryDoesntExist', () {
47 fs.root.getDirectory(
48 'directory2',
49 options: {},
50 successCallback: (e) {
51 fail('Should not be reached');
52 },
53 errorCallback: expectAsync1((FileError e) {
54 expect(e.code, equals(FileError.NOT_FOUND_ERR));
55 }));
56 });
57
58 test('directoryCreate', () {
59 fs.root.getDirectory(
60 'directory3',
61 options: {'create': true},
62 successCallback: expectAsync1((DirectoryEntry e) {
63 expect(e.name, equals('directory3'));
64 }),
65 errorCallback: (e) {
66 fail('Got file error: ${e.code}');
67 });
68 });
69 }
70 });
71
52 group('getFile', () { 72 group('getFile', () {
73 if (FileSystem.supported) {
74 test('getFileSystem', getFileSystem);
53 75
54 test('fileDoesntExist', () { 76 test('fileDoesntExist', () {
55 fs.root.getFile( 77 fs.root.getFile(
56 'file2', 78 'file2',
57 options: {}, 79 options: {},
58 successCallback: (e) { 80 successCallback: (e) {
59 fail('Should not be reached'); 81 fail('Should not be reached');
60 }, 82 },
61 errorCallback: expectAsync1((FileError e) { 83 errorCallback: expectAsync1((FileError e) {
62 expect(e.code, equals(FileError.NOT_FOUND_ERR)); 84 expect(e.code, equals(FileError.NOT_FOUND_ERR));
63 })); 85 }));
64 }); 86 });
65 87
66 test('fileCreate', () { 88 test('fileCreate', () {
67 fs.root.getFile( 89 fs.root.getFile(
68 'file4', 90 'file4',
69 options: {'create': true}, 91 options: {'create': true},
70 successCallback: expectAsync1((FileEntry e) { 92 successCallback: expectAsync1((FileEntry e) {
71 expect(e.name, equals('file4')); 93 expect(e.name, equals('file4'));
72 expect(e.isFile, isTrue); 94 expect(e.isFile, isTrue);
73 }), 95 }),
74 errorCallback: (e) { 96 errorCallback: (e) {
75 fail('Got file error: ${e.code}'); 97 fail('Got file error: ${e.code}');
76 }); 98 });
77 }); 99 });
Emily Fortuna 2013/01/14 23:28:03 nit: I think this should be indented two spaces le
blois 2013/01/14 23:45:10 The joys of closures, changing these APIs to futur
100 }
78 }); 101 });
79 } 102 }
OLDNEW
« no previous file with comments | « sdk/lib/html/dartium/html_dartium.dart ('k') | tests/html/html.status » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698