| 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'; | 9 import 'package:analysis_server/src/constants.dart'; |
| 10 import 'package:analysis_testing/reflective_tests.dart'; | 10 import 'package:analysis_testing/reflective_tests.dart'; |
| 11 import 'package:unittest/unittest.dart'; | 11 import 'package:unittest/unittest.dart'; |
| 12 | 12 |
| 13 import 'integration_tests.dart'; | 13 import 'integration_tests.dart'; |
| 14 import 'protocol_matchers.dart'; | 14 import 'protocol_matchers.dart'; |
| 15 | 15 |
| 16 @ReflectiveTestCase() | 16 @ReflectiveTestCase() |
| 17 class ServerDomainIntegrationTest extends AbstractAnalysisServerIntegrationTest | 17 class ServerDomainIntegrationTest extends AbstractAnalysisServerIntegrationTest |
| 18 { | 18 { |
| 19 test_getVersion() { | 19 test_getVersion() { |
| 20 return server.send(SERVER_GET_VERSION, null).then((response) { | 20 return sendServerGetVersion(); |
| 21 expect(response, isServerGetVersionResult); | |
| 22 }); | |
| 23 } | 21 } |
| 24 | 22 |
| 25 test_shutdown() { | 23 test_shutdown() { |
| 26 return server.send(SERVER_SHUTDOWN, null).then((response) { | 24 return sendServerShutdown().then((_) { |
| 27 expect(response, isNull); | |
| 28 return new Future.delayed(new Duration(seconds: 1)).then((_) { | 25 return new Future.delayed(new Duration(seconds: 1)).then((_) { |
| 29 server.send(SERVER_GET_VERSION, null).then((_) { | 26 sendServerGetVersion().then((_) { |
| 30 fail('Server still alive after server.shutdown'); | 27 fail('Server still alive after server.shutdown'); |
| 31 }); | 28 }); |
| 32 // Give the server time to respond before terminating the test. | 29 // Give the server time to respond before terminating the test. |
| 33 return new Future.delayed(new Duration(seconds: 1)); | 30 return new Future.delayed(new Duration(seconds: 1)); |
| 34 }); | 31 }); |
| 35 }); | 32 }); |
| 36 } | 33 } |
| 37 | 34 |
| 38 fail_test_setSubscriptions() { | 35 fail_test_setSubscriptions() { |
| 39 // TODO(paulberry): fix the server so that it passes this test. | 36 // TODO(paulberry): fix the server so that it passes this test. |
| 40 bool statusReceived = false; | 37 bool statusReceived = false; |
| 41 Completer analysisBegun = new Completer(); | 38 Completer analysisBegun = new Completer(); |
| 42 server.onNotification(SERVER_STATUS).listen((_) { | 39 server.onNotification(SERVER_STATUS).listen((_) { |
| 43 statusReceived = true; | 40 statusReceived = true; |
| 44 }); | 41 }); |
| 45 server.onNotification(ANALYSIS_ERRORS).listen((_) { | 42 server.onNotification(ANALYSIS_ERRORS).listen((_) { |
| 46 if (!analysisBegun.isCompleted) { | 43 if (!analysisBegun.isCompleted) { |
| 47 analysisBegun.complete(); | 44 analysisBegun.complete(); |
| 48 } | 45 } |
| 49 }); | 46 }); |
| 50 return server_setSubscriptions([]).then((response) { | 47 return sendServerSetSubscriptions([]).then((_) { |
| 51 expect(response, isNull); | |
| 52 String pathname = sourcePath('test.dart'); | 48 String pathname = sourcePath('test.dart'); |
| 53 writeFile(pathname, ''' | 49 writeFile(pathname, ''' |
| 54 main() { | 50 main() { |
| 55 var x; | 51 var x; |
| 56 }'''); | 52 }'''); |
| 57 standardAnalysisRoot(); | 53 standardAnalysisRoot(); |
| 58 // Analysis should begin, but no server.status notification should be | 54 // Analysis should begin, but no server.status notification should be |
| 59 // received. | 55 // received. |
| 60 return analysisBegun.future.then((_) { | 56 return analysisBegun.future.then((_) { |
| 61 expect(statusReceived, isFalse); | 57 expect(statusReceived, isFalse); |
| 62 return server_setSubscriptions(['STATUS']).then((_) { | 58 return sendServerSetSubscriptions(['STATUS']).then((_) { |
| 63 // Tickle test.dart just in case analysis has already completed. | 59 // Tickle test.dart just in case analysis has already completed. |
| 64 writeFile(pathname, ''' | 60 writeFile(pathname, ''' |
| 65 main() { | 61 main() { |
| 66 var y; | 62 var y; |
| 67 }'''); | 63 }'''); |
| 68 // Analysis should eventually complete, and we should be notified | 64 // Analysis should eventually complete, and we should be notified |
| 69 // about it. | 65 // about it. |
| 70 return analysisFinished; | 66 return analysisFinished; |
| 71 }); | 67 }); |
| 72 }); | 68 }); |
| 73 }); | 69 }); |
| 74 } | 70 } |
| 75 | 71 |
| 76 test_setSubscriptions_invalidService() { | 72 test_setSubscriptions_invalidService() { |
| 77 // TODO(paulberry): verify that if an invalid service is specified, the | 73 // TODO(paulberry): verify that if an invalid service is specified, the |
| 78 // current subscriptions are unchanged. | 74 // current subscriptions are unchanged. |
| 79 return server_setSubscriptions(['bogus']).then((_) { | 75 return sendServerSetSubscriptions(['bogus'], checkTypes: false).then((_) { |
| 80 fail('setSubscriptions should have produced an error'); | 76 fail('setSubscriptions should have produced an error'); |
| 81 }, onError: (error) { | 77 }, onError: (error) { |
| 82 // The expected error occurred. | 78 // The expected error occurred. |
| 83 }); | 79 }); |
| 84 } | 80 } |
| 85 | 81 |
| 86 test_connected() { | 82 test_connected() { |
| 87 expect(serverConnectedParams, isNull); | 83 expect(serverConnectedParams, isNull); |
| 88 } | 84 } |
| 89 | 85 |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 123 return analysisBegun.future.then((_) { | 119 return analysisBegun.future.then((_) { |
| 124 expect(analysisFinished.isCompleted, isFalse); | 120 expect(analysisFinished.isCompleted, isFalse); |
| 125 return analysisFinished.future; | 121 return analysisFinished.future; |
| 126 }); | 122 }); |
| 127 } | 123 } |
| 128 } | 124 } |
| 129 | 125 |
| 130 main() { | 126 main() { |
| 131 runReflectiveTests(ServerDomainIntegrationTest); | 127 runReflectiveTests(ServerDomainIntegrationTest); |
| 132 } | 128 } |
| OLD | NEW |