OLD | NEW |
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.domain.search; | 5 library test.domain.search; |
6 | 6 |
7 import 'dart:async'; | 7 import 'dart:async'; |
8 | 8 |
9 import 'package:analysis_server/src/analysis_server.dart'; | 9 import 'package:analysis_server/src/analysis_server.dart'; |
10 import 'package:analysis_server/src/constants.dart'; | 10 import 'package:analysis_server/src/constants.dart'; |
11 import 'package:analysis_server/src/domain_search.dart'; | 11 import 'package:analysis_server/src/domain_search.dart'; |
12 import 'package:analysis_server/src/index/index.dart'; | |
13 import 'package:analysis_server/src/protocol.dart'; | 12 import 'package:analysis_server/src/protocol.dart'; |
14 import 'package:analysis_server/src/resource.dart'; | 13 import 'package:analysis_server/src/resource.dart'; |
15 import 'package:analyzer/src/generated/index.dart'; | |
16 import 'package:unittest/unittest.dart'; | 14 import 'package:unittest/unittest.dart'; |
17 | 15 |
18 import 'analysis_abstract.dart'; | 16 import 'analysis_abstract.dart'; |
19 import 'index/store/memory_node_manager.dart'; | |
20 import 'mocks.dart'; | 17 import 'mocks.dart'; |
21 import 'reflective_tests.dart'; | 18 import 'reflective_tests.dart'; |
| 19 import 'package:analyzer/src/index/local_index.dart'; |
| 20 import 'package:analyzer/index/index.dart'; |
22 | 21 |
23 main() { | 22 main() { |
24 groupSep = ' | '; | 23 groupSep = ' | '; |
25 group('SearchDomainHandler', () { | 24 group('SearchDomainHandler', () { |
26 runReflectiveTests(SearchDomainTest); | 25 runReflectiveTests(SearchDomainTest); |
27 }); | 26 }); |
28 | 27 |
29 MockServerChannel serverChannel; | 28 MockServerChannel serverChannel; |
30 MemoryResourceProvider resourceProvider; | 29 MemoryResourceProvider resourceProvider; |
31 AnalysisServer server; | 30 AnalysisServer server; |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
75 }); | 74 }); |
76 }); | 75 }); |
77 } | 76 } |
78 | 77 |
79 @ReflectiveTestCase() | 78 @ReflectiveTestCase() |
80 class SearchDomainTest extends AbstractAnalysisTest { | 79 class SearchDomainTest extends AbstractAnalysisTest { |
81 LocalIndex index; | 80 LocalIndex index; |
82 | 81 |
83 @override | 82 @override |
84 Index createIndex() { | 83 Index createIndex() { |
85 return new LocalIndex(new MemoryNodeManager()); | 84 return createLocalMemorySplitIndex(); |
86 } | 85 } |
87 | 86 |
88 @override | 87 @override |
89 void setUp() { | 88 void setUp() { |
90 super.setUp(); | 89 super.setUp(); |
91 index = server.index; | 90 index = server.index; |
92 createProject(); | 91 createProject(); |
93 } | 92 } |
94 | 93 |
95 Future test_findTopLevelDeclarations() { | 94 Future test_findTopLevelDeclarations() { |
96 // TODO(scheglov) replace this temporary Index test with an actual | 95 // TODO(scheglov) replace this temporary Index test with an actual |
97 // SearchEngine and SearchDomainHandler test. | 96 // SearchEngine and SearchDomainHandler test. |
98 addTestFile(''' | 97 addTestFile(''' |
99 class AAA { | 98 class AAA { |
100 AAA() {} | 99 AAA() {} |
101 } | 100 } |
102 '''); | 101 '''); |
103 return waitForTasksFinished().then((_) { | 102 return waitForTasksFinished().then((_) { |
104 return index.getRelationshipsAsync(UniverseElement.INSTANCE, | 103 return index.getRelationships(UniverseElement.INSTANCE, |
105 IndexConstants.DEFINES_CLASS).then((List<Location> locations) { | 104 IndexConstants.DEFINES_CLASS).then((List<Location> locations) { |
106 bool hasClassFunction = false; | 105 bool hasClassFunction = false; |
107 bool hasClassAAA = false; | 106 bool hasClassAAA = false; |
108 for (var location in locations) { | 107 for (var location in locations) { |
109 if (location.element.name == 'Function') { | 108 if (location.element.name == 'Function') { |
110 hasClassFunction = true; | 109 hasClassFunction = true; |
111 } | 110 } |
112 if (location.element.name == 'AAA') { | 111 if (location.element.name == 'AAA') { |
113 hasClassAAA = true; | 112 hasClassAAA = true; |
114 } | 113 } |
115 } | 114 } |
116 expect(hasClassFunction, isTrue, reason: locations.toString()); | 115 expect(hasClassFunction, isTrue, reason: locations.toString()); |
117 expect(hasClassAAA, isTrue, reason: locations.toString()); | 116 expect(hasClassAAA, isTrue, reason: locations.toString()); |
118 }); | 117 }); |
119 }); | 118 }); |
120 } | 119 } |
121 } | 120 } |
OLD | NEW |