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

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

Issue 12328037: Add missing files from previous commit (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « tests/standalone/io/raw_socket_test.dart ('k') | tests/standalone/io/secure_client_raw_server_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/standalone/io/raw_socket_write_destroy_test.dart
diff --git a/tests/standalone/io/raw_socket_write_destroy_test.dart b/tests/standalone/io/raw_socket_write_destroy_test.dart
new file mode 100644
index 0000000000000000000000000000000000000000..b5e558a8433d8130445818577eec07c89ef0a90c
--- /dev/null
+++ b/tests/standalone/io/raw_socket_write_destroy_test.dart
@@ -0,0 +1,96 @@
+// 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.
+//
+// VMOptions=
+// VMOptions=--short_socket_read
+// VMOptions=--short_socket_write
+// VMOptions=--short_socket_read --short_socket_write
+
+import "dart:async";
+import "dart:io";
+import "dart:isolate";
+const SERVER_ADDRESS = "127.0.0.1";
+
+void testWriteDestroyServer() {
+ int WROTE = 100000;
+ RawServerSocket.bind(SERVER_ADDRESS).then((server) {
+ server.listen((socket) {
+ socket.writeEventsEnabled = false;
+
+ var buffer = new List.fixedLength(WROTE, fill: 0);
+ int offset = 0;
+ void write() {
+ int n = socket.write(buffer, offset, buffer.length - offset);
+ offset += n;
+ socket.writeEventsEnabled = true;
+ }
+ socket.listen((e) {
+ if (e == RawSocketEvent.WRITE) {
+ if (offset == buffer.length) {
+ socket.close();
+ } else {
+ write();
+ }
+ }
+ });
+ write();
+ });
+ RawSocket.connect(SERVER_ADDRESS, server.port).then((socket) {
+ var bytes = 0;
+ socket.listen((e) {
+ if (e == RawSocketEvent.READ) {
+ bytes += socket.read().length;
+ } else if (e == RawSocketEvent.READ_CLOSED) {
+ Expect.equals(WROTE, bytes);
+ socket.close();
+ server.close();
+ }
+ });
+ });
+ });
+}
+
+void testWriteDestroyClient() {
+ int WROTE = 100000;
+ RawServerSocket.bind(SERVER_ADDRESS).then((server) {
+ server.listen((socket) {
+ var bytes = 0;
+ socket.listen((e) {
+ if (e == RawSocketEvent.READ) {
+ bytes += socket.read().length;
+ } else if (e == RawSocketEvent.READ_CLOSED) {
+ Expect.equals(WROTE, bytes);
+ socket.close();
+ server.close();
+ }
+ });
+ });
+ RawSocket.connect(SERVER_ADDRESS, server.port).then((socket) {
+ socket.writeEventsEnabled = false;
+
+ var buffer = new List.fixedLength(WROTE, fill: 0);
+ int offset = 0;
+ void write() {
+ int n = socket.write(buffer, offset, buffer.length - offset);
+ offset += n;
+ socket.writeEventsEnabled = true;
+ }
+ socket.listen((e) {
+ if (e == RawSocketEvent.WRITE) {
+ if (offset == buffer.length) {
+ socket.close();
+ } else {
+ write();
+ }
+ }
+ });
+ write();
+ });
+ });
+}
+
+void main() {
+ testWriteDestroyServer();
+ testWriteDestroyClient();
+}
« no previous file with comments | « tests/standalone/io/raw_socket_test.dart ('k') | tests/standalone/io/secure_client_raw_server_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698