| 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.search.abstract_search_domain; | 5 library test.search.abstract_search_domain; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 | 8 |
| 9 import 'package:analysis_server/src/computer/element.dart'; | |
| 10 import 'package:analysis_server/src/constants.dart'; | 9 import 'package:analysis_server/src/constants.dart'; |
| 11 import 'package:analysis_server/src/protocol.dart'; | 10 import 'package:analysis_server/src/protocol.dart'; |
| 11 import 'package:analysis_server/src/protocol2.dart'; |
| 12 import 'package:analysis_server/src/search/search_domain.dart'; | 12 import 'package:analysis_server/src/search/search_domain.dart'; |
| 13 import 'package:analysis_server/src/search/search_result.dart'; | |
| 14 import 'package:analysis_server/src/services/index/index.dart' show Index; | 13 import 'package:analysis_server/src/services/index/index.dart' show Index; |
| 15 import 'package:analysis_server/src/services/index/local_memory_index.dart'; | 14 import 'package:analysis_server/src/services/index/local_memory_index.dart'; |
| 16 import 'package:unittest/unittest.dart'; | 15 import 'package:unittest/unittest.dart'; |
| 17 | 16 |
| 18 import '../analysis_abstract.dart'; | 17 import '../analysis_abstract.dart'; |
| 19 | 18 |
| 20 | 19 |
| 21 class AbstractSearchDomainTest extends AbstractAnalysisTest { | 20 class AbstractSearchDomainTest extends AbstractAnalysisTest { |
| 22 String searchId; | 21 String searchId; |
| 23 bool searchDone = false; | 22 bool searchDone = false; |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 69 | 68 |
| 70 String getPathString(List<Element> path) { | 69 String getPathString(List<Element> path) { |
| 71 return path.map((Element element) { | 70 return path.map((Element element) { |
| 72 return '${element.kind.name} ${element.name}'; | 71 return '${element.kind.name} ${element.name}'; |
| 73 }).join('\n'); | 72 }).join('\n'); |
| 74 } | 73 } |
| 75 | 74 |
| 76 @override | 75 @override |
| 77 void processNotification(Notification notification) { | 76 void processNotification(Notification notification) { |
| 78 if (notification.event == SEARCH_RESULTS) { | 77 if (notification.event == SEARCH_RESULTS) { |
| 79 String id = notification.getParameter(ID); | 78 var params = new SearchResultsParams.fromNotification(notification); |
| 80 if (id == searchId) { | 79 if (params.id == searchId) { |
| 81 for (Map<String, Object> json in notification.getParameter(RESULTS)) { | 80 results.addAll(params.results); |
| 82 results.add(new SearchResult.fromJson(json)); | 81 searchDone = params.last; |
| 83 } | |
| 84 searchDone = notification.getParameter(LAST); | |
| 85 } | 82 } |
| 86 } | 83 } |
| 87 } | 84 } |
| 88 | 85 |
| 89 @override | 86 @override |
| 90 void setUp() { | 87 void setUp() { |
| 91 super.setUp(); | 88 super.setUp(); |
| 92 createProject(); | 89 createProject(); |
| 93 handler = new SearchDomainHandler(server); | 90 handler = new SearchDomainHandler(server); |
| 94 } | 91 } |
| 95 | 92 |
| 96 Future waitForSearchResults() { | 93 Future waitForSearchResults() { |
| 97 if (searchDone) { | 94 if (searchDone) { |
| 98 return new Future.value(); | 95 return new Future.value(); |
| 99 } | 96 } |
| 100 return new Future.delayed(Duration.ZERO, waitForSearchResults); | 97 return new Future.delayed(Duration.ZERO, waitForSearchResults); |
| 101 } | 98 } |
| 102 } | 99 } |
| OLD | NEW |