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

Unified Diff: pkg/analysis_server/test/search/element_references_test.dart

Issue 399483002: Implementation for 'search.findTopLevelDeclarations' API. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 5 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 side-by-side diff with in-line comments
Download patch
Index: pkg/analysis_server/test/search/element_references_test.dart
diff --git a/pkg/analysis_server/test/search/element_references_test.dart b/pkg/analysis_server/test/search/element_references_test.dart
index 578a5a0aa1a2f12a972a6f8dcb0a2f0b5a0a0d86..a71c005b03bd56422c6d88829cf918bb37644f9d 100644
--- a/pkg/analysis_server/test/search/element_references_test.dart
+++ b/pkg/analysis_server/test/search/element_references_test.dart
@@ -6,17 +6,13 @@ library test.search.element_references;
import 'dart:async';
-import 'package:analysis_server/src/computer/element.dart';
import 'package:analysis_server/src/constants.dart';
import 'package:analysis_server/src/protocol.dart';
-import 'package:analysis_server/src/search/search_domain.dart';
import 'package:analysis_server/src/search/search_result.dart';
-import 'package:analysis_services/index/index.dart' show Index;
-import 'package:analysis_services/index/local_memory_index.dart';
import 'package:analysis_testing/reflective_tests.dart';
import 'package:unittest/unittest.dart';
-import '../analysis_abstract.dart';
+import 'abstract_search_domain.dart';
main() {
@@ -28,33 +24,7 @@ main() {
@ReflectiveTestCase()
-class ElementReferencesTest extends AbstractAnalysisTest {
- String searchId;
- bool searchDone = false;
- List<SearchResult> results = <SearchResult>[];
- SearchResult result;
-
- void assertHasResult(SearchResultKind kind, String search, [int length]) {
- int offset = findOffset(search);
- if (length == null) {
- length = findIdentifierLength(search);
- }
- findResult(kind, testFile, offset, length, true);
- }
-
- void assertNoResult(SearchResultKind kind, String search, [int length]) {
- int offset = findOffset(search);
- if (length == null) {
- length = findIdentifierLength(search);
- }
- findResult(kind, testFile, offset, length, false);
- }
-
- @override
- Index createIndex() {
- return createLocalMemoryIndex();
- }
-
+class ElementReferencesTest extends AbstractSearchDomainTest {
Future findElementReferences(String search, bool includePotential) {
int offset = findOffset(search);
return waitForTasksFinished().then((_) {
@@ -65,57 +35,10 @@ class ElementReferencesTest extends AbstractAnalysisTest {
Response response = handleSuccessfulRequest(request);
searchId = response.getResult(ID);
results.clear();
- return _waitForSearchResults();
+ return waitForSearchResults();
});
}
- void findResult(SearchResultKind kind, String file, int offset, int length,
- bool expected) {
- for (SearchResult result in results) {
- Location location = result.location;
- if (result.kind == kind &&
- location.file == file &&
- location.offset == offset &&
- location.length == length) {
- if (!expected) {
- fail('Unexpected result $result in\n' + results.join('\n'));
- }
- this.result = result;
- return;
- }
- }
- if (expected) {
- fail(
- 'Not found: "search" kind=$kind offset=$offset length=$length\nin\n' +
- results.join('\n'));
- }
- }
-
- String getPathString(List<Element> path) {
- return path.map((Element element) {
- return '${element.kind} ${element.name}';
- }).join('\n');
- }
-
- void processNotification(Notification notification) {
- if (notification.event == SEARCH_RESULTS) {
- String id = notification.getParameter(ID);
- if (id == searchId) {
- for (Map<String, Object> json in notification.getParameter(RESULTS)) {
- results.add(new SearchResult.fromJson(json));
- }
- searchDone = notification.getParameter(LAST);
- }
- }
- }
-
- @override
- void setUp() {
- super.setUp();
- createProject();
- handler = new SearchDomainHandler(server);
- }
-
test_constructor_named() {
addTestFile('''
class A {
@@ -640,11 +563,4 @@ class A<T> {
assertHasResult(SearchResultKind.REFERENCE, 'T m()');
});
}
-
- Future _waitForSearchResults() {
- if (searchDone) {
- return new Future.value();
- }
- return new Future.delayed(Duration.ZERO, _waitForSearchResults);
- }
}
« no previous file with comments | « pkg/analysis_server/test/search/abstract_search_domain.dart ('k') | pkg/analysis_server/test/search/test_all.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698