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

Unified Diff: pkg/analysis_server/test/index/store/split_store_test.dart

Issue 351813002: A local file-based Index implementation. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Tweaks Created 6 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 side-by-side diff with in-line comments
Download patch
Index: pkg/analysis_server/test/index/store/split_store_test.dart
diff --git a/pkg/analysis_server/test/index/store/split_store_test.dart b/pkg/analysis_server/test/index/store/split_store_test.dart
index 6fa5b0f45645c5e38e39c3974c497c26f32e409e..39c134ac9c55cc2681e149a93b66b972e17b341f 100644
--- a/pkg/analysis_server/test/index/store/split_store_test.dart
+++ b/pkg/analysis_server/test/index/store/split_store_test.dart
@@ -2,7 +2,7 @@
// 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 test.index.split.store;
+library test.index.split_store;
import 'dart:async';
import 'dart:collection';
@@ -17,6 +17,7 @@ import 'package:typed_mock/typed_mock.dart';
import 'package:unittest/unittest.dart';
import '../../reflective_tests.dart';
+import 'single_source_container.dart';
import 'typed_mocks.dart';
@@ -541,12 +542,6 @@ class _RelationKeyDataTest {
}
-class _SingleSourceContainer implements SourceContainer {
- final Source _source;
- _SingleSourceContainer(this._source);
- @override
- bool contains(Source source) => source == _source;
-}
@ReflectiveTestCase()
@@ -635,10 +630,12 @@ class _SplitIndexStoreTest {
when(libraryElement.source).thenReturn(librarySource);
when(libraryElement.definingCompilationUnit).thenReturn(libraryUnitElement);
}
+
void test_aboutToIndexDart_disposedContext() {
when(contextA.isDisposed).thenReturn(true);
expect(store.aboutToIndexDart(contextA, unitElementA), isFalse);
}
+
void test_aboutToIndexDart_disposedContext_wrapped() {
when(contextA.isDisposed).thenReturn(true);
InstrumentedAnalysisContextImpl instrumentedContext =
@@ -951,7 +948,7 @@ class _SplitIndexStoreTest {
assertLocations(locations, [locationA, locationB]);
}).then((_) {
// remove "librarySource"
- store.removeSources(contextA, new _SingleSourceContainer(librarySource));
+ store.removeSources(contextA, new SingleSourceContainer(librarySource));
return store.getRelationshipsAsync(elementA, relationship).then(
(List<Location> locations) {
assertLocations(locations, []);
@@ -988,7 +985,7 @@ class _SplitIndexStoreTest {
assertLocations(locations, [locationA, locationB, locationC]);
}).then((_) {
// remove "A" source
- store.removeSources(contextA, new _SingleSourceContainer(sourceA));
+ store.removeSources(contextA, new SingleSourceContainer(sourceA));
store.removeSource(contextA, sourceA);
return store.getRelationshipsAsync(elementA, relationship).then(
(List<Location> locations) {
@@ -1059,6 +1056,66 @@ class _SplitIndexStoreTest {
});
}
+ test_universe_removeSource() {
+ when(contextA.getElement(elementLocationA)).thenReturn(elementA);
+ when(contextB.getElement(elementLocationB)).thenReturn(elementB);
+ Location locationA = mockLocation(elementA);
+ Location locationB = mockLocation(elementB);
+ {
+ store.aboutToIndexDart(contextA, unitElementA);
+ store.recordRelationship(UniverseElement.INSTANCE, relationship,
+ locationA);
+ store.doneIndex();
+ }
+ {
+ store.aboutToIndexDart(contextA, unitElementB);
+ store.recordRelationship(UniverseElement.INSTANCE, relationship,
+ locationB);
+ store.doneIndex();
+ }
+ return store.getRelationshipsAsync(UniverseElement.INSTANCE,
+ relationship).then((List<Location> locations) {
+ assertLocations(locations, [locationA, locationB]);
+ }).then((_) {
+ // remove "sourceA"
+ store.removeSource(contextA, sourceA);
+ return store.getRelationshipsAsync(UniverseElement.INSTANCE,
+ relationship).then((List<Location> locations) {
+ assertLocations(locations, [locationB]);
+ });
+ });
+ }
+
+ test_universe_clear() {
+ when(contextA.getElement(elementLocationA)).thenReturn(elementA);
+ when(contextB.getElement(elementLocationB)).thenReturn(elementB);
+ Location locationA = mockLocation(elementA);
+ Location locationB = mockLocation(elementB);
+ {
+ store.aboutToIndexDart(contextA, unitElementA);
+ store.recordRelationship(UniverseElement.INSTANCE, relationship,
+ locationA);
+ store.doneIndex();
+ }
+ {
+ store.aboutToIndexDart(contextA, unitElementB);
+ store.recordRelationship(UniverseElement.INSTANCE, relationship,
+ locationB);
+ store.doneIndex();
+ }
+ return store.getRelationshipsAsync(UniverseElement.INSTANCE,
+ relationship).then((List<Location> locations) {
+ assertLocations(locations, [locationA, locationB]);
+ }).then((_) {
+ // clear
+ store.clear();
+ return store.getRelationshipsAsync(UniverseElement.INSTANCE,
+ relationship).then((List<Location> locations) {
+ expect(locations, isEmpty);
+ });
+ });
+ }
+
/**
* Asserts that the [actual] locations have all the [expected] locations and
* only them.
« no previous file with comments | « pkg/analysis_server/test/index/store/single_source_container.dart ('k') | pkg/analysis_server/test/index/test_all.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698