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.server.domain; | |
| 6 | |
| 7 import 'dart:async'; | |
| 8 | |
| 9 import 'package:analysis_testing/reflective_tests.dart'; | |
| 10 import 'package:unittest/unittest.dart'; | |
| 11 | |
| 12 import 'integration_tests.dart'; | |
| 13 | |
| 14 @ReflectiveTestCase() | |
| 15 class ServerDomainIntegrationTest extends AbstractAnalysisServerIntegrationTest | |
| 16 { | |
| 17 test_getVersion() { | |
| 18 return server.send('server.getVersion', null).then((response) { | |
| 19 expect(response, isServerGetVersionResult); | |
| 20 }); | |
| 21 } | |
| 22 | |
| 23 fail_test_shutdown() { | |
| 24 // TODO(paulberry): fix the server so that it passes this test. | |
| 25 return server.send('server.shutdown', null).then((response) { | |
| 26 expect(response, isNull); | |
| 27 return new Future.delayed(new Duration(seconds: 1)).then((_) { | |
| 28 server.send('server.getVersion', null).then((_) { | |
| 29 fail('Server still alive after server.shutdown'); | |
| 30 }); | |
| 31 // Give the server time to respond before terminating the test. | |
| 32 return new Future.delayed(new Duration(seconds: 1)); | |
| 33 }); | |
| 34 }); | |
| 35 } | |
| 36 | |
| 37 fail_test_setSubscriptions() { | |
| 38 // TODO(paulberry): fix the server so that it passes this test. | |
| 39 bool statusReceived = false; | |
| 40 Completer analysisBegun = new Completer(); | |
| 41 server.onNotification('server.status').listen((_) { | |
| 42 statusReceived = true; | |
| 43 }); | |
| 44 server.onNotification('analysis.errors').listen((_) { | |
| 45 if (!analysisBegun.isCompleted) { | |
| 46 analysisBegun.complete(); | |
| 47 } | |
| 48 }); | |
| 49 return server_setSubscriptions([]).then((response) { | |
| 50 expect(response, isNull); | |
| 51 writeFile('test.dart', ''' | |
| 52 main() { | |
| 53 var x; | |
| 54 }'''); | |
| 55 setAnalysisRoots(['']); | |
| 56 // Analysis should begin, but no server.status notification should be | |
| 57 // received. | |
| 58 return analysisBegun.future.then((_) { | |
| 59 expect(statusReceived, isFalse); | |
| 60 return server_setSubscriptions(['STATUS']).then((_) { | |
| 61 // Tickle test.dart just in case analysis has already completed. | |
| 62 writeFile('test.dart', ''' | |
| 63 main() { | |
| 64 var y; | |
| 65 }'''); | |
| 66 // Analysis should eventually complete, and we should be notified | |
| 67 // about it. | |
| 68 return analysisFinished; | |
| 69 }); | |
| 70 }); | |
| 71 }); | |
| 72 } | |
| 73 | |
| 74 test_connected() { | |
| 75 Completer receivedConnected = new Completer(); | |
| 76 server.onNotification('server.connected').listen((params) { | |
| 77 expect(receivedConnected.isCompleted, isFalse); | |
| 78 receivedConnected.complete(); | |
| 79 expect(params, isNull); | |
| 80 }); | |
| 81 return receivedConnected.future; | |
| 82 } | |
| 83 | |
| 84 test_error() { | |
| 85 // TODO(paulberry): how do we test the 'server.error' notification given | |
| 86 // that this notification should only occur in the event of a server bug? | |
|
Brian Wilkerson
2014/07/16 21:47:32
What is it about this notification that you want t
Paul Berry
2014/07/16 23:43:25
It would be nice if we could find a way to test th
| |
| 87 } | |
| 88 | |
| 89 test_status() { | |
| 90 // TODO(paulberry): spec says that server.status is not subscribed to by | |
| 91 // default, but currently it's behaving as though it is. | |
| 92 | |
| 93 // After we kick off analysis, we should get one server.status message with | |
| 94 // analyzing=true, and another server.status message after that with | |
| 95 // analyzing=false. | |
| 96 Completer analysisBegun = new Completer(); | |
| 97 Completer analysisFinished = new Completer(); | |
| 98 server.onNotification('server.status').listen((params) { | |
| 99 expect(params, isServerStatusParams); | |
| 100 if (params['analysis'] != null) { | |
| 101 if (params['analysis']['analyzing']) { | |
| 102 expect(analysisBegun.isCompleted, isFalse); | |
| 103 analysisBegun.complete(); | |
| 104 } else { | |
| 105 expect(analysisFinished.isCompleted, isFalse); | |
| 106 analysisFinished.complete(); | |
| 107 } | |
| 108 } | |
| 109 }); | |
| 110 writeFile('test.dart', ''' | |
| 111 main() { | |
| 112 var x; | |
| 113 }'''); | |
| 114 setAnalysisRoots(['']); | |
| 115 expect(analysisBegun.isCompleted, isFalse); | |
| 116 expect(analysisFinished.isCompleted, isFalse); | |
| 117 return analysisBegun.future.then((_) { | |
| 118 expect(analysisFinished.isCompleted, isFalse); | |
| 119 return analysisFinished.future; | |
| 120 }); | |
| 121 } | |
| 122 } | |
| 123 | |
| 124 main() { | |
| 125 runReflectiveTests(ServerDomainIntegrationTest); | |
| 126 } | |
| OLD | NEW |