| OLD | NEW |
| 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 // 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 "dart:async"; | 10 import "dart:async"; |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 // work with www.google.dk. | 24 // work with www.google.dk. |
| 25 RawSecureSocket.connect("www.google.dk", 443).then((socket) { | 25 RawSecureSocket.connect("www.google.dk", 443).then((socket) { |
| 26 StreamSubscription subscription; | 26 StreamSubscription subscription; |
| 27 bool paused = false; | 27 bool paused = false; |
| 28 bool readEventsTested = false; | 28 bool readEventsTested = false; |
| 29 bool readEventsPaused = false; | 29 bool readEventsPaused = false; |
| 30 | 30 |
| 31 void runPauseTest() { | 31 void runPauseTest() { |
| 32 subscription.pause(); | 32 subscription.pause(); |
| 33 paused = true; | 33 paused = true; |
| 34 new Timer(500, (_) { | 34 new Timer(const Duration(milliseconds: 500), () { |
| 35 paused = false; | 35 paused = false; |
| 36 subscription.resume(); | 36 subscription.resume(); |
| 37 }); | 37 }); |
| 38 } | 38 } |
| 39 | 39 |
| 40 void runReadEventTest() { | 40 void runReadEventTest() { |
| 41 if (readEventsTested) return; | 41 if (readEventsTested) return; |
| 42 readEventsTested = true; | 42 readEventsTested = true; |
| 43 socket.readEventsEnabled = false; | 43 socket.readEventsEnabled = false; |
| 44 readEventsPaused = true; | 44 readEventsPaused = true; |
| 45 new Timer(500, (_) { | 45 new Timer(const Duration(milliseconds: 500), () { |
| 46 readEventsPaused = false; | 46 readEventsPaused = false; |
| 47 socket.readEventsEnabled = true; | 47 socket.readEventsEnabled = true; |
| 48 }); | 48 }); |
| 49 } | 49 } |
| 50 | 50 |
| 51 subscription = socket.listen((RawSocketEvent event) { | 51 subscription = socket.listen((RawSocketEvent event) { |
| 52 Expect.isFalse(paused); | 52 Expect.isFalse(paused); |
| 53 switch (event) { | 53 switch (event) { |
| 54 case RawSocketEvent.READ: | 54 case RawSocketEvent.READ: |
| 55 Expect.isFalse(readEventsPaused); | 55 Expect.isFalse(readEventsPaused); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 72 String fullPage = chunks.join(); | 72 String fullPage = chunks.join(); |
| 73 Expect.isTrue(fullPage.contains('</body></html>')); | 73 Expect.isTrue(fullPage.contains('</body></html>')); |
| 74 break; | 74 break; |
| 75 default: throw "Unexpected event $event"; | 75 default: throw "Unexpected event $event"; |
| 76 } | 76 } |
| 77 }, onError: (AsyncError a) { | 77 }, onError: (AsyncError a) { |
| 78 Expect.fail("onError handler of RawSecureSocket stream hit: $a"); | 78 Expect.fail("onError handler of RawSecureSocket stream hit: $a"); |
| 79 }); | 79 }); |
| 80 }); | 80 }); |
| 81 } | 81 } |
| OLD | NEW |