| 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 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/package_map_provider.dart'; | 9 import 'package:analysis_server/src/package_map_provider.dart'; |
| 10 import 'package:analysis_server/src/resource.dart'; | 10 import 'package:analysis_server/src/resource.dart'; |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 126 String projPath = '/my/proj'; | 126 String projPath = '/my/proj'; |
| 127 resourceProvider.newFolder(projPath); | 127 resourceProvider.newFolder(projPath); |
| 128 String filePath = posix.join(projPath, 'foo.dart'); | 128 String filePath = posix.join(projPath, 'foo.dart'); |
| 129 resourceProvider.newFile(filePath, 'contents'); | 129 resourceProvider.newFile(filePath, 'contents'); |
| 130 manager.setRoots(<String>[projPath], <String>[]); | 130 manager.setRoots(<String>[projPath], <String>[]); |
| 131 var filePaths = manager.currentContextFilePaths[projPath]; | 131 var filePaths = manager.currentContextFilePaths[projPath]; |
| 132 expect(filePaths, hasLength(1)); | 132 expect(filePaths, hasLength(1)); |
| 133 expect(filePaths, contains(filePath)); | 133 expect(filePaths, contains(filePath)); |
| 134 }); | 134 }); |
| 135 | 135 |
| 136 test('add folder with dummy link', () { |
| 137 String projPath = '/my/proj'; |
| 138 resourceProvider.newFolder(projPath); |
| 139 String filePath = posix.join(projPath, 'foo.dart'); |
| 140 resourceProvider.newDummyLink(filePath); |
| 141 manager.setRoots(<String>[projPath], <String>[]); |
| 142 var filePaths = manager.currentContextFilePaths[projPath]; |
| 143 expect(filePaths, isEmpty); |
| 144 }); |
| 145 |
| 136 test('add folder with dart file in subdir', () { | 146 test('add folder with dart file in subdir', () { |
| 137 String projPath = '/my/proj'; | 147 String projPath = '/my/proj'; |
| 138 resourceProvider.newFolder(projPath); | 148 resourceProvider.newFolder(projPath); |
| 139 String filePath = posix.join(projPath, 'foo', 'bar.dart'); | 149 String filePath = posix.join(projPath, 'foo', 'bar.dart'); |
| 140 resourceProvider.newFile(filePath, 'contents'); | 150 resourceProvider.newFile(filePath, 'contents'); |
| 141 manager.setRoots(<String>[projPath], <String>[]); | 151 manager.setRoots(<String>[projPath], <String>[]); |
| 142 var filePaths = manager.currentContextFilePaths[projPath]; | 152 var filePaths = manager.currentContextFilePaths[projPath]; |
| 143 expect(filePaths, hasLength(1)); | 153 expect(filePaths, hasLength(1)); |
| 144 expect(filePaths, contains(filePath)); | 154 expect(filePaths, contains(filePath)); |
| 145 }); | 155 }); |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 183 }); | 193 }); |
| 184 | 194 |
| 185 group('detect context modifications', () { | 195 group('detect context modifications', () { |
| 186 String projPath; | 196 String projPath; |
| 187 | 197 |
| 188 setUp(() { | 198 setUp(() { |
| 189 projPath = '/my/proj'; | 199 projPath = '/my/proj'; |
| 190 resourceProvider.newFolder(projPath); | 200 resourceProvider.newFolder(projPath); |
| 191 }); | 201 }); |
| 192 | 202 |
| 203 test('Add dummy link', () { |
| 204 manager.setRoots(<String>[projPath], <String>[]); |
| 205 Map<String, int> filePaths = manager.currentContextFilePaths[projPath]; |
| 206 expect(filePaths, isEmpty); |
| 207 String filePath = posix.join(projPath, 'foo.dart'); |
| 208 resourceProvider.newDummyLink(filePath); |
| 209 return pumpEventQueue().then((_) { |
| 210 expect(filePaths, isEmpty); |
| 211 }); |
| 212 }); |
| 213 |
| 193 test('Add file', () { | 214 test('Add file', () { |
| 194 manager.setRoots(<String>[projPath], <String>[]); | 215 manager.setRoots(<String>[projPath], <String>[]); |
| 195 Map<String, int> filePaths = manager.currentContextFilePaths[projPath]; | 216 Map<String, int> filePaths = manager.currentContextFilePaths[projPath]; |
| 196 expect(filePaths, hasLength(0)); | 217 expect(filePaths, hasLength(0)); |
| 197 String filePath = posix.join(projPath, 'foo.dart'); | 218 String filePath = posix.join(projPath, 'foo.dart'); |
| 198 resourceProvider.newFile(filePath, 'contents'); | 219 resourceProvider.newFile(filePath, 'contents'); |
| 199 return pumpEventQueue().then((_) { | 220 return pumpEventQueue().then((_) { |
| 200 expect(filePaths, hasLength(1)); | 221 expect(filePaths, hasLength(1)); |
| 201 expect(filePaths, contains(filePath)); | 222 expect(filePaths, contains(filePath)); |
| 202 }); | 223 }); |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 279 packageMapProvider.packageMap = null; | 300 packageMapProvider.packageMap = null; |
| 280 resourceProvider.modifyFile(dependencyPath, 'new contents'); | 301 resourceProvider.modifyFile(dependencyPath, 'new contents'); |
| 281 return pumpEventQueue().then((_) { | 302 return pumpEventQueue().then((_) { |
| 282 // The package map should have been changed to null. | 303 // The package map should have been changed to null. |
| 283 expect(manager.currentContextPackageMaps[projPath], isNull); | 304 expect(manager.currentContextPackageMaps[projPath], isNull); |
| 284 }); | 305 }); |
| 285 }); | 306 }); |
| 286 }); | 307 }); |
| 287 }); | 308 }); |
| 288 } | 309 } |
| OLD | NEW |