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.outline; | 5 library test.analysis.notification.outline; |
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'; |
11 import 'package:test_reflective_loader/test_reflective_loader.dart'; | 11 import 'package:test_reflective_loader/test_reflective_loader.dart'; |
12 import 'package:unittest/unittest.dart'; | 12 import 'package:unittest/unittest.dart'; |
13 | 13 |
14 import '../analysis_abstract.dart'; | 14 import '../analysis_abstract.dart'; |
15 import '../utils.dart'; | 15 import '../utils.dart'; |
16 | 16 |
17 main() { | 17 main() { |
18 initializeTestEnvironment(); | 18 initializeTestEnvironment(); |
19 defineReflectiveTests(_AnalysisNotificationOutlineTest); | 19 defineReflectiveTests(_AnalysisNotificationOutlineTest); |
20 } | 20 } |
21 | 21 |
22 @reflectiveTest | 22 @reflectiveTest |
23 class _AnalysisNotificationOutlineTest extends AbstractAnalysisTest { | 23 class _AnalysisNotificationOutlineTest extends AbstractAnalysisTest { |
24 FileKind fileKind; | |
25 String libraryName; | |
24 Outline outline; | 26 Outline outline; |
25 | 27 |
26 Future prepareOutline() { | 28 Future prepareOutline() { |
27 addAnalysisSubscription(AnalysisService.OUTLINE, testFile); | 29 addAnalysisSubscription(AnalysisService.OUTLINE, testFile); |
28 return waitForTasksFinished(); | 30 return waitForTasksFinished(); |
29 } | 31 } |
30 | 32 |
31 void processNotification(Notification notification) { | 33 void processNotification(Notification notification) { |
32 if (notification.event == ANALYSIS_OUTLINE) { | 34 if (notification.event == ANALYSIS_OUTLINE) { |
33 var params = new AnalysisOutlineParams.fromNotification(notification); | 35 var params = new AnalysisOutlineParams.fromNotification(notification); |
34 if (params.file == testFile) { | 36 if (params.file == testFile) { |
37 fileKind = params.kind; | |
38 libraryName = params.libraryName; | |
35 outline = params.outline; | 39 outline = params.outline; |
36 } | 40 } |
37 } | 41 } |
38 } | 42 } |
39 | 43 |
40 @override | 44 @override |
41 void setUp() { | 45 void setUp() { |
42 super.setUp(); | 46 super.setUp(); |
43 createProject(); | 47 createProject(); |
44 } | 48 } |
(...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
304 const int CONST = 0; | 308 const int CONST = 0; |
305 } | 309 } |
306 } | 310 } |
307 } | 311 } |
308 '''); | 312 '''); |
309 return prepareOutline().then((_) { | 313 return prepareOutline().then((_) { |
310 expect(outline, isNotNull); | 314 expect(outline, isNotNull); |
311 }); | 315 }); |
312 } | 316 } |
313 | 317 |
318 test_libraryName_hasLibraryDirective() async { | |
Brian Wilkerson
2015/10/01 20:01:16
Perhaps add a test for neither library nor part-of
| |
319 addTestFile(''' | |
320 library my.lib; | |
321 '''); | |
322 await prepareOutline(); | |
323 expect(fileKind, FileKind.LIBRARY); | |
324 expect(libraryName, 'my.lib'); | |
325 } | |
326 | |
327 test_libraryName_hasLibraryPartOfDirectives() async { | |
328 addTestFile(''' | |
329 part of lib.in.part.of; | |
330 library my.lib; | |
331 '''); | |
332 await prepareOutline(); | |
333 expect(fileKind, FileKind.LIBRARY); | |
334 expect(libraryName, 'my.lib'); | |
335 } | |
336 | |
337 test_libraryName_hasPartOfDirective() async { | |
338 addTestFile(''' | |
339 part of my.lib; | |
340 '''); | |
341 await prepareOutline(); | |
342 expect(fileKind, FileKind.PART); | |
343 expect(libraryName, 'my.lib'); | |
344 } | |
345 | |
314 test_localFunctions() { | 346 test_localFunctions() { |
315 addTestFile(''' | 347 addTestFile(''' |
316 class A { | 348 class A { |
317 A() { | 349 A() { |
318 int local_A() {} | 350 int local_A() {} |
319 } | 351 } |
320 m() { | 352 m() { |
321 local_m() {} | 353 local_m() {} |
322 } | 354 } |
323 } | 355 } |
(...skipping 488 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
812 } | 844 } |
813 | 845 |
814 void _isEnumConstant(Outline outline, String name) { | 846 void _isEnumConstant(Outline outline, String name) { |
815 Element element = outline.element; | 847 Element element = outline.element; |
816 expect(element.kind, ElementKind.ENUM_CONSTANT); | 848 expect(element.kind, ElementKind.ENUM_CONSTANT); |
817 expect(element.name, name); | 849 expect(element.name, name); |
818 expect(element.parameters, isNull); | 850 expect(element.parameters, isNull); |
819 expect(element.returnType, isNull); | 851 expect(element.returnType, isNull); |
820 } | 852 } |
821 } | 853 } |
OLD | NEW |