logs_test.dart 1001 Bytes
Newer Older
1 2 3 4 5 6
// 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';
7
import 'package:flutter_tools/src/commands/logs.dart';
8 9
import 'package:test/test.dart';

10
import 'src/mocks.dart';
11 12 13 14 15 16

main() => defineTests();

defineTests() {
  group('logs', () {
    test('returns 0 when no device is connected', () {
17 18 19
      LogsCommand command = new LogsCommand();
      applyMocksToCommand(command);
      MockDeviceStore mockDevices = command.devices;
20

21 22 23
      when(mockDevices.android.isConnected()).thenReturn(false);
      when(mockDevices.iOS.isConnected()).thenReturn(false);
      when(mockDevices.iOSSimulator.isConnected()).thenReturn(false);
24 25 26 27 28 29 30

      CommandRunner runner = new CommandRunner('test_flutter', '')
        ..addCommand(command);
      runner.run(['logs']).then((int code) => expect(code, equals(0)));
    });
  });
}