| OLD | NEW |
| 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 @TestOn("vm") | 5 @TestOn("vm") |
| 6 | 6 |
| 7 import 'dart:core' hide Resource; | 7 import 'dart:core' hide Resource; |
| 8 import "dart:async" show Future, Stream; | 8 import "dart:async" show Future, Stream; |
| 9 import "dart:isolate" show Isolate; | 9 import "dart:isolate" show Isolate; |
| 10 import "dart:convert" show Encoding, ASCII; | 10 import "dart:convert" show Encoding, ASCII; |
| (...skipping 21 matching lines...) Expand all Loading... |
| 32 expect(res, [0, 0, 0]); | 32 expect(res, [0, 0, 0]); |
| 33 res = await resource.readAsString(encoding: ASCII); | 33 res = await resource.readAsString(encoding: ASCII); |
| 34 expect(res, "\x00\x00\x00"); | 34 expect(res, "\x00\x00\x00"); |
| 35 | 35 |
| 36 expect(loader.requests, [["Stream", resolved], | 36 expect(loader.requests, [["Stream", resolved], |
| 37 ["Bytes", resolved], | 37 ["Bytes", resolved], |
| 38 ["String", resolved, ASCII]]); | 38 ["String", resolved, ASCII]]); |
| 39 } | 39 } |
| 40 | 40 |
| 41 test("load package: URIs", () async { | 41 test("load package: URIs", () async { |
| 42 await testLoad(pkguri("foo/bar/baz")); | 42 await testLoad(pkguri("resource/bar/baz")); |
| 43 await testLoad(pkguri("bar/foo/baz")); | 43 await testLoad(pkguri("test/foo/baz")); |
| 44 }); | 44 }); |
| 45 test("load non-pkgUri", () async { | 45 test("load non-pkgUri", () async { |
| 46 await testLoad(Uri.parse("file://localhost/something?x#y")); | 46 await testLoad(Uri.parse("file://localhost/something?x#y")); |
| 47 await testLoad(Uri.parse("http://auth/something?x#y")); | 47 await testLoad(Uri.parse("http://auth/something?x#y")); |
| 48 await testLoad(Uri.parse("https://auth/something?x#y")); | 48 await testLoad(Uri.parse("https://auth/something?x#y")); |
| 49 await testLoad(Uri.parse("data:,something?x")); | 49 await testLoad(Uri.parse("data:,something?x")); |
| 50 await testLoad(Uri.parse("unknown:/something")); | 50 await testLoad(Uri.parse("unknown:/something")); |
| 51 }); | 51 }); |
| 52 }); | 52 }); |
| 53 } | 53 } |
| 54 | 54 |
| 55 | 55 |
| 56 class LogLoader implements ResourceLoader { | 56 class LogLoader implements ResourceLoader { |
| 57 final List requests = []; | 57 final List requests = []; |
| 58 void reset() { requests.clear(); } | 58 void reset() { requests.clear(); } |
| 59 Stream<List<int>> openRead(Uri uri) async* { | 59 Stream<List<int>> openRead(Uri uri) async* { |
| 60 requests.add(["Stream", uri]); | 60 requests.add(["Stream", uri]); |
| 61 yield [0x00, 0x00, 0x00]; | 61 yield [0x00, 0x00, 0x00]; |
| 62 } | 62 } |
| 63 Future<List<int>> readAsBytes(Uri uri) async { | 63 Future<List<int>> readAsBytes(Uri uri) async { |
| 64 requests.add(["Bytes", uri]); | 64 requests.add(["Bytes", uri]); |
| 65 return [0x00, 0x00, 0x00]; | 65 return [0x00, 0x00, 0x00]; |
| 66 } | 66 } |
| 67 Future<String> readAsString(Uri uri, {Encoding encoding}) async { | 67 Future<String> readAsString(Uri uri, {Encoding encoding}) async { |
| 68 requests.add(["String", uri, encoding]); | 68 requests.add(["String", uri, encoding]); |
| 69 return "\x00\x00\x00"; | 69 return "\x00\x00\x00"; |
| 70 } | 70 } |
| 71 } | 71 } |
| OLD | NEW |