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

Side by Side Diff: sdk/lib/_internal/pub/test/serve/utils.dart

Issue 131233011: Set the correct mime types for assets served via pub serve. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: code review Created 6 years, 10 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 | « sdk/lib/_internal/pub/test/serve/uses_appropriate_mime_types_test.dart ('k') | no next file » | 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) 2013, the Dart project authors. Please see the AUTHORS d.file 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS d.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 pub_tests; 5 library pub_tests;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 import 'dart:convert'; 8 import 'dart:convert';
9 import 'dart:io'; 9 import 'dart:io';
10 10
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
162 } 162 }
163 163
164 void endPubServe() { 164 void endPubServe() {
165 _pubServer.kill(); 165 _pubServer.kill();
166 } 166 }
167 167
168 /// Schedules an HTTP request to the running pub server with [urlPath] and 168 /// Schedules an HTTP request to the running pub server with [urlPath] and
169 /// verifies that it responds with a body that matches [expectation]. 169 /// verifies that it responds with a body that matches [expectation].
170 /// 170 ///
171 /// [expectation] may either be a [Matcher] or a string to match an exact body. 171 /// [expectation] may either be a [Matcher] or a string to match an exact body.
172 void requestShouldSucceed(String urlPath, expectation) { 172 /// [headers] may be either a [Matcher] or a map to match an exact headers map.
173 void requestShouldSucceed(String urlPath, expectation, {headers}) {
173 schedule(() { 174 schedule(() {
174 return http.get("http://127.0.0.1:$_port/$urlPath").then((response) { 175 return http.get("http://127.0.0.1:$_port/$urlPath").then((response) {
175 expect(response.body, expectation); 176 if (expectation != null) expect(response.body, expectation);
177 if (headers != null) expect(response.headers, headers);
176 }); 178 });
177 }, "request $urlPath"); 179 }, "request $urlPath");
178 } 180 }
179 181
180 /// Schedules an HTTP request to the running pub server with [urlPath] and 182 /// Schedules an HTTP request to the running pub server with [urlPath] and
181 /// verifies that it responds with a 404. 183 /// verifies that it responds with a 404.
182 void requestShould404(String urlPath) { 184 void requestShould404(String urlPath) {
183 schedule(() { 185 schedule(() {
184 return http.get("http://127.0.0.1:$_port/$urlPath").then((response) { 186 return http.get("http://127.0.0.1:$_port/$urlPath").then((response) {
185 expect(response.statusCode, equals(404)); 187 expect(response.statusCode, equals(404));
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
240 /// socket. It omitted, request is JSON encoded to a string first. 242 /// socket. It omitted, request is JSON encoded to a string first.
241 void webSocketShouldReply(request, expectation, {bool encodeRequest: true}) { 243 void webSocketShouldReply(request, expectation, {bool encodeRequest: true}) {
242 schedule(() => _ensureWebSocket().then((_) { 244 schedule(() => _ensureWebSocket().then((_) {
243 if (encodeRequest) request = JSON.encode(request); 245 if (encodeRequest) request = JSON.encode(request);
244 _webSocket.add(request); 246 _webSocket.add(request);
245 return _webSocketBroadcastStream.first.then((value) { 247 return _webSocketBroadcastStream.first.then((value) {
246 expect(JSON.decode(value), expectation); 248 expect(JSON.decode(value), expectation);
247 }); 249 });
248 }), "send $request to web socket and expect reply that $expectation"); 250 }), "send $request to web socket and expect reply that $expectation");
249 } 251 }
OLDNEW
« no previous file with comments | « sdk/lib/_internal/pub/test/serve/uses_appropriate_mime_types_test.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698