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 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
183 expect_librarySourceQueue([source2]); | 183 expect_librarySourceQueue([source2]); |
184 } | 184 } |
185 | 185 |
186 void test_getNextResult_hasLibraries_nothingToDo() { | 186 void test_getNextResult_hasLibraries_nothingToDo() { |
187 manager.librarySources.addAll([source1]); | 187 manager.librarySources.addAll([source1]); |
188 manager.partSources.addAll([source2]); | 188 manager.partSources.addAll([source2]); |
189 TargetedResult request = manager.getNextResult(); | 189 TargetedResult request = manager.getNextResult(); |
190 expect(request, isNull); | 190 expect(request, isNull); |
191 } | 191 } |
192 | 192 |
| 193 void test_getNextResult_hasPriority_firstIsError() { |
| 194 manager.addPriorityResult(source1, SOURCE_KIND); |
| 195 manager.addPriorityResult(source2, SOURCE_KIND); |
| 196 expect(manager.priorityResultQueue, unorderedEquals([ |
| 197 new TargetedResult(source1, SOURCE_KIND), |
| 198 new TargetedResult(source2, SOURCE_KIND) |
| 199 ])); |
| 200 // configure state and get next result |
| 201 entry1.setErrorState(caughtException, [SOURCE_KIND]); |
| 202 TargetedResult request = manager.getNextResult(); |
| 203 expect(request.target, source2); |
| 204 expect(request.result, SOURCE_KIND); |
| 205 // source1 is out, source2 is waiting |
| 206 expect(manager.priorityResultQueue, |
| 207 unorderedEquals([new TargetedResult(source2, SOURCE_KIND)])); |
| 208 } |
| 209 |
| 210 void test_getNextResult_hasPriority_firstIsValid() { |
| 211 manager.addPriorityResult(source1, SOURCE_KIND); |
| 212 manager.addPriorityResult(source2, SOURCE_KIND); |
| 213 expect(manager.priorityResultQueue, unorderedEquals([ |
| 214 new TargetedResult(source1, SOURCE_KIND), |
| 215 new TargetedResult(source2, SOURCE_KIND) |
| 216 ])); |
| 217 // configure state and get next result |
| 218 entry1.setValue(SOURCE_KIND, SourceKind.LIBRARY, []); |
| 219 TargetedResult request = manager.getNextResult(); |
| 220 expect(request.target, source2); |
| 221 expect(request.result, SOURCE_KIND); |
| 222 // source1 is out, source2 is waiting |
| 223 expect(manager.priorityResultQueue, |
| 224 unorderedEquals([new TargetedResult(source2, SOURCE_KIND)])); |
| 225 } |
| 226 |
193 void test_getNextResult_hasUnknown_firstIsError() { | 227 void test_getNextResult_hasUnknown_firstIsError() { |
194 entry1.setErrorState(caughtException, [SOURCE_KIND]); | 228 entry1.setErrorState(caughtException, [SOURCE_KIND]); |
195 manager.unknownSourceQueue.addAll([source1, source2]); | 229 manager.unknownSourceQueue.addAll([source1, source2]); |
196 TargetedResult request = manager.getNextResult(); | 230 TargetedResult request = manager.getNextResult(); |
197 expect(request.target, source2); | 231 expect(request.target, source2); |
198 expect(request.result, SOURCE_KIND); | 232 expect(request.result, SOURCE_KIND); |
199 // source1 is out, source2 is waiting | 233 // source1 is out, source2 is waiting |
200 expect_librarySourceQueue([]); | 234 expect_librarySourceQueue([]); |
201 expect_unknownSourceQueue([source2]); | 235 expect_unknownSourceQueue([source2]); |
202 } | 236 } |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
287 CacheEntry entry = analysisCache.get(target); | 321 CacheEntry entry = analysisCache.get(target); |
288 if (entry == null) { | 322 if (entry == null) { |
289 entry = new CacheEntry(target); | 323 entry = new CacheEntry(target); |
290 analysisCache.put(entry); | 324 analysisCache.put(entry); |
291 } | 325 } |
292 return entry; | 326 return entry; |
293 } | 327 } |
294 | 328 |
295 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation); | 329 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation); |
296 } | 330 } |
OLD | NEW |