android_emulator_test.dart 2.01 KB
Newer Older
1 2 3 4 5 6
// Copyright 2018 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/android_emulator.dart';

7
import '../src/common.dart';
8 9 10 11 12 13
import '../src/context.dart';

void main() {
  group('android_emulator', () {
    testUsingContext('flags emulators without config', () {
      const String emulatorID = '1234';
14
      final AndroidEmulator emulator = AndroidEmulator(emulatorID);
15 16 17 18 19 20
      expect(emulator.id, emulatorID);
      expect(emulator.hasConfig, false);
    });
    testUsingContext('flags emulators with config', () {
      const String emulatorID = '1234';
      final AndroidEmulator emulator =
21
          AndroidEmulator(emulatorID, <String, String>{'name': 'test'});
22 23 24 25 26 27 28 29 30 31 32 33 34 35
      expect(emulator.id, emulatorID);
      expect(emulator.hasConfig, true);
    });
    testUsingContext('stores expected metadata', () {
      const String emulatorID = '1234';
      const String name = 'My Test Name';
      const String manufacturer = 'Me';
      const String label = 'The best one';
      final Map<String, String> properties = <String, String>{
        'hw.device.name': name,
        'hw.device.manufacturer': manufacturer,
        'avd.ini.displayname': label
      };
      final AndroidEmulator emulator =
36
          AndroidEmulator(emulatorID, properties);
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56
      expect(emulator.id, emulatorID);
      expect(emulator.name, name);
      expect(emulator.manufacturer, manufacturer);
      expect(emulator.label, label);
    });
    testUsingContext('parses ini files', () {
      const String iniFile = '''
        hw.device.name=My Test Name
        #hw.device.name=Bad Name

        hw.device.manufacturer=Me
        avd.ini.displayname = dispName
      ''';
      final Map<String, String> results = parseIniLines(iniFile.split('\n'));
      expect(results['hw.device.name'], 'My Test Name');
      expect(results['hw.device.manufacturer'], 'Me');
      expect(results['avd.ini.displayname'], 'dispName');
    });
  });
}