1#  Copyright (C) 2024 The Android Open Source Project
2#
3#  Licensed under the Apache License, Version 2.0 (the "License");
4#  you may not use this file except in compliance with the License.
5#  You may obtain a copy of the License at
6#
7#       http://www.apache.org/licenses/LICENSE-2.0
8#
9#  Unless required by applicable law or agreed to in writing, software
10#  distributed under the License is distributed on an "AS IS" BASIS,
11#  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12#  See the License for the specific language governing permissions and
13#  limitations under the License.
14#
15#  Licensed under the Apache License, Version 2.0 (the "License");
16#  you may not use this file except in compliance with the License.
17#  You may obtain a copy of the License at
18#
19#       http://www.apache.org/licenses/LICENSE-2.0
20#
21#  Unless required by applicable law or agreed to in writing, software
22#  distributed under the License is distributed on an "AS IS" BASIS,
23#  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
24#  See the License for the specific language governing permissions and
25#  limitations under the License.
26
27from mobly import base_test
28from mobly import utils
29from mobly.controllers import android_device
30
31CONNECTIVITY_MULTI_DEVICES_SNIPPET_PACKAGE = "com.google.snippet.connectivity"
32
33
34class MultiDevicesTestBase(base_test.BaseTestClass):
35
36  def setup_class(self):
37    # Declare that two Android devices are needed.
38    self.clientDevice, self.serverDevice = self.register_controller(
39        android_device, min_number=2
40    )
41
42    def setup_device(device):
43      device.load_snippet(
44          "connectivity_multi_devices_snippet",
45          CONNECTIVITY_MULTI_DEVICES_SNIPPET_PACKAGE,
46      )
47
48    # Set up devices in parallel to save time.
49    utils.concurrent_exec(
50        setup_device,
51        ((self.clientDevice,), (self.serverDevice,)),
52        max_workers=2,
53        raise_on_exception=True,
54    )
55    self.client = self.clientDevice.connectivity_multi_devices_snippet
56