mirror of
https://github.com/flutter/flutter.git
synced 2025-06-03 00:51:18 +00:00

This patch makes `flutter start` work without a clone of the engine git repository. Making this work pulled a relatively large refactor of how the commands interact with application packages and devices. Now commands that want to interact with application packages or devices inherit from a common base class that holds stores of those objects as members. In production, the commands download and connect to devices based on the build configuration stored on the FlutterCommandRunner. In testing, these fields are used to mock out the real application package and devices.
57 lines
2.0 KiB
Dart
57 lines
2.0 KiB
Dart
// 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.
|
|
|
|
library stop_test;
|
|
|
|
import 'package:args/command_runner.dart';
|
|
import 'package:mockito/mockito.dart';
|
|
import 'package:sky_tools/src/commands/stop.dart';
|
|
import 'package:test/test.dart';
|
|
|
|
import 'src/mocks.dart';
|
|
|
|
main() => defineTests();
|
|
|
|
defineTests() {
|
|
group('stop', () {
|
|
test('returns 0 when Android is connected and ready to be stopped', () {
|
|
StopCommand command = new StopCommand();
|
|
applyMocksToCommand(command);
|
|
MockDeviceStore mockDevices = command.devices;
|
|
|
|
when(mockDevices.android.isConnected()).thenReturn(true);
|
|
when(mockDevices.android.stopApp(any)).thenReturn(true);
|
|
|
|
when(mockDevices.iOS.isConnected()).thenReturn(false);
|
|
when(mockDevices.iOS.stopApp(any)).thenReturn(false);
|
|
|
|
when(mockDevices.iOSSimulator.isConnected()).thenReturn(false);
|
|
when(mockDevices.iOSSimulator.stopApp(any)).thenReturn(false);
|
|
|
|
CommandRunner runner = new CommandRunner('test_flutter', '')
|
|
..addCommand(command);
|
|
runner.run(['stop']).then((int code) => expect(code, equals(0)));
|
|
});
|
|
|
|
test('returns 0 when iOS is connected and ready to be stopped', () {
|
|
StopCommand command = new StopCommand();
|
|
applyMocksToCommand(command);
|
|
MockDeviceStore mockDevices = command.devices;
|
|
|
|
when(mockDevices.android.isConnected()).thenReturn(false);
|
|
when(mockDevices.android.stopApp(any)).thenReturn(false);
|
|
|
|
when(mockDevices.iOS.isConnected()).thenReturn(true);
|
|
when(mockDevices.iOS.stopApp(any)).thenReturn(true);
|
|
|
|
when(mockDevices.iOSSimulator.isConnected()).thenReturn(false);
|
|
when(mockDevices.iOSSimulator.stopApp(any)).thenReturn(false);
|
|
|
|
CommandRunner runner = new CommandRunner('test_flutter', '')
|
|
..addCommand(command);
|
|
runner.run(['stop']).then((int code) => expect(code, equals(0)));
|
|
});
|
|
});
|
|
}
|