android_device_test.dart 1.54 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.

5
import 'package:flutter_tools/src/android/android_device.dart';
6 7
import 'package:test/test.dart';

8
import 'src/context.dart';
9

10
void main() {
11
  group('android_device', () {
12
    testUsingContext('stores the requested id', () {
13
      String deviceId = '1234';
14
      AndroidDevice device = new AndroidDevice(deviceId);
15
      expect(device.id, deviceId);
16 17
    });
  });
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40

  group('getAdbDevices', () {
    testUsingContext('physical devices', () {
      List<AndroidDevice> devices = getAdbDevices(mockAdbOutput: '''
List of devices attached
05a02bac               device usb:336592896X product:razor model:Nexus_7 device:flo

''');
      expect(devices, hasLength(1));
      expect(devices.first.name, 'Nexus 7');
    });

    testUsingContext('emulators and short listings', () {
      List<AndroidDevice> devices = getAdbDevices(mockAdbOutput: '''
List of devices attached
localhost:36790        device
0149947A0D01500C       device usb:340787200X
emulator-5612          host features:shell_2

''');
      expect(devices, hasLength(3));
      expect(devices.first.name, 'localhost:36790');
    });
41 42 43 44 45 46 47 48

    testUsingContext('android n', () {
      List<AndroidDevice> devices = getAdbDevices(mockAdbOutput: '''
ZX1G22JJWR             device usb:3-3 product:shamu model:Nexus_6 device:shamu features:cmd,shell_v2
''');
      expect(devices, hasLength(1));
      expect(devices.first.name, 'Nexus 6');
    });
49
  });
50
}