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

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

Issue 3001413002: Remove uses of the old plugin model from the analysis server (Closed)
Patch Set: Created 3 years, 3 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 import 'dart:async'; 5 import 'dart:async';
6 6
7 import 'package:analysis_server/protocol/protocol.dart'; 7 import 'package:analysis_server/protocol/protocol.dart';
8 import 'package:analysis_server/protocol/protocol_constants.dart'; 8 import 'package:analysis_server/protocol/protocol_constants.dart';
9 import 'package:analysis_server/protocol/protocol_generated.dart'; 9 import 'package:analysis_server/protocol/protocol_generated.dart';
10 import 'package:analysis_server/src/analysis_server.dart'; 10 import 'package:analysis_server/src/analysis_server.dart';
11 import 'package:analysis_server/src/domain_analysis.dart'; 11 import 'package:analysis_server/src/domain_analysis.dart';
12 import 'package:analysis_server/src/plugin/server_plugin.dart';
13 import 'package:analyzer/file_system/memory_file_system.dart'; 12 import 'package:analyzer/file_system/memory_file_system.dart';
14 import 'package:analyzer/instrumentation/instrumentation.dart'; 13 import 'package:analyzer/instrumentation/instrumentation.dart';
15 import 'package:analyzer/src/generated/engine.dart'; 14 import 'package:analyzer/src/generated/engine.dart';
16 import 'package:analyzer/src/generated/sdk.dart'; 15 import 'package:analyzer/src/generated/sdk.dart';
17 import 'package:analyzer_plugin/protocol/protocol_common.dart'; 16 import 'package:analyzer_plugin/protocol/protocol_common.dart';
18 import 'package:analyzer_plugin/protocol/protocol_generated.dart' as plugin; 17 import 'package:analyzer_plugin/protocol/protocol_generated.dart' as plugin;
19 import 'package:plugin/manager.dart'; 18 import 'package:plugin/manager.dart';
20 import 'package:plugin/plugin.dart'; 19 import 'package:plugin/plugin.dart';
21 import 'package:test/test.dart'; 20 import 'package:test/test.dart';
22 import 'package:test_reflective_loader/test_reflective_loader.dart'; 21 import 'package:test_reflective_loader/test_reflective_loader.dart';
23 22
24 import 'analysis_abstract.dart'; 23 import 'analysis_abstract.dart';
25 import 'mock_sdk.dart'; 24 import 'mock_sdk.dart';
26 import 'mocks.dart'; 25 import 'mocks.dart';
27 26
28 main() { 27 main() {
29 defineReflectiveSuite(() { 28 defineReflectiveSuite(() {
30 defineReflectiveTests(AnalysisDomainTest); 29 defineReflectiveTests(AnalysisDomainTest);
31 defineReflectiveTests(SetSubscriptionsTest); 30 defineReflectiveTests(SetSubscriptionsTest);
32 }); 31 });
33 32
34 MockServerChannel serverChannel; 33 MockServerChannel serverChannel;
35 MemoryResourceProvider resourceProvider; 34 MemoryResourceProvider resourceProvider;
36 AnalysisServer server; 35 AnalysisServer server;
37 AnalysisDomainHandler handler; 36 AnalysisDomainHandler handler;
38 37
39 void processRequiredPlugins(ServerPlugin serverPlugin) { 38 void processRequiredPlugins() {
40 List<Plugin> plugins = <Plugin>[]; 39 List<Plugin> plugins = <Plugin>[];
41 plugins.addAll(AnalysisEngine.instance.requiredPlugins); 40 plugins.addAll(AnalysisEngine.instance.requiredPlugins);
42 plugins.add(serverPlugin);
43 41
44 ExtensionManager manager = new ExtensionManager(); 42 ExtensionManager manager = new ExtensionManager();
45 manager.processPlugins(plugins); 43 manager.processPlugins(plugins);
46 } 44 }
47 45
48 setUp(() { 46 setUp(() {
49 serverChannel = new MockServerChannel(); 47 serverChannel = new MockServerChannel();
50 resourceProvider = new MemoryResourceProvider(); 48 resourceProvider = new MemoryResourceProvider();
51 ServerPlugin serverPlugin = new ServerPlugin(); 49 processRequiredPlugins();
52 processRequiredPlugins(serverPlugin);
53 // Create an SDK in the mock file system. 50 // Create an SDK in the mock file system.
54 new MockSdk(resourceProvider: resourceProvider); 51 new MockSdk(resourceProvider: resourceProvider);
55 server = new AnalysisServer( 52 server = new AnalysisServer(
56 serverChannel, 53 serverChannel,
57 resourceProvider, 54 resourceProvider,
58 new MockPackageMapProvider(), 55 new MockPackageMapProvider(),
59 serverPlugin,
60 new AnalysisServerOptions(), 56 new AnalysisServerOptions(),
61 new DartSdkManager('/', false), 57 new DartSdkManager('/', false),
62 InstrumentationService.NULL_SERVICE); 58 InstrumentationService.NULL_SERVICE);
63 handler = new AnalysisDomainHandler(server); 59 handler = new AnalysisDomainHandler(server);
64 }); 60 });
65 61
66 group('updateContent', testUpdateContent); 62 group('updateContent', testUpdateContent);
67 63
68 group('AnalysisDomainHandler', () { 64 group('AnalysisDomainHandler', () {
69 // TODO(brianwilkerson) Re-enable these tests if we re-enable the 65 // TODO(brianwilkerson) Re-enable these tests if we re-enable the
(...skipping 354 matching lines...) Expand 10 before | Expand all | Expand 10 after
424 Map<AnalysisService, List<String>> analysisSubscriptions = {}; 420 Map<AnalysisService, List<String>> analysisSubscriptions = {};
425 421
426 Map<String, List<AnalysisError>> filesErrors = {}; 422 Map<String, List<AnalysisError>> filesErrors = {};
427 Map<String, List<HighlightRegion>> filesHighlights = {}; 423 Map<String, List<HighlightRegion>> filesHighlights = {};
428 Map<String, List<NavigationRegion>> filesNavigation = {}; 424 Map<String, List<NavigationRegion>> filesNavigation = {};
429 425
430 String testFile = '/project/bin/test.dart'; 426 String testFile = '/project/bin/test.dart';
431 String testCode; 427 String testCode;
432 428
433 AnalysisTestHelper() { 429 AnalysisTestHelper() {
434 ServerPlugin serverPlugin = new ServerPlugin(); 430 processRequiredPlugins();
435 processRequiredPlugins(serverPlugin);
436 serverChannel = new MockServerChannel(); 431 serverChannel = new MockServerChannel();
437 resourceProvider = new MemoryResourceProvider(); 432 resourceProvider = new MemoryResourceProvider();
438 // Create an SDK in the mock file system. 433 // Create an SDK in the mock file system.
439 new MockSdk(resourceProvider: resourceProvider); 434 new MockSdk(resourceProvider: resourceProvider);
440 server = new AnalysisServer( 435 server = new AnalysisServer(
441 serverChannel, 436 serverChannel,
442 resourceProvider, 437 resourceProvider,
443 new MockPackageMapProvider(), 438 new MockPackageMapProvider(),
444 serverPlugin,
445 new AnalysisServerOptions(), 439 new AnalysisServerOptions(),
446 new DartSdkManager('/', false), 440 new DartSdkManager('/', false),
447 InstrumentationService.NULL_SERVICE); 441 InstrumentationService.NULL_SERVICE);
448 handler = new AnalysisDomainHandler(server); 442 handler = new AnalysisDomainHandler(server);
449 // listen for notifications 443 // listen for notifications
450 Stream<Notification> notificationStream = 444 Stream<Notification> notificationStream =
451 serverChannel.notificationController.stream; 445 serverChannel.notificationController.stream;
452 notificationStream.listen((Notification notification) { 446 notificationStream.listen((Notification notification) {
453 if (notification.event == ANALYSIS_NOTIFICATION_ERRORS) { 447 if (notification.event == ANALYSIS_NOTIFICATION_ERRORS) {
454 var decoded = new AnalysisErrorsParams.fromNotification(notification); 448 var decoded = new AnalysisErrorsParams.fromNotification(notification);
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
590 } 584 }
591 585
592 /** 586 /**
593 * Validates that the given [request] is handled successfully. 587 * Validates that the given [request] is handled successfully.
594 */ 588 */
595 void handleSuccessfulRequest(Request request) { 589 void handleSuccessfulRequest(Request request) {
596 Response response = handler.handleRequest(request); 590 Response response = handler.handleRequest(request);
597 expect(response, isResponseSuccess('0')); 591 expect(response, isResponseSuccess('0'));
598 } 592 }
599 593
600 void processRequiredPlugins(ServerPlugin serverPlugin) { 594 void processRequiredPlugins() {
601 List<Plugin> plugins = <Plugin>[]; 595 List<Plugin> plugins = <Plugin>[];
602 plugins.addAll(AnalysisEngine.instance.requiredPlugins); 596 plugins.addAll(AnalysisEngine.instance.requiredPlugins);
603 plugins.add(serverPlugin);
604 597
605 ExtensionManager manager = new ExtensionManager(); 598 ExtensionManager manager = new ExtensionManager();
606 manager.processPlugins(plugins); 599 manager.processPlugins(plugins);
607 } 600 }
608 601
609 /** 602 /**
610 * Send an `updateContent` request for [testFile]. 603 * Send an `updateContent` request for [testFile].
611 */ 604 */
612 void sendContentChange(dynamic contentChange) { 605 void sendContentChange(dynamic contentChange) {
613 Request request = new AnalysisUpdateContentParams({testFile: contentChange}) 606 Request request = new AnalysisUpdateContentParams({testFile: contentChange})
(...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after
795 plugin.AnalysisSetSubscriptionsParams params = 788 plugin.AnalysisSetSubscriptionsParams params =
796 pluginManager.analysisSetSubscriptionsParams; 789 pluginManager.analysisSetSubscriptionsParams;
797 expect(params, isNotNull); 790 expect(params, isNotNull);
798 Map<plugin.AnalysisService, List<String>> subscriptions = 791 Map<plugin.AnalysisService, List<String>> subscriptions =
799 params.subscriptions; 792 params.subscriptions;
800 expect(subscriptions, hasLength(1)); 793 expect(subscriptions, hasLength(1));
801 List<String> files = subscriptions[plugin.AnalysisService.HIGHLIGHTS]; 794 List<String> files = subscriptions[plugin.AnalysisService.HIGHLIGHTS];
802 expect(files, [testFile]); 795 expect(files, [testFile]);
803 } 796 }
804 } 797 }
OLDNEW
« no previous file with comments | « pkg/analysis_server/test/analysis_server_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