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

Side by Side Diff: pkg/analysis_server/test/integration/analysis/get_hover_test.dart

Issue 1054063002: Fix 'getHover' integration test. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 years, 8 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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.integration.analysis.get.hover; 5 library test.integration.analysis.get.hover;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 8
9 import 'package:analysis_server/src/protocol.dart'; 9 import 'package:analysis_server/src/protocol.dart';
10 import 'package:path/path.dart'; 10 import 'package:path/path.dart';
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
55 * matching [staticTypeRegexps]. 55 * matching [staticTypeRegexps].
56 * 56 *
57 * [isCore] means the hover info should indicate that the element is defined 57 * [isCore] means the hover info should indicate that the element is defined
58 * in dart.core. [docRegexp], if specified, should match the documentation 58 * in dart.core. [docRegexp], if specified, should match the documentation
59 * string of the element. [isLiteral] means the hover should indicate a 59 * string of the element. [isLiteral] means the hover should indicate a
60 * literal value. [parameterRegexps] means is a set of regexps which should 60 * literal value. [parameterRegexps] means is a set of regexps which should
61 * match the hover parameters. [propagatedType], if specified, is the 61 * match the hover parameters. [propagatedType], if specified, is the
62 * expected propagated type of the element. 62 * expected propagated type of the element.
63 */ 63 */
64 checkHover(String target, int length, List<String> descriptionRegexps, 64 checkHover(String target, int length, List<String> descriptionRegexps,
65 String kind, List<String> staticTypeRegexps, {bool isCore: false, 65 String kind, List<String> staticTypeRegexps, {bool isLocal: false,
66 String docRegexp: null, bool isLiteral: false, 66 bool isCore: false, String docRegexp: null, bool isLiteral: false,
67 List<String> parameterRegexps: null, propagatedType: null}) { 67 List<String> parameterRegexps: null, propagatedType: null}) {
68 int offset = text.indexOf(target); 68 int offset = text.indexOf(target);
69 return sendAnalysisGetHover(pathname, offset).then((result) { 69 return sendAnalysisGetHover(pathname, offset).then((result) {
70 expect(result.hovers, hasLength(1)); 70 expect(result.hovers, hasLength(1));
71 HoverInformation info = result.hovers[0]; 71 HoverInformation info = result.hovers[0];
72 expect(info.offset, equals(offset)); 72 expect(info.offset, equals(offset));
73 expect(info.length, equals(length)); 73 expect(info.length, equals(length));
74 if (isCore) { 74 if (isCore) {
75 expect(basename(info.containingLibraryPath), equals('core.dart')); 75 expect(basename(info.containingLibraryPath), equals('core.dart'));
76 expect(info.containingLibraryName, equals('dart.core')); 76 expect(info.containingLibraryName, equals('dart.core'));
77 } else if (isLiteral) { 77 } else if (isLocal || isLiteral) {
78 expect(info.containingLibraryPath, isNull); 78 expect(info.containingLibraryPath, isNull);
79 expect(info.containingLibraryName, isNull); 79 expect(info.containingLibraryName, isNull);
80 } else { 80 } else {
81 expect(info.containingLibraryPath, equals(pathname)); 81 expect(info.containingLibraryPath, equals(pathname));
82 expect(info.containingLibraryName, equals('lib.test')); 82 expect(info.containingLibraryName, equals('lib.test'));
83 } 83 }
84 if (docRegexp == null) { 84 if (docRegexp == null) {
85 expect(info.dartdoc, isNull); 85 expect(info.dartdoc, isNull);
86 } else { 86 } else {
87 expect(info.dartdoc, matches(docRegexp)); 87 expect(info.dartdoc, matches(docRegexp));
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
134 134
135 test_getHover() { 135 test_getHover() {
136 writeFile(pathname, text); 136 writeFile(pathname, text);
137 standardAnalysisSetup(); 137 standardAnalysisSetup();
138 138
139 // Note: analysis.getHover doesn't wait for analysis to complete--it simply 139 // Note: analysis.getHover doesn't wait for analysis to complete--it simply
140 // returns the latest results that are available at the time that the 140 // returns the latest results that are available at the time that the
141 // request is made. So wait for analysis to finish before testing anything. 141 // request is made. So wait for analysis to finish before testing anything.
142 return analysisFinished.then((_) { 142 return analysisFinished.then((_) {
143 List<Future> tests = []; 143 List<Future> tests = [];
144 tests.add(checkHover('topLevelVar;', 11, 144 tests.add(checkHover('topLevelVar;', 11, [
145 ['List', 'topLevelVar'], 'top level variable', ['List'])); 145 'List',
146 tests.add(checkHover('func(', 4, [ 146 'topLevelVar'
147 'func', 147 ], 'top level variable', ['List']));
148 'int', 148 tests.add(checkHover(
149 'param' 149 'func(', 4, ['func', 'int', 'param'], 'function', ['int', 'void'],
150 ], 'function', ['int', 'void'], docRegexp: 'Documentation for func')); 150 docRegexp: 'Documentation for func'));
151 tests.add(checkHover('int param', 3, ['int'], 'class', ['int'], 151 tests.add(checkHover('int param', 3, ['int'], 'class', ['int'],
152 isCore: true, docRegexp: '.*')); 152 isCore: true, docRegexp: '.*'));
153 tests.add(checkHover('param)', 5, ['int', 'param'], 'parameter', ['int'], 153 tests.add(checkHover('param)', 5, ['int', 'param'], 'parameter', ['int'],
154 docRegexp: 'Documentation for func')); 154 isLocal: true, docRegexp: 'Documentation for func'));
155 tests.add(checkHover('num localVar', 3, ['num'], 'class', ['num'], 155 tests.add(checkHover('num localVar', 3, ['num'], 'class', ['num'],
156 isCore: true, docRegexp: '.*')); 156 isCore: true, docRegexp: '.*'));
157 tests.add(checkHover('localVar =', 8, [ 157 tests.add(checkHover(
158 'num', 158 'localVar =', 8, ['num', 'localVar'], 'local variable', ['num'],
159 'localVar' 159 isLocal: true, propagatedType: 'int'));
160 ], 'local variable', ['num'], propagatedType: 'int'));
161 tests.add(checkHover('topLevelVar.length;', 11, [ 160 tests.add(checkHover('topLevelVar.length;', 11, [
162 'List', 161 'List',
163 'topLevelVar' 162 'topLevelVar'
164 ], 'top level variable', ['List'])); 163 ], 'top level variable', ['List']));
165 tests.add(checkHover('length;', 6, [ 164 tests.add(checkHover(
166 'get', 165 'length;', 6, ['get', 'length', 'int'], 'getter', ['int'],
167 'length', 166 isCore: true, docRegexp: '.*'));
168 'int' 167 tests.add(checkHover(
169 ], 'getter', ['int'], isCore: true, docRegexp: '.*')); 168 'length =', 6, ['set', 'length', 'int'], 'setter', ['int'],
170 tests.add(checkHover('length =', 6, [ 169 isCore: true, docRegexp: '.*'));
171 'set',
172 'length',
173 'int'
174 ], 'setter', ['int'], isCore: true, docRegexp: '.*'));
175 tests.add(checkHover('param;', 5, ['int', 'param'], 'parameter', ['int'], 170 tests.add(checkHover('param;', 5, ['int', 'param'], 'parameter', ['int'],
176 docRegexp: 'Documentation for func', parameterRegexps: ['.*'])); 171 isLocal: true,
172 docRegexp: 'Documentation for func',
173 parameterRegexps: ['.*']));
177 tests.add(checkHover('add(', 3, ['List', 'add'], 'method', null, 174 tests.add(checkHover('add(', 3, ['List', 'add'], 'method', null,
178 isCore: true, docRegexp: '.*')); 175 isCore: true, docRegexp: '.*'));
179 tests.add(checkHover('localVar)', 8, [ 176 tests.add(checkHover(
180 'num', 177 'localVar)', 8, ['num', 'localVar'], 'local variable', ['num'],
181 'localVar' 178 isLocal: true, parameterRegexps: ['.*'], propagatedType: 'int'));
182 ], 'local variable', [ 179 tests.add(checkHover(
183 'num' 180 'func(35', 4, ['func', 'int', 'param'], 'function', null,
184 ], parameterRegexps: ['.*'], propagatedType: 'int')); 181 docRegexp: 'Documentation for func'));
185 tests.add(checkHover('func(35', 4, [
186 'func',
187 'int',
188 'param'
189 ], 'function', null, docRegexp: 'Documentation for func'));
190 tests.add(checkHover('35', 2, null, null, ['int'], 182 tests.add(checkHover('35', 2, null, null, ['int'],
191 isLiteral: true, parameterRegexps: ['int', 'param'])); 183 isLiteral: true, parameterRegexps: ['int', 'param']));
192 tests.add(checkNoHover('comment')); 184 tests.add(checkNoHover('comment'));
193 return Future.wait(tests); 185 return Future.wait(tests);
194 }); 186 });
195 } 187 }
196 } 188 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698