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

Side by Side Diff: tests/standalone/io/http_advanced_test.dart

Issue 13841005: Rename DateTime constants to full names. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 8 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 | « tests/corelib/date_time_test.dart ('k') | tests/standalone/io/http_date_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) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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 // VMOptions= 5 // VMOptions=
6 // VMOptions=--short_socket_read 6 // VMOptions=--short_socket_read
7 // VMOptions=--short_socket_write 7 // VMOptions=--short_socket_write
8 // VMOptions=--short_socket_read --short_socket_write 8 // VMOptions=--short_socket_read --short_socket_write
9 9
10 import "package:expect/expect.dart"; 10 import "package:expect/expect.dart";
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 Expect.equals("www.dartlang.org:1234", request.headers["Host"][0]); 117 Expect.equals("www.dartlang.org:1234", request.headers["Host"][0]);
118 Expect.equals("www.dartlang.org", request.headers.host); 118 Expect.equals("www.dartlang.org", request.headers.host);
119 Expect.equals(1234, request.headers.port); 119 Expect.equals(1234, request.headers.port);
120 response.statusCode = HttpStatus.OK; 120 response.statusCode = HttpStatus.OK;
121 response.close(); 121 response.close();
122 } 122 }
123 123
124 // Set the "Expires" header using the expires property. 124 // Set the "Expires" header using the expires property.
125 void _expires1Handler(HttpRequest request) { 125 void _expires1Handler(HttpRequest request) {
126 var response = request.response; 126 var response = request.response;
127 DateTime date = new DateTime.utc(1999, DateTime.JUN, 11, 18, 46, 53, 0); 127 DateTime date = new DateTime.utc(1999, DateTime.JUNE, 11, 18, 46, 53, 0);
128 response.headers.expires = date; 128 response.headers.expires = date;
129 Expect.equals(date, response.headers.expires); 129 Expect.equals(date, response.headers.expires);
130 response.close(); 130 response.close();
131 } 131 }
132 132
133 // Set the "Expires" header. 133 // Set the "Expires" header.
134 void _expires2Handler(HttpRequest request) { 134 void _expires2Handler(HttpRequest request) {
135 var response = request.response; 135 var response = request.response;
136 response.headers.set("Expires", "Fri, 11 Jun 1999 18:46:53 GMT"); 136 response.headers.set("Expires", "Fri, 11 Jun 1999 18:46:53 GMT");
137 DateTime date = new DateTime.utc(1999, DateTime.JUN, 11, 18, 46, 53, 0); 137 DateTime date = new DateTime.utc(1999, DateTime.JUNE, 11, 18, 46, 53, 0);
138 Expect.equals(date, response.headers.expires); 138 Expect.equals(date, response.headers.expires);
139 response.close(); 139 response.close();
140 } 140 }
141 141
142 void _contentType1Handler(HttpRequest request) { 142 void _contentType1Handler(HttpRequest request) {
143 var response = request.response; 143 var response = request.response;
144 Expect.equals("text/html", request.headers.contentType.value); 144 Expect.equals("text/html", request.headers.contentType.value);
145 Expect.equals("text", request.headers.contentType.primaryType); 145 Expect.equals("text", request.headers.contentType.primaryType);
146 Expect.equals("html", request.headers.contentType.subType); 146 Expect.equals("html", request.headers.contentType.subType);
147 Expect.equals("utf-8", request.headers.contentType.parameters["charset"]); 147 Expect.equals("utf-8", request.headers.contentType.parameters["charset"]);
(...skipping 15 matching lines...) Expand all
163 response.close(); 163 response.close();
164 } 164 }
165 165
166 void _cookie1Handler(HttpRequest request) { 166 void _cookie1Handler(HttpRequest request) {
167 var response = request.response; 167 var response = request.response;
168 168
169 // No cookies passed with this request. 169 // No cookies passed with this request.
170 Expect.equals(0, request.cookies.length); 170 Expect.equals(0, request.cookies.length);
171 171
172 Cookie cookie1 = new Cookie("name1", "value1"); 172 Cookie cookie1 = new Cookie("name1", "value1");
173 DateTime date = new DateTime.utc(2014, DateTime.JAN, 5, 23, 59, 59, 0); 173 DateTime date = new DateTime.utc(2014, DateTime.JANUARY, 5, 23, 59, 59, 0);
174 cookie1.expires = date; 174 cookie1.expires = date;
175 cookie1.domain = "www.example.com"; 175 cookie1.domain = "www.example.com";
176 cookie1.httpOnly = true; 176 cookie1.httpOnly = true;
177 response.cookies.add(cookie1); 177 response.cookies.add(cookie1);
178 Cookie cookie2 = new Cookie("name2", "value2"); 178 Cookie cookie2 = new Cookie("name2", "value2");
179 cookie2.maxAge = 100; 179 cookie2.maxAge = 100;
180 cookie2.domain = ".example.com"; 180 cookie2.domain = ".example.com";
181 cookie2.path = "/shop"; 181 cookie2.path = "/shop";
182 response.cookies.add(cookie2); 182 response.cookies.add(cookie2);
183 response.close(); 183 response.close();
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
286 Completer completer = new Completer(); 286 Completer completer = new Completer();
287 IsolatedHttpServer server = new IsolatedHttpServer(); 287 IsolatedHttpServer server = new IsolatedHttpServer();
288 server.setServerStartedHandler((int port) { 288 server.setServerStartedHandler((int port) {
289 int responses = 0; 289 int responses = 0;
290 HttpClient httpClient = new HttpClient(); 290 HttpClient httpClient = new HttpClient();
291 291
292 void processResponse(HttpClientResponse response) { 292 void processResponse(HttpClientResponse response) {
293 Expect.equals(HttpStatus.OK, response.statusCode); 293 Expect.equals(HttpStatus.OK, response.statusCode);
294 Expect.equals("Fri, 11 Jun 1999 18:46:53 GMT", 294 Expect.equals("Fri, 11 Jun 1999 18:46:53 GMT",
295 response.headers["expires"][0]); 295 response.headers["expires"][0]);
296 Expect.equals(new DateTime.utc(1999, DateTime.JUN, 11, 18, 46, 53, 0), 296 Expect.equals(new DateTime.utc(1999, DateTime.JUNE, 11, 18, 46, 53, 0),
297 response.headers.expires); 297 response.headers.expires);
298 response.listen((_) { }, 298 response.listen((_) { },
299 onDone: () { 299 onDone: () {
300 responses++; 300 responses++;
301 if (responses == 2) { 301 if (responses == 2) {
302 httpClient.close(); 302 httpClient.close();
303 server.shutdown(); 303 server.shutdown();
304 completer.complete(true); 304 completer.complete(true);
305 } 305 }
306 }); 306 });
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
373 HttpClient httpClient = new HttpClient(); 373 HttpClient httpClient = new HttpClient();
374 374
375 httpClient.get("127.0.0.1", port, "/cookie1") 375 httpClient.get("127.0.0.1", port, "/cookie1")
376 .then((request) => request.close()) 376 .then((request) => request.close())
377 .then((response) { 377 .then((response) {
378 Expect.equals(2, response.cookies.length); 378 Expect.equals(2, response.cookies.length);
379 response.cookies.forEach((cookie) { 379 response.cookies.forEach((cookie) {
380 if (cookie.name == "name1") { 380 if (cookie.name == "name1") {
381 Expect.equals("value1", cookie.value); 381 Expect.equals("value1", cookie.value);
382 DateTime date = 382 DateTime date =
383 new DateTime.utc(2014, DateTime.JAN, 5, 23, 59, 59, 0); 383 new DateTime.utc(2014, DateTime.JANUARY, 5, 23, 59, 59, 0);
384 Expect.equals(date, cookie.expires); 384 Expect.equals(date, cookie.expires);
385 Expect.equals("www.example.com", cookie.domain); 385 Expect.equals("www.example.com", cookie.domain);
386 Expect.isTrue(cookie.httpOnly); 386 Expect.isTrue(cookie.httpOnly);
387 } else if (cookie.name == "name2") { 387 } else if (cookie.name == "name2") {
388 Expect.equals("value2", cookie.value); 388 Expect.equals("value2", cookie.value);
389 Expect.equals(100, cookie.maxAge); 389 Expect.equals(100, cookie.maxAge);
390 Expect.equals(".example.com", cookie.domain); 390 Expect.equals(".example.com", cookie.domain);
391 Expect.equals("/shop", cookie.path); 391 Expect.equals("/shop", cookie.path);
392 } else { 392 } else {
393 Expect.fail("Unexpected cookie"); 393 Expect.fail("Unexpected cookie");
(...skipping 27 matching lines...) Expand all
421 421
422 void main() { 422 void main() {
423 testHost().then((_) { 423 testHost().then((_) {
424 return testExpires().then((_) { 424 return testExpires().then((_) {
425 return testContentType().then((_) { 425 return testContentType().then((_) {
426 return testCookies(); 426 return testCookies();
427 }); 427 });
428 }); 428 });
429 }); 429 });
430 } 430 }
OLDNEW
« no previous file with comments | « tests/corelib/date_time_test.dart ('k') | tests/standalone/io/http_date_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698