adb_test.dart 1.11 KB
Newer Older
Devon Carew's avatar
Devon Carew committed
1 2 3 4 5
// 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:flutter_tools/src/android/adb.dart';
6
import 'package:flutter_tools/src/base/os.dart';
Devon Carew's avatar
Devon Carew committed
7 8
import 'package:test/test.dart';

9
import 'src/context.dart';
Devon Carew's avatar
Devon Carew committed
10

11
void main() {
Devon Carew's avatar
Devon Carew committed
12
  // We only test the [Adb] class is we're able to locate the adb binary.
13 14
  final String adbPath = new OperatingSystemUtils().which('adb')?.path;
  if (adbPath == null)
Devon Carew's avatar
Devon Carew committed
15 16
    return;

17 18 19 20 21 22 23
  Adb adb;

  setUp(() {
    if (adbPath != null)
      adb = new Adb(adbPath);
  });

Devon Carew's avatar
Devon Carew committed
24
  group('adb', () {
25
    testUsingContext('getVersion', () {
Devon Carew's avatar
Devon Carew committed
26 27 28
      expect(adb.getVersion(), isNotEmpty);
    });

29
    testUsingContext('getServerVersion', () async {
Devon Carew's avatar
Devon Carew committed
30 31
      adb.startServer();

32
      final String version = await adb.getServerVersion();
Devon Carew's avatar
Devon Carew committed
33 34 35
      expect(version, isNotEmpty);
    });

36
    testUsingContext('listDevices', () async {
Devon Carew's avatar
Devon Carew committed
37 38
      adb.startServer();

39
      final List<AdbDevice> devices = await adb.listDevices();
Devon Carew's avatar
Devon Carew committed
40 41 42 43

      // Any result is ok.
      expect(devices, isList);
    });
44
  }, skip: adbPath == null);
Devon Carew's avatar
Devon Carew committed
45
}