Unnecessary new (#20138)
* enable lint unnecessary_new * fix tests * fix tests * fix tests
This commit is contained in:
committed by
GitHub
parent
d7a0dcaa4a
commit
d927c93310
@@ -56,7 +56,7 @@ Future<Null> main(List<String> args) async {
|
||||
// Scrolls down 300px.
|
||||
await driver.scroll(find.byType('Scaffold'), 0.0, -300.0,
|
||||
const Duration(milliseconds: 300));
|
||||
await new Future<Null>.delayed(const Duration(milliseconds: 500));
|
||||
await Future<Null>.delayed(const Duration(milliseconds: 500));
|
||||
// Scrolls up 300px.
|
||||
await driver.scroll(find.byType('Scaffold'), 300.0, 300.0,
|
||||
const Duration(milliseconds: 300));
|
||||
|
||||
@@ -72,7 +72,7 @@ class LogMessage {
|
||||
LogMessage(this.message, this.tag, this.level)
|
||||
: this.levelName =
|
||||
level.toString().substring(level.toString().indexOf('.') + 1),
|
||||
this.time = new DateTime.now();
|
||||
this.time = DateTime.now();
|
||||
|
||||
/// The actual log message.
|
||||
final String message;
|
||||
@@ -124,27 +124,27 @@ class Logger {
|
||||
///
|
||||
/// Severe messages are always logged, regardless of what level is set.
|
||||
void severe(String message) {
|
||||
loggingFunction(new LogMessage(message, tag, LoggingLevel.severe));
|
||||
loggingFunction(LogMessage(message, tag, LoggingLevel.severe));
|
||||
}
|
||||
|
||||
/// Logs a [LoggingLevel.warning] level `message`.
|
||||
void warning(String message) {
|
||||
if (globalLevel.index >= LoggingLevel.warning.index) {
|
||||
loggingFunction(new LogMessage(message, tag, LoggingLevel.warning));
|
||||
loggingFunction(LogMessage(message, tag, LoggingLevel.warning));
|
||||
}
|
||||
}
|
||||
|
||||
/// Logs a [LoggingLevel.info] level `message`.
|
||||
void info(String message) {
|
||||
if (globalLevel.index >= LoggingLevel.info.index) {
|
||||
loggingFunction(new LogMessage(message, tag, LoggingLevel.info));
|
||||
loggingFunction(LogMessage(message, tag, LoggingLevel.info));
|
||||
}
|
||||
}
|
||||
|
||||
/// Logs a [LoggingLevel.fine] level `message`.
|
||||
void fine(String message) {
|
||||
if (globalLevel.index >= LoggingLevel.fine.index) {
|
||||
loggingFunction(new LogMessage(message, tag, LoggingLevel.fine));
|
||||
loggingFunction(LogMessage(message, tag, LoggingLevel.fine));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@ import 'dart:core';
|
||||
/// Throws an [ArgumentError] if the address is neither.
|
||||
void validateAddress(String address) {
|
||||
if (!(isIpV4Address(address) || isIpV6Address(address))) {
|
||||
throw new ArgumentError(
|
||||
throw ArgumentError(
|
||||
'"$address" is neither a valid IPv4 nor IPv6 address');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@ const Duration _kReconnectAttemptInterval = Duration(seconds: 3);
|
||||
|
||||
const Duration _kRpcTimeout = Duration(seconds: 5);
|
||||
|
||||
final Logger _log = new Logger('DartVm');
|
||||
final Logger _log = Logger('DartVm');
|
||||
|
||||
/// Signature of an asynchronous function for astablishing a JSON RPC-2
|
||||
/// connection to a [Uri].
|
||||
@@ -32,7 +32,7 @@ RpcPeerConnectionFunction fuchsiaVmServiceConnectionFunction = _waitAndConnect;
|
||||
///
|
||||
/// Gives up after `_kConnectTimeout` has elapsed.
|
||||
Future<json_rpc.Peer> _waitAndConnect(Uri uri) async {
|
||||
final Stopwatch timer = new Stopwatch()..start();
|
||||
final Stopwatch timer = Stopwatch()..start();
|
||||
|
||||
Future<json_rpc.Peer> attemptConnection(Uri uri) async {
|
||||
WebSocket socket;
|
||||
@@ -40,7 +40,7 @@ Future<json_rpc.Peer> _waitAndConnect(Uri uri) async {
|
||||
try {
|
||||
socket =
|
||||
await WebSocket.connect(uri.toString()).timeout(_kConnectTimeout);
|
||||
peer = new json_rpc.Peer(new IOWebSocketChannel(socket).cast())..listen();
|
||||
peer = json_rpc.Peer(IOWebSocketChannel(socket).cast())..listen();
|
||||
return peer;
|
||||
} on HttpException catch (e) {
|
||||
// This is a fine warning as this most likely means the port is stale.
|
||||
@@ -55,7 +55,7 @@ Future<json_rpc.Peer> _waitAndConnect(Uri uri) async {
|
||||
await socket?.close();
|
||||
if (timer.elapsed < _kConnectTimeout) {
|
||||
_log.info('Attempting to reconnect');
|
||||
await new Future<Null>.delayed(_kReconnectAttemptInterval);
|
||||
await Future<Null>.delayed(_kReconnectAttemptInterval);
|
||||
return attemptConnection(uri);
|
||||
} else {
|
||||
_log.warning('Connection to Fuchsia\'s Dart VM timed out at '
|
||||
@@ -113,7 +113,7 @@ class DartVm {
|
||||
if (peer == null) {
|
||||
return null;
|
||||
}
|
||||
return new DartVm._(peer, uri);
|
||||
return DartVm._(peer, uri);
|
||||
}
|
||||
|
||||
/// Returns a [List] of [IsolateRef] objects whose name matches `pattern`.
|
||||
@@ -125,8 +125,8 @@ class DartVm {
|
||||
final List<IsolateRef> result = <IsolateRef>[];
|
||||
for (Map<String, dynamic> jsonIsolate in jsonVmRef['isolates']) {
|
||||
final String name = jsonIsolate['name'];
|
||||
if (name.contains(pattern) && name.contains(new RegExp(r':main\(\)'))) {
|
||||
result.add(new IsolateRef._fromJson(jsonIsolate, this));
|
||||
if (name.contains(pattern) && name.contains(RegExp(r':main\(\)'))) {
|
||||
result.add(IsolateRef._fromJson(jsonIsolate, this));
|
||||
}
|
||||
}
|
||||
return result;
|
||||
@@ -145,7 +145,7 @@ class DartVm {
|
||||
final Map<String, dynamic> result = await _peer
|
||||
.sendRequest(function, params ?? <String, dynamic>{})
|
||||
.timeout(timeout, onTimeout: () {
|
||||
throw new TimeoutException(
|
||||
throw TimeoutException(
|
||||
'Peer connection timed out during RPC call',
|
||||
timeout,
|
||||
);
|
||||
@@ -164,7 +164,7 @@ class DartVm {
|
||||
final Map<String, dynamic> rpcResponse =
|
||||
await invokeRpc('_flutter.listViews', timeout: _kRpcTimeout);
|
||||
for (Map<String, dynamic> jsonView in rpcResponse['views']) {
|
||||
final FlutterView flutterView = new FlutterView._fromJson(jsonView);
|
||||
final FlutterView flutterView = FlutterView._fromJson(jsonView);
|
||||
if (flutterView != null) {
|
||||
views.add(flutterView);
|
||||
}
|
||||
@@ -199,14 +199,14 @@ class FlutterView {
|
||||
if (isolate != null) {
|
||||
name = isolate['name'];
|
||||
if (name == null) {
|
||||
throw new RpcFormatError('Unable to find name for isolate "$isolate"');
|
||||
throw RpcFormatError('Unable to find name for isolate "$isolate"');
|
||||
}
|
||||
}
|
||||
if (id == null) {
|
||||
throw new RpcFormatError(
|
||||
throw RpcFormatError(
|
||||
'Unable to find view name for the following JSON structure "$json"');
|
||||
}
|
||||
return new FlutterView._(name, id);
|
||||
return FlutterView._(name, id);
|
||||
}
|
||||
|
||||
/// Determines the name of the isolate associated with this view. If there is
|
||||
@@ -240,20 +240,20 @@ class IsolateRef {
|
||||
final String name = json['name'];
|
||||
final String type = json['type'];
|
||||
if (type == null) {
|
||||
throw new RpcFormatError('Unable to find type within JSON "$json"');
|
||||
throw RpcFormatError('Unable to find type within JSON "$json"');
|
||||
}
|
||||
if (type != '@Isolate') {
|
||||
throw new RpcFormatError('Type "$type" does not match for IsolateRef');
|
||||
throw RpcFormatError('Type "$type" does not match for IsolateRef');
|
||||
}
|
||||
if (number == null) {
|
||||
throw new RpcFormatError(
|
||||
throw RpcFormatError(
|
||||
'Unable to find number for isolate ref within JSON "$json"');
|
||||
}
|
||||
if (name == null) {
|
||||
throw new RpcFormatError(
|
||||
throw RpcFormatError(
|
||||
'Unable to find name for isolate ref within JSON "$json"');
|
||||
}
|
||||
return new IsolateRef._(name, int.parse(number), dartVm);
|
||||
return IsolateRef._(name, int.parse(number), dartVm);
|
||||
}
|
||||
|
||||
/// The full name of this Isolate (not guaranteed to be unique).
|
||||
|
||||
@@ -23,7 +23,7 @@ const Duration _kIsolateFindTimeout = Duration(minutes: 1);
|
||||
|
||||
const Duration _kVmPollInterval = Duration(milliseconds: 1500);
|
||||
|
||||
final Logger _log = new Logger('FuchsiaRemoteConnection');
|
||||
final Logger _log = Logger('FuchsiaRemoteConnection');
|
||||
|
||||
/// A function for forwarding ports on the local machine to a remote device.
|
||||
///
|
||||
@@ -113,13 +113,13 @@ class FuchsiaRemoteConnection {
|
||||
final Map<int, PortForwarder> _dartVmPortMap = <int, PortForwarder>{};
|
||||
|
||||
/// Tracks stale ports so as not to reconnect while polling.
|
||||
final Set<int> _stalePorts = new Set<int>();
|
||||
final Set<int> _stalePorts = Set<int>();
|
||||
|
||||
/// A broadcast stream that emits events relating to Dart VM's as they update.
|
||||
Stream<DartVmEvent> get onDartVmEvent => _onDartVmEvent;
|
||||
Stream<DartVmEvent> _onDartVmEvent;
|
||||
final StreamController<DartVmEvent> _dartVmEventController =
|
||||
new StreamController<DartVmEvent>();
|
||||
StreamController<DartVmEvent>();
|
||||
|
||||
/// VM service cache to avoid repeating handshakes across function
|
||||
/// calls. Keys a forwarded port to a DartVm connection instance.
|
||||
@@ -130,7 +130,7 @@ class FuchsiaRemoteConnection {
|
||||
@visibleForTesting
|
||||
static Future<FuchsiaRemoteConnection> connectWithSshCommandRunner(
|
||||
SshCommandRunner commandRunner) async {
|
||||
final FuchsiaRemoteConnection connection = new FuchsiaRemoteConnection._(
|
||||
final FuchsiaRemoteConnection connection = FuchsiaRemoteConnection._(
|
||||
isIpV6Address(commandRunner.address), commandRunner);
|
||||
await connection._forwardLocalPortsToDeviceServicePorts();
|
||||
|
||||
@@ -138,7 +138,7 @@ class FuchsiaRemoteConnection {
|
||||
Future<Null> listen() async {
|
||||
while (connection._pollDartVms) {
|
||||
await connection._pollVms();
|
||||
await new Future<Null>.delayed(_kVmPollInterval);
|
||||
await Future<Null>.delayed(_kVmPollInterval);
|
||||
}
|
||||
connection._dartVmEventController.close();
|
||||
}
|
||||
@@ -193,7 +193,7 @@ class FuchsiaRemoteConnection {
|
||||
address ??= Platform.environment['FUCHSIA_DEVICE_URL'];
|
||||
sshConfigPath ??= Platform.environment['FUCHSIA_SSH_CONFIG'];
|
||||
if (address == null) {
|
||||
throw new FuchsiaRemoteConnectionError(
|
||||
throw FuchsiaRemoteConnectionError(
|
||||
'No address supplied, and \$FUCHSIA_DEVICE_URL not found.');
|
||||
}
|
||||
const String interfaceDelimiter = '%';
|
||||
@@ -205,7 +205,7 @@ class FuchsiaRemoteConnection {
|
||||
}
|
||||
|
||||
return await FuchsiaRemoteConnection.connectWithSshCommandRunner(
|
||||
new SshCommandRunner(
|
||||
SshCommandRunner(
|
||||
address: address,
|
||||
interface: interface,
|
||||
sshConfigPath: sshConfigPath,
|
||||
@@ -250,7 +250,7 @@ class FuchsiaRemoteConnection {
|
||||
Duration timeout = _kIsolateFindTimeout,
|
||||
]) async {
|
||||
final Completer<List<IsolateRef>> completer =
|
||||
new Completer<List<IsolateRef>>();
|
||||
Completer<List<IsolateRef>>();
|
||||
_onDartVmEvent.listen(
|
||||
(DartVmEvent event) async {
|
||||
if (event.eventType == DartVmEventType.started) {
|
||||
@@ -307,7 +307,7 @@ class FuchsiaRemoteConnection {
|
||||
.timeout(timeout)
|
||||
.then((List<List<IsolateRef>> listOfLists) {
|
||||
final List<List<IsolateRef>> mutableListOfLists =
|
||||
new List<List<IsolateRef>>.from(listOfLists)
|
||||
List<List<IsolateRef>>.from(listOfLists)
|
||||
..retainWhere((List<IsolateRef> list) => list.isNotEmpty);
|
||||
// Folds the list of lists into one flat list.
|
||||
return mutableListOfLists.fold<List<IsolateRef>>(
|
||||
@@ -351,7 +351,7 @@ class FuchsiaRemoteConnection {
|
||||
acc.addAll(element);
|
||||
return acc;
|
||||
});
|
||||
return new List<FlutterView>.unmodifiable(results);
|
||||
return List<FlutterView>.unmodifiable(results);
|
||||
}
|
||||
|
||||
// Calls all Dart VM's, returning a list of results.
|
||||
@@ -370,7 +370,7 @@ class FuchsiaRemoteConnection {
|
||||
await pf.stop();
|
||||
_stalePorts.add(pf.remotePort);
|
||||
if (queueEvents) {
|
||||
_dartVmEventController.add(new DartVmEvent._(
|
||||
_dartVmEventController.add(DartVmEvent._(
|
||||
eventType: DartVmEventType.stopped,
|
||||
servicePort: pf.remotePort,
|
||||
uri: _getDartVmUri(pf.port),
|
||||
@@ -431,7 +431,7 @@ class FuchsiaRemoteConnection {
|
||||
_sshCommandRunner.interface,
|
||||
_sshCommandRunner.sshConfigPath);
|
||||
|
||||
_dartVmEventController.add(new DartVmEvent._(
|
||||
_dartVmEventController.add(DartVmEvent._(
|
||||
eventType: DartVmEventType.started,
|
||||
servicePort: servicePort,
|
||||
uri: _getDartVmUri(_dartVmPortMap[servicePort].port),
|
||||
@@ -606,7 +606,7 @@ class _SshPortForwarder implements PortForwarder {
|
||||
if (processResult.exitCode != 0) {
|
||||
return null;
|
||||
}
|
||||
final _SshPortForwarder result = new _SshPortForwarder._(
|
||||
final _SshPortForwarder result = _SshPortForwarder._(
|
||||
address, remotePort, localSocket, interface, sshConfigPath, isIpV6);
|
||||
_log.fine('Set up forwarding from ${localSocket.port} '
|
||||
'to $address port $remotePort');
|
||||
|
||||
@@ -64,7 +64,7 @@ class SshCommandRunner {
|
||||
validateAddress(address);
|
||||
}
|
||||
|
||||
final Logger _log = new Logger('SshCommandRunner');
|
||||
final Logger _log = Logger('SshCommandRunner');
|
||||
|
||||
final ProcessManager _processManager;
|
||||
|
||||
@@ -98,7 +98,7 @@ class SshCommandRunner {
|
||||
_log.fine('Running command through SSH: ${args.join(' ')}');
|
||||
final ProcessResult result = await _processManager.run(args);
|
||||
if (result.exitCode != 0) {
|
||||
throw new SshCommandError(
|
||||
throw SshCommandError(
|
||||
'Command failed: $command\nstdout: ${result.stdout}\nstderr: ${result.stderr}');
|
||||
}
|
||||
_log.fine('SSH command stdout in brackets:[${result.stdout}]');
|
||||
|
||||
@@ -11,4 +11,4 @@ import 'package:test/test.dart' as test_package show TypeMatcher;
|
||||
export 'package:test/test.dart' hide TypeMatcher, isInstanceOf;
|
||||
|
||||
/// A matcher that compares the type of the actual value to the type argument T.
|
||||
Matcher isInstanceOf<T>() => new test_package.TypeMatcher<T>(); // ignore: prefer_const_constructors, https://github.com/dart-lang/sdk/issues/32544
|
||||
Matcher isInstanceOf<T>() => test_package.TypeMatcher<T>(); // ignore: prefer_const_constructors, https://github.com/dart-lang/sdk/issues/32544
|
||||
|
||||
@@ -19,10 +19,10 @@ void main() {
|
||||
List<Uri> uriConnections;
|
||||
|
||||
setUp(() {
|
||||
mockRunner = new MockSshCommandRunner();
|
||||
mockRunner = MockSshCommandRunner();
|
||||
// Adds some extra junk to make sure the strings will be cleaned up.
|
||||
when(mockRunner.run(any)).thenAnswer((_) =>
|
||||
new Future<List<String>>.value(
|
||||
Future<List<String>>.value(
|
||||
<String>['123\n\n\n', '456 ', '789']));
|
||||
const String address = 'fe80::8eae:4cff:fef4:9247';
|
||||
const String interface = 'eno1';
|
||||
@@ -33,8 +33,8 @@ void main() {
|
||||
Future<PortForwarder> mockPortForwardingFunction(
|
||||
String address, int remotePort,
|
||||
[String interface = '', String configFile]) {
|
||||
return new Future<PortForwarder>(() {
|
||||
final MockPortForwarder pf = new MockPortForwarder();
|
||||
return Future<PortForwarder>(() {
|
||||
final MockPortForwarder pf = MockPortForwarder();
|
||||
forwardedPorts.add(pf);
|
||||
when(pf.port).thenReturn(port++);
|
||||
when(pf.remotePort).thenReturn(remotePort);
|
||||
@@ -87,14 +87,14 @@ void main() {
|
||||
mockPeerConnections = <MockPeer>[];
|
||||
uriConnections = <Uri>[];
|
||||
Future<json_rpc.Peer> mockVmConnectionFunction(Uri uri) {
|
||||
return new Future<json_rpc.Peer>(() async {
|
||||
final MockPeer mp = new MockPeer();
|
||||
return Future<json_rpc.Peer>(() async {
|
||||
final MockPeer mp = MockPeer();
|
||||
mockPeerConnections.add(mp);
|
||||
uriConnections.add(uri);
|
||||
when(mp.sendRequest(any, any))
|
||||
// The local ports match the desired indices for now, so get the
|
||||
// canned response from the URI port.
|
||||
.thenAnswer((_) => new Future<Map<String, dynamic>>(
|
||||
.thenAnswer((_) => Future<Map<String, dynamic>>(
|
||||
() => flutterViewCannedResponses[uri.port]));
|
||||
return mp;
|
||||
});
|
||||
|
||||
@@ -18,7 +18,7 @@ void main() {
|
||||
|
||||
test('null connector', () async {
|
||||
Future<json_rpc.Peer> mockServiceFunction(Uri uri) {
|
||||
return new Future<json_rpc.Peer>(() => null);
|
||||
return Future<json_rpc.Peer>(() => null);
|
||||
}
|
||||
|
||||
fuchsiaVmServiceConnectionFunction = mockServiceFunction;
|
||||
@@ -27,9 +27,9 @@ void main() {
|
||||
});
|
||||
|
||||
test('disconnect closes peer', () async {
|
||||
final MockPeer peer = new MockPeer();
|
||||
final MockPeer peer = MockPeer();
|
||||
Future<json_rpc.Peer> mockServiceFunction(Uri uri) {
|
||||
return new Future<json_rpc.Peer>(() => peer);
|
||||
return Future<json_rpc.Peer>(() => peer);
|
||||
}
|
||||
|
||||
fuchsiaVmServiceConnectionFunction = mockServiceFunction;
|
||||
@@ -45,7 +45,7 @@ void main() {
|
||||
MockPeer mockPeer;
|
||||
|
||||
setUp(() {
|
||||
mockPeer = new MockPeer();
|
||||
mockPeer = MockPeer();
|
||||
});
|
||||
|
||||
tearDown(() {
|
||||
@@ -86,9 +86,9 @@ void main() {
|
||||
|
||||
Future<json_rpc.Peer> mockVmConnectionFunction(Uri uri) {
|
||||
when(mockPeer.sendRequest(any, any))
|
||||
.thenAnswer((_) => new Future<Map<String, dynamic>>(
|
||||
.thenAnswer((_) => Future<Map<String, dynamic>>(
|
||||
() => flutterViewCannedResponses));
|
||||
return new Future<json_rpc.Peer>(() => mockPeer);
|
||||
return Future<json_rpc.Peer>(() => mockPeer);
|
||||
}
|
||||
|
||||
fuchsiaVmServiceConnectionFunction = mockVmConnectionFunction;
|
||||
@@ -142,9 +142,9 @@ void main() {
|
||||
|
||||
Future<json_rpc.Peer> mockVmConnectionFunction(Uri uri) {
|
||||
when(mockPeer.sendRequest(any, any))
|
||||
.thenAnswer((_) => new Future<Map<String, dynamic>>(
|
||||
.thenAnswer((_) => Future<Map<String, dynamic>>(
|
||||
() => flutterViewCannedResponses));
|
||||
return new Future<json_rpc.Peer>(() => mockPeer);
|
||||
return Future<json_rpc.Peer>(() => mockPeer);
|
||||
}
|
||||
|
||||
fuchsiaVmServiceConnectionFunction = mockVmConnectionFunction;
|
||||
@@ -190,9 +190,9 @@ void main() {
|
||||
|
||||
Future<json_rpc.Peer> mockVmConnectionFunction(Uri uri) {
|
||||
when(mockPeer.sendRequest(any, any))
|
||||
.thenAnswer((_) => new Future<Map<String, dynamic>>(
|
||||
.thenAnswer((_) => Future<Map<String, dynamic>>(
|
||||
() => flutterViewCannedResponseMissingId));
|
||||
return new Future<json_rpc.Peer>(() => mockPeer);
|
||||
return Future<json_rpc.Peer>(() => mockPeer);
|
||||
}
|
||||
|
||||
fuchsiaVmServiceConnectionFunction = mockVmConnectionFunction;
|
||||
@@ -237,8 +237,8 @@ void main() {
|
||||
Future<json_rpc.Peer> mockVmConnectionFunction(Uri uri) {
|
||||
when(mockPeer.sendRequest(any, any))
|
||||
.thenAnswer((_) =>
|
||||
new Future<Map<String, dynamic>>(() => vmCannedResponse));
|
||||
return new Future<json_rpc.Peer>(() => mockPeer);
|
||||
Future<Map<String, dynamic>>(() => vmCannedResponse));
|
||||
return Future<json_rpc.Peer>(() => mockPeer);
|
||||
}
|
||||
|
||||
fuchsiaVmServiceConnectionFunction = mockVmConnectionFunction;
|
||||
@@ -270,9 +270,9 @@ void main() {
|
||||
|
||||
Future<json_rpc.Peer> mockVmConnectionFunction(Uri uri) {
|
||||
when(mockPeer.sendRequest(any, any))
|
||||
.thenAnswer((_) => new Future<Map<String, dynamic>>(
|
||||
.thenAnswer((_) => Future<Map<String, dynamic>>(
|
||||
() => flutterViewCannedResponseMissingIsolateName));
|
||||
return new Future<json_rpc.Peer>(() => mockPeer);
|
||||
return Future<json_rpc.Peer>(() => mockPeer);
|
||||
}
|
||||
|
||||
fuchsiaVmServiceConnectionFunction = mockVmConnectionFunction;
|
||||
@@ -292,7 +292,7 @@ void main() {
|
||||
MockPeer mockPeer;
|
||||
|
||||
setUp(() {
|
||||
mockPeer = new MockPeer();
|
||||
mockPeer = MockPeer();
|
||||
});
|
||||
|
||||
tearDown(() {
|
||||
@@ -304,8 +304,8 @@ void main() {
|
||||
Future<json_rpc.Peer> mockVmConnectionFunction(Uri uri) {
|
||||
// Return a command that will never complete.
|
||||
when(mockPeer.sendRequest(any, any))
|
||||
.thenAnswer((_) => new Completer<Map<String, dynamic>>().future);
|
||||
return new Future<json_rpc.Peer>(() => mockPeer);
|
||||
.thenAnswer((_) => Completer<Map<String, dynamic>>().future);
|
||||
return Future<json_rpc.Peer>(() => mockPeer);
|
||||
}
|
||||
|
||||
fuchsiaVmServiceConnectionFunction = mockVmConnectionFunction;
|
||||
|
||||
@@ -15,7 +15,7 @@ void main() {
|
||||
group('SshCommandRunner.constructors', () {
|
||||
test('throws exception with invalid address', () async {
|
||||
SshCommandRunner newCommandRunner() {
|
||||
return new SshCommandRunner(address: 'sillyaddress.what');
|
||||
return SshCommandRunner(address: 'sillyaddress.what');
|
||||
}
|
||||
|
||||
expect(newCommandRunner, throwsArgumentError);
|
||||
@@ -24,7 +24,7 @@ void main() {
|
||||
test('throws exception from injection constructor with invalid addr',
|
||||
() async {
|
||||
SshCommandRunner newCommandRunner() {
|
||||
return new SshCommandRunner.withProcessManager(
|
||||
return SshCommandRunner.withProcessManager(
|
||||
const LocalProcessManager(),
|
||||
address: '192.168.1.1.1');
|
||||
}
|
||||
@@ -39,16 +39,16 @@ void main() {
|
||||
SshCommandRunner runner;
|
||||
|
||||
setUp(() {
|
||||
mockProcessManager = new MockProcessManager();
|
||||
mockProcessResult = new MockProcessResult();
|
||||
mockProcessManager = MockProcessManager();
|
||||
mockProcessResult = MockProcessResult();
|
||||
when(mockProcessManager.run(any)).thenAnswer(
|
||||
(_) => new Future<MockProcessResult>.value(mockProcessResult));
|
||||
(_) => Future<MockProcessResult>.value(mockProcessResult));
|
||||
});
|
||||
|
||||
test('verify interface is appended to ipv6 address', () async {
|
||||
const String ipV6Addr = 'fe80::8eae:4cff:fef4:9247';
|
||||
const String interface = 'eno1';
|
||||
runner = new SshCommandRunner.withProcessManager(
|
||||
runner = SshCommandRunner.withProcessManager(
|
||||
mockProcessManager,
|
||||
address: ipV6Addr,
|
||||
interface: interface,
|
||||
@@ -65,7 +65,7 @@ void main() {
|
||||
test('verify no percentage symbol is added when no ipv6 interface',
|
||||
() async {
|
||||
const String ipV6Addr = 'fe80::8eae:4cff:fef4:9247';
|
||||
runner = new SshCommandRunner.withProcessManager(
|
||||
runner = SshCommandRunner.withProcessManager(
|
||||
mockProcessManager,
|
||||
address: ipV6Addr,
|
||||
);
|
||||
@@ -79,7 +79,7 @@ void main() {
|
||||
|
||||
test('verify commands are split into multiple lines', () async {
|
||||
const String addr = '192.168.1.1';
|
||||
runner = new SshCommandRunner.withProcessManager(mockProcessManager,
|
||||
runner = SshCommandRunner.withProcessManager(mockProcessManager,
|
||||
address: addr);
|
||||
when<String>(mockProcessResult.stdout).thenReturn('''this
|
||||
has
|
||||
@@ -92,7 +92,7 @@ void main() {
|
||||
|
||||
test('verify exception on nonzero process result exit code', () async {
|
||||
const String addr = '192.168.1.1';
|
||||
runner = new SshCommandRunner.withProcessManager(mockProcessManager,
|
||||
runner = SshCommandRunner.withProcessManager(mockProcessManager,
|
||||
address: addr);
|
||||
when<String>(mockProcessResult.stdout).thenReturn('whatever');
|
||||
when(mockProcessResult.exitCode).thenReturn(1);
|
||||
@@ -106,7 +106,7 @@ void main() {
|
||||
test('verify correct args with config', () async {
|
||||
const String addr = 'fe80::8eae:4cff:fef4:9247';
|
||||
const String config = '/this/that/this/and/uh';
|
||||
runner = new SshCommandRunner.withProcessManager(
|
||||
runner = SshCommandRunner.withProcessManager(
|
||||
mockProcessManager,
|
||||
address: addr,
|
||||
sshConfigPath: config,
|
||||
@@ -124,7 +124,7 @@ void main() {
|
||||
|
||||
test('verify config is excluded correctly', () async {
|
||||
const String addr = 'fe80::8eae:4cff:fef4:9247';
|
||||
runner = new SshCommandRunner.withProcessManager(
|
||||
runner = SshCommandRunner.withProcessManager(
|
||||
mockProcessManager,
|
||||
address: addr,
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user