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

Unified Diff: pkg/analysis_server/test/src/plugin/plugin_manager_test.dart

Issue 2842013003: Add support for watch events and error notifications (Closed)
Patch Set: fix comment Created 3 years, 8 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 side-by-side diff with in-line comments
Download patch
Index: pkg/analysis_server/test/src/plugin/plugin_manager_test.dart
diff --git a/pkg/analysis_server/test/src/plugin/plugin_manager_test.dart b/pkg/analysis_server/test/src/plugin/plugin_manager_test.dart
index f572cfd96dfa466a533d1b890137b949fd153587..11ed4066a6702ed50e09401c35a7a4539751cb6a 100644
--- a/pkg/analysis_server/test/src/plugin/plugin_manager_test.dart
+++ b/pkg/analysis_server/test/src/plugin/plugin_manager_test.dart
@@ -18,6 +18,7 @@ import 'package:analyzer_plugin/protocol/protocol_generated.dart'
import 'package:path/path.dart' as path;
import 'package:test/test.dart';
import 'package:test_reflective_loader/test_reflective_loader.dart';
+import 'package:watcher/watcher.dart' as watcher;
main() {
defineReflectiveSuite(() {
@@ -140,10 +141,11 @@ class PluginManagerFromDiskTest extends PluginTestSupport {
await manager.addPluginToContextRoot(contextRoot, plugin1Path);
await manager.addPluginToContextRoot(contextRoot, plugin2Path);
- Map<PluginInfo, Future<Response>> responses = manager.broadcast(
- contextRoot,
- new CompletionGetSuggestionsParams(
- '/pkg1/lib/pkg1.dart', 100));
+ Map<PluginInfo, Future<Response>> responses =
+ manager.broadcastRequest(
+ contextRoot,
+ new CompletionGetSuggestionsParams(
+ '/pkg1/lib/pkg1.dart', 100));
expect(responses, hasLength(2));
await manager.stopAll();
@@ -152,6 +154,30 @@ class PluginManagerFromDiskTest extends PluginTestSupport {
pkg1Dir.deleteSync(recursive: true);
}
+ test_broadcastWatchEvent() async {
+ io.Directory pkg1Dir = io.Directory.systemTemp.createTempSync('pkg1');
+ String pkgPath = pkg1Dir.resolveSymbolicLinksSync();
+ await withPlugin(
+ pluginName: 'plugin1',
+ test: (String plugin1Path) async {
+ ContextRoot contextRoot = new ContextRoot(pkgPath, []);
+ await manager.addPluginToContextRoot(contextRoot, plugin1Path);
+ List<PluginInfo> plugins = manager.pluginsForContextRoot(contextRoot);
+ expect(plugins, hasLength(1));
+ watcher.WatchEvent watchEvent = new watcher.WatchEvent(
+ watcher.ChangeType.MODIFY,
+ path.join(plugin1Path, 'lib', 'lib.dart'));
+ List<Future<Response>> responses =
+ await manager.broadcastWatchEvent(watchEvent);
+ expect(responses, hasLength(1));
+ Response response = await responses[0];
+ expect(response, isNotNull);
+ expect(response.error, isNull);
+ await manager.stopAll();
+ });
+ pkg1Dir.deleteSync(recursive: true);
+ }
+
test_pluginsForContextRoot_multiple() async {
io.Directory pkg1Dir = io.Directory.systemTemp.createTempSync('pkg1');
String pkgPath = pkg1Dir.resolveSymbolicLinksSync();
@@ -224,9 +250,10 @@ class PluginManagerTest {
notificationManager, InstrumentationService.NULL_SERVICE);
}
- void test_broadcast_none() {
+ void test_broadcastRequest_none() {
ContextRoot contextRoot = new ContextRoot('/pkg1', []);
- Map<PluginInfo, Future<Response>> responses = manager.broadcast(contextRoot,
+ Map<PluginInfo, Future<Response>> responses = manager.broadcastRequest(
+ contextRoot,
new CompletionGetSuggestionsParams('/pkg1/lib/pkg1.dart', 100));
expect(responses, hasLength(0));
}
@@ -460,6 +487,7 @@ import 'dart:isolate';
import 'package:analyzer/file_system/file_system.dart';
import 'package:analyzer/file_system/physical_file_system.dart';
import 'package:analyzer_plugin/plugin/plugin.dart';
+import 'package:analyzer_plugin/protocol/protocol_generated.dart';
import 'package:analyzer_plugin/starter.dart';
import 'package:pub_semver/pub_semver.dart';
@@ -472,7 +500,7 @@ class MinimalPlugin extends ServerPlugin {
MinimalPlugin(ResourceProvider provider) : super(provider);
@override
- List<String> get fileGlobsToAnalyze => <String>[];
+ List<String> get fileGlobsToAnalyze => <String>['**/*.dart'];
@override
String get name => 'minimal';
@@ -481,6 +509,11 @@ class MinimalPlugin extends ServerPlugin {
String get version => '0.0.1';
@override
+ AnalysisHandleWatchEventsResult handleAnalysisHandleWatchEvents(
+ Map<String, Object> parameters) =>
+ new AnalysisHandleWatchEventsResult();
+
+ @override
bool isCompatibleWith(Version serverVersion) => true;
}
''';
@@ -503,8 +536,7 @@ class MinimalPlugin extends ServerPlugin {
* Return the path to the '.packages' file in the root of the SDK checkout.
*/
String _sdkPackagesPath() {
- String packagesPath =
- io.Platform.script.toFilePath(windows: io.Platform.isWindows);
+ String packagesPath = io.Platform.script.toFilePath();
while (packagesPath.isNotEmpty &&
path.basename(packagesPath) != 'analysis_server') {
packagesPath = path.dirname(packagesPath);

Powered by Google App Engine
This is Rietveld 408576698