mocks.dart 2.07 KB
Newer Older
1 2 3 4
// 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.

5 6 7
import 'package:flutter_tools/src/application_package.dart';
import 'package:flutter_tools/src/build_configuration.dart';
import 'package:flutter_tools/src/device.dart';
8
import 'package:flutter_tools/src/runner/flutter_command.dart';
9
import 'package:flutter_tools/src/toolchain.dart';
10
import 'package:mockito/mockito.dart';
11 12 13 14 15 16 17 18

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'));
}

19 20 21 22 23 24 25 26 27
class MockCompiler extends Mock implements Compiler {
  @override
  dynamic noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation);
}

class MockToolchain extends Toolchain {
  MockToolchain() : super(compiler: new MockCompiler());
}

28
class MockAndroidDevice extends Mock implements AndroidDevice {
29
  TargetPlatform get platform => TargetPlatform.android;
30 31 32 33 34 35

  @override
  dynamic noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation);
}

class MockIOSDevice extends Mock implements IOSDevice {
36
  TargetPlatform get platform => TargetPlatform.iOS;
37 38 39 40 41 42

  @override
  dynamic noSuchMethod(Invocation invocation) => super.noSuchMethod(invocation);
}

class MockIOSSimulator extends Mock implements IOSSimulator {
43
  TargetPlatform get platform => TargetPlatform.iOSSimulator;
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58

  @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()
59
    ..toolchain = new MockToolchain()
60 61
    ..devices = new MockDeviceStore();
}