| OLD | NEW |
| (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 } |
| OLD | NEW |