| 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 analyzer.test.src.task.html_work_manager_test; |
| 6 | 6 |
| 7 import 'package:analyzer/error/error.dart' show AnalysisError; |
| 8 import 'package:analyzer/exception/exception.dart'; |
| 7 import 'package:analyzer/src/context/cache.dart'; | 9 import 'package:analyzer/src/context/cache.dart'; |
| 10 import 'package:analyzer/src/error/codes.dart' show HtmlErrorCode; |
| 8 import 'package:analyzer/src/generated/engine.dart' | 11 import 'package:analyzer/src/generated/engine.dart' |
| 9 show | 12 show |
| 10 AnalysisEngine, | 13 AnalysisEngine, |
| 11 AnalysisErrorInfo, | 14 AnalysisErrorInfo, |
| 12 AnalysisErrorInfoImpl, | 15 AnalysisErrorInfoImpl, |
| 13 CacheState, | 16 CacheState, |
| 14 ChangeNoticeImpl, | 17 ChangeNoticeImpl, |
| 15 InternalAnalysisContext; | 18 InternalAnalysisContext; |
| 16 import 'package:analyzer/src/generated/error.dart' | |
| 17 show AnalysisError, HtmlErrorCode; | |
| 18 import 'package:analyzer/src/generated/java_engine.dart' show CaughtException; | |
| 19 import 'package:analyzer/src/generated/source.dart'; | 19 import 'package:analyzer/src/generated/source.dart'; |
| 20 import 'package:analyzer/src/task/html.dart'; | 20 import 'package:analyzer/src/task/html.dart'; |
| 21 import 'package:analyzer/src/task/html_work_manager.dart'; | 21 import 'package:analyzer/src/task/html_work_manager.dart'; |
| 22 import 'package:analyzer/task/dart.dart'; | 22 import 'package:analyzer/task/dart.dart'; |
| 23 import 'package:analyzer/task/general.dart'; | 23 import 'package:analyzer/task/general.dart'; |
| 24 import 'package:analyzer/task/html.dart'; | 24 import 'package:analyzer/task/html.dart'; |
| 25 import 'package:analyzer/task/model.dart'; | 25 import 'package:analyzer/task/model.dart'; |
| 26 import 'package:test_reflective_loader/test_reflective_loader.dart'; |
| 26 import 'package:typed_mock/typed_mock.dart'; | 27 import 'package:typed_mock/typed_mock.dart'; |
| 27 import 'package:unittest/unittest.dart'; | 28 import 'package:unittest/unittest.dart'; |
| 28 | 29 |
| 29 import '../../generated/test_support.dart'; | 30 import '../../generated/test_support.dart'; |
| 30 import '../../reflective_tests.dart'; | |
| 31 import '../../utils.dart'; | 31 import '../../utils.dart'; |
| 32 | 32 |
| 33 main() { | 33 main() { |
| 34 initializeTestEnvironment(); | 34 initializeTestEnvironment(); |
| 35 runReflectiveTests(HtmlWorkManagerTest); | 35 defineReflectiveTests(HtmlWorkManagerTest); |
| 36 } | 36 } |
| 37 | 37 |
| 38 @reflectiveTest | 38 @reflectiveTest |
| 39 class HtmlWorkManagerTest { | 39 class HtmlWorkManagerTest { |
| 40 InternalAnalysisContext context = new _InternalAnalysisContextMock(); | 40 InternalAnalysisContext context = new _InternalAnalysisContextMock(); |
| 41 AnalysisCache cache; | 41 AnalysisCache cache; |
| 42 HtmlWorkManager manager; | 42 HtmlWorkManager manager; |
| 43 | 43 |
| 44 CaughtException caughtException = new CaughtException(null, null); | 44 CaughtException caughtException = new CaughtException(null, null); |
| 45 | 45 |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 103 expect_sourceQueue([source2]); | 103 expect_sourceQueue([source2]); |
| 104 // remove source2 | 104 // remove source2 |
| 105 manager.applyChange([], [], [source2]); | 105 manager.applyChange([], [], [source2]); |
| 106 expect_sourceQueue([]); | 106 expect_sourceQueue([]); |
| 107 // remove source3 | 107 // remove source3 |
| 108 manager.applyChange([], [], [source3]); | 108 manager.applyChange([], [], [source3]); |
| 109 expect_sourceQueue([]); | 109 expect_sourceQueue([]); |
| 110 } | 110 } |
| 111 | 111 |
| 112 void test_applyPriorityTargets() { | 112 void test_applyPriorityTargets() { |
| 113 when(context.shouldErrorsBeAnalyzed(source2, null)).thenReturn(true); | 113 when(context.shouldErrorsBeAnalyzed(source2)).thenReturn(true); |
| 114 when(context.shouldErrorsBeAnalyzed(source3, null)).thenReturn(true); | 114 when(context.shouldErrorsBeAnalyzed(source3)).thenReturn(true); |
| 115 manager.priorityResultQueue.add(new TargetedResult(source1, HTML_ERRORS)); | 115 manager.priorityResultQueue.add(new TargetedResult(source1, HTML_ERRORS)); |
| 116 manager.priorityResultQueue.add(new TargetedResult(source2, HTML_ERRORS)); | 116 manager.priorityResultQueue.add(new TargetedResult(source2, HTML_ERRORS)); |
| 117 // -source1 +source3 | 117 // -source1 +source3 |
| 118 manager.applyPriorityTargets([source2, source3]); | 118 manager.applyPriorityTargets([source2, source3]); |
| 119 expect( | 119 expect( |
| 120 manager.priorityResultQueue, | 120 manager.priorityResultQueue, |
| 121 unorderedEquals([ | 121 unorderedEquals([ |
| 122 new TargetedResult(source2, HTML_ERRORS), | 122 new TargetedResult(source2, HTML_ERRORS), |
| 123 new TargetedResult(source3, HTML_ERRORS) | 123 new TargetedResult(source3, HTML_ERRORS) |
| 124 ])); | 124 ])); |
| (...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 339 } | 339 } |
| 340 return new AnalysisErrorInfoImpl( | 340 return new AnalysisErrorInfoImpl( |
| 341 errors, getCacheEntry(source).getValue(LINE_INFO)); | 341 errors, getCacheEntry(source).getValue(LINE_INFO)); |
| 342 } | 342 } |
| 343 | 343 |
| 344 @override | 344 @override |
| 345 ChangeNoticeImpl getNotice(Source source) { | 345 ChangeNoticeImpl getNotice(Source source) { |
| 346 return _pendingNotices.putIfAbsent( | 346 return _pendingNotices.putIfAbsent( |
| 347 source, () => new ChangeNoticeImpl(source)); | 347 source, () => new ChangeNoticeImpl(source)); |
| 348 } | 348 } |
| 349 | |
| 350 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation); | |
| 351 } | 349 } |
| OLD | NEW |