Teach sky_tools about prebuilt artifacts
This patch makes `flutter start` work without a clone of the engine git repository. Making this work pulled a relatively large refactor of how the commands interact with application packages and devices. Now commands that want to interact with application packages or devices inherit from a common base class that holds stores of those objects as members. In production, the commands download and connect to devices based on the build configuration stored on the FlutterCommandRunner. In testing, these fields are used to mock out the real application package and devices.
This commit is contained in:
@@ -1,32 +0,0 @@
|
||||
// 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: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);
|
||||
}
|
||||
|
||||
class MockIOSSimulator extends Mock implements IOSSimulator {
|
||||
@override
|
||||
dynamic noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation);
|
||||
}
|
||||
|
||||
void applicationPackageSetup() {
|
||||
ApplicationPackageFactory.srcPath = './';
|
||||
ApplicationPackageFactory.setBuildPath(
|
||||
BuildType.prebuilt, BuildPlatform.android, './');
|
||||
ApplicationPackageFactory.setBuildPath(
|
||||
BuildType.prebuilt, BuildPlatform.iOS, './');
|
||||
ApplicationPackageFactory.setBuildPath(
|
||||
BuildType.prebuilt, BuildPlatform.iOSSimulator, './');
|
||||
}
|
||||
50
packages/flutter_tools/test/src/mocks.dart
Normal file
50
packages/flutter_tools/test/src/mocks.dart
Normal file
@@ -0,0 +1,50 @@
|
||||
// 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:mockito/mockito.dart';
|
||||
import 'package:sky_tools/src/application_package.dart';
|
||||
import 'package:sky_tools/src/build_configuration.dart';
|
||||
import 'package:sky_tools/src/commands/flutter_command.dart';
|
||||
import 'package:sky_tools/src/device.dart';
|
||||
|
||||
class MockApplicationPackageStore extends ApplicationPackageStore {
|
||||
MockApplicationPackageStore() : super(
|
||||
android: new AndroidApk(localPath: '/mock/path/to/android/SkyShell.apk'),
|
||||
iOS: new IOSApp(localPath: '/mock/path/to/iOS/SkyShell.app'),
|
||||
iOSSimulator: new IOSApp(localPath: '/mock/path/to/iOSSimulator/SkyShell.app'));
|
||||
}
|
||||
|
||||
class MockAndroidDevice extends Mock implements AndroidDevice {
|
||||
BuildPlatform get platform => BuildPlatform.android;
|
||||
|
||||
@override
|
||||
dynamic noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation);
|
||||
}
|
||||
|
||||
class MockIOSDevice extends Mock implements IOSDevice {
|
||||
BuildPlatform get platform => BuildPlatform.iOS;
|
||||
|
||||
@override
|
||||
dynamic noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation);
|
||||
}
|
||||
|
||||
class MockIOSSimulator extends Mock implements IOSSimulator {
|
||||
BuildPlatform get platform => BuildPlatform.iOSSimulator;
|
||||
|
||||
@override
|
||||
dynamic noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation);
|
||||
}
|
||||
|
||||
class MockDeviceStore extends DeviceStore {
|
||||
MockDeviceStore() : super(
|
||||
android: new MockAndroidDevice(),
|
||||
iOS: new MockIOSDevice(),
|
||||
iOSSimulator: new MockIOSSimulator());
|
||||
}
|
||||
|
||||
void applyMocksToCommand(FlutterCommand command) {
|
||||
command
|
||||
..applicationPackages = new MockApplicationPackageStore()
|
||||
..devices = new MockDeviceStore();
|
||||
}
|
||||
Reference in New Issue
Block a user