Files
sdk/tests/html/fileapi_test.dart
T
gram@google.com 981c4b11df Restructure pkg/unittest and pkg/webdriver to follow the pub conventions.
This means all imports of unittest in our test code had to change to include 'lib' in the path.
While doing that change I changed the library/imports to the new syntax in the affected files.
Review URL: https://codereview.chromium.org//11301046

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@14443 260f80e4-7a28-3924-810f-c04153c831b5
2012-11-01 23:09:47 +00:00

80 lines
1.9 KiB
Dart

library fileapi;
import '../../pkg/unittest/lib/unittest.dart';
import '../../pkg/unittest/lib/html_config.dart';
import 'dart:html';
void fail(message) {
guardAsync(() {
expect(false, isTrue, reason: message);
});
}
DOMFileSystem fs;
main() {
useHtmlConfiguration();
test('getFileSystem', () {
window.webkitRequestFileSystem(LocalWindow.TEMPORARY, 100, expectAsync1(
(DOMFileSystem fileSystem) {
fs = fileSystem;
}),
(e) {
fail('Got file error: ${e.code}');
});
});
group('getDirectory', () {
test('directoryDoesntExist', () {
fs.root.getDirectory(
'directory2',
options: {},
successCallback: (e) {
fail('Should not be reached');
},
errorCallback: expectAsync1((FileError e) {
expect(e.code, equals(FileError.NOT_FOUND_ERR));
}));
});
test('directoryCreate', () {
fs.root.getDirectory(
'directory3',
options: {'create': true},
successCallback: expectAsync1((DirectoryEntry e) {
expect(e.name, equals('directory3'));
}),
errorCallback: (e) {
fail('Got file error: ${e.code}');
});
});
});
group('getFile', () {
test('fileDoesntExist', () {
fs.root.getFile(
'file2',
options: {},
successCallback: (e) {
fail('Should not be reached');
},
errorCallback: expectAsync1((FileError e) {
expect(e.code, equals(FileError.NOT_FOUND_ERR));
}));
});
test('fileCreate', () {
fs.root.getFile(
'file4',
options: {'create': true},
successCallback: expectAsync1((FileEntry e) {
expect(e.name, equals('file4'));
expect(e.isFile, isTrue);
}),
errorCallback: (e) {
fail('Got file error: ${e.code}');
});
});
});
}