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

Side by Side Diff: pkg/analyzer_plugin/test/plugin/plugin_test.dart

Issue 2886343002: Register files with new drivers (issue 29641) (Closed)
Patch Set: Created 3 years, 7 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) 2017, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2017, 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:analyzer/file_system/file_system.dart'; 7 import 'package:analyzer/file_system/file_system.dart';
8 import 'package:analyzer/file_system/memory_file_system.dart'; 8 import 'package:analyzer/file_system/memory_file_system.dart';
9 import 'package:analyzer/src/dart/analysis/driver.dart'; 9 import 'package:analyzer/src/dart/analysis/driver.dart';
10 import 'package:analyzer_plugin/plugin/plugin.dart'; 10 import 'package:analyzer_plugin/plugin/plugin.dart';
11 import 'package:analyzer_plugin/protocol/protocol_common.dart'; 11 import 'package:analyzer_plugin/protocol/protocol_common.dart';
12 import 'package:analyzer_plugin/protocol/protocol_generated.dart'; 12 import 'package:analyzer_plugin/protocol/protocol_generated.dart';
13 import 'package:path/src/context.dart'; 13 import 'package:path/src/context.dart';
14 import 'package:test/test.dart'; 14 import 'package:test/test.dart';
15 import 'package:test_reflective_loader/test_reflective_loader.dart'; 15 import 'package:test_reflective_loader/test_reflective_loader.dart';
16 16
17 void main() { 17 void main() {
18 defineReflectiveTests(ServerPluginTest); 18 defineReflectiveTests(ServerPluginTest);
19 } 19 }
20 20
21 class MockAnalysisDriver extends AnalysisDriverGeneric { 21 class MockAnalysisDriver extends AnalysisDriverGeneric {
22 /**
23 * The files that have been added to this driver.
24 */
25 List<String> addedFiles = <String>[];
26
22 @override 27 @override
23 bool get hasFilesToAnalyze => false; 28 bool get hasFilesToAnalyze => false;
24 29
25 @override 30 @override
26 set priorityFiles(List<String> priorityPaths) {} 31 set priorityFiles(List<String> priorityPaths) {}
27 32
28 @override 33 @override
29 AnalysisDriverPriority get workPriority => AnalysisDriverPriority.nothing; 34 AnalysisDriverPriority get workPriority => AnalysisDriverPriority.nothing;
30 35
31 @override 36 @override
37 void addFile(String path) {
38 addedFiles.add(path);
39 }
40
41 @override
32 void dispose() {} 42 void dispose() {}
33 43
34 @override 44 @override
35 Future<Null> performWork() => new Future.value(null); 45 Future<Null> performWork() => new Future.value(null);
36 } 46 }
37 47
38 @reflectiveTest 48 @reflectiveTest
39 class ServerPluginTest { 49 class ServerPluginTest {
40 MemoryResourceProvider resourceProvider = new MemoryResourceProvider(); 50 MemoryResourceProvider resourceProvider = new MemoryResourceProvider();
41 51
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
113 var result = await plugin.handleAnalysisSetContextBuilderOptions( 123 var result = await plugin.handleAnalysisSetContextBuilderOptions(
114 new AnalysisSetContextBuilderOptionsParams( 124 new AnalysisSetContextBuilderOptionsParams(
115 new ContextBuilderOptions())); 125 new ContextBuilderOptions()));
116 expect(result, isNotNull); 126 expect(result, isNotNull);
117 } 127 }
118 128
119 test_handleAnalysisSetContextRoots() async { 129 test_handleAnalysisSetContextRoots() async {
120 var result = await plugin.handleAnalysisSetContextRoots( 130 var result = await plugin.handleAnalysisSetContextRoots(
121 new AnalysisSetContextRootsParams([contextRoot1])); 131 new AnalysisSetContextRootsParams([contextRoot1]));
122 expect(result, isNotNull); 132 expect(result, isNotNull);
123 expect(plugin.driverMap[contextRoot1], isNotNull); 133 AnalysisDriverGeneric driver = plugin.driverMap[contextRoot1];
134 expect(driver, isNotNull);
135 expect((driver as MockAnalysisDriver).addedFiles, hasLength(1));
124 } 136 }
125 137
126 test_handleAnalysisSetPriorityFiles() async { 138 test_handleAnalysisSetPriorityFiles() async {
127 await plugin.handleAnalysisSetContextRoots( 139 await plugin.handleAnalysisSetContextRoots(
128 new AnalysisSetContextRootsParams([contextRoot1])); 140 new AnalysisSetContextRootsParams([contextRoot1]));
129 141
130 var result = await plugin.handleAnalysisSetPriorityFiles( 142 var result = await plugin.handleAnalysisSetPriorityFiles(
131 new AnalysisSetPriorityFilesParams([filePath1])); 143 new AnalysisSetPriorityFilesParams([filePath1]));
132 expect(result, isNotNull); 144 expect(result, isNotNull);
133 } 145 }
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
271 AnalysisDriverGeneric createAnalysisDriver(ContextRoot contextRoot) { 283 AnalysisDriverGeneric createAnalysisDriver(ContextRoot contextRoot) {
272 return new MockAnalysisDriver(); 284 return new MockAnalysisDriver();
273 } 285 }
274 286
275 @override 287 @override
276 void sendNotificationsForSubscriptions( 288 void sendNotificationsForSubscriptions(
277 Map<String, List<AnalysisService>> subscriptions) { 289 Map<String, List<AnalysisService>> subscriptions) {
278 latestSubscriptions = subscriptions; 290 latestSubscriptions = subscriptions;
279 } 291 }
280 } 292 }
OLDNEW
« pkg/analyzer_plugin/lib/plugin/plugin.dart ('K') | « pkg/analyzer_plugin/lib/plugin/plugin.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698