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

Side by Side Diff: pkg/analysis_server/test/context_directory_manager_test.dart

Issue 340773005: Add support for adding/removing pubspec.yaml files. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 6 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.context.directory.manager; 5 library test.context.directory.manager;
6 6
7 import 'mocks.dart'; 7 import 'mocks.dart';
8 import 'package:analysis_server/src/context_directory_manager.dart'; 8 import 'package:analysis_server/src/context_directory_manager.dart';
9 import 'package:analysis_server/src/resource.dart'; 9 import 'package:analysis_server/src/resource.dart';
10 import 'package:path/path.dart'; 10 import 'package:path/path.dart';
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after
182 Map<String, int> filePaths = manager.currentContextFilePaths[projPath]; 182 Map<String, int> filePaths = manager.currentContextFilePaths[projPath];
183 expect(filePaths, hasLength(0)); 183 expect(filePaths, hasLength(0));
184 String filePath = posix.join(projPath, 'foo', 'bar.dart'); 184 String filePath = posix.join(projPath, 'foo', 'bar.dart');
185 provider.newFile(filePath, 'contents'); 185 provider.newFile(filePath, 'contents');
186 return pumpEventQueue().then((_) { 186 return pumpEventQueue().then((_) {
187 expect(filePaths, hasLength(1)); 187 expect(filePaths, hasLength(1));
188 expect(filePaths, contains(filePath)); 188 expect(filePaths, contains(filePath));
189 }); 189 });
190 }); 190 });
191 191
192 test('Add pubspec file', () {
193 manager.setRoots(<String>[projPath], <String>[]);
194 String pubspecPath = posix.join(projPath, 'pubspec.yaml');
195 expect(manager.currentContextPubspecPaths[projPath], isNull);
196 provider.newFile(pubspecPath, 'pubspec');
197 return pumpEventQueue().then((_) {
198 expect(manager.currentContextPubspecPaths[projPath], equals(pubspecPat h));
199 });
200 });
201
192 test('Delete file', () { 202 test('Delete file', () {
193 String filePath = posix.join(projPath, 'foo.dart'); 203 String filePath = posix.join(projPath, 'foo.dart');
194 provider.newFile(filePath, 'contents'); 204 provider.newFile(filePath, 'contents');
195 manager.setRoots(<String>[projPath], <String>[]); 205 manager.setRoots(<String>[projPath], <String>[]);
196 Map<String, int> filePaths = manager.currentContextFilePaths[projPath]; 206 Map<String, int> filePaths = manager.currentContextFilePaths[projPath];
197 expect(filePaths, hasLength(1)); 207 expect(filePaths, hasLength(1));
198 expect(filePaths, contains(filePath)); 208 expect(filePaths, contains(filePath));
199 provider.deleteFile(filePath); 209 provider.deleteFile(filePath);
200 return pumpEventQueue().then((_) => expect(filePaths, hasLength(0))); 210 return pumpEventQueue().then((_) => expect(filePaths, hasLength(0)));
201 }); 211 });
202 212
213 test('Delete pubspec file', () {
214 String pubspecPath = posix.join(projPath, 'pubspec.yaml');
215 provider.newFile(pubspecPath, 'pubspec');
216 manager.setRoots(<String>[projPath], <String>[]);
217 expect(manager.currentContextPubspecPaths[projPath], equals(pubspecPath) );
218 provider.deleteFile(pubspecPath);
219 return pumpEventQueue().then((_) {
220 expect(manager.currentContextPubspecPaths[projPath], isNull);
221 });
222 });
223
203 test('Modify file', () { 224 test('Modify file', () {
204 String filePath = posix.join(projPath, 'foo.dart'); 225 String filePath = posix.join(projPath, 'foo.dart');
205 provider.newFile(filePath, 'contents'); 226 provider.newFile(filePath, 'contents');
206 manager.setRoots(<String>[projPath], <String>[]); 227 manager.setRoots(<String>[projPath], <String>[]);
207 Map<String, int> filePaths = manager.currentContextFilePaths[projPath]; 228 Map<String, int> filePaths = manager.currentContextFilePaths[projPath];
208 expect(filePaths, hasLength(1)); 229 expect(filePaths, hasLength(1));
209 expect(filePaths, contains(filePath)); 230 expect(filePaths, contains(filePath));
210 expect(filePaths[filePath], equals(manager.now)); 231 expect(filePaths[filePath], equals(manager.now));
211 manager.now++; 232 manager.now++;
212 provider.modifyFile(filePath, 'new contents'); 233 provider.modifyFile(filePath, 'new contents');
213 return pumpEventQueue().then((_) => expect(filePaths[filePath], equals( 234 return pumpEventQueue().then((_) => expect(filePaths[filePath], equals(
214 manager.now))); 235 manager.now)));
215 }); 236 });
216 }); 237 });
217 }); 238 });
218 } 239 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698