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

Unified Diff: pkg/analysis_server/test/analysis/notification_navigation_test.dart

Issue 717513003: Issue 21552. Fixes for navigation, hover and rename in instance creation expressions. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 1 month 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/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 {');
}
});
« no previous file with comments | « pkg/analysis_server/test/analysis/get_hover_test.dart ('k') | pkg/analysis_server/test/edit/refactoring_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698