Chromium Code Reviews| 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 mocks; | 5 library mocks; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 import 'dart:io'; | 8 import 'dart:io'; |
| 9 import 'dart:mirrors'; | 9 import 'dart:mirrors'; |
| 10 | 10 |
| 11 import 'package:analyzer/src/generated/engine.dart'; | 11 import 'package:analyzer/src/generated/engine.dart'; |
| 12 import 'package:analyzer/src/generated/source.dart'; | |
| 12 import 'package:analysis_server/src/analysis_logger.dart'; | 13 import 'package:analysis_server/src/analysis_logger.dart'; |
| 13 import 'package:analysis_server/src/analysis_server.dart'; | 14 import 'package:analysis_server/src/analysis_server.dart'; |
| 14 import 'package:analysis_server/src/channel.dart'; | 15 import 'package:analysis_server/src/channel.dart'; |
| 15 import 'package:analysis_server/src/protocol.dart'; | 16 import 'package:analysis_server/src/protocol.dart'; |
| 16 import 'package:matcher/matcher.dart'; | 17 import 'package:matcher/matcher.dart'; |
| 18 import 'package:mock/mock.dart'; | |
| 17 import 'package:unittest/unittest.dart'; | 19 import 'package:unittest/unittest.dart'; |
| 18 | 20 |
| 19 /** | 21 /** |
| 20 * Answer the absolute path the the SDK relative to the currently running | 22 * Answer the absolute path the the SDK relative to the currently running |
| 21 * script or throw an exception if it cannot be found. | 23 * script or throw an exception if it cannot be found. |
| 22 */ | 24 */ |
| 23 String get sdkPath { | 25 String get sdkPath { |
| 24 Uri sdkUri = Platform.script.resolve('../../../sdk/'); | 26 Uri sdkUri = Platform.script.resolve('../../../sdk/'); |
| 25 | 27 |
| 26 // Verify the directory exists | 28 // Verify the directory exists |
| (...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 175 _unexpected('MockAnalysisLogger.logError'); | 177 _unexpected('MockAnalysisLogger.logError'); |
| 176 } | 178 } |
| 177 | 179 |
| 178 noSuchMethod(Invocation invocation) { | 180 noSuchMethod(Invocation invocation) { |
| 179 var name = MirrorSystem.getName(invocation.memberName); | 181 var name = MirrorSystem.getName(invocation.memberName); |
| 180 return _unexpected("MockAnalysisLogger.$name"); | 182 return _unexpected("MockAnalysisLogger.$name"); |
| 181 } | 183 } |
| 182 } | 184 } |
| 183 | 185 |
| 184 /** | 186 /** |
| 185 * A mock [AnalysisContext] for testing [AnalysisServer]. This class raises an | 187 * A mock [AnalysisContext] for testing [AnalysisServer]. |
| 186 * exception for every abstract method in [AnalysisContext]. Tests should | |
| 187 * derive from this and re-implement the methods they need. | |
| 188 */ | 188 */ |
| 189 @proxy | 189 @proxy |
|
scheglov
2014/04/24 05:56:25
Why do we need @proxy here?
Paul Berry
2014/04/24 15:05:26
My mistake. I've removed it.
| |
| 190 class MockAnalysisContext extends AnalysisContext { | 190 class MockAnalysisContext extends Mock implements AnalysisContext { |
| 191 noSuchMethod(Invocation invocation) { | 191 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation); |
| 192 var name = MirrorSystem.getName(invocation.memberName); | |
| 193 return _unexpected("MockAnalysisContext.$name"); | |
| 194 } | |
| 195 } | 192 } |
| 193 | |
| 194 /** | |
| 195 * A mock [Source]. Particularly useful when all that is needed is the | |
| 196 * encoding. | |
| 197 */ | |
| 198 class MockSource extends Mock implements Source { | |
| 199 noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation); | |
| 200 } | |
| OLD | NEW |