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

Side by Side Diff: pkg/analysis_server/test/index/split_store_test.dart

Issue 347153002: Use single quotes for index store. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, 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.index.split.store; 5 library test.index.split.store;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 import 'dart:collection'; 8 import 'dart:collection';
9 9
10 import 'package:analysis_server/src/index/split_store.dart'; 10 import 'package:analysis_server/src/index/split_store.dart';
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 AnalysisContext context = new _MockAnalysisContext('context'); 87 AnalysisContext context = new _MockAnalysisContext('context');
88 StringCodec stringCodec = new StringCodec(); 88 StringCodec stringCodec = new StringCodec();
89 89
90 void setUp() { 90 void setUp() {
91 codec = new ElementCodec(stringCodec); 91 codec = new ElementCodec(stringCodec);
92 } 92 }
93 93
94 void test_localLocalVariable() { 94 void test_localLocalVariable() {
95 { 95 {
96 Element element = new _MockElement(); 96 Element element = new _MockElement();
97 ElementLocation location = new ElementLocationImpl.con3(["main", "foo@1", 97 ElementLocation location = new ElementLocationImpl.con3(['main', 'foo@1',
98 "bar@2"]); 98 'bar@2']);
99 when(context.getElement(location)).thenReturn(element); 99 when(context.getElement(location)).thenReturn(element);
100 when(element.location).thenReturn(location); 100 when(element.location).thenReturn(location);
101 int id = codec.encode(element); 101 int id = codec.encode(element);
102 expect(codec.decode(context, id), element); 102 expect(codec.decode(context, id), element);
103 } 103 }
104 { 104 {
105 Element element = new _MockElement(); 105 Element element = new _MockElement();
106 ElementLocation location = new ElementLocationImpl.con3(["main", "foo@10", 106 ElementLocation location = new ElementLocationImpl.con3(['main', 'foo@10',
107 "bar@20"]); 107 'bar@20']);
108 when(context.getElement(location)).thenReturn(element); 108 when(context.getElement(location)).thenReturn(element);
109 when(element.location).thenReturn(location); 109 when(element.location).thenReturn(location);
110 int id = codec.encode(element); 110 int id = codec.encode(element);
111 expect(codec.decode(context, id), element); 111 expect(codec.decode(context, id), element);
112 } 112 }
113 // check strings, "foo" as a single string, no "foo@1" or "foo@10" 113 // check strings, "foo" as a single string, no "foo@1" or "foo@10"
114 expect(stringCodec.nameToIndex, hasLength(3)); 114 expect(stringCodec.nameToIndex, hasLength(3));
115 expect(stringCodec.nameToIndex, containsPair('main', 0)); 115 expect(stringCodec.nameToIndex, containsPair('main', 0));
116 expect(stringCodec.nameToIndex, containsPair('foo', 1)); 116 expect(stringCodec.nameToIndex, containsPair('foo', 1));
117 expect(stringCodec.nameToIndex, containsPair('bar', 2)); 117 expect(stringCodec.nameToIndex, containsPair('bar', 2));
118 } 118 }
119 119
120 void test_localVariable() { 120 void test_localVariable() {
121 { 121 {
122 Element element = new _MockElement(); 122 Element element = new _MockElement();
123 ElementLocation location = new ElementLocationImpl.con3(["main", 123 ElementLocation location = new ElementLocationImpl.con3(['main',
124 "foo@42"]); 124 'foo@42']);
125 when(context.getElement(location)).thenReturn(element); 125 when(context.getElement(location)).thenReturn(element);
126 when(element.location).thenReturn(location); 126 when(element.location).thenReturn(location);
127 int id = codec.encode(element); 127 int id = codec.encode(element);
128 expect(codec.decode(context, id), element); 128 expect(codec.decode(context, id), element);
129 } 129 }
130 { 130 {
131 Element element = new _MockElement(); 131 Element element = new _MockElement();
132 ElementLocation location = new ElementLocationImpl.con3(["main", 132 ElementLocation location = new ElementLocationImpl.con3(['main',
133 "foo@4200"]); 133 'foo@4200']);
134 when(context.getElement(location)).thenReturn(element); 134 when(context.getElement(location)).thenReturn(element);
135 when(element.location).thenReturn(location); 135 when(element.location).thenReturn(location);
136 int id = codec.encode(element); 136 int id = codec.encode(element);
137 expect(codec.decode(context, id), element); 137 expect(codec.decode(context, id), element);
138 } 138 }
139 // check strings, "foo" as a single string, no "foo@42" or "foo@4200" 139 // check strings, "foo" as a single string, no "foo@42" or "foo@4200"
140 expect(stringCodec.nameToIndex, hasLength(2)); 140 expect(stringCodec.nameToIndex, hasLength(2));
141 expect(stringCodec.nameToIndex, containsPair('main', 0)); 141 expect(stringCodec.nameToIndex, containsPair('main', 0));
142 expect(stringCodec.nameToIndex, containsPair('foo', 1)); 142 expect(stringCodec.nameToIndex, containsPair('foo', 1));
143 } 143 }
144 144
145 void test_notLocal() { 145 void test_notLocal() {
146 Element element = new _MockElement(); 146 Element element = new _MockElement();
147 ElementLocation location = new ElementLocationImpl.con3(["foo", "bar"]); 147 ElementLocation location = new ElementLocationImpl.con3(['foo', 'bar']);
148 when(element.location).thenReturn(location); 148 when(element.location).thenReturn(location);
149 when(context.getElement(location)).thenReturn(element); 149 when(context.getElement(location)).thenReturn(element);
150 int id = codec.encode(element); 150 int id = codec.encode(element);
151 expect(codec.encode(element), id); 151 expect(codec.encode(element), id);
152 expect(codec.decode(context, id), element); 152 expect(codec.decode(context, id), element);
153 // check strings 153 // check strings
154 expect(stringCodec.nameToIndex, hasLength(2)); 154 expect(stringCodec.nameToIndex, hasLength(2));
155 expect(stringCodec.nameToIndex, containsPair('foo', 0)); 155 expect(stringCodec.nameToIndex, containsPair('foo', 0));
156 expect(stringCodec.nameToIndex, containsPair('bar', 1)); 156 expect(stringCodec.nameToIndex, containsPair('bar', 1));
157 } 157 }
(...skipping 24 matching lines...) Expand all
182 void test_clear() { 182 void test_clear() {
183 nodeManager.clear(); 183 nodeManager.clear();
184 verify(fileManager.clear()).once(); 184 verify(fileManager.clear()).once();
185 } 185 }
186 186
187 void test_getLocationCount_empty() { 187 void test_getLocationCount_empty() {
188 expect(nodeManager.locationCount, 0); 188 expect(nodeManager.locationCount, 0);
189 } 189 }
190 190
191 void test_getNode_contextNull() { 191 void test_getNode_contextNull() {
192 String name = "42.index"; 192 String name = '42.index';
193 // record bytes 193 // record bytes
194 List<int> bytes; 194 List<int> bytes;
195 when(fileManager.write(name, anyObject)).thenInvoke((name, bs) { 195 when(fileManager.write(name, anyObject)).thenInvoke((name, bs) {
196 bytes = bs; 196 bytes = bs;
197 }); 197 });
198 // put Node 198 // put Node
199 Future putFuture; 199 Future putFuture;
200 { 200 {
201 IndexNode node = new IndexNode(context, elementCodec, relationshipCodec); 201 IndexNode node = new IndexNode(context, elementCodec, relationshipCodec);
202 putFuture = nodeManager.putNode(name, node); 202 putFuture = nodeManager.putNode(name, node);
203 } 203 }
204 // do in the "put" Future 204 // do in the "put" Future
205 putFuture.then((_) { 205 putFuture.then((_) {
206 // force "null" context 206 // force "null" context
207 when(contextCodec.decode(contextId)).thenReturn(null); 207 when(contextCodec.decode(contextId)).thenReturn(null);
208 // prepare input bytes 208 // prepare input bytes
209 when(fileManager.read(name)).thenReturn(new Future.value(bytes)); 209 when(fileManager.read(name)).thenReturn(new Future.value(bytes));
210 // get Node 210 // get Node
211 return nodeManager.getNode(name).then((IndexNode node) { 211 return nodeManager.getNode(name).then((IndexNode node) {
212 expect(node, isNull); 212 expect(node, isNull);
213 // no exceptions 213 // no exceptions
214 verifyZeroInteractions(logger); 214 verifyZeroInteractions(logger);
215 }); 215 });
216 }); 216 });
217 } 217 }
218 218
219 test_getNode_invalidVersion() { 219 test_getNode_invalidVersion() {
220 String name = "42.index"; 220 String name = '42.index';
221 // prepare a stream with an invalid version 221 // prepare a stream with an invalid version
222 when(fileManager.read(name)).thenReturn(new Future.value([0x01, 0x02, 0x03, 222 when(fileManager.read(name)).thenReturn(new Future.value([0x01, 0x02, 0x03,
223 0x04])); 223 0x04]));
224 // do in the Future 224 // do in the Future
225 return nodeManager.getNode(name).then((IndexNode node) { 225 return nodeManager.getNode(name).then((IndexNode node) {
226 // no IndexNode 226 // no IndexNode
227 expect(node, isNull); 227 expect(node, isNull);
228 // failed 228 // failed
229 verify(logger.logError2(anyObject, anyObject)).once(); 229 verify(logger.logError2(anyObject, anyObject)).once();
230 }); 230 });
231 } 231 }
232 232
233 test_getNode_streamException() { 233 test_getNode_streamException() {
234 String name = "42.index"; 234 String name = '42.index';
235 when(fileManager.read(name)).thenReturn(new Future(() { 235 when(fileManager.read(name)).thenReturn(new Future(() {
236 return throw new Exception(); 236 return throw new Exception();
237 })); 237 }));
238 // do in the Future 238 // do in the Future
239 return nodeManager.getNode(name).then((IndexNode node) { 239 return nodeManager.getNode(name).then((IndexNode node) {
240 expect(node, isNull); 240 expect(node, isNull);
241 // failed 241 // failed
242 verify(logger.logError2(anyString, anyObject)).once(); 242 verify(logger.logError2(anyString, anyObject)).once();
243 }); 243 });
244 } 244 }
245 245
246 test_getNode_streamNull() { 246 test_getNode_streamNull() {
247 String name = "42.index"; 247 String name = '42.index';
248 when(fileManager.read(name)).thenReturn(new Future.value(null)); 248 when(fileManager.read(name)).thenReturn(new Future.value(null));
249 // do in the Future 249 // do in the Future
250 return nodeManager.getNode(name).then((IndexNode node) { 250 return nodeManager.getNode(name).then((IndexNode node) {
251 expect(node, isNull); 251 expect(node, isNull);
252 // OK 252 // OK
253 verifyZeroInteractions(logger); 253 verifyZeroInteractions(logger);
254 }); 254 });
255 } 255 }
256 256
257 void test_newNode() { 257 void test_newNode() {
258 IndexNode node = nodeManager.newNode(context); 258 IndexNode node = nodeManager.newNode(context);
259 expect(node.context, context); 259 expect(node.context, context);
260 expect(node.locationCount, 0); 260 expect(node.locationCount, 0);
261 } 261 }
262 262
263 test_putNode_getNode() { 263 test_putNode_getNode() {
264 String name = "42.index"; 264 String name = '42.index';
265 // record bytes 265 // record bytes
266 List<int> bytes; 266 List<int> bytes;
267 when(fileManager.write(name, anyObject)).thenInvoke((name, bs) { 267 when(fileManager.write(name, anyObject)).thenInvoke((name, bs) {
268 bytes = bs; 268 bytes = bs;
269 }); 269 });
270 // prepare elements 270 // prepare elements
271 Element elementA = _mockElement(); 271 Element elementA = _mockElement();
272 Element elementB = _mockElement(); 272 Element elementB = _mockElement();
273 Element elementC = _mockElement(); 273 Element elementC = _mockElement();
274 Relationship relationship = Relationship.getRelationship("my-relationship"); 274 Relationship relationship = Relationship.getRelationship('my-relationship');
275 // put Node 275 // put Node
276 Future putFuture; 276 Future putFuture;
277 { 277 {
278 // prepare relations 278 // prepare relations
279 int elementIdA = 0; 279 int elementIdA = 0;
280 int elementIdB = 1; 280 int elementIdB = 1;
281 int elementIdC = 2; 281 int elementIdC = 2;
282 int relationshipId = relationshipCodec.encode(relationship); 282 int relationshipId = relationshipCodec.encode(relationship);
283 RelationKeyData key = new RelationKeyData.forData(elementIdA, 283 RelationKeyData key = new RelationKeyData.forData(elementIdA,
284 relationshipId); 284 relationshipId);
(...skipping 24 matching lines...) Expand all
309 relationship); 309 relationship);
310 expect(locations, hasLength(2)); 310 expect(locations, hasLength(2));
311 _assertHasLocation(locations, elementB, 1, 10); 311 _assertHasLocation(locations, elementB, 1, 10);
312 _assertHasLocation(locations, elementC, 2, 20); 312 _assertHasLocation(locations, elementC, 2, 20);
313 } 313 }
314 }); 314 });
315 }); 315 });
316 } 316 }
317 317
318 test_putNode_streamException() { 318 test_putNode_streamException() {
319 String name = "42.index"; 319 String name = '42.index';
320 Exception exception = new Exception(); 320 Exception exception = new Exception();
321 when(fileManager.write(name, anyObject)).thenReturn(new Future(() { 321 when(fileManager.write(name, anyObject)).thenReturn(new Future(() {
322 return throw exception; 322 return throw exception;
323 })); 323 }));
324 // prepare IndexNode 324 // prepare IndexNode
325 IndexNode node = new _MockIndexNode(); 325 IndexNode node = new _MockIndexNode();
326 when(node.context).thenReturn(context); 326 when(node.context).thenReturn(context);
327 when(node.locationCount).thenReturn(0); 327 when(node.locationCount).thenReturn(0);
328 when(node.relations).thenReturn({}); 328 when(node.relations).thenReturn({});
329 // try to put 329 // try to put
330 return nodeManager.putNode(name, node).then((_) { 330 return nodeManager.putNode(name, node).then((_) {
331 // failed 331 // failed
332 verify(logger.logError2(anyString, anyObject)).once(); 332 verify(logger.logError2(anyString, anyObject)).once();
333 }); 333 });
334 } 334 }
335 335
336 void test_removeNode() { 336 void test_removeNode() {
337 String name = "42.index"; 337 String name = '42.index';
338 nodeManager.removeNode(name); 338 nodeManager.removeNode(name);
339 verify(fileManager.delete(name)).once(); 339 verify(fileManager.delete(name)).once();
340 } 340 }
341 341
342 Element _mockElement() { 342 Element _mockElement() {
343 int elementId = nextElementId++; 343 int elementId = nextElementId++;
344 Element element = new _MockElement(); 344 Element element = new _MockElement();
345 when(elementCodec.encode(element)).thenReturn(elementId); 345 when(elementCodec.encode(element)).thenReturn(elementId);
346 when(elementCodec.decode(context, elementId)).thenReturn(element); 346 when(elementCodec.decode(context, elementId)).thenReturn(element);
347 return element; 347 return element;
(...skipping 16 matching lines...) Expand all
364 } 364 }
365 365
366 void test_getContext() { 366 void test_getContext() {
367 expect(node.context, context); 367 expect(node.context, context);
368 } 368 }
369 369
370 void test_recordRelationship() { 370 void test_recordRelationship() {
371 Element elementA = _mockElement(); 371 Element elementA = _mockElement();
372 Element elementB = _mockElement(); 372 Element elementB = _mockElement();
373 Element elementC = _mockElement(); 373 Element elementC = _mockElement();
374 Relationship relationship = Relationship.getRelationship("my-relationship"); 374 Relationship relationship = Relationship.getRelationship('my-relationship');
375 Location locationA = new Location(elementB, 1, 2); 375 Location locationA = new Location(elementB, 1, 2);
376 Location locationB = new Location(elementC, 10, 20); 376 Location locationB = new Location(elementC, 10, 20);
377 // empty initially 377 // empty initially
378 expect(node.locationCount, 0); 378 expect(node.locationCount, 0);
379 // record 379 // record
380 node.recordRelationship(elementA, relationship, locationA); 380 node.recordRelationship(elementA, relationship, locationA);
381 expect(node.locationCount, 1); 381 expect(node.locationCount, 1);
382 node.recordRelationship(elementA, relationship, locationB); 382 node.recordRelationship(elementA, relationship, locationB);
383 expect(node.locationCount, 2); 383 expect(node.locationCount, 2);
384 // get relations 384 // get relations
(...skipping 10 matching lines...) Expand all
395 expect(relations, hasLength(1)); 395 expect(relations, hasLength(1));
396 List<LocationData> locations = relations.values.first; 396 List<LocationData> locations = relations.values.first;
397 expect(locations, hasLength(2)); 397 expect(locations, hasLength(2));
398 } 398 }
399 } 399 }
400 400
401 void test_setRelations() { 401 void test_setRelations() {
402 Element elementA = _mockElement(); 402 Element elementA = _mockElement();
403 Element elementB = _mockElement(); 403 Element elementB = _mockElement();
404 Element elementC = _mockElement(); 404 Element elementC = _mockElement();
405 Relationship relationship = Relationship.getRelationship("my-relationship"); 405 Relationship relationship = Relationship.getRelationship('my-relationship');
406 // record 406 // record
407 { 407 {
408 int elementIdA = 0; 408 int elementIdA = 0;
409 int elementIdB = 1; 409 int elementIdB = 1;
410 int elementIdC = 2; 410 int elementIdC = 2;
411 int relationshipId = relationshipCodec.encode(relationship); 411 int relationshipId = relationshipCodec.encode(relationship);
412 RelationKeyData key = new RelationKeyData.forData(elementIdA, 412 RelationKeyData key = new RelationKeyData.forData(elementIdA,
413 relationshipId); 413 relationshipId);
414 List<LocationData> locations = [new LocationData.forData(elementIdB, 1, 414 List<LocationData> locations = [new LocationData.forData(elementIdB, 1,
415 10), new LocationData.forData(elementIdC, 2, 20)]; 415 10), new LocationData.forData(elementIdC, 2, 20)];
(...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after
729 expect(keyData == keyData, isTrue); 729 expect(keyData == keyData, isTrue);
730 expect(keyData == new RelationKeyData.forData(1, 2), isTrue); 730 expect(keyData == new RelationKeyData.forData(1, 2), isTrue);
731 } 731 }
732 732
733 void test_newFromObjects() { 733 void test_newFromObjects() {
734 // prepare Element 734 // prepare Element
735 Element element; 735 Element element;
736 int elementId = 2; 736 int elementId = 2;
737 { 737 {
738 element = new _MockElement(); 738 element = new _MockElement();
739 ElementLocation location = new ElementLocationImpl.con3(["foo", "bar"]); 739 ElementLocation location = new ElementLocationImpl.con3(['foo', 'bar']);
740 when(element.location).thenReturn(location); 740 when(element.location).thenReturn(location);
741 when(context.getElement(location)).thenReturn(element); 741 when(context.getElement(location)).thenReturn(element);
742 when(elementCodec.encode(element)).thenReturn(elementId); 742 when(elementCodec.encode(element)).thenReturn(elementId);
743 } 743 }
744 // prepare relationship 744 // prepare relationship
745 Relationship relationship = Relationship.getRelationship("my-relationship"); 745 Relationship relationship = Relationship.getRelationship('my-relationship');
746 int relationshipId = 1; 746 int relationshipId = 1;
747 when(relationshipCodec.encode(relationship)).thenReturn(relationshipId); 747 when(relationshipCodec.encode(relationship)).thenReturn(relationshipId);
748 // create RelationKeyData 748 // create RelationKeyData
749 RelationKeyData keyData = new RelationKeyData.forObject(elementCodec, 749 RelationKeyData keyData = new RelationKeyData.forObject(elementCodec,
750 relationshipCodec, element, relationship); 750 relationshipCodec, element, relationship);
751 // touch 751 // touch
752 keyData.hashCode; 752 keyData.hashCode;
753 // equals 753 // equals
754 expect(keyData == this, isFalse); 754 expect(keyData == this, isFalse);
755 expect(keyData == new RelationKeyData.forData(10, 20), isFalse); 755 expect(keyData == new RelationKeyData.forData(10, 20), isFalse);
756 expect(keyData == keyData, isTrue); 756 expect(keyData == keyData, isTrue);
757 expect(keyData == new RelationKeyData.forData(elementId, relationshipId), 757 expect(keyData == new RelationKeyData.forData(elementId, relationshipId),
758 isTrue); 758 isTrue);
759 } 759 }
760 } 760 }
761 761
762 762
763 @ReflectiveTestCase() 763 @ReflectiveTestCase()
764 class _RelationshipCodecTest { 764 class _RelationshipCodecTest {
765 RelationshipCodec codec; 765 RelationshipCodec codec;
766 StringCodec stringCodec = new StringCodec(); 766 StringCodec stringCodec = new StringCodec();
767 767
768 void setUp() { 768 void setUp() {
769 codec = new RelationshipCodec(stringCodec); 769 codec = new RelationshipCodec(stringCodec);
770 } 770 }
771 771
772 void test_all() { 772 void test_all() {
773 Relationship relationship = Relationship.getRelationship("my-relationship"); 773 Relationship relationship = Relationship.getRelationship('my-relationship');
774 int id = codec.encode(relationship); 774 int id = codec.encode(relationship);
775 expect(codec.decode(id), relationship); 775 expect(codec.decode(id), relationship);
776 } 776 }
777 } 777 }
778 778
779 779
780 class _SingleSourceContainer implements SourceContainer { 780 class _SingleSourceContainer implements SourceContainer {
781 final Source _source; 781 final Source _source;
782 _SingleSourceContainer(this._source); 782 _SingleSourceContainer(this._source);
783 @override 783 @override
784 bool contains(Source source) => source == _source; 784 bool contains(Source source) => source == _source;
785 } 785 }
786 786
787 787
788 @ReflectiveTestCase() 788 @ReflectiveTestCase()
789 class _SplitIndexStoreTest { 789 class _SplitIndexStoreTest {
790 AnalysisContext contextA = new _MockAnalysisContext('contextA'); 790 AnalysisContext contextA = new _MockAnalysisContext('contextA');
791 791
792 AnalysisContext contextB = new _MockAnalysisContext('contextB'); 792 AnalysisContext contextB = new _MockAnalysisContext('contextB');
793 793
794 AnalysisContext contextC = new _MockAnalysisContext('contextC'); 794 AnalysisContext contextC = new _MockAnalysisContext('contextC');
795 795
796 Element elementA = new _MockElement('elementA'); 796 Element elementA = new _MockElement('elementA');
797 Element elementB = new _MockElement('elementB'); 797 Element elementB = new _MockElement('elementB');
798 798
799 Element elementC = new _MockElement('elementC'); 799 Element elementC = new _MockElement('elementC');
800 Element elementD = new _MockElement('elementD'); 800 Element elementD = new _MockElement('elementD');
801 ElementLocation elementLocationA = new ElementLocationImpl.con3( 801 ElementLocation elementLocationA = new ElementLocationImpl.con3(
802 ["/home/user/sourceA.dart", "ClassA"]); 802 ['/home/user/sourceA.dart', 'ClassA']);
803 ElementLocation elementLocationB = new ElementLocationImpl.con3( 803 ElementLocation elementLocationB = new ElementLocationImpl.con3(
804 ["/home/user/sourceB.dart", "ClassB"]); 804 ['/home/user/sourceB.dart', 'ClassB']);
805 ElementLocation elementLocationC = new ElementLocationImpl.con3( 805 ElementLocation elementLocationC = new ElementLocationImpl.con3(
806 ["/home/user/sourceC.dart", "ClassC"]); 806 ['/home/user/sourceC.dart', 'ClassC']);
807 ElementLocation elementLocationD = new ElementLocationImpl.con3( 807 ElementLocation elementLocationD = new ElementLocationImpl.con3(
808 ["/home/user/sourceD.dart", "ClassD"]); 808 ['/home/user/sourceD.dart', 'ClassD']);
809 HtmlElement htmlElementA = new _MockHtmlElement(); 809 HtmlElement htmlElementA = new _MockHtmlElement();
810 HtmlElement htmlElementB = new _MockHtmlElement(); 810 HtmlElement htmlElementB = new _MockHtmlElement();
811 LibraryElement libraryElement = new _MockLibraryElement(); 811 LibraryElement libraryElement = new _MockLibraryElement();
812 Source librarySource = new _MockSource('librarySource'); 812 Source librarySource = new _MockSource('librarySource');
813 CompilationUnitElement libraryUnitElement = new _MockCompilationUnitElement(); 813 CompilationUnitElement libraryUnitElement = new _MockCompilationUnitElement();
814 _MemoryNodeManager nodeManager = new _MemoryNodeManager(); 814 _MemoryNodeManager nodeManager = new _MemoryNodeManager();
815 Relationship relationship = Relationship.getRelationship("test-relationship"); 815 Relationship relationship = Relationship.getRelationship('test-relationship');
816 Source sourceA = new _MockSource('sourceA'); 816 Source sourceA = new _MockSource('sourceA');
817 Source sourceB = new _MockSource('sourceB'); 817 Source sourceB = new _MockSource('sourceB');
818 Source sourceC = new _MockSource('sourceC'); 818 Source sourceC = new _MockSource('sourceC');
819 Source sourceD = new _MockSource('sourceD'); 819 Source sourceD = new _MockSource('sourceD');
820 SplitIndexStore store; 820 SplitIndexStore store;
821 CompilationUnitElement unitElementA = new _MockCompilationUnitElement(); 821 CompilationUnitElement unitElementA = new _MockCompilationUnitElement();
822 CompilationUnitElement unitElementB = new _MockCompilationUnitElement(); 822 CompilationUnitElement unitElementB = new _MockCompilationUnitElement();
823 CompilationUnitElement unitElementC = new _MockCompilationUnitElement(); 823 CompilationUnitElement unitElementC = new _MockCompilationUnitElement();
824 CompilationUnitElement unitElementD = new _MockCompilationUnitElement(); 824 CompilationUnitElement unitElementD = new _MockCompilationUnitElement();
825 void setUp() { 825 void setUp() {
826 store = new SplitIndexStore(nodeManager); 826 store = new SplitIndexStore(nodeManager);
827 when(contextA.isDisposed).thenReturn(false); 827 when(contextA.isDisposed).thenReturn(false);
828 when(contextB.isDisposed).thenReturn(false); 828 when(contextB.isDisposed).thenReturn(false);
829 when(contextC.isDisposed).thenReturn(false); 829 when(contextC.isDisposed).thenReturn(false);
830 when(contextA.getElement(elementLocationA)).thenReturn(elementA); 830 when(contextA.getElement(elementLocationA)).thenReturn(elementA);
831 when(contextA.getElement(elementLocationB)).thenReturn(elementB); 831 when(contextA.getElement(elementLocationB)).thenReturn(elementB);
832 when(contextA.getElement(elementLocationC)).thenReturn(elementC); 832 when(contextA.getElement(elementLocationC)).thenReturn(elementC);
833 when(contextA.getElement(elementLocationD)).thenReturn(elementD); 833 when(contextA.getElement(elementLocationD)).thenReturn(elementD);
834 when(sourceA.fullName).thenReturn("/home/user/sourceA.dart"); 834 when(sourceA.fullName).thenReturn('/home/user/sourceA.dart');
835 when(sourceB.fullName).thenReturn("/home/user/sourceB.dart"); 835 when(sourceB.fullName).thenReturn('/home/user/sourceB.dart');
836 when(sourceC.fullName).thenReturn("/home/user/sourceC.dart"); 836 when(sourceC.fullName).thenReturn('/home/user/sourceC.dart');
837 when(sourceD.fullName).thenReturn("/home/user/sourceD.dart"); 837 when(sourceD.fullName).thenReturn('/home/user/sourceD.dart');
838 when(elementA.context).thenReturn(contextA); 838 when(elementA.context).thenReturn(contextA);
839 when(elementB.context).thenReturn(contextA); 839 when(elementB.context).thenReturn(contextA);
840 when(elementC.context).thenReturn(contextA); 840 when(elementC.context).thenReturn(contextA);
841 when(elementD.context).thenReturn(contextA); 841 when(elementD.context).thenReturn(contextA);
842 when(elementA.location).thenReturn(elementLocationA); 842 when(elementA.location).thenReturn(elementLocationA);
843 when(elementB.location).thenReturn(elementLocationB); 843 when(elementB.location).thenReturn(elementLocationB);
844 when(elementC.location).thenReturn(elementLocationC); 844 when(elementC.location).thenReturn(elementLocationC);
845 when(elementD.location).thenReturn(elementLocationD); 845 when(elementD.location).thenReturn(elementLocationD);
846 when(elementA.enclosingElement).thenReturn(unitElementA); 846 when(elementA.enclosingElement).thenReturn(unitElementA);
847 when(elementB.enclosingElement).thenReturn(unitElementB); 847 when(elementB.enclosingElement).thenReturn(unitElementB);
(...skipping 441 matching lines...) Expand 10 before | Expand all | Expand 10 after
1289 // remove "contextA" 1289 // remove "contextA"
1290 store.removeContext(contextA); 1290 store.removeContext(contextA);
1291 return store.getRelationshipsAsync(UniverseElement.INSTANCE, 1291 return store.getRelationshipsAsync(UniverseElement.INSTANCE,
1292 relationship).then((List<Location> locations) { 1292 relationship).then((List<Location> locations) {
1293 assertLocations(locations, [locationB]); 1293 assertLocations(locations, [locationB]);
1294 }); 1294 });
1295 }); 1295 });
1296 } 1296 }
1297 1297
1298 /** 1298 /**
1299 * Asserts that the "actual" locations have all the "expected" locations and o nly them. 1299 * Asserts that the [actual] locations have all the [expected] locations and
1300 * only them.
1300 */ 1301 */
1301 static void assertLocations(List<Location> actual, List<Location> expected) { 1302 static void assertLocations(List<Location> actual, List<Location> expected) {
1302 List<_LocationEqualsWrapper> actualWrappers = wrapLocations(actual); 1303 List<_LocationEqualsWrapper> actualWrappers = wrapLocations(actual);
1303 List<_LocationEqualsWrapper> expectedWrappers = wrapLocations(expected); 1304 List<_LocationEqualsWrapper> expectedWrappers = wrapLocations(expected);
1304 expect(actualWrappers, unorderedEquals(expectedWrappers)); 1305 expect(actualWrappers, unorderedEquals(expectedWrappers));
1305 } 1306 }
1306 1307
1307 /** 1308 /**
1308 * @return the new [Location] mock. 1309 * @return the new [Location] mock.
1309 */ 1310 */
(...skipping 22 matching lines...) Expand all
1332 class _StringCodecTest { 1333 class _StringCodecTest {
1333 StringCodec codec = new StringCodec(); 1334 StringCodec codec = new StringCodec();
1334 1335
1335 void test_all() { 1336 void test_all() {
1336 int idA = codec.encode('aaa'); 1337 int idA = codec.encode('aaa');
1337 int idB = codec.encode('bbb'); 1338 int idB = codec.encode('bbb');
1338 expect(codec.decode(idA), 'aaa'); 1339 expect(codec.decode(idA), 'aaa');
1339 expect(codec.decode(idB), 'bbb'); 1340 expect(codec.decode(idB), 'bbb');
1340 } 1341 }
1341 } 1342 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698