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

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

Issue 11881007: Revert "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: 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_individual_config.dart'; 3 import '../../pkg/unittest/lib/html_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 useHtmlIndividualConfiguration(); 15 useHtmlConfiguration();
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', () {
16 26
17 group('supported', () { 27 test('directoryDoesntExist', () {
18 test('supported', () { 28 fs.root.getDirectory(
19 expect(FileSystem.supported, true); 29 'directory2',
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 });
20 }); 49 });
21 }); 50 });
22 51
23 getFileSystem() { 52 group('getFile', () {
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 53
33 group('fileSystem', () { 54 test('fileDoesntExist', () {
34 test('getFileSystem', () { 55 fs.root.getFile(
35 var expectation = FileSystem.supported ? returnsNormally : throws; 56 'file2',
36 expect(() { 57 options: {},
37 getFileSystem(); 58 successCallback: (e) {
38 }, expectation); 59 fail('Should not be reached');
60 },
61 errorCallback: expectAsync1((FileError e) {
62 expect(e.code, equals(FileError.NOT_FOUND_ERR));
63 }));
39 }); 64 });
40 });
41 65
42 group('getDirectory', () { 66 test('fileCreate', () {
43 if (FileSystem.supported) { 67 fs.root.getFile(
44 test('getFileSystem', getFileSystem); 68 'file4',
45 69 options: {'create': true},
46 test('directoryDoesntExist', () { 70 successCallback: expectAsync1((FileEntry e) {
47 fs.root.getDirectory( 71 expect(e.name, equals('file4'));
48 'directory2', 72 expect(e.isFile, isTrue);
49 options: {}, 73 }),
50 successCallback: (e) { 74 errorCallback: (e) {
51 fail('Should not be reached'); 75 fail('Got file error: ${e.code}');
52 }, 76 });
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
72 group('getFile', () {
73 if (FileSystem.supported) {
74 test('getFileSystem', getFileSystem);
75
76 test('fileDoesntExist', () {
77 fs.root.getFile(
78 'file2',
79 options: {},
80 successCallback: (e) {
81 fail('Should not be reached');
82 },
83 errorCallback: expectAsync1((FileError e) {
84 expect(e.code, equals(FileError.NOT_FOUND_ERR));
85 }));
86 }); 77 });
87
88 test('fileCreate', () {
89 fs.root.getFile(
90 'file4',
91 options: {'create': true},
92 successCallback: expectAsync1((FileEntry e) {
93 expect(e.name, equals('file4'));
94 expect(e.isFile, isTrue);
95 }),
96 errorCallback: (e) {
97 fail('Got file error: ${e.code}');
98 });
99 });
100 }
101 }); 78 });
102 } 79 }
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