| 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/resource.dart'; | 9 import 'package:analysis_server/src/resource.dart'; |
| 10 import 'package:path/path.dart'; | 10 import 'package:path/path.dart'; |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 90 String projPath = '/my/proj'; | 90 String projPath = '/my/proj'; |
| 91 provider.newFolder(projPath); | 91 provider.newFolder(projPath); |
| 92 String filePath = posix.join(projPath, 'foo', 'bar.dart'); | 92 String filePath = posix.join(projPath, 'foo', 'bar.dart'); |
| 93 provider.newFile(filePath, 'contents'); | 93 provider.newFile(filePath, 'contents'); |
| 94 manager.setRoots(<String>[projPath], <String>[]); | 94 manager.setRoots(<String>[projPath], <String>[]); |
| 95 var filePaths = manager.currentContextFilePaths[projPath]; | 95 var filePaths = manager.currentContextFilePaths[projPath]; |
| 96 expect(filePaths, hasLength(1)); | 96 expect(filePaths, hasLength(1)); |
| 97 expect(filePaths, contains(filePath)); | 97 expect(filePaths, contains(filePath)); |
| 98 }); | 98 }); |
| 99 | 99 |
| 100 test('ignore files in packages dir', () { |
| 101 String projPath = '/my/proj'; |
| 102 provider.newFolder(projPath); |
| 103 String pubspecPath = posix.join(projPath, 'pubspec.yaml'); |
| 104 provider.newFile(pubspecPath, 'pubspec'); |
| 105 String filePath1 = posix.join(projPath, 'packages', 'file1.dart'); |
| 106 provider.newFile(filePath1, 'contents'); |
| 107 manager.setRoots(<String>[projPath], <String>[]); |
| 108 Set<String> filePaths = manager.currentContextFilePaths[projPath]; |
| 109 expect(filePaths, hasLength(0)); |
| 110 String filePath2 = posix.join(projPath, 'packages', 'file2.dart'); |
| 111 provider.newFile(filePath2, 'contents'); |
| 112 return pumpEventQueue().then((_) { |
| 113 expect(filePaths, hasLength(0)); |
| 114 }); |
| 115 }); |
| 116 |
| 100 group('detect context modifications', () { | 117 group('detect context modifications', () { |
| 101 String projPath; | 118 String projPath; |
| 102 | 119 |
| 103 setUp(() { | 120 setUp(() { |
| 104 projPath = '/my/proj'; | 121 projPath = '/my/proj'; |
| 105 provider.newFolder(projPath); | 122 provider.newFolder(projPath); |
| 106 }); | 123 }); |
| 107 | 124 |
| 108 test('Add file', () { | 125 test('Add file', () { |
| 109 manager.setRoots(<String>[projPath], <String>[]); | 126 manager.setRoots(<String>[projPath], <String>[]); |
| (...skipping 25 matching lines...) Expand all Loading... |
| 135 manager.setRoots(<String>[projPath], <String>[]); | 152 manager.setRoots(<String>[projPath], <String>[]); |
| 136 Set<String> filePaths = manager.currentContextFilePaths[projPath]; | 153 Set<String> filePaths = manager.currentContextFilePaths[projPath]; |
| 137 expect(filePaths, hasLength(1)); | 154 expect(filePaths, hasLength(1)); |
| 138 expect(filePaths, contains(filePath)); | 155 expect(filePaths, contains(filePath)); |
| 139 provider.deleteFile(filePath); | 156 provider.deleteFile(filePath); |
| 140 return pumpEventQueue().then((_) => expect(filePaths, hasLength(0))); | 157 return pumpEventQueue().then((_) => expect(filePaths, hasLength(0))); |
| 141 }); | 158 }); |
| 142 }); | 159 }); |
| 143 }); | 160 }); |
| 144 } | 161 } |
| OLD | NEW |