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

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

Issue 787553002: invoke computeCache when priority sources change (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: merge Created 6 years 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 | Annotate | Revision Log
« no previous file with comments | « pkg/analysis_server/lib/src/services/completion/dart_completion_manager.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/src/analysis_server.dart'; 9 import 'package:analysis_server/src/analysis_server.dart';
10 import 'package:analysis_server/src/channel/channel.dart'; 10 import 'package:analysis_server/src/channel/channel.dart';
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 return pumpEventQueue(); 125 return pumpEventQueue();
126 }).then((_) { 126 }).then((_) {
127 expect(completionDomain.manager, expectedManager); 127 expect(completionDomain.manager, expectedManager);
128 expect(completionDomain.mockContext.mockStream.listenCount, 1); 128 expect(completionDomain.mockContext.mockStream.listenCount, 1);
129 expect(completionDomain.mockContext.mockStream.cancelCount, 0); 129 expect(completionDomain.mockContext.mockStream.cancelCount, 0);
130 expect(completionDomain.mockManager.computeCallCount, 2); 130 expect(completionDomain.mockManager.computeCallCount, 2);
131 }); 131 });
132 } 132 }
133 133
134 /** 134 /**
135 * Assert manager is cleared when analysis roots are set
136 */
137 test_setAnalysisRoots() {
138 sendRequest(testFile);
139 return pumpEventQueue().then((_) {
140 expect(completionDomain.manager, isNotNull);
141 request = new AnalysisSetAnalysisRootsParams([], []).toRequest('7');
142 Response response = analysisDomain.handleRequest(request);
143 expect(response, isResponseSuccess('7'));
144 return pumpEventQueue();
145 }).then((_) {
146 expect(completionDomain.manager, isNull);
147 });
148 }
149
150 /**
151 * Assert manager is NOT cleared when context NOT associated with manager chan ges. 135 * Assert manager is NOT cleared when context NOT associated with manager chan ges.
152 */ 136 */
153 test_contextsChanged_different() { 137 test_contextsChanged_different() {
154 sendRequest(testFile); 138 sendRequest(testFile);
155 CompletionManager expectedManager; 139 CompletionManager expectedManager;
156 return pumpEventQueue().then((_) { 140 return pumpEventQueue().then((_) {
157 expect(completionDomain.manager, isNotNull); 141 expect(completionDomain.manager, isNotNull);
158 expectedManager = completionDomain.manager; 142 expectedManager = completionDomain.manager;
159 completionDomain.contextsChangedRaw( 143 completionDomain.contextsChangedRaw(
160 new ContextsChangedEvent(changed: [new MockContext()])); 144 new ContextsChangedEvent(changed: [new MockContext()]));
(...skipping 12 matching lines...) Expand all
173 expect(completionDomain.manager, isNotNull); 157 expect(completionDomain.manager, isNotNull);
174 completionDomain.contextsChangedRaw( 158 completionDomain.contextsChangedRaw(
175 new ContextsChangedEvent(changed: [completionDomain.mockContext])); 159 new ContextsChangedEvent(changed: [completionDomain.mockContext]));
176 return pumpEventQueue(); 160 return pumpEventQueue();
177 }).then((_) { 161 }).then((_) {
178 expect(completionDomain.manager, isNull); 162 expect(completionDomain.manager, isNull);
179 }); 163 });
180 } 164 }
181 165
182 /** 166 /**
167 * Assert manager is cleared when analysis roots are set
168 */
169 test_setAnalysisRoots() {
170 sendRequest(testFile);
171 return pumpEventQueue().then((_) {
172 expect(completionDomain.manager, isNotNull);
173 request = new AnalysisSetAnalysisRootsParams([], []).toRequest('7');
174 Response response = analysisDomain.handleRequest(request);
175 expect(response, isResponseSuccess('7'));
176 return pumpEventQueue();
177 }).then((_) {
178 expect(completionDomain.manager, isNull);
179 });
180 }
181
182 /**
183 * Assert manager is cleared when source NOT associated with manager is change d. 183 * Assert manager is cleared when source NOT associated with manager is change d.
184 */ 184 */
185 test_sourcesChanged_different_source_changed() { 185 test_sourcesChanged_different_source_changed() {
186 sendRequest(testFile); 186 sendRequest(testFile);
187 return pumpEventQueue().then((_) { 187 return pumpEventQueue().then((_) {
188 expect(completionDomain.manager, isNotNull); 188 expect(completionDomain.manager, isNotNull);
189 ChangeSet changeSet = new ChangeSet(); 189 ChangeSet changeSet = new ChangeSet();
190 changeSet.changedSource(server.getSource(testFile2)); 190 changeSet.changedSource(server.getSource(testFile2));
191 completionDomain.sourcesChanged(new SourcesChangedEvent(changeSet)); 191 completionDomain.sourcesChanged(new SourcesChangedEvent(changeSet));
192 expect(completionDomain.manager, isNull); 192 expect(completionDomain.manager, isNull);
(...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after
436 final Source source; 436 final Source source;
437 final SearchEngine searchEngine; 437 final SearchEngine searchEngine;
438 CompletionCache cache; 438 CompletionCache cache;
439 StreamController<CompletionResult> controller; 439 StreamController<CompletionResult> controller;
440 int computeCallCount = 0; 440 int computeCallCount = 0;
441 441
442 MockCompletionManager(this.context, this.source, this.searchEngine, 442 MockCompletionManager(this.context, this.source, this.searchEngine,
443 this.cache); 443 this.cache);
444 444
445 @override 445 @override
446 void compute(CompletionRequest request) { 446 void computeCache() {
447 // ignored
448 }
449
450 @override
451 void computeSuggestions(CompletionRequest request) {
447 ++computeCallCount; 452 ++computeCallCount;
448 CompletionResult result = new CompletionResult(0, 0, [], true); 453 CompletionResult result = new CompletionResult(0, 0, [], true);
449 controller.add(result); 454 controller.add(result);
450 } 455 }
451 456
452 @override 457 @override
453 Stream<CompletionResult> results(CompletionRequest request) { 458 Stream<CompletionResult> results(CompletionRequest request) {
454 controller = new StreamController<CompletionResult>(onListen: () { 459 controller = new StreamController<CompletionResult>(onListen: () {
455 scheduleMicrotask(() { 460 scheduleMicrotask(() {
456 compute(request); 461 computeSuggestions(request);
457 }); 462 });
458 }); 463 });
459 return controller.stream; 464 return controller.stream;
460 } 465 }
461 } 466 }
462 467
463 /** 468 /**
464 * Mock [AnaysisContext] for tracking usage of onSourcesChanged. 469 * Mock [AnaysisContext] for tracking usage of onSourcesChanged.
465 */ 470 */
466 class MockContext implements AnalysisContext { 471 class MockContext implements AnalysisContext {
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
550 555
551 void contextsChangedRaw(ContextsChangedEvent newEvent) { 556 void contextsChangedRaw(ContextsChangedEvent newEvent) {
552 super.contextsChanged(newEvent); 557 super.contextsChanged(newEvent);
553 } 558 }
554 559
555 CompletionManager createCompletionManager(AnalysisContext context, 560 CompletionManager createCompletionManager(AnalysisContext context,
556 Source source, SearchEngine searchEngine, CompletionCache cache) { 561 Source source, SearchEngine searchEngine, CompletionCache cache) {
557 return new MockCompletionManager(mockContext, source, searchEngine, cache); 562 return new MockCompletionManager(mockContext, source, searchEngine, cache);
558 } 563 }
559 } 564 }
OLDNEW
« no previous file with comments | « pkg/analysis_server/lib/src/services/completion/dart_completion_manager.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698