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

Side by Side Diff: pkg/analysis_server/test/integration/analysis/outline_test.dart

Issue 472933003: Add an integration test for analysis.outline. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | pkg/analysis_server/test/integration/analysis/test_all.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // BSD-style license that can be found in the LICENSE file.
4
5 library test.integration.analysis.outline;
6
7 import 'package:analysis_testing/reflective_tests.dart';
8 import 'package:unittest/unittest.dart';
9
10 import '../integration_tests.dart';
11
12 @ReflectiveTestCase()
13 class Test extends AbstractAnalysisServerIntegrationTest {
14 test_outline() {
15 String pathname = sourcePath('test.dart');
16 String text =
17 r'''
18 class Class1 {
19 int field;
20
21 void method() {
22 }
23
24 static staticMethod() {
25 }
26
27 get getter {
28 return null;
29 }
30
31 set setter(value) {
32 }
33 }
34
35 class Class2 {
36 }
37 ''';
38 writeFile(pathname, text);
39 standardAnalysisSetup();
40 sendAnalysisSetSubscriptions({
41 'OUTLINE': [pathname]
42 });
43 Map outline;
44 onAnalysisOutline.listen((params) {
45 expect(params['file'], equals(pathname));
46 outline = params['outline'];
47 });
48 return analysisFinished.then((_) {
49 expect(outline['element']['kind'], equals('COMPILATION_UNIT'));
50 expect(outline['offset'], equals(0));
51 expect(outline['length'], equals(text.length));
52 List classes = outline['children'];
53 expect(classes, hasLength(2));
54 expect(classes[0]['element']['name'], equals('Class1'));
55 expect(classes[1]['element']['name'], equals('Class2'));
56 checkConnected(classes);
57 List members = classes[0]['children'];
58 expect(members, hasLength(5));
59 expect(members[0]['element']['name'], equals('field'));
60 expect(members[1]['element']['name'], equals('method'));
61 expect(members[2]['element']['name'], equals('staticMethod'));
62 expect(members[3]['element']['name'], equals('getter'));
63 expect(members[4]['element']['name'], equals('setter'));
64 checkConnected(members);
65 });
66 }
67
68 /**
69 * Verify that the range of source text covered by the given outline objects
70 * is connected (the end of each object in the list corresponds to the start
71 * of the next).
72 */
73 void checkConnected(List outlineObjects) {
74 for (int i = 0; i < outlineObjects.length - 1; i++) {
75 expect(outlineObjects[i + 1]['offset'], equals(outlineObjects[i]['offset']
76 + outlineObjects[i]['length']));
77 }
78 }
79 }
80
81 main() {
82 runReflectiveTests(Test);
83 }
OLDNEW
« no previous file with comments | « no previous file | pkg/analysis_server/test/integration/analysis/test_all.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698