Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding ability to run adb reverse via mobly AdbProxy, fixes #900 #903

Merged
merged 2 commits into from
Oct 31, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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):
ssachinsunder marked this conversation as resolved.
Show resolved Hide resolved
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
Loading