stop_test.dart 1.35 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
import 'dart:async';

7
import 'package:flutter_tools/src/commands/stop.dart';
8
import 'package:mockito/mockito.dart';
9 10
import 'package:test/test.dart';

11 12
import 'src/common.dart';
import 'src/context.dart';
13
import 'src/mocks.dart';
14

15
void main() {
16
  group('stop', () {
17
    testUsingContext('returns 0 when Android is connected and ready to be stopped', () {
18 19
      StopCommand command = new StopCommand();
      applyMocksToCommand(command);
20
      MockAndroidDevice device = new MockAndroidDevice();
Ian Hickson's avatar
Ian Hickson committed
21
      when(device.stopApp(any)).thenReturn(new Future<bool>.value(true));
22
      testDeviceManager.addDevice(device);
23 24 25
      return createTestCommandRunner(command).run(['stop']).then((int code) {
        expect(code, equals(0));
      });
26 27
    });

28
    testUsingContext('returns 0 when iOS is connected and ready to be stopped', () {
29 30
      StopCommand command = new StopCommand();
      applyMocksToCommand(command);
31
      MockIOSDevice device = new MockIOSDevice();
Ian Hickson's avatar
Ian Hickson committed
32
      when(device.stopApp(any)).thenReturn(new Future<bool>.value(true));
33
      testDeviceManager.addDevice(device);
34

35 36 37
      return createTestCommandRunner(command).run(['stop']).then((int code) {
        expect(code, equals(0));
      });
38 39 40
    });
  });
}