Merge pull request #67 from iansf/ios_basics
Beginning implementation of IOSDevice. Implements list and install.
This commit is contained in:
@@ -2,6 +2,8 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
// This test can take a while due to network requests
|
||||
@Timeout(const Duration(seconds: 60))
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:args/command_runner.dart';
|
||||
@@ -27,7 +29,7 @@ defineTests() {
|
||||
test('init flutter-simple', () async {
|
||||
InitCommand command = new InitCommand();
|
||||
CommandRunner runner = new CommandRunner('test_flutter', '')
|
||||
..addCommand(command);
|
||||
..addCommand(command);
|
||||
await runner.run(['init', '--out', temp.path])
|
||||
.then((int code) => expect(code, equals(0)));
|
||||
|
||||
|
||||
@@ -6,7 +6,6 @@ library install_test;
|
||||
|
||||
import 'package:args/command_runner.dart';
|
||||
import 'package:mockito/mockito.dart';
|
||||
import 'package:sky_tools/src/application_package.dart';
|
||||
import 'package:sky_tools/src/install.dart';
|
||||
import 'package:test/test.dart';
|
||||
|
||||
@@ -17,19 +16,39 @@ main() => defineTests();
|
||||
defineTests() {
|
||||
group('install', () {
|
||||
test('returns 0 when Android is connected and ready for an install', () {
|
||||
ApplicationPackageFactory.srcPath = './';
|
||||
ApplicationPackageFactory.setBuildPath(
|
||||
BuildType.prebuilt, BuildPlatform.android, './');
|
||||
applicationPackageSetup();
|
||||
|
||||
MockAndroidDevice android = new MockAndroidDevice();
|
||||
when(android.isConnected()).thenReturn(true);
|
||||
when(android.installApp(any)).thenReturn(true);
|
||||
InstallCommand command = new InstallCommand(android);
|
||||
|
||||
MockIOSDevice ios = new MockIOSDevice();
|
||||
when(ios.isConnected()).thenReturn(false);
|
||||
when(ios.installApp(any)).thenReturn(false);
|
||||
|
||||
InstallCommand command = new InstallCommand(android: android, ios: ios);
|
||||
|
||||
CommandRunner runner = new CommandRunner('test_flutter', '')
|
||||
..addCommand(command);
|
||||
runner.run(['install'])
|
||||
.then((int code) => expect(code, equals(0)));
|
||||
..addCommand(command);
|
||||
runner.run(['install']).then((int code) => expect(code, equals(0)));
|
||||
});
|
||||
|
||||
test('returns 0 when iOS is connected and ready for an install', () {
|
||||
applicationPackageSetup();
|
||||
|
||||
MockAndroidDevice android = new MockAndroidDevice();
|
||||
when(android.isConnected()).thenReturn(false);
|
||||
when(android.installApp(any)).thenReturn(false);
|
||||
|
||||
MockIOSDevice ios = new MockIOSDevice();
|
||||
when(ios.isConnected()).thenReturn(true);
|
||||
when(ios.installApp(any)).thenReturn(true);
|
||||
|
||||
InstallCommand command = new InstallCommand(android: android, ios: ios);
|
||||
|
||||
CommandRunner runner = new CommandRunner('test_flutter', '')
|
||||
..addCommand(command);
|
||||
runner.run(['install']).then((int code) => expect(code, equals(0)));
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
@@ -16,12 +16,21 @@ main() => defineTests();
|
||||
defineTests() {
|
||||
group('list', () {
|
||||
test('returns 0 when called', () {
|
||||
applicationPackageSetup();
|
||||
|
||||
MockAndroidDevice android = new MockAndroidDevice();
|
||||
// Avoid relying on adb being installed on the test system.
|
||||
// Instead, cause the test to run the echo command.
|
||||
when(android.adbPath).thenReturn('echo');
|
||||
|
||||
ListCommand command = new ListCommand(android);
|
||||
MockIOSDevice ios = new MockIOSDevice();
|
||||
// Avoid relying on idevice* being installed on the test system.
|
||||
// Instead, cause the test to run the echo command.
|
||||
when(ios.informerPath).thenReturn('echo');
|
||||
when(ios.installerPath).thenReturn('echo');
|
||||
when(ios.listerPath).thenReturn('echo');
|
||||
|
||||
ListCommand command = new ListCommand(android: android, ios: ios);
|
||||
CommandRunner runner = new CommandRunner('test_flutter', '')
|
||||
..addCommand(command);
|
||||
runner.run(['list']).then((int code) => expect(code, equals(0)));
|
||||
|
||||
@@ -6,7 +6,6 @@ library stop_test;
|
||||
|
||||
import 'package:args/command_runner.dart';
|
||||
import 'package:mockito/mockito.dart';
|
||||
import 'package:sky_tools/src/application_package.dart';
|
||||
import 'package:sky_tools/src/listen.dart';
|
||||
import 'package:test/test.dart';
|
||||
|
||||
@@ -17,9 +16,7 @@ main() => defineTests();
|
||||
defineTests() {
|
||||
group('listen', () {
|
||||
test('returns 0 when no device is connected', () {
|
||||
ApplicationPackageFactory.srcPath = './';
|
||||
ApplicationPackageFactory.setBuildPath(
|
||||
BuildType.prebuilt, BuildPlatform.android, './');
|
||||
applicationPackageSetup();
|
||||
|
||||
MockAndroidDevice android = new MockAndroidDevice();
|
||||
when(android.isConnected()).thenReturn(false);
|
||||
|
||||
@@ -6,7 +6,6 @@ library stop_test;
|
||||
|
||||
import 'package:args/command_runner.dart';
|
||||
import 'package:mockito/mockito.dart';
|
||||
import 'package:sky_tools/src/application_package.dart';
|
||||
import 'package:sky_tools/src/logs.dart';
|
||||
import 'package:test/test.dart';
|
||||
|
||||
@@ -17,9 +16,7 @@ main() => defineTests();
|
||||
defineTests() {
|
||||
group('logs', () {
|
||||
test('returns 0 when no device is connected', () {
|
||||
ApplicationPackageFactory.srcPath = './';
|
||||
ApplicationPackageFactory.setBuildPath(
|
||||
BuildType.prebuilt, BuildPlatform.android, './');
|
||||
applicationPackageSetup();
|
||||
|
||||
MockAndroidDevice android = new MockAndroidDevice();
|
||||
when(android.isConnected()).thenReturn(false);
|
||||
|
||||
@@ -3,9 +3,23 @@
|
||||
// found in the LICENSE file.
|
||||
|
||||
import 'package:mockito/mockito.dart';
|
||||
import 'package:sky_tools/src/application_package.dart';
|
||||
import 'package:sky_tools/src/device.dart';
|
||||
|
||||
class MockAndroidDevice extends Mock implements AndroidDevice {
|
||||
@override
|
||||
dynamic noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation);
|
||||
}
|
||||
|
||||
class MockIOSDevice extends Mock implements IOSDevice {
|
||||
@override
|
||||
dynamic noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation);
|
||||
}
|
||||
|
||||
void applicationPackageSetup() {
|
||||
ApplicationPackageFactory.srcPath = './';
|
||||
ApplicationPackageFactory.setBuildPath(
|
||||
BuildType.prebuilt, BuildPlatform.android, './');
|
||||
ApplicationPackageFactory.setBuildPath(
|
||||
BuildType.prebuilt, BuildPlatform.iOS, './');
|
||||
}
|
||||
|
||||
@@ -6,7 +6,6 @@ library start_test;
|
||||
|
||||
import 'package:args/command_runner.dart';
|
||||
import 'package:mockito/mockito.dart';
|
||||
import 'package:sky_tools/src/application_package.dart';
|
||||
import 'package:sky_tools/src/start.dart';
|
||||
import 'package:test/test.dart';
|
||||
|
||||
@@ -17,15 +16,18 @@ main() => defineTests();
|
||||
defineTests() {
|
||||
group('start', () {
|
||||
test('returns 0 when Android is connected and ready to be started', () {
|
||||
ApplicationPackageFactory.srcPath = './';
|
||||
ApplicationPackageFactory.setBuildPath(
|
||||
BuildType.prebuilt, BuildPlatform.android, './');
|
||||
applicationPackageSetup();
|
||||
|
||||
MockAndroidDevice android = new MockAndroidDevice();
|
||||
when(android.isConnected()).thenReturn(true);
|
||||
when(android.installApp(any)).thenReturn(true);
|
||||
when(android.stop(any)).thenReturn(true);
|
||||
StartCommand command = new StartCommand(android);
|
||||
|
||||
MockIOSDevice ios = new MockIOSDevice();
|
||||
when(ios.isConnected()).thenReturn(false);
|
||||
when(ios.installApp(any)).thenReturn(false);
|
||||
|
||||
StartCommand command = new StartCommand(android: android, ios: ios);
|
||||
|
||||
CommandRunner runner = new CommandRunner('test_flutter', '')
|
||||
..addCommand(command);
|
||||
|
||||
@@ -6,7 +6,6 @@ library stop_test;
|
||||
|
||||
import 'package:args/command_runner.dart';
|
||||
import 'package:mockito/mockito.dart';
|
||||
import 'package:sky_tools/src/application_package.dart';
|
||||
import 'package:sky_tools/src/stop.dart';
|
||||
import 'package:test/test.dart';
|
||||
|
||||
@@ -17,9 +16,7 @@ main() => defineTests();
|
||||
defineTests() {
|
||||
group('stop', () {
|
||||
test('returns 0 when Android is connected and ready to be stopped', () {
|
||||
ApplicationPackageFactory.srcPath = './';
|
||||
ApplicationPackageFactory.setBuildPath(
|
||||
BuildType.prebuilt, BuildPlatform.android, './');
|
||||
applicationPackageSetup();
|
||||
|
||||
MockAndroidDevice android = new MockAndroidDevice();
|
||||
when(android.isConnected()).thenReturn(true);
|
||||
|
||||
@@ -6,7 +6,6 @@ library trace_test;
|
||||
|
||||
import 'package:args/command_runner.dart';
|
||||
import 'package:mockito/mockito.dart';
|
||||
import 'package:sky_tools/src/application_package.dart';
|
||||
import 'package:sky_tools/src/trace.dart';
|
||||
import 'package:test/test.dart';
|
||||
|
||||
@@ -17,9 +16,7 @@ main() => defineTests();
|
||||
defineTests() {
|
||||
group('trace', () {
|
||||
test('returns 1 when no Android device is connected', () {
|
||||
ApplicationPackageFactory.srcPath = './';
|
||||
ApplicationPackageFactory.setBuildPath(
|
||||
BuildType.prebuilt, BuildPlatform.android, './');
|
||||
applicationPackageSetup();
|
||||
|
||||
MockAndroidDevice android = new MockAndroidDevice();
|
||||
when(android.isConnected()).thenReturn(false);
|
||||
|
||||
Reference in New Issue
Block a user