| 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.model_test; | 5 library test.src.task.model_test; |
| 6 | 6 |
| 7 import 'package:analyzer/src/generated/engine.dart' hide AnalysisTask; | 7 import 'package:analyzer/src/generated/engine.dart' hide AnalysisTask; |
| 8 import 'package:analyzer/src/generated/java_engine.dart'; | 8 import 'package:analyzer/src/generated/java_engine.dart'; |
| 9 import 'package:analyzer/src/task/model.dart'; | 9 import 'package:analyzer/src/task/model.dart'; |
| 10 import 'package:analyzer/task/model.dart'; | 10 import 'package:analyzer/task/model.dart'; |
| 11 import 'package:unittest/unittest.dart'; | 11 import 'package:unittest/unittest.dart'; |
| 12 | 12 |
| 13 import '../../generated/test_support.dart'; | 13 import '../../generated/test_support.dart'; |
| 14 import '../../reflective_tests.dart'; | 14 import '../../reflective_tests.dart'; |
| 15 import 'test_support.dart'; | 15 import 'test_support.dart'; |
| 16 | 16 |
| 17 main() { | 17 main() { |
| 18 groupSep = ' | '; | 18 groupSep = ' | '; |
| 19 runReflectiveTests(AnalysisTaskTest); | 19 runReflectiveTests(AnalysisTaskTest); |
| 20 runReflectiveTests(ContributionPointImplTest); | |
| 21 runReflectiveTests(ResultDescriptorImplTest); | 20 runReflectiveTests(ResultDescriptorImplTest); |
| 22 runReflectiveTests(SimpleResultCachingPolicyTest); | 21 runReflectiveTests(SimpleResultCachingPolicyTest); |
| 23 runReflectiveTests(TaskDescriptorImplTest); | 22 runReflectiveTests(TaskDescriptorImplTest); |
| 24 } | 23 } |
| 25 | 24 |
| 26 @reflectiveTest | 25 @reflectiveTest |
| 27 class AnalysisTaskTest extends EngineTestCase { | 26 class AnalysisTaskTest extends EngineTestCase { |
| 28 test_getRequiredInput_missingKey() { | 27 test_getRequiredInput_missingKey() { |
| 29 AnalysisTarget target = new TestSource(); | 28 AnalysisTarget target = new TestSource(); |
| 30 AnalysisTask task = new TestAnalysisTask(null, target); | 29 AnalysisTask task = new TestAnalysisTask(null, target); |
| (...skipping 19 matching lines...) Expand all Loading... |
| 50 } | 49 } |
| 51 | 50 |
| 52 test_getRequiredSource() { | 51 test_getRequiredSource() { |
| 53 AnalysisTarget target = new TestSource(); | 52 AnalysisTarget target = new TestSource(); |
| 54 AnalysisTask task = new TestAnalysisTask(null, target); | 53 AnalysisTask task = new TestAnalysisTask(null, target); |
| 55 expect(task.getRequiredSource(), target); | 54 expect(task.getRequiredSource(), target); |
| 56 } | 55 } |
| 57 } | 56 } |
| 58 | 57 |
| 59 @reflectiveTest | 58 @reflectiveTest |
| 60 class ContributionPointImplTest extends EngineTestCase { | |
| 61 test_contributors_empty() { | |
| 62 CompositeResultDescriptorImpl point = | |
| 63 new CompositeResultDescriptorImpl('point'); | |
| 64 List<ResultDescriptor> contributors = point.contributors; | |
| 65 expect(contributors, isEmpty); | |
| 66 } | |
| 67 | |
| 68 test_contributors_nonEmpty() { | |
| 69 ResultDescriptorImpl result1 = new ResultDescriptorImpl('result1', null); | |
| 70 ResultDescriptorImpl result2 = new ResultDescriptorImpl('result2', null); | |
| 71 CompositeResultDescriptorImpl point = | |
| 72 new CompositeResultDescriptorImpl('point'); | |
| 73 point.recordContributor(result1); | |
| 74 point.recordContributor(result2); | |
| 75 List<ResultDescriptor> contributors = point.contributors; | |
| 76 expect(contributors, isNotNull); | |
| 77 expect(contributors, hasLength(2)); | |
| 78 if (!(contributors[0] == result1 && contributors[1] == result2) || | |
| 79 (contributors[0] == result2 && contributors[1] == result1)) { | |
| 80 fail("Invalid contributors: $contributors"); | |
| 81 } | |
| 82 } | |
| 83 | |
| 84 test_create() { | |
| 85 expect(new CompositeResultDescriptorImpl('name'), isNotNull); | |
| 86 } | |
| 87 | |
| 88 test_name() { | |
| 89 String name = 'point'; | |
| 90 CompositeResultDescriptorImpl point = | |
| 91 new CompositeResultDescriptorImpl(name); | |
| 92 expect(point.name, name); | |
| 93 } | |
| 94 } | |
| 95 | |
| 96 @reflectiveTest | |
| 97 class ResultDescriptorImplTest extends EngineTestCase { | 59 class ResultDescriptorImplTest extends EngineTestCase { |
| 98 test_create_withCachingPolicy() { | 60 test_create_withCachingPolicy() { |
| 99 ResultCachingPolicy policy = new SimpleResultCachingPolicy(128, 16); | 61 ResultCachingPolicy policy = new SimpleResultCachingPolicy(128, 16); |
| 100 ResultDescriptorImpl result = | 62 ResultDescriptorImpl result = |
| 101 new ResultDescriptorImpl('result', null, cachingPolicy: policy); | 63 new ResultDescriptorImpl('result', null, cachingPolicy: policy); |
| 102 expect(result.cachingPolicy, same(policy)); | 64 expect(result.cachingPolicy, same(policy)); |
| 103 } | 65 } |
| 104 | 66 |
| 105 test_create_withContribution() { | |
| 106 CompositeResultDescriptorImpl point = | |
| 107 new CompositeResultDescriptorImpl('point'); | |
| 108 ResultDescriptorImpl result = | |
| 109 new ResultDescriptorImpl('result', null, contributesTo: point); | |
| 110 expect(result, isNotNull); | |
| 111 List<ResultDescriptor> contributors = point.contributors; | |
| 112 expect(contributors, unorderedEquals([result])); | |
| 113 } | |
| 114 | |
| 115 test_create_withoutCachingPolicy() { | 67 test_create_withoutCachingPolicy() { |
| 116 ResultDescriptorImpl result = new ResultDescriptorImpl('result', null); | 68 ResultDescriptorImpl result = new ResultDescriptorImpl('result', null); |
| 117 ResultCachingPolicy cachingPolicy = result.cachingPolicy; | 69 ResultCachingPolicy cachingPolicy = result.cachingPolicy; |
| 118 expect(cachingPolicy, isNotNull); | 70 expect(cachingPolicy, isNotNull); |
| 119 expect(cachingPolicy.maxActiveSize, -1); | 71 expect(cachingPolicy.maxActiveSize, -1); |
| 120 expect(cachingPolicy.maxIdleSize, -1); | 72 expect(cachingPolicy.maxIdleSize, -1); |
| 121 } | 73 } |
| 122 | 74 |
| 123 test_create_withoutContribution() { | 75 test_create_withoutContribution() { |
| 124 expect(new ResultDescriptorImpl('name', null), isNotNull); | 76 expect(new ResultDescriptorImpl('name', null), isNotNull); |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 177 String inputMemento = 'main() {}'; | 129 String inputMemento = 'main() {}'; |
| 178 AnalysisTask createTask = | 130 AnalysisTask createTask = |
| 179 descriptor.createTask(context, target, inputs, inputMemento); | 131 descriptor.createTask(context, target, inputs, inputMemento); |
| 180 expect(createTask, isNotNull); | 132 expect(createTask, isNotNull); |
| 181 expect(createTask.context, context); | 133 expect(createTask.context, context); |
| 182 expect(createTask.inputs, inputs); | 134 expect(createTask.inputs, inputs); |
| 183 expect(createTask.inputMemento, inputMemento); | 135 expect(createTask.inputMemento, inputMemento); |
| 184 expect(createTask.target, target); | 136 expect(createTask.target, target); |
| 185 } | 137 } |
| 186 } | 138 } |
| OLD | NEW |