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

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

Issue 815233002: Catch exceptions in refactorings and return them as a SERVER_ERROR. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years 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/protocol.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 246 matching lines...) Expand 10 before | Expand all | Expand 10 after
257 return sendExtractRequest(offset, length, name, extractAll); 257 return sendExtractRequest(offset, length, name, extractAll);
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() {
268 test_simulateRefactoringException = false;
269 super.tearDown();
270 }
271
267 test_extractAll() { 272 test_extractAll() {
268 addTestFile(''' 273 addTestFile('''
269 main() { 274 main() {
270 print(1 + 2); 275 print(1 + 2);
271 print(1 + 2); 276 print(1 + 2);
272 } 277 }
273 '''); 278 ''');
274 return assertSuccessfulRefactoring(() { 279 return assertSuccessfulRefactoring(() {
275 return sendStringRequest('1 + 2', 'res', true); 280 return sendStringRequest('1 + 2', 'res', true);
276 }, ''' 281 }, '''
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
349 } 354 }
350 '''); 355 ''');
351 return getRefactoringResult(() { 356 return getRefactoringResult(() {
352 return sendStringRequest('1 + 2', 'res', true); 357 return sendStringRequest('1 + 2', 'res', true);
353 }).then((result) { 358 }).then((result) {
354 ExtractLocalVariableFeedback feedback = result.feedback; 359 ExtractLocalVariableFeedback feedback = result.feedback;
355 expect(feedback.offsets, [findOffset('1 + 2'), findOffset('1 + 2')]); 360 expect(feedback.offsets, [findOffset('1 + 2'), findOffset('1 + 2')]);
356 expect(feedback.lengths, [5, 6]); 361 expect(feedback.lengths, [5, 6]);
357 }); 362 });
358 } 363 }
364
365 test_serverError() {
366 test_simulateRefactoringException = true;
367 addTestFile('''
368 main() {
369 print(1 + 2);
370 }
371 ''');
372 return waitForTasksFinished().then((_) {
373 return sendStringRequest('1 + 2', 'res', true).then((response) {
374 expect(response.error, isNotNull);
375 });
376 });
377 }
359 } 378 }
360 379
361 380
362 @ReflectiveTestCase() 381 @ReflectiveTestCase()
363 class ExtractMethodTest extends _AbstractGetRefactoring_Test { 382 class ExtractMethodTest extends _AbstractGetRefactoring_Test {
364 int offset; 383 int offset;
365 int length; 384 int length;
366 String name = 'res'; 385 String name = 'res';
367 ExtractMethodOptions options; 386 ExtractMethodOptions options;
368 387
(...skipping 1270 matching lines...) Expand 10 before | Expand all | Expand 10 after
1639 } 1658 }
1640 1659
1641 @override 1660 @override
1642 void setUp() { 1661 void setUp() {
1643 super.setUp(); 1662 super.setUp();
1644 server.handlers = [new EditDomainHandler(server),]; 1663 server.handlers = [new EditDomainHandler(server),];
1645 createProject(); 1664 createProject();
1646 handler = new EditDomainHandler(server); 1665 handler = new EditDomainHandler(server);
1647 } 1666 }
1648 } 1667 }
OLDNEW
« no previous file with comments | « 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