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

Side by Side Diff: pkg/analysis_server/test/services/search/search_engine_test.dart

Issue 844593003: Remove Angular support from the analyzer and analysis_server packages. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 years, 11 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.services.src.search.search_engine; 5 library test.services.src.search.search_engine;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 8
9 import 'package:analysis_server/src/services/index/index.dart'; 9 import 'package:analysis_server/src/services/index/index.dart';
10 import 'package:analysis_server/src/services/index/local_memory_index.dart'; 10 import 'package:analysis_server/src/services/index/local_memory_index.dart';
11 import 'package:analysis_server/src/services/search/search_engine.dart'; 11 import 'package:analysis_server/src/services/search/search_engine.dart';
12 import 'package:analysis_server/src/services/search/search_engine_internal.dart' ; 12 import 'package:analysis_server/src/services/search/search_engine_internal.dart' ;
13 import 'package:analyzer/src/generated/element.dart'; 13 import 'package:analyzer/src/generated/element.dart';
14 import 'package:analyzer/src/generated/source.dart'; 14 import 'package:analyzer/src/generated/source.dart';
15 import 'package:typed_mock/typed_mock.dart'; 15 import 'package:typed_mock/typed_mock.dart';
16 import 'package:unittest/unittest.dart'; 16 import 'package:unittest/unittest.dart';
17 17
18 import '../../abstract_single_unit.dart'; 18 import '../../abstract_single_unit.dart';
19 import '../../mocks.dart';
20 import '../../reflective_tests.dart'; 19 import '../../reflective_tests.dart';
21 20
22 21
23 main() { 22 main() {
24 groupSep = ' | '; 23 groupSep = ' | ';
25 runReflectiveTests(SearchEngineImplTest); 24 runReflectiveTests(SearchEngineImplTest);
26 } 25 }
27 26
28 class ExpectedMatch { 27 class ExpectedMatch {
29 final Element element; 28 final Element element;
(...skipping 27 matching lines...) Expand all
57 buffer.write(", isResolved="); 56 buffer.write(", isResolved=");
58 buffer.write(isResolved); 57 buffer.write(isResolved);
59 buffer.write(", isQualified="); 58 buffer.write(", isQualified=");
60 buffer.write(isQualified); 59 buffer.write(isQualified);
61 buffer.write(")"); 60 buffer.write(")");
62 return buffer.toString(); 61 return buffer.toString();
63 } 62 }
64 } 63 }
65 64
66 65
67 class MockAngularComponentElement extends TypedMock implements
68 AngularComponentElement {
69 final kind = ElementKind.ANGULAR_COMPONENT;
70 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation);
71 }
72
73
74 class MockAngularControllerElement extends TypedMock implements
75 AngularControllerElement {
76 final kind = ElementKind.ANGULAR_CONTROLLER;
77 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation);
78 }
79
80
81 class MockAngularFormatterElement extends TypedMock implements
82 AngularFormatterElement {
83 final kind = ElementKind.ANGULAR_FORMATTER;
84 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation);
85 }
86
87
88 class MockIndex extends TypedMock implements Index { 66 class MockIndex extends TypedMock implements Index {
89 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation); 67 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation);
90 } 68 }
91 69
92 70
93 @ReflectiveTestCase() 71 @ReflectiveTestCase()
94 class SearchEngineImplTest extends AbstractSingleUnitTest { 72 class SearchEngineImplTest extends AbstractSingleUnitTest {
95 Index index; 73 Index index;
96 SearchEngineImpl searchEngine; 74 SearchEngineImpl searchEngine;
97 75
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
182 _expectIdQ(main, MatchKind.READ, 'test); // a-read-r-q'), 160 _expectIdQ(main, MatchKind.READ, 'test); // a-read-r-q'),
183 _expectIdU(main, MatchKind.INVOCATION, 'test(); // p-inv-ur-q'), 161 _expectIdU(main, MatchKind.INVOCATION, 'test(); // p-inv-ur-q'),
184 _expectIdU(main, MatchKind.WRITE, 'test = 1; // p-write-ur-q'), 162 _expectIdU(main, MatchKind.WRITE, 'test = 1; // p-write-ur-q'),
185 _expectIdU(main, MatchKind.READ_WRITE, 'test += 2; // p-read-write-ur-q' ), 163 _expectIdU(main, MatchKind.READ_WRITE, 'test += 2; // p-read-write-ur-q' ),
186 _expectIdU(main, MatchKind.READ, 'test); // p-read-ur-q'),]; 164 _expectIdU(main, MatchKind.READ, 'test); // p-read-ur-q'),];
187 return searchEngine.searchMemberReferences('test').then((matches) { 165 return searchEngine.searchMemberReferences('test').then((matches) {
188 _assertMatches(matches, expected); 166 _assertMatches(matches, expected);
189 }); 167 });
190 } 168 }
191 169
192 Future test_searchReferences_AngularComponentElement() {
193 // use mocks
194 index = new MockIndex();
195 searchEngine = new SearchEngineImpl(index);
196 Element elementA = new MockElement('A');
197 Element elementB = new MockElement('B');
198 // fill mocks
199 AngularComponentElement element = new MockAngularComponentElement();
200 void mockLocation(Element element, Relationship relationship,
201 Location location) {
202 index.getRelationships(element, relationship);
203 when(null).thenReturn(new Future.value([location]));
204 }
205 mockLocation(
206 element,
207 IndexConstants.ANGULAR_REFERENCE,
208 new Location(elementA, 1, 10));
209 mockLocation(
210 element,
211 IndexConstants.ANGULAR_CLOSING_TAG_REFERENCE,
212 new Location(elementB, 2, 20));
213 var expected = [
214 new ExpectedMatch(elementA, MatchKind.ANGULAR_REFERENCE, 1, 10),
215 new ExpectedMatch(elementB, MatchKind.ANGULAR_CLOSING_TAG_REFERENCE, 2, 20)];
216 return _verifyReferences(element, expected);
217 }
218
219 Future test_searchReferences_ClassElement() { 170 Future test_searchReferences_ClassElement() {
220 _indexTestUnit(''' 171 _indexTestUnit('''
221 class A {} 172 class A {}
222 main(A p) { 173 main(A p) {
223 A v; 174 A v;
224 } 175 }
225 '''); 176 ''');
226 ClassElement element = findElement('A'); 177 ClassElement element = findElement('A');
227 Element pElement = findElement('p'); 178 Element pElement = findElement('p');
228 Element vElement = findElement('v'); 179 Element vElement = findElement('v');
(...skipping 460 matching lines...) Expand 10 before | Expand all | Expand 10 after
689 pattern).then((List<SearchMatch> matches) { 640 pattern).then((List<SearchMatch> matches) {
690 _assertMatches(matches, expectedMatches); 641 _assertMatches(matches, expectedMatches);
691 }); 642 });
692 } 643 }
693 644
694 static void _assertMatches(List<SearchMatch> matches, 645 static void _assertMatches(List<SearchMatch> matches,
695 List<ExpectedMatch> expectedMatches) { 646 List<ExpectedMatch> expectedMatches) {
696 expect(matches, unorderedEquals(expectedMatches)); 647 expect(matches, unorderedEquals(expectedMatches));
697 } 648 }
698 } 649 }
OLDNEW
« no previous file with comments | « pkg/analysis_server/test/protocol_server_test.dart ('k') | pkg/analyzer/lib/src/analyzer_impl.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698