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

Side by Side Diff: pkg/analysis_server/test/operation/operation_queue_test.dart

Issue 1008443002: Cherry-pick r44373, r44378, and r44275. (Closed) Base URL: https://dart.googlecode.com/svn/trunk/dart
Patch Set: Created 5 years, 9 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 | Annotate | Revision Log
OLDNEW
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.dart'; 8 import 'package:analysis_server/src/operation/operation.dart';
9 import 'package:analysis_server/src/operation/operation_analysis.dart'; 9 import 'package:analysis_server/src/operation/operation_analysis.dart';
10 import 'package:analysis_server/src/operation/operation_queue.dart'; 10 import 'package:analysis_server/src/operation/operation_queue.dart';
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 var operationB = mockOperation(ServerOperationPriority.ANALYSIS_CONTINUE); 54 var operationB = mockOperation(ServerOperationPriority.ANALYSIS_CONTINUE);
55 queue.add(operationA); 55 queue.add(operationA);
56 queue.add(operationB); 56 queue.add(operationB);
57 // there are some operations 57 // there are some operations
58 expect(queue.isEmpty, false); 58 expect(queue.isEmpty, false);
59 // clear - no operations 59 // clear - no operations
60 queue.clear(); 60 queue.clear();
61 expect(queue.isEmpty, true); 61 expect(queue.isEmpty, true);
62 } 62 }
63 63
64 void test_contextRemoved() {
65 var contextA = new AnalysisContextMock();
66 var contextB = new AnalysisContextMock();
67 var opA1 = new _ServerOperationMock(contextA);
68 var opA2 = new _ServerOperationMock(contextA);
69 var opB1 = new _ServerOperationMock(contextB);
70 var opB2 = new _ServerOperationMock(contextB);
71 when(opA1.priority)
72 .thenReturn(ServerOperationPriority.ANALYSIS_NOTIFICATION);
73 when(opA2.priority)
74 .thenReturn(ServerOperationPriority.ANALYSIS_NOTIFICATION);
75 when(opB1.priority)
76 .thenReturn(ServerOperationPriority.ANALYSIS_NOTIFICATION);
77 when(opB2.priority)
78 .thenReturn(ServerOperationPriority.ANALYSIS_NOTIFICATION);
79 queue.add(opA1);
80 queue.add(opB1);
81 queue.add(opA2);
82 queue.add(opB2);
83 queue.contextRemoved(contextA);
84 expect(queue.take(), same(opB1));
85 expect(queue.take(), same(opB2));
86 }
87
64 void test_isEmpty_false() { 88 void test_isEmpty_false() {
65 var operation = mockOperation(ServerOperationPriority.ANALYSIS); 89 var operation = mockOperation(ServerOperationPriority.ANALYSIS);
66 queue.add(operation); 90 queue.add(operation);
67 expect(queue.isEmpty, isFalse); 91 expect(queue.isEmpty, isFalse);
68 } 92 }
69 93
70 void test_isEmpty_true() { 94 void test_isEmpty_true() {
71 expect(queue.isEmpty, isTrue); 95 expect(queue.isEmpty, isTrue);
72 } 96 }
73 97
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
141 queue.add(operationB); 165 queue.add(operationB);
142 queue.add(operationC); 166 queue.add(operationC);
143 expect(queue.take(), operationC); 167 expect(queue.take(), operationC);
144 expect(queue.take(), operationB); 168 expect(queue.take(), operationB);
145 expect(queue.take(), operationA); 169 expect(queue.take(), operationA);
146 expect(queue.take(), isNull); 170 expect(queue.take(), isNull);
147 } 171 }
148 } 172 }
149 173
150 class _ServerOperationMock extends TypedMock implements ServerOperation { 174 class _ServerOperationMock extends TypedMock implements ServerOperation {
175 final AnalysisContext context;
176
177 _ServerOperationMock([this.context]);
178
151 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation); 179 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation);
152 } 180 }
153 181
154 class _SourceMock extends TypedMock implements Source { 182 class _SourceMock extends TypedMock implements Source {
155 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation); 183 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation);
156 } 184 }
157 185
158 class _SourceSensitiveOperationMock extends TypedMock 186 class _SourceSensitiveOperationMock extends TypedMock
159 implements SourceSensitiveOperation { 187 implements SourceSensitiveOperation {
160 final Source source; 188 final Source source;
161 189
162 _SourceSensitiveOperationMock(this.source); 190 _SourceSensitiveOperationMock(this.source);
163 191
164 @override 192 @override
165 ServerOperationPriority get priority { 193 ServerOperationPriority get priority {
166 return ServerOperationPriority.ANALYSIS_NOTIFICATION; 194 return ServerOperationPriority.ANALYSIS_NOTIFICATION;
167 } 195 }
168 196
169 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation); 197 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation);
170 198
171 @override 199 @override
172 bool shouldBeDiscardedOnSourceChange(Source source) { 200 bool shouldBeDiscardedOnSourceChange(Source source) {
173 return source == this.source; 201 return source == this.source;
174 } 202 }
175 } 203 }
OLDNEW
« no previous file with comments | « pkg/analysis_server/test/analysis_server_test.dart ('k') | pkg/analyzer/lib/src/generated/engine.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698