| OLD | NEW |
| (Empty) | |
| 1 # Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. |
| 4 |
| 5 """Tests for the Android shell abstraction.""" |
| 6 |
| 7 import imp |
| 8 import os.path |
| 9 import sys |
| 10 import unittest |
| 11 |
| 12 try: |
| 13 imp.find_module("devtoolslib") |
| 14 except ImportError: |
| 15 sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) |
| 16 |
| 17 from devtoolslib.android_shell import parse_adb_devices_output |
| 18 |
| 19 class AndroidShellTest(unittest.TestCase): |
| 20 """Tests the Android shell abstraction.""" |
| 21 |
| 22 def test_parse_adb_devices_output(self): |
| 23 """Tests parsing of the `adb devices` output.""" |
| 24 one_device_output = """\ |
| 25 List of devices attached |
| 26 42424242 device |
| 27 |
| 28 """ |
| 29 results = parse_adb_devices_output(one_device_output) |
| 30 self.assertEquals(1, len(results)) |
| 31 self.assertTrue('42424242' in results) |
| 32 self.assertEquals('device', results['42424242']) |
| 33 |
| 34 multi_devices_output = """\ |
| 35 List of devices attached |
| 36 42424242 device |
| 37 42424243 offline |
| 38 42424244 device |
| 39 |
| 40 """ |
| 41 results = parse_adb_devices_output(multi_devices_output) |
| 42 self.assertEquals(3, len(results)) |
| 43 self.assertTrue('42424242' in results) |
| 44 self.assertEquals('device', results['42424242']) |
| 45 self.assertTrue('42424243' in results) |
| 46 self.assertEquals('offline', results['42424243']) |
| 47 self.assertTrue('42424244' in results) |
| 48 self.assertEquals('device', results['42424244']) |
| 49 |
| 50 # Output produced when adb server needs to be started. |
| 51 adb_server_startup_output = """\ |
| 52 * daemon not running. starting it now on port 5037 * |
| 53 * daemon started successfully * |
| 54 List of devices attached |
| 55 42424242 device |
| 56 |
| 57 """ |
| 58 results = parse_adb_devices_output(adb_server_startup_output) |
| 59 self.assertEquals(1, len(results)) |
| 60 self.assertTrue('42424242' in results) |
| 61 self.assertEquals('device', results['42424242']) |
| OLD | NEW |