blob: b30813d1ea35f602d4b9f5da63e03fe6cb590151 [file] [log] [blame]
Ian Fischerfa592332015-09-25 16:16:19 -07001// Copyright 2015 The Chromium Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
Devon Carew8283ce82016-03-03 13:31:05 -08005import 'dart:async';
6
Todd Volkert83d411f2017-03-10 09:39:01 -08007import 'package:flutter_tools/src/cache.dart';
Adam Barthda0a12c2015-11-10 13:18:34 -08008import 'package:flutter_tools/src/commands/stop.dart';
Todd Volkert5d297372017-03-10 13:53:22 -08009import 'package:mockito/mockito.dart';
Ian Fischerfa592332015-09-25 16:16:19 -070010
Devon Carewdcf0b7b2016-02-13 12:00:41 -080011import 'src/common.dart';
12import 'src/context.dart';
Adam Barthbdd20662015-10-11 19:42:50 -070013import 'src/mocks.dart';
Ian Fischerfa592332015-09-25 16:16:19 -070014
Hixiec7339de2016-03-09 17:43:14 -080015void main() {
Ian Fischerfa592332015-09-25 16:16:19 -070016 group('stop', () {
Todd Volkert83d411f2017-03-10 09:39:01 -080017 setUpAll(() {
18 Cache.disableLocking();
19 });
20
Dan Rubel34e466f2016-11-14 14:21:30 -050021 testUsingContext('returns 0 when Android is connected and ready to be stopped', () async {
Alexandre Ardhuind927c932018-09-12 08:29:29 +020022 final StopCommand command = StopCommand();
Adam Barthbdd20662015-10-11 19:42:50 -070023 applyMocksToCommand(command);
Alexandre Ardhuind927c932018-09-12 08:29:29 +020024 final MockAndroidDevice device = MockAndroidDevice();
25 when(device.stopApp(any)).thenAnswer((Invocation invocation) => Future<bool>.value(true));
Devon Carew8283ce82016-03-03 13:31:05 -080026 testDeviceManager.addDevice(device);
Dan Rubel34e466f2016-11-14 14:21:30 -050027 await createTestCommandRunner(command).run(<String>['stop']);
Ian Fischer844678d2015-10-07 15:13:24 -070028 });
29
Dan Rubel34e466f2016-11-14 14:21:30 -050030 testUsingContext('returns 0 when iOS is connected and ready to be stopped', () async {
Alexandre Ardhuind927c932018-09-12 08:29:29 +020031 final StopCommand command = StopCommand();
Adam Barthbdd20662015-10-11 19:42:50 -070032 applyMocksToCommand(command);
Alexandre Ardhuind927c932018-09-12 08:29:29 +020033 final MockIOSDevice device = MockIOSDevice();
34 when(device.stopApp(any)).thenAnswer((Invocation invocation) => Future<bool>.value(true));
Devon Carew8283ce82016-03-03 13:31:05 -080035 testDeviceManager.addDevice(device);
Ian Fischerfa592332015-09-25 16:16:19 -070036
Dan Rubel34e466f2016-11-14 14:21:30 -050037 await createTestCommandRunner(command).run(<String>['stop']);
Ian Fischerfa592332015-09-25 16:16:19 -070038 });
39 });
40}