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

Unified Diff: dart/editor/tools/plugins/com.google.dart.engine_test/src/com/google/dart/engine/internal/index/MemoryIndexStoreImplTest.java

Issue 64033002: Version 0.8.10.8 (Closed) Base URL: http://dart.googlecode.com/svn/trunk/
Patch Set: Created 7 years, 1 month 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: dart/editor/tools/plugins/com.google.dart.engine_test/src/com/google/dart/engine/internal/index/MemoryIndexStoreImplTest.java
===================================================================
--- dart/editor/tools/plugins/com.google.dart.engine_test/src/com/google/dart/engine/internal/index/MemoryIndexStoreImplTest.java (revision 30037)
+++ dart/editor/tools/plugins/com.google.dart.engine_test/src/com/google/dart/engine/internal/index/MemoryIndexStoreImplTest.java (working copy)
@@ -25,6 +25,8 @@
import com.google.dart.engine.index.Relationship;
import com.google.dart.engine.internal.context.InstrumentedAnalysisContextImpl;
import com.google.dart.engine.internal.element.ElementLocationImpl;
+import com.google.dart.engine.internal.element.member.Member;
+import com.google.dart.engine.source.DirectoryBasedSourceContainer;
import com.google.dart.engine.source.Source;
import com.google.dart.engine.source.SourceContainer;
@@ -219,23 +221,59 @@
assertEquals(1, store.internalGetLocationCount());
}
+ public void test_recordRelationship_member() throws Exception {
+ Member member = mock(Member.class);
+ when(member.getBaseElement()).thenReturn(elementA);
+ // no relationships initially
+ assertEquals(0, store.internalGetLocationCount());
+ // record relationship
+ store.recordRelationship(member, relationship, location);
+ // no location for "member"
+ {
+ Location[] locations = store.getRelationships(member, relationship);
+ assertLocations(locations);
+ }
+ // has location for "elementA"
+ {
+ Location[] locations = store.getRelationships(elementA, relationship);
+ assertLocations(locations, location);
+ }
+ }
+
public void test_recordRelationship_noElement() throws Exception {
store.recordRelationship(null, relationship, location);
assertEquals(0, store.internalGetLocationCount());
}
+ public void test_recordRelationship_noElementContext() throws Exception {
+ when(elementA.getContext()).thenReturn(null);
+ store.recordRelationship(elementA, relationship, location);
+ assertEquals(0, store.internalGetLocationCount());
+ }
+
+ public void test_recordRelationship_noElementSource() throws Exception {
+ when(elementA.getSource()).thenReturn(null);
+ store.recordRelationship(elementA, relationship, location);
+ assertEquals(0, store.internalGetLocationCount());
+ }
+
public void test_recordRelationship_noLocation() throws Exception {
store.recordRelationship(elementA, relationship, null);
assertEquals(0, store.internalGetLocationCount());
}
- public void test_recordRelationship_noLocationElement() throws Exception {
- Element elementWithoutEnclosing = mock(Element.class);
- Location location = new Location(elementWithoutEnclosing, 0, 0);
+ public void test_recordRelationship_noLocationContext() throws Exception {
+ when(location.getElement().getContext()).thenReturn(null);
store.recordRelationship(elementA, relationship, location);
assertEquals(0, store.internalGetLocationCount());
}
+ public void test_recordRelationship_noLocationSource() throws Exception {
+ when(location.getElement().getSource()).thenReturn(null);
+ store.recordRelationship(elementA, relationship, location);
+ assertEquals(0, store.internalGetLocationCount());
+ }
+
public void test_removeContext_instrumented() throws Exception {
InstrumentedAnalysisContextImpl instrumentedContext = mock(InstrumentedAnalysisContextImpl.class);
when(instrumentedContext.getBasis()).thenReturn(contextA);
@@ -421,6 +459,18 @@
}
}
+ public void test_removeSources_nullContext() throws Exception {
+ // record
+ {
+ store.recordRelationship(IndexConstants.UNIVERSE, relationship, location);
+ assertEquals(1, store.internalGetLocationCount());
+ }
+ // remove "null" context, should never happen - ignored
+ SourceContainer sourceContainer = new DirectoryBasedSourceContainer("/path/");
+ store.removeSources(null, sourceContainer);
+ assertEquals(1, store.internalGetLocationCount());
+ }
+
public void test_removeSources_withDeclaration() throws Exception {
Location locationB = mockLocation(elementB);
Location locationC = mockLocation(elementC);

Powered by Google App Engine
This is Rietveld 408576698