forked from firka/flutter
start a daemon command
wrap up first daemon implementation
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
// found in the LICENSE file.
|
||||
|
||||
import 'android_device_test.dart' as android_device_test;
|
||||
import 'daemon_test.dart' as daemon_test;
|
||||
import 'init_test.dart' as init_test;
|
||||
import 'install_test.dart' as install_test;
|
||||
import 'listen_test.dart' as listen_test;
|
||||
@@ -15,6 +16,7 @@ import 'trace_test.dart' as trace_test;
|
||||
|
||||
main() {
|
||||
android_device_test.defineTests();
|
||||
daemon_test.defineTests();
|
||||
init_test.defineTests();
|
||||
install_test.defineTests();
|
||||
listen_test.defineTests();
|
||||
|
||||
80
packages/flutter_tools/test/daemon_test.dart
Normal file
80
packages/flutter_tools/test/daemon_test.dart
Normal file
@@ -0,0 +1,80 @@
|
||||
// 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 'dart:async';
|
||||
|
||||
import 'package:mockito/mockito.dart';
|
||||
import 'package:sky_tools/src/commands/daemon.dart';
|
||||
import 'package:test/test.dart';
|
||||
|
||||
import 'src/mocks.dart';
|
||||
|
||||
main() => defineTests();
|
||||
|
||||
defineTests() {
|
||||
group('daemon', () {
|
||||
Daemon daemon;
|
||||
|
||||
tearDown(() {
|
||||
if (daemon != null)
|
||||
return daemon.shutdown();
|
||||
});
|
||||
|
||||
test('daemon.version', () async {
|
||||
StreamController<Map> commands = new StreamController();
|
||||
StreamController<Map> responses = new StreamController();
|
||||
daemon = new Daemon(
|
||||
commands.stream,
|
||||
(Map result) => responses.add(result)
|
||||
);
|
||||
commands.add({'id': 0, 'event': 'daemon.version'});
|
||||
Map response = await responses.stream.first;
|
||||
expect(response['id'], 0);
|
||||
expect(response['result'], isNotEmpty);
|
||||
expect(response['result'] is String, true);
|
||||
});
|
||||
|
||||
test('daemon.shutdown', () async {
|
||||
StreamController<Map> commands = new StreamController();
|
||||
StreamController<Map> responses = new StreamController();
|
||||
daemon = new Daemon(
|
||||
commands.stream,
|
||||
(Map result) => responses.add(result)
|
||||
);
|
||||
commands.add({'id': 0, 'event': 'daemon.shutdown'});
|
||||
return daemon.onExit.then((int code) {
|
||||
expect(code, 0);
|
||||
});
|
||||
});
|
||||
|
||||
test('daemon.stopAll', () async {
|
||||
DaemonCommand command = new DaemonCommand();
|
||||
applyMocksToCommand(command);
|
||||
|
||||
StreamController<Map> commands = new StreamController();
|
||||
StreamController<Map> responses = new StreamController();
|
||||
daemon = new Daemon(
|
||||
commands.stream,
|
||||
(Map result) => responses.add(result),
|
||||
daemonCommand: 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);
|
||||
|
||||
commands.add({'id': 0, 'event': 'app.stopAll'});
|
||||
Map response = await responses.stream.first;
|
||||
expect(response['id'], 0);
|
||||
expect(response['result'], true);
|
||||
});
|
||||
});
|
||||
}
|
||||
@@ -13,7 +13,7 @@ import 'package:test/test.dart';
|
||||
main() => defineTests();
|
||||
|
||||
defineTests() {
|
||||
group('', () {
|
||||
group('init', () {
|
||||
Directory temp;
|
||||
|
||||
setUp(() {
|
||||
@@ -28,7 +28,7 @@ defineTests() {
|
||||
// covered on the linux one.
|
||||
if (!Platform.isWindows) {
|
||||
// Verify that we create a project that is well-formed.
|
||||
test('init flutter-simple', () async {
|
||||
test('flutter-simple', () async {
|
||||
InitCommand command = new InitCommand();
|
||||
CommandRunner runner = new CommandRunner('test_flutter', '')
|
||||
..addCommand(command);
|
||||
|
||||
@@ -36,7 +36,6 @@ defineTests() {
|
||||
// Instead, cause the test to run the echo command.
|
||||
when(mockDevices.iOSSimulator.xcrunPath).thenReturn(mockCommand);
|
||||
|
||||
|
||||
CommandRunner runner = new CommandRunner('test_flutter', '')
|
||||
..addCommand(command);
|
||||
runner.run(['list']).then((int code) => expect(code, equals(0)));
|
||||
|
||||
Reference in New Issue
Block a user