def bluetooth_pair(): controller = RemoteController("N0AA003759K70700223") controller2 = RemoteController("N0AA003759K70700223") bluetooth = controller.get_bluetooth_adapter() bluetooth2 = controller2.get_bluetooth_adapter() bluetooth.enable() bluetooth2.enable() wait(condition=lambda: bluetooth.is_enabled(), max_timeout=15, waiting_for='bluetooth enabled', error_msg='bluetooth disabled') wait(condition=lambda: bluetooth2.is_enabled(), max_timeout=15, waiting_for='bluetooth enabled', error_msg='bluetooth disabled') bluetooth.pair(bluetooth2.get_address()) time.sleep(5)
def player_play_stop_remote_file_test(): controller = RemoteController("N0AA003759K70700223") player = controller.get_player_adapter() audio_folder = controller.get_remote_file("/storage/emulated/0/audio") for audio_file in audio_folder.list_files(): player.play(audio_file) time.sleep(5) assert player.is_playing() player.stop() assert not player.is_playing()
def rename_file_test(): controller = RemoteController("N0AA003759K70700223") rename_file = controller.get_remote_file("/storage/emulated/0/before_rename.txt") if not rename_file.exist(): rename_file.create_new_file() assert rename_file.exist() assert rename_file.is_file() rename_file.rename_to("/storage/emulated/0/after_rename.txt") assert rename_file.get_name() == "after_rename.txt" assert rename_file.exist() assert rename_file.is_file() rename_file.delete()
def bluetooth_discoverable(): controller = RemoteController("N0AA003759K70700223") bluetooth = controller.get_bluetooth_adapter() bluetooth.enable() wait(condition=lambda: bluetooth.is_enabled(), max_timeout=15, waiting_for='bluetooth enabled', error_msg='bluetooth disabled') bluetooth.start_discoverable(120) wait(condition=lambda: bluetooth.is_discoverable(), max_timeout=15, waiting_for='bluetooth discoverable', error_msg='bluetooth not discoverable')
def list_files_test(): controller = RemoteController("N0AA003759K70700223") storage = controller.get_environment_adapter().get_external_storage_directory() for file in storage.list_files(): file.is_file() file.last_modified() file.is_directory() file.exist() file.get_name() file.can_execute() file.can_read() file.can_write() file.get_parent() file.get_total_space() file.is_hidden() file.is_absolute() print("-----------------------------------")
def bluetooth_enable_disable(): controller = RemoteController("N0AA003759K70700223") controller.start_view(Actions.ACTION_BLUETOOTH_SETTINGS) bluetooth = controller.get_bluetooth_adapter() bluetooth.enable() wait(condition=lambda: bluetooth.is_enabled(), max_timeout=15, waiting_for='bluetooth enabled', error_msg='bluetooth disabled') bluetooth.disable() wait(condition=lambda: not bluetooth.is_enabled(), max_timeout=15, waiting_for='bluetooth disabled', error_msg='bluetooth enabled')
def wifi_enable_disable(): controller = RemoteController("N0AA003759K70700223") controller.start_view(Actions.ACTION_WIFI_SETTINGS) wifi = controller.get_wifi_adapter() wifi.enable() wait(condition=lambda: wifi.is_enabled(), max_timeout=15, waiting_for='wifi enabled', error_msg='wifi disabled') wifi.disable() wait(condition=lambda: not wifi.is_enabled(), max_timeout=15, waiting_for='wifi disabled', error_msg='wifi enabled')
def bluetooth_change_name(): controller = RemoteController("N0AA003759K70700223") controller.start_view(Actions.ACTION_BLUETOOTH_SETTINGS) bluetooth = controller.get_bluetooth_adapter() bluetooth.enable() wait(condition=lambda: bluetooth.is_enabled(), max_timeout=15, waiting_for='bluetooth enabled', error_msg='bluetooth disabled') previous_name = bluetooth.get_name() bluetooth.set_name("TestName") assert bluetooth.get_name() == "TestName" bluetooth.set_name(previous_name)
def answer_incoming_call(): controller = RemoteController("N0AA003759K70700223") telecom = controller.get_telecom_adapter() # TODO call to your test phone ) wait(condition=lambda: telecom.get_call_state() == CallState.INCOMING_CALL, max_timeout=45, waiting_for='incoming call', error_msg='nobody calling)') telecom.answer_incoming_call() time.sleep(5) telecom.end_call() wait(condition=lambda: telecom.get_call_state() == CallState.NONE, max_timeout=15, waiting_for='not in call', error_msg='in call')
def call_state_test(): controller = RemoteController("N0AA003759K70700223") telecom = controller.get_telecom_adapter() telecom.get_call_state() telecom.call("466") wait(condition=lambda: telecom.get_call_state() == CallState.IN_CALL, max_timeout=15, waiting_for='in call', error_msg='not in call') time.sleep(5) telecom.get_call_state() telecom.end_call() wait(condition=lambda: telecom.get_call_state() == CallState.NONE, max_timeout=15, waiting_for='not in call', error_msg='in call')
from controllers.remote_controller import RemoteController from utils.wait import wait from adapters.wifi.wifi_configuration import SecurityType from adapters.wifi.wifi_configuration import WifiConfiguration import time from adapters.bluetooth.bluetooth_device import BluetoothDevice def print_hi(name): # Use a breakpoint in the code line below to debug your script. print(f'Hi, {name}') # Press Ctrl+F8 to toggle the breakpoint. # Press the green button in the gutter to run the script. if __name__ == '__main__': controller = RemoteController("N0AA003759K70700223") adapter = controller.get_wifi_adapter() adapter.enable() wait(condition=lambda: adapter.is_enabled(), max_timeout=15, waiting_for='wifi enabled', error_msg='wifi disabled') net_id = adapter.add_network("RNS_AES", "12345678", SecurityType.PASS) adapter.enable_network(net_id=net_id) time.sleep(15)
def ussd_request_test(): controller = RemoteController("N0AA003759K70700223") telecom = controller.get_telecom_adapter() telecom.send_ussd_request("*161#")