2015-09-11 22:00:02 +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.
|
|
|
|
|
2015-11-10 21:18:34 +00:00
|
|
|
import 'package:flutter_tools/src/commands/install.dart';
|
2017-03-10 21:53:22 +00:00
|
|
|
import 'package:mockito/mockito.dart';
|
2015-09-11 22:00:02 +00:00
|
|
|
|
2017-05-12 17:44:52 +00:00
|
|
|
import '../src/common.dart';
|
|
|
|
import '../src/context.dart';
|
|
|
|
import '../src/mocks.dart';
|
2015-09-11 23:12:27 +00:00
|
|
|
|
2016-03-10 01:43:14 +00:00
|
|
|
void main() {
|
2015-09-11 22:00:02 +00:00
|
|
|
group('install', () {
|
2016-11-14 19:21:30 +00:00
|
|
|
testUsingContext('returns 0 when Android is connected and ready for an install', () async {
|
2018-09-12 06:29:29 +00:00
|
|
|
final InstallCommand command = InstallCommand();
|
2015-10-12 02:42:50 +00:00
|
|
|
applyMocksToCommand(command);
|
2015-09-19 00:11:30 +00:00
|
|
|
|
2018-09-12 06:29:29 +00:00
|
|
|
final MockAndroidDevice device = MockAndroidDevice();
|
2018-04-09 19:43:31 +00:00
|
|
|
when(device.isAppInstalled(any)).thenAnswer((_) async => false);
|
|
|
|
when(device.installApp(any)).thenAnswer((_) async => true);
|
2016-03-11 16:49:55 +00:00
|
|
|
testDeviceManager.addDevice(device);
|
2016-02-24 18:06:59 +00:00
|
|
|
|
2016-11-14 19:21:30 +00:00
|
|
|
await createTestCommandRunner(command).run(<String>['install']);
|
2015-10-02 15:34:09 +00:00
|
|
|
});
|
|
|
|
|
2016-11-14 19:21:30 +00:00
|
|
|
testUsingContext('returns 0 when iOS is connected and ready for an install', () async {
|
2018-09-12 06:29:29 +00:00
|
|
|
final InstallCommand command = InstallCommand();
|
2015-10-12 02:42:50 +00:00
|
|
|
applyMocksToCommand(command);
|
2015-09-16 19:33:11 +00:00
|
|
|
|
2018-09-12 06:29:29 +00:00
|
|
|
final MockIOSDevice device = MockIOSDevice();
|
2018-04-09 19:43:31 +00:00
|
|
|
when(device.isAppInstalled(any)).thenAnswer((_) async => false);
|
|
|
|
when(device.installApp(any)).thenAnswer((_) async => true);
|
2016-03-11 16:49:55 +00:00
|
|
|
testDeviceManager.addDevice(device);
|
2016-02-24 18:06:59 +00:00
|
|
|
|
2016-11-14 19:21:30 +00:00
|
|
|
await createTestCommandRunner(command).run(<String>['install']);
|
2015-09-11 22:00:02 +00:00
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|