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

Unified Diff: pkg/barback/test/asset_test.dart

Issue 23469003: Add an AssetStream class to Barback. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Add tests and fix a few bugs. Created 7 years, 4 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
Index: pkg/barback/test/asset_test.dart
diff --git a/pkg/barback/test/asset_test.dart b/pkg/barback/test/asset_test.dart
index b26d4629cde8142236d4987b44c8dda43ddcdd0d..05ece1fe810ee1df9749889da82c49fac2306827 100644
--- a/pkg/barback/test/asset_test.dart
+++ b/pkg/barback/test/asset_test.dart
@@ -73,6 +73,14 @@ main() {
});
});
+ group("Asset.fromStream", () {
+ test("returns an asset with the given ID", () {
+ var asset = new Asset.fromStream(id,
+ new Stream.fromFuture(new Future.value([104, 101, 108, 108, 111])));
+ expect(asset.id, equals(id));
+ });
+ });
+
group("read()", () {
test("gets the UTF-8-encoded string for a string asset", () {
var asset = new Asset.fromString(id, "çøñ†éℵ™");
@@ -97,6 +105,13 @@ main() {
expect(asset.read().toList(),
completion(equals([encodeUtf8("çøñ†éℵ™")])));
});
+
+ test("gets the raw bytes for a stream", () {
+ var asset = new Asset.fromStream(id,
+ new Stream.fromFuture(new Future.value(encodeUtf8("çøñ†éℵ™"))));
+ expect(asset.read().toList(),
+ completion(equals([encodeUtf8("çøñ†éℵ™")])));
+ });
});
group("readAsString()", () {
@@ -137,6 +152,24 @@ main() {
completion(equals("çøñ†éℵ™")));
});
});
+
+ group("stream asset", () {
+ test("defaults to UTF-8 if encoding is omitted", () {
+ var asset = new Asset.fromStream(id,
+ new Stream.fromFuture(new Future.value(encodeUtf8("çøñ†éℵ™"))));
+ expect(asset.readAsString(),
+ completion(equals("çøñ†éℵ™")));
+ });
+
+ test("supports UTF-8", () {
+ var asset = new Asset.fromStream(id,
+ new Stream.fromFuture(new Future.value(encodeUtf8("çøñ†éℵ™"))));
+ expect(asset.readAsString(encoding: UTF8),
+ completion(equals("çøñ†éℵ™")));
+ });
+
+ // TODO(nweiz): Test other encodings once #6284 is fixed.
Bob Nystrom 2013/08/27 17:20:29 Add some tests for how it handles the source strea
nweiz 2013/08/27 17:47:52 These are essentially the tests we already have fo
+ });
});
group("toString()", () {

Powered by Google App Engine
This is Rietveld 408576698