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

Unified Diff: pkg/analysis_server/test/integration/analysis/navigation_test.dart

Issue 631553002: Change integration test notifications to use structured objects. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 2 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 side-by-side diff with in-line comments
Download patch
Index: pkg/analysis_server/test/integration/analysis/navigation_test.dart
diff --git a/pkg/analysis_server/test/integration/analysis/navigation_test.dart b/pkg/analysis_server/test/integration/analysis/navigation_test.dart
index caab4cc84c624da9618aeebb0d7c6907531ca012..f1873fe0c88176d45243bc2abc6f806b1600f4ab 100644
--- a/pkg/analysis_server/test/integration/analysis/navigation_test.dart
+++ b/pkg/analysis_server/test/integration/analysis/navigation_test.dart
@@ -14,8 +14,7 @@ import '../integration_tests.dart';
class AnalysisNavigationTest extends AbstractAnalysisServerIntegrationTest {
test_navigation() {
String pathname1 = sourcePath('test1.dart');
- String text1 =
- r'''
+ String text1 = r'''
library foo;
import 'dart:async';
@@ -46,63 +45,87 @@ main() {
''';
writeFile(pathname1, text1);
String pathname2 = sourcePath('test2.dart');
- String text2 =
- r'''
+ String text2 = r'''
part of foo;
''';
writeFile(pathname2, text2);
standardAnalysisSetup();
- sendAnalysisSetSubscriptions({AnalysisService.NAVIGATION: [pathname1]});
- List regions;
- onAnalysisNavigation.listen((params) {
- expect(params['file'], equals(pathname1));
- regions = params['regions'];
+ sendAnalysisSetSubscriptions({
+ AnalysisService.NAVIGATION: [pathname1]
+ });
+ List<NavigationRegion> regions;
+ onAnalysisNavigation.listen((AnalysisNavigationParams params) {
+ expect(params.file, equals(pathname1));
+ regions = params.regions;
});
return analysisFinished.then((_) {
// There should be a single error, due to the fact that 'dart:async' is
// not used.
expect(currentAnalysisErrors[pathname1], hasLength(1));
expect(currentAnalysisErrors[pathname2], isEmpty);
- Map findTargetElement(int index) {
- for (Map region in regions) {
- if (region['offset'] <= index && index < region['offset'] + region['length']) {
- expect(region['targets'], hasLength(1));
- return region['targets'][0];
+ Element findTargetElement(int index) {
+ for (NavigationRegion region in regions) {
+ if (region.offset <= index && index < region.offset + region.length) {
+ expect(region.targets, hasLength(1));
+ return region.targets[0];
}
}
fail('No element found for index $index');
return null;
}
- void checkLocal(String source, String expectedTarget, String expectedKind) {
+ void checkLocal(String source, String expectedTarget,
+ ElementKind expectedKind) {
int sourceIndex = text1.indexOf(source);
int targetIndex = text1.indexOf(expectedTarget);
- Map element = findTargetElement(sourceIndex);
- expect(element['location']['file'], equals(pathname1));
- expect(element['location']['offset'], equals(targetIndex));
- expect(element['kind'], equals(expectedKind));
+ Element element = findTargetElement(sourceIndex);
+ expect(element.location.file, equals(pathname1));
+ expect(element.location.offset, equals(targetIndex));
+ expect(element.kind, equals(expectedKind));
}
- void checkRemote(String source, String expectedTargetRegexp, String expectedKind) {
+ void checkRemote(String source, String expectedTargetRegexp,
+ ElementKind expectedKind) {
int sourceIndex = text1.indexOf(source);
- Map element = findTargetElement(sourceIndex);
- expect(element['location']['file'], matches(expectedTargetRegexp));
- expect(element['kind'], equals(expectedKind));
+ Element element = findTargetElement(sourceIndex);
+ expect(element.location.file, matches(expectedTargetRegexp));
+ expect(element.kind, equals(expectedKind));
}
// TODO(paulberry): will the element type 'CLASS_TYPE_ALIAS' ever appear
// as a navigation target?
- checkLocal('Class<int>', 'Class<TypeParameter>', 'CLASS');
- checkRemote("part 'test2.dart';", r'test2.dart$', 'COMPILATION_UNIT');
- checkLocal('new Class<int>.constructor', 'constructor(); /* constructor declaration */', 'CONSTRUCTOR');
- checkLocal('field;', 'field;', 'FIELD');
- checkLocal('function(() => localVariable.field)', 'function(FunctionTypeAlias parameter)', 'FUNCTION');
- checkLocal('FunctionTypeAlias parameter', 'FunctionTypeAlias();', 'FUNCTION_TYPE_ALIAS');
- checkLocal('field)', 'field;', 'GETTER');
- checkRemote("import 'dart:async'", r'async\.dart$', 'LIBRARY');
- checkLocal('localVariable.field', 'localVariable =', 'LOCAL_VARIABLE');
- checkLocal('method();', 'method() {', 'METHOD');
- checkLocal('parameter());', 'parameter) {', 'PARAMETER');
- checkLocal('field = 1', 'field;', 'SETTER');
- checkLocal('topLevelVariable;', 'topLevelVariable;', 'TOP_LEVEL_VARIABLE');
- checkLocal('TypeParameter field;', 'TypeParameter>', 'TYPE_PARAMETER');
+ checkLocal('Class<int>', 'Class<TypeParameter>', ElementKind.CLASS);
+ checkRemote(
+ "part 'test2.dart';",
+ r'test2.dart$',
+ ElementKind.COMPILATION_UNIT);
+ checkLocal(
+ 'new Class<int>.constructor',
+ 'constructor(); /* constructor declaration */',
+ ElementKind.CONSTRUCTOR);
+ checkLocal('field;', 'field;', ElementKind.FIELD);
+ checkLocal(
+ 'function(() => localVariable.field)',
+ 'function(FunctionTypeAlias parameter)',
+ ElementKind.FUNCTION);
+ checkLocal(
+ 'FunctionTypeAlias parameter',
+ 'FunctionTypeAlias();',
+ ElementKind.FUNCTION_TYPE_ALIAS);
+ checkLocal('field)', 'field;', ElementKind.GETTER);
+ checkRemote("import 'dart:async'", r'async\.dart$', ElementKind.LIBRARY);
+ checkLocal(
+ 'localVariable.field',
+ 'localVariable =',
+ ElementKind.LOCAL_VARIABLE);
+ checkLocal('method();', 'method() {', ElementKind.METHOD);
+ checkLocal('parameter());', 'parameter) {', ElementKind.PARAMETER);
+ checkLocal('field = 1', 'field;', ElementKind.SETTER);
+ checkLocal(
+ 'topLevelVariable;',
+ 'topLevelVariable;',
+ ElementKind.TOP_LEVEL_VARIABLE);
+ checkLocal(
+ 'TypeParameter field;',
+ 'TypeParameter>',
+ ElementKind.TYPE_PARAMETER);
});
}
}

Powered by Google App Engine
This is Rietveld 408576698