| 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 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 127 TargetedResult request = manager.getNextResult(); | 127 TargetedResult request = manager.getNextResult(); |
| 128 expect(request.target, source2); | 128 expect(request.target, source2); |
| 129 expect(request.result, HTML_ERRORS); | 129 expect(request.result, HTML_ERRORS); |
| 130 } | 130 } |
| 131 | 131 |
| 132 void test_getErrors_fullList() { | 132 void test_getErrors_fullList() { |
| 133 AnalysisError error1 = | 133 AnalysisError error1 = |
| 134 new AnalysisError(source1, 1, 0, HtmlErrorCode.PARSE_ERROR, ['']); | 134 new AnalysisError(source1, 1, 0, HtmlErrorCode.PARSE_ERROR, ['']); |
| 135 AnalysisError error2 = | 135 AnalysisError error2 = |
| 136 new AnalysisError(source1, 2, 0, HtmlErrorCode.PARSE_ERROR, ['']); | 136 new AnalysisError(source1, 2, 0, HtmlErrorCode.PARSE_ERROR, ['']); |
| 137 LineInfo lineInfo = new LineInfo([0]); | |
| 138 entry1.setValue(HTML_DOCUMENT_ERRORS, <AnalysisError>[error1], []); | 137 entry1.setValue(HTML_DOCUMENT_ERRORS, <AnalysisError>[error1], []); |
| 139 entry1.setValue(LINE_INFO, lineInfo, []); | |
| 140 | 138 |
| 141 DartScript script = new DartScript(source1, []); | 139 DartScript script = new DartScript(source1, []); |
| 142 entry1.setValue(DART_SCRIPTS, [script], []); | 140 entry1.setValue(DART_SCRIPTS, [script], []); |
| 143 CacheEntry scriptEntry = context.getCacheEntry(script); | 141 CacheEntry scriptEntry = context.getCacheEntry(script); |
| 144 scriptEntry.setValue(DART_ERRORS, [error2], []); | 142 scriptEntry.setValue(DART_ERRORS, [error2], []); |
| 145 | 143 |
| 146 AnalysisErrorInfo errorInfo = manager.getErrors(source1); | 144 List<AnalysisError> errors = manager.getErrors(source1); |
| 147 expect(errorInfo.errors, unorderedEquals([error1, error2])); | 145 expect(errors, unorderedEquals([error1, error2])); |
| 148 expect(errorInfo.lineInfo, lineInfo); | |
| 149 } | 146 } |
| 150 | 147 |
| 151 void test_getErrors_partialList() { | 148 void test_getErrors_partialList() { |
| 152 AnalysisError error1 = | 149 AnalysisError error1 = |
| 153 new AnalysisError(source1, 1, 0, HtmlErrorCode.PARSE_ERROR, ['']); | 150 new AnalysisError(source1, 1, 0, HtmlErrorCode.PARSE_ERROR, ['']); |
| 154 AnalysisError error2 = | 151 AnalysisError error2 = |
| 155 new AnalysisError(source1, 2, 0, HtmlErrorCode.PARSE_ERROR, ['']); | 152 new AnalysisError(source1, 2, 0, HtmlErrorCode.PARSE_ERROR, ['']); |
| 156 LineInfo lineInfo = new LineInfo([0]); | |
| 157 entry1.setValue(HTML_DOCUMENT_ERRORS, <AnalysisError>[error1, error2], []); | 153 entry1.setValue(HTML_DOCUMENT_ERRORS, <AnalysisError>[error1, error2], []); |
| 158 entry1.setValue(LINE_INFO, lineInfo, []); | |
| 159 | 154 |
| 160 AnalysisErrorInfo errorInfo = manager.getErrors(source1); | 155 List<AnalysisError> errors = manager.getErrors(source1); |
| 161 expect(errorInfo.errors, unorderedEquals([error1, error2])); | 156 expect(errors, unorderedEquals([error1, error2])); |
| 162 expect(errorInfo.lineInfo, lineInfo); | |
| 163 } | 157 } |
| 164 | 158 |
| 165 void test_getNextResult_hasNormal_firstIsError() { | 159 void test_getNextResult_hasNormal_firstIsError() { |
| 166 entry1.setErrorState(caughtException, [HTML_ERRORS]); | 160 entry1.setErrorState(caughtException, [HTML_ERRORS]); |
| 167 manager.sourceQueue.addAll([source1, source2]); | 161 manager.sourceQueue.addAll([source1, source2]); |
| 168 TargetedResult request = manager.getNextResult(); | 162 TargetedResult request = manager.getNextResult(); |
| 169 expect(request.target, source2); | 163 expect(request.target, source2); |
| 170 expect(request.result, HTML_ERRORS); | 164 expect(request.result, HTML_ERRORS); |
| 171 // source1 is out, source2 is waiting | 165 // source1 is out, source2 is waiting |
| 172 expect_sourceQueue([source2]); | 166 expect_sourceQueue([source2]); |
| (...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 349 } | 343 } |
| 350 | 344 |
| 351 @override | 345 @override |
| 352 ChangeNoticeImpl getNotice(Source source) { | 346 ChangeNoticeImpl getNotice(Source source) { |
| 353 return _pendingNotices.putIfAbsent( | 347 return _pendingNotices.putIfAbsent( |
| 354 source, () => new ChangeNoticeImpl(source)); | 348 source, () => new ChangeNoticeImpl(source)); |
| 355 } | 349 } |
| 356 | 350 |
| 357 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation); | 351 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation); |
| 358 } | 352 } |
| OLD | NEW |