Пример #1
0
def bluetooth_scan():
    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_discovery()

    wait(condition=lambda: bluetooth.is_discovering(),
         max_timeout=15,
         waiting_for='bluetooth discovering',
         error_msg='bluetooth not discovering')

    time.sleep(10)

    bluetooth.cancel_discovery()

    list_devices = bluetooth.get_discovered_devices()

    for device in list_devices:
        device.get_pair_state()
        device.get_name()
        device.get_type()
        device.get_bluetooth_class()
        print("---------------------------------")
Пример #2
0
def telecom_contacts_test():
    controller = RemoteController("N0AA003759K70700223")

    telecom = controller.get_telecom_adapter()

    for item in telecom.get_contacts():
        print(item)
Пример #3
0
def wifi_scan_results():
    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.start_scan()

    time.sleep(6)

    for scan_result in wifi.get_scan_results():
        print(scan_result)

    wifi.disable()

    wait(condition=lambda: not wifi.is_enabled(),
         max_timeout=15,
         waiting_for='wifi enabled',
         error_msg='wifi disabled')
Пример #4
0
def player_seek_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)

        player.get_duration()

        time.sleep(5)

        assert player.get_current_position() > 5000

        middle_track_time = int(player.get_duration()/2)

        player.seek_to(middle_track_time)

        assert player.get_current_position() >= middle_track_time

        time.sleep(5)

        player.stop()

        assert not player.is_playing()
Пример #5
0
def get_storage_volumes():
    controller = RemoteController("N0AA003759K70700223")

    environment = controller.get_environment_adapter()

    for volume in environment.get_storage_volumes():
        print(volume)
Пример #6
0
def wifi_connect_network():
    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')

    net_id = wifi.add_network("RNS_AES", "12345678", SecurityType.PASS)

    wifi.enable_network(net_id=net_id)


    wait(condition=lambda: wifi.is_network_connected(),
         max_timeout=15,
         waiting_for='wifi enabled',
         error_msg='wifi disabled')

    for net in wifi.get_configured_networks():
        print(net.SSID)

    wifi.remove_network(net_id=net_id)

    wifi.disable()

    wait(condition=lambda: not wifi.is_enabled(),
         max_timeout=15,
         waiting_for='wifi enabled',
         error_msg='wifi disabled')
Пример #7
0
def get_input_device_list():
    controller = RemoteController("0000")

    usb = controller.get_usb_adapter()

    for device in usb.get_input_device_list():
        print(device)
Пример #8
0
def remove_paired_devices_test():
    # TODO before test pair device
    controller = RemoteController("N0AA003759K70700223")

    bluetooth = controller.get_bluetooth_adapter()

    bluetooth.remove_all_paired_devices()

    assert len(bluetooth.get_paired_devices()) == 0
Пример #9
0
def telecom_call_history_test():
    controller = RemoteController("N0AA003759K70700223")

    telecom = controller.get_telecom_adapter()

    telecom.get_call_state()

    for item in telecom.get_call_history():
        print(item)
Пример #10
0
def player_play_stop_test():
    controller = RemoteController("N0AA003759K70700223")

    player = controller.get_player_adapter()

    player.play("/storage/emulated/0/1.mp3")

    time.sleep(10)

    player.stop()
Пример #11
0
def create_delete_file_test():
    controller = RemoteController("N0AA003759K70700223")

    test_file = controller.get_remote_file("/storage/emulated/0/test.txt")

    if not test_file.exist():
        test_file.create_new_file()

    assert test_file.exist()
    assert test_file.is_file()

    test_file.delete()
Пример #12
0
def create_delete_dirs_test():
    controller = RemoteController("N0AA003759K70700223")

    test_dir = controller.get_remote_file("/storage/emulated/0/outer_dir/inner_dir")

    if not test_dir.exist():
        test_dir.make_dirs()

    assert test_dir.exist()
    assert test_dir.is_directory()

    test_dir.delete()
Пример #13
0
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()
Пример #14
0
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')
Пример #15
0
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()
Пример #16
0
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("-----------------------------------")
Пример #17
0
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')
Пример #18
0
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)
Пример #19
0
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')
Пример #20
0
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')
Пример #21
0
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)
Пример #22
0
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)
Пример #23
0
def ussd_request_test():
    controller = RemoteController("N0AA003759K70700223")

    telecom = controller.get_telecom_adapter()

    telecom.send_ussd_request("*161#")