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

Side by Side Diff: pkg/analysis_server/test/mocks.dart

Issue 532333002: Merge analysis server's mocks.dart and mocks2.dart into one file. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 3 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
« no previous file with comments | « pkg/analysis_server/test/computer/error_test.dart ('k') | pkg/analysis_server/test/mocks2.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 mocks; 5 library mocks;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 import 'dart:io'; 8 import 'dart:io';
9 9
10 @MirrorsUsed(targets: 'mocks', override: '*') 10 @MirrorsUsed(targets: 'mocks', override: '*')
11 import 'dart:mirrors'; 11 import 'dart:mirrors';
12 12
13 import 'package:analysis_server/src/services/index/index.dart'; 13 import 'package:analysis_server/src/services/index/index.dart';
14 import 'package:analyzer/file_system/file_system.dart' as resource; 14 import 'package:analyzer/file_system/file_system.dart' as resource;
15 import 'package:analyzer/file_system/memory_file_system.dart' as resource; 15 import 'package:analyzer/file_system/memory_file_system.dart' as resource;
16 import 'package:analysis_server/src/analysis_server.dart'; 16 import 'package:analysis_server/src/analysis_server.dart';
17 import 'package:analysis_server/src/channel.dart'; 17 import 'package:analysis_server/src/channel.dart';
18 import 'package:analysis_server/src/operation/operation_analysis.dart'; 18 import 'package:analysis_server/src/operation/operation_analysis.dart';
19 import 'package:analysis_server/src/operation/operation.dart'; 19 import 'package:analysis_server/src/operation/operation.dart';
20 import 'package:analysis_server/src/package_map_provider.dart'; 20 import 'package:analysis_server/src/package_map_provider.dart';
21 import 'package:analysis_server/src/protocol.dart'; 21 import 'package:analysis_server/src/protocol.dart' hide Element, ElementKind;
22 import 'package:analyzer/src/generated/element.dart';
22 import 'package:analyzer/src/generated/engine.dart'; 23 import 'package:analyzer/src/generated/engine.dart';
23 import 'package:analyzer/src/generated/source.dart'; 24 import 'package:analyzer/src/generated/source.dart';
24 import 'package:matcher/matcher.dart'; 25 import 'package:matcher/matcher.dart';
25 import 'package:mock/mock.dart'; 26 import 'package:typed_mock/typed_mock.dart';
26 import 'package:unittest/unittest.dart'; 27 import 'package:unittest/unittest.dart';
27 28
28 /** 29 /**
29 * Answer the absolute path the the SDK relative to the currently running 30 * Answer the absolute path the the SDK relative to the currently running
30 * script or throw an exception if it cannot be found. 31 * script or throw an exception if it cannot be found.
31 */ 32 */
32 String get sdkPath { 33 String get sdkPath {
33 Uri sdkUri = Platform.script.resolve('../../../sdk/'); 34 Uri sdkUri = Platform.script.resolve('../../../sdk/');
34 35
35 // Verify the directory exists 36 // Verify the directory exists
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
197 // return response.id == id; 198 // return response.id == id;
198 // }); 199 // });
199 } 200 }
200 201
201 @override 202 @override
202 void close() { 203 void close() {
203 _closed = true; 204 _closed = true;
204 } 205 }
205 } 206 }
206 207
207 /**
208 * A mock [AnalysisContext] for testing [AnalysisServer].
209 */
210 class MockAnalysisContext extends Mock implements AnalysisContext {
211 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation);
212 }
213
214 /**
215 * A mock [Source]. Particularly useful when all that is needed is the
216 * encoding.
217 */
218 class MockSource extends Mock implements Source {
219 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation);
220 }
221
222 typedef void MockServerOperationPerformFunction(AnalysisServer server); 208 typedef void MockServerOperationPerformFunction(AnalysisServer server);
223 209
224 /** 210 /**
225 * A mock [ServerOperation] for testing [AnalysisServer]. 211 * A mock [ServerOperation] for testing [AnalysisServer].
226 */ 212 */
227 class MockServerOperation implements PerformAnalysisOperation { 213 class MockServerOperation implements PerformAnalysisOperation {
228 final ServerOperationPriority priority; 214 final ServerOperationPriority priority;
229 final MockServerOperationPerformFunction _perform; 215 final MockServerOperationPerformFunction _perform;
230 216
231 MockServerOperation(this.priority, this._perform); 217 MockServerOperation(this.priority, this._perform);
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
355 Set<String> dependencies = new Set<String>(); 341 Set<String> dependencies = new Set<String>();
356 342
357 @override 343 @override
358 PackageMapInfo computePackageMap(resource.Folder folder) { 344 PackageMapInfo computePackageMap(resource.Folder folder) {
359 if (packageMaps != null) { 345 if (packageMaps != null) {
360 return new PackageMapInfo(packageMaps[folder.path], dependencies); 346 return new PackageMapInfo(packageMaps[folder.path], dependencies);
361 } 347 }
362 return new PackageMapInfo(packageMap, dependencies); 348 return new PackageMapInfo(packageMap, dependencies);
363 } 349 }
364 } 350 }
351
352
353 class MockAnalysisContext extends StringTypedMock implements AnalysisContext {
354 MockAnalysisContext(String name) : super(name);
355 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation);
356 }
357
358
359 class MockClassElement extends TypedMock implements ClassElement {
360 final ElementKind kind = ElementKind.CLASS;
361 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation);
362 }
363
364
365 class MockCompilationUnitElement extends TypedMock implements
366 CompilationUnitElement {
367 final ElementKind kind = ElementKind.COMPILATION_UNIT;
368 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation);
369 }
370
371
372 class MockConstructorElement extends TypedMock implements ConstructorElement {
373 final kind = ElementKind.CONSTRUCTOR;
374 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation);
375 }
376
377
378 class MockElement extends StringTypedMock implements Element {
379 MockElement([String name = '<element>']) : super(name);
380
381 @override
382 String get displayName => _toString;
383
384 @override
385 String get name => _toString;
386
387 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation);
388 }
389
390
391 class MockFieldElement extends TypedMock implements FieldElement {
392 final ElementKind kind = ElementKind.FIELD;
393 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation);
394 }
395
396
397 class MockFunctionElement extends TypedMock implements FunctionElement {
398 final ElementKind kind = ElementKind.FUNCTION;
399 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation);
400 }
401
402
403 class MockFunctionTypeAliasElement extends TypedMock implements
404 FunctionTypeAliasElement {
405 final ElementKind kind = ElementKind.FUNCTION_TYPE_ALIAS;
406 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation);
407 }
408
409
410 class MockHtmlElement extends TypedMock implements HtmlElement {
411 final ElementKind kind = ElementKind.HTML;
412 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation);
413 }
414
415
416 class MockImportElement extends TypedMock implements ImportElement {
417 final ElementKind kind = ElementKind.IMPORT;
418 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation);
419 }
420
421
422 class MockLibraryElement extends TypedMock implements LibraryElement {
423 final ElementKind kind = ElementKind.LIBRARY;
424 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation);
425 }
426
427
428 class MockLocalVariableElement extends TypedMock implements LocalVariableElement
429 {
430 final ElementKind kind = ElementKind.LOCAL_VARIABLE;
431 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation);
432 }
433
434
435 class MockLogger extends TypedMock implements Logger {
436 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation);
437 }
438
439
440 class MockMethodElement extends StringTypedMock implements MethodElement {
441 final kind = ElementKind.METHOD;
442 MockMethodElement([String name = 'method']) : super(name);
443 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation);
444 }
445
446
447 class MockParameterElement extends TypedMock implements ParameterElement {
448 final ElementKind kind = ElementKind.PARAMETER;
449 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation);
450 }
451
452
453 class MockPropertyAccessorElement extends TypedMock implements
454 PropertyAccessorElement {
455 final ElementKind kind;
456 MockPropertyAccessorElement(this.kind);
457 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation);
458 }
459
460
461 class MockSource extends StringTypedMock implements Source {
462 MockSource([String name = 'mocked.dart']) : super(name);
463 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation);
464 }
465
466
467 class MockTopLevelVariableElement extends TypedMock implements
468 TopLevelVariableElement {
469 final ElementKind kind = ElementKind.TOP_LEVEL_VARIABLE;
470 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation);
471 }
472
473
474 class MockTypeParameterElement extends TypedMock implements TypeParameterElement
475 {
476 final ElementKind kind = ElementKind.TYPE_PARAMETER;
477 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation);
478 }
479
480
481 class StringTypedMock extends TypedMock {
482 String _toString;
483
484 StringTypedMock(this._toString);
485
486 @override
487 String toString() {
488 if (_toString != null) {
489 return _toString;
490 }
491 return super.toString();
492 }
493 }
OLDNEW
« no previous file with comments | « pkg/analysis_server/test/computer/error_test.dart ('k') | pkg/analysis_server/test/mocks2.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698