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

Side by Side Diff: pkg/analysis_server/test/analysis/navigation_collector_test.dart

Issue 3002253002: Use the NavigationCollector from analyzer_plugin to avoid duplication (Closed)
Patch Set: Created 3 years, 4 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 unified diff | Download patch
OLDNEW
(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 import 'package:analysis_server/src/domains/analysis/navigation.dart';
6 import 'package:analyzer_plugin/protocol/protocol_common.dart';
7 import 'package:test/test.dart';
8 import 'package:test_reflective_loader/test_reflective_loader.dart';
9
10 main() {
11 defineReflectiveSuite(() {
12 defineReflectiveTests(NavigationCollectorImplTest);
13 });
14 }
15
16 @reflectiveTest
17 class NavigationCollectorImplTest {
18 NavigationCollectorImpl collector = new NavigationCollectorImpl();
19
20 void test_multipleTargets() {
21 collector.addRegion(
22 10, 5, ElementKind.CLASS, new Location('file', 11, 12, 13, 14));
23 collector.addRegion(
24 10, 5, ElementKind.CLASS, new Location('file', 21, 22, 23, 24));
25 collector.createRegions();
26 List<NavigationRegion> regions = collector.regions;
27 expect(regions, hasLength(1));
28 {
29 NavigationRegion region = regions[0];
30 expect(region.offset, 10);
31 expect(region.length, 5);
32 expect(region.targets, hasLength(2));
33 {
34 NavigationTarget target = collector.targets[region.targets[0]];
35 expect(target.offset, 11);
36 expect(target.length, 12);
37 }
38 {
39 NavigationTarget target = collector.targets[region.targets[1]];
40 expect(target.offset, 21);
41 expect(target.length, 22);
42 }
43 }
44 }
45
46 void test_unique() {
47 collector.addRegion(
48 100, 10, ElementKind.CLASS, new Location('file', 11, 12, 13, 14));
49 collector.addRegion(
50 200, 20, ElementKind.CLASS, new Location('file', 21, 22, 23, 24));
51 collector.createRegions();
52 List<NavigationRegion> regions = collector.regions;
53 expect(regions, hasLength(2));
54 {
55 NavigationRegion region = regions[0];
56 expect(region.offset, 100);
57 expect(region.length, 10);
58 expect(region.targets, hasLength(1));
59 {
60 NavigationTarget target = collector.targets[region.targets[0]];
61 expect(target.offset, 11);
62 expect(target.length, 12);
63 }
64 }
65 {
66 NavigationRegion region = regions[1];
67 expect(region.offset, 200);
68 expect(region.length, 20);
69 expect(region.targets, hasLength(1));
70 {
71 NavigationTarget target = collector.targets[region.targets[0]];
72 expect(target.offset, 21);
73 expect(target.length, 22);
74 }
75 }
76 }
77 }
OLDNEW
« no previous file with comments | « pkg/analysis_server/lib/src/domains/analysis/navigation_dart.dart ('k') | pkg/analysis_server/test/analysis/test_all.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698