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

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

Issue 492563002: Make more use of generated classes in analysis server. (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.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/constants.dart'; 9 import 'package:analysis_server/src/edit/edit_domain.dart' hide RefactoringKind;
10 import 'package:analysis_server/src/edit/edit_domain.dart';
11 import 'package:analysis_server/src/protocol.dart'; 10 import 'package:analysis_server/src/protocol.dart';
12 import 'package:analysis_server/src/protocol2.dart' show 11 import 'package:analysis_server/src/protocol2.dart' show
13 EditGetAvailableRefactoringsParams; 12 EditGetAvailableRefactoringsParams, EditGetAvailableRefactoringsResult,
13 RefactoringKind;
14 import 'package:analysis_testing/reflective_tests.dart'; 14 import 'package:analysis_testing/reflective_tests.dart';
15 import 'package:unittest/unittest.dart' hide ERROR; 15 import 'package:unittest/unittest.dart' hide ERROR;
16 16
17 import '../analysis_abstract.dart'; 17 import '../analysis_abstract.dart';
18 18
19 19
20 main() { 20 main() {
21 groupSep = ' | '; 21 groupSep = ' | ';
22 runReflectiveTests(GetAvailableRefactoringsTest); 22 runReflectiveTests(GetAvailableRefactoringsTest);
23 } 23 }
24 24
25 25
26 @ReflectiveTestCase() 26 @ReflectiveTestCase()
27 class GetAvailableRefactoringsTest extends AbstractAnalysisTest { 27 class GetAvailableRefactoringsTest extends AbstractAnalysisTest {
28 /** 28 /**
29 * Tests that there is a RENAME refactoring available at the [search] offset. 29 * Tests that there is a RENAME refactoring available at the [search] offset.
30 */ 30 */
31 Future assertHasRenameRefactoring(String code, String search) { 31 Future assertHasRenameRefactoring(String code, String search) {
32 addTestFile(code); 32 addTestFile(code);
33 return waitForTasksFinished().then((_) { 33 return waitForTasksFinished().then((_) {
34 List<String> kinds = getAvailableRefactorings(search); 34 List<RefactoringKind> kinds = getAvailableRefactorings(search);
35 expect(kinds, contains(RefactoringKind.RENAME)); 35 expect(kinds, contains(RefactoringKind.RENAME));
36 }); 36 });
37 } 37 }
38 38
39 /** 39 /**
40 * Returns the list of available refactorings of the offset of [search] with 40 * Returns the list of available refactorings of the offset of [search] with
41 * [length] characters selected. 41 * [length] characters selected.
42 */ 42 */
43 List<String> getAvailableRefactorings(String search, [int length = 0]) { 43 List<RefactoringKind> getAvailableRefactorings(String search, [int length = 0] ) {
44 Request request = new EditGetAvailableRefactoringsParams(testFile, 44 Request request = new EditGetAvailableRefactoringsParams(testFile,
45 findOffset(search), length).toRequest('0'); 45 findOffset(search), length).toRequest('0');
46 Response response = handleSuccessfulRequest(request); 46 Response response = handleSuccessfulRequest(request);
47 return response.getResult(KINDS); 47 var result = new EditGetAvailableRefactoringsResult.fromResponse(response);
48 return result.kinds;
48 } 49 }
49 50
50 @override 51 @override
51 void setUp() { 52 void setUp() {
52 super.setUp(); 53 super.setUp();
53 createProject(); 54 createProject();
54 handler = new EditDomainHandler(server); 55 handler = new EditDomainHandler(server);
55 } 56 }
56 57
57 Future test_rename_hasElement_class() { 58 Future test_rename_hasElement_class() {
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
159 ''', 'test();'); 160 ''', 'test();');
160 } 161 }
161 162
162 Future test_rename_noElement() { 163 Future test_rename_noElement() {
163 addTestFile(''' 164 addTestFile('''
164 main() { 165 main() {
165 // not an element 166 // not an element
166 } 167 }
167 '''); 168 ''');
168 return waitForTasksFinished().then((_) { 169 return waitForTasksFinished().then((_) {
169 List<String> kinds = getAvailableRefactorings('// not an element'); 170 List<RefactoringKind> kinds = getAvailableRefactorings('// not an element' );
170 expect(kinds, isNot(contains(RefactoringKind.RENAME))); 171 expect(kinds, isNot(contains(RefactoringKind.RENAME)));
171 }); 172 });
172 } 173 }
173 } 174 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698