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

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

Issue 1686613002: Use different SDKs based on option settings (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Created 4 years, 10 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.analysis_server; 5 library test.analysis_server;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 8
9 import 'package:analysis_server/plugin/protocol/protocol.dart'; 9 import 'package:analysis_server/plugin/protocol/protocol.dart';
10 import 'package:analysis_server/src/analysis_server.dart'; 10 import 'package:analysis_server/src/analysis_server.dart';
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
134 channel = new MockServerChannel(); 134 channel = new MockServerChannel();
135 resourceProvider = new MemoryResourceProvider(); 135 resourceProvider = new MemoryResourceProvider();
136 packageMapProvider = new MockPackageMapProvider(); 136 packageMapProvider = new MockPackageMapProvider();
137 server = new AnalysisServer( 137 server = new AnalysisServer(
138 channel, 138 channel,
139 resourceProvider, 139 resourceProvider,
140 packageMapProvider, 140 packageMapProvider,
141 null, 141 null,
142 new ServerPlugin(), 142 new ServerPlugin(),
143 new AnalysisServerOptions(), 143 new AnalysisServerOptions(),
144 new MockSdk(), 144 () => new MockSdk(),
145 InstrumentationService.NULL_SERVICE, 145 InstrumentationService.NULL_SERVICE,
146 rethrowExceptions: true); 146 rethrowExceptions: true);
147 processRequiredPlugins(); 147 processRequiredPlugins();
148 } 148 }
149 149
150 Future test_contextDisposed() { 150 Future test_contextDisposed() {
151 resourceProvider.newFolder('/foo'); 151 resourceProvider.newFolder('/foo');
152 resourceProvider.newFile('/foo/bar.dart', 'library lib;'); 152 resourceProvider.newFile('/foo/bar.dart', 'library lib;');
153 server.setAnalysisRoots('0', ['/foo'], [], {}); 153 server.setAnalysisRoots('0', ['/foo'], [], {});
154 AnalysisContext context; 154 AnalysisContext context;
155 return pumpEventQueue().then((_) { 155 return pumpEventQueue()
156 context = server.getAnalysisContext('/foo/bar.dart'); 156 .then((_) {
157 server.setAnalysisRoots('1', [], [], {}); 157 context = server.getAnalysisContext('/foo/bar.dart');
158 }).then((_) => pumpEventQueue()).then((_) { 158 server.setAnalysisRoots('1', [], [], {});
159 expect(context.isDisposed, isTrue); 159 })
160 }); 160 .then((_) => pumpEventQueue())
161 .then((_) {
162 expect(context.isDisposed, isTrue);
163 });
161 } 164 }
162 165
163 Future test_contextsChangedEvent() { 166 Future test_contextsChangedEvent() {
164 resourceProvider.newFolder('/foo'); 167 resourceProvider.newFolder('/foo');
165 168
166 bool wasAdded = false; 169 bool wasAdded = false;
167 bool wasChanged = false; 170 bool wasChanged = false;
168 bool wasRemoved = false; 171 bool wasRemoved = false;
169 server.onContextsChanged.listen((ContextsChangedEvent event) { 172 server.onContextsChanged.listen((ContextsChangedEvent event) {
170 wasAdded = event.added.length == 1; 173 wasAdded = event.added.length == 1;
(...skipping 351 matching lines...) Expand 10 before | Expand all | Expand 10 after
522 await pumpEventQueue(); 525 await pumpEventQueue();
523 // the file has an overlay, so the file-system change was ignored 526 // the file has an overlay, so the file-system change was ignored
524 expect(channel.notificationsReceived.any((notification) { 527 expect(channel.notificationsReceived.any((notification) {
525 return notification.event == SERVER_STATUS; 528 return notification.event == SERVER_STATUS;
526 }), isFalse); 529 }), isFalse);
527 } 530 }
528 531
529 void _assertContextOfFolder( 532 void _assertContextOfFolder(
530 AnalysisContext context, String expectedFolderPath) { 533 AnalysisContext context, String expectedFolderPath) {
531 Folder expectedFolder = resourceProvider.newFolder(expectedFolderPath); 534 Folder expectedFolder = resourceProvider.newFolder(expectedFolderPath);
532 ContextInfo expectedContextInfo = (server.contextManager 535 ContextInfo expectedContextInfo =
533 as ContextManagerImpl).getContextInfoFor(expectedFolder); 536 (server.contextManager as ContextManagerImpl)
537 .getContextInfoFor(expectedFolder);
534 expect(expectedContextInfo, isNotNull); 538 expect(expectedContextInfo, isNotNull);
535 expect(context, same(expectedContextInfo.context)); 539 expect(context, same(expectedContextInfo.context));
536 } 540 }
537 541
538 void _configureSourceFactory(AnalysisContext context) { 542 void _configureSourceFactory(AnalysisContext context) {
539 var resourceUriResolver = new ResourceUriResolver(resourceProvider); 543 var resourceUriResolver = new ResourceUriResolver(resourceProvider);
540 var packageUriResolver = new PackageMapUriResolver( 544 var packageUriResolver = new PackageMapUriResolver(
541 resourceProvider, packageMapProvider.packageMap); 545 resourceProvider, packageMapProvider.packageMap);
542 context.sourceFactory = 546 context.sourceFactory =
543 new SourceFactory([packageUriResolver, resourceUriResolver]); 547 new SourceFactory([packageUriResolver, resourceUriResolver]);
(...skipping 21 matching lines...) Expand all
565 _MockServerOperation(this.context); 569 _MockServerOperation(this.context);
566 570
567 @override 571 @override
568 ServerOperationPriority get priority => ServerOperationPriority.ANALYSIS; 572 ServerOperationPriority get priority => ServerOperationPriority.ANALYSIS;
569 573
570 @override 574 @override
571 void perform(AnalysisServer server) { 575 void perform(AnalysisServer server) {
572 isComplete = true; 576 isComplete = true;
573 } 577 }
574 } 578 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698