# Setup
ui_steps.press_home(serial=serial)()
ui_steps.press_home(serial=serial2)()
ui_steps.am_stop_package(serial=serial,
                         package_name="com.android.settings",
                         blocking=True)()
ui_steps.am_stop_package(serial=serial2,
                         package_name="com.android.settings",
                         blocking=True)()

bluetooth_steps.OpenBluetoothSettings(serial=serial2,
                                      use_intent=True,
                                      blocking=True)()
bluetooth_steps.BtChangeDeviceName(serial=serial2,
                                   name=DEV_MAC_ADDRESS,
                                   blocking=True)()
bluetooth_steps.OpenBluetoothSettings(serial=serial, blocking=True)()
bluetooth_steps.BtChangeDeviceName(serial=serial, name=DUT_NAME,
                                   blocking=True)()
bluetooth_steps.ClickBluetoothSwitch(serial=serial, state="ON",
                                     blocking=True)()

# add step to connect device
bluetooth_steps.BtRemoveAllPairedDevices(serial=serial, blocking=True)()
bluetooth_steps.CheckBtVisibility(serial=serial, blocking=True)()
bluetooth_steps.CheckBtVisibility(serial=serial2, blocking=True)()

# Set Up

bluetooth_steps.LogInfo("##### ACTUAL TEST #####")()
示例#2
0
    bluetooth_steps.PressHome(serial=serial_dev, blocking=True)()
    bluetooth_steps.OpenBluetoothSettings(serial=serial_dev,
                                          use_intent=True,
                                          version=DEV_VERSION,
                                          blocking=True)()
    bluetooth_steps.ClickBluetoothSwitch(serial=serial_dev,
                                         state="ON",
                                         version=DEV_VERSION,
                                         blocking=True)()

    # DUT: wait scan, rename device and remove all paired devices
    bluetooth_steps.WaitBtScanning(serial=serial,
                                   version=DUT_VERSION,
                                   blocking=True)()
    bluetooth_steps.BtChangeDeviceName(serial=serial,
                                       name=DUT_NAME,
                                       version=DUT_VERSION,
                                       blocking=True)()
    bluetooth_steps.BtRemoveAllPairedDevices(serial=serial,
                                             version=DUT_VERSION,
                                             blocking=True)()
    bluetooth_steps.CheckBtVisibility(serial=serial,
                                      version=DUT_VERSION,
                                      blocking=True)()

    # DEV: wait scan (should be already finished), rename device and remove all paired devices
    bluetooth_steps.WaitBtScanning(serial=serial_dev,
                                   timeout_appear=0,
                                   version=DEV_VERSION,
                                   blocking=True)()
    bluetooth_steps.BtChangeDeviceName(serial=serial_dev,
                                       name=PAIRING_DEV_NAME,
    # DEV: turn on bt
    bluetooth_steps.OpenBluetoothSettings(serial=serial_dev,
                                          use_intent=True,
                                          version=DEV_VERSION,
                                          blocking=True)()
    bluetooth_steps.ClickBluetoothSwitch(serial=serial_dev,
                                         state="ON",
                                         version=DEV_VERSION,
                                         blocking=True)()

    # DUT: wait scan, rename and remove paired devices
    bluetooth_steps.WaitBtScanning(serial=serial,
                                   version=DUT_VERSION,
                                   blocking=True)()
    bluetooth_steps.BtChangeDeviceName(serial=serial,
                                       name=DUT_NAME,
                                       version=DUT_VERSION,
                                       blocking=True)()
    bluetooth_steps.BtRemoveAllPairedDevices(serial=serial,
                                             version=DUT_VERSION,
                                             blocking=True)()
    bluetooth_steps.CheckBtVisibility(serial=serial,
                                      version=DUT_VERSION,
                                      blocking=True)()

    # DEV:  wait scan (should be already finsihed) and remove paired devices
    bluetooth_steps.WaitBtScanning(serial=serial_dev,
                                   timeout_appear=0,
                                   version=DEV_VERSION,
                                   blocking=True)()
    bluetooth_steps.BtRemoveAllPairedDevices(serial=serial_dev,
                                             version=DEV_VERSION,
    # #########################################

    bluetooth_steps.LogInfo("######## SETUP ########")()

    bluetooth_steps.StopPackage(serial=serial, blocking=True)()
    bluetooth_steps.PressHome(serial=serial, blocking=True)()
    bluetooth_steps.OpenBluetoothSettings(serial=serial_dev,
                                          use_intent=True,
                                          version=DEV_VERSION,
                                          blocking=True)()
    bluetooth_steps.ClickBluetoothSwitch(serial=serial_dev,
                                         state="ON",
                                         version=DEV_VERSION,
                                         blocking=True)()
    bluetooth_steps.BtChangeDeviceName(serial=serial_dev,
                                       name=PAIRING_DEV_NAME,
                                       blocking=True)()
    # ############ Actual Test ################
    # #########################################

    bluetooth_steps.LogInfo("##### ACTUAL TEST #####")()

    bluetooth_steps.OpenBluetoothSettings(serial=serial,
                                          use_intent=True,
                                          version=DUT_VERSION)()
    bluetooth_steps.ClickBluetoothSwitch(serial=serial,
                                         state="ON",
                                         version=DUT_VERSION)()
    counter = 1
    while counter < attempts:
        bluetooth_steps.BtSearchDevices(serial=serial,
示例#5
0
def opp_send_file(serial, serial_dev, condition, event,
                  file_path="/storage/emulated/0/acs_files",
                  file_name="10MB.txt", iteration=1, q=None):
    result = []
    try:
        file_full_path = file_path + '/' + file_name
        # Initialize versions and names (we only need dev name)
        DUT_VERSION = bluetooth_steps.GetAndroidVersion(serial=serial,
                                                        blocking=True)()
        DEV_VERSION = bluetooth_steps.GetAndroidVersion(serial=serial_dev,
                                                        blocking=True)()
        PAIRING_DUT_NAME = bluetooth_steps.GetBtMac(serial=serial,
                                                    blocking=True)()
        PAIRING_DEV_NAME = bluetooth_steps.GetBtMac(serial=serial_dev,
                                                    blocking=True)()
        # taking only the name and removing the extensions
        FILE_NAME = file_name.split(".")[0]

        bluetooth_steps.LogInfo("######## SETUP ########")()

        for _ in range(0, iteration):
            if initiator == "dev" and _ == 0:
                serial, serial_dev = serial_dev, serial
                DUT_VERSION, DEV_VERSION = DEV_VERSION, DUT_VERSION
                PAIRING_DUT_NAME, PAIRING_DEV_NAME = PAIRING_DEV_NAME, \
                                                     PAIRING_DUT_NAME

            if iteration > 1:
                log.info("Opp transfer: Iteration #{}".format(_ + 1))
            if priority == 'bt' and _ == 0:
                # print e.is_set()
                # print 'bt 1st event wait'
                event.wait(CONDITION_EVENT_TIMEOUT)
                event.clear()
            elif not priority == "toggle":
                # print 'bt 1st event set'
                event.set()

            with condition:
                # print 'Before wifi'
                if priority == 'wifi' and _ == 0:
                    condition.wait(CONDITION_EVENT_TIMEOUT)
                # print 'Started after notified from wifi'
                # DUT: clear all notifications etc
                bluetooth_steps.StopPackage(serial=serial, blocking=True)()
                bluetooth_steps.PressHome(serial=serial, blocking=True)()
                bluetooth_steps.ClearAllNotifications(serial=serial,
                                                      version=DUT_VERSION,
                                                      blocking=True)()
                bluetooth_steps.BtOppDismissEventualIncoming(serial=serial,
                                                             version=DUT_VERSION,
                                                             blocking=True)()
                bluetooth_steps.ClearRecentApps(serial=serial,
                                                    version=DUT_VERSION,
                                                    blocking=True)()

                # DEV: clear all notifications/opp files etc
                bluetooth_steps.StopPackage(serial=serial_dev, blocking=True)()
                bluetooth_steps.PressHome(serial=serial_dev, blocking=True)()
                bluetooth_steps.ClearAllNotifications(serial=serial_dev,
                                                      version=DEV_VERSION,
                                                      blocking=True)()
                bluetooth_steps.BtOppDismissEventualIncoming(serial=serial_dev,
                                                             version=DEV_VERSION,
                                                             blocking=True)()
                bluetooth_steps.ClearPath(serial=serial_dev, blocking=True)()

                if _ == 0:
                    # DUT: turn on bt
                    # already turned on during TC setup phase
                    bluetooth_steps.OpenBluetoothSettings(serial=serial,
                                                          use_intent=True,
                                                          version=DUT_VERSION,
                                                          blocking=True)()
                    bluetooth_steps.ClickBluetoothSwitch(serial=serial, state="ON",
                                                         version=DUT_VERSION,
                                                         blocking=True)()

                    # DEV: turn on bt
                    # already turned on during TC setup phase
                    bluetooth_steps.OpenBluetoothSettings(serial=serial_dev,
                                                          use_intent=True,
                                                          version=DEV_VERSION,
                                                          blocking=True)()
                    bluetooth_steps.ClickBluetoothSwitch(serial=serial_dev,
                                                         state="ON",
                                                         version=DEV_VERSION,
                                                         blocking=True)()

                    # DUT: wait scan and remove paired devices
                    bluetooth_steps.WaitBtScanning(serial=serial,
                                                   version=DUT_VERSION,
                                                   blocking=True)()
                    bluetooth_steps.BtChangeDeviceName(serial=serial,
                                                       name=PAIRING_DUT_NAME,
                                                       version=DUT_VERSION,
                                                       blocking=True)()
                    bluetooth_steps.BtRemoveAllPairedDevices(serial=serial,
                                                             version=DUT_VERSION,
                                                             blocking=True)()
                    bluetooth_steps.CheckBtVisibility(serial=serial,
                                                      version=DUT_VERSION,
                                                      blocking=True)()

                    # DEV:  wait scan (should be already finished), rename and
                    # remove paired devices
                    bluetooth_steps.WaitBtScanning(serial=serial_dev,
                                                   timeout_appear=0,
                                                   version=DEV_VERSION,
                                                   blocking=True)()
                    bluetooth_steps.BtChangeDeviceName(serial=serial_dev,
                                                       name=PAIRING_DEV_NAME,
                                                       version=DEV_VERSION,
                                                       blocking=True)()
                    bluetooth_steps.BtRemoveAllPairedDevices(serial=serial_dev,
                                                             version=DEV_VERSION,
                                                             blocking=True)()
                    bluetooth_steps.CheckBtVisibility(serial=serial_dev,
                                                      version=DEV_VERSION,
                                                      blocking=True)()
                    if priority == 'bt' and _ == 0:
                        condition.notify()

            if _ == 0 and bt_pair_device:
                if not pair_device(serial, serial_dev, PAIRING_DUT_NAME,
                        PAIRING_DEV_NAME, DUT_VERSION, DEV_VERSION):
                    raise

            if priority == 'bt' and _ == 0:
                # print e.is_set()
                # print 'bt 2nd event wait'
                event.wait(CONDITION_EVENT_TIMEOUT)
                event.clear()
            elif not priority == 'toggle':
                # print 'bt 2nd event set'
                event.set()

            with condition:
                if priority == 'wifi' and _ == 0:
                    condition.wait(CONDITION_EVENT_TIMEOUT)

                bt_opp_receive_obj = None
                bluetooth_steps.BrowseFileInSettingsStorage(serial=serial,
                                                            file_full_path=file_full_path)()
                bluetooth_steps.BtOppShareFile(serial=serial,
                                               server_dut=str(PAIRING_DEV_NAME),
                                               bt_already_opened=True,
                                               version=DUT_VERSION,
                                               blocking=True)()
                bt_opp_receive_obj = bluetooth_steps.BtOppReceiveFile(
                    serial=serial_dev,
                    action='Accept',
                    filename_starting_string=FILE_NAME,
                    version=DEV_VERSION,
                    check_file_received=False)
                bt_opp_receive_obj()
                if priority == 'bt' and _ == 0:
                    condition.notify()

                # this condition will notify the 'toggle_wifi' to proceed to
                # toggle state
                if priority == 'toggle':
                    event.set()

            # This waits for Wifi to start downloas as both collides when
            # start together
            if initiator == "dev" and priority == "bt" and _ == 0:
                event.wait(CONDITION_EVENT_TIMEOUT)
                event.clear()

            # Below verification of OPP received file is separated from
            # above BtOppReceiveFile because parallelly when file is receiving
            # toggling WIFI should happen
            try:
                # open notification menu and click on incoming file notification
                if not bluetooth_steps.OpenNotificationsMenu(serial=serial_dev,
                                                             version=DEV_VERSION,
                                                             critical=False,
                                                             no_log=True)():
                    raise Exception("Notifications menu not opened")
                if not bluetooth_steps.BtCheckNotificationAppear(serial=serial_dev,
                                                                 text_contains="Bluetooth share: Receiving",
                                                                 click_on_notification=True,
                                                                 time_to_appear=VIEW_TIMEOUT,
                                                                 version=DEV_VERSION,
                                                                 critical=False,
                                                                 no_log=True)():
                    if not bluetooth_steps.BtCheckNotificationAppear(serial=serial_dev,
                                                                 text_contains="Bluetooth share: Received",
                                                                 click_on_notification=True,
                                                                 time_to_appear=VIEW_TIMEOUT,
                                                                 version=DEV_VERSION,
                                                                 critical=False,
                                                                 no_log=True)():
                        raise Exception("Receiving file notification click failed")
                    else:
                        if not bt_opp_receive_obj.uidevice(
                                textContains=FILE_NAME).wait.exists(timeout=VIEW_TIMEOUT):
                            raise Exception("Receiving file not found in "
                                            "Inbound transfers window")
                        if not bt_opp_receive_obj.uidevice(
                                    textContains="Received complete"):
                            raise Exception("File not received completely")
                        bt_opp_receive_obj.uidevice.press.back()
                else:
                    if not bt_opp_receive_obj.uidevice(
                            resourceId="android:id/alertTitle",
                            text="File transfer").wait.exists(timeout=VIEW_TIMEOUT):
                        raise Exception("File transfer progress window not "
                                        "shown after click on receiving file notification")
                    # check the filename in the window (if not empty)
                    if FILE_NAME != "":
                        filename_obj = bt_opp_receive_obj.uidevice(
                            textContains="File:")
                        if not filename_obj.wait.exists(timeout=VIEW_TIMEOUT):
                            raise Exception(
                                "Receiving File Name not found in the file "
                                "transfer window")
                        filename_text = str(filename_obj.text)
                        if FILE_NAME not in filename_text:
                            raise Exception("Not expected string contained in the "
                                            "file transfer window, exp " + str(
                                FILE_NAME) + " but found " + filename_text)
                    # wait till the file is received
                    if not bt_opp_receive_obj.uidevice(
                            text="File received").wait.exists(
                            timeout=TRANSFER_TIMEOUT):
                        if bt_opp_receive_obj.uidevice(textContains="OK",
                                        className="android.widget.Button").exists:
                            bt_opp_receive_obj.uidevice.press.back()
                            #bt_opp_receive_obj.uidevice(textContains="OK",
                            #
                            # className="android.widget.Button").click.wait()
                        raise Exception("Timeout reached, file transfer not finished")
                    # return to the previous window
                    bt_opp_receive_obj.uidevice.press.back()
                    if not bt_opp_receive_obj.uidevice(
                            resourceId="android:id/alertTitle",
                            text="File transfer").wait.gone(timeout=VIEW_TIMEOUT):
                        #if bt_opp_receive_obj.uidevice(textContains="OK",
                        #            className="android.widget.Button").exists:
                        #    bt_opp_receive_obj.uidevice.press.back()
                            #bt_opp_receive_obj.uidevice(textContains="OK",
                            #           className="android.widget.Button").click()

                        # this will help avoid the "File transfer" window
                        # appear in next opp transfer
                        bt_opp_receive_obj.uidevice.press.back()
                        raise Exception("File transfer progress window not closed")
                log.info("File received successfully")
                result.append(True)
            except Exception, e:
                log.error(e.message)
                log.error(traceback.format_exc())
                log.error("Exception raised, File not received successfully")
                result.append(False)
    except:
        log.error('OppTransferFile: Unexpected Error')
        log.error(traceback.format_exc())
        result.append(False)
    finally:
        bluetooth_steps.LogInfo("####### CLEANUP #######")()

        # DUT: close inbounds transfers, turn off bt, clear all opp notifications/files
        bluetooth_steps.DismissTransferList(serial=serial, version=DUT_VERSION,
                                            critical=False)()
        bluetooth_steps.StopPackage(serial=serial, critical=False)()
        bluetooth_steps.ClearAllNotifications(serial=serial,
                                              version=DUT_VERSION,
                                              critical=False)()
        bluetooth_steps.PressHome(serial=serial, critical=False)()

        # DEV: turn off bt, clear all opp notifications/files
        bluetooth_steps.ClearAllNotifications(serial=serial_dev,
                                              version=DEV_VERSION,
                                              critical=False)()
        bluetooth_steps.StopPackage(serial=serial_dev, critical=False)()
        bluetooth_steps.PressHome(serial=serial_dev, critical=False)()

    if False in result:
        q.put(['OppTransferFile', 'Fail', result])
    else:
        q.put(['OppTransferFile', 'Pass'])
        # Teardown
    log.info("BT Opp transfer completed")
示例#6
0
                             ap_password=ddwrt_ap_pass)()
    prerequisites.run_prereq(serial=serial2,
                             pin="1234",
                             set_screen_lock=True,
                             require_pin_to_start_device=True,
                             set_wifi=True,
                             ap_name=ddwrt_ap_name,
                             ap_password=ddwrt_ap_pass)()

    #Enable Bluetooth tethering
    bluetooth_steps.BtSetTethering(serial=serial, state="ON", timeout=30000)()
    bluetooth_steps.BtSetTethering(serial=serial2, state="ON", timeout=30000)()

    bluetooth_steps.OpenBluetoothSettings(serial=serial, use_intent=True)()

    bluetooth_steps.BtChangeDeviceName(serial=serial, name=serial)()

    bluetooth_steps.OpenBluetoothSettings(serial=serial2, use_intent=True)()

    bluetooth_steps.BtChangeDeviceName(serial=serial2, name=serial2)()

    bluetooth_steps.WaitBtScanning(serial=serial)()

    bluetooth_steps.InitiatePairRequest(serial=serial,
                                        dev_to_pair_name=serial2,
                                        scan_max_attempts=5)()

    bluetooth_steps.PerformActionPairRequest(serial=serial)()
    bluetooth_steps.PerformActionPairRequest(serial=serial2)()

    bluetooth_steps.ConnectPairedDevices(serial=serial,
示例#7
0
    # ############ Actual Test ################
    # #########################################

    bluetooth_steps.LogInfo("##### ACTUAL TEST #####")()

    bluetooth_steps.OpenBluetoothSettings(serial=serial,
                                          use_intent=True,
                                          version=DUT_VERSION)()
    bluetooth_steps.ClickBluetoothSwitch(serial=serial,
                                         state="ON",
                                         version=DUT_VERSION)()
    bluetooth_steps.WaitBtScanning(serial=serial, version=DUT_VERSION)()

    bluetooth_steps.BtChangeDeviceName(serial=serial,
                                       name="",
                                       version=DUT_VERSION)()

finally:

    # ########### Postconditions ##############
    # #########################################

    bluetooth_steps.LogInfo("####### CLEANUP #######")()

    bluetooth_steps.StopPackage(serial=serial, critical=False)()
    bluetooth_steps.PressHome(serial=serial, critical=False)()
    bluetooth_steps.OpenBluetoothSettings(serial=serial,
                                          use_intent=True,
                                          version=DUT_VERSION,
                                          critical=False)()