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

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

Issue 1266923004: More fixes for failures on the Windows bot (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Created 5 years, 4 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
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';
11 import 'package:test_reflective_loader/test_reflective_loader.dart'; 11 import 'package:test_reflective_loader/test_reflective_loader.dart';
12 import 'package:unittest/unittest.dart'; 12 import 'package:unittest/unittest.dart';
13 13
14 import '../../utils.dart';
14 import '../integration_tests.dart'; 15 import '../integration_tests.dart';
15 16
16 main() { 17 main() {
18 initializeTestEnvironment();
17 defineReflectiveTests(AnalysisGetHoverIntegrationTest); 19 defineReflectiveTests(AnalysisGetHoverIntegrationTest);
18 } 20 }
19 21
20 @reflectiveTest 22 @reflectiveTest
21 class AnalysisGetHoverIntegrationTest 23 class AnalysisGetHoverIntegrationTest
22 extends AbstractAnalysisServerIntegrationTest { 24 extends AbstractAnalysisServerIntegrationTest {
23 /** 25 /**
24 * Pathname of the file containing Dart code. 26 * Pathname of the file containing Dart code.
25 */ 27 */
26 String pathname; 28 String pathname;
(...skipping 28 matching lines...) Expand all
55 * matching [staticTypeRegexps]. 57 * matching [staticTypeRegexps].
56 * 58 *
57 * [isCore] means the hover info should indicate that the element is defined 59 * [isCore] means the hover info should indicate that the element is defined
58 * in dart.core. [docRegexp], if specified, should match the documentation 60 * in dart.core. [docRegexp], if specified, should match the documentation
59 * string of the element. [isLiteral] means the hover should indicate a 61 * string of the element. [isLiteral] means the hover should indicate a
60 * literal value. [parameterRegexps] means is a set of regexps which should 62 * literal value. [parameterRegexps] means is a set of regexps which should
61 * match the hover parameters. [propagatedType], if specified, is the 63 * match the hover parameters. [propagatedType], if specified, is the
62 * expected propagated type of the element. 64 * expected propagated type of the element.
63 */ 65 */
64 checkHover(String target, int length, List<String> descriptionRegexps, 66 checkHover(String target, int length, List<String> descriptionRegexps,
65 String kind, List<String> staticTypeRegexps, {bool isLocal: false, 67 String kind, List<String> staticTypeRegexps,
66 bool isCore: false, String docRegexp: null, bool isLiteral: false, 68 {bool isLocal: false,
67 List<String> parameterRegexps: null, propagatedType: null}) { 69 bool isCore: false,
70 String docRegexp: null,
71 bool isLiteral: false,
72 List<String> parameterRegexps: null,
73 propagatedType: null}) {
68 int offset = text.indexOf(target); 74 int offset = text.indexOf(target);
69 return sendAnalysisGetHover(pathname, offset).then((result) { 75 return sendAnalysisGetHover(pathname, offset).then((result) {
70 expect(result.hovers, hasLength(1)); 76 expect(result.hovers, hasLength(1));
71 HoverInformation info = result.hovers[0]; 77 HoverInformation info = result.hovers[0];
72 expect(info.offset, equals(offset)); 78 expect(info.offset, equals(offset));
73 expect(info.length, equals(length)); 79 expect(info.length, equals(length));
74 if (isCore) { 80 if (isCore) {
75 expect(basename(info.containingLibraryPath), equals('core.dart')); 81 expect(basename(info.containingLibraryPath), equals('core.dart'));
76 expect(info.containingLibraryName, equals('dart.core')); 82 expect(info.containingLibraryName, equals('dart.core'));
77 } else if (isLocal || isLiteral) { 83 } else if (isLocal || isLiteral) {
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
134 140
135 test_getHover() { 141 test_getHover() {
136 writeFile(pathname, text); 142 writeFile(pathname, text);
137 standardAnalysisSetup(); 143 standardAnalysisSetup();
138 144
139 // Note: analysis.getHover doesn't wait for analysis to complete--it simply 145 // 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 146 // 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. 147 // request is made. So wait for analysis to finish before testing anything.
142 return analysisFinished.then((_) { 148 return analysisFinished.then((_) {
143 List<Future> tests = []; 149 List<Future> tests = [];
144 tests.add(checkHover('topLevelVar;', 11, [ 150 tests.add(checkHover('topLevelVar;', 11, ['List', 'topLevelVar'],
145 'List', 151 'top level variable', ['List']));
146 'topLevelVar'
147 ], 'top level variable', ['List']));
148 tests.add(checkHover( 152 tests.add(checkHover(
149 'func(', 4, ['func', 'int', 'param'], 'function', ['int', 'void'], 153 'func(', 4, ['func', 'int', 'param'], 'function', ['int', 'void'],
150 docRegexp: 'Documentation for func')); 154 docRegexp: 'Documentation for func'));
151 tests.add(checkHover('int param', 3, ['int'], 'class', ['int'], 155 tests.add(checkHover('int param', 3, ['int'], 'class', ['int'],
152 isCore: true, docRegexp: '.*')); 156 isCore: true, docRegexp: '.*'));
153 tests.add(checkHover('param)', 5, ['int', 'param'], 'parameter', ['int'], 157 tests.add(checkHover('param)', 5, ['int', 'param'], 'parameter', ['int'],
154 isLocal: true, docRegexp: 'Documentation for func')); 158 isLocal: true, docRegexp: 'Documentation for func'));
155 tests.add(checkHover('num localVar', 3, ['num'], 'class', ['num'], 159 tests.add(checkHover('num localVar', 3, ['num'], 'class', ['num'],
156 isCore: true, docRegexp: '.*')); 160 isCore: true, docRegexp: '.*'));
157 tests.add(checkHover( 161 tests.add(checkHover(
158 'localVar =', 8, ['num', 'localVar'], 'local variable', ['num'], 162 'localVar =', 8, ['num', 'localVar'], 'local variable', ['num'],
159 isLocal: true, propagatedType: 'int')); 163 isLocal: true, propagatedType: 'int'));
160 tests.add(checkHover('topLevelVar.length;', 11, [ 164 tests.add(checkHover('topLevelVar.length;', 11, ['List', 'topLevelVar'],
161 'List', 165 'top level variable', ['List']));
162 'topLevelVar'
163 ], 'top level variable', ['List']));
164 tests.add(checkHover( 166 tests.add(checkHover(
165 'length;', 6, ['get', 'length', 'int'], 'getter', ['int'], 167 'length;', 6, ['get', 'length', 'int'], 'getter', ['int'],
166 isCore: true, docRegexp: '.*')); 168 isCore: true, docRegexp: '.*'));
167 tests.add(checkHover( 169 tests.add(checkHover(
168 'length =', 6, ['set', 'length', 'int'], 'setter', ['int'], 170 'length =', 6, ['set', 'length', 'int'], 'setter', ['int'],
169 isCore: true, docRegexp: '.*')); 171 isCore: true, docRegexp: '.*'));
170 tests.add(checkHover('param;', 5, ['int', 'param'], 'parameter', ['int'], 172 tests.add(checkHover('param;', 5, ['int', 'param'], 'parameter', ['int'],
171 isLocal: true, 173 isLocal: true,
172 docRegexp: 'Documentation for func', 174 docRegexp: 'Documentation for func',
173 parameterRegexps: ['.*'])); 175 parameterRegexps: ['.*']));
174 tests.add(checkHover('add(', 3, ['List', 'add'], 'method', null, 176 tests.add(checkHover('add(', 3, ['List', 'add'], 'method', null,
175 isCore: true, docRegexp: '.*')); 177 isCore: true, docRegexp: '.*'));
176 tests.add(checkHover( 178 tests.add(checkHover(
177 'localVar)', 8, ['num', 'localVar'], 'local variable', ['num'], 179 'localVar)', 8, ['num', 'localVar'], 'local variable', ['num'],
178 isLocal: true, parameterRegexps: ['.*'], propagatedType: 'int')); 180 isLocal: true, parameterRegexps: ['.*'], propagatedType: 'int'));
179 tests.add(checkHover( 181 tests.add(checkHover(
180 'func(35', 4, ['func', 'int', 'param'], 'function', null, 182 'func(35', 4, ['func', 'int', 'param'], 'function', null,
181 docRegexp: 'Documentation for func')); 183 docRegexp: 'Documentation for func'));
182 tests.add(checkHover('35', 2, null, null, ['int'], 184 tests.add(checkHover('35', 2, null, null, ['int'],
183 isLiteral: true, parameterRegexps: ['int', 'param'])); 185 isLiteral: true, parameterRegexps: ['int', 'param']));
184 tests.add(checkNoHover('comment')); 186 tests.add(checkNoHover('comment'));
185 return Future.wait(tests); 187 return Future.wait(tests);
186 }); 188 });
187 } 189 }
188 } 190 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698