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

Side by Side Diff: editor/tools/plugins/com.google.dart.engine_test/src/com/google/dart/engine/internal/index/file/IndexNodeTest.java

Issue 587743002: Version 1.7.0-dev.3.2 . (Closed) Base URL: http://dart.googlecode.com/svn/trunk/dart/
Patch Set: Created 6 years, 3 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 | Annotate | Revision Log
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2014, the Dart project authors. 2 * Copyright (c) 2014, the Dart project authors.
3 * 3 *
4 * Licensed under the Eclipse Public License v1.0 (the "License"); you may not u se this file except 4 * Licensed under the Eclipse Public License v1.0 (the "License"); you may not u se this file except
5 * in compliance with the License. You may obtain a copy of the License at 5 * in compliance with the License. You may obtain a copy of the License at
6 * 6 *
7 * http://www.eclipse.org/legal/epl-v10.html 7 * http://www.eclipse.org/legal/epl-v10.html
8 * 8 *
9 * Unless required by applicable law or agreed to in writing, software distribut ed under the License 9 * Unless required by applicable law or agreed to in writing, software distribut ed under the License
10 * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY K IND, either express 10 * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY K IND, either express
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 Map<RelationKeyData, List<LocationData>> relations = ImmutableMap.of(key, locations); 97 Map<RelationKeyData, List<LocationData>> relations = ImmutableMap.of(key, locations);
98 node.setRelations(relations); 98 node.setRelations(relations);
99 } 99 }
100 // request 100 // request
101 Location[] locations = node.getRelationships(elementA, relationship); 101 Location[] locations = node.getRelationships(elementA, relationship);
102 assertThat(locations).hasSize(2); 102 assertThat(locations).hasSize(2);
103 assertHasLocation(locations, elementB, 1, 10); 103 assertHasLocation(locations, elementB, 1, 10);
104 assertHasLocation(locations, elementC, 2, 20); 104 assertHasLocation(locations, elementC, 2, 20);
105 } 105 }
106 106
107 @Override
108 protected void tearDown() throws Exception {
109 stringCodec = null;
110 elementCodec = null;
111 relationshipCodec = null;
112 node = null;
113 super.tearDown();
114 }
115
107 private void assertHasLocation(Location[] locations, Element element, int offs et, int length) { 116 private void assertHasLocation(Location[] locations, Element element, int offs et, int length) {
108 for (Location location : locations) { 117 for (Location location : locations) {
109 if (Objects.equal(location.getElement(), element) && location.getOffset() == offset 118 if (Objects.equal(location.getElement(), element) && location.getOffset() == offset
110 && location.getLength() == length) { 119 && location.getLength() == length) {
111 return; 120 return;
112 } 121 }
113 } 122 }
114 fail("Expected to find Location(element=" + element + ", offset=" + offset + ", length=" 123 fail("Expected to find Location(element=" + element + ", offset=" + offset + ", length="
115 + length + ")"); 124 + length + ")");
116 } 125 }
117 126
118 private Element mockElement() { 127 private Element mockElement() {
119 int elementId = nextElementId++; 128 int elementId = nextElementId++;
120 Element element = mock(Element.class); 129 Element element = mock(Element.class);
121 when(elementCodec.encode(element)).thenReturn(elementId); 130 when(elementCodec.encode(element)).thenReturn(elementId);
122 when(elementCodec.decode(context, elementId)).thenReturn(element); 131 when(elementCodec.decode(context, elementId)).thenReturn(element);
123 return element; 132 return element;
124 } 133 }
125 } 134 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698