Chromium Code Reviews| Index: pkg/analysis_server/test/integration/server_domain_inttest.dart |
| diff --git a/pkg/analysis_server/test/integration/server_domain_inttest.dart b/pkg/analysis_server/test/integration/server_domain_inttest.dart |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..d86db0679e36201001df69f79ca9f5c5923b96d0 |
| --- /dev/null |
| +++ b/pkg/analysis_server/test/integration/server_domain_inttest.dart |
| @@ -0,0 +1,126 @@ |
| +// Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file |
| +// for details. All rights reserved. Use of this source code is governed by a |
| +// BSD-style license that can be found in the LICENSE file. |
| + |
| +library test.integration.server.domain; |
| + |
| +import 'dart:async'; |
| + |
| +import 'package:analysis_testing/reflective_tests.dart'; |
| +import 'package:unittest/unittest.dart'; |
| + |
| +import 'integration_tests.dart'; |
| + |
| +@ReflectiveTestCase() |
| +class ServerDomainIntegrationTest extends AbstractAnalysisServerIntegrationTest |
| + { |
| + test_getVersion() { |
| + return server.send('server.getVersion', null).then((response) { |
| + expect(response, isServerGetVersionResult); |
| + }); |
| + } |
| + |
| + fail_test_shutdown() { |
| + // TODO(paulberry): fix the server so that it passes this test. |
| + return server.send('server.shutdown', null).then((response) { |
| + expect(response, isNull); |
| + return new Future.delayed(new Duration(seconds: 1)).then((_) { |
| + server.send('server.getVersion', null).then((_) { |
| + fail('Server still alive after server.shutdown'); |
| + }); |
| + // Give the server time to respond before terminating the test. |
| + return new Future.delayed(new Duration(seconds: 1)); |
| + }); |
| + }); |
| + } |
| + |
| + fail_test_setSubscriptions() { |
| + // TODO(paulberry): fix the server so that it passes this test. |
| + bool statusReceived = false; |
| + Completer analysisBegun = new Completer(); |
| + server.onNotification('server.status').listen((_) { |
| + statusReceived = true; |
| + }); |
| + server.onNotification('analysis.errors').listen((_) { |
| + if (!analysisBegun.isCompleted) { |
| + analysisBegun.complete(); |
| + } |
| + }); |
| + return server_setSubscriptions([]).then((response) { |
| + expect(response, isNull); |
| + writeFile('test.dart', ''' |
| +main() { |
| + var x; |
| +}'''); |
| + setAnalysisRoots(['']); |
| + // Analysis should begin, but no server.status notification should be |
| + // received. |
| + return analysisBegun.future.then((_) { |
| + expect(statusReceived, isFalse); |
| + return server_setSubscriptions(['STATUS']).then((_) { |
| + // Tickle test.dart just in case analysis has already completed. |
| + writeFile('test.dart', ''' |
| +main() { |
| + var y; |
| +}'''); |
| + // Analysis should eventually complete, and we should be notified |
| + // about it. |
| + return analysisFinished; |
| + }); |
| + }); |
| + }); |
| + } |
| + |
| + test_connected() { |
| + Completer receivedConnected = new Completer(); |
| + server.onNotification('server.connected').listen((params) { |
| + expect(receivedConnected.isCompleted, isFalse); |
| + receivedConnected.complete(); |
| + expect(params, isNull); |
| + }); |
| + return receivedConnected.future; |
| + } |
| + |
| + test_error() { |
| + // TODO(paulberry): how do we test the 'server.error' notification given |
| + // 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
|
| + } |
| + |
| + test_status() { |
| + // TODO(paulberry): spec says that server.status is not subscribed to by |
| + // default, but currently it's behaving as though it is. |
| + |
| + // After we kick off analysis, we should get one server.status message with |
| + // analyzing=true, and another server.status message after that with |
| + // analyzing=false. |
| + Completer analysisBegun = new Completer(); |
| + Completer analysisFinished = new Completer(); |
| + server.onNotification('server.status').listen((params) { |
| + expect(params, isServerStatusParams); |
| + if (params['analysis'] != null) { |
| + if (params['analysis']['analyzing']) { |
| + expect(analysisBegun.isCompleted, isFalse); |
| + analysisBegun.complete(); |
| + } else { |
| + expect(analysisFinished.isCompleted, isFalse); |
| + analysisFinished.complete(); |
| + } |
| + } |
| + }); |
| + writeFile('test.dart', ''' |
| +main() { |
| + var x; |
| +}'''); |
| + setAnalysisRoots(['']); |
| + expect(analysisBegun.isCompleted, isFalse); |
| + expect(analysisFinished.isCompleted, isFalse); |
| + return analysisBegun.future.then((_) { |
| + expect(analysisFinished.isCompleted, isFalse); |
| + return analysisFinished.future; |
| + }); |
| + } |
| +} |
| + |
| +main() { |
| + runReflectiveTests(ServerDomainIntegrationTest); |
| +} |