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

Side by Side Diff: tests/html/resource_http_test.dart

Issue 1308143002: dart2js: fetch http Resources (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 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 unified diff | Download patch
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 library resource_http_test;
6 import 'dart:convert';
7 import 'package:unittest/html_individual_config.dart';
8 import 'package:unittest/unittest.dart';
9
10 main() {
11 useHtmlIndividualConfiguration();
12 // Cache blocker is a workaround for:
13 // https://code.google.com/p/dart/issues/detail?id=11834
14 var cacheBlocker = new DateTime.now().millisecondsSinceEpoch;
15 var url = '/root_dart/tests/html/xhr_cross_origin_data.txt?'
Siggi Cherem (dart-lang) 2015/08/25 00:43:27 let's use a new data file specific for this test,
Harry Terkelsen 2015/08/25 17:45:06 Done.
16 'cacheBlock=$cacheBlocker';
17
18 void validateResponse(d) {
19 var data = JSON.decode(d);
Siggi Cherem (dart-lang) 2015/08/25 00:43:27 then this could be a simple string equality check
Harry Terkelsen 2015/08/25 17:45:06 Done.
20 expect(data, contains('feed'));
21 expect(data['feed'], contains('entry'));
22 expect(data, isMap);
23 }
24
25 group('resource', () {
26 test('readAsString', () {
27 Resource r = new Resource(url);
28 r.readAsString().then(expectAsync((s) {
Siggi Cherem (dart-lang) 2015/08/25 00:43:27 either use await or return the future to ensure we
Harry Terkelsen 2015/08/25 17:45:06 Done.
29 validateResponse(s);
30 }));
31 });
32 test('readAsBytes', () {
33 Resource r = new Resource(url);
34 r.readAsBytes().then(expectAsync((b) {
Siggi Cherem (dart-lang) 2015/08/25 00:43:27 ditto
Harry Terkelsen 2015/08/25 17:45:06 Done.
35 validateResponse(new String.fromCharCodes(b));
36 }));
37 });
38 test('openRead', () async {
39 Resource r = new Resource(url);
40 var bytes = [];
41 await for (var b in r.openRead()) {
42 bytes.addAll(b);
43 }
44 validateResponse(new String.fromCharCodes(bytes));
45 });
46 });
47 }
OLDNEW
« sdk/lib/_internal/js_runtime/lib/js_helper.dart ('K') | « tests/corelib/corelib.status ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698