aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSachin Sagadevan <148814276+ssachinsunder@users.noreply.github.com>2023-10-31 00:10:18 -0500
committerGitHub <noreply@github.com>2023-10-30 22:10:18 -0700
commit8ad26db66f37450a9abe87f8cf47b2b241c3a1f5 (patch)
tree026d00332c2f2d270d8bc2eeb86e07ec4a09455e
parentebdec3a739616cf48b6d60624b68801d0bbf4718 (diff)
downloadmobly-8ad26db66f37450a9abe87f8cf47b2b241c3a1f5.tar.gz
Adding ability to run adb reverse via mobly AdbProxy, fixes #900 (#903)
-rw-r--r--mobly/controllers/android_device_lib/adb.py6
-rwxr-xr-xtests/mobly/controllers/android_device_lib/adb_test.py18
2 files changed, 23 insertions, 1 deletions
diff --git a/mobly/controllers/android_device_lib/adb.py b/mobly/controllers/android_device_lib/adb.py
index d813245..721dcc7 100644
--- a/mobly/controllers/android_device_lib/adb.py
+++ b/mobly/controllers/android_device_lib/adb.py
@@ -459,6 +459,12 @@ class AdbProxy:
'forward', args, shell, timeout=None, stderr=None
)
+ def reverse(self, args=None, shell=False) -> bytes:
+ with ADB_PORT_LOCK:
+ return self._exec_adb_cmd(
+ 'reverse', args, shell, timeout=None, stderr=None
+ )
+
def instrument(
self, package, options=None, runner=None, handler=None
) -> bytes:
diff --git a/tests/mobly/controllers/android_device_lib/adb_test.py b/tests/mobly/controllers/android_device_lib/adb_test.py
index 4b26b92..65c7eb5 100755
--- a/tests/mobly/controllers/android_device_lib/adb_test.py
+++ b/tests/mobly/controllers/android_device_lib/adb_test.py
@@ -702,7 +702,23 @@ class AdbTest(unittest.TestCase):
def test_forward(self):
with mock.patch.object(adb.AdbProxy, '_exec_cmd') as mock_exec_cmd:
- adb.AdbProxy().forward(MOCK_SHELL_COMMAND)
+ adb.AdbProxy().forward(['tcp:12345', 'tcp:98765'])
+ mock_exec_cmd.assert_called_with(
+ ['adb', 'forward', 'tcp:12345', 'tcp:98765'],
+ shell=False,
+ timeout=None,
+ stderr=None,
+ )
+
+ def test_reverse(self):
+ with mock.patch.object(adb.AdbProxy, '_exec_cmd') as mock_exec_cmd:
+ adb.AdbProxy().reverse(['tcp:12345', 'tcp:98765'])
+ mock_exec_cmd.assert_called_with(
+ ['adb', 'reverse', 'tcp:12345', 'tcp:98765'],
+ shell=False,
+ timeout=None,
+ stderr=None,
+ )
def test_instrument_without_parameters(self):
"""Verifies the AndroidDevice object's instrument command is correct in