Chromium Code Reviews| Index: pkg/analyzer/test/src/task/html_work_manager_integration_test.dart |
| diff --git a/pkg/analyzer/test/src/task/html_work_manager_integration_test.dart b/pkg/analyzer/test/src/task/html_work_manager_integration_test.dart |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..cc4bfa19b6c38a5d518be06f5147b8de61389f41 |
| --- /dev/null |
| +++ b/pkg/analyzer/test/src/task/html_work_manager_integration_test.dart |
| @@ -0,0 +1,75 @@ |
| +// Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file |
| +// for details. All rights reserved. Use of this source code is governed by a |
| +// BSD-style license that can be found in the LICENSE file. |
| + |
| +library analyzer.test.src.task.html_work_manager_integration_test; |
| + |
| +import 'package:analyzer/src/context/context.dart'; |
| +import 'package:analyzer/src/context/cache.dart'; |
| +import 'package:analyzer/src/generated/engine.dart' |
| + show |
| + CacheState, |
| + InternalAnalysisContext; |
| +import 'package:analyzer/src/generated/source.dart'; |
| +import 'package:analyzer/src/task/html_work_manager.dart'; |
| +import 'package:analyzer/task/html.dart'; |
| +import 'package:test/test.dart'; |
| +import 'package:test_reflective_loader/test_reflective_loader.dart'; |
| +import 'package:typed_mock/typed_mock.dart'; |
| + |
| +import '../../generated/test_support.dart'; |
| + |
| +main() { |
| + defineReflectiveSuite(() { |
| + defineReflectiveTests(HtmlWorkManagerIntegrationTest); |
|
scheglov
2016/10/28 19:04:45
I would just add it to html_work_manager_test.dart
|
| + }); |
| +} |
| + |
| +@reflectiveTest |
| +class HtmlWorkManagerIntegrationTest { |
| + InternalAnalysisContext context = new AnalysisContextImpl(); |
| + AnalysisCache cache; |
| + HtmlWorkManager manager; |
| + |
| + Source source1 = new TestSource('1.html'); |
| + Source source2 = new TestSource('2.html'); |
| + CacheEntry entry1; |
| + CacheEntry entry2; |
| + |
| + void expect_sourceQueue(List<Source> sources) { |
| + expect(manager.sourceQueue, unorderedEquals(sources)); |
| + } |
| + |
| + void setUp() { |
| + cache = context.analysisCache; |
| + manager = new HtmlWorkManager(context); |
| + entry1 = context.getCacheEntry(source1); |
| + entry2 = context.getCacheEntry(source2); |
| + } |
| + |
| + void test_onResultInvalidated_scheduleInvalidatedLibrariesAfterSetSourceFactory() { |
| + // Change the source factory, changing the analysis cache from when |
| + // the work manager was constructed. This used to create a failure |
| + // case for test_onResultInvalidated_scheduleInvalidLibraries so its |
| + // tested here. |
| + context.sourceFactory = new _SourceFactoryMock(); |
| + |
| + // now just do the same checks as |
| + // test_onResultInvalidated_scheduleInvalidLibraries |
| + |
| + // set HTML_ERRORS for source1 and source2 |
| + entry1.setValue(HTML_ERRORS, [], []); |
| + entry2.setValue(HTML_ERRORS, [], []); |
| + // invalidate HTML_ERRORS for source1, schedule it |
| + entry1.setState(HTML_ERRORS, CacheState.INVALID); |
| + expect_sourceQueue([source1]); |
| + // invalidate HTML_ERRORS for source2, schedule it |
| + entry2.setState(HTML_ERRORS, CacheState.INVALID); |
| + expect_sourceQueue([source1, source2]); |
| + } |
| + |
| +} |
| + |
| +class _SourceFactoryMock extends TypedMock |
| + implements SourceFactory { |
| +} |