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

Side by Side Diff: pkg/analysis_server/test/edit/refactoring_test.dart

Issue 816133002: Improve tests for refactoring exceptions. Catch initial exceptions. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Use runZoned(). Created 5 years, 11 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
« no previous file with comments | « pkg/analysis_server/lib/src/edit/edit_domain.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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.edit.refactoring; 5 library test.edit.refactoring;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 8
9 import 'package:analysis_server/src/edit/edit_domain.dart'; 9 import 'package:analysis_server/src/edit/edit_domain.dart';
10 import 'package:analysis_server/src/protocol.dart'; 10 import 'package:analysis_server/src/protocol.dart';
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after
258 } 258 }
259 259
260 Future<Response> sendStringSuffixRequest(String search, String suffix, 260 Future<Response> sendStringSuffixRequest(String search, String suffix,
261 String name, bool extractAll) { 261 String name, bool extractAll) {
262 int offset = findOffset(search + suffix); 262 int offset = findOffset(search + suffix);
263 int length = search.length; 263 int length = search.length;
264 return sendExtractRequest(offset, length, name, extractAll); 264 return sendExtractRequest(offset, length, name, extractAll);
265 } 265 }
266 266
267 void tearDown() { 267 void tearDown() {
268 test_simulateRefactoringException = false; 268 test_simulateRefactoringException_init = false;
269 test_simulateRefactoringException_final = false;
270 test_simulateRefactoringException_change = false;
269 super.tearDown(); 271 super.tearDown();
270 } 272 }
271 273
272 test_extractAll() { 274 test_extractAll() {
273 addTestFile(''' 275 addTestFile('''
274 main() { 276 main() {
275 print(1 + 2); 277 print(1 + 2);
276 print(1 + 2); 278 print(1 + 2);
277 } 279 }
278 '''); 280 ''');
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
355 '''); 357 ''');
356 return getRefactoringResult(() { 358 return getRefactoringResult(() {
357 return sendStringRequest('1 + 2', 'res', true); 359 return sendStringRequest('1 + 2', 'res', true);
358 }).then((result) { 360 }).then((result) {
359 ExtractLocalVariableFeedback feedback = result.feedback; 361 ExtractLocalVariableFeedback feedback = result.feedback;
360 expect(feedback.offsets, [findOffset('1 + 2'), findOffset('1 + 2')]); 362 expect(feedback.offsets, [findOffset('1 + 2'), findOffset('1 + 2')]);
361 expect(feedback.lengths, [5, 6]); 363 expect(feedback.lengths, [5, 6]);
362 }); 364 });
363 } 365 }
364 366
365 test_serverError() { 367 test_serverError_change() {
366 test_simulateRefactoringException = true; 368 test_simulateRefactoringException_change = true;
367 addTestFile(''' 369 addTestFile('''
368 main() { 370 main() {
369 print(1 + 2); 371 print(1 + 2);
370 } 372 }
371 '''); 373 ''');
372 return waitForTasksFinished().then((_) { 374 return waitForTasksFinished().then((_) {
373 return sendStringRequest('1 + 2', 'res', true).then((response) { 375 return sendStringRequest('1 + 2', 'res', true).then((response) {
374 expect(response.error, isNotNull); 376 expect(response.error, isNotNull);
377 expect(response.error.code, RequestErrorCode.SERVER_ERROR);
375 }); 378 });
376 }); 379 });
377 } 380 }
381
382 test_serverError_final() {
383 test_simulateRefactoringException_final = true;
384 addTestFile('''
385 main() {
386 print(1 + 2);
387 }
388 ''');
389 return waitForTasksFinished().then((_) {
390 return sendStringRequest('1 + 2', 'res', true).then((response) {
391 expect(response.error, isNotNull);
392 expect(response.error.code, RequestErrorCode.SERVER_ERROR);
393 });
394 });
395 }
396
397 test_serverError_init() {
398 test_simulateRefactoringException_init = true;
399 addTestFile('''
400 main() {
401 print(1 + 2);
402 }
403 ''');
404 return waitForTasksFinished().then((_) {
405 return sendStringRequest('1 + 2', 'res', true).then((response) {
406 expect(response.error, isNotNull);
407 expect(response.error.code, RequestErrorCode.SERVER_ERROR);
408 });
409 });
410 }
378 } 411 }
379 412
380 413
381 @ReflectiveTestCase() 414 @ReflectiveTestCase()
382 class ExtractMethodTest extends _AbstractGetRefactoring_Test { 415 class ExtractMethodTest extends _AbstractGetRefactoring_Test {
383 int offset; 416 int offset;
384 int length; 417 int length;
385 String name = 'res'; 418 String name = 'res';
386 ExtractMethodOptions options; 419 ExtractMethodOptions options;
387 420
(...skipping 1270 matching lines...) Expand 10 before | Expand all | Expand 10 after
1658 } 1691 }
1659 1692
1660 @override 1693 @override
1661 void setUp() { 1694 void setUp() {
1662 super.setUp(); 1695 super.setUp();
1663 server.handlers = [new EditDomainHandler(server),]; 1696 server.handlers = [new EditDomainHandler(server),];
1664 createProject(); 1697 createProject();
1665 handler = new EditDomainHandler(server); 1698 handler = new EditDomainHandler(server);
1666 } 1699 }
1667 } 1700 }
OLDNEW
« no previous file with comments | « pkg/analysis_server/lib/src/edit/edit_domain.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698