| OLD | NEW |
| 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 import 'package:analyzer_plugin/protocol/protocol_common.dart'; | 5 import 'package:analyzer_plugin/protocol/protocol_common.dart'; |
| 6 import 'package:test/test.dart'; | 6 import 'package:test/test.dart'; |
| 7 import 'package:test_reflective_loader/test_reflective_loader.dart'; | 7 import 'package:test_reflective_loader/test_reflective_loader.dart'; |
| 8 | 8 |
| 9 import 'abstract_rename.dart'; | 9 import 'abstract_rename.dart'; |
| 10 | 10 |
| (...skipping 22 matching lines...) Expand all Loading... |
| 33 expectedMessage: "Library name must not be blank."); | 33 expectedMessage: "Library name must not be blank."); |
| 34 // same name | 34 // same name |
| 35 refactoring.newName = 'my.app'; | 35 refactoring.newName = 'my.app'; |
| 36 assertRefactoringStatus( | 36 assertRefactoringStatus( |
| 37 refactoring.checkNewName(), RefactoringProblemSeverity.FATAL, | 37 refactoring.checkNewName(), RefactoringProblemSeverity.FATAL, |
| 38 expectedMessage: | 38 expectedMessage: |
| 39 "The new name must be different than the current name."); | 39 "The new name must be different than the current name."); |
| 40 } | 40 } |
| 41 | 41 |
| 42 test_createChange() async { | 42 test_createChange() async { |
| 43 addSource( | 43 addSource('/part.dart', ''' |
| 44 '/part.dart', | |
| 45 ''' | |
| 46 part of my.app; | 44 part of my.app; |
| 47 '''); | 45 '''); |
| 48 await indexTestUnit(''' | 46 await indexTestUnit(''' |
| 49 library my.app; | 47 library my.app; |
| 50 part 'part.dart'; | 48 part 'part.dart'; |
| 51 '''); | 49 '''); |
| 52 // configure refactoring | 50 // configure refactoring |
| 53 _createRenameRefactoring(); | 51 _createRenameRefactoring(); |
| 54 expect(refactoring.refactoringName, 'Rename Library'); | 52 expect(refactoring.refactoringName, 'Rename Library'); |
| 55 expect(refactoring.elementKindName, 'library'); | 53 expect(refactoring.elementKindName, 'library'); |
| 56 refactoring.newName = 'the.new.name'; | 54 refactoring.newName = 'the.new.name'; |
| 57 // validate change | 55 // validate change |
| 58 await assertSuccessfulRefactoring(''' | 56 await assertSuccessfulRefactoring(''' |
| 59 library the.new.name; | 57 library the.new.name; |
| 60 part 'part.dart'; | 58 part 'part.dart'; |
| 61 '''); | 59 '''); |
| 62 assertFileChangeResult( | 60 assertFileChangeResult('/part.dart', ''' |
| 63 '/part.dart', | |
| 64 ''' | |
| 65 part of the.new.name; | 61 part of the.new.name; |
| 66 '''); | 62 '''); |
| 67 } | 63 } |
| 68 | 64 |
| 69 test_createChange_hasWhitespaces() async { | 65 test_createChange_hasWhitespaces() async { |
| 70 addSource( | 66 addSource('/part.dart', ''' |
| 71 '/part.dart', | |
| 72 ''' | |
| 73 part of my . app; | 67 part of my . app; |
| 74 '''); | 68 '''); |
| 75 await indexTestUnit(''' | 69 await indexTestUnit(''' |
| 76 library my . app; | 70 library my . app; |
| 77 part 'part.dart'; | 71 part 'part.dart'; |
| 78 '''); | 72 '''); |
| 79 // configure refactoring | 73 // configure refactoring |
| 80 _createRenameRefactoring(); | 74 _createRenameRefactoring(); |
| 81 expect(refactoring.refactoringName, 'Rename Library'); | 75 expect(refactoring.refactoringName, 'Rename Library'); |
| 82 expect(refactoring.elementKindName, 'library'); | 76 expect(refactoring.elementKindName, 'library'); |
| 83 refactoring.newName = 'the.new.name'; | 77 refactoring.newName = 'the.new.name'; |
| 84 // validate change | 78 // validate change |
| 85 await assertSuccessfulRefactoring(''' | 79 await assertSuccessfulRefactoring(''' |
| 86 library the.new.name; | 80 library the.new.name; |
| 87 part 'part.dart'; | 81 part 'part.dart'; |
| 88 '''); | 82 '''); |
| 89 assertFileChangeResult( | 83 assertFileChangeResult('/part.dart', ''' |
| 90 '/part.dart', | |
| 91 ''' | |
| 92 part of the.new.name; | 84 part of the.new.name; |
| 93 '''); | 85 '''); |
| 94 } | 86 } |
| 95 | 87 |
| 96 void _createRenameRefactoring() { | 88 void _createRenameRefactoring() { |
| 97 createRenameRefactoringForElement(testUnitElement.library); | 89 createRenameRefactoringForElement(testUnitElement.library); |
| 98 } | 90 } |
| 99 } | 91 } |
| OLD | NEW |