| Index: pkg/mime/test/mime_type_test.dart
|
| diff --git a/pkg/mime/test/mime_type_test.dart b/pkg/mime/test/mime_type_test.dart
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..29c8b572a4a385d0b845b560d28cb12a6fbf1411
|
| --- /dev/null
|
| +++ b/pkg/mime/test/mime_type_test.dart
|
| @@ -0,0 +1,52 @@
|
| +// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
|
| +// for details. All rights reserved. Use of this source code is governed by a
|
| +// BSD-style license that can be found in the LICENSE file.
|
| +
|
| +import 'package:mime/mime.dart';
|
| +
|
| +
|
| +void test(String path, String expectedMimeType, [List<int> headerBytes]) {
|
| + String mimeType = lookupMimeType(
|
| + path,
|
| + headerBytes: headerBytes);
|
| +
|
| + if (mimeType != expectedMimeType) {
|
| + throw "Expect '$expectedMimeType' but got '$mimeType'";
|
| + }
|
| +}
|
| +
|
| +void main() {
|
| + test('file.dart', 'application/dart');
|
| + test('file.DaRT', 'application/dart');
|
| + test('file.html', 'text/html');
|
| + test('file.xhtml', 'application/xhtml+xml');
|
| + test('file.jpeg', 'image/jpeg');
|
| + test('file.jpg', 'image/jpeg');
|
| + test('file.png', 'image/png');
|
| + test('file.gif', 'image/gif');
|
| + test('file.cc', 'text/x-c');
|
| + test('file.c', 'text/x-c');
|
| + test('file.css', 'text/css');
|
| + test('file.js', 'application/javascript');
|
| + test('file.ps', 'application/postscript');
|
| + test('file.pdf', 'application/pdf');
|
| + test('file.tiff', 'image/tiff');
|
| +
|
| + test('file.jpg',
|
| + 'image/png',
|
| + [0x89, 0x50, 0x4E, 0x47, 0x0D, 0x0A, 0x1A, 0x0A]);
|
| +
|
| + test('file.jpg',
|
| + 'image/gif',
|
| + [0x47, 0x49, 0x46, 0x38, 0x39, 0x61, 0x0D, 0x0A, 0x1A, 0x0A]);
|
| +
|
| + test('file.gif',
|
| + 'image/jpeg',
|
| + [0xFF, 0xD8, 0x46, 0x38, 0x39, 0x61, 0x0D, 0x0A, 0x1A, 0x0A]);
|
| +
|
| + test('file.mp4',
|
| + lookupMimeType('file.mp4'),
|
| + [0x00, 0x00, 0x00, 0x04, 0x66, 0x74,
|
| + 0x79, 0x70, 0x33, 0x67, 0x70, 0x35]);
|
| +}
|
| +
|
|
|