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

Side by Side Diff: test/loader_file_test.dart

Issue 1612003002: Add browser-compatible version. (Closed) Base URL: https://github.com/dart-lang/resource.git@master
Patch Set: Made test run Created 4 years, 10 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 | « test/loader_data_test.dart ('k') | test/loader_http_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
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");
6
5 import "dart:async"; 7 import "dart:async";
6 import "dart:convert"; 8 import "dart:convert";
7 import "dart:io"; 9 import "dart:io";
8 10
9 import "package:resource/resource.dart"; 11 import "package:resource/resource.dart";
10 import "package:test/test.dart"; 12 import "package:test/test.dart";
11 13
12 const content = "Rødgrød med fløde"; 14 const content = "Rødgrød med fløde";
13 15
14
15 main() { 16 main() {
16 var dir; 17 var dir;
18 int dirCounter = 0;
17 setUp(() { 19 setUp(() {
18 dir = Directory.systemTemp.createTempSync('testdir'); 20 dir = Directory.systemTemp.createTempSync('testdir${dirCounter++}');
19 }); 21 });
20 testFile(Encoding encoding) { 22 testFile(Encoding encoding) {
21 group("${encoding.name}", () { 23 group("${encoding.name}", () {
22 var file; 24 var file;
23 var uri; 25 var uri;
24 setUp(() { 26 setUp(() {
25 var dirUri = dir.uri; 27 var dirUri = dir.uri;
26 uri = dirUri.resolve("file.txt"); 28 uri = dirUri.resolve("file.txt");
27 file = new File.fromUri(uri); 29 file = new File.fromUri(uri);
28 file.createSync(); 30 file.writeAsBytesSync(encoding.encode(content));
29 var sink = file.openWrite(encoding: encoding);
30 sink.write(content);
31 sink.close();
32 }); 31 });
33 32
34 test("read string", () async { 33 test("read string", () async {
35 var loader = ResourceLoader.defaultLoader; 34 var loader = ResourceLoader.defaultLoader;
36 String string = await loader.readAsString(uri, encoding: encoding); 35 String string = await loader.readAsString(uri, encoding: encoding);
37 expect(string, content); 36 expect(string, content);
38 }); 37 });
39 38
40 test("read bytes", () async { 39 test("read bytes", () async {
41 var loader = ResourceLoader.defaultLoader; 40 var loader = ResourceLoader.defaultLoader;
(...skipping 14 matching lines...) Expand all
56 }); 55 });
57 }); 56 });
58 } 57 }
59 testFile(LATIN1); 58 testFile(LATIN1);
60 testFile(UTF8); 59 testFile(UTF8);
61 60
62 tearDown(() { 61 tearDown(() {
63 dir.delete(recursive: true); 62 dir.delete(recursive: true);
64 }); 63 });
65 } 64 }
OLDNEW
« no previous file with comments | « test/loader_data_test.dart ('k') | test/loader_http_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698