OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file |
| 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. |
| 4 |
| 5 library test.analysis.navigation_collector; |
| 6 |
| 7 import 'package:analysis_server/plugin/protocol/protocol.dart'; |
| 8 import 'package:analysis_server/src/domains/analysis/navigation.dart'; |
| 9 import 'package:test_reflective_loader/test_reflective_loader.dart'; |
| 10 import 'package:unittest/unittest.dart'; |
| 11 |
| 12 import '../utils.dart'; |
| 13 |
| 14 main() { |
| 15 initializeTestEnvironment(); |
| 16 defineReflectiveTests(NavigationCollectorImplTest); |
| 17 } |
| 18 |
| 19 @reflectiveTest |
| 20 class NavigationCollectorImplTest { |
| 21 NavigationCollectorImpl collector = new NavigationCollectorImpl(); |
| 22 |
| 23 void test_multipleTargets() { |
| 24 collector.addRegion( |
| 25 10, 5, ElementKind.CLASS, new Location('file', 11, 12, 13, 14)); |
| 26 collector.addRegion( |
| 27 10, 5, ElementKind.CLASS, new Location('file', 21, 22, 23, 24)); |
| 28 collector.createRegions(); |
| 29 List<NavigationRegion> regions = collector.regions; |
| 30 expect(regions, hasLength(1)); |
| 31 { |
| 32 NavigationRegion region = regions[0]; |
| 33 expect(region.offset, 10); |
| 34 expect(region.length, 5); |
| 35 expect(region.targets, hasLength(2)); |
| 36 { |
| 37 NavigationTarget target = collector.targets[region.targets[0]]; |
| 38 expect(target.offset, 11); |
| 39 expect(target.length, 12); |
| 40 } |
| 41 { |
| 42 NavigationTarget target = collector.targets[region.targets[1]]; |
| 43 expect(target.offset, 21); |
| 44 expect(target.length, 22); |
| 45 } |
| 46 } |
| 47 } |
| 48 |
| 49 void test_unique() { |
| 50 collector.addRegion( |
| 51 100, 10, ElementKind.CLASS, new Location('file', 11, 12, 13, 14)); |
| 52 collector.addRegion( |
| 53 200, 20, ElementKind.CLASS, new Location('file', 21, 22, 23, 24)); |
| 54 collector.createRegions(); |
| 55 List<NavigationRegion> regions = collector.regions; |
| 56 expect(regions, hasLength(2)); |
| 57 { |
| 58 NavigationRegion region = regions[0]; |
| 59 expect(region.offset, 100); |
| 60 expect(region.length, 10); |
| 61 expect(region.targets, hasLength(1)); |
| 62 { |
| 63 NavigationTarget target = collector.targets[region.targets[0]]; |
| 64 expect(target.offset, 11); |
| 65 expect(target.length, 12); |
| 66 } |
| 67 } |
| 68 { |
| 69 NavigationRegion region = regions[1]; |
| 70 expect(region.offset, 200); |
| 71 expect(region.length, 20); |
| 72 expect(region.targets, hasLength(1)); |
| 73 { |
| 74 NavigationTarget target = collector.targets[region.targets[0]]; |
| 75 expect(target.offset, 21); |
| 76 expect(target.length, 22); |
| 77 } |
| 78 } |
| 79 } |
| 80 } |
OLD | NEW |