Ian Fischer | fa59233 | 2015-09-25 16:16:19 -0700 | [diff] [blame] | 1 | // 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 Carew | 8283ce8 | 2016-03-03 13:31:05 -0800 | [diff] [blame] | 5 | import 'dart:async'; |
| 6 | |
Todd Volkert | 83d411f | 2017-03-10 09:39:01 -0800 | [diff] [blame] | 7 | import 'package:flutter_tools/src/cache.dart'; |
Adam Barth | da0a12c | 2015-11-10 13:18:34 -0800 | [diff] [blame] | 8 | import 'package:flutter_tools/src/commands/stop.dart'; |
Todd Volkert | 5d29737 | 2017-03-10 13:53:22 -0800 | [diff] [blame] | 9 | import 'package:mockito/mockito.dart'; |
Ian Fischer | fa59233 | 2015-09-25 16:16:19 -0700 | [diff] [blame] | 10 | |
Devon Carew | dcf0b7b | 2016-02-13 12:00:41 -0800 | [diff] [blame] | 11 | import 'src/common.dart'; |
| 12 | import 'src/context.dart'; |
Adam Barth | bdd2066 | 2015-10-11 19:42:50 -0700 | [diff] [blame] | 13 | import 'src/mocks.dart'; |
Ian Fischer | fa59233 | 2015-09-25 16:16:19 -0700 | [diff] [blame] | 14 | |
Hixie | c7339de | 2016-03-09 17:43:14 -0800 | [diff] [blame] | 15 | void main() { |
Ian Fischer | fa59233 | 2015-09-25 16:16:19 -0700 | [diff] [blame] | 16 | group('stop', () { |
Todd Volkert | 83d411f | 2017-03-10 09:39:01 -0800 | [diff] [blame] | 17 | setUpAll(() { |
| 18 | Cache.disableLocking(); |
| 19 | }); |
| 20 | |
Dan Rubel | 34e466f | 2016-11-14 14:21:30 -0500 | [diff] [blame] | 21 | testUsingContext('returns 0 when Android is connected and ready to be stopped', () async { |
Alexandre Ardhuin | d927c93 | 2018-09-12 08:29:29 +0200 | [diff] [blame] | 22 | final StopCommand command = StopCommand(); |
Adam Barth | bdd2066 | 2015-10-11 19:42:50 -0700 | [diff] [blame] | 23 | applyMocksToCommand(command); |
Alexandre Ardhuin | d927c93 | 2018-09-12 08:29:29 +0200 | [diff] [blame] | 24 | final MockAndroidDevice device = MockAndroidDevice(); |
| 25 | when(device.stopApp(any)).thenAnswer((Invocation invocation) => Future<bool>.value(true)); |
Devon Carew | 8283ce8 | 2016-03-03 13:31:05 -0800 | [diff] [blame] | 26 | testDeviceManager.addDevice(device); |
Dan Rubel | 34e466f | 2016-11-14 14:21:30 -0500 | [diff] [blame] | 27 | await createTestCommandRunner(command).run(<String>['stop']); |
Ian Fischer | 844678d | 2015-10-07 15:13:24 -0700 | [diff] [blame] | 28 | }); |
| 29 | |
Dan Rubel | 34e466f | 2016-11-14 14:21:30 -0500 | [diff] [blame] | 30 | testUsingContext('returns 0 when iOS is connected and ready to be stopped', () async { |
Alexandre Ardhuin | d927c93 | 2018-09-12 08:29:29 +0200 | [diff] [blame] | 31 | final StopCommand command = StopCommand(); |
Adam Barth | bdd2066 | 2015-10-11 19:42:50 -0700 | [diff] [blame] | 32 | applyMocksToCommand(command); |
Alexandre Ardhuin | d927c93 | 2018-09-12 08:29:29 +0200 | [diff] [blame] | 33 | final MockIOSDevice device = MockIOSDevice(); |
| 34 | when(device.stopApp(any)).thenAnswer((Invocation invocation) => Future<bool>.value(true)); |
Devon Carew | 8283ce8 | 2016-03-03 13:31:05 -0800 | [diff] [blame] | 35 | testDeviceManager.addDevice(device); |
Ian Fischer | fa59233 | 2015-09-25 16:16:19 -0700 | [diff] [blame] | 36 | |
Dan Rubel | 34e466f | 2016-11-14 14:21:30 -0500 | [diff] [blame] | 37 | await createTestCommandRunner(command).run(<String>['stop']); |
Ian Fischer | fa59233 | 2015-09-25 16:16:19 -0700 | [diff] [blame] | 38 | }); |
| 39 | }); |
| 40 | } |