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

Side by Side Diff: pkg/analyzer/test/src/task/dart_work_manager_test.dart

Issue 1193993003: Add AnalysisCache.onResultInvalidated, use in DartWorkManager. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 6 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 unified diff | Download patch
« no previous file with comments | « pkg/analyzer/test/src/context/cache_test.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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.dart_work_manager_test; 5 library test.src.task.dart_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/ast.dart'; 8 import 'package:analyzer/src/generated/ast.dart';
9 import 'package:analyzer/src/generated/engine.dart' 9 import 'package:analyzer/src/generated/engine.dart'
10 show 10 show
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 // remove source3 115 // remove source3
116 manager.applyChange([], [], [source3]); 116 manager.applyChange([], [], [source3]);
117 expect_librarySourceQueue([]); 117 expect_librarySourceQueue([]);
118 expect_unknownSourceQueue([source4]); 118 expect_unknownSourceQueue([source4]);
119 // remove source4 119 // remove source4
120 manager.applyChange([], [], [source4]); 120 manager.applyChange([], [], [source4]);
121 expect_librarySourceQueue([]); 121 expect_librarySourceQueue([]);
122 expect_unknownSourceQueue([]); 122 expect_unknownSourceQueue([]);
123 } 123 }
124 124
125 void test_applyChange_scheduleInvalidatedLibraries() {
126 // libraries source1 and source3 are invalid
127 entry1.setValue(SOURCE_KIND, SourceKind.LIBRARY, []);
128 entry2.setValue(SOURCE_KIND, SourceKind.PART, []);
129 entry3.setValue(SOURCE_KIND, SourceKind.LIBRARY, []);
130 entry1.setValue(LIBRARY_ERRORS_READY, false, []);
131 entry3.setValue(LIBRARY_ERRORS_READY, false, []);
132 // change source2, schedule source1 and source3
133 manager.applyChange([], [source2], []);
134 expect_librarySourceQueue([source1, source3]);
135 }
136
137 void test_applyChange_updatePartsLibraries_changeLibrary() { 125 void test_applyChange_updatePartsLibraries_changeLibrary() {
138 Source part1 = new TestSource('part1.dart'); 126 Source part1 = new TestSource('part1.dart');
139 Source part2 = new TestSource('part2.dart'); 127 Source part2 = new TestSource('part2.dart');
140 Source part3 = new TestSource('part3.dart'); 128 Source part3 = new TestSource('part3.dart');
141 Source library1 = new TestSource('library1.dart'); 129 Source library1 = new TestSource('library1.dart');
142 Source library2 = new TestSource('library2.dart'); 130 Source library2 = new TestSource('library2.dart');
143 manager.partLibrariesMap[part1] = [library1, library2]; 131 manager.partLibrariesMap[part1] = [library1, library2];
144 manager.partLibrariesMap[part2] = [library2]; 132 manager.partLibrariesMap[part2] = [library2];
145 manager.partLibrariesMap[part3] = [library1]; 133 manager.partLibrariesMap[part3] = [library1];
146 manager.libraryPartsMap[library1] = [part1, part3]; 134 manager.libraryPartsMap[library1] = [part1, part3];
(...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after
478 // resolution is invalidated 466 // resolution is invalidated
479 expect(unitEntry.getState(BUILD_LIBRARY_ERRORS), CacheState.INVALID); 467 expect(unitEntry.getState(BUILD_LIBRARY_ERRORS), CacheState.INVALID);
480 // ...but URIs are still value 468 // ...but URIs are still value
481 expect(entry1.getState(PARSED_UNIT), CacheState.VALID); 469 expect(entry1.getState(PARSED_UNIT), CacheState.VALID);
482 expect(entry1.getState(IMPORTED_LIBRARIES), CacheState.VALID); 470 expect(entry1.getState(IMPORTED_LIBRARIES), CacheState.VALID);
483 expect(entry1.getState(EXPLICITLY_IMPORTED_LIBRARIES), CacheState.VALID); 471 expect(entry1.getState(EXPLICITLY_IMPORTED_LIBRARIES), CacheState.VALID);
484 expect(entry1.getState(EXPORTED_LIBRARIES), CacheState.VALID); 472 expect(entry1.getState(EXPORTED_LIBRARIES), CacheState.VALID);
485 expect(entry1.getState(INCLUDED_PARTS), CacheState.VALID); 473 expect(entry1.getState(INCLUDED_PARTS), CacheState.VALID);
486 } 474 }
487 475
476 void test_onResultInvalidated_scheduleInvalidatedLibraries() {
477 // set SOURCE_KIND
478 entry1.setValue(SOURCE_KIND, SourceKind.LIBRARY, []);
479 entry2.setValue(SOURCE_KIND, SourceKind.PART, []);
480 entry3.setValue(SOURCE_KIND, SourceKind.LIBRARY, []);
481 // set LIBRARY_ERRORS_READY for source1 and source3
482 entry1.setValue(LIBRARY_ERRORS_READY, true, []);
483 entry3.setValue(LIBRARY_ERRORS_READY, true, []);
484 // invalidate LIBRARY_ERRORS_READY for source1, schedule it
485 entry1.setState(LIBRARY_ERRORS_READY, CacheState.INVALID);
486 expect_librarySourceQueue([source1]);
487 // invalidate LIBRARY_ERRORS_READY for source3, schedule it
488 entry3.setState(LIBRARY_ERRORS_READY, CacheState.INVALID);
489 expect_librarySourceQueue([source1, source3]);
490 }
491
488 void test_onSourceFactoryChanged() { 492 void test_onSourceFactoryChanged() {
489 when(context.exists(anyObject)).thenReturn(true); 493 when(context.exists(anyObject)).thenReturn(true);
490 // set cache values 494 // set cache values
491 entry1.setValue(PARSED_UNIT, AstFactory.compilationUnit(), []); 495 entry1.setValue(PARSED_UNIT, AstFactory.compilationUnit(), []);
492 entry1.setValue(IMPORTED_LIBRARIES, <Source>[], []); 496 entry1.setValue(IMPORTED_LIBRARIES, <Source>[], []);
493 entry1.setValue(EXPLICITLY_IMPORTED_LIBRARIES, <Source>[], []); 497 entry1.setValue(EXPLICITLY_IMPORTED_LIBRARIES, <Source>[], []);
494 entry1.setValue(EXPORTED_LIBRARIES, <Source>[], []); 498 entry1.setValue(EXPORTED_LIBRARIES, <Source>[], []);
495 entry1.setValue(INCLUDED_PARTS, <Source>[], []); 499 entry1.setValue(INCLUDED_PARTS, <Source>[], []);
496 // configure LibrarySpecificUnit 500 // configure LibrarySpecificUnit
497 LibrarySpecificUnit unitTarget = new LibrarySpecificUnit(source2, source3); 501 LibrarySpecificUnit unitTarget = new LibrarySpecificUnit(source2, source3);
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after
690 } 694 }
691 695
692 @override 696 @override
693 ChangeNoticeImpl getNotice(Source source) { 697 ChangeNoticeImpl getNotice(Source source) {
694 return _pendingNotices.putIfAbsent( 698 return _pendingNotices.putIfAbsent(
695 source, () => new ChangeNoticeImpl(source)); 699 source, () => new ChangeNoticeImpl(source));
696 } 700 }
697 701
698 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation); 702 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation);
699 } 703 }
OLDNEW
« no previous file with comments | « pkg/analyzer/test/src/context/cache_test.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698