2015-09-25 23:16:19 +00:00
|
|
|
// Copyright 2015 The Chromium Authors. All rights reserved.
|
|
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
|
|
// found in the LICENSE file.
|
|
|
|
|
|
|
|
import 'package:args/command_runner.dart';
|
2015-11-10 21:18:34 +00:00
|
|
|
import 'package:flutter_tools/src/commands/stop.dart';
|
2016-01-28 06:38:57 +00:00
|
|
|
import 'package:mockito/mockito.dart';
|
2015-09-25 23:16:19 +00:00
|
|
|
import 'package:test/test.dart';
|
|
|
|
|
2015-10-12 02:42:50 +00:00
|
|
|
import 'src/mocks.dart';
|
2015-09-25 23:16:19 +00:00
|
|
|
|
|
|
|
main() => defineTests();
|
|
|
|
|
|
|
|
defineTests() {
|
|
|
|
group('stop', () {
|
|
|
|
test('returns 0 when Android is connected and ready to be stopped', () {
|
2015-10-12 02:42:50 +00:00
|
|
|
StopCommand command = new StopCommand();
|
|
|
|
applyMocksToCommand(command);
|
|
|
|
MockDeviceStore mockDevices = command.devices;
|
2015-09-25 23:16:19 +00:00
|
|
|
|
2015-10-12 02:42:50 +00:00
|
|
|
when(mockDevices.android.isConnected()).thenReturn(true);
|
|
|
|
when(mockDevices.android.stopApp(any)).thenReturn(true);
|
2015-10-07 22:13:24 +00:00
|
|
|
|
2015-10-12 02:42:50 +00:00
|
|
|
when(mockDevices.iOS.isConnected()).thenReturn(false);
|
|
|
|
when(mockDevices.iOS.stopApp(any)).thenReturn(false);
|
2015-10-07 22:13:24 +00:00
|
|
|
|
2015-10-12 02:42:50 +00:00
|
|
|
when(mockDevices.iOSSimulator.isConnected()).thenReturn(false);
|
|
|
|
when(mockDevices.iOSSimulator.stopApp(any)).thenReturn(false);
|
2015-10-07 22:13:24 +00:00
|
|
|
|
|
|
|
CommandRunner runner = new CommandRunner('test_flutter', '')
|
|
|
|
..addCommand(command);
|
|
|
|
runner.run(['stop']).then((int code) => expect(code, equals(0)));
|
|
|
|
});
|
|
|
|
|
|
|
|
test('returns 0 when iOS is connected and ready to be stopped', () {
|
2015-10-12 02:42:50 +00:00
|
|
|
StopCommand command = new StopCommand();
|
|
|
|
applyMocksToCommand(command);
|
|
|
|
MockDeviceStore mockDevices = command.devices;
|
2015-10-07 22:13:24 +00:00
|
|
|
|
2015-10-12 02:42:50 +00:00
|
|
|
when(mockDevices.android.isConnected()).thenReturn(false);
|
|
|
|
when(mockDevices.android.stopApp(any)).thenReturn(false);
|
2015-10-07 22:13:24 +00:00
|
|
|
|
2015-10-12 02:42:50 +00:00
|
|
|
when(mockDevices.iOS.isConnected()).thenReturn(true);
|
|
|
|
when(mockDevices.iOS.stopApp(any)).thenReturn(true);
|
2015-10-10 01:37:21 +00:00
|
|
|
|
2015-10-12 02:42:50 +00:00
|
|
|
when(mockDevices.iOSSimulator.isConnected()).thenReturn(false);
|
|
|
|
when(mockDevices.iOSSimulator.stopApp(any)).thenReturn(false);
|
2015-09-25 23:16:19 +00:00
|
|
|
|
|
|
|
CommandRunner runner = new CommandRunner('test_flutter', '')
|
|
|
|
..addCommand(command);
|
|
|
|
runner.run(['stop']).then((int code) => expect(code, equals(0)));
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|