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

Unified Diff: pkg/http_server/test/virtual_directory_test.dart

Issue 17573011: Add auto-detection of MIME-type in VirtualDirectory. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 6 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 | « pkg/http_server/pubspec.yaml ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/http_server/test/virtual_directory_test.dart
diff --git a/pkg/http_server/test/virtual_directory_test.dart b/pkg/http_server/test/virtual_directory_test.dart
index 7b6c81553f0532ad2df220d518816665b93ec1ae..1bbe66e0a16df4ccc417982a11b4be27eeffa1bf 100644
--- a/pkg/http_server/test/virtual_directory_test.dart
+++ b/pkg/http_server/test/virtual_directory_test.dart
@@ -230,7 +230,7 @@ void main() {
}
});
- group('last-mofidied', () {
+ group('last-modified', () {
group('file', () {
test('file-exists', () {
expect(HttpServer.bind('localhost', 0).then((server) {
@@ -286,5 +286,45 @@ void main() {
});
});
});
+
+ group('content-type', () {
+ group('mime-type', () {
+ test('from-path', () {
+ expect(HttpServer.bind('localhost', 0).then((server) {
+ var dir = new Directory('').createTempSync();
+ var file = new File('${dir.path}/file.jpg')..createSync();
+ var virDir = new VirtualDirectory(dir.path);
+
+ virDir.serve(server);
+
+ return getHeaders(server.port, '/file.jpg')
+ .then((headers) => headers.contentType.toString())
+ .whenComplete(() {
+ server.close();
+ dir.deleteSync(recursive: true);
+ });
+ }), completion(equals('image/jpeg')));
+ });
+
+ test('from-magic-number', () {
+ expect(HttpServer.bind('localhost', 0).then((server) {
+ var dir = new Directory('').createTempSync();
+ var file = new File('${dir.path}/file.jpg')..createSync();
+ file.writeAsBytesSync(
+ [0x89, 0x50, 0x4E, 0x47, 0x0D, 0x0A, 0x1A, 0x0A]);
+ var virDir = new VirtualDirectory(dir.path);
+
+ virDir.serve(server);
+
+ return getHeaders(server.port, '/file.jpg')
+ .then((headers) => headers.contentType.toString())
+ .whenComplete(() {
+ server.close();
+ dir.deleteSync(recursive: true);
+ });
+ }), completion(equals('image/png')));
+ });
+ });
+ });
}
« no previous file with comments | « pkg/http_server/pubspec.yaml ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698