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

Side by Side Diff: pkg/analyzer_cli/test/plugin_manager_test.dart

Issue 2559523005: Remove the AnalysisOptionsProcessor (Closed)
Patch Set: Created 4 years 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
« no previous file with comments | « pkg/analyzer_cli/test/driver_test.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file
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.
4
5 library analyzer_cli.test.plugin_manager_test;
6
7 import 'package:analyzer/src/plugin/plugin_configuration.dart';
8 import 'package:analyzer_cli/src/plugin/plugin_manager.dart';
9 import 'package:test/test.dart';
10
11 main() {
12 group('plugin manager tests', () {
13 test('combine plugin info', () {
14 PluginInfo localInfo = new PluginInfo(name: 'my_plugin');
15 PluginInfo manifestInfo = new PluginInfo(
16 className: 'MyPlugin', libraryUri: 'my_plugin/my_plugin.dart');
17
18 PluginInfo merged = combine(localInfo, manifestInfo);
19 expect(merged.name, equals('my_plugin'));
20 expect(merged.className, equals('MyPlugin'));
21 expect(merged.libraryUri, equals('my_plugin/my_plugin.dart'));
22 });
23
24 test('find manifest', () {
25 const manifestSrc = '''
26 library_uri: 'my_plugin/my_plugin.dart'
27 ''';
28 var packageMap = {'my_plugin': new Uri.file('my_plugin')};
29
30 PluginManager pm =
31 new PluginManager(packageMap, 'analyzer', (Uri uri) => manifestSrc);
32
33 PluginManifest manifest = pm.findManifest('my_plugin');
34 expect(manifest, isNotNull);
35 expect(manifest.plugin.libraryUri, equals('my_plugin/my_plugin.dart'));
36 });
37
38 final plugin1Uri = new Uri.file('my_plugin1');
39 final plugin2Uri = new Uri.file('my_plugin2');
40 final plugin3Uri = new Uri.file('my_plugin3');
41
42 const serverPluginManifest = '''
43 library_uri: 'my_plugin2/my_plugin2.dart'
44 contributes_to: analysis_server
45 ''';
46 const analyzerPluginManifest = '''
47 library_uri: 'my_plugin3/my_plugin3.dart'
48 contributes_to: analyzer
49 ''';
50
51 var packageMap = {
52 'my_plugin': plugin1Uri,
53 'my_plugin2': plugin2Uri,
54 'my_plugin3': plugin3Uri
55 };
56
57 var manifestReader = (Uri uri) {
58 if (uri == plugin2Uri) return serverPluginManifest;
59 if (uri == plugin3Uri) return analyzerPluginManifest;
60 return null;
61 };
62
63 test('get plugin details', () {
64 PluginManager pm =
65 new PluginManager(packageMap, 'analysis_server', manifestReader);
66
67 PluginInfo notFound = new PluginInfo(name: 'my_plugin1');
68 PluginInfo applicable = new PluginInfo(name: 'my_plugin2');
69 PluginInfo notApplicable = new PluginInfo(name: 'my_plugin3');
70
71 PluginConfig localConfig =
72 new PluginConfig([notFound, applicable, notApplicable]);
73
74 Iterable<PluginDetails> details = pm.getPluginDetails(localConfig);
75 expect(details, hasLength(3));
76
77 List<PluginDetails> plugins = sortByName(details);
78
79 expect(plugins[0].plugin.name, equals('my_plugin1'));
80 expect(plugins[0].status, equals(PluginStatus.NotFound));
81 expect(plugins[1].plugin.name, equals('my_plugin2'));
82 expect(
83 plugins[1].plugin.libraryUri, equals('my_plugin2/my_plugin2.dart'));
84 expect(plugins[1].status, equals(PluginStatus.Applicable));
85 expect(plugins[2].plugin.name, equals('my_plugin3'));
86 expect(plugins[2].status, equals(PluginStatus.NotApplicable));
87 });
88 });
89 }
90
91 List<PluginDetails> sortByName(Iterable<PluginDetails> details) =>
92 details.toList()
93 ..sort((p1, p2) => p1.plugin.name.compareTo(p2.plugin.name));
OLDNEW
« no previous file with comments | « pkg/analyzer_cli/test/driver_test.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698