OLD | NEW |
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, 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 analyzer.test.src.task.options_work_manager_test; | 5 library analyzer.test.src.task.options_work_manager_test; |
6 | 6 |
7 import 'package:analyzer/src/context/cache.dart'; | 7 import 'package:analyzer/src/context/cache.dart'; |
8 import 'package:analyzer/src/generated/engine.dart' | 8 import 'package:analyzer/src/generated/engine.dart' |
9 show | 9 show |
10 AnalysisEngine, | 10 AnalysisEngine, |
(...skipping 13 matching lines...) Expand all Loading... |
24 import 'package:analyzer/task/model.dart'; | 24 import 'package:analyzer/task/model.dart'; |
25 import 'package:typed_mock/typed_mock.dart'; | 25 import 'package:typed_mock/typed_mock.dart'; |
26 import 'package:unittest/unittest.dart'; | 26 import 'package:unittest/unittest.dart'; |
27 | 27 |
28 import '../../generated/test_support.dart'; | 28 import '../../generated/test_support.dart'; |
29 import '../../reflective_tests.dart'; | 29 import '../../reflective_tests.dart'; |
30 import '../../utils.dart'; | 30 import '../../utils.dart'; |
31 | 31 |
32 main() { | 32 main() { |
33 initializeTestEnvironment(); | 33 initializeTestEnvironment(); |
34 runReflectiveTests(OptionsWorkManagerTest); | 34 runReflectiveTests(OptionsWorkManagerNewFileTest); |
| 35 runReflectiveTests(OptionsWorkManagerOldFileTest); |
35 } | 36 } |
36 | 37 |
37 @reflectiveTest | 38 @reflectiveTest |
38 class OptionsWorkManagerTest { | 39 class OptionsWorkManagerNewFileTest extends OptionsWorkManagerTest { |
39 static final optionsFile = AnalysisEngine.ANALYSIS_OPTIONS_FILE; | 40 String get optionsFile => AnalysisEngine.ANALYSIS_OPTIONS_YAML_FILE; |
| 41 } |
| 42 |
| 43 @reflectiveTest |
| 44 class OptionsWorkManagerOldFileTest extends OptionsWorkManagerTest { |
| 45 String get optionsFile => AnalysisEngine.ANALYSIS_OPTIONS_FILE; |
| 46 } |
| 47 |
| 48 abstract class OptionsWorkManagerTest { |
40 InternalAnalysisContext context = new _InternalAnalysisContextMock(); | 49 InternalAnalysisContext context = new _InternalAnalysisContextMock(); |
41 AnalysisCache cache; | 50 AnalysisCache cache; |
42 | |
43 OptionsWorkManager manager; | 51 OptionsWorkManager manager; |
44 | 52 |
45 CaughtException caughtException = new CaughtException(null, null); | 53 CaughtException caughtException = new CaughtException(null, null); |
46 | 54 |
47 Source source1 = new TestSource('test1/$optionsFile'); | 55 Source source1; |
48 Source source2 = new TestSource('test2/$optionsFile'); | 56 |
49 Source source3 = new TestSource('test3/$optionsFile'); | 57 Source source2; |
50 Source source4 = new TestSource('test4/$optionsFile'); | 58 Source source3; |
| 59 Source source4; |
51 CacheEntry entry1; | 60 CacheEntry entry1; |
52 CacheEntry entry2; | 61 CacheEntry entry2; |
53 CacheEntry entry3; | 62 CacheEntry entry3; |
54 CacheEntry entry4; | 63 CacheEntry entry4; |
| 64 String get optionsFile; |
55 | 65 |
56 void expect_sourceQueue(List<Source> sources) { | 66 void expect_sourceQueue(List<Source> sources) { |
57 expect(manager.sourceQueue, unorderedEquals(sources)); | 67 expect(manager.sourceQueue, unorderedEquals(sources)); |
58 } | 68 } |
59 | 69 |
60 void setUp() { | 70 void setUp() { |
61 cache = context.analysisCache; | 71 cache = context.analysisCache; |
62 manager = new OptionsWorkManager(context); | 72 manager = new OptionsWorkManager(context); |
| 73 source1 = new TestSource('test1/$optionsFile'); |
| 74 source2 = new TestSource('test2/$optionsFile'); |
| 75 source3 = new TestSource('test3/$optionsFile'); |
| 76 source4 = new TestSource('test4/$optionsFile'); |
63 entry1 = context.getCacheEntry(source1); | 77 entry1 = context.getCacheEntry(source1); |
64 entry2 = context.getCacheEntry(source2); | 78 entry2 = context.getCacheEntry(source2); |
65 entry3 = context.getCacheEntry(source3); | 79 entry3 = context.getCacheEntry(source3); |
66 entry4 = context.getCacheEntry(source4); | 80 entry4 = context.getCacheEntry(source4); |
67 } | 81 } |
68 | 82 |
69 void test_applyChange_add() { | 83 void test_applyChange_add() { |
70 // add source1 | 84 // add source1 |
71 manager.applyChange([source1], [], []); | 85 manager.applyChange([source1], [], []); |
72 expect_sourceQueue([source1]); | 86 expect_sourceQueue([source1]); |
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
276 errors = getCacheEntry(source).getValue(ANALYSIS_OPTIONS_ERRORS); | 290 errors = getCacheEntry(source).getValue(ANALYSIS_OPTIONS_ERRORS); |
277 } | 291 } |
278 return new AnalysisErrorInfoImpl( | 292 return new AnalysisErrorInfoImpl( |
279 errors, getCacheEntry(source).getValue(LINE_INFO)); | 293 errors, getCacheEntry(source).getValue(LINE_INFO)); |
280 } | 294 } |
281 | 295 |
282 @override | 296 @override |
283 ChangeNoticeImpl getNotice(Source source) => | 297 ChangeNoticeImpl getNotice(Source source) => |
284 _pendingNotices.putIfAbsent(source, () => new ChangeNoticeImpl(source)); | 298 _pendingNotices.putIfAbsent(source, () => new ChangeNoticeImpl(source)); |
285 } | 299 } |
OLD | NEW |