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

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

Issue 2382033003: Revert "Remove unused option in server API" (Closed)
Patch Set: Created 4 years, 2 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
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 import 'package:analysis_server/plugin/protocol/protocol.dart' 10 import 'package:analysis_server/plugin/protocol/protocol.dart'
11 hide Element, ElementKind; 11 hide Element, ElementKind;
12 import 'package:analysis_server/src/analysis_server.dart'; 12 import 'package:analysis_server/src/analysis_server.dart';
13 import 'package:analysis_server/src/channel/channel.dart'; 13 import 'package:analysis_server/src/channel/channel.dart';
14 import 'package:analysis_server/src/operation/operation.dart'; 14 import 'package:analysis_server/src/operation/operation.dart';
15 import 'package:analysis_server/src/operation/operation_analysis.dart'; 15 import 'package:analysis_server/src/operation/operation_analysis.dart';
16 import 'package:analyzer/dart/element/element.dart'; 16 import 'package:analyzer/dart/element/element.dart';
17 import 'package:analyzer/file_system/file_system.dart' as resource;
18 import 'package:analyzer/file_system/memory_file_system.dart' as resource;
19 import 'package:analyzer/source/package_map_provider.dart';
20 import 'package:analyzer/source/pub_package_map_provider.dart';
17 import 'package:analyzer/src/generated/engine.dart'; 21 import 'package:analyzer/src/generated/engine.dart';
18 import 'package:analyzer/src/generated/source.dart'; 22 import 'package:analyzer/src/generated/source.dart';
19 import 'package:typed_mock/typed_mock.dart'; 23 import 'package:typed_mock/typed_mock.dart';
20 import 'package:unittest/unittest.dart'; 24 import 'package:unittest/unittest.dart';
21 25
22 /** 26 /**
23 * Answer the absolute path the SDK relative to the currently running 27 * Answer the absolute path the SDK relative to the currently running
24 * script or throw an exception if it cannot be found. 28 * script or throw an exception if it cannot be found.
25 */ 29 */
26 String get sdkPath { 30 String get sdkPath {
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 final ElementKind kind = ElementKind.LOCAL_VARIABLE; 121 final ElementKind kind = ElementKind.LOCAL_VARIABLE;
118 } 122 }
119 123
120 class MockLogger extends TypedMock implements Logger {} 124 class MockLogger extends TypedMock implements Logger {}
121 125
122 class MockMethodElement extends StringTypedMock implements MethodElement { 126 class MockMethodElement extends StringTypedMock implements MethodElement {
123 final kind = ElementKind.METHOD; 127 final kind = ElementKind.METHOD;
124 MockMethodElement([String name = 'method']) : super(name); 128 MockMethodElement([String name = 'method']) : super(name);
125 } 129 }
126 130
131 /**
132 * A mock [PackageMapProvider].
133 */
134 class MockPackageMapProvider implements PubPackageMapProvider {
135 /**
136 * Package map that will be returned by the next call to [computePackageMap].
137 */
138 Map<String, List<resource.Folder>> packageMap =
139 <String, List<resource.Folder>>{};
140
141 /**
142 * Package maps that will be returned by the next call to [computePackageMap].
143 */
144 Map<String, Map<String, List<resource.Folder>>> packageMaps = null;
145
146 /**
147 * Dependency list that will be returned by the next call to [computePackageMa p].
148 */
149 Set<String> dependencies = new Set<String>();
150
151 /**
152 * Number of times [computePackageMap] has been called.
153 */
154 int computeCount = 0;
155
156 @override
157 PackageMapInfo computePackageMap(resource.Folder folder) {
158 ++computeCount;
159 if (packageMaps != null) {
160 return new PackageMapInfo(packageMaps[folder.path], dependencies);
161 }
162 return new PackageMapInfo(packageMap, dependencies);
163 }
164
165 noSuchMethod(Invocation invocation) {
166 // No other methods should be called.
167 return super.noSuchMethod(invocation);
168 }
169 }
170
127 class MockParameterElement extends TypedMock implements ParameterElement { 171 class MockParameterElement extends TypedMock implements ParameterElement {
128 final ElementKind kind = ElementKind.PARAMETER; 172 final ElementKind kind = ElementKind.PARAMETER;
129 } 173 }
130 174
131 class MockPropertyAccessorElement extends TypedMock 175 class MockPropertyAccessorElement extends TypedMock
132 implements PropertyAccessorElement { 176 implements PropertyAccessorElement {
133 final ElementKind kind; 177 final ElementKind kind;
134 MockPropertyAccessorElement(this.kind); 178 MockPropertyAccessorElement(this.kind);
135 } 179 }
136 180
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after
387 } 431 }
388 return mismatchDescription; 432 return mismatchDescription;
389 } 433 }
390 434
391 @override 435 @override
392 bool matches(item, Map matchState) { 436 bool matches(item, Map matchState) {
393 Response response = item; 437 Response response = item;
394 return response != null && response.id == _id && response.error == null; 438 return response != null && response.id == _id && response.error == null;
395 } 439 }
396 } 440 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698