| 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.services.completion.suggestion; | 5 library test.services.completion.suggestion; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 | 8 |
| 9 import 'package:analysis_server/plugin/protocol/protocol.dart'; | 9 import 'package:analysis_server/plugin/protocol/protocol.dart'; |
| 10 import 'package:analysis_server/src/analysis_server.dart'; | 10 import 'package:analysis_server/src/analysis_server.dart'; |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 77 | 77 |
| 78 @override | 78 @override |
| 79 void tearDown() { | 79 void tearDown() { |
| 80 _continuePerformingAnalysis = false; | 80 _continuePerformingAnalysis = false; |
| 81 } | 81 } |
| 82 | 82 |
| 83 test_compute_fastAndFull() { | 83 test_compute_fastAndFull() { |
| 84 contributor1 = new MockCompletionContributor(suggestion1, null); | 84 contributor1 = new MockCompletionContributor(suggestion1, null); |
| 85 contributor2 = new MockCompletionContributor(null, suggestion2); | 85 contributor2 = new MockCompletionContributor(null, suggestion2); |
| 86 manager.contributors = [contributor1, contributor2]; | 86 manager.contributors = [contributor1, contributor2]; |
| 87 manager.newContributors = []; |
| 87 int count = 0; | 88 int count = 0; |
| 88 bool done = false; | 89 bool done = false; |
| 89 AnalysisServer server = new AnalysisServerMock(searchEngine: searchEngine); | 90 AnalysisServer server = new AnalysisServerMock(searchEngine: searchEngine); |
| 90 CompletionRequest completionRequest = | 91 CompletionRequest completionRequest = |
| 91 new CompletionRequestImpl(server, context, source, 0); | 92 new CompletionRequestImpl(server, context, source, 0); |
| 92 manager.results(completionRequest).listen((CompletionResult r) { | 93 manager.results(completionRequest).listen((CompletionResult r) { |
| 93 bool isLast = r is CompletionResultImpl ? r.isLast : true; | 94 bool isLast = r is CompletionResultImpl ? r.isLast : true; |
| 94 switch (++count) { | 95 switch (++count) { |
| 95 case 1: | 96 case 1: |
| 96 contributor1.assertCalls(context, source, 0, searchEngine); | 97 contributor1.assertCalls(context, source, 0, searchEngine); |
| (...skipping 18 matching lines...) Expand all Loading... |
| 115 }); | 116 }); |
| 116 return pumpEventQueue(250).then((_) { | 117 return pumpEventQueue(250).then((_) { |
| 117 expect(done, isTrue); | 118 expect(done, isTrue); |
| 118 }); | 119 }); |
| 119 } | 120 } |
| 120 | 121 |
| 121 test_compute_fastOnly() { | 122 test_compute_fastOnly() { |
| 122 contributor1 = new MockCompletionContributor(suggestion1, null); | 123 contributor1 = new MockCompletionContributor(suggestion1, null); |
| 123 contributor2 = new MockCompletionContributor(suggestion2, null); | 124 contributor2 = new MockCompletionContributor(suggestion2, null); |
| 124 manager.contributors = [contributor1, contributor2]; | 125 manager.contributors = [contributor1, contributor2]; |
| 126 manager.newContributors = []; |
| 125 int count = 0; | 127 int count = 0; |
| 126 bool done = false; | 128 bool done = false; |
| 127 AnalysisServer server = new AnalysisServerMock(searchEngine: searchEngine); | 129 AnalysisServer server = new AnalysisServerMock(searchEngine: searchEngine); |
| 128 CompletionRequest completionRequest = | 130 CompletionRequest completionRequest = |
| 129 new CompletionRequestImpl(server, context, source, 0); | 131 new CompletionRequestImpl(server, context, source, 0); |
| 130 manager.results(completionRequest).listen((CompletionResult r) { | 132 manager.results(completionRequest).listen((CompletionResult r) { |
| 131 bool isLast = r is CompletionResultImpl ? r.isLast : true; | 133 bool isLast = r is CompletionResultImpl ? r.isLast : true; |
| 132 switch (++count) { | 134 switch (++count) { |
| 133 case 1: | 135 case 1: |
| 134 contributor1.assertCalls(context, source, 0, searchEngine); | 136 contributor1.assertCalls(context, source, 0, searchEngine); |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 198 @override | 200 @override |
| 199 Future<bool> computeFull(DartCompletionRequest request) { | 201 Future<bool> computeFull(DartCompletionRequest request) { |
| 200 this.request = request; | 202 this.request = request; |
| 201 fullCount++; | 203 fullCount++; |
| 202 if (fullSuggestion != null) { | 204 if (fullSuggestion != null) { |
| 203 request.addSuggestion(fullSuggestion); | 205 request.addSuggestion(fullSuggestion); |
| 204 } | 206 } |
| 205 return new Future.value(fullSuggestion != null); | 207 return new Future.value(fullSuggestion != null); |
| 206 } | 208 } |
| 207 } | 209 } |
| OLD | NEW |