OLD | NEW |
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, 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.src.task.dart_work_manager_test; | 5 library test.src.task.dart_work_manager_test; |
6 | 6 |
7 import 'package:analyzer/src/context/cache.dart'; | 7 import 'package:analyzer/src/context/cache.dart'; |
8 import 'package:analyzer/src/generated/engine.dart' | 8 import 'package:analyzer/src/generated/engine.dart' |
9 show CacheState, InternalAnalysisContext; | 9 show CacheState, InternalAnalysisContext; |
10 import 'package:analyzer/src/generated/java_engine.dart' show CaughtException; | 10 import 'package:analyzer/src/generated/java_engine.dart' show CaughtException; |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
116 entry1.setValue(SOURCE_KIND, SourceKind.LIBRARY, []); | 116 entry1.setValue(SOURCE_KIND, SourceKind.LIBRARY, []); |
117 entry2.setValue(SOURCE_KIND, SourceKind.PART, []); | 117 entry2.setValue(SOURCE_KIND, SourceKind.PART, []); |
118 entry3.setValue(SOURCE_KIND, SourceKind.LIBRARY, []); | 118 entry3.setValue(SOURCE_KIND, SourceKind.LIBRARY, []); |
119 entry1.setValue(LIBRARY_ERRORS_READY, false, []); | 119 entry1.setValue(LIBRARY_ERRORS_READY, false, []); |
120 entry3.setValue(LIBRARY_ERRORS_READY, false, []); | 120 entry3.setValue(LIBRARY_ERRORS_READY, false, []); |
121 // change source2, schedule source1 and source3 | 121 // change source2, schedule source1 and source3 |
122 manager.applyChange([], [source2], []); | 122 manager.applyChange([], [source2], []); |
123 expect_librarySourceQueue([source1, source3]); | 123 expect_librarySourceQueue([source1, source3]); |
124 } | 124 } |
125 | 125 |
| 126 void test_applyPriorityTargets_library() { |
| 127 entry1.setValue(SOURCE_KIND, SourceKind.LIBRARY, []); |
| 128 entry2.setValue(SOURCE_KIND, SourceKind.LIBRARY, []); |
| 129 entry3.setValue(SOURCE_KIND, SourceKind.LIBRARY, []); |
| 130 manager.priorityResultQueue |
| 131 .add(new TargetedResult(source1, LIBRARY_ERRORS_READY)); |
| 132 manager.priorityResultQueue |
| 133 .add(new TargetedResult(source2, LIBRARY_ERRORS_READY)); |
| 134 // -source1 +source3 |
| 135 manager.applyPriorityTargets([source2, source3]); |
| 136 expect(manager.priorityResultQueue, unorderedEquals([ |
| 137 new TargetedResult(source2, LIBRARY_ERRORS_READY), |
| 138 new TargetedResult(source3, LIBRARY_ERRORS_READY) |
| 139 ])); |
| 140 // get next request |
| 141 TargetedResult request = manager.getNextResult(); |
| 142 expect(request.target, source2); |
| 143 expect(request.result, LIBRARY_ERRORS_READY); |
| 144 } |
| 145 |
| 146 void test_applyPriorityTargets_part() { |
| 147 entry1.setValue(SOURCE_KIND, SourceKind.PART, []); |
| 148 entry2.setValue(SOURCE_KIND, SourceKind.LIBRARY, []); |
| 149 entry3.setValue(SOURCE_KIND, SourceKind.LIBRARY, []); |
| 150 // +source2 +source3 |
| 151 when(context.getLibrariesContaining(source1)) |
| 152 .thenReturn([source2, source3]); |
| 153 manager.applyPriorityTargets([source1]); |
| 154 expect(manager.priorityResultQueue, unorderedEquals([ |
| 155 new TargetedResult(source2, LIBRARY_ERRORS_READY), |
| 156 new TargetedResult(source3, LIBRARY_ERRORS_READY) |
| 157 ])); |
| 158 // get next request |
| 159 TargetedResult request = manager.getNextResult(); |
| 160 expect(request.target, source2); |
| 161 expect(request.result, LIBRARY_ERRORS_READY); |
| 162 } |
| 163 |
126 void test_getNextResult_hasLibraries_firstIsError() { | 164 void test_getNextResult_hasLibraries_firstIsError() { |
127 entry1.setErrorState(caughtException, [LIBRARY_ERRORS_READY]); | 165 entry1.setErrorState(caughtException, [LIBRARY_ERRORS_READY]); |
128 manager.librarySourceQueue.addAll([source1, source2]); | 166 manager.librarySourceQueue.addAll([source1, source2]); |
129 TargetedResult request = manager.getNextResult(); | 167 TargetedResult request = manager.getNextResult(); |
130 expect(request.target, source2); | 168 expect(request.target, source2); |
131 expect(request.result, LIBRARY_ERRORS_READY); | 169 expect(request.result, LIBRARY_ERRORS_READY); |
132 // source1 is out, source2 is waiting | 170 // source1 is out, source2 is waiting |
133 expect_librarySourceQueue([source2]); | 171 expect_librarySourceQueue([source2]); |
134 } | 172 } |
135 | 173 |
(...skipping 10 matching lines...) Expand all Loading... |
146 void test_getNextResult_hasLibraries_firstIsValid() { | 184 void test_getNextResult_hasLibraries_firstIsValid() { |
147 entry1.setValue(LIBRARY_ERRORS_READY, true, []); | 185 entry1.setValue(LIBRARY_ERRORS_READY, true, []); |
148 manager.librarySourceQueue.addAll([source1, source2]); | 186 manager.librarySourceQueue.addAll([source1, source2]); |
149 TargetedResult request = manager.getNextResult(); | 187 TargetedResult request = manager.getNextResult(); |
150 expect(request.target, source2); | 188 expect(request.target, source2); |
151 expect(request.result, LIBRARY_ERRORS_READY); | 189 expect(request.result, LIBRARY_ERRORS_READY); |
152 // source1 is out, source2 is waiting | 190 // source1 is out, source2 is waiting |
153 expect_librarySourceQueue([source2]); | 191 expect_librarySourceQueue([source2]); |
154 } | 192 } |
155 | 193 |
156 void test_getNextResult_nothingToDo() { | |
157 TargetedResult request = manager.getNextResult(); | |
158 expect(request, isNull); | |
159 } | |
160 | |
161 void test_getNextResult_hasPriority_firstIsError() { | 194 void test_getNextResult_hasPriority_firstIsError() { |
162 manager.addPriorityResult(source1, SOURCE_KIND); | 195 manager.addPriorityResult(source1, SOURCE_KIND); |
163 manager.addPriorityResult(source2, SOURCE_KIND); | 196 manager.addPriorityResult(source2, SOURCE_KIND); |
164 expect(manager.priorityResultQueue, unorderedEquals([ | 197 expect(manager.priorityResultQueue, unorderedEquals([ |
165 new TargetedResult(source1, SOURCE_KIND), | 198 new TargetedResult(source1, SOURCE_KIND), |
166 new TargetedResult(source2, SOURCE_KIND) | 199 new TargetedResult(source2, SOURCE_KIND) |
167 ])); | 200 ])); |
168 // configure state and get next result | 201 // configure state and get next result |
169 entry1.setErrorState(caughtException, [SOURCE_KIND]); | 202 entry1.setErrorState(caughtException, [SOURCE_KIND]); |
170 TargetedResult request = manager.getNextResult(); | 203 TargetedResult request = manager.getNextResult(); |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
217 entry1.setValue(SOURCE_KIND, SourceKind.LIBRARY, []); | 250 entry1.setValue(SOURCE_KIND, SourceKind.LIBRARY, []); |
218 manager.unknownSourceQueue.addAll([source1, source2]); | 251 manager.unknownSourceQueue.addAll([source1, source2]); |
219 TargetedResult request = manager.getNextResult(); | 252 TargetedResult request = manager.getNextResult(); |
220 expect(request.target, source2); | 253 expect(request.target, source2); |
221 expect(request.result, SOURCE_KIND); | 254 expect(request.result, SOURCE_KIND); |
222 // source1 is out, source2 is waiting | 255 // source1 is out, source2 is waiting |
223 expect_librarySourceQueue([]); | 256 expect_librarySourceQueue([]); |
224 expect_unknownSourceQueue([source2]); | 257 expect_unknownSourceQueue([source2]); |
225 } | 258 } |
226 | 259 |
| 260 void test_getNextResult_nothingToDo() { |
| 261 TargetedResult request = manager.getNextResult(); |
| 262 expect(request, isNull); |
| 263 } |
| 264 |
227 void test_getNextResultPriority_hasLibrary() { | 265 void test_getNextResultPriority_hasLibrary() { |
228 manager.librarySourceQueue.addAll([source1]); | 266 manager.librarySourceQueue.addAll([source1]); |
229 expect(manager.getNextResultPriority(), WorkOrderPriority.NORMAL); | 267 expect(manager.getNextResultPriority(), WorkOrderPriority.NORMAL); |
230 } | 268 } |
231 | 269 |
232 void test_getNextResultPriority_hasPriority() { | 270 void test_getNextResultPriority_hasPriority() { |
233 manager.addPriorityResult(source1, SOURCE_KIND); | 271 manager.addPriorityResult(source1, SOURCE_KIND); |
234 expect(manager.getNextResultPriority(), WorkOrderPriority.PRIORITY); | 272 expect(manager.getNextResultPriority(), WorkOrderPriority.PRIORITY); |
235 } | 273 } |
236 | 274 |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
286 CacheEntry entry = analysisCache.get(target); | 324 CacheEntry entry = analysisCache.get(target); |
287 if (entry == null) { | 325 if (entry == null) { |
288 entry = new CacheEntry(target); | 326 entry = new CacheEntry(target); |
289 analysisCache.put(entry); | 327 analysisCache.put(entry); |
290 } | 328 } |
291 return entry; | 329 return entry; |
292 } | 330 } |
293 | 331 |
294 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation); | 332 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation); |
295 } | 333 } |
OLD | NEW |