Skip to content

Commit

Permalink
Adding ability to run adb reverse via mobly AdbProxy, fixes #900 (#903)
Browse files Browse the repository at this point in the history
  • Loading branch information
ssachinsunder authored Oct 31, 2023
1 parent ebdec3a commit 8ad26db
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
6 changes: 6 additions & 0 deletions mobly/controllers/android_device_lib/adb.py
Original file line number Diff line number Diff line change
Expand Up @@ -459,6 +459,12 @@ def forward(self, args=None, shell=False) -> bytes:
'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:
Expand Down
18 changes: 17 additions & 1 deletion tests/mobly/controllers/android_device_lib/adb_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -702,7 +702,23 @@ def test_getprops_when_empty_string_always_returned(self, mock_sleep):

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
Expand Down

0 comments on commit 8ad26db

Please sign in to comment.