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.integration.analysis.overrides; | 5 library test.integration.analysis.overrides; |
6 | 6 |
7 import 'package:analysis_server/src/protocol.dart'; | 7 import 'package:analysis_server/src/protocol.dart'; |
8 import 'package:test_reflective_loader/test_reflective_loader.dart'; | 8 import 'package:test_reflective_loader/test_reflective_loader.dart'; |
9 import 'package:unittest/unittest.dart'; | 9 import 'package:unittest/unittest.dart'; |
10 | 10 |
| 11 import '../../utils.dart'; |
11 import '../integration_tests.dart'; | 12 import '../integration_tests.dart'; |
12 | 13 |
13 main() { | 14 main() { |
| 15 initializeTestEnvironment(); |
14 defineReflectiveTests(Test); | 16 defineReflectiveTests(Test); |
15 } | 17 } |
16 | 18 |
17 @reflectiveTest | 19 @reflectiveTest |
18 class Test extends AbstractAnalysisServerIntegrationTest { | 20 class Test extends AbstractAnalysisServerIntegrationTest { |
19 test_overrides() { | 21 test_overrides() { |
20 String pathname = sourcePath('test.dart'); | 22 String pathname = sourcePath('test.dart'); |
21 String text = r''' | 23 String text = r''' |
22 abstract class Interface1 { | 24 abstract class Interface1 { |
23 method0(); | 25 method0(); |
(...skipping 22 matching lines...) Expand all Loading... |
46 method2() {} | 48 method2() {} |
47 method3() {} | 49 method3() {} |
48 method4() {} | 50 method4() {} |
49 method5() {} | 51 method5() {} |
50 method6() {} | 52 method6() {} |
51 method7() {} | 53 method7() {} |
52 } | 54 } |
53 '''; | 55 '''; |
54 writeFile(pathname, text); | 56 writeFile(pathname, text); |
55 standardAnalysisSetup(); | 57 standardAnalysisSetup(); |
56 sendAnalysisSetSubscriptions({AnalysisService.OVERRIDES: [pathname]}); | 58 sendAnalysisSetSubscriptions({ |
| 59 AnalysisService.OVERRIDES: [pathname] |
| 60 }); |
57 List<Override> overrides; | 61 List<Override> overrides; |
58 onAnalysisOverrides.listen((AnalysisOverridesParams params) { | 62 onAnalysisOverrides.listen((AnalysisOverridesParams params) { |
59 expect(params.file, equals(pathname)); | 63 expect(params.file, equals(pathname)); |
60 overrides = params.overrides; | 64 overrides = params.overrides; |
61 }); | 65 }); |
62 return analysisFinished.then((_) { | 66 return analysisFinished.then((_) { |
63 int targetOffset = text.indexOf('Target'); | 67 int targetOffset = text.indexOf('Target'); |
64 Override findOverride(String methodName) { | 68 Override findOverride(String methodName) { |
65 int methodOffset = text.indexOf(methodName, targetOffset); | 69 int methodOffset = text.indexOf(methodName, targetOffset); |
66 for (Override override in overrides) { | 70 for (Override override in overrides) { |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
109 checkOverrides('method1', false, ['Interface1', 'Interface2']); | 113 checkOverrides('method1', false, ['Interface1', 'Interface2']); |
110 checkOverrides('method2', true, ['Interface1']); | 114 checkOverrides('method2', true, ['Interface1']); |
111 checkOverrides('method3', false, ['Interface1']); | 115 checkOverrides('method3', false, ['Interface1']); |
112 checkOverrides('method4', true, ['Interface2']); | 116 checkOverrides('method4', true, ['Interface2']); |
113 checkOverrides('method5', false, ['Interface2']); | 117 checkOverrides('method5', false, ['Interface2']); |
114 checkOverrides('method6', true, []); | 118 checkOverrides('method6', true, []); |
115 checkOverrides('method7', false, []); | 119 checkOverrides('method7', false, []); |
116 }); | 120 }); |
117 } | 121 } |
118 } | 122 } |
OLD | NEW |