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

Side by Side Diff: pkg/analysis_server/test/src/plugin/plugin_locator_test.dart

Issue 2671773007: Add code to locate a plugin within a package (Closed)
Patch Set: Created 3 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
(Empty)
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
3 // BSD-style license that can be found in the LICENSE file.
4
5 import 'package:analysis_server/src/plugin/plugin_locator.dart';
6 import 'package:analyzer/file_system/memory_file_system.dart';
7 import 'package:test/test.dart';
8 import 'package:test_reflective_loader/test_reflective_loader.dart';
9
10 main() {
11 defineReflectiveSuite(() {
12 defineReflectiveTests(PluginLocatorTest);
13 });
14 }
15
16 @reflectiveTest
17 class PluginLocatorTest {
18 MemoryResourceProvider resourceProvider;
19 String packageRoot;
20 String pubspecPath;
21 String defaultDirPath;
22 PluginLocator locator;
23
24 void setUp() {
25 resourceProvider = new MemoryResourceProvider();
26 packageRoot = resourceProvider.convertPath('/package');
27 resourceProvider.newFolder(packageRoot);
28 locator = new PluginLocator(resourceProvider);
29 }
30
31 void test_findPlugin_inPubspec_defaultDir() {
32 String dirPath = _createPubspecWithKey();
33 _createDefaultDir();
34 expect(locator.findPlugin(packageRoot), dirPath);
35 }
36
37 void test_findPlugin_inPubspec_noDefaultDir() {
38 String dirPath = _createPubspecWithKey();
39 expect(locator.findPlugin(packageRoot), dirPath);
40 }
41
42 void test_findPlugin_noPubspec_defaultDir() {
43 _createDefaultDir();
44 expect(locator.findPlugin(packageRoot), defaultDirPath);
45 }
46
47 void test_findPlugin_noPubspec_noDefaultDir() {
48 expect(locator.findPlugin(packageRoot), isNull);
49 }
50
51 void test_findPlugin_notInPubspec_defaultDir() {
52 _createPubspecWithoutKey();
53 _createDefaultDir();
54 expect(locator.findPlugin(packageRoot), defaultDirPath);
55 }
56
57 void test_findPlugin_notInPubspec_noDefaultDir() {
58 _createPubspecWithoutKey();
59 expect(locator.findPlugin(packageRoot), isNull);
60 }
61
62 void _createDefaultDir() {
63 defaultDirPath = resourceProvider.pathContext.join(packageRoot,
64 PluginLocator.toolsFolderName, PluginLocator.defaultPluginFolderName);
65 resourceProvider.newFolder(defaultDirPath);
66 }
67
68 void _createPubspec(String content) {
69 pubspecPath = resourceProvider.pathContext
70 .join(packageRoot, PluginLocator.pubspecFileName);
71 resourceProvider.newFile(pubspecPath, content);
72 }
73
74 String _createPubspecWithKey() {
75 String nonDefaultPath =
76 resourceProvider.pathContext.join(packageRoot, 'pluginDir');
77 _createPubspec('''
78 name: test_project
79 ${PluginLocator.analysisPluginKey}: $nonDefaultPath
80 ''');
81 resourceProvider.newFolder(nonDefaultPath);
82 return nonDefaultPath;
83 }
84
85 void _createPubspecWithoutKey() {
86 _createPubspec('''
87 name: test_project
88 ''');
89 }
90 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698