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.analysis.notification.navigation; | 5 library test.analysis.notification.navigation; |
6 | 6 |
7 import 'dart:async'; | 7 import 'dart:async'; |
8 | 8 |
9 import 'package:analysis_server/src/constants.dart'; | 9 import 'package:analysis_server/src/constants.dart'; |
10 import 'package:analysis_server/src/protocol.dart'; | 10 import 'package:analysis_server/src/protocol.dart'; |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
96 */ | 96 */ |
97 void assertHasTarget(String search, [int length = -1]) { | 97 void assertHasTarget(String search, [int length = -1]) { |
98 int offset = findOffset(search); | 98 int offset = findOffset(search); |
99 if (length == -1) { | 99 if (length == -1) { |
100 length = findIdentifierLength(search); | 100 length = findIdentifierLength(search); |
101 } | 101 } |
102 assertHasFileTarget(testFile, offset, length); | 102 assertHasFileTarget(testFile, offset, length); |
103 } | 103 } |
104 | 104 |
105 /** | 105 /** |
| 106 * Validates that there is a target in [testTargets] with [testFile], at the |
| 107 * offset of [str] in [testFile], and with the length of [str]. |
| 108 */ |
| 109 void assertHasTargetString(String str) { |
| 110 assertHasTarget(str, str.length); |
| 111 } |
| 112 |
| 113 /** |
106 * Validates that there is no a region at [search] and with the given | 114 * Validates that there is no a region at [search] and with the given |
107 * [length]. | 115 * [length]. |
108 */ | 116 */ |
109 void assertNoRegion(String search, int length) { | 117 void assertNoRegion(String search, int length) { |
110 int offset = findOffset(search); | 118 int offset = findOffset(search); |
111 findRegion(offset, length, false); | 119 findRegion(offset, length, false); |
112 } | 120 } |
113 | 121 |
114 /** | 122 /** |
115 * Validates that there is no a region at [search] with any length. | 123 * Validates that there is no a region at [search] with any length. |
(...skipping 458 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
574 assertHasRegionString('B<A>();', 'B'.length); | 582 assertHasRegionString('B<A>();', 'B'.length); |
575 assertHasTarget('B() {}', 0); | 583 assertHasTarget('B() {}', 0); |
576 } | 584 } |
577 { | 585 { |
578 assertHasRegion('A>();'); | 586 assertHasRegion('A>();'); |
579 assertHasTarget('A {'); | 587 assertHasTarget('A {'); |
580 } | 588 } |
581 }); | 589 }); |
582 } | 590 } |
583 | 591 |
| 592 test_library() { |
| 593 addTestFile(''' |
| 594 library my.lib; |
| 595 '''); |
| 596 return prepareNavigation().then((_) { |
| 597 assertHasRegionString('my.lib'); |
| 598 assertHasTargetString('my.lib'); |
| 599 }); |
| 600 } |
| 601 |
584 test_multiplyDefinedElement() { | 602 test_multiplyDefinedElement() { |
585 addFile('$projectPath/bin/libA.dart', 'library A; int TEST = 1;'); | 603 addFile('$projectPath/bin/libA.dart', 'library A; int TEST = 1;'); |
586 addFile('$projectPath/bin/libB.dart', 'library B; int TEST = 2;'); | 604 addFile('$projectPath/bin/libB.dart', 'library B; int TEST = 2;'); |
587 addTestFile(''' | 605 addTestFile(''' |
588 import 'libA.dart'; | 606 import 'libA.dart'; |
589 import 'libB.dart'; | 607 import 'libB.dart'; |
590 main() { | 608 main() { |
591 TEST; | 609 TEST; |
592 } | 610 } |
593 '''); | 611 '''); |
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
799 test_type_void() { | 817 test_type_void() { |
800 addTestFile(''' | 818 addTestFile(''' |
801 void main() { | 819 void main() { |
802 } | 820 } |
803 '''); | 821 '''); |
804 return prepareNavigation().then((_) { | 822 return prepareNavigation().then((_) { |
805 assertNoRegionAt('void'); | 823 assertNoRegionAt('void'); |
806 }); | 824 }); |
807 } | 825 } |
808 } | 826 } |
OLD | NEW |