| 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.driver_test; | 5 library test.src.task.driver_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 hide | 9 hide |
| 10 AnalysisCache, | 10 AnalysisCache, |
| (...skipping 10 matching lines...) Expand all Loading... |
| 21 import 'package:unittest/unittest.dart'; | 21 import 'package:unittest/unittest.dart'; |
| 22 | 22 |
| 23 import '../../generated/test_support.dart'; | 23 import '../../generated/test_support.dart'; |
| 24 import '../../reflective_tests.dart'; | 24 import '../../reflective_tests.dart'; |
| 25 import 'test_support.dart'; | 25 import 'test_support.dart'; |
| 26 | 26 |
| 27 main() { | 27 main() { |
| 28 groupSep = ' | '; | 28 groupSep = ' | '; |
| 29 runReflectiveTests(AnalysisDriverTest); | 29 runReflectiveTests(AnalysisDriverTest); |
| 30 runReflectiveTests(CycleAwareDependencyWalkerTest); | 30 runReflectiveTests(CycleAwareDependencyWalkerTest); |
| 31 runReflectiveTests(WorkItemTest); |
| 31 runReflectiveTests(WorkOrderTest); | 32 runReflectiveTests(WorkOrderTest); |
| 32 runReflectiveTests(WorkItemTest); | |
| 33 } | 33 } |
| 34 | 34 |
| 35 class AbstractDriverTest { | 35 class AbstractDriverTest { |
| 36 TaskManager taskManager = new TaskManager(); | 36 TaskManager taskManager = new TaskManager(); |
| 37 List<WorkManager> workManagers = <WorkManager>[]; | 37 List<WorkManager> workManagers = <WorkManager>[]; |
| 38 InternalAnalysisContext context = new _InternalAnalysisContextMock(); | 38 InternalAnalysisContext context = new _InternalAnalysisContextMock(); |
| 39 AnalysisDriver analysisDriver; | 39 AnalysisDriver analysisDriver; |
| 40 | 40 |
| 41 void setUp() { | 41 void setUp() { |
| 42 context = new _InternalAnalysisContextMock(); | 42 context = new _InternalAnalysisContextMock(); |
| (...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 325 expect(context.getCacheEntry(target).getValue(resultA), 10); | 325 expect(context.getCacheEntry(target).getValue(resultA), 10); |
| 326 expect(context.getCacheEntry(target).getValue(resultB), -2); | 326 expect(context.getCacheEntry(target).getValue(resultB), -2); |
| 327 // compute resultB | 327 // compute resultB |
| 328 expect(analysisDriver.performAnalysisTask(), true); | 328 expect(analysisDriver.performAnalysisTask(), true); |
| 329 expect(context.getCacheEntry(target).getValue(resultA), 10); | 329 expect(context.getCacheEntry(target).getValue(resultA), 10); |
| 330 expect(context.getCacheEntry(target).getValue(resultB), 20); | 330 expect(context.getCacheEntry(target).getValue(resultB), 20); |
| 331 // done | 331 // done |
| 332 expect(analysisDriver.performAnalysisTask(), false); | 332 expect(analysisDriver.performAnalysisTask(), false); |
| 333 } | 333 } |
| 334 | 334 |
| 335 test_performAnalysisTask_onResultComputed() { |
| 336 AnalysisTarget target = new TestSource(); |
| 337 ResultDescriptor result = new ResultDescriptor('result', null); |
| 338 TestAnalysisTask task; |
| 339 TaskDescriptor descriptor = new TaskDescriptor( |
| 340 'task', (context, target) => task, (target) => {}, [result]); |
| 341 task = new TestAnalysisTask(context, target, |
| 342 descriptor: descriptor, value: 42); |
| 343 WorkItem item = new WorkItem(context, target, descriptor, null); |
| 344 |
| 345 bool streamNotified = false; |
| 346 analysisDriver.onResultComputed(result).listen((event) { |
| 347 streamNotified = true; |
| 348 expect(event.context, same(context)); |
| 349 expect(event.target, same(target)); |
| 350 expect(event.descriptor, same(result)); |
| 351 expect(event.value, 42); |
| 352 }); |
| 353 analysisDriver.performWorkItem(item); |
| 354 expect(streamNotified, isTrue); |
| 355 } |
| 356 |
| 335 test_performWorkItem_exceptionInTask() { | 357 test_performWorkItem_exceptionInTask() { |
| 336 AnalysisTarget target = new TestSource(); | 358 AnalysisTarget target = new TestSource(); |
| 337 ResultDescriptor result = new ResultDescriptor('result', null); | 359 ResultDescriptor result = new ResultDescriptor('result', null); |
| 338 CaughtException exception = | 360 CaughtException exception = |
| 339 new CaughtException(new AnalysisException(), null); | 361 new CaughtException(new AnalysisException(), null); |
| 340 TestAnalysisTask task; | 362 TestAnalysisTask task; |
| 341 TaskDescriptor descriptor = new TaskDescriptor( | 363 TaskDescriptor descriptor = new TaskDescriptor( |
| 342 'task', (context, target) => task, (target) => {}, [result]); | 364 'task', (context, target) => task, (target) => {}, [result]); |
| 343 task = new TestAnalysisTask(context, target, | 365 task = new TestAnalysisTask(context, target, |
| 344 descriptor: descriptor, exception: exception); | 366 descriptor: descriptor, exception: exception); |
| (...skipping 335 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 680 return dependency; | 702 return dependency; |
| 681 } | 703 } |
| 682 } | 704 } |
| 683 return null; | 705 return null; |
| 684 } | 706 } |
| 685 } | 707 } |
| 686 | 708 |
| 687 class _WorkManagerMock extends TypedMock implements WorkManager { | 709 class _WorkManagerMock extends TypedMock implements WorkManager { |
| 688 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation); | 710 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation); |
| 689 } | 711 } |
| OLD | NEW |