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

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

Issue 583193005: Integration of MOVE_FILE into the server and a couple of fixes. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 3 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.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';
11 import 'package:analysis_server/src/services/index/index.dart'; 11 import 'package:analysis_server/src/services/index/index.dart';
12 import 'package:analysis_server/src/services/index/local_memory_index.dart'; 12 import 'package:analysis_server/src/services/index/local_memory_index.dart';
13 import 'package:unittest/unittest.dart' hide ERROR; 13 import 'package:unittest/unittest.dart' hide ERROR;
14 14
15 import '../analysis_abstract.dart'; 15 import '../analysis_abstract.dart';
16 import '../reflective_tests.dart'; 16 import '../reflective_tests.dart';
17 17
18 18
19 main() { 19 main() {
20 groupSep = ' | '; 20 groupSep = ' | ';
21 runReflectiveTests(ExtractLocalVariableTest); 21 runReflectiveTests(ExtractLocalVariableTest);
22 runReflectiveTests(ExtractMethodTest); 22 runReflectiveTests(ExtractMethodTest);
23 runReflectiveTests(GetAvailableRefactoringsTest);
23 runReflectiveTests(InlineLocalTest); 24 runReflectiveTests(InlineLocalTest);
24 runReflectiveTests(InlineMethodTest); 25 runReflectiveTests(InlineMethodTest);
25 runReflectiveTests(GetAvailableRefactoringsTest); 26 runReflectiveTests(MoveFileTest);
26 runReflectiveTests(RenameTest); 27 runReflectiveTests(RenameTest);
27 } 28 }
28 29
29 30
30 @ReflectiveTestCase() 31 @ReflectiveTestCase()
31 class ExtractLocalVariableTest extends _AbstractGetRefactoring_Test { 32 class ExtractLocalVariableTest extends _AbstractGetRefactoring_Test {
32 Future<Response> sendExtractRequest(int offset, int length, String name, 33 Future<Response> sendExtractRequest(int offset, int length, String name,
33 bool extractAll) { 34 bool extractAll) {
34 RefactoringKind kind = RefactoringKind.EXTRACT_LOCAL_VARIABLE; 35 RefactoringKind kind = RefactoringKind.EXTRACT_LOCAL_VARIABLE;
35 ExtractLocalVariableOptions options = 36 ExtractLocalVariableOptions options =
(...skipping 665 matching lines...) Expand 10 before | Expand all | Expand 10 after
701 findOffset(search), 702 findOffset(search),
702 0, 703 0,
703 false, 704 false,
704 options: options).toRequest('0'); 705 options: options).toRequest('0');
705 return serverChannel.sendRequest(request); 706 return serverChannel.sendRequest(request);
706 } 707 }
707 } 708 }
708 709
709 710
710 @ReflectiveTestCase() 711 @ReflectiveTestCase()
712 class MoveFileTest extends _AbstractGetRefactoring_Test {
713 MoveFileOptions options = new MoveFileOptions(null);
714
715 test_OK() {
716 resourceProvider.newFile('/project/bin/lib.dart', '');
717 addTestFile('''
718 import 'dart:math';
719 import 'lib.dart';
720 ''');
721 options.newFile = '/project/test.dart';
722 return assertSuccessfulRefactoring(() {
723 return _sendMoveRequest();
724 }, '''
725 import 'dart:math';
726 import 'bin/lib.dart';
727 ''');
728 }
729
730 Future<Response> _sendMoveRequest() {
731 Request request = new EditGetRefactoringParams(
732 RefactoringKind.MOVE_FILE,
733 testFile,
734 0,
735 0,
736 false,
737 options: options).toRequest('0');
738 return serverChannel.sendRequest(request);
739 }
740 }
741
742
743 @ReflectiveTestCase()
711 class RenameTest extends _AbstractGetRefactoring_Test { 744 class RenameTest extends _AbstractGetRefactoring_Test {
712 Future<Response> sendRenameRequest(String search, String newName, 745 Future<Response> sendRenameRequest(String search, String newName,
713 [bool validateOnly = false]) { 746 [bool validateOnly = false]) {
714 RenameOptions options = newName != null ? new RenameOptions(newName) : null; 747 RenameOptions options = newName != null ? new RenameOptions(newName) : null;
715 Request request = new EditGetRefactoringParams( 748 Request request = new EditGetRefactoringParams(
716 RefactoringKind.RENAME, 749 RefactoringKind.RENAME,
717 testFile, 750 testFile,
718 findOffset(search), 751 findOffset(search),
719 0, 752 0,
720 validateOnly, 753 validateOnly,
(...skipping 404 matching lines...) Expand 10 before | Expand all | Expand 10 after
1125 } 1158 }
1126 1159
1127 @override 1160 @override
1128 void setUp() { 1161 void setUp() {
1129 super.setUp(); 1162 super.setUp();
1130 server.handlers = [new EditDomainHandler(server),]; 1163 server.handlers = [new EditDomainHandler(server),];
1131 createProject(); 1164 createProject();
1132 handler = new EditDomainHandler(server); 1165 handler = new EditDomainHandler(server);
1133 } 1166 }
1134 } 1167 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698