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.operation.queue; | 5 library test.operation.queue; |
6 | 6 |
7 import 'package:analysis_server/src/analysis_server.dart'; | 7 import 'package:analysis_server/src/analysis_server.dart'; |
8 import 'package:analysis_server/src/context_manager.dart'; | 8 import 'package:analysis_server/src/context_manager.dart'; |
9 import 'package:analysis_server/src/operation/operation.dart'; | 9 import 'package:analysis_server/src/operation/operation.dart'; |
10 import 'package:analysis_server/src/operation/operation_analysis.dart'; | 10 import 'package:analysis_server/src/operation/operation_analysis.dart'; |
(...skipping 18 matching lines...) Expand all Loading... |
29 * Return a [ServerOperation] mock with the given priority. | 29 * Return a [ServerOperation] mock with the given priority. |
30 */ | 30 */ |
31 ServerOperation mockOperation(ServerOperationPriority priority) { | 31 ServerOperation mockOperation(ServerOperationPriority priority) { |
32 ServerOperation operation = new _ServerOperationMock(); | 32 ServerOperation operation = new _ServerOperationMock(); |
33 when(operation.priority).thenReturn(priority); | 33 when(operation.priority).thenReturn(priority); |
34 return operation; | 34 return operation; |
35 } | 35 } |
36 | 36 |
37 class AnalysisContextMock extends TypedMock implements InternalAnalysisContext { | 37 class AnalysisContextMock extends TypedMock implements InternalAnalysisContext { |
38 List<Source> prioritySources = <Source>[]; | 38 List<Source> prioritySources = <Source>[]; |
39 | |
40 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation); | |
41 } | 39 } |
42 | 40 |
43 class AnalysisServerMock extends TypedMock implements AnalysisServer { | 41 class AnalysisServerMock extends TypedMock implements AnalysisServer { |
44 @override | 42 @override |
45 final ResourceProvider resourceProvider; | 43 final ResourceProvider resourceProvider; |
46 | 44 |
47 @override | 45 @override |
48 final SearchEngine searchEngine; | 46 final SearchEngine searchEngine; |
49 | 47 |
50 AnalysisServerMock({this.resourceProvider, this.searchEngine}); | 48 AnalysisServerMock({this.resourceProvider, this.searchEngine}); |
51 | |
52 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation); | |
53 } | 49 } |
54 | 50 |
55 class ServerContextManagerMock extends TypedMock implements ContextManager { | 51 class ServerContextManagerMock extends TypedMock implements ContextManager {} |
56 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation); | |
57 } | |
58 | 52 |
59 @reflectiveTest | 53 @reflectiveTest |
60 class ServerOperationQueueTest { | 54 class ServerOperationQueueTest { |
61 ServerOperationQueue queue = new ServerOperationQueue(); | 55 ServerOperationQueue queue = new ServerOperationQueue(); |
62 | 56 |
63 void test_add_withMerge() { | 57 void test_add_withMerge() { |
64 var opA = new _MergeableOperationMock(); | 58 var opA = new _MergeableOperationMock(); |
65 var opB = new _MergeableOperationMock(); | 59 var opB = new _MergeableOperationMock(); |
66 var opC = new _MergeableOperationMock(); | 60 var opC = new _MergeableOperationMock(); |
67 when(opA.merge(opC)).thenReturn(true); | 61 when(opA.merge(opC)).thenReturn(true); |
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
223 expect(queue.takeIf((operation) => operation == operationA), operationA); | 217 expect(queue.takeIf((operation) => operation == operationA), operationA); |
224 expect(queue.isEmpty, isTrue); | 218 expect(queue.isEmpty, isTrue); |
225 } | 219 } |
226 } | 220 } |
227 | 221 |
228 class _MergeableOperationMock extends TypedMock implements MergeableOperation { | 222 class _MergeableOperationMock extends TypedMock implements MergeableOperation { |
229 @override | 223 @override |
230 ServerOperationPriority get priority { | 224 ServerOperationPriority get priority { |
231 return ServerOperationPriority.ANALYSIS_NOTIFICATION; | 225 return ServerOperationPriority.ANALYSIS_NOTIFICATION; |
232 } | 226 } |
233 | |
234 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation); | |
235 } | 227 } |
236 | 228 |
237 class _ServerOperationMock extends TypedMock implements ServerOperation { | 229 class _ServerOperationMock extends TypedMock implements ServerOperation { |
238 final AnalysisContext context; | 230 final AnalysisContext context; |
239 | 231 |
240 _ServerOperationMock([this.context]); | 232 _ServerOperationMock([this.context]); |
241 | |
242 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation); | |
243 } | 233 } |
244 | 234 |
245 class _SourceMock extends TypedMock implements Source { | 235 class _SourceMock extends TypedMock implements Source {} |
246 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation); | |
247 } | |
248 | 236 |
249 class _SourceSensitiveOperationMock extends TypedMock | 237 class _SourceSensitiveOperationMock extends TypedMock |
250 implements SourceSensitiveOperation { | 238 implements SourceSensitiveOperation { |
251 final Source source; | 239 final Source source; |
252 | 240 |
253 _SourceSensitiveOperationMock(this.source); | 241 _SourceSensitiveOperationMock(this.source); |
254 | 242 |
255 @override | 243 @override |
256 ServerOperationPriority get priority { | 244 ServerOperationPriority get priority { |
257 return ServerOperationPriority.ANALYSIS_NOTIFICATION; | 245 return ServerOperationPriority.ANALYSIS_NOTIFICATION; |
258 } | 246 } |
259 | 247 |
260 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation); | |
261 | |
262 @override | 248 @override |
263 bool shouldBeDiscardedOnSourceChange(Source source) { | 249 bool shouldBeDiscardedOnSourceChange(Source source) { |
264 return source == this.source; | 250 return source == this.source; |
265 } | 251 } |
266 } | 252 } |
OLD | NEW |