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

Unified Diff: tests/standalone/src/io/HttpClientTest.dart

Issue 9625008: Add support for using an URL for establishing HTTP connections (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Addressed rewiev comments from @ager Created 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « runtime/bin/http_impl.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/standalone/src/io/HttpClientTest.dart
diff --git a/tests/standalone/src/io/HttpClientTest.dart b/tests/standalone/src/io/HttpClientTest.dart
index 897e921256ff9f1f69146ce1b4262d2445b09a29..3598b54c899c7a10843835a3a1d46ad78758d02f 100644
--- a/tests/standalone/src/io/HttpClientTest.dart
+++ b/tests/standalone/src/io/HttpClientTest.dart
@@ -3,6 +3,7 @@
// BSD-style license that can be found in the LICENSE file.
#import("dart:io");
+#import("dart:uri");
void testGoogle() {
HttpClient client = new HttpClient();
@@ -21,8 +22,48 @@ void testGoogle() {
client.shutdown();
};
};
+ conn.onError = (error) => Expect.fail("Unexpected IO error");
+}
+
+void testGoogleUrl() {
+ HttpClient client = new HttpClient();
+
+ void testUrl(String url) {
+ var conn = client.getUrl(new Uri.fromString(url));
+
+ conn.onRequest = (HttpClientRequest request) {
+ request.keepAlive = false;
+ request.outputStream.close();
+ };
+ conn.onResponse = (HttpClientResponse response) {
+ Expect.isTrue(response.statusCode < 500);
+ response.inputStream.onData = () {
+ response.inputStream.read();
+ };
+ response.inputStream.onClosed = () {
+ client.shutdown();
+ };
+ };
+ conn.onError = (error) => Expect.fail("Unexpected IO error");
+ }
+
+ testUrl('http://www.google.com');
+ testUrl('http://www.google.com/abc');
+ testUrl('http://www.google.com/?abc');
+ testUrl('http://www.google.com/abc?abc');
+ testUrl('http://www.google.com/abc?abc#abc');
+}
+
+void testInvalidUrl() {
+ HttpClient client = new HttpClient();
+ Expect.throws(
+ () => client.getUrl(new Uri.fromString('ftp://www.google.com')));
+ Expect.throws(
+ () => client.getUrl(new Uri.fromString('http://usr:pwd@www.google.com')));
}
void main() {
testGoogle();
+ testGoogleUrl();
+ testInvalidUrl();
}
« no previous file with comments | « runtime/bin/http_impl.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698