Index: pkg/analysis_server/test/analysis/notification_navigation_test.dart |
diff --git a/pkg/analysis_server/test/analysis/notification_navigation_test.dart b/pkg/analysis_server/test/analysis/notification_navigation_test.dart |
index fc40264b539413ef4949bfa04e3f2bd423668dc3..84b73529749ec1c5e88d239b900268ddd0bfb53a 100644 |
--- a/pkg/analysis_server/test/analysis/notification_navigation_test.dart |
+++ b/pkg/analysis_server/test/analysis/notification_navigation_test.dart |
@@ -69,9 +69,11 @@ class AnalysisNotificationNavigationTest extends AbstractAnalysisTest { |
* Validates that there is a region at the offset of [search] in [testFile] |
* with the length of [search]. |
Brian Wilkerson
2014/11/10 21:04:23
The comment needs to be updated.
scheglov
2014/11/11 03:01:06
Done.
|
*/ |
- void assertHasRegionString(String search) { |
+ void assertHasRegionString(String search, [int length = -1]) { |
int offset = findOffset(search); |
- int length = search.length; |
+ if (length == -1) { |
+ length = search.length; |
+ } |
findRegion(offset, length, true); |
} |
@@ -144,7 +146,7 @@ class AnalysisNotificationNavigationTest extends AbstractAnalysisTest { |
* |
* If [exists] is `false`, then fails if such region exists. |
*/ |
- void findRegion(int offset, int length, [bool exists]) { |
+ void findRegion(int offset, int length, bool exists) { |
for (NavigationRegion region in regions) { |
if (region.offset == offset && |
(length == -1 || region.length == length)) { |
@@ -318,33 +320,26 @@ main() { |
} |
'''); |
return prepareNavigation().then((_) { |
- { |
- findRegion(findOffset('new A'), 'new'.length, true); |
- assertHasTarget('A {'); |
- } |
- { |
- findRegion(findOffset('A()'), 'A'.length, true); |
- assertHasTarget('A {'); |
- } |
+ assertHasRegionString('new A'); |
+ assertHasTarget('A {'); |
}); |
} |
test_instanceCreation_implicit_withTypeArgument() { |
addTestFile(''' |
class A {} |
-class B<T> { |
-} |
+class B<T> {} |
main() { |
new B<A>(); |
} |
'''); |
return prepareNavigation().then((_) { |
{ |
- findRegion(findOffset('new B'), 'new'.length, true); |
+ assertHasRegion('new B<A>', 'new B'.length); |
assertHasTarget('B<T> {'); |
} |
{ |
- findRegion(findOffset('A>();'), 'A'.length, true); |
+ assertHasRegion('A>();', 'A'.length); |
assertHasTarget('A {'); |
} |
}); |
@@ -360,18 +355,8 @@ main() { |
} |
'''); |
return prepareNavigation().then((_) { |
- { |
- findRegion(findOffset('new '), 'new'.length, true); |
- assertHasTarget('named() {}'); |
- } |
- { |
- findRegion(findOffset('A.named();'), 'A'.length, true); |
- assertHasTarget('A {'); |
- } |
- { |
- findRegion(findOffset('.named();'), '.named'.length, true); |
- assertHasTarget('named() {}'); |
- } |
+ assertHasRegionString('new A.named'); |
+ assertHasTarget('named() {}'); |
}); |
} |
@@ -387,21 +372,17 @@ main() { |
'''); |
return prepareNavigation().then((_) { |
{ |
- findRegion(findOffset('new '), 'new'.length, true); |
+ assertHasRegionString('new B'); |
assertHasTarget('named() {}'); |
} |
{ |
- findRegion(findOffset('B<A>.named();'), 'B'.length, true); |
- assertHasTarget('B<T> {'); |
+ assertHasRegion('A>.named'); |
+ assertHasTarget('A {'); |
} |
{ |
- findRegion(findOffset('.named();'), '.named'.length, true); |
+ assertHasRegion('.named();', '.named'.length); |
assertHasTarget('named() {}'); |
} |
- { |
- findRegion(findOffset('A>.named();'), 'A'.length, true); |
- assertHasTarget('A {'); |
- } |
}); |
} |
@@ -415,14 +396,8 @@ main() { |
} |
'''); |
return prepareNavigation().then((_) { |
- { |
- findRegion(findOffset('new '), 'new'.length, true); |
- assertHasTarget('A() {}', 0); |
- } |
- { |
- findRegion(findOffset('A();'), 'A'.length, true); |
- assertHasTarget('A {'); |
- } |
+ assertHasRegionString('new A'); |
+ assertHasTarget('A() {}', 0); |
}); |
} |
@@ -438,15 +413,11 @@ main() { |
'''); |
return prepareNavigation().then((_) { |
{ |
- findRegion(findOffset('new '), 'new'.length, true); |
+ assertHasRegionString('new B'); |
assertHasTarget('B() {}', 0); |
} |
{ |
- findRegion(findOffset('B<A>();'), 'B'.length, true); |
- assertHasTarget('B<T> {'); |
- } |
- { |
- findRegion(findOffset('A>();'), 'A'.length, true); |
+ assertHasRegion('A>();'); |
assertHasTarget('A {'); |
} |
}); |