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

Unified Diff: pkg/analysis_server/test/analysis/update_content_test.dart

Issue 2834993002: Add support for three more plugin requests (Closed)
Patch Set: 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/analysis/update_content_test.dart
diff --git a/pkg/analysis_server/test/analysis/update_content_test.dart b/pkg/analysis_server/test/analysis/update_content_test.dart
index 005528e1763cfe26396c984c657994207b250b79..8c73c9086fc83a96e86bf4960371701c24061216 100644
--- a/pkg/analysis_server/test/analysis/update_content_test.dart
+++ b/pkg/analysis_server/test/analysis/update_content_test.dart
@@ -13,6 +13,7 @@ import 'package:analyzer/dart/ast/standard_resolution_map.dart';
import 'package:analyzer/file_system/file_system.dart';
import 'package:analyzer/src/generated/engine.dart';
import 'package:analyzer/src/generated/source.dart';
+import 'package:analyzer_plugin/protocol/protocol_generated.dart' as plugin;
import 'package:test/test.dart';
import 'package:test_reflective_loader/test_reflective_loader.dart';
import 'package:typed_mock/typed_mock.dart';
@@ -269,6 +270,55 @@ f() {}
expect(filesErrors, isNotEmpty);
}
+ test_sentToPlugins() {
+ String filePath = '/project/target.dart';
+ String fileContent = 'import "none.dart";';
+ //
+ // Add
+ //
+ handleSuccessfulRequest(new AnalysisUpdateContentParams(
+ <String, dynamic>{filePath: new AddContentOverlay(fileContent)})
+ .toRequest('0'));
+ plugin.AnalysisUpdateContentParams params =
+ pluginManager.analysisUpdateContentParams;
+ expect(params, isNotNull);
+ Map<String, dynamic> files = params.files;
+ expect(files, hasLength(1));
+ Object overlay = files[filePath];
+ expect(overlay, new isInstanceOf<plugin.AddContentOverlay>());
+ plugin.AddContentOverlay addOverlay = overlay;
+ expect(addOverlay.content, fileContent);
+ //
+ // Change
+ //
+ pluginManager.analysisUpdateContentParams = null;
+ handleSuccessfulRequest(new AnalysisUpdateContentParams(<String, dynamic>{
+ filePath: new ChangeContentOverlay(
+ <SourceEdit>[new SourceEdit(8, 1, "'"), new SourceEdit(18, 1, "'")])
+ }).toRequest('1'));
+ params = pluginManager.analysisUpdateContentParams;
+ expect(params, isNotNull);
+ files = params.files;
+ expect(files, hasLength(1));
+ overlay = files[filePath];
+ expect(overlay, new isInstanceOf<plugin.ChangeContentOverlay>());
+ plugin.ChangeContentOverlay changeOverlay = overlay;
+ expect(changeOverlay.edits, hasLength(2));
+ //
+ // Remove
+ //
+ pluginManager.analysisUpdateContentParams = null;
+ handleSuccessfulRequest(new AnalysisUpdateContentParams(
+ <String, dynamic>{filePath: new RemoveContentOverlay()})
+ .toRequest('2'));
+ params = pluginManager.analysisUpdateContentParams;
+ expect(params, isNotNull);
+ files = params.files;
+ expect(files, hasLength(1));
+ overlay = files[filePath];
+ expect(overlay, new isInstanceOf<plugin.RemoveContentOverlay>());
+ }
+
CompilationUnit _getTestUnit() {
ContextSourcePair pair = server.getContextSourcePair(testFile);
AnalysisContext context = pair.context;
« no previous file with comments | « pkg/analysis_server/test/analysis/set_priority_files_test.dart ('k') | pkg/analysis_server/test/analysis_abstract.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698