| OLD | NEW |
| 1 // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2017, 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 import 'package:analyzer_plugin/protocol/protocol_generated.dart'; | 5 import 'package:analyzer_plugin/protocol/protocol_generated.dart'; |
| 6 import 'package:analyzer_plugin/utilities/subscriptions/subscription_manager.dar
t'; | 6 import 'package:analyzer_plugin/utilities/subscriptions/subscription_manager.dar
t'; |
| 7 import 'package:test/test.dart'; | 7 import 'package:test/test.dart'; |
| 8 import 'package:test_reflective_loader/test_reflective_loader.dart'; | 8 import 'package:test_reflective_loader/test_reflective_loader.dart'; |
| 9 | 9 |
| 10 void main() { | 10 void main() { |
| 11 defineReflectiveTests(SubscriptionManagerTest); | 11 defineReflectiveTests(SubscriptionManagerTest); |
| 12 } | 12 } |
| 13 | 13 |
| 14 @reflectiveTest | 14 @reflectiveTest |
| 15 class SubscriptionManagerTest { | 15 class SubscriptionManagerTest { |
| 16 SubscriptionManager manager = new SubscriptionManager(); | 16 SubscriptionManager manager = new SubscriptionManager(); |
| 17 | 17 |
| 18 String fooPath = '/project/lib/foo.dart'; |
| 19 String barPath = '/project/lib/bar.dart'; |
| 20 String bazPath = '/project/lib/baz.dart'; |
| 21 |
| 22 test_hasSubscriptionForFile_differentSubscription() { |
| 23 manager.setSubscriptions({ |
| 24 AnalysisService.NAVIGATION: [barPath] |
| 25 }); |
| 26 expect(manager.hasSubscriptionForFile(fooPath, AnalysisService.HIGHLIGHTS), |
| 27 isFalse); |
| 28 } |
| 29 |
| 30 test_hasSubscriptionForFile_hasSubscription() { |
| 31 manager.setSubscriptions({ |
| 32 AnalysisService.HIGHLIGHTS: [fooPath] |
| 33 }); |
| 34 expect(manager.hasSubscriptionForFile(fooPath, AnalysisService.HIGHLIGHTS), |
| 35 isTrue); |
| 36 } |
| 37 |
| 38 test_hasSubscriptionForFile_noSubscription() { |
| 39 expect(manager.hasSubscriptionForFile(fooPath, AnalysisService.HIGHLIGHTS), |
| 40 isFalse); |
| 41 } |
| 42 |
| 18 test_servicesForFile() { | 43 test_servicesForFile() { |
| 19 expect(manager.servicesForFile('/project/lib/test.dart'), hasLength(0)); | 44 expect(manager.servicesForFile('/project/lib/test.dart'), hasLength(0)); |
| 20 } | 45 } |
| 21 | 46 |
| 22 test_setSubscriptions() { | 47 test_setSubscriptions() { |
| 23 String fooPath = '/project/lib/foo.dart'; | |
| 24 String barPath = '/project/lib/bar.dart'; | |
| 25 String bazPath = '/project/lib/baz.dart'; | |
| 26 // | 48 // |
| 27 // Set the initial set of subscriptions. | 49 // Set the initial set of subscriptions. |
| 28 // | 50 // |
| 29 Map<String, List<AnalysisService>> newSubscriptions = | 51 Map<String, List<AnalysisService>> newSubscriptions = |
| 30 manager.setSubscriptions({ | 52 manager.setSubscriptions({ |
| 31 AnalysisService.HIGHLIGHTS: [fooPath, barPath], | 53 AnalysisService.HIGHLIGHTS: [fooPath, barPath], |
| 32 AnalysisService.NAVIGATION: [fooPath] | 54 AnalysisService.NAVIGATION: [fooPath] |
| 33 }); | 55 }); |
| 34 | 56 |
| 35 expect( | 57 expect( |
| (...skipping 25 matching lines...) Expand all Loading... |
| 61 [AnalysisService.HIGHLIGHTS, AnalysisService.NAVIGATION])); | 83 [AnalysisService.HIGHLIGHTS, AnalysisService.NAVIGATION])); |
| 62 expect(manager.servicesForFile(bazPath), | 84 expect(manager.servicesForFile(bazPath), |
| 63 unorderedEquals([AnalysisService.HIGHLIGHTS])); | 85 unorderedEquals([AnalysisService.HIGHLIGHTS])); |
| 64 | 86 |
| 65 expect(newSubscriptions[barPath], | 87 expect(newSubscriptions[barPath], |
| 66 unorderedEquals([AnalysisService.NAVIGATION])); | 88 unorderedEquals([AnalysisService.NAVIGATION])); |
| 67 expect(newSubscriptions[bazPath], | 89 expect(newSubscriptions[bazPath], |
| 68 unorderedEquals([AnalysisService.HIGHLIGHTS])); | 90 unorderedEquals([AnalysisService.HIGHLIGHTS])); |
| 69 } | 91 } |
| 70 } | 92 } |
| OLD | NEW |