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

Side by Side Diff: pkg/analysis_server/test/integration/search/find_element_references_test.dart

Issue 2747893004: Add analysis server integration tests for the search domain. (Closed)
Patch Set: update todos Created 3 years, 9 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
OLDNEW
(Empty)
1 // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file
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.
4
5 import 'dart:async';
6
7 import 'package:analysis_server/plugin/protocol/protocol.dart';
8 import 'package:test/test.dart';
9 import 'package:test_reflective_loader/test_reflective_loader.dart';
10
11 import '../integration_tests.dart';
12
13 main() {
14 defineReflectiveSuite(() {
15 defineReflectiveTests(FindElementReferencesTest);
16 });
17 }
18
19 @reflectiveTest
20 class FindElementReferencesTest extends AbstractAnalysisServerIntegrationTest {
21 String pathname;
22
23 test_findReferences() async {
24 String text = r'''
25 main() {
26 print /* target */ ('Hello');
27 }
28 ''';
29
30 pathname = sourcePath('foo.dart');
31 writeFile(pathname, text);
32 standardAnalysisSetup();
33 await analysisFinished;
34
35 List<SearchResult> results = await _findElementReferences(text);
36 expect(results, hasLength(1));
37 SearchResult result = results.first;
38 expect(result.location.file, pathname);
39 expect(result.isPotential, false);
40 expect(result.kind.name, SearchResultKind.INVOCATION.name);
41 expect(result.path.first.name, 'main');
42 }
43
44 test_badTarget() async {
45 String text = r'''
46 main() {
47 if /* target */ (true) {
48 print('Hello');
49 }
50 }
51 ''';
52
53 pathname = sourcePath('foo.dart');
54 writeFile(pathname, text);
55 standardAnalysisSetup();
56 await analysisFinished;
57
58 List<SearchResult> results = await _findElementReferences(text);
59 expect(results, isNull);
60 }
61
62 Future<List<SearchResult>> _findElementReferences(String text) async {
63 int offset = text.indexOf(' /* target */') - 1;
64 SearchFindElementReferencesResult result =
65 await sendSearchFindElementReferences(pathname, offset, false);
66 if (result.id == null) return null;
67 SearchResultsParams searchParams = await onSearchResults.first;
68 expect(searchParams.id, result.id);
69 expect(searchParams.isLast, true);
Brian Wilkerson 2017/03/13 22:54:36 nit: 'true' --> 'isTrue'
devoncarew 2017/03/13 23:08:48 Done.
70 return searchParams.results;
71 }
72
73 @override
74 bool get enableNewAnalysisDriver => true;
75 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698