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

Side by Side Diff: test/loader_data_test.dart

Issue 1387163002: Add Resource package. (Closed) Base URL: https://github.com/dart-lang/resource.git@master
Patch Set: Address comments. Created 4 years, 11 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 unified diff | Download patch
« no previous file with comments | « pubspec.yaml ('k') | test/loader_file_test.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // BSD-style license that can be found in the LICENSE file.
4
5 import "dart:async";
6 import "dart:convert";
7 import "dart:io";
8
9 import "package:resource/resource.dart";
10 import "package:test/test.dart";
11
12 const content = "Rødgrød med fløde";
13
14 main() {
15 var dir;
16 testFile(Encoding encoding, bool base64) {
17 group("${encoding.name}${base64 ? " base64" : ""}", () {
18 var uri;
19 setUp(() {
20 var dataUri = new UriData.fromString(content,
21 encoding: encoding,
22 base64: base64);
23 uri = dataUri.uri;
24 });
25
26 test("read string", () async {
27 var loader = ResourceLoader.defaultLoader;
28 String string = await loader.readAsString(uri, encoding: encoding);
29 expect(string, content);
30 });
31
32 test("read bytes", () async {
33 var loader = ResourceLoader.defaultLoader;
34 List<int> bytes = await loader.readAsBytes(uri);
35 expect(bytes, encoding.encode(content));
36 });
37
38 test("read byte stream", () async {
39 var loader = ResourceLoader.defaultLoader;
40 Stream<int> bytes = loader.openRead(uri);
41 var buffer = [];
42 await bytes.forEach(buffer.addAll);
43 expect(buffer, encoding.encode(content));
44 });
45 });
46 }
47 testFile(LATIN1, true);
48 testFile(LATIN1, false);
49 testFile(UTF8, true);
50 testFile(UTF8, false);
51 }
OLDNEW
« no previous file with comments | « pubspec.yaml ('k') | test/loader_file_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698