Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(448)

Unified Diff: pkg/analysis_server/test/integration/server_domain_inttest.dart

Issue 396383002: More integration tests for analysis server. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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);
+}
« no previous file with comments | « pkg/analysis_server/test/integration/integration_tests.dart ('k') | pkg/analysis_server/test/integration/test_all.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698