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; |
11 import 'package:analyzer/src/generated/source.dart'; | 11 import 'package:analyzer/src/generated/source.dart'; |
12 import 'package:analyzer/src/task/dart.dart'; | 12 import 'package:analyzer/src/task/dart.dart'; |
13 import 'package:analyzer/src/task/dart_work_manager.dart'; | 13 import 'package:analyzer/src/task/dart_work_manager.dart'; |
| 14 import 'package:analyzer/src/task/driver.dart'; |
14 import 'package:analyzer/task/dart.dart'; | 15 import 'package:analyzer/task/dart.dart'; |
15 import 'package:typed_mock/typed_mock.dart'; | 16 import 'package:typed_mock/typed_mock.dart'; |
16 import 'package:unittest/unittest.dart'; | 17 import 'package:unittest/unittest.dart'; |
17 | 18 |
18 import '../../generated/test_support.dart'; | 19 import '../../generated/test_support.dart'; |
19 import '../../reflective_tests.dart'; | 20 import '../../reflective_tests.dart'; |
20 | 21 |
21 main() { | 22 main() { |
22 groupSep = ' | '; | 23 groupSep = ' | '; |
23 runReflectiveTests(DartWorkManagerTest); | 24 runReflectiveTests(DartWorkManagerTest); |
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
211 entry1.setValue(SOURCE_KIND, SourceKind.LIBRARY, []); | 212 entry1.setValue(SOURCE_KIND, SourceKind.LIBRARY, []); |
212 manager.unknownSourceQueue.addAll([source1, source2]); | 213 manager.unknownSourceQueue.addAll([source1, source2]); |
213 TargetedResult request = manager.getNextResult(); | 214 TargetedResult request = manager.getNextResult(); |
214 expect(request.target, source2); | 215 expect(request.target, source2); |
215 expect(request.result, SOURCE_KIND); | 216 expect(request.result, SOURCE_KIND); |
216 // source1 is out, source2 is waiting | 217 // source1 is out, source2 is waiting |
217 expect_librarySourceQueue([]); | 218 expect_librarySourceQueue([]); |
218 expect_unknownSourceQueue([source2]); | 219 expect_unknownSourceQueue([source2]); |
219 } | 220 } |
220 | 221 |
| 222 void test_getNextResultPriority_hasLibrary() { |
| 223 manager.librarySourceQueue.addAll([source1]); |
| 224 expect(manager.getNextResultPriority(), WorkOrderPriority.NORMAL); |
| 225 } |
| 226 |
| 227 void test_getNextResultPriority_hasUnknown() { |
| 228 manager.unknownSourceQueue.addAll([source1]); |
| 229 expect(manager.getNextResultPriority(), WorkOrderPriority.NORMAL); |
| 230 } |
| 231 |
| 232 void test_getNextResultPriority_nothingToDo() { |
| 233 expect(manager.getNextResultPriority(), WorkOrderPriority.NONE); |
| 234 } |
| 235 |
221 void test_resultsComputed_isLibrary() { | 236 void test_resultsComputed_isLibrary() { |
222 manager.unknownSourceQueue.addAll([source1, source2, source3]); | 237 manager.unknownSourceQueue.addAll([source1, source2, source3]); |
223 manager.resultsComputed(source2, {SOURCE_KIND: SourceKind.LIBRARY}); | 238 manager.resultsComputed(source2, {SOURCE_KIND: SourceKind.LIBRARY}); |
224 expect_librarySources([source2]); | 239 expect_librarySources([source2]); |
225 expect_partSources([]); | 240 expect_partSources([]); |
226 expect_librarySourceQueue([source2]); | 241 expect_librarySourceQueue([source2]); |
227 expect_unknownSourceQueue([source1, source3]); | 242 expect_unknownSourceQueue([source1, source3]); |
228 } | 243 } |
229 | 244 |
230 void test_resultsComputed_isPart() { | 245 void test_resultsComputed_isPart() { |
(...skipping 21 matching lines...) Expand all Loading... |
252 expect_partSources([]); | 267 expect_partSources([]); |
253 expect_librarySourceQueue([]); | 268 expect_librarySourceQueue([]); |
254 expect_unknownSourceQueue([source1, source2]); | 269 expect_unknownSourceQueue([source1, source2]); |
255 } | 270 } |
256 } | 271 } |
257 | 272 |
258 class _InternalAnalysisContextMock extends TypedMock | 273 class _InternalAnalysisContextMock extends TypedMock |
259 implements InternalAnalysisContext { | 274 implements InternalAnalysisContext { |
260 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation); | 275 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation); |
261 } | 276 } |
OLD | NEW |