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

Side by Side Diff: pkg/http/test/mock_client_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/pubspec.yaml ('k') | pkg/http/test/response_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 mock_client_test; 5 library mock_client_test;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 import 'dart:convert'; 8 import 'dart:convert';
9 9
10 import 'package:http/http.dart' as http; 10 import 'package:http/http.dart' as http;
(...skipping 22 matching lines...) Expand all
33 33
34 test('handles a streamed request', () { 34 test('handles a streamed request', () {
35 var client = new MockClient.streaming((request, bodyStream) { 35 var client = new MockClient.streaming((request, bodyStream) {
36 return bodyStream.bytesToString().then((bodyString) { 36 return bodyStream.bytesToString().then((bodyString) {
37 var controller = new StreamController<List<int>>(sync: true); 37 var controller = new StreamController<List<int>>(sync: true);
38 async.then((_) { 38 async.then((_) {
39 controller.add('Request body was "$bodyString"'.codeUnits); 39 controller.add('Request body was "$bodyString"'.codeUnits);
40 controller.close(); 40 controller.close();
41 }); 41 });
42 42
43 return new http.StreamedResponse(controller.stream, 200, -1); 43 return new http.StreamedResponse(controller.stream, 200);
44 }); 44 });
45 }); 45 });
46 46
47 var uri = Uri.parse("http://example.com/foo"); 47 var uri = Uri.parse("http://example.com/foo");
48 var request = new http.Request("POST", uri); 48 var request = new http.Request("POST", uri);
49 request.body = "hello, world"; 49 request.body = "hello, world";
50 var future = client.send(request) 50 var future = client.send(request)
51 .then(http.Response.fromStream) 51 .then(http.Response.fromStream)
52 .then((response) => response.body); 52 .then((response) => response.body);
53 expect(future, completion(equals('Request body was "hello, world"'))); 53 expect(future, completion(equals('Request body was "hello, world"')));
54 }); 54 });
55 55
56 test('handles a request with no body', () { 56 test('handles a request with no body', () {
57 var client = new MockClient((request) { 57 var client = new MockClient((request) {
58 return new Future.value(new http.Response('you did it', 200)); 58 return new Future.value(new http.Response('you did it', 200));
59 }); 59 });
60 60
61 expect(client.read("http://example.com/foo"), 61 expect(client.read("http://example.com/foo"),
62 completion(equals('you did it'))); 62 completion(equals('you did it')));
63 }); 63 });
64 } 64 }
OLDNEW
« no previous file with comments | « pkg/http/pubspec.yaml ('k') | pkg/http/test/response_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698