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/services/refactoring/move_file_test.dart

Issue 2975253002: Format analyzer, analysis_server, analyzer_plugin, front_end and kernel with the latest dartfmt. (Closed)
Patch Set: Created 3 years, 5 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
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 import 'dart:async'; 5 import 'dart:async';
6 6
7 import 'package:analysis_server/src/services/refactoring/refactoring.dart'; 7 import 'package:analysis_server/src/services/refactoring/refactoring.dart';
8 import 'package:test/test.dart'; 8 import 'package:test/test.dart';
9 import 'package:test_reflective_loader/test_reflective_loader.dart'; 9 import 'package:test_reflective_loader/test_reflective_loader.dart';
10 10
(...skipping 29 matching lines...) Expand all
40 export '333/d.dart'; 40 export '333/d.dart';
41 part 'a.dart'; 41 part 'a.dart';
42 part '/absolute/uri.dart'; 42 part '/absolute/uri.dart';
43 '''); 43 ''');
44 // perform refactoring 44 // perform refactoring
45 _createRefactoring('/project/000/1111/22/new_name.dart'); 45 _createRefactoring('/project/000/1111/22/new_name.dart');
46 await _assertSuccessfulRefactoring(); 46 await _assertSuccessfulRefactoring();
47 assertNoFileChange(pathA); 47 assertNoFileChange(pathA);
48 assertFileChangeResult(pathB, "import '22/new_name.dart';"); 48 assertFileChangeResult(pathB, "import '22/new_name.dart';");
49 assertNoFileChange(pathC); 49 assertNoFileChange(pathC);
50 assertFileChangeResult( 50 assertFileChangeResult(testFile, '''
51 testFile,
52 '''
53 library lib; 51 library lib;
54 import 'dart:math'; 52 import 'dart:math';
55 import 'c.dart'; 53 import 'c.dart';
56 export '../333/d.dart'; 54 export '../333/d.dart';
57 part '../a.dart'; 55 part '../a.dart';
58 part '/absolute/uri.dart'; 56 part '/absolute/uri.dart';
59 '''); 57 ''');
60 } 58 }
61 59
62 @failingTest 60 @failingTest
63 test_file_importedLibrary() async { 61 test_file_importedLibrary() async {
64 fail('The move file refactoring is not supported under the new driver'); 62 fail('The move file refactoring is not supported under the new driver');
65 String pathA = '/project/000/1111/a.dart'; 63 String pathA = '/project/000/1111/a.dart';
66 testFile = '/project/000/1111/sub/folder/test.dart'; 64 testFile = '/project/000/1111/sub/folder/test.dart';
67 addSource( 65 addSource(pathA, '''
68 pathA,
69 '''
70 import 'sub/folder/test.dart'; 66 import 'sub/folder/test.dart';
71 '''); 67 ''');
72 addTestSource(''); 68 addTestSource('');
73 // perform refactoring 69 // perform refactoring
74 _createRefactoring('/project/000/new/folder/name/new_name.dart'); 70 _createRefactoring('/project/000/new/folder/name/new_name.dart');
75 await _assertSuccessfulRefactoring(); 71 await _assertSuccessfulRefactoring();
76 assertFileChangeResult( 72 assertFileChangeResult(pathA, '''
77 pathA,
78 '''
79 import '../new/folder/name/new_name.dart'; 73 import '../new/folder/name/new_name.dart';
80 '''); 74 ''');
81 assertNoFileChange(testFile); 75 assertNoFileChange(testFile);
82 } 76 }
83 77
84 @failingTest 78 @failingTest
85 test_file_importedLibrary_down() async { 79 test_file_importedLibrary_down() async {
86 fail('The move file refactoring is not supported under the new driver'); 80 fail('The move file refactoring is not supported under the new driver');
87 String pathA = '/project/000/1111/a.dart'; 81 String pathA = '/project/000/1111/a.dart';
88 testFile = '/project/000/1111/test.dart'; 82 testFile = '/project/000/1111/test.dart';
89 addSource( 83 addSource(pathA, '''
90 pathA,
91 '''
92 import 'test.dart'; 84 import 'test.dart';
93 '''); 85 ''');
94 addTestSource(''); 86 addTestSource('');
95 // perform refactoring 87 // perform refactoring
96 _createRefactoring('/project/000/1111/22/new_name.dart'); 88 _createRefactoring('/project/000/1111/22/new_name.dart');
97 await _assertSuccessfulRefactoring(); 89 await _assertSuccessfulRefactoring();
98 assertFileChangeResult( 90 assertFileChangeResult(pathA, '''
99 pathA,
100 '''
101 import '22/new_name.dart'; 91 import '22/new_name.dart';
102 '''); 92 ''');
103 assertNoFileChange(testFile); 93 assertNoFileChange(testFile);
104 } 94 }
105 95
106 @failingTest 96 @failingTest
107 test_file_importedLibrary_package() async { 97 test_file_importedLibrary_package() async {
108 fail('The move file refactoring is not supported under the new driver'); 98 fail('The move file refactoring is not supported under the new driver');
109 // configure packages 99 // configure packages
110 testFile = '/packages/my_pkg/lib/aaa/test.dart'; 100 testFile = '/packages/my_pkg/lib/aaa/test.dart';
111 provider.newFile(testFile, ''); 101 provider.newFile(testFile, '');
112 // TODO(brianwilkerson) Figure out what this should be replaced with. 102 // TODO(brianwilkerson) Figure out what this should be replaced with.
113 // Map<String, List<Folder>> packageMap = { 103 // Map<String, List<Folder>> packageMap = {
114 // 'my_pkg': <Folder>[provider.getResource('/packages/my_pkg/lib')] 104 // 'my_pkg': <Folder>[provider.getResource('/packages/my_pkg/lib')]
115 // }; 105 // };
116 // context.sourceFactory = new SourceFactory([ 106 // context.sourceFactory = new SourceFactory([
117 // new DartUriResolver(sdk), 107 // new DartUriResolver(sdk),
118 // new PackageMapUriResolver(provider, packageMap), 108 // new PackageMapUriResolver(provider, packageMap),
119 // resourceResolver 109 // resourceResolver
120 // ]); 110 // ]);
121 // do testing 111 // do testing
122 String pathA = '/project/bin/a.dart'; 112 String pathA = '/project/bin/a.dart';
123 addSource( 113 addSource(pathA, '''
124 pathA,
125 '''
126 import 'package:my_pkg/aaa/test.dart'; 114 import 'package:my_pkg/aaa/test.dart';
127 '''); 115 ''');
128 addTestSource('', Uri.parse('package:my_pkg/aaa/test.dart')); 116 addTestSource('', Uri.parse('package:my_pkg/aaa/test.dart'));
129 // perform refactoring 117 // perform refactoring
130 _createRefactoring('/packages/my_pkg/lib/bbb/ccc/new_name.dart'); 118 _createRefactoring('/packages/my_pkg/lib/bbb/ccc/new_name.dart');
131 await _assertSuccessfulRefactoring(); 119 await _assertSuccessfulRefactoring();
132 assertFileChangeResult( 120 assertFileChangeResult(pathA, '''
133 pathA,
134 '''
135 import 'package:my_pkg/bbb/ccc/new_name.dart'; 121 import 'package:my_pkg/bbb/ccc/new_name.dart';
136 '''); 122 ''');
137 assertNoFileChange(testFile); 123 assertNoFileChange(testFile);
138 } 124 }
139 125
140 @failingTest 126 @failingTest
141 test_file_importedLibrary_up() async { 127 test_file_importedLibrary_up() async {
142 fail('The move file refactoring is not supported under the new driver'); 128 fail('The move file refactoring is not supported under the new driver');
143 String pathA = '/project/000/1111/a.dart'; 129 String pathA = '/project/000/1111/a.dart';
144 testFile = '/project/000/1111/22/test.dart'; 130 testFile = '/project/000/1111/22/test.dart';
145 addSource( 131 addSource(pathA, '''
146 pathA,
147 '''
148 import '22/test.dart'; 132 import '22/test.dart';
149 '''); 133 ''');
150 addTestSource(''); 134 addTestSource('');
151 // perform refactoring 135 // perform refactoring
152 _createRefactoring('/project/000/1111/new_name.dart'); 136 _createRefactoring('/project/000/1111/new_name.dart');
153 await _assertSuccessfulRefactoring(); 137 await _assertSuccessfulRefactoring();
154 assertFileChangeResult( 138 assertFileChangeResult(pathA, '''
155 pathA,
156 '''
157 import 'new_name.dart'; 139 import 'new_name.dart';
158 '''); 140 ''');
159 assertNoFileChange(testFile); 141 assertNoFileChange(testFile);
160 } 142 }
161 143
162 @failingTest 144 @failingTest
163 test_file_sourcedUnit() async { 145 test_file_sourcedUnit() async {
164 fail('The move file refactoring is not supported under the new driver'); 146 fail('The move file refactoring is not supported under the new driver');
165 String pathA = '/project/000/1111/a.dart'; 147 String pathA = '/project/000/1111/a.dart';
166 testFile = '/project/000/1111/22/test.dart'; 148 testFile = '/project/000/1111/22/test.dart';
167 addSource( 149 addSource(pathA, '''
168 pathA,
169 '''
170 library lib; 150 library lib;
171 part '22/test.dart'; 151 part '22/test.dart';
172 '''); 152 ''');
173 addTestSource(''' 153 addTestSource('''
174 part of lib; 154 part of lib;
175 '''); 155 ''');
176 // perform refactoring 156 // perform refactoring
177 _createRefactoring('/project/000/1111/22/new_name.dart'); 157 _createRefactoring('/project/000/1111/22/new_name.dart');
178 await _assertSuccessfulRefactoring(); 158 await _assertSuccessfulRefactoring();
179 assertFileChangeResult( 159 assertFileChangeResult(pathA, '''
180 pathA,
181 '''
182 library lib; 160 library lib;
183 part '22/new_name.dart'; 161 part '22/new_name.dart';
184 '''); 162 ''');
185 assertNoFileChange(testFile); 163 assertNoFileChange(testFile);
186 } 164 }
187 165
188 @failingTest 166 @failingTest
189 test_file_sourcedUnit_multipleLibraries() async { 167 test_file_sourcedUnit_multipleLibraries() async {
190 fail('The move file refactoring is not supported under the new driver'); 168 fail('The move file refactoring is not supported under the new driver');
191 String pathA = '/project/000/1111/a.dart'; 169 String pathA = '/project/000/1111/a.dart';
192 String pathB = '/project/000/b.dart'; 170 String pathB = '/project/000/b.dart';
193 testFile = '/project/000/1111/22/test.dart'; 171 testFile = '/project/000/1111/22/test.dart';
194 addSource( 172 addSource(pathA, '''
195 pathA,
196 '''
197 library lib; 173 library lib;
198 part '22/test.dart'; 174 part '22/test.dart';
199 '''); 175 ''');
200 addSource( 176 addSource(pathB, '''
201 pathB,
202 '''
203 library lib; 177 library lib;
204 part '1111/22/test.dart'; 178 part '1111/22/test.dart';
205 '''); 179 ''');
206 addTestSource(''' 180 addTestSource('''
207 part of lib; 181 part of lib;
208 '''); 182 ''');
209 // perform refactoring 183 // perform refactoring
210 _createRefactoring('/project/000/1111/22/new_name.dart'); 184 _createRefactoring('/project/000/1111/22/new_name.dart');
211 await _assertSuccessfulRefactoring(); 185 await _assertSuccessfulRefactoring();
212 assertFileChangeResult( 186 assertFileChangeResult(pathA, '''
213 pathA,
214 '''
215 library lib; 187 library lib;
216 part '22/new_name.dart'; 188 part '22/new_name.dart';
217 '''); 189 ''');
218 assertFileChangeResult( 190 assertFileChangeResult(pathB, '''
219 pathB,
220 '''
221 library lib; 191 library lib;
222 part '1111/22/new_name.dart'; 192 part '1111/22/new_name.dart';
223 '''); 193 ''');
224 assertNoFileChange(testFile); 194 assertNoFileChange(testFile);
225 } 195 }
226 196
227 @failingTest 197 @failingTest
228 test_project() async { 198 test_project() async {
229 fail('The move file refactoring is not supported under the new driver'); 199 fail('The move file refactoring is not supported under the new driver');
230 String pubspecPath = '/testName/pubspec.yaml'; 200 String pubspecPath = '/testName/pubspec.yaml';
231 String appPath = '/testName/bin/myApp.dart'; 201 String appPath = '/testName/bin/myApp.dart';
232 provider.newFile( 202 provider.newFile(pubspecPath, '''
233 pubspecPath,
234 '''
235 name: testName 203 name: testName
236 version: 0.0.1 204 version: 0.0.1
237 description: My pubspec file. 205 description: My pubspec file.
238 '''); 206 ''');
239 addSource('/testName/lib/myLib.dart', ''); 207 addSource('/testName/lib/myLib.dart', '');
240 addSource( 208 addSource(appPath, '''
241 appPath,
242 '''
243 import 'package:testName/myLib.dart'; 209 import 'package:testName/myLib.dart';
244 export 'package:testName/myLib.dart'; 210 export 'package:testName/myLib.dart';
245 '''); 211 ''');
246 // configure Uri resolves 212 // configure Uri resolves
247 // TODO(brianwilkerson) Figure out what this should be replaced with. 213 // TODO(brianwilkerson) Figure out what this should be replaced with.
248 // context.sourceFactory = new SourceFactory([ 214 // context.sourceFactory = new SourceFactory([
249 // new DartUriResolver(sdk), 215 // new DartUriResolver(sdk),
250 // new PackageMapUriResolver(provider, <String, List<Folder>>{ 216 // new PackageMapUriResolver(provider, <String, List<Folder>>{
251 // 'testName': <Folder>[provider.getResource('/testName/lib')] 217 // 'testName': <Folder>[provider.getResource('/testName/lib')]
252 // }), 218 // }),
253 // resourceResolver, 219 // resourceResolver,
254 // ]); 220 // ]);
255 // perform refactoring 221 // perform refactoring
256 refactoring = new MoveFileRefactoring( 222 refactoring = new MoveFileRefactoring(
257 provider, searchEngine, null, null, '/testName'); 223 provider, searchEngine, null, null, '/testName');
258 refactoring.newFile = '/newName'; 224 refactoring.newFile = '/newName';
259 await _assertSuccessfulRefactoring(); 225 await _assertSuccessfulRefactoring();
260 assertFileChangeResult( 226 assertFileChangeResult(pubspecPath, '''
261 pubspecPath,
262 '''
263 name: newName 227 name: newName
264 version: 0.0.1 228 version: 0.0.1
265 description: My pubspec file. 229 description: My pubspec file.
266 '''); 230 ''');
267 assertFileChangeResult( 231 assertFileChangeResult(appPath, '''
268 appPath,
269 '''
270 import 'package:newName/myLib.dart'; 232 import 'package:newName/myLib.dart';
271 export 'package:newName/myLib.dart'; 233 export 'package:newName/myLib.dart';
272 '''); 234 ''');
273 } 235 }
274 236
275 /** 237 /**
276 * Checks that all conditions are OK. 238 * Checks that all conditions are OK.
277 */ 239 */
278 Future _assertSuccessfulRefactoring() async { 240 Future _assertSuccessfulRefactoring() async {
279 await assertRefactoringConditionsOK(); 241 await assertRefactoringConditionsOK();
280 refactoringChange = await refactoring.createChange(); 242 refactoringChange = await refactoring.createChange();
281 } 243 }
282 244
283 void _createRefactoring(String newName) { 245 void _createRefactoring(String newName) {
284 refactoring = 246 refactoring =
285 new MoveFileRefactoring(provider, searchEngine, null, testSource, null); 247 new MoveFileRefactoring(provider, searchEngine, null, testSource, null);
286 refactoring.newFile = newName; 248 refactoring.newFile = newName;
287 } 249 }
288 } 250 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698