Add listen command and basic test, and don’t do unnecessary repeated work when listening or poking the android server.

This commit is contained in:
Ian Fischer
2015-09-29 17:10:47 -07:00
parent 2bc289dec9
commit 00bed774ce
5 changed files with 172 additions and 15 deletions

View File

@@ -0,0 +1,34 @@
// 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/application_package.dart';
import 'package:sky_tools/src/listen.dart';
import 'package:test/test.dart';
import 'src/common.dart';
main() => defineTests();
defineTests() {
group('listen', () {
test('returns 0 when no device is connected', () {
ApplicationPackageFactory.srcPath = './';
ApplicationPackageFactory.setBuildPath(
BuildType.prebuilt, BuildPlatform.android, './');
MockAndroidDevice android = new MockAndroidDevice();
when(android.isConnected()).thenReturn(false);
ListenCommand command =
new ListenCommand(android: android, singleRun: true);
CommandRunner runner = new CommandRunner('test_flutter', '')
..addCommand(command);
runner.run(['listen']).then((int code) => expect(code, equals(0)));
});
});
}