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 553 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
564 }); | 564 }); |
565 }); | 565 }); |
566 return controller.stream; | 566 return controller.stream; |
567 } | 567 } |
568 } | 568 } |
569 | 569 |
570 /** | 570 /** |
571 * Mock [AnaysisContext] for tracking usage of onSourcesChanged. | 571 * Mock [AnaysisContext] for tracking usage of onSourcesChanged. |
572 */ | 572 */ |
573 class MockContext implements AnalysisContext { | 573 class MockContext implements AnalysisContext { |
| 574 static final SourceFactory DEFAULT_SOURCE_FACTORY = new SourceFactory([]); |
| 575 |
574 MockStream<SourcesChangedEvent> mockStream; | 576 MockStream<SourcesChangedEvent> mockStream; |
575 | 577 |
| 578 SourceFactory sourceFactory = DEFAULT_SOURCE_FACTORY; |
| 579 |
576 MockContext() { | 580 MockContext() { |
577 mockStream = new MockStream<SourcesChangedEvent>(); | 581 mockStream = new MockStream<SourcesChangedEvent>(); |
578 } | 582 } |
579 | 583 |
580 @override | 584 @override |
581 Stream<SourcesChangedEvent> get onSourcesChanged => mockStream; | 585 Stream<SourcesChangedEvent> get onSourcesChanged => mockStream; |
582 | 586 |
583 @override | 587 @override |
584 TimestampedData<String> getContents(Source source) { | 588 TimestampedData<String> getContents(Source source) { |
585 return source.contents; | 589 return source.contents; |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
681 handler = new CompletionDomainHandler(server); | 685 handler = new CompletionDomainHandler(server); |
682 } | 686 } |
683 | 687 |
684 test_noSearchEngine() async { | 688 test_noSearchEngine() async { |
685 addTestFile(''' | 689 addTestFile(''' |
686 main() { | 690 main() { |
687 ^ | 691 ^ |
688 } | 692 } |
689 '''); | 693 '''); |
690 await waitForTasksFinished(); | 694 await waitForTasksFinished(); |
691 Request request = | 695 Request request = |
692 new CompletionGetSuggestionsParams(testFile, 0).toRequest('0'); | 696 new CompletionGetSuggestionsParams(testFile, 0).toRequest('0'); |
693 Response response = handler.handleRequest(request); | 697 Response response = handler.handleRequest(request); |
694 expect(response.error, isNotNull); | 698 expect(response.error, isNotNull); |
695 expect(response.error.code, RequestErrorCode.NO_INDEX_GENERATED); | 699 expect(response.error.code, RequestErrorCode.NO_INDEX_GENERATED); |
696 } | 700 } |
697 } | 701 } |
OLD | NEW |