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

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

Issue 1266923004: More fixes for failures on the Windows bot (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Created 5 years, 4 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, CompletionResult; 10 show CompletionRequest, CompletionResult;
(...skipping 16 matching lines...) Expand all
27 import 'package:analyzer/src/generated/engine.dart'; 27 import 'package:analyzer/src/generated/engine.dart';
28 import 'package:analyzer/src/generated/sdk.dart'; 28 import 'package:analyzer/src/generated/sdk.dart';
29 import 'package:analyzer/src/generated/source.dart'; 29 import 'package:analyzer/src/generated/source.dart';
30 import 'package:plugin/manager.dart'; 30 import 'package:plugin/manager.dart';
31 import 'package:test_reflective_loader/test_reflective_loader.dart'; 31 import 'package:test_reflective_loader/test_reflective_loader.dart';
32 import 'package:unittest/unittest.dart'; 32 import 'package:unittest/unittest.dart';
33 33
34 import 'analysis_abstract.dart'; 34 import 'analysis_abstract.dart';
35 import 'mock_sdk.dart'; 35 import 'mock_sdk.dart';
36 import 'mocks.dart'; 36 import 'mocks.dart';
37 import 'utils.dart';
37 38
38 main() { 39 main() {
39 groupSep = ' | '; 40 initializeTestEnvironment();
40 defineReflectiveTests(CompletionManagerTest); 41 defineReflectiveTests(CompletionManagerTest);
41 defineReflectiveTests(CompletionTest); 42 defineReflectiveTests(CompletionTest);
42 defineReflectiveTests(_NoSearchEngine); 43 defineReflectiveTests(_NoSearchEngine);
43 } 44 }
44 45
45 @reflectiveTest 46 @reflectiveTest
46 class CompletionManagerTest extends AbstractAnalysisTest { 47 class CompletionManagerTest extends AbstractAnalysisTest {
47 AnalysisDomainHandler analysisDomain; 48 AnalysisDomainHandler analysisDomain;
48 Test_CompletionDomainHandler completionDomain; 49 Test_CompletionDomainHandler completionDomain;
49 Request request; 50 Request request;
50 int requestCount = 0; 51 int requestCount = 0;
51 String testFile2 = '/project/bin/test2.dart'; 52 String testFile2 = '/project/bin/test2.dart';
52 53
53 AnalysisServer createAnalysisServer(Index index) { 54 AnalysisServer createAnalysisServer(Index index) {
54 ExtensionManager manager = new ExtensionManager(); 55 ExtensionManager manager = new ExtensionManager();
55 ServerPlugin serverPlugin = new ServerPlugin(); 56 ServerPlugin serverPlugin = new ServerPlugin();
56 manager.processPlugins([serverPlugin]); 57 manager.processPlugins([serverPlugin]);
57 return new Test_AnalysisServer(super.serverChannel, super.resourceProvider, 58 return new Test_AnalysisServer(
58 super.packageMapProvider, index, serverPlugin, 59 super.serverChannel,
59 new AnalysisServerOptions(), new MockSdk(), 60 super.resourceProvider,
61 super.packageMapProvider,
62 index,
63 serverPlugin,
64 new AnalysisServerOptions(),
65 new MockSdk(),
60 InstrumentationService.NULL_SERVICE); 66 InstrumentationService.NULL_SERVICE);
61 } 67 }
62 68
63 @override 69 @override
64 Index createIndex() { 70 Index createIndex() {
65 return createLocalMemoryIndex(); 71 return createLocalMemoryIndex();
66 } 72 }
67 73
68 void sendRequest(String path) { 74 void sendRequest(String path) {
69 String id = (++requestCount).toString(); 75 String id = (++requestCount).toString();
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after
270 return super.addTestFile(content); 276 return super.addTestFile(content);
271 } 277 }
272 expect(completionOffset, isNot(equals(-1)), reason: 'missing ^'); 278 expect(completionOffset, isNot(equals(-1)), reason: 'missing ^');
273 int nextOffset = content.indexOf('^', completionOffset + 1); 279 int nextOffset = content.indexOf('^', completionOffset + 1);
274 expect(nextOffset, equals(-1), reason: 'too many ^'); 280 expect(nextOffset, equals(-1), reason: 'too many ^');
275 return super.addTestFile(content.substring(0, completionOffset) + 281 return super.addTestFile(content.substring(0, completionOffset) +
276 content.substring(completionOffset + 1)); 282 content.substring(completionOffset + 1));
277 } 283 }
278 284
279 void assertHasResult(CompletionSuggestionKind kind, String completion, 285 void assertHasResult(CompletionSuggestionKind kind, String completion,
280 [int relevance = DART_RELEVANCE_DEFAULT, bool isDeprecated = false, 286 [int relevance = DART_RELEVANCE_DEFAULT,
287 bool isDeprecated = false,
281 bool isPotential = false]) { 288 bool isPotential = false]) {
282 var cs; 289 var cs;
283 suggestions.forEach((s) { 290 suggestions.forEach((s) {
284 if (s.completion == completion) { 291 if (s.completion == completion) {
285 if (cs == null) { 292 if (cs == null) {
286 cs = s; 293 cs = s;
287 } else { 294 } else {
288 fail('expected exactly one $completion but found > 1'); 295 fail('expected exactly one $completion but found > 1');
289 } 296 }
290 } 297 }
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after
468 '''); 475 ''');
469 return getSuggestions().then((_) { 476 return getSuggestions().then((_) {
470 expect(replacementOffset, equals(completionOffset)); 477 expect(replacementOffset, equals(completionOffset));
471 expect(replacementLength, equals(0)); 478 expect(replacementLength, equals(0));
472 assertHasResult(CompletionSuggestionKind.INVOCATION, 'm', 479 assertHasResult(CompletionSuggestionKind.INVOCATION, 'm',
473 DART_RELEVANCE_LOCAL_METHOD); 480 DART_RELEVANCE_LOCAL_METHOD);
474 }); 481 });
475 } 482 }
476 483
477 test_partFile() { 484 test_partFile() {
478 addFile('/project/bin/testA.dart', ''' 485 addFile(
486 '/project/bin/testA.dart',
487 '''
479 library libA; 488 library libA;
480 part "$testFile"; 489 part "$testFile";
481 import 'dart:html'; 490 import 'dart:html';
482 class A { } 491 class A { }
483 '''); 492 ''');
484 addTestFile(''' 493 addTestFile('''
485 part of libA; 494 part of libA;
486 main() {^}'''); 495 main() {^}''');
487 return getSuggestions().then((_) { 496 return getSuggestions().then((_) {
488 expect(replacementOffset, equals(completionOffset)); 497 expect(replacementOffset, equals(completionOffset));
489 expect(replacementLength, equals(0)); 498 expect(replacementLength, equals(0));
490 assertHasResult(CompletionSuggestionKind.INVOCATION, 'Object'); 499 assertHasResult(CompletionSuggestionKind.INVOCATION, 'Object');
491 assertHasResult(CompletionSuggestionKind.INVOCATION, 'HtmlElement'); 500 assertHasResult(CompletionSuggestionKind.INVOCATION, 'HtmlElement');
492 assertHasResult(CompletionSuggestionKind.INVOCATION, 'A'); 501 assertHasResult(CompletionSuggestionKind.INVOCATION, 'A');
493 assertNoResult('test'); 502 assertNoResult('test');
494 }); 503 });
495 } 504 }
496 505
497 test_partFile2() { 506 test_partFile2() {
498 addFile('/testA.dart', ''' 507 addFile(
508 '/testA.dart',
509 '''
499 part of libA; 510 part of libA;
500 class A { }'''); 511 class A { }''');
501 addTestFile(''' 512 addTestFile('''
502 library libA; 513 library libA;
503 part "/testA.dart"; 514 part "/testA.dart";
504 import 'dart:html'; 515 import 'dart:html';
505 main() {^} 516 main() {^}
506 '''); 517 ''');
507 return getSuggestions().then((_) { 518 return getSuggestions().then((_) {
508 expect(replacementOffset, equals(completionOffset)); 519 expect(replacementOffset, equals(completionOffset));
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
648 ++cancelCount; 659 ++cancelCount;
649 return new Future.value(true); 660 return new Future.value(true);
650 } 661 }
651 662
652 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation); 663 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation);
653 } 664 }
654 665
655 class Test_AnalysisServer extends AnalysisServer { 666 class Test_AnalysisServer extends AnalysisServer {
656 final MockContext mockContext = new MockContext(); 667 final MockContext mockContext = new MockContext();
657 668
658 Test_AnalysisServer(ServerCommunicationChannel channel, 669 Test_AnalysisServer(
670 ServerCommunicationChannel channel,
659 ResourceProvider resourceProvider, 671 ResourceProvider resourceProvider,
660 PubPackageMapProvider packageMapProvider, Index index, 672 PubPackageMapProvider packageMapProvider,
661 ServerPlugin serverPlugin, AnalysisServerOptions analysisServerOptions, 673 Index index,
662 DartSdk defaultSdk, InstrumentationService instrumentationService) 674 ServerPlugin serverPlugin,
663 : super(channel, resourceProvider, packageMapProvider, index, 675 AnalysisServerOptions analysisServerOptions,
664 serverPlugin, analysisServerOptions, defaultSdk, 676 DartSdk defaultSdk,
665 instrumentationService); 677 InstrumentationService instrumentationService)
678 : super(
679 channel,
680 resourceProvider,
681 packageMapProvider,
682 index,
683 serverPlugin,
684 analysisServerOptions,
685 defaultSdk,
686 instrumentationService);
666 687
667 @override 688 @override
668 AnalysisContext getAnalysisContext(String path) { 689 AnalysisContext getAnalysisContext(String path) {
669 return mockContext; 690 return mockContext;
670 } 691 }
671 692
672 @override 693 @override
673 ContextSourcePair getContextSourcePair(String path) { 694 ContextSourcePair getContextSourcePair(String path) {
674 ContextSourcePair pair = super.getContextSourcePair(path); 695 ContextSourcePair pair = super.getContextSourcePair(path);
675 return new ContextSourcePair(mockContext, pair.source); 696 return new ContextSourcePair(mockContext, pair.source);
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
720 } 741 }
721 '''); 742 ''');
722 await waitForTasksFinished(); 743 await waitForTasksFinished();
723 Request request = 744 Request request =
724 new CompletionGetSuggestionsParams(testFile, 0).toRequest('0'); 745 new CompletionGetSuggestionsParams(testFile, 0).toRequest('0');
725 Response response = handler.handleRequest(request); 746 Response response = handler.handleRequest(request);
726 expect(response.error, isNotNull); 747 expect(response.error, isNotNull);
727 expect(response.error.code, RequestErrorCode.NO_INDEX_GENERATED); 748 expect(response.error.code, RequestErrorCode.NO_INDEX_GENERATED);
728 } 749 }
729 } 750 }
OLDNEW
« no previous file with comments | « pkg/analysis_server/test/domain_analysis_test.dart ('k') | pkg/analysis_server/test/domain_execution_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698