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

Side by Side Diff: pkg/analysis_server/test/domain_completion_test.dart

Issue 1223413003: Hook for overriding the ContextManager and some code clean-up (with more to follow) (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Created 5 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 unified diff | Download patch
OLDNEW
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.domain.completion; 5 library test.domain.completion;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 8
9 import 'package:analysis_server/completion/completion_core.dart' 9 import 'package:analysis_server/completion/completion_core.dart'
10 show CompletionRequest; 10 show CompletionRequest;
11 import 'package:analysis_server/src/analysis_server.dart'; 11 import 'package:analysis_server/src/analysis_server.dart';
12 import 'package:analysis_server/src/channel/channel.dart'; 12 import 'package:analysis_server/src/channel/channel.dart';
13 import 'package:analysis_server/src/constants.dart'; 13 import 'package:analysis_server/src/constants.dart';
14 import 'package:analysis_server/src/context_manager.dart';
14 import 'package:analysis_server/src/domain_analysis.dart'; 15 import 'package:analysis_server/src/domain_analysis.dart';
15 import 'package:analysis_server/src/domain_completion.dart'; 16 import 'package:analysis_server/src/domain_completion.dart';
16 import 'package:analysis_server/src/plugin/server_plugin.dart'; 17 import 'package:analysis_server/src/plugin/server_plugin.dart';
17 import 'package:analysis_server/src/protocol.dart'; 18 import 'package:analysis_server/src/protocol.dart';
18 import 'package:analysis_server/src/services/completion/completion_manager.dart' ; 19 import 'package:analysis_server/src/services/completion/completion_manager.dart' ;
19 import 'package:analysis_server/src/services/completion/dart_completion_manager. dart'; 20 import 'package:analysis_server/src/services/completion/dart_completion_manager. dart';
20 import 'package:analysis_server/src/services/index/index.dart' show Index; 21 import 'package:analysis_server/src/services/index/index.dart' show Index;
21 import 'package:analysis_server/src/services/index/local_memory_index.dart'; 22 import 'package:analysis_server/src/services/index/local_memory_index.dart';
22 import 'package:analysis_server/src/services/search/search_engine.dart'; 23 import 'package:analysis_server/src/services/search/search_engine.dart';
23 import 'package:analysis_server/src/source/optimizing_pub_package_map_provider.d art'; 24 import 'package:analysis_server/src/source/optimizing_pub_package_map_provider.d art';
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 /** 149 /**
149 * Assert manager is NOT cleared when context NOT associated with manager chan ges. 150 * Assert manager is NOT cleared when context NOT associated with manager chan ges.
150 */ 151 */
151 test_contextsChanged_different() { 152 test_contextsChanged_different() {
152 sendRequest(testFile); 153 sendRequest(testFile);
153 CompletionManager expectedManager; 154 CompletionManager expectedManager;
154 return pumpEventQueue().then((_) { 155 return pumpEventQueue().then((_) {
155 expect(completionDomain.manager, isNotNull); 156 expect(completionDomain.manager, isNotNull);
156 expectedManager = completionDomain.manager; 157 expectedManager = completionDomain.manager;
157 completionDomain.contextsChangedRaw( 158 completionDomain.contextsChangedRaw(
158 new ContextsChangedEvent(changed: [new MockContext()])); 159 new ContextsChangedEventImpl(changed: [new MockContext()]));
159 return pumpEventQueue(); 160 return pumpEventQueue();
160 }).then((_) { 161 }).then((_) {
161 expect(completionDomain.manager, expectedManager); 162 expect(completionDomain.manager, expectedManager);
162 }); 163 });
163 } 164 }
164 165
165 /** 166 /**
166 * Assert manager is cleared when context associated with manager changes. 167 * Assert manager is cleared when context associated with manager changes.
167 */ 168 */
168 test_contextsChanged_same() { 169 test_contextsChanged_same() {
169 sendRequest(testFile); 170 sendRequest(testFile);
170 return pumpEventQueue().then((_) { 171 return pumpEventQueue().then((_) {
171 expect(completionDomain.manager, isNotNull); 172 expect(completionDomain.manager, isNotNull);
172 completionDomain.contextsChangedRaw( 173 completionDomain.contextsChangedRaw(new ContextsChangedEventImpl(
173 new ContextsChangedEvent(changed: [completionDomain.mockContext])); 174 changed: [completionDomain.mockContext]));
174 return pumpEventQueue(); 175 return pumpEventQueue();
175 }).then((_) { 176 }).then((_) {
176 expect(completionDomain.manager, isNull); 177 expect(completionDomain.manager, isNull);
177 }); 178 });
178 } 179 }
179 180
180 /** 181 /**
181 * Assert manager is cleared when analysis roots are set 182 * Assert manager is cleared when analysis roots are set
182 */ 183 */
183 test_setAnalysisRoots() { 184 test_setAnalysisRoots() {
(...skipping 496 matching lines...) Expand 10 before | Expand all | Expand 10 after
680 * so that the domain handler cache management can be tested. 681 * so that the domain handler cache management can be tested.
681 */ 682 */
682 class Test_CompletionDomainHandler extends CompletionDomainHandler { 683 class Test_CompletionDomainHandler extends CompletionDomainHandler {
683 Test_CompletionDomainHandler(Test_AnalysisServer server) : super(server); 684 Test_CompletionDomainHandler(Test_AnalysisServer server) : super(server);
684 685
685 MockContext get mockContext => (server as Test_AnalysisServer).mockContext; 686 MockContext get mockContext => (server as Test_AnalysisServer).mockContext;
686 687
687 MockCompletionManager get mockManager => manager; 688 MockCompletionManager get mockManager => manager;
688 689
689 void contextsChanged(ContextsChangedEvent event) { 690 void contextsChanged(ContextsChangedEvent event) {
690 contextsChangedRaw(new ContextsChangedEvent( 691 contextsChangedRaw(new ContextsChangedEventImpl(
691 added: event.added.length > 0 ? [mockContext] : [], 692 added: event.added.length > 0 ? [mockContext] : [],
692 changed: event.changed.length > 0 ? [mockContext] : [], 693 changed: event.changed.length > 0 ? [mockContext] : [],
693 removed: event.removed.length > 0 ? [mockContext] : [])); 694 removed: event.removed.length > 0 ? [mockContext] : []));
694 } 695 }
695 696
696 void contextsChangedRaw(ContextsChangedEvent newEvent) { 697 void contextsChangedRaw(ContextsChangedEvent newEvent) {
697 super.contextsChanged(newEvent); 698 super.contextsChanged(newEvent);
698 } 699 }
699 700
700 CompletionManager createCompletionManager( 701 CompletionManager createCompletionManager(
(...skipping 18 matching lines...) Expand all
719 } 720 }
720 '''); 721 ''');
721 await waitForTasksFinished(); 722 await waitForTasksFinished();
722 Request request = 723 Request request =
723 new CompletionGetSuggestionsParams(testFile, 0).toRequest('0'); 724 new CompletionGetSuggestionsParams(testFile, 0).toRequest('0');
724 Response response = handler.handleRequest(request); 725 Response response = handler.handleRequest(request);
725 expect(response.error, isNotNull); 726 expect(response.error, isNotNull);
726 expect(response.error.code, RequestErrorCode.NO_INDEX_GENERATED); 727 expect(response.error.code, RequestErrorCode.NO_INDEX_GENERATED);
727 } 728 }
728 } 729 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698