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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « pubspec.yaml ('k') | test/loader_file_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/loader_data_test.dart
diff --git a/test/loader_data_test.dart b/test/loader_data_test.dart
new file mode 100644
index 0000000000000000000000000000000000000000..8c84f7d7d53fb266ab9b5f255a1adfa26fdc7b19
--- /dev/null
+++ b/test/loader_data_test.dart
@@ -0,0 +1,51 @@
+// Copyright (c) 2015, 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 "dart:async";
+import "dart:convert";
+import "dart:io";
+
+import "package:resource/resource.dart";
+import "package:test/test.dart";
+
+const content = "Rødgrød med fløde";
+
+main() {
+ var dir;
+ testFile(Encoding encoding, bool base64) {
+ group("${encoding.name}${base64 ? " base64" : ""}", () {
+ var uri;
+ setUp(() {
+ var dataUri = new UriData.fromString(content,
+ encoding: encoding,
+ base64: base64);
+ uri = dataUri.uri;
+ });
+
+ test("read string", () async {
+ var loader = ResourceLoader.defaultLoader;
+ String string = await loader.readAsString(uri, encoding: encoding);
+ expect(string, content);
+ });
+
+ test("read bytes", () async {
+ var loader = ResourceLoader.defaultLoader;
+ List<int> bytes = await loader.readAsBytes(uri);
+ expect(bytes, encoding.encode(content));
+ });
+
+ test("read byte stream", () async {
+ var loader = ResourceLoader.defaultLoader;
+ Stream<int> bytes = loader.openRead(uri);
+ var buffer = [];
+ await bytes.forEach(buffer.addAll);
+ expect(buffer, encoding.encode(content));
+ });
+ });
+ }
+ testFile(LATIN1, true);
+ testFile(LATIN1, false);
+ testFile(UTF8, true);
+ testFile(UTF8, false);
+}
« 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