2015-09-25 23:16:19 +00:00
|
|
|
// 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.
|
|
|
|
|
2016-03-03 21:31:05 +00:00
|
|
|
import 'dart:async';
|
|
|
|
|
2017-03-10 17:39:01 +00:00
|
|
|
import 'package:flutter_tools/src/cache.dart';
|
2015-11-10 21:18:34 +00:00
|
|
|
import 'package:flutter_tools/src/commands/stop.dart';
|
2017-03-10 21:53:22 +00:00
|
|
|
import 'package:mockito/mockito.dart';
|
2015-09-25 23:16:19 +00:00
|
|
|
import 'package:test/test.dart';
|
|
|
|
|
2016-02-13 20:00:41 +00:00
|
|
|
import 'src/common.dart';
|
|
|
|
import 'src/context.dart';
|
2015-10-12 02:42:50 +00:00
|
|
|
import 'src/mocks.dart';
|
2015-09-25 23:16:19 +00:00
|
|
|
|
2016-03-10 01:43:14 +00:00
|
|
|
void main() {
|
2015-09-25 23:16:19 +00:00
|
|
|
group('stop', () {
|
2017-03-10 17:39:01 +00:00
|
|
|
setUpAll(() {
|
|
|
|
Cache.disableLocking();
|
|
|
|
});
|
|
|
|
|
2016-11-14 19:21:30 +00:00
|
|
|
testUsingContext('returns 0 when Android is connected and ready to be stopped', () async {
|
2017-03-04 01:50:46 +00:00
|
|
|
final StopCommand command = new StopCommand();
|
2015-10-12 02:42:50 +00:00
|
|
|
applyMocksToCommand(command);
|
2017-03-04 01:50:46 +00:00
|
|
|
final MockAndroidDevice device = new MockAndroidDevice();
|
2017-12-19 21:13:57 +00:00
|
|
|
when(device.stopApp(any)).thenAnswer((Invocation invocation) => new Future<bool>.value(true));
|
2016-03-03 21:31:05 +00:00
|
|
|
testDeviceManager.addDevice(device);
|
2016-11-14 19:21:30 +00:00
|
|
|
await createTestCommandRunner(command).run(<String>['stop']);
|
2015-10-07 22:13:24 +00:00
|
|
|
});
|
|
|
|
|
2016-11-14 19:21:30 +00:00
|
|
|
testUsingContext('returns 0 when iOS is connected and ready to be stopped', () async {
|
2017-03-04 01:50:46 +00:00
|
|
|
final StopCommand command = new StopCommand();
|
2015-10-12 02:42:50 +00:00
|
|
|
applyMocksToCommand(command);
|
2017-03-04 01:50:46 +00:00
|
|
|
final MockIOSDevice device = new MockIOSDevice();
|
2017-12-19 21:13:57 +00:00
|
|
|
when(device.stopApp(any)).thenAnswer((Invocation invocation) => new Future<bool>.value(true));
|
2016-03-03 21:31:05 +00:00
|
|
|
testDeviceManager.addDevice(device);
|
2015-09-25 23:16:19 +00:00
|
|
|
|
2016-11-14 19:21:30 +00:00
|
|
|
await createTestCommandRunner(command).run(<String>['stop']);
|
2015-09-25 23:16:19 +00:00
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|