aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorMinghao Li <minghaoli@google.com>2022-05-20 12:18:44 +0800
committerGitHub <noreply@github.com>2022-05-19 21:18:44 -0700
commit913e47084f8e8dd77b862b57d651dcc384d572b8 (patch)
tree6203898b57122cb2a4c8bec1ce11d2130de5c1c6 /tests
parent286c2f5819c1f640e4ea99d569bd6f3ab87dad9d (diff)
downloadmobly-913e47084f8e8dd77b862b57d651dcc384d572b8.tar.gz
Event client clears host_port and device_port attribute (#822)
Diffstat (limited to 'tests')
-rwxr-xr-xtests/mobly/controllers/android_device_lib/snippet_client_test.py25
1 files changed, 25 insertions, 0 deletions
diff --git a/tests/mobly/controllers/android_device_lib/snippet_client_test.py b/tests/mobly/controllers/android_device_lib/snippet_client_test.py
index bfa41d6..53da1ae 100755
--- a/tests/mobly/controllers/android_device_lib/snippet_client_test.py
+++ b/tests/mobly/controllers/android_device_lib/snippet_client_test.py
@@ -228,6 +228,31 @@ class SnippetClientTest(jsonrpc_client_test_base.JsonRpcClientTestBase):
self.assertIsNone(client._event_client)
@mock.patch('socket.create_connection')
+ @mock.patch('mobly.utils.stop_standing_subprocess')
+ @mock.patch.object(snippet_client.SnippetClient, 'connect')
+ def test_event_client_does_not_stop_port_forwarding(
+ self, mock_stop_standing_subprocess, mock_create_connection,
+ mock_connect):
+ adb_proxy = mock.MagicMock()
+ adb_proxy.shell.return_value = b'OK (0 tests)'
+ client = self._make_client(adb_proxy)
+ client.host_port = 12345
+ client.device_port = 67890
+
+ event_client = client._start_event_client()
+ # Mock adb proxy of event client to validate forward call
+ event_client._ad = mock.MagicMock()
+ event_client._adb = event_client._ad.adb
+ client._event_client = event_client
+
+ # Verify that neither the stop process nor the deconstructor is trying to
+ # stop the port forwarding
+ client.stop_app()
+ event_client.__del__()
+
+ event_client._adb.forward.assert_not_called()
+
+ @mock.patch('socket.create_connection')
@mock.patch('mobly.controllers.android_device_lib.snippet_client.'
'utils.start_standing_subprocess')
@mock.patch('mobly.controllers.android_device_lib.snippet_client.'