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

Side by Side Diff: pkg/analysis_server/test/domain_analysis_test.dart

Issue 449213002: Rework "analysis.updateContent" analysis server request. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 4 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 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. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 library test.domain.analysis; 5 library test.domain.analysis;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 8
9 import 'package:analysis_server/src/analysis_server.dart'; 9 import 'package:analysis_server/src/analysis_server.dart';
10 import 'package:analysis_server/src/computer/error.dart'; 10 import 'package:analysis_server/src/computer/error.dart';
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
141 expect(response, isResponseSuccess('0')); 141 expect(response, isResponseSuccess('0'));
142 expect(options.analyzeAngular, equals(analyzeAngular)); 142 expect(options.analyzeAngular, equals(analyzeAngular));
143 expect(options.enableDeferredLoading, equals(enableDeferredLoading)); 143 expect(options.enableDeferredLoading, equals(enableDeferredLoading));
144 }); 144 });
145 }); 145 });
146 }); 146 });
147 } 147 }
148 148
149 149
150 testUpdateContent() { 150 testUpdateContent() {
151 test('bad type', () {
152 AnalysisTestHelper helper = new AnalysisTestHelper();
153 helper.createSingleFileProject('// empty');
154 return helper.waitForOperationsFinished().then((_) {
155 Request request = new Request('0', ANALYSIS_UPDATE_CONTENT);
156 request.setParameter('files', {
157 helper.testFile: {
158 TYPE: 'foo',
159 }
160 });
161 Response response = helper.handler.handleRequest(request);
162 expect(response, isResponseFailure('0'));
163 });
164 });
165
151 test('full content', () { 166 test('full content', () {
152 AnalysisTestHelper helper = new AnalysisTestHelper(); 167 AnalysisTestHelper helper = new AnalysisTestHelper();
153 helper.createSingleFileProject('// empty'); 168 helper.createSingleFileProject('// empty');
154 return helper.waitForOperationsFinished().then((_) { 169 return helper.waitForOperationsFinished().then((_) {
155 // no errors initially 170 // no errors initially
156 List<AnalysisError> errors = helper.getTestErrors(); 171 List<AnalysisError> errors = helper.getTestErrors();
157 expect(errors, isEmpty); 172 expect(errors, isEmpty);
158 // update code 173 // update code
159 helper.sendContentChange({ 174 helper.sendContentChange({
175 TYPE: ADD,
160 CONTENT: 'library lib' 176 CONTENT: 'library lib'
161 }); 177 });
162 // wait, there is an error 178 // wait, there is an error
163 return helper.waitForOperationsFinished().then((_) { 179 return helper.waitForOperationsFinished().then((_) {
164 List<AnalysisError> errors = helper.getTestErrors(); 180 List<AnalysisError> errors = helper.getTestErrors();
165 expect(errors, hasLength(1)); 181 expect(errors, hasLength(1));
166 }); 182 });
167 }); 183 });
168 }); 184 });
169 185
170 test('incremental', () { 186 test('incremental', () {
171 AnalysisTestHelper helper = new AnalysisTestHelper(); 187 AnalysisTestHelper helper = new AnalysisTestHelper();
172 helper.createSingleFileProject('library A;'); 188 String initialContent = 'library A;';
189 helper.createSingleFileProject(initialContent);
173 return helper.waitForOperationsFinished().then((_) { 190 return helper.waitForOperationsFinished().then((_) {
174 // no errors initially 191 // no errors initially
175 List<AnalysisError> errors = helper.getTestErrors(); 192 List<AnalysisError> errors = helper.getTestErrors();
176 expect(errors, isEmpty); 193 expect(errors, isEmpty);
194 // Add the file to the cache
195 helper.sendContentChange({
196 TYPE: ADD,
197 CONTENT: initialContent
198 });
177 // update code 199 // update code
178 helper.sendContentChange({ 200 helper.sendContentChange({
179 CONTENT: 'library lib', 201 TYPE: CHANGE,
202 REPLACEMENT: 'lib',
180 OFFSET: 'library '.length, 203 OFFSET: 'library '.length,
181 OLD_LENGTH: 'A;'.length, 204 OLD_LENGTH: 'A;'.length,
182 NEW_LENGTH: 'lib'.length,
183 }); 205 });
184 // wait, there is an error 206 // wait, there is an error
185 return helper.waitForOperationsFinished().then((_) { 207 return helper.waitForOperationsFinished().then((_) {
186 List<AnalysisError> errors = helper.getTestErrors(); 208 List<AnalysisError> errors = helper.getTestErrors();
187 expect(errors, hasLength(1)); 209 expect(errors, hasLength(1));
188 }); 210 });
189 }); 211 });
190 }); 212 });
191 213
192 test('change on disk, normal', () { 214 test('change on disk, normal', () {
(...skipping 12 matching lines...) Expand all
205 }); 227 });
206 }); 228 });
207 }); 229 });
208 230
209 test('change on disk, during override', () { 231 test('change on disk, during override', () {
210 AnalysisTestHelper helper = new AnalysisTestHelper(); 232 AnalysisTestHelper helper = new AnalysisTestHelper();
211 helper.createSingleFileProject('library A;'); 233 helper.createSingleFileProject('library A;');
212 return helper.waitForOperationsFinished().then((_) { 234 return helper.waitForOperationsFinished().then((_) {
213 // update code 235 // update code
214 helper.sendContentChange({ 236 helper.sendContentChange({
237 TYPE: ADD,
215 CONTENT: 'library B;' 238 CONTENT: 'library B;'
216 }); 239 });
217 // There should be no errors 240 // There should be no errors
218 return helper.waitForOperationsFinished().then((_) { 241 return helper.waitForOperationsFinished().then((_) {
219 expect(helper.getTestErrors(), hasLength(0)); 242 expect(helper.getTestErrors(), hasLength(0));
220 // Change file on disk, adding a syntax error. 243 // Change file on disk, adding a syntax error.
221 helper.resourceProvider.modifyFile(helper.testFile, 'library lib'); 244 helper.resourceProvider.modifyFile(helper.testFile, 'library lib');
222 // There should still be no errors (file should not have been reread). 245 // There should still be no errors (file should not have been reread).
223 return helper.waitForOperationsFinished().then((_) { 246 return helper.waitForOperationsFinished().then((_) {
224 expect(helper.getTestErrors(), hasLength(0)); 247 expect(helper.getTestErrors(), hasLength(0));
225 // Send a content change with a null content param--file should be 248 // Send a content change with a null content param--file should be
226 // reread from disk. 249 // reread from disk.
227 helper.sendContentChange({ 250 helper.sendContentChange({
228 CONTENT: null 251 TYPE: REMOVE
229 }); 252 });
230 // There should be errors now. 253 // There should be errors now.
231 return helper.waitForOperationsFinished().then((_) { 254 return helper.waitForOperationsFinished().then((_) {
232 expect(helper.getTestErrors(), hasLength(1)); 255 expect(helper.getTestErrors(), hasLength(1));
233 }); 256 });
234 }); 257 });
235 }); 258 });
236 }); 259 });
237 }); 260 });
238 } 261 }
(...skipping 343 matching lines...) Expand 10 before | Expand all | Expand 10 after
582 return waitForServerOperationsPerformed(server); 605 return waitForServerOperationsPerformed(server);
583 } 606 }
584 607
585 static String _getCodeString(code) { 608 static String _getCodeString(code) {
586 if (code is List<String>) { 609 if (code is List<String>) {
587 code = code.join('\n'); 610 code = code.join('\n');
588 } 611 }
589 return code as String; 612 return code as String;
590 } 613 }
591 } 614 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698