list_test.dart 1.56 KB
Newer Older
1 2 3 4
// 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.

Devon Carew's avatar
Devon Carew committed
5 6
import 'dart:io';

7 8
import 'package:args/command_runner.dart';
import 'package:mockito/mockito.dart';
9
import 'package:flutter_tools/src/commands/list.dart';
10 11
import 'package:test/test.dart';

12
import 'src/mocks.dart';
13 14 15 16 17 18

main() => defineTests();

defineTests() {
  group('list', () {
    test('returns 0 when called', () {
Devon Carew's avatar
Devon Carew committed
19 20
      final String mockCommand = Platform.isWindows ? 'cmd /c echo' : 'echo';

21 22 23
      ListCommand command = new ListCommand();
      applyMocksToCommand(command);
      MockDeviceStore mockDevices = command.devices;
24

25 26
      // Avoid relying on adb being installed on the test system.
      // Instead, cause the test to run the echo command.
Devon Carew's avatar
Devon Carew committed
27
      when(mockDevices.android.adbPath).thenReturn(mockCommand);
28

29 30
      // Avoid relying on idevice* being installed on the test system.
      // Instead, cause the test to run the echo command.
Devon Carew's avatar
Devon Carew committed
31 32 33
      when(mockDevices.iOS.informerPath).thenReturn(mockCommand);
      when(mockDevices.iOS.installerPath).thenReturn(mockCommand);
      when(mockDevices.iOS.listerPath).thenReturn(mockCommand);
34

35 36
      // Avoid relying on xcrun being installed on the test system.
      // Instead, cause the test to run the echo command.
Devon Carew's avatar
Devon Carew committed
37
      when(mockDevices.iOSSimulator.xcrunPath).thenReturn(mockCommand);
38

39 40 41 42 43 44
      CommandRunner runner = new CommandRunner('test_flutter', '')
        ..addCommand(command);
      runner.run(['list']).then((int code) => expect(code, equals(0)));
    });
  });
}