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); | 20 runReflectiveTests(ContributionPointImplTest); |
21 runReflectiveTests(ResultDescriptorImplTest); | 21 runReflectiveTests(ResultDescriptorImplTest); |
| 22 runReflectiveTests(SimpleResultCachingPolicyTest); |
22 runReflectiveTests(TaskDescriptorImplTest); | 23 runReflectiveTests(TaskDescriptorImplTest); |
23 } | 24 } |
24 | 25 |
25 @reflectiveTest | 26 @reflectiveTest |
26 class AnalysisTaskTest extends EngineTestCase { | 27 class AnalysisTaskTest extends EngineTestCase { |
27 test_getRequiredInput_missingKey() { | 28 test_getRequiredInput_missingKey() { |
28 AnalysisTarget target = new TestSource(); | 29 AnalysisTarget target = new TestSource(); |
29 AnalysisTask task = new TestAnalysisTask(null, target); | 30 AnalysisTask task = new TestAnalysisTask(null, target); |
30 task.inputs = {'a': 'b'}; | 31 task.inputs = {'a': 'b'}; |
31 expect(() => task.getRequiredInput('c'), | 32 expect(() => task.getRequiredInput('c'), |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
87 test_name() { | 88 test_name() { |
88 String name = 'point'; | 89 String name = 'point'; |
89 CompositeResultDescriptorImpl point = | 90 CompositeResultDescriptorImpl point = |
90 new CompositeResultDescriptorImpl(name); | 91 new CompositeResultDescriptorImpl(name); |
91 expect(point.name, name); | 92 expect(point.name, name); |
92 } | 93 } |
93 } | 94 } |
94 | 95 |
95 @reflectiveTest | 96 @reflectiveTest |
96 class ResultDescriptorImplTest extends EngineTestCase { | 97 class ResultDescriptorImplTest extends EngineTestCase { |
| 98 test_create_withCachingPolicy() { |
| 99 ResultCachingPolicy policy = new SimpleResultCachingPolicy(128, 16); |
| 100 ResultDescriptorImpl result = |
| 101 new ResultDescriptorImpl('result', null, cachingPolicy: policy); |
| 102 expect(result.cachingPolicy, same(policy)); |
| 103 } |
| 104 |
97 test_create_withContribution() { | 105 test_create_withContribution() { |
98 CompositeResultDescriptorImpl point = | 106 CompositeResultDescriptorImpl point = |
99 new CompositeResultDescriptorImpl('point'); | 107 new CompositeResultDescriptorImpl('point'); |
100 ResultDescriptorImpl result = | 108 ResultDescriptorImpl result = |
101 new ResultDescriptorImpl('result', null, contributesTo: point); | 109 new ResultDescriptorImpl('result', null, contributesTo: point); |
102 expect(result, isNotNull); | 110 expect(result, isNotNull); |
103 List<ResultDescriptor> contributors = point.contributors; | 111 List<ResultDescriptor> contributors = point.contributors; |
104 expect(contributors, unorderedEquals([result])); | 112 expect(contributors, unorderedEquals([result])); |
105 } | 113 } |
106 | 114 |
| 115 test_create_withoutCachingPolicy() { |
| 116 ResultDescriptorImpl result = new ResultDescriptorImpl('result', null); |
| 117 ResultCachingPolicy cachingPolicy = result.cachingPolicy; |
| 118 expect(cachingPolicy, isNotNull); |
| 119 expect(cachingPolicy.maxActiveSize, -1); |
| 120 expect(cachingPolicy.maxIdleSize, -1); |
| 121 } |
| 122 |
107 test_create_withoutContribution() { | 123 test_create_withoutContribution() { |
108 expect(new ResultDescriptorImpl('name', null), isNotNull); | 124 expect(new ResultDescriptorImpl('name', null), isNotNull); |
109 } | 125 } |
110 | 126 |
111 test_inputFor() { | 127 test_inputFor() { |
112 AnalysisTarget target = new TestSource(); | 128 AnalysisTarget target = new TestSource(); |
113 ResultDescriptorImpl result = new ResultDescriptorImpl('result', null); | 129 ResultDescriptorImpl result = new ResultDescriptorImpl('result', null); |
114 TaskInput input = result.of(target); | 130 TaskInput input = result.of(target); |
115 expect(input, isNotNull); | 131 expect(input, isNotNull); |
116 } | 132 } |
117 | 133 |
118 test_name() { | 134 test_name() { |
119 String name = 'result'; | 135 String name = 'result'; |
120 ResultDescriptorImpl result = new ResultDescriptorImpl(name, null); | 136 ResultDescriptorImpl result = new ResultDescriptorImpl(name, null); |
121 expect(result.name, name); | 137 expect(result.name, name); |
122 } | 138 } |
123 } | 139 } |
124 | 140 |
125 @reflectiveTest | 141 @reflectiveTest |
| 142 class SimpleResultCachingPolicyTest extends EngineTestCase { |
| 143 test_create() { |
| 144 ResultCachingPolicy policy = new SimpleResultCachingPolicy(256, 32); |
| 145 expect(policy.maxActiveSize, 256); |
| 146 expect(policy.maxIdleSize, 32); |
| 147 expect(policy.measure(null), 1); |
| 148 } |
| 149 } |
| 150 |
| 151 @reflectiveTest |
126 class TaskDescriptorImplTest extends EngineTestCase { | 152 class TaskDescriptorImplTest extends EngineTestCase { |
127 test_create() { | 153 test_create() { |
128 String name = 'name'; | 154 String name = 'name'; |
129 BuildTask buildTask = (context, target) {}; | 155 BuildTask buildTask = (context, target) {}; |
130 CreateTaskInputs createTaskInputs = (target) {}; | 156 CreateTaskInputs createTaskInputs = (target) {}; |
131 List<ResultDescriptor> results = <ResultDescriptor>[]; | 157 List<ResultDescriptor> results = <ResultDescriptor>[]; |
132 TaskDescriptorImpl descriptor = | 158 TaskDescriptorImpl descriptor = |
133 new TaskDescriptorImpl(name, buildTask, createTaskInputs, results); | 159 new TaskDescriptorImpl(name, buildTask, createTaskInputs, results); |
134 expect(descriptor, isNotNull); | 160 expect(descriptor, isNotNull); |
135 expect(descriptor.name, name); | 161 expect(descriptor.name, name); |
(...skipping 15 matching lines...) Expand all Loading... |
151 String inputMemento = 'main() {}'; | 177 String inputMemento = 'main() {}'; |
152 AnalysisTask createTask = | 178 AnalysisTask createTask = |
153 descriptor.createTask(context, target, inputs, inputMemento); | 179 descriptor.createTask(context, target, inputs, inputMemento); |
154 expect(createTask, isNotNull); | 180 expect(createTask, isNotNull); |
155 expect(createTask.context, context); | 181 expect(createTask.context, context); |
156 expect(createTask.inputs, inputs); | 182 expect(createTask.inputs, inputs); |
157 expect(createTask.inputMemento, inputMemento); | 183 expect(createTask.inputMemento, inputMemento); |
158 expect(createTask.target, target); | 184 expect(createTask.target, target); |
159 } | 185 } |
160 } | 186 } |
OLD | NEW |