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

Unified Diff: tests/standalone/io/socket_ipv6_test.dart

Issue 14083007: Add new InternetAddress class with a static lookup function (including IPv6 results). (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Fix new test. 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « tests/standalone/io/secure_socket_test.dart ('k') | tests/standalone/io/socket_upgrade_to_secure_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/standalone/io/socket_ipv6_test.dart
diff --git a/tests/standalone/io/socket_ipv6_test.dart b/tests/standalone/io/socket_ipv6_test.dart
new file mode 100644
index 0000000000000000000000000000000000000000..1c5a651dc714d0d8c15d4129003dc91c4ad7da0b
--- /dev/null
+++ b/tests/standalone/io/socket_ipv6_test.dart
@@ -0,0 +1,88 @@
+// Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+import 'dart:io';
+import 'dart:isolate';
+
+void testIPv6toIPv6() {
+ ServerSocket.bind("::0").then((server) {
+ server.listen((socket) {
+ socket.destroy();
+ server.close();
+ });
+ Socket.connect("::1", server.port).then((socket) {
+ socket.destroy();
+ });
+ });
+}
+
+void testIPv4toIPv6() {
+ ServerSocket.bind("::0").then((server) {
+ server.listen((socket) {
+ socket.destroy();
+ server.close();
+ });
+ Socket.connect("127.0.0.1", server.port).then((socket) {
+ socket.destroy();
+ });
+ });
+}
+
+void testIPv6toIPv4() {
+ ServerSocket.bind("127.0.0.1").then((server) {
+ server.listen((socket) {
+ throw "Unexpected socket";
+ });
+ Socket.connect("::1", server.port).catchError((e) {
+ server.close();
+ });
+ });
+}
+
+void testIPv4toIPv4() {
+ ServerSocket.bind("127.0.0.1").then((server) {
+ server.listen((socket) {
+ socket.destroy();
+ server.close();
+ });
+ Socket.connect("127.0.0.1", server.port).then((socket) {
+ socket.destroy();
+ });
+ });
+}
+
+void testIPv6Lookup() {
+ var port = new ReceivePort();
+ InternetAddress.lookup("::0").then((list) {
+ if (list.length < 0) throw "no address";
+ for (var entry in list) {
+ if (entry.type != InternetAddressType.IPv6) {
+ throw "Wrong IP type";
+ }
+ }
+ port.close();
+ });
+}
+
+void testIPv4Lookup() {
+ var port = new ReceivePort();
+ InternetAddress.lookup("127.0.0.1").then((list) {
+ if (list.length < 0) throw "no addresse";
+ for (var entry in list) {
+ if (entry.type != InternetAddressType.IPv4) {
+ throw "Wrong IP type";
+ }
+ }
+ port.close();
+ });
+}
+
+void main() {
+ testIPv6toIPv6();
+ testIPv4toIPv6();
+ testIPv6toIPv4();
+ testIPv4toIPv4();
+ testIPv6Lookup();
+ testIPv4Lookup();
+}
« no previous file with comments | « tests/standalone/io/secure_socket_test.dart ('k') | tests/standalone/io/socket_upgrade_to_secure_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698