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

Side by Side Diff: pkg/http/test/response_test.dart

Issue 196423017: Make BaseRequest.contentType use null rather than -1 as a flag value. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: code review Created 6 years, 9 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 | Annotate | Revision Log
« no previous file with comments | « pkg/http/test/mock_client_test.dart ('k') | pkg/http/test/streamed_request_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) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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 library response_test; 5 library response_test;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 8
9 import 'package:http/http.dart' as http; 9 import 'package:http/http.dart' as http;
10 import 'package:unittest/unittest.dart'; 10 import 'package:unittest/unittest.dart';
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 var response = new http.Response.bytes([102, 246, 248, 98, 227, 114], 200, 45 var response = new http.Response.bytes([102, 246, 248, 98, 227, 114], 200,
46 headers: {'content-type': 'text/plain; charset=iso-8859-1'}); 46 headers: {'content-type': 'text/plain; charset=iso-8859-1'});
47 expect(response.body, equals("föøbãr")); 47 expect(response.body, equals("föøbãr"));
48 }); 48 });
49 }); 49 });
50 50
51 group('.fromStream()', () { 51 group('.fromStream()', () {
52 test('sets body', () { 52 test('sets body', () {
53 var controller = new StreamController(sync: true); 53 var controller = new StreamController(sync: true);
54 var streamResponse = new http.StreamedResponse( 54 var streamResponse = new http.StreamedResponse(
55 controller.stream, 200, 13); 55 controller.stream, 200, contentLength: 13);
56 var future = http.Response.fromStream(streamResponse) 56 var future = http.Response.fromStream(streamResponse)
57 .then((response) => response.body); 57 .then((response) => response.body);
58 expect(future, completion(equals("Hello, world!"))); 58 expect(future, completion(equals("Hello, world!")));
59 59
60 controller.add([72, 101, 108, 108, 111, 44, 32]); 60 controller.add([72, 101, 108, 108, 111, 44, 32]);
61 controller.add([119, 111, 114, 108, 100, 33]); 61 controller.add([119, 111, 114, 108, 100, 33]);
62 controller.close(); 62 controller.close();
63 }); 63 });
64 64
65 test('sets bodyBytes', () { 65 test('sets bodyBytes', () {
66 var controller = new StreamController(sync: true); 66 var controller = new StreamController(sync: true);
67 var streamResponse = new http.StreamedResponse(controller.stream, 200, 5); 67 var streamResponse = new http.StreamedResponse(
68 controller.stream, 200, contentLength: 5);
68 var future = http.Response.fromStream(streamResponse) 69 var future = http.Response.fromStream(streamResponse)
69 .then((response) => response.bodyBytes); 70 .then((response) => response.bodyBytes);
70 expect(future, completion(equals([104, 101, 108, 108, 111]))); 71 expect(future, completion(equals([104, 101, 108, 108, 111])));
71 72
72 controller.add([104, 101, 108, 108, 111]); 73 controller.add([104, 101, 108, 108, 111]);
73 controller.close(); 74 controller.close();
74 }); 75 });
75 }); 76 });
76 } 77 }
OLDNEW
« no previous file with comments | « pkg/http/test/mock_client_test.dart ('k') | pkg/http/test/streamed_request_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698