| 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.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 '../../reflective_tests.dart'; | 9 import 'package:analysis_server/src/protocol.dart'; |
| 10 import 'package:path/path.dart'; | 10 import 'package:path/path.dart'; |
| 11 import 'package:unittest/unittest.dart'; | 11 import 'package:unittest/unittest.dart'; |
| 12 | 12 |
| 13 import '../../reflective_tests.dart'; |
| 13 import '../integration_tests.dart'; | 14 import '../integration_tests.dart'; |
| 14 | 15 |
| 15 @ReflectiveTestCase() | 16 @ReflectiveTestCase() |
| 16 class AnalysisGetHoverIntegrationTest extends | 17 class AnalysisGetHoverIntegrationTest extends |
| 17 AbstractAnalysisServerIntegrationTest { | 18 AbstractAnalysisServerIntegrationTest { |
| 18 /** | 19 /** |
| 19 * Pathname of the file containing Dart code. | 20 * Pathname of the file containing Dart code. |
| 20 */ | 21 */ |
| 21 String pathname; | 22 String pathname; |
| 22 | 23 |
| (...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 104 * literal value. [parameterRegexps] means is a set of regexps which should | 105 * literal value. [parameterRegexps] means is a set of regexps which should |
| 105 * match the hover parameters. [propagatedType], if specified, is the | 106 * match the hover parameters. [propagatedType], if specified, is the |
| 106 * expected propagated type of the element. | 107 * expected propagated type of the element. |
| 107 */ | 108 */ |
| 108 checkHover(String target, int length, List<String> descriptionRegexps, String | 109 checkHover(String target, int length, List<String> descriptionRegexps, String |
| 109 kind, List<String> staticTypeRegexps, {bool isCore: false, String docRegex
p: | 110 kind, List<String> staticTypeRegexps, {bool isCore: false, String docRegex
p: |
| 110 null, bool isLiteral: false, List<String> parameterRegexps: | 111 null, bool isLiteral: false, List<String> parameterRegexps: |
| 111 null, propagatedType: null}) { | 112 null, propagatedType: null}) { |
| 112 int offset = text.indexOf(target); | 113 int offset = text.indexOf(target); |
| 113 return sendAnalysisGetHover(pathname, offset).then((result) { | 114 return sendAnalysisGetHover(pathname, offset).then((result) { |
| 114 expect(result['hovers'], hasLength(1)); | 115 expect(result.hovers, hasLength(1)); |
| 115 var info = result['hovers'][0]; | 116 HoverInformation info = result.hovers[0]; |
| 116 expect(info['offset'], equals(offset)); | 117 expect(info.offset, equals(offset)); |
| 117 expect(info['length'], equals(length)); | 118 expect(info.length, equals(length)); |
| 118 if (isCore) { | 119 if (isCore) { |
| 119 expect(basename(info['containingLibraryPath']), equals('core.dart')); | 120 expect(basename(info.containingLibraryPath), equals('core.dart')); |
| 120 expect(info['containingLibraryName'], equals('dart.core')); | 121 expect(info.containingLibraryName, equals('dart.core')); |
| 121 } else if (isLiteral) { | 122 } else if (isLiteral) { |
| 122 expect(info['containingLibraryPath'], isNull); | 123 expect(info.containingLibraryPath, isNull); |
| 123 expect(info['containingLibraryName'], isNull); | 124 expect(info.containingLibraryName, isNull); |
| 124 } else { | 125 } else { |
| 125 expect(info['containingLibraryPath'], equals(pathname)); | 126 expect(info.containingLibraryPath, equals(pathname)); |
| 126 expect(info['containingLibraryName'], equals('lib.test')); | 127 expect(info.containingLibraryName, equals('lib.test')); |
| 127 } | 128 } |
| 128 if (docRegexp == null) { | 129 if (docRegexp == null) { |
| 129 expect(info['dartdoc'], isNull); | 130 expect(info.dartdoc, isNull); |
| 130 } else { | 131 } else { |
| 131 expect(info['dartdoc'], matches(docRegexp)); | 132 expect(info.dartdoc, matches(docRegexp)); |
| 132 } | 133 } |
| 133 if (descriptionRegexps == null) { | 134 if (descriptionRegexps == null) { |
| 134 expect(info['elementDescription'], isNull); | 135 expect(info.elementDescription, isNull); |
| 135 } else { | 136 } else { |
| 136 expect(info['elementDescription'], isString); | 137 expect(info.elementDescription, isString); |
| 137 for (String descriptionRegexp in descriptionRegexps) { | 138 for (String descriptionRegexp in descriptionRegexps) { |
| 138 expect(info['elementDescription'], matches(descriptionRegexp)); | 139 expect(info.elementDescription, matches(descriptionRegexp)); |
| 139 } | 140 } |
| 140 } | 141 } |
| 141 expect(info['elementKind'], equals(kind)); | 142 expect(info.elementKind, equals(kind)); |
| 142 if (parameterRegexps == null) { | 143 if (parameterRegexps == null) { |
| 143 expect(info['parameter'], isNull); | 144 expect(info.parameter, isNull); |
| 144 } else { | 145 } else { |
| 145 expect(info['parameter'], isString); | 146 expect(info.parameter, isString); |
| 146 for (String parameterRegexp in parameterRegexps) { | 147 for (String parameterRegexp in parameterRegexps) { |
| 147 expect(info['parameter'], matches(parameterRegexp)); | 148 expect(info.parameter, matches(parameterRegexp)); |
| 148 } | 149 } |
| 149 } | 150 } |
| 150 expect(info['propagatedType'], equals(propagatedType)); | 151 expect(info.propagatedType, equals(propagatedType)); |
| 151 if (staticTypeRegexps == null) { | 152 if (staticTypeRegexps == null) { |
| 152 expect(info['staticType'], isNull); | 153 expect(info.staticType, isNull); |
| 153 } else { | 154 } else { |
| 154 expect(info['staticType'], isString); | 155 expect(info.staticType, isString); |
| 155 for (String staticTypeRegexp in staticTypeRegexps) { | 156 for (String staticTypeRegexp in staticTypeRegexps) { |
| 156 expect(info['staticType'], matches(staticTypeRegexp)); | 157 expect(info.staticType, matches(staticTypeRegexp)); |
| 157 } | 158 } |
| 158 } | 159 } |
| 159 }); | 160 }); |
| 160 } | 161 } |
| 161 | 162 |
| 162 /** | 163 /** |
| 163 * Check that a getHover request on the substring [target] produces no | 164 * Check that a getHover request on the substring [target] produces no |
| 164 * results. | 165 * results. |
| 165 */ | 166 */ |
| 166 Future checkNoHover(String target) { | 167 Future checkNoHover(String target) { |
| 167 int offset = text.indexOf(target); | 168 int offset = text.indexOf(target); |
| 168 return sendAnalysisGetHover(pathname, offset).then((result) { | 169 return sendAnalysisGetHover(pathname, offset).then((result) { |
| 169 expect(result['hovers'], hasLength(0)); | 170 expect(result.hovers, hasLength(0)); |
| 170 }); | 171 }); |
| 171 } | 172 } |
| 172 } | 173 } |
| 173 | 174 |
| 174 main() { | 175 main() { |
| 175 runReflectiveTests(AnalysisGetHoverIntegrationTest); | 176 runReflectiveTests(AnalysisGetHoverIntegrationTest); |
| 176 } | 177 } |
| OLD | NEW |