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.html_work_manager_test; | 5 library test.src.task.html_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 | 9 show |
10 AnalysisEngine, | 10 AnalysisEngine, |
(...skipping 11 matching lines...) Expand all Loading... |
22 import 'package:analyzer/src/task/html_work_manager.dart'; | 22 import 'package:analyzer/src/task/html_work_manager.dart'; |
23 import 'package:analyzer/task/dart.dart'; | 23 import 'package:analyzer/task/dart.dart'; |
24 import 'package:analyzer/task/general.dart'; | 24 import 'package:analyzer/task/general.dart'; |
25 import 'package:analyzer/task/html.dart'; | 25 import 'package:analyzer/task/html.dart'; |
26 import 'package:analyzer/task/model.dart'; | 26 import 'package:analyzer/task/model.dart'; |
27 import 'package:typed_mock/typed_mock.dart'; | 27 import 'package:typed_mock/typed_mock.dart'; |
28 import 'package:unittest/unittest.dart'; | 28 import 'package:unittest/unittest.dart'; |
29 | 29 |
30 import '../../generated/test_support.dart'; | 30 import '../../generated/test_support.dart'; |
31 import '../../reflective_tests.dart'; | 31 import '../../reflective_tests.dart'; |
| 32 import '../../utils.dart'; |
32 | 33 |
33 main() { | 34 main() { |
34 groupSep = ' | '; | 35 initializeTestEnvironment(); |
35 runReflectiveTests(HtmlWorkManagerTest); | 36 runReflectiveTests(HtmlWorkManagerTest); |
36 } | 37 } |
37 | 38 |
38 @reflectiveTest | 39 @reflectiveTest |
39 class HtmlWorkManagerTest { | 40 class HtmlWorkManagerTest { |
40 InternalAnalysisContext context = new _InternalAnalysisContextMock(); | 41 InternalAnalysisContext context = new _InternalAnalysisContextMock(); |
41 AnalysisCache cache; | 42 AnalysisCache cache; |
42 HtmlWorkManager manager; | 43 HtmlWorkManager manager; |
43 | 44 |
44 CaughtException caughtException = new CaughtException(null, null); | 45 CaughtException caughtException = new CaughtException(null, null); |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
109 expect_sourceQueue([]); | 110 expect_sourceQueue([]); |
110 } | 111 } |
111 | 112 |
112 void test_applyPriorityTargets() { | 113 void test_applyPriorityTargets() { |
113 when(context.shouldErrorsBeAnalyzed(source2, null)).thenReturn(true); | 114 when(context.shouldErrorsBeAnalyzed(source2, null)).thenReturn(true); |
114 when(context.shouldErrorsBeAnalyzed(source3, null)).thenReturn(true); | 115 when(context.shouldErrorsBeAnalyzed(source3, null)).thenReturn(true); |
115 manager.priorityResultQueue.add(new TargetedResult(source1, HTML_ERRORS)); | 116 manager.priorityResultQueue.add(new TargetedResult(source1, HTML_ERRORS)); |
116 manager.priorityResultQueue.add(new TargetedResult(source2, HTML_ERRORS)); | 117 manager.priorityResultQueue.add(new TargetedResult(source2, HTML_ERRORS)); |
117 // -source1 +source3 | 118 // -source1 +source3 |
118 manager.applyPriorityTargets([source2, source3]); | 119 manager.applyPriorityTargets([source2, source3]); |
119 expect(manager.priorityResultQueue, unorderedEquals([ | 120 expect( |
120 new TargetedResult(source2, HTML_ERRORS), | 121 manager.priorityResultQueue, |
121 new TargetedResult(source3, HTML_ERRORS) | 122 unorderedEquals([ |
122 ])); | 123 new TargetedResult(source2, HTML_ERRORS), |
| 124 new TargetedResult(source3, HTML_ERRORS) |
| 125 ])); |
123 // get next request | 126 // get next request |
124 TargetedResult request = manager.getNextResult(); | 127 TargetedResult request = manager.getNextResult(); |
125 expect(request.target, source2); | 128 expect(request.target, source2); |
126 expect(request.result, HTML_ERRORS); | 129 expect(request.result, HTML_ERRORS); |
127 } | 130 } |
128 | 131 |
129 void test_getErrors_fullList() { | 132 void test_getErrors_fullList() { |
130 AnalysisError error1 = | 133 AnalysisError error1 = |
131 new AnalysisError(source1, 1, 0, HtmlErrorCode.PARSE_ERROR, ['']); | 134 new AnalysisError(source1, 1, 0, HtmlErrorCode.PARSE_ERROR, ['']); |
132 AnalysisError error2 = | 135 AnalysisError error2 = |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
197 TargetedResult request = manager.getNextResult(); | 200 TargetedResult request = manager.getNextResult(); |
198 expect(request.target, source3); | 201 expect(request.target, source3); |
199 expect(request.result, HTML_ERRORS); | 202 expect(request.result, HTML_ERRORS); |
200 // no changes until computed | 203 // no changes until computed |
201 expect_sourceQueue([source1, source2]); | 204 expect_sourceQueue([source1, source2]); |
202 } | 205 } |
203 | 206 |
204 void test_getNextResult_hasPriority() { | 207 void test_getNextResult_hasPriority() { |
205 manager.addPriorityResult(source1, HTML_ERRORS); | 208 manager.addPriorityResult(source1, HTML_ERRORS); |
206 manager.addPriorityResult(source2, HTML_ERRORS); | 209 manager.addPriorityResult(source2, HTML_ERRORS); |
207 expect(manager.priorityResultQueue, unorderedEquals([ | 210 expect( |
208 new TargetedResult(source1, HTML_ERRORS), | 211 manager.priorityResultQueue, |
209 new TargetedResult(source2, HTML_ERRORS) | 212 unorderedEquals([ |
210 ])); | 213 new TargetedResult(source1, HTML_ERRORS), |
| 214 new TargetedResult(source2, HTML_ERRORS) |
| 215 ])); |
211 | 216 |
212 TargetedResult request = manager.getNextResult(); | 217 TargetedResult request = manager.getNextResult(); |
213 expect(request.target, source1); | 218 expect(request.target, source1); |
214 expect(request.result, HTML_ERRORS); | 219 expect(request.result, HTML_ERRORS); |
215 // no changes until computed | 220 // no changes until computed |
216 expect(manager.priorityResultQueue, unorderedEquals([ | 221 expect( |
217 new TargetedResult(source1, HTML_ERRORS), | 222 manager.priorityResultQueue, |
218 new TargetedResult(source2, HTML_ERRORS) | 223 unorderedEquals([ |
219 ])); | 224 new TargetedResult(source1, HTML_ERRORS), |
| 225 new TargetedResult(source2, HTML_ERRORS) |
| 226 ])); |
220 } | 227 } |
221 | 228 |
222 void test_getNextResult_nothingToDo() { | 229 void test_getNextResult_nothingToDo() { |
223 TargetedResult request = manager.getNextResult(); | 230 TargetedResult request = manager.getNextResult(); |
224 expect(request, isNull); | 231 expect(request, isNull); |
225 } | 232 } |
226 | 233 |
227 void test_getNextResultPriority_hasPriority() { | 234 void test_getNextResultPriority_hasPriority() { |
228 manager.addPriorityResult(source1, SOURCE_KIND); | 235 manager.addPriorityResult(source1, SOURCE_KIND); |
229 expect(manager.getNextResultPriority(), WorkOrderPriority.PRIORITY); | 236 expect(manager.getNextResultPriority(), WorkOrderPriority.PRIORITY); |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
342 } | 349 } |
343 | 350 |
344 @override | 351 @override |
345 ChangeNoticeImpl getNotice(Source source) { | 352 ChangeNoticeImpl getNotice(Source source) { |
346 return _pendingNotices.putIfAbsent( | 353 return _pendingNotices.putIfAbsent( |
347 source, () => new ChangeNoticeImpl(source)); | 354 source, () => new ChangeNoticeImpl(source)); |
348 } | 355 } |
349 | 356 |
350 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation); | 357 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation); |
351 } | 358 } |
OLD | NEW |