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

Side by Side Diff: pkg/analysis_server/test/services/refactoring/rename_constructor_test.dart

Issue 908463004: Convert refactoring tests to use 'await'. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 years, 10 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.services.refactoring.rename_constructor; 5 library test.services.refactoring.rename_constructor;
6 6
7 import 'package:analysis_server/src/protocol.dart'; 7 import 'package:analysis_server/src/protocol.dart';
8 import 'package:analysis_server/src/services/correction/status.dart';
8 import 'package:analyzer/src/generated/ast.dart'; 9 import 'package:analyzer/src/generated/ast.dart';
9 import 'package:analyzer/src/generated/element.dart'; 10 import 'package:analyzer/src/generated/element.dart';
10 import 'package:unittest/unittest.dart'; 11 import 'package:unittest/unittest.dart';
11 12
12 import '../../reflective_tests.dart'; 13 import '../../reflective_tests.dart';
13 import 'abstract_rename.dart'; 14 import 'abstract_rename.dart';
14 15
15 16
16 main() { 17 main() {
17 groupSep = ' | '; 18 groupSep = ' | ';
18 runReflectiveTests(RenameConstructorTest); 19 runReflectiveTests(RenameConstructorTest);
19 } 20 }
20 21
21 22
22 @reflectiveTest 23 @reflectiveTest
23 class RenameConstructorTest extends RenameRefactoringTest { 24 class RenameConstructorTest extends RenameRefactoringTest {
24 test_checkFinalConditions_hasMember_constructor() { 25 test_checkFinalConditions_hasMember_constructor() async {
25 indexTestUnit(''' 26 indexTestUnit('''
26 class A { 27 class A {
27 A.test() {} 28 A.test() {}
28 A.newName() {} // existing 29 A.newName() {} // existing
29 } 30 }
30 '''); 31 ''');
31 _createConstructorDeclarationRefactoring('test() {}'); 32 _createConstructorDeclarationRefactoring('test() {}');
32 // check status 33 // check status
33 refactoring.newName = 'newName'; 34 refactoring.newName = 'newName';
34 return refactoring.checkFinalConditions().then((status) { 35 RefactoringStatus status = await refactoring.checkFinalConditions();
35 assertRefactoringStatus( 36 assertRefactoringStatus(
36 status, 37 status,
37 RefactoringProblemSeverity.ERROR, 38 RefactoringProblemSeverity.ERROR,
38 expectedMessage: "Class 'A' already declares constructor with name 'ne wName'.", 39 expectedMessage: "Class 'A' already declares constructor with name 'newN ame'.",
39 expectedContextSearch: 'newName() {} // existing'); 40 expectedContextSearch: 'newName() {} // existing');
40 });
41 } 41 }
42 42
43 test_checkFinalConditions_hasMember_method() { 43 test_checkFinalConditions_hasMember_method() async {
44 indexTestUnit(''' 44 indexTestUnit('''
45 class A { 45 class A {
46 A.test() {} 46 A.test() {}
47 newName() {} // existing 47 newName() {} // existing
48 } 48 }
49 '''); 49 ''');
50 _createConstructorDeclarationRefactoring('test() {}'); 50 _createConstructorDeclarationRefactoring('test() {}');
51 // check status 51 // check status
52 refactoring.newName = 'newName'; 52 refactoring.newName = 'newName';
53 return refactoring.checkFinalConditions().then((status) { 53 RefactoringStatus status = await refactoring.checkFinalConditions();
54 assertRefactoringStatus( 54 assertRefactoringStatus(
55 status, 55 status,
56 RefactoringProblemSeverity.ERROR, 56 RefactoringProblemSeverity.ERROR,
57 expectedMessage: "Class 'A' already declares method with name 'newName '.", 57 expectedMessage: "Class 'A' already declares method with name 'newName'. ",
58 expectedContextSearch: 'newName() {} // existing'); 58 expectedContextSearch: 'newName() {} // existing');
59 });
60 } 59 }
61 60
62 test_checkNewName() { 61 test_checkNewName() {
63 indexTestUnit(''' 62 indexTestUnit('''
64 class A { 63 class A {
65 A.test() {} 64 A.test() {}
66 } 65 }
67 '''); 66 ''');
68 createRenameRefactoringAtString('test() {}'); 67 createRenameRefactoringAtString('test() {}');
69 expect(refactoring.oldName, 'test'); 68 expect(refactoring.oldName, 'test');
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
188 } 187 }
189 '''); 188 ''');
190 } 189 }
191 190
192 void _createConstructorDeclarationRefactoring(String search) { 191 void _createConstructorDeclarationRefactoring(String search) {
193 ConstructorElement element = 192 ConstructorElement element =
194 findNodeElementAtString(search, (node) => node is ConstructorDeclaration ); 193 findNodeElementAtString(search, (node) => node is ConstructorDeclaration );
195 createRenameRefactoringForElement(element); 194 createRenameRefactoringForElement(element);
196 } 195 }
197 } 196 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698