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

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

Issue 988593002: Don't send notifications for disposed contexts. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/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 _ContextOperationMock(contextA);
68 var opA2 = new _ContextOperationMock(contextA);
69 var opB1 = new _ContextOperationMock(contextB);
70 var opB2 = new _ContextOperationMock(contextB);
71 queue.add(opA1);
72 queue.add(opB1);
73 queue.add(opA2);
74 queue.add(opB2);
75 queue.contextRemoved(contextA);
76 expect(queue.take(), same(opB1));
77 expect(queue.take(), same(opB2));
78 }
79
64 void test_isEmpty_false() { 80 void test_isEmpty_false() {
65 var operation = mockOperation(ServerOperationPriority.ANALYSIS); 81 var operation = mockOperation(ServerOperationPriority.ANALYSIS);
66 queue.add(operation); 82 queue.add(operation);
67 expect(queue.isEmpty, isFalse); 83 expect(queue.isEmpty, isFalse);
68 } 84 }
69 85
70 void test_isEmpty_true() { 86 void test_isEmpty_true() {
71 expect(queue.isEmpty, isTrue); 87 expect(queue.isEmpty, isTrue);
72 } 88 }
73 89
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
140 queue.add(operationA); 156 queue.add(operationA);
141 queue.add(operationB); 157 queue.add(operationB);
142 queue.add(operationC); 158 queue.add(operationC);
143 expect(queue.take(), operationC); 159 expect(queue.take(), operationC);
144 expect(queue.take(), operationB); 160 expect(queue.take(), operationB);
145 expect(queue.take(), operationA); 161 expect(queue.take(), operationA);
146 expect(queue.take(), isNull); 162 expect(queue.take(), isNull);
147 } 163 }
148 } 164 }
149 165
166 class _ContextOperationMock extends TypedMock implements ServerOperation {
scheglov 2015/03/06 00:37:23 We could merge this class with _ServerOperationMoc
Paul Berry 2015/03/06 01:11:09 Done.
167 final AnalysisContext context;
168
169 _ContextOperationMock(this.context);
170
171 @override
172 ServerOperationPriority get priority {
173 return ServerOperationPriority.ANALYSIS_NOTIFICATION;
174 }
175
176 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation);
177 }
178
150 class _ServerOperationMock extends TypedMock implements ServerOperation { 179 class _ServerOperationMock extends TypedMock implements ServerOperation {
151 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation); 180 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation);
152 } 181 }
153 182
154 class _SourceMock extends TypedMock implements Source { 183 class _SourceMock extends TypedMock implements Source {
155 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation); 184 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation);
156 } 185 }
157 186
158 class _SourceSensitiveOperationMock extends TypedMock 187 class _SourceSensitiveOperationMock extends TypedMock
159 implements SourceSensitiveOperation { 188 implements SourceSensitiveOperation {
160 final Source source; 189 final Source source;
161 190
162 _SourceSensitiveOperationMock(this.source); 191 _SourceSensitiveOperationMock(this.source);
163 192
164 @override 193 @override
165 ServerOperationPriority get priority { 194 ServerOperationPriority get priority {
166 return ServerOperationPriority.ANALYSIS_NOTIFICATION; 195 return ServerOperationPriority.ANALYSIS_NOTIFICATION;
167 } 196 }
168 197
169 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation); 198 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation);
170 199
171 @override 200 @override
172 bool shouldBeDiscardedOnSourceChange(Source source) { 201 bool shouldBeDiscardedOnSourceChange(Source source) {
173 return source == this.source; 202 return source == this.source;
174 } 203 }
175 } 204 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698