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

Unified Diff: pkg/analysis_server/test/integration/analysis_domain_int_test.dart

Issue 423393005: Integration tests for analysis.updateContent. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 5 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analysis_server/test/integration/analysis_domain_int_test.dart
diff --git a/pkg/analysis_server/test/integration/analysis_domain_int_test.dart b/pkg/analysis_server/test/integration/analysis_domain_int_test.dart
index 22881a5e8aeb191facaccb6bffc0c8c141ebf368..f744c1d979329d6d922cb7a3c5620142ecb41fe9 100644
--- a/pkg/analysis_server/test/integration/analysis_domain_int_test.dart
+++ b/pkg/analysis_server/test/integration/analysis_domain_int_test.dart
@@ -172,11 +172,10 @@ main() {
Future getErrorsTest(bool afterAnalysis) {
String filename = 'test.dart';
String pathname = normalizePath(filename);
- String text =
- r'''
- main() {
- var x // parse error: missing ';'
- }''';
+ String text = r'''
+main() {
+ var x // parse error: missing ';'
+}''';
writeFile(filename, text);
setAnalysisRoots(['']);
Future finishTest() {
@@ -193,6 +192,64 @@ main() {
return finishTest();
}
}
+
+ test_updateContent_content_only() {
+ return updateContentTest(false);
+ }
+
+ test_updateContent_including_offset_and_lengths() {
+ return updateContentTest(true);
+ }
+
+ Future updateContentTest(bool includeOffsetAndLengths) {
+ String filename = 'test.dart';
+ String pathname = normalizePath(filename);
+ String goodText = r'''
+main() {
+ print("Hello, world!");
+}''';
+ String badText = goodText.replaceAll(';', '');
+ writeFile(filename, badText);
+ setAnalysisRoots(['']);
+ return analysisFinished.then((_) {
+ // The contents on disk (badText) are missing a semicolon.
+ expect(currentAnalysisErrors[pathname], isNot(isEmpty));
+ var contentChange = {
+ 'content': goodText
+ };
+ if (includeOffsetAndLengths) {
+ contentChange['offset'] = goodText.indexOf(';');
+ contentChange['oldLength'] = 0;
+ contentChange['newLength'] = 1;
+ }
+ return server.send(ANALYSIS_UPDATE_CONTENT, {
+ 'files': {
+ pathname: contentChange
+ }
+ });
+ }).then((result) {
+ expect(result, isNull);
+ return analysisFinished;
+ }).then((_) {
+ // There should be no errors now because the contents on disk have been
+ // overriden with goodText.
+ expect(currentAnalysisErrors[pathname], isEmpty);
+ return server.send(ANALYSIS_UPDATE_CONTENT, {
+ 'files': {
+ pathname: {
+ 'content': null
+ }
+ }
+ });
+ }).then((result) {
+ expect(result, isNull);
+ return analysisFinished;
+ }).then((_) {
+ // Now there should be errors again, because the contents on disk are no
+ // longer overridden.
+ expect(currentAnalysisErrors[pathname], isNot(isEmpty));
+ });
+ }
}
main() {
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698