Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(796)

Unified Diff: mojo/devtools/common/devtoolslib/android_shell_unittest.py

Issue 1381863004: Fix mojo_ tools on the first run after adb kill-server. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Address Ben's comments. Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « mojo/devtools/common/devtoolslib/android_shell.py ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/devtools/common/devtoolslib/android_shell_unittest.py
diff --git a/mojo/devtools/common/devtoolslib/android_shell_unittest.py b/mojo/devtools/common/devtoolslib/android_shell_unittest.py
new file mode 100644
index 0000000000000000000000000000000000000000..caf24838d533fc351098e77010528c5a18e147d2
--- /dev/null
+++ b/mojo/devtools/common/devtoolslib/android_shell_unittest.py
@@ -0,0 +1,61 @@
+# 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.
+
+"""Tests for the Android shell abstraction."""
+
+import imp
+import os.path
+import sys
+import unittest
+
+try:
+ imp.find_module("devtoolslib")
+except ImportError:
+ sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
+
+from devtoolslib.android_shell import parse_adb_devices_output
+
+class AndroidShellTest(unittest.TestCase):
+ """Tests the Android shell abstraction."""
+
+ def test_parse_adb_devices_output(self):
+ """Tests parsing of the `adb devices` output."""
+ one_device_output = """\
+List of devices attached
+42424242 device
+
+"""
+ results = parse_adb_devices_output(one_device_output)
+ self.assertEquals(1, len(results))
+ self.assertTrue('42424242' in results)
+ self.assertEquals('device', results['42424242'])
+
+ multi_devices_output = """\
+List of devices attached
+42424242 device
+42424243 offline
+42424244 device
+
+"""
+ results = parse_adb_devices_output(multi_devices_output)
+ self.assertEquals(3, len(results))
+ self.assertTrue('42424242' in results)
+ self.assertEquals('device', results['42424242'])
+ self.assertTrue('42424243' in results)
+ self.assertEquals('offline', results['42424243'])
+ self.assertTrue('42424244' in results)
+ self.assertEquals('device', results['42424244'])
+
+ # Output produced when adb server needs to be started.
+ adb_server_startup_output = """\
+* daemon not running. starting it now on port 5037 *
+* daemon started successfully *
+List of devices attached
+42424242 device
+
+"""
+ results = parse_adb_devices_output(adb_server_startup_output)
+ self.assertEquals(1, len(results))
+ self.assertTrue('42424242' in results)
+ self.assertEquals('device', results['42424242'])
« no previous file with comments | « mojo/devtools/common/devtoolslib/android_shell.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698