install_test.dart 1.43 KB
Newer Older
Ian Fischer's avatar
Ian Fischer committed
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
import 'package:flutter_tools/src/commands/install.dart';
6
import 'package:mockito/mockito.dart';
Ian Fischer's avatar
Ian Fischer committed
7 8
import 'package:test/test.dart';

9 10
import 'src/common.dart';
import 'src/context.dart';
11
import 'src/mocks.dart';
12

13
void main() {
Ian Fischer's avatar
Ian Fischer committed
14
  group('install', () {
15
    testUsingContext('returns 0 when Android is connected and ready for an install', () {
16 17
      InstallCommand command = new InstallCommand();
      applyMocksToCommand(command);
18

19 20 21 22
      MockAndroidDevice device = new MockAndroidDevice();
      when(device.isAppInstalled(any)).thenReturn(false);
      when(device.installApp(any)).thenReturn(true);
      testDeviceManager.addDevice(device);
23

24
      return createTestCommandRunner(command).run(<String>['install']).then((int code) {
25
        expect(code, 0);
26
      });
27 28
    });

29
    testUsingContext('returns 0 when iOS is connected and ready for an install', () {
30 31
      InstallCommand command = new InstallCommand();
      applyMocksToCommand(command);
32

33 34 35 36
      MockIOSDevice device = new MockIOSDevice();
      when(device.isAppInstalled(any)).thenReturn(false);
      when(device.installApp(any)).thenReturn(true);
      testDeviceManager.addDevice(device);
37

38
      return createTestCommandRunner(command).run(<String>['install']).then((int code) {
39
        expect(code, 0);
40
      });
Ian Fischer's avatar
Ian Fischer committed
41 42 43
    });
  });
}