| 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'; |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 return new Future.delayed(new Duration(seconds: 1)).then((_) { | 25 return new Future.delayed(new Duration(seconds: 1)).then((_) { |
| 26 sendServerGetVersion().then((_) { | 26 sendServerGetVersion().then((_) { |
| 27 fail('Server still alive after server.shutdown'); | 27 fail('Server still alive after server.shutdown'); |
| 28 }); | 28 }); |
| 29 // Give the server time to respond before terminating the test. | 29 // Give the server time to respond before terminating the test. |
| 30 return new Future.delayed(new Duration(seconds: 1)); | 30 return new Future.delayed(new Duration(seconds: 1)); |
| 31 }); | 31 }); |
| 32 }); | 32 }); |
| 33 } | 33 } |
| 34 | 34 |
| 35 fail_test_setSubscriptions() { | 35 test_setSubscriptions() { |
| 36 // TODO(paulberry): fix the server so that it passes this test. | |
| 37 bool statusReceived = false; | 36 bool statusReceived = false; |
| 38 Completer analysisBegun = new Completer(); | 37 Completer analysisBegun = new Completer(); |
| 39 server.onNotification(SERVER_STATUS).listen((_) { | 38 server.onNotification(SERVER_STATUS).listen((_) { |
| 40 statusReceived = true; | 39 statusReceived = true; |
| 41 }); | 40 }); |
| 42 server.onNotification(ANALYSIS_ERRORS).listen((_) { | 41 server.onNotification(ANALYSIS_ERRORS).listen((_) { |
| 43 if (!analysisBegun.isCompleted) { | 42 if (!analysisBegun.isCompleted) { |
| 44 analysisBegun.complete(); | 43 analysisBegun.complete(); |
| 45 } | 44 } |
| 46 }); | 45 }); |
| 47 return sendServerSetSubscriptions([]).then((_) { | 46 return sendServerSetSubscriptions([]).then((_) { |
| 48 String pathname = sourcePath('test.dart'); | 47 String pathname = sourcePath('test.dart'); |
| 49 writeFile(pathname, ''' | 48 writeFile(pathname, ''' |
| 50 main() { | 49 main() { |
| 51 var x; | 50 var x; |
| 52 }'''); | 51 }'''); |
| 53 standardAnalysisRoot(); | 52 standardAnalysisSetup(subscribeStatus: false); |
| 54 // Analysis should begin, but no server.status notification should be | 53 // Analysis should begin, but no server.status notification should be |
| 55 // received. | 54 // received. |
| 56 return analysisBegun.future.then((_) { | 55 return analysisBegun.future.then((_) { |
| 57 expect(statusReceived, isFalse); | 56 expect(statusReceived, isFalse); |
| 58 return sendServerSetSubscriptions(['STATUS']).then((_) { | 57 return sendServerSetSubscriptions(['STATUS']).then((_) { |
| 59 // Tickle test.dart just in case analysis has already completed. | 58 // Tickle test.dart just in case analysis has already completed. |
| 60 writeFile(pathname, ''' | 59 writeFile(pathname, ''' |
| 61 main() { | 60 main() { |
| 62 var y; | 61 var y; |
| 63 }'''); | 62 }'''); |
| (...skipping 18 matching lines...) Expand all Loading... |
| 82 test_connected() { | 81 test_connected() { |
| 83 expect(serverConnectedParams, isNull); | 82 expect(serverConnectedParams, isNull); |
| 84 } | 83 } |
| 85 | 84 |
| 86 test_error() { | 85 test_error() { |
| 87 // TODO(paulberry): how do we test the 'server.error' notification given | 86 // TODO(paulberry): how do we test the 'server.error' notification given |
| 88 // that this notification should only occur in the event of a server bug? | 87 // that this notification should only occur in the event of a server bug? |
| 89 } | 88 } |
| 90 | 89 |
| 91 test_status() { | 90 test_status() { |
| 92 // TODO(paulberry): spec says that server.status is not subscribed to by | |
| 93 // default, but currently it's behaving as though it is. | |
| 94 | |
| 95 // After we kick off analysis, we should get one server.status message with | 91 // After we kick off analysis, we should get one server.status message with |
| 96 // analyzing=true, and another server.status message after that with | 92 // analyzing=true, and another server.status message after that with |
| 97 // analyzing=false. | 93 // analyzing=false. |
| 98 Completer analysisBegun = new Completer(); | 94 Completer analysisBegun = new Completer(); |
| 99 Completer analysisFinished = new Completer(); | 95 Completer analysisFinished = new Completer(); |
| 100 server.onNotification(SERVER_STATUS).listen((params) { | 96 server.onNotification(SERVER_STATUS).listen((params) { |
| 101 expect(params, isServerStatusParams); | 97 expect(params, isServerStatusParams); |
| 102 if (params['analysis'] != null) { | 98 if (params['analysis'] != null) { |
| 103 if (params['analysis']['analyzing']) { | 99 if (params['analysis']['analyzing']) { |
| 104 expect(analysisBegun.isCompleted, isFalse); | 100 expect(analysisBegun.isCompleted, isFalse); |
| 105 analysisBegun.complete(); | 101 analysisBegun.complete(); |
| 106 } else { | 102 } else { |
| 107 expect(analysisFinished.isCompleted, isFalse); | 103 expect(analysisFinished.isCompleted, isFalse); |
| 108 analysisFinished.complete(); | 104 analysisFinished.complete(); |
| 109 } | 105 } |
| 110 } | 106 } |
| 111 }); | 107 }); |
| 112 writeFile(sourcePath('test.dart'), ''' | 108 writeFile(sourcePath('test.dart'), ''' |
| 113 main() { | 109 main() { |
| 114 var x; | 110 var x; |
| 115 }'''); | 111 }'''); |
| 116 standardAnalysisRoot(); | 112 standardAnalysisSetup(); |
| 117 expect(analysisBegun.isCompleted, isFalse); | 113 expect(analysisBegun.isCompleted, isFalse); |
| 118 expect(analysisFinished.isCompleted, isFalse); | 114 expect(analysisFinished.isCompleted, isFalse); |
| 119 return analysisBegun.future.then((_) { | 115 return analysisBegun.future.then((_) { |
| 120 expect(analysisFinished.isCompleted, isFalse); | 116 expect(analysisFinished.isCompleted, isFalse); |
| 121 return analysisFinished.future; | 117 return analysisFinished.future; |
| 122 }); | 118 }); |
| 123 } | 119 } |
| 124 } | 120 } |
| 125 | 121 |
| 126 main() { | 122 main() { |
| 127 runReflectiveTests(ServerDomainIntegrationTest); | 123 runReflectiveTests(ServerDomainIntegrationTest); |
| 128 } | 124 } |
| OLD | NEW |