Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | |
| 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. | |
| 4 | |
| 5 library test.integration.analysis.error; | |
| 6 | |
| 7 import 'dart:async'; | |
| 8 | |
| 9 import 'package:unittest/unittest.dart'; | |
| 10 | |
| 11 import '../reflective_tests.dart'; | |
| 12 import 'integration_tests.dart'; | |
| 13 | |
| 14 /** | |
| 15 * Verify that the server's input and output streams are asynchronous by | |
| 16 * attempting to flood its input buffer with commands without listening to | |
| 17 * its output buffer for responses. The server should continue to train its | |
| 18 * input buffer even though its output buffer is full. | |
| 19 * | |
| 20 * Once enough commands have been sent, we begin reading from the server's | |
| 21 * output buffer, and verify that it responds to the last command. | |
| 22 */ | |
| 23 @ReflectiveTestCase() | |
| 24 class AsynchronyIntegrationTest { | |
| 25 /** | |
| 26 * Connection to the analysis server. | |
| 27 */ | |
| 28 final Server server = new Server(); | |
| 29 | |
| 30 /** | |
| 31 * Number of messages to queue up before listening for responses. | |
| 32 */ | |
| 33 static const MESSAGE_COUNT = 10000; | |
| 34 | |
| 35 Future setUp() { | |
| 36 return server.start(); | |
| 37 } | |
| 38 | |
| 39 test_asynchrony() { | |
| 40 // Send MESSAGE_COUNT messages to the server without listening for | |
| 41 // responses. | |
| 42 Future lastMessageResult; | |
| 43 for (int i = 0; i < MESSAGE_COUNT; i++) { | |
| 44 lastMessageResult = server.send('server.getVersion', null); | |
| 45 } | |
| 46 | |
| 47 // Flush the server's standard input stream to verify that it has really | |
| 48 // received them all. If the server is blocked waiting for us to read | |
| 49 // its responses, the flush will never complete. | |
| 50 return server.flushCommands().then((_) { | |
|
danrubel
2014/10/22 14:56:14
Is it possible to add a timeout for the flushComma
| |
| 51 | |
| 52 // Begin processing responses from the server. | |
| 53 server.listenToOutput((String event, params) { | |
| 54 // No notifications are expected. | |
| 55 fail('Unexpected notification: $event'); | |
| 56 }); | |
| 57 | |
| 58 // Terminate the test when the response to the last message is received. | |
| 59 lastMessageResult.then((_) { | |
| 60 server.send("server.shutdown", null).then((_) { | |
| 61 return server.exitCode; | |
| 62 }); | |
| 63 }); | |
| 64 }); | |
| 65 } | |
| 66 } | |
| 67 | |
| 68 main() { | |
| 69 runReflectiveTests(AsynchronyIntegrationTest); | |
| 70 } | |
| OLD | NEW |