OLD | NEW |
(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:async'; |
| 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/resource_data.txt?cacheBlock=$cacheBlocker'; |
| 16 |
| 17 void validateResponse(data) { |
| 18 expect(data, equals('This file was read by a Resource!')); |
| 19 } |
| 20 |
| 21 group('resource', () { |
| 22 test('readAsString', () async { |
| 23 Resource r = new Resource(url); |
| 24 var data = await r.readAsString(); |
| 25 validateResponse(data); |
| 26 }); |
| 27 test('readAsBytes', () async { |
| 28 Resource r = new Resource(url); |
| 29 var data = await r.readAsBytes(); |
| 30 validateResponse(new String.fromCharCodes(data)); |
| 31 }); |
| 32 test('openRead', () async { |
| 33 Resource r = new Resource(url); |
| 34 var bytes = []; |
| 35 await for (var b in r.openRead()) { |
| 36 bytes.addAll(b); |
| 37 } |
| 38 validateResponse(new String.fromCharCodes(bytes)); |
| 39 }); |
| 40 }); |
| 41 } |
OLD | NEW |