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

Unified Diff: pkg/analysis_server/test/domain_analysis_test.dart

Issue 335853003: Handle null content in ContentChange. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 6 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/domain_analysis_test.dart
diff --git a/pkg/analysis_server/test/domain_analysis_test.dart b/pkg/analysis_server/test/domain_analysis_test.dart
index a4df7bb927fe06cd6c7114c840cc6938a0cdd3ca..19d825158e909b7bca3239c093deb07bcd56c01f 100644
--- a/pkg/analysis_server/test/domain_analysis_test.dart
+++ b/pkg/analysis_server/test/domain_analysis_test.dart
@@ -351,6 +351,17 @@ class AnalysisTestHelper {
server.done();
}
+ /**
+ * Send an updateContent request for testFile.
scheglov 2014/06/13 16:55:54 Would be good to wrap constants with ``. Send an
Paul Berry 2014/06/13 20:23:00 Done.
+ */
+ void sendContentChange(Map contentChange) {
+ Request request = new Request('0', METHOD_UPDATE_CONTENT);
+ request.setParameter('files', {
+ testFile: contentChange
+ });
+ handleSuccessfulRequest(request);
+ }
+
static String _getCodeString(code) {
if (code is List<String>) {
code = code.join('\n');
@@ -1560,16 +1571,9 @@ testUpdateContent() {
List<AnalysisError> errors = helper.getTestErrors();
expect(errors, isEmpty);
// update code
- {
- Request request = new Request('0', METHOD_UPDATE_CONTENT);
- request.setParameter('files',
- {
- helper.testFile : {
- CONTENT : 'library lib'
- }
- });
- helper.handleSuccessfulRequest(request);
- }
+ helper.sendContentChange({
+ CONTENT: 'library lib'
+ });
// wait, there is an error
return helper.waitForOperationsFinished().then((_) {
List<AnalysisError> errors = helper.getTestErrors();
@@ -1586,19 +1590,12 @@ testUpdateContent() {
List<AnalysisError> errors = helper.getTestErrors();
expect(errors, isEmpty);
// update code
- {
- Request request = new Request('0', METHOD_UPDATE_CONTENT);
- request.setParameter('files',
- {
- helper.testFile : {
- CONTENT : 'library lib',
- OFFSET : 'library '.length,
- OLD_LENGTH : 'A;'.length,
- NEW_LENGTH : 'lib'.length,
- }
- });
- helper.handleSuccessfulRequest(request);
- }
+ helper.sendContentChange({
+ CONTENT: 'library lib',
+ OFFSET: 'library '.length,
+ OLD_LENGTH: 'A;'.length,
+ NEW_LENGTH: 'lib'.length,
+ });
// wait, there is an error
return helper.waitForOperationsFinished().then((_) {
List<AnalysisError> errors = helper.getTestErrors();
@@ -1606,8 +1603,37 @@ testUpdateContent() {
});
});
});
-}
+ test('change on disk', () {
+ AnalysisTestHelper helper = new AnalysisTestHelper();
+ helper.createSingleFileProject('library A;');
+ return helper.waitForOperationsFinished().then((_) {
+ // update code
+ helper.sendContentChange({
+ CONTENT: 'library B;'
+ });
+ // There should be no errors
+ return helper.waitForOperationsFinished().then((_) {
+ expect(helper.getTestErrors(), hasLength(0));
+ // Change file on disk, adding a syntax error.
+ helper.resourceProvider.modifyFile(helper.testFile, 'library lib');
+ // There should still be no errors (file should not have been reread).
+ return helper.waitForOperationsFinished().then((_) {
+ expect(helper.getTestErrors(), hasLength(0));
+ // Send a content change with a null content param--file should be
+ // reread from disk.
+ helper.sendContentChange({
+ CONTENT: null
+ });
+ // There should be errors now.
+ return helper.waitForOperationsFinished().then((_) {
+ expect(helper.getTestErrors(), hasLength(1));
+ });
+ });
+ });
+ });
+ });
+}
void test_setSubscriptions() {
test('before analysis', () {
« pkg/analysis_server/lib/src/protocol.dart ('K') | « pkg/analysis_server/lib/src/protocol.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698