Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 // BSD-style license that can be found in the LICENSE file. | |
| 4 | |
| 5 library analyzer.test.src.task.html_work_manager_integration_test; | |
| 6 | |
| 7 import 'package:analyzer/src/context/context.dart'; | |
| 8 import 'package:analyzer/src/context/cache.dart'; | |
| 9 import 'package:analyzer/src/generated/engine.dart' | |
| 10 show | |
| 11 CacheState, | |
| 12 InternalAnalysisContext; | |
| 13 import 'package:analyzer/src/generated/source.dart'; | |
| 14 import 'package:analyzer/src/task/html_work_manager.dart'; | |
| 15 import 'package:analyzer/task/html.dart'; | |
| 16 import 'package:test/test.dart'; | |
| 17 import 'package:test_reflective_loader/test_reflective_loader.dart'; | |
| 18 import 'package:typed_mock/typed_mock.dart'; | |
| 19 | |
| 20 import '../../generated/test_support.dart'; | |
| 21 | |
| 22 main() { | |
| 23 defineReflectiveSuite(() { | |
| 24 defineReflectiveTests(HtmlWorkManagerIntegrationTest); | |
|
scheglov
2016/10/28 19:04:45
I would just add it to html_work_manager_test.dart
| |
| 25 }); | |
| 26 } | |
| 27 | |
| 28 @reflectiveTest | |
| 29 class HtmlWorkManagerIntegrationTest { | |
| 30 InternalAnalysisContext context = new AnalysisContextImpl(); | |
| 31 AnalysisCache cache; | |
| 32 HtmlWorkManager manager; | |
| 33 | |
| 34 Source source1 = new TestSource('1.html'); | |
| 35 Source source2 = new TestSource('2.html'); | |
| 36 CacheEntry entry1; | |
| 37 CacheEntry entry2; | |
| 38 | |
| 39 void expect_sourceQueue(List<Source> sources) { | |
| 40 expect(manager.sourceQueue, unorderedEquals(sources)); | |
| 41 } | |
| 42 | |
| 43 void setUp() { | |
| 44 cache = context.analysisCache; | |
| 45 manager = new HtmlWorkManager(context); | |
| 46 entry1 = context.getCacheEntry(source1); | |
| 47 entry2 = context.getCacheEntry(source2); | |
| 48 } | |
| 49 | |
| 50 void test_onResultInvalidated_scheduleInvalidatedLibrariesAfterSetSourceFactor y() { | |
| 51 // Change the source factory, changing the analysis cache from when | |
| 52 // the work manager was constructed. This used to create a failure | |
| 53 // case for test_onResultInvalidated_scheduleInvalidLibraries so its | |
| 54 // tested here. | |
| 55 context.sourceFactory = new _SourceFactoryMock(); | |
| 56 | |
| 57 // now just do the same checks as | |
| 58 // test_onResultInvalidated_scheduleInvalidLibraries | |
| 59 | |
| 60 // set HTML_ERRORS for source1 and source2 | |
| 61 entry1.setValue(HTML_ERRORS, [], []); | |
| 62 entry2.setValue(HTML_ERRORS, [], []); | |
| 63 // invalidate HTML_ERRORS for source1, schedule it | |
| 64 entry1.setState(HTML_ERRORS, CacheState.INVALID); | |
| 65 expect_sourceQueue([source1]); | |
| 66 // invalidate HTML_ERRORS for source2, schedule it | |
| 67 entry2.setState(HTML_ERRORS, CacheState.INVALID); | |
| 68 expect_sourceQueue([source1, source2]); | |
| 69 } | |
| 70 | |
| 71 } | |
| 72 | |
| 73 class _SourceFactoryMock extends TypedMock | |
| 74 implements SourceFactory { | |
| 75 } | |
| OLD | NEW |