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

Unified 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 up comment error in html.status. Created 8 years, 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | tests/html/html.status » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/html/fileapi_test.dart
diff --git a/tests/html/fileapi_test.dart b/tests/html/fileapi_test.dart
index 6b85308493fee4975d8bf7d0a5fc5b176d3d12ed..c623fd335c506cfea4404717a50d236a01049d61 100644
--- a/tests/html/fileapi_test.dart
+++ b/tests/html/fileapi_test.dart
@@ -3,58 +3,84 @@
#import('../../pkg/unittest/html_config.dart');
#import('dart:html');
+void fail(message) {
+ guardAsync(() {
+ Expect.fail(message);
+ });
+}
+
+DOMFileSystem fs;
+
main() {
useHtmlConfiguration();
- window.webkitRequestFileSystem(Window.TEMPORARY, 100, (fs) {
- // FIXME: add types to callback arguments after migration to wrapperless dart:html.
-
- test('getDirectory', () {
- expect(() => fs.root.getDirectory('directory1', {'x': true}, (e) {}),
- throws);
+ test('getFileSystem', () {
+ window.webkitRequestFileSystem(Window.TEMPORARY, 100, expectAsync1(
+ (DOMFileSystem fileSystem) {
+ fs = fileSystem;
+ }),
+ (FileError e) {
+ fail('Got file error: ${e.code}');
+ });
+ });
+ group('getDirectory', () {
+ test('directoryDoesntExist', () {
fs.root.getDirectory(
'directory2',
options: {},
- successCallback: expectAsync1((e) {
- expect(false, 'Should not be reached');
- }, count:0),
- errorCallback: expectAsync1((e) {
- expect(e.code, equals(FileError.NOT_FOUND_ERR));
+ successCallback: (DirectoryEntry e) {
vsm 2012/08/28 22:24:09 Hmm, one problem with this pattern is that if the
+ fail('Should not be reached');
+ },
+ errorCallback: expectAsync1((FileError e) {
+ guardAsync(() {
+ expect(e.code, equals(FileError.NOT_FOUND_ERR));
+ });
}));
+ });
+ test('directoryCreate', () {
fs.root.getDirectory(
'directory3',
options: {'create': true},
- successCallback: expectAsync1((e) {
- expect(e.name, equals('directory3'));
+ successCallback: expectAsync1((DirectoryEntry e) {
+ guardAsync(() {
+ expect(e.name, equals('directory3'));
+ });
}),
- errorCallback: expectAsync1((e) {
- expect(false, 'Got file error: ${e.code}');
- }, count:0));
+ errorCallback: (FileError e) {
+ fail('Got file error: ${e.code}');
+ });
});
+ });
- test('getFile', () {
- expect(() => fs.root.getFile('file1', {'x': true}, (e) {}), throws);
+ group('getFile', () {
+ test('fileDoesntExist', () {
fs.root.getDirectory(
'file2',
options: {},
- successCallback: expectAsync1((e) {
- expect(false, 'Should not be reached');
- }, count:0),
- errorCallback: expectAsync1((e) {
- expect(e.code, equals(FileError.NOT_FOUND_ERR));
+ successCallback: (FileEntry e) {
+ fail('Should not be reached');
+ },
+ errorCallback: expectAsync1((FileError e) {
+ guardAsync(() {
+ expect(e.code, equals(FileError.NOT_FOUND_ERR));
+ });
}));
+ });
+ test('fileCreate', () {
fs.root.getDirectory(
'file3',
options: {'create': true},
successCallback: expectAsync1((e) {
- expect(e.name, equals('file3'));
+ guardAsync(() {
+ expect(e.name, equals('file3'));
+ });
}),
- errorCallback: expectAsync1((e) {
- expect(false, 'Got file error: ${e.code}');
- }, count:0));
- });
+ errorCallback: (FileError e) {
+ fail('Got file error: ${e.code}');
+ });
+ });
});
}
« 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