1 #!/usr/bin/env python 2 # 3 # Copyright 2016 - The Android Open Source Project 4 # 5 # Licensed under the Apache License, Version 2.0 (the "License"); 6 # you may not use this file except in compliance with the License. 7 # You may obtain a copy of the License at 8 # 9 # http://www.apache.org/licenses/LICENSE-2.0 10 # 11 # Unless required by applicable law or agreed to in writing, software 12 # distributed under the License is distributed on an "AS IS" BASIS, 13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 # See the License for the specific language governing permissions and 15 # limitations under the License. 16 from acts import base_test 17 from acts import test_runner 18 from acts.controllers.relay_lib.relay import SynchronizeRelays 19 20 class RelayDeviceSampleTest(base_test.BaseTestClass): 21 """ Demonstrates example usage of a configurable access point.""" 22 23 def setup_class(self): 24 # Take devices from relay_devices. 25 self.relay_device = self.relay_devices[0] 26 27 # You can use this workaround to get devices by name: 28 29 relay_rig = self.relay_devices[0].rig 30 #self.other_relay_device = relay_rig.devices['UniqueDeviceName'] 31 # Note: If the "devices" key from the config is missing 32 # a GenericRelayDevice that contains every switch in the config 33 # will be stored in relay_devices[0]. Its name will be 34 # "GenericRelayDevice". 35 36 def setup_test(self): 37 # setup() will set the relay device to the default state. 38 # Unless overridden, the default state is all switches set to off. 39 self.relay_device.setup() 40 41 def teardown_test(self): 42 # clean_up() will set the relay device back to a default state. 43 # Unless overridden, the default state is all switches set to off. 44 self.relay_device.clean_up() 45 46 47 def test_toggling(self): 48 # This test just spams the toggle on each relay. 49 ## print(self.relay_device.relays.mac_address) 50 print("--->" + self.relay_device.mac_address + "<---") 51 for _ in range(0, 2): 52 self.relay_device.relays['Play'].toggle() 53 54 if __name__ == "__main__": 55 test_runner.main() 56