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

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

Issue 11770004: Rename Date to DateTime. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Address comments and keep Backwards-compatibility class Date. Created 7 years, 11 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
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 import 'dart:async'; 5 import 'dart:async';
6 import 'dart:math'; 6 import 'dart:math';
7 7
8 part "../../../sdk/lib/io/input_stream.dart"; 8 part "../../../sdk/lib/io/input_stream.dart";
9 part "../../../sdk/lib/io/output_stream.dart"; 9 part "../../../sdk/lib/io/output_stream.dart";
10 part "../../../sdk/lib/io/chunked_stream.dart"; 10 part "../../../sdk/lib/io/chunked_stream.dart";
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 Expect.equals(1, headers[HttpHeaders.PRAGMA].length); 47 Expect.equals(1, headers[HttpHeaders.PRAGMA].length);
48 48
49 headers.set(HttpHeaders.PRAGMA, ["pragma6", "pragma7"]); 49 headers.set(HttpHeaders.PRAGMA, ["pragma6", "pragma7"]);
50 Expect.equals(2, headers[HttpHeaders.PRAGMA].length); 50 Expect.equals(2, headers[HttpHeaders.PRAGMA].length);
51 51
52 headers.removeAll(HttpHeaders.PRAGMA); 52 headers.removeAll(HttpHeaders.PRAGMA);
53 Expect.isNull(headers[HttpHeaders.PRAGMA]); 53 Expect.isNull(headers[HttpHeaders.PRAGMA]);
54 } 54 }
55 55
56 void testDate() { 56 void testDate() {
57 Date date1 = new Date.utc(1999, Date.JUN, 11, 18, 46, 53, 0); 57 DateTime date1 = new DateTime.utc(1999, DateTime.JUN, 11, 18, 46, 53, 0);
58 String httpDate1 = "Fri, 11 Jun 1999 18:46:53 GMT"; 58 String httpDate1 = "Fri, 11 Jun 1999 18:46:53 GMT";
59 Date date2 = new Date.utc(2000, Date.AUG, 16, 12, 34, 56, 0); 59 DateTime date2 = new DateTime.utc(2000, DateTime.AUG, 16, 12, 34, 56, 0);
60 String httpDate2 = "Wed, 16 Aug 2000 12:34:56 GMT"; 60 String httpDate2 = "Wed, 16 Aug 2000 12:34:56 GMT";
61 61
62 _HttpHeaders headers = new _HttpHeaders(); 62 _HttpHeaders headers = new _HttpHeaders();
63 Expect.isNull(headers.date); 63 Expect.isNull(headers.date);
64 headers.date = date1; 64 headers.date = date1;
65 Expect.equals(date1, headers.date); 65 Expect.equals(date1, headers.date);
66 Expect.equals(httpDate1, headers.value(HttpHeaders.DATE)); 66 Expect.equals(httpDate1, headers.value(HttpHeaders.DATE));
67 Expect.equals(1, headers[HttpHeaders.DATE].length); 67 Expect.equals(1, headers[HttpHeaders.DATE].length);
68 headers.add(HttpHeaders.DATE, httpDate2); 68 headers.add(HttpHeaders.DATE, httpDate2);
69 Expect.equals(1, headers[HttpHeaders.DATE].length); 69 Expect.equals(1, headers[HttpHeaders.DATE].length);
70 Expect.equals(date2, headers.date); 70 Expect.equals(date2, headers.date);
71 Expect.equals(httpDate2, headers.value(HttpHeaders.DATE)); 71 Expect.equals(httpDate2, headers.value(HttpHeaders.DATE));
72 headers.set(HttpHeaders.DATE, httpDate1); 72 headers.set(HttpHeaders.DATE, httpDate1);
73 Expect.equals(1, headers[HttpHeaders.DATE].length); 73 Expect.equals(1, headers[HttpHeaders.DATE].length);
74 Expect.equals(date1, headers.date); 74 Expect.equals(date1, headers.date);
75 Expect.equals(httpDate1, headers.value(HttpHeaders.DATE)); 75 Expect.equals(httpDate1, headers.value(HttpHeaders.DATE));
76 76
77 headers.set(HttpHeaders.DATE, "xxx"); 77 headers.set(HttpHeaders.DATE, "xxx");
78 Expect.equals("xxx", headers.value(HttpHeaders.DATE)); 78 Expect.equals("xxx", headers.value(HttpHeaders.DATE));
79 Expect.equals(null, headers.date); 79 Expect.equals(null, headers.date);
80 } 80 }
81 81
82 void testExpires() { 82 void testExpires() {
83 Date date1 = new Date.utc(1999, Date.JUN, 11, 18, 46, 53, 0); 83 DateTime date1 = new DateTime.utc(1999, DateTime.JUN, 11, 18, 46, 53, 0);
84 String httpDate1 = "Fri, 11 Jun 1999 18:46:53 GMT"; 84 String httpDate1 = "Fri, 11 Jun 1999 18:46:53 GMT";
85 Date date2 = new Date.utc(2000, Date.AUG, 16, 12, 34, 56, 0); 85 DateTime date2 = new DateTime.utc(2000, DateTime.AUG, 16, 12, 34, 56, 0);
86 String httpDate2 = "Wed, 16 Aug 2000 12:34:56 GMT"; 86 String httpDate2 = "Wed, 16 Aug 2000 12:34:56 GMT";
87 87
88 _HttpHeaders headers = new _HttpHeaders(); 88 _HttpHeaders headers = new _HttpHeaders();
89 Expect.isNull(headers.expires); 89 Expect.isNull(headers.expires);
90 headers.expires = date1; 90 headers.expires = date1;
91 Expect.equals(date1, headers.expires); 91 Expect.equals(date1, headers.expires);
92 Expect.equals(httpDate1, headers.value(HttpHeaders.EXPIRES)); 92 Expect.equals(httpDate1, headers.value(HttpHeaders.EXPIRES));
93 Expect.equals(1, headers[HttpHeaders.EXPIRES].length); 93 Expect.equals(1, headers[HttpHeaders.EXPIRES].length);
94 headers.add(HttpHeaders.EXPIRES, httpDate2); 94 headers.add(HttpHeaders.EXPIRES, httpDate2);
95 Expect.equals(1, headers[HttpHeaders.EXPIRES].length); 95 Expect.equals(1, headers[HttpHeaders.EXPIRES].length);
96 Expect.equals(date2, headers.expires); 96 Expect.equals(date2, headers.expires);
97 Expect.equals(httpDate2, headers.value(HttpHeaders.EXPIRES)); 97 Expect.equals(httpDate2, headers.value(HttpHeaders.EXPIRES));
98 headers.set(HttpHeaders.EXPIRES, httpDate1); 98 headers.set(HttpHeaders.EXPIRES, httpDate1);
99 Expect.equals(1, headers[HttpHeaders.EXPIRES].length); 99 Expect.equals(1, headers[HttpHeaders.EXPIRES].length);
100 Expect.equals(date1, headers.expires); 100 Expect.equals(date1, headers.expires);
101 Expect.equals(httpDate1, headers.value(HttpHeaders.EXPIRES)); 101 Expect.equals(httpDate1, headers.value(HttpHeaders.EXPIRES));
102 102
103 headers.set(HttpHeaders.EXPIRES, "xxx"); 103 headers.set(HttpHeaders.EXPIRES, "xxx");
104 Expect.equals("xxx", headers.value(HttpHeaders.EXPIRES)); 104 Expect.equals("xxx", headers.value(HttpHeaders.EXPIRES));
105 Expect.equals(null, headers.expires); 105 Expect.equals(null, headers.expires);
106 } 106 }
107 107
108 void testIfModifiedSince() { 108 void testIfModifiedSince() {
109 Date date1 = new Date.utc(1999, Date.JUN, 11, 18, 46, 53, 0); 109 DateTime date1 = new DateTime.utc(1999, DateTime.JUN, 11, 18, 46, 53, 0);
110 String httpDate1 = "Fri, 11 Jun 1999 18:46:53 GMT"; 110 String httpDate1 = "Fri, 11 Jun 1999 18:46:53 GMT";
111 Date date2 = new Date.utc(2000, Date.AUG, 16, 12, 34, 56, 0); 111 DateTime date2 = new DateTime.utc(2000, DateTime.AUG, 16, 12, 34, 56, 0);
112 String httpDate2 = "Wed, 16 Aug 2000 12:34:56 GMT"; 112 String httpDate2 = "Wed, 16 Aug 2000 12:34:56 GMT";
113 113
114 _HttpHeaders headers = new _HttpHeaders(); 114 _HttpHeaders headers = new _HttpHeaders();
115 Expect.isNull(headers.ifModifiedSince); 115 Expect.isNull(headers.ifModifiedSince);
116 headers.ifModifiedSince = date1; 116 headers.ifModifiedSince = date1;
117 Expect.equals(date1, headers.ifModifiedSince); 117 Expect.equals(date1, headers.ifModifiedSince);
118 Expect.equals(httpDate1, headers.value(HttpHeaders.IF_MODIFIED_SINCE)); 118 Expect.equals(httpDate1, headers.value(HttpHeaders.IF_MODIFIED_SINCE));
119 Expect.equals(1, headers[HttpHeaders.IF_MODIFIED_SINCE].length); 119 Expect.equals(1, headers[HttpHeaders.IF_MODIFIED_SINCE].length);
120 headers.add(HttpHeaders.IF_MODIFIED_SINCE, httpDate2); 120 headers.add(HttpHeaders.IF_MODIFIED_SINCE, httpDate2);
121 Expect.equals(1, headers[HttpHeaders.IF_MODIFIED_SINCE].length); 121 Expect.equals(1, headers[HttpHeaders.IF_MODIFIED_SINCE].length);
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after
312 312
313 void checkCookie(cookie, s) { 313 void checkCookie(cookie, s) {
314 Expect.equals(s, cookie.toString()); 314 Expect.equals(s, cookie.toString());
315 var c = new _Cookie.fromSetCookieValue(s); 315 var c = new _Cookie.fromSetCookieValue(s);
316 checkCookiesEquals(cookie, c); 316 checkCookiesEquals(cookie, c);
317 } 317 }
318 318
319 Cookie cookie; 319 Cookie cookie;
320 cookie = new Cookie("name", "value"); 320 cookie = new Cookie("name", "value");
321 Expect.equals("name=value", cookie.toString()); 321 Expect.equals("name=value", cookie.toString());
322 Date date = new Date.utc(2014, Date.JAN, 5, 23, 59, 59, 0); 322 DateTime date = new DateTime.utc(2014, DateTime.JAN, 5, 23, 59, 59, 0);
323 cookie.expires = date; 323 cookie.expires = date;
324 checkCookie(cookie, "name=value" 324 checkCookie(cookie, "name=value"
325 "; Expires=Sun, 5 Jan 2014 23:59:59 GMT"); 325 "; Expires=Sun, 5 Jan 2014 23:59:59 GMT");
326 cookie.maxAge = 567; 326 cookie.maxAge = 567;
327 checkCookie(cookie, "name=value" 327 checkCookie(cookie, "name=value"
328 "; Expires=Sun, 5 Jan 2014 23:59:59 GMT" 328 "; Expires=Sun, 5 Jan 2014 23:59:59 GMT"
329 "; Max-Age=567"); 329 "; Max-Age=567");
330 cookie.domain = "example.com"; 330 cookie.domain = "example.com";
331 checkCookie(cookie, "name=value" 331 checkCookie(cookie, "name=value"
332 "; Expires=Sun, 5 Jan 2014 23:59:59 GMT" 332 "; Expires=Sun, 5 Jan 2014 23:59:59 GMT"
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
404 testIfModifiedSince(); 404 testIfModifiedSince();
405 testHost(); 405 testHost();
406 testEnumeration(); 406 testEnumeration();
407 testHeaderValue(); 407 testHeaderValue();
408 testContentType(); 408 testContentType();
409 testContentTypeCache(); 409 testContentTypeCache();
410 testCookie(); 410 testCookie();
411 testInvalidCookie(); 411 testInvalidCookie();
412 testHeaderLists(); 412 testHeaderLists();
413 } 413 }
OLDNEW
« no previous file with comments | « tests/standalone/io/http_date_test.dart ('k') | tests/standalone/io/secure_socket_bad_certificate_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698