| 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/operation/operation_analysis.dart'; | 8 import 'package:analysis_server/src/operation/operation_analysis.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_queue.dart'; | 10 import 'package:analysis_server/src/operation/operation_queue.dart'; |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 47 expect(queue.isEmpty, isFalse); | 47 expect(queue.isEmpty, isFalse); |
| 48 }); | 48 }); |
| 49 }); | 49 }); |
| 50 | 50 |
| 51 group('take', () { | 51 group('take', () { |
| 52 test('empty', () { | 52 test('empty', () { |
| 53 expect(queue.take(), isNull); | 53 expect(queue.take(), isNull); |
| 54 }); | 54 }); |
| 55 | 55 |
| 56 test('use operation priorities', () { | 56 test('use operation priorities', () { |
| 57 // TODO(scheglov) update 'typed_mock' to make 'any*' fields dynamic | 57 when(server.isPriorityContext(anyObject)).thenReturn(false); |
| 58 when(server.isPriorityContext(anyObject as dynamic)).thenReturn(false); | |
| 59 var analysisContext = new AnalysisContextMock(); | 58 var analysisContext = new AnalysisContextMock(); |
| 60 var operationA = mockOperation(ServerOperationPriority.SEARCH); | 59 var operationA = mockOperation(ServerOperationPriority.SEARCH); |
| 61 var operationB = mockOperation(ServerOperationPriority.REFACTORING); | 60 var operationB = mockOperation(ServerOperationPriority.REFACTORING); |
| 62 var operationC = new PerformAnalysisOperation(analysisContext, false); | 61 var operationC = new PerformAnalysisOperation(analysisContext, false); |
| 63 queue.add(operationA); | 62 queue.add(operationA); |
| 64 queue.add(operationB); | 63 queue.add(operationB); |
| 65 queue.add(operationC); | 64 queue.add(operationC); |
| 66 expect(queue.take(), operationC); | 65 expect(queue.take(), operationC); |
| 67 expect(queue.take(), operationA); | 66 expect(queue.take(), operationA); |
| 68 expect(queue.take(), operationB); | 67 expect(queue.take(), operationB); |
| 69 expect(queue.take(), isNull); | 68 expect(queue.take(), isNull); |
| 70 }); | 69 }); |
| 71 | 70 |
| 72 test('continue analysis first', () { | 71 test('continue analysis first', () { |
| 73 // TODO(scheglov) update 'typed_mock' to make 'any*' fields dynamic | 72 when(server.isPriorityContext(anyObject)).thenReturn(false); |
| 74 when(server.isPriorityContext(anyObject as dynamic)).thenReturn(false); | |
| 75 var analysisContext = new AnalysisContextMock(); | 73 var analysisContext = new AnalysisContextMock(); |
| 76 var operationA = new PerformAnalysisOperation(analysisContext, false); | 74 var operationA = new PerformAnalysisOperation(analysisContext, false); |
| 77 var operationB = new PerformAnalysisOperation(analysisContext, true); | 75 var operationB = new PerformAnalysisOperation(analysisContext, true); |
| 78 queue.add(operationA); | 76 queue.add(operationA); |
| 79 queue.add(operationB); | 77 queue.add(operationB); |
| 80 expect(queue.take(), operationB); | 78 expect(queue.take(), operationB); |
| 81 expect(queue.take(), operationA); | 79 expect(queue.take(), operationA); |
| 82 expect(queue.take(), isNull); | 80 expect(queue.take(), isNull); |
| 83 }); | 81 }); |
| 84 | 82 |
| (...skipping 29 matching lines...) Expand all Loading... |
| 114 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation); | 112 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation); |
| 115 } | 113 } |
| 116 | 114 |
| 117 class ServerOperationMock extends TypedMock implements ServerOperation { | 115 class ServerOperationMock extends TypedMock implements ServerOperation { |
| 118 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation); | 116 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation); |
| 119 } | 117 } |
| 120 | 118 |
| 121 class AnalysisServerMock extends TypedMock implements AnalysisServer { | 119 class AnalysisServerMock extends TypedMock implements AnalysisServer { |
| 122 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation); | 120 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation); |
| 123 } | 121 } |
| OLD | NEW |