mirror of
https://github.com/flutter/flutter
synced 2024-10-13 11:42:54 +00:00
bdd20661d7
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.
31 lines
997 B
Dart
31 lines
997 B
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.
|
|
|
|
import 'package:args/command_runner.dart';
|
|
import 'package:mockito/mockito.dart';
|
|
import 'package:sky_tools/src/commands/logs.dart';
|
|
import 'package:test/test.dart';
|
|
|
|
import 'src/mocks.dart';
|
|
|
|
main() => defineTests();
|
|
|
|
defineTests() {
|
|
group('logs', () {
|
|
test('returns 0 when no device is connected', () {
|
|
LogsCommand command = new LogsCommand();
|
|
applyMocksToCommand(command);
|
|
MockDeviceStore mockDevices = command.devices;
|
|
|
|
when(mockDevices.android.isConnected()).thenReturn(false);
|
|
when(mockDevices.iOS.isConnected()).thenReturn(false);
|
|
when(mockDevices.iOSSimulator.isConnected()).thenReturn(false);
|
|
|
|
CommandRunner runner = new CommandRunner('test_flutter', '')
|
|
..addCommand(command);
|
|
runner.run(['logs']).then((int code) => expect(code, equals(0)));
|
|
});
|
|
});
|
|
}
|