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

Side by Side Diff: pkg/analyzer_plugin/test/utilities/subscriptions/subscription_manager_test.dart

Issue 2861373005: Improve default support provided for plugins (Closed)
Patch Set: Created 3 years, 7 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
OLDNEW
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 test_servicesForFile() { 18 test_servicesForFile() {
19 expect(manager.servicesForFile('/project/lib/test.dart'), hasLength(0)); 19 expect(manager.servicesForFile('/project/lib/test.dart'), hasLength(0));
20 } 20 }
21 21
22 test_setSubscriptions() { 22 test_setSubscriptions() {
23 manager.setSubscriptions({ 23 String fooPath = '/project/lib/foo.dart';
24 AnalysisService.HIGHLIGHTS: [ 24 String barPath = '/project/lib/bar.dart';
25 '/project/lib/foo.dart', 25 String bazPath = '/project/lib/baz.dart';
26 '/project/lib/bar.dart' 26 //
27 ], 27 // Set the initial set of subscriptions.
28 AnalysisService.NAVIGATION: ['/project/lib/foo.dart'] 28 //
29 Map<String, List<AnalysisService>> newSubscriptions =
30 manager.setSubscriptions({
31 AnalysisService.HIGHLIGHTS: [fooPath, barPath],
32 AnalysisService.NAVIGATION: [fooPath]
29 }); 33 });
30 expect(manager.servicesForFile('/project/lib/test.dart'), hasLength(0)); 34
31 expect(manager.servicesForFile('/project/lib/bar.dart'),
32 unorderedEquals([AnalysisService.HIGHLIGHTS]));
33 expect( 35 expect(
34 manager.servicesForFile('/project/lib/foo.dart'), 36 manager.servicesForFile(fooPath),
35 unorderedEquals( 37 unorderedEquals(
36 [AnalysisService.HIGHLIGHTS, AnalysisService.NAVIGATION])); 38 [AnalysisService.HIGHLIGHTS, AnalysisService.NAVIGATION]));
39 expect(manager.servicesForFile(barPath),
40 unorderedEquals([AnalysisService.HIGHLIGHTS]));
41 expect(manager.servicesForFile(bazPath), hasLength(0));
42
43 expect(
44 newSubscriptions[fooPath],
45 unorderedEquals(
46 [AnalysisService.HIGHLIGHTS, AnalysisService.NAVIGATION]));
47 expect(newSubscriptions[barPath],
48 unorderedEquals([AnalysisService.HIGHLIGHTS]));
49 //
50 // Update the subscriptions.
51 //
52 newSubscriptions = manager.setSubscriptions({
53 AnalysisService.HIGHLIGHTS: [bazPath, barPath],
54 AnalysisService.NAVIGATION: [barPath]
55 });
56
57 expect(manager.servicesForFile(fooPath), hasLength(0));
58 expect(
59 manager.servicesForFile(barPath),
60 unorderedEquals(
61 [AnalysisService.HIGHLIGHTS, AnalysisService.NAVIGATION]));
62 expect(manager.servicesForFile(bazPath),
63 unorderedEquals([AnalysisService.HIGHLIGHTS]));
64
65 expect(newSubscriptions[barPath],
66 unorderedEquals([AnalysisService.NAVIGATION]));
67 expect(newSubscriptions[bazPath],
68 unorderedEquals([AnalysisService.HIGHLIGHTS]));
37 } 69 }
38 } 70 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698