| OLD | NEW |
| 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 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 | 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 library test.integration.server.domain; | 5 library test.integration.server.domain; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 | 8 |
| 9 import 'package:analysis_server/src/constants.dart'; | |
| 10 import 'package:analysis_testing/reflective_tests.dart'; | 9 import 'package:analysis_testing/reflective_tests.dart'; |
| 11 import 'package:unittest/unittest.dart'; | 10 import 'package:unittest/unittest.dart'; |
| 12 | 11 |
| 13 import 'integration_tests.dart'; | 12 import 'integration_tests.dart'; |
| 14 import 'protocol_matchers.dart'; | |
| 15 | 13 |
| 16 @ReflectiveTestCase() | 14 @ReflectiveTestCase() |
| 17 class ServerDomainIntegrationTest extends AbstractAnalysisServerIntegrationTest | 15 class ServerDomainIntegrationTest extends AbstractAnalysisServerIntegrationTest |
| 18 { | 16 { |
| 19 test_getVersion() { | 17 test_getVersion() { |
| 20 return sendServerGetVersion(); | 18 return sendServerGetVersion(); |
| 21 } | 19 } |
| 22 | 20 |
| 23 test_shutdown() { | 21 test_shutdown() { |
| 24 return sendServerShutdown().then((_) { | 22 return sendServerShutdown().then((_) { |
| 25 return new Future.delayed(new Duration(seconds: 1)).then((_) { | 23 return new Future.delayed(new Duration(seconds: 1)).then((_) { |
| 26 sendServerGetVersion().then((_) { | 24 sendServerGetVersion().then((_) { |
| 27 fail('Server still alive after server.shutdown'); | 25 fail('Server still alive after server.shutdown'); |
| 28 }); | 26 }); |
| 29 // Give the server time to respond before terminating the test. | 27 // Give the server time to respond before terminating the test. |
| 30 return new Future.delayed(new Duration(seconds: 1)); | 28 return new Future.delayed(new Duration(seconds: 1)); |
| 31 }); | 29 }); |
| 32 }); | 30 }); |
| 33 } | 31 } |
| 34 | 32 |
| 35 test_setSubscriptions() { | 33 test_setSubscriptions() { |
| 36 bool statusReceived = false; | 34 bool statusReceived = false; |
| 37 Completer analysisBegun = new Completer(); | 35 Completer analysisBegun = new Completer(); |
| 38 server.onNotification(SERVER_STATUS).listen((_) { | 36 onServerStatus.listen((_) { |
| 39 statusReceived = true; | 37 statusReceived = true; |
| 40 }); | 38 }); |
| 41 server.onNotification(ANALYSIS_ERRORS).listen((_) { | 39 onAnalysisErrors.listen((_) { |
| 42 if (!analysisBegun.isCompleted) { | 40 if (!analysisBegun.isCompleted) { |
| 43 analysisBegun.complete(); | 41 analysisBegun.complete(); |
| 44 } | 42 } |
| 45 }); | 43 }); |
| 46 return sendServerSetSubscriptions([]).then((_) { | 44 return sendServerSetSubscriptions([]).then((_) { |
| 47 String pathname = sourcePath('test.dart'); | 45 String pathname = sourcePath('test.dart'); |
| 48 writeFile(pathname, ''' | 46 writeFile(pathname, ''' |
| 49 main() { | 47 main() { |
| 50 var x; | 48 var x; |
| 51 }'''); | 49 }'''); |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 86 // TODO(paulberry): how do we test the 'server.error' notification given | 84 // TODO(paulberry): how do we test the 'server.error' notification given |
| 87 // that this notification should only occur in the event of a server bug? | 85 // that this notification should only occur in the event of a server bug? |
| 88 } | 86 } |
| 89 | 87 |
| 90 test_status() { | 88 test_status() { |
| 91 // After we kick off analysis, we should get one server.status message with | 89 // After we kick off analysis, we should get one server.status message with |
| 92 // analyzing=true, and another server.status message after that with | 90 // analyzing=true, and another server.status message after that with |
| 93 // analyzing=false. | 91 // analyzing=false. |
| 94 Completer analysisBegun = new Completer(); | 92 Completer analysisBegun = new Completer(); |
| 95 Completer analysisFinished = new Completer(); | 93 Completer analysisFinished = new Completer(); |
| 96 server.onNotification(SERVER_STATUS).listen((params) { | 94 onServerStatus.listen((params) { |
| 97 expect(params, isServerStatusParams); | |
| 98 if (params['analysis'] != null) { | 95 if (params['analysis'] != null) { |
| 99 if (params['analysis']['analyzing']) { | 96 if (params['analysis']['analyzing']) { |
| 100 expect(analysisBegun.isCompleted, isFalse); | 97 expect(analysisBegun.isCompleted, isFalse); |
| 101 analysisBegun.complete(); | 98 analysisBegun.complete(); |
| 102 } else { | 99 } else { |
| 103 expect(analysisFinished.isCompleted, isFalse); | 100 expect(analysisFinished.isCompleted, isFalse); |
| 104 analysisFinished.complete(); | 101 analysisFinished.complete(); |
| 105 } | 102 } |
| 106 } | 103 } |
| 107 }); | 104 }); |
| 108 writeFile(sourcePath('test.dart'), ''' | 105 writeFile(sourcePath('test.dart'), ''' |
| 109 main() { | 106 main() { |
| 110 var x; | 107 var x; |
| 111 }'''); | 108 }'''); |
| 112 standardAnalysisSetup(); | 109 standardAnalysisSetup(); |
| 113 expect(analysisBegun.isCompleted, isFalse); | 110 expect(analysisBegun.isCompleted, isFalse); |
| 114 expect(analysisFinished.isCompleted, isFalse); | 111 expect(analysisFinished.isCompleted, isFalse); |
| 115 return analysisBegun.future.then((_) { | 112 return analysisBegun.future.then((_) { |
| 116 expect(analysisFinished.isCompleted, isFalse); | 113 expect(analysisFinished.isCompleted, isFalse); |
| 117 return analysisFinished.future; | 114 return analysisFinished.future; |
| 118 }); | 115 }); |
| 119 } | 116 } |
| 120 } | 117 } |
| 121 | 118 |
| 122 main() { | 119 main() { |
| 123 runReflectiveTests(ServerDomainIntegrationTest); | 120 runReflectiveTests(ServerDomainIntegrationTest); |
| 124 } | 121 } |
| OLD | NEW |