| 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.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 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 185 }); | 185 }); |
| 186 } | 186 } |
| 187 | 187 |
| 188 /** | 188 /** |
| 189 * Assert manager is cleared when source NOT associated with manager is change
d. | 189 * Assert manager is cleared when source NOT associated with manager is change
d. |
| 190 */ | 190 */ |
| 191 test_sourcesChanged_different_source_changed() { | 191 test_sourcesChanged_different_source_changed() { |
| 192 sendRequest(testFile); | 192 sendRequest(testFile); |
| 193 return pumpEventQueue().then((_) { | 193 return pumpEventQueue().then((_) { |
| 194 expect(completionDomain.manager, isNotNull); | 194 expect(completionDomain.manager, isNotNull); |
| 195 ContextSourcePair contextSource = server.getContextSourcePair(testFile2); |
| 195 ChangeSet changeSet = new ChangeSet(); | 196 ChangeSet changeSet = new ChangeSet(); |
| 196 changeSet.changedSource(server.getSource(testFile2)); | 197 changeSet.changedSource(contextSource.source); |
| 197 completionDomain.sourcesChanged(new SourcesChangedEvent(changeSet)); | 198 completionDomain.sourcesChanged(new SourcesChangedEvent(changeSet)); |
| 198 expect(completionDomain.manager, isNull); | 199 expect(completionDomain.manager, isNull); |
| 199 }); | 200 }); |
| 200 } | 201 } |
| 201 | 202 |
| 202 /** | 203 /** |
| 203 * Assert manager is NOT cleared when source associated with manager is change
d. | 204 * Assert manager is NOT cleared when source associated with manager is change
d. |
| 204 */ | 205 */ |
| 205 test_sourcesChanged_same_source_changed() { | 206 test_sourcesChanged_same_source_changed() { |
| 206 sendRequest(testFile); | 207 sendRequest(testFile); |
| (...skipping 403 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 610 class Test_AnalysisServer extends AnalysisServer { | 611 class Test_AnalysisServer extends AnalysisServer { |
| 611 final MockContext mockContext = new MockContext(); | 612 final MockContext mockContext = new MockContext(); |
| 612 | 613 |
| 613 Test_AnalysisServer(ServerCommunicationChannel channel, | 614 Test_AnalysisServer(ServerCommunicationChannel channel, |
| 614 ResourceProvider resourceProvider, PackageMapProvider packageMapProvider, | 615 ResourceProvider resourceProvider, PackageMapProvider packageMapProvider, |
| 615 Index index, AnalysisServerOptions analysisServerOptions, | 616 Index index, AnalysisServerOptions analysisServerOptions, |
| 616 DartSdk defaultSdk, InstrumentationService instrumentationService) | 617 DartSdk defaultSdk, InstrumentationService instrumentationService) |
| 617 : super(channel, resourceProvider, packageMapProvider, index, | 618 : super(channel, resourceProvider, packageMapProvider, index, |
| 618 analysisServerOptions, defaultSdk, instrumentationService); | 619 analysisServerOptions, defaultSdk, instrumentationService); |
| 619 | 620 |
| 621 @override |
| 620 AnalysisContext getAnalysisContext(String path) { | 622 AnalysisContext getAnalysisContext(String path) { |
| 621 return mockContext; | 623 return mockContext; |
| 622 } | 624 } |
| 625 |
| 626 @override |
| 627 ContextSourcePair getContextSourcePair(String path) { |
| 628 ContextSourcePair pair = super.getContextSourcePair(path); |
| 629 return new ContextSourcePair(mockContext, pair.source); |
| 630 } |
| 623 } | 631 } |
| 624 | 632 |
| 625 /** | 633 /** |
| 626 * A [CompletionDomainHandler] subclass that returns a mock completion manager | 634 * A [CompletionDomainHandler] subclass that returns a mock completion manager |
| 627 * so that the domain handler cache management can be tested. | 635 * so that the domain handler cache management can be tested. |
| 628 */ | 636 */ |
| 629 class Test_CompletionDomainHandler extends CompletionDomainHandler { | 637 class Test_CompletionDomainHandler extends CompletionDomainHandler { |
| 630 Test_CompletionDomainHandler(Test_AnalysisServer server) : super(server); | 638 Test_CompletionDomainHandler(Test_AnalysisServer server) : super(server); |
| 631 | 639 |
| 632 MockContext get mockContext => (server as Test_AnalysisServer).mockContext; | 640 MockContext get mockContext => (server as Test_AnalysisServer).mockContext; |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 666 } | 674 } |
| 667 '''); | 675 '''); |
| 668 await waitForTasksFinished(); | 676 await waitForTasksFinished(); |
| 669 Request request = | 677 Request request = |
| 670 new CompletionGetSuggestionsParams(testFile, 0).toRequest('0'); | 678 new CompletionGetSuggestionsParams(testFile, 0).toRequest('0'); |
| 671 Response response = handler.handleRequest(request); | 679 Response response = handler.handleRequest(request); |
| 672 expect(response.error, isNotNull); | 680 expect(response.error, isNotNull); |
| 673 expect(response.error.code, RequestErrorCode.NO_INDEX_GENERATED); | 681 expect(response.error.code, RequestErrorCode.NO_INDEX_GENERATED); |
| 674 } | 682 } |
| 675 } | 683 } |
| OLD | NEW |