Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(35)

Unified Diff: pkg/analyzer/test/src/task/html_work_manager_test.dart

Issue 2454233003: Ensure HtmlWorkManager is subscribed to the right stream for invalidations in the presence of Sourc… (Closed)
Patch Set: Move new html work manager test class into existing test file (plus capitalize comment and add peri… Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « pkg/analyzer/lib/src/task/html_work_manager.dart ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analyzer/test/src/task/html_work_manager_test.dart
diff --git a/pkg/analyzer/test/src/task/html_work_manager_test.dart b/pkg/analyzer/test/src/task/html_work_manager_test.dart
index ee102d40f0fa2e23e340fa6637e4eed1697ac325..f4e9e7006f26be34999e5dc82b1dd814b38c3526 100644
--- a/pkg/analyzer/test/src/task/html_work_manager_test.dart
+++ b/pkg/analyzer/test/src/task/html_work_manager_test.dart
@@ -7,6 +7,7 @@ library analyzer.test.src.task.html_work_manager_test;
import 'package:analyzer/error/error.dart' show AnalysisError;
import 'package:analyzer/exception/exception.dart';
import 'package:analyzer/src/context/cache.dart';
+import 'package:analyzer/src/context/context.dart';
import 'package:analyzer/src/error/codes.dart' show HtmlErrorCode;
import 'package:analyzer/src/generated/engine.dart'
show
@@ -32,6 +33,7 @@ import '../../generated/test_support.dart';
main() {
defineReflectiveSuite(() {
defineReflectiveTests(HtmlWorkManagerTest);
+ defineReflectiveTests(HtmlWorkManagerIntegrationTest);
});
}
@@ -303,6 +305,53 @@ class HtmlWorkManagerTest {
}
}
+@reflectiveTest
+class HtmlWorkManagerIntegrationTest {
+ InternalAnalysisContext context = new AnalysisContextImpl();
+ 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() {
+ 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 {
+}
+
class _InternalAnalysisContextMock extends TypedMock
implements InternalAnalysisContext {
@override
@@ -311,6 +360,12 @@ class _InternalAnalysisContextMock extends TypedMock
@override
AnalysisCache analysisCache;
+ // The production version is a stream that carries messages from the cache
+ // since the cache changes. Here, we can just pass the inner stream because
+ // it doesn't change.
+ @override
+ get onResultInvalidated => analysisCache.onResultInvalidated;
+
Map<Source, ChangeNoticeImpl> _pendingNotices = <Source, ChangeNoticeImpl>{};
_InternalAnalysisContextMock() {
« no previous file with comments | « pkg/analyzer/lib/src/task/html_work_manager.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698