Esempio n. 1
0
def get_sent_received_count(serial=None, share_type="Sent", count_successful=True, count_unsuccessful=False,
                            notif_menu_already_opened=False, **kwargs):
    """ Description:
            Swipes down to open the notification bar and gets the current number of successful or
            unsuccessful OPP file transfers. If no Sent/Received notification is found, it
            returns 0 as files count, otherwise it returns the found number.
            If count_successful=True, then it returns the value of the successful transfers
            If count_unsuccessful=True, then it returns the value of the successful transfers
            If the notification menu is already opened, set notif_menu_already_opened to True
        Usage:
            count_value = bt_utils.get_sent_received_count(serial=device_serial,
                                    share_type=Received/Sent, count_successful=bool,
                                    count_unsuccessful=bool, notif_menu_already_opened=False)()
    :param serial: serial of the device
    :param share_type: "Sent"/"Received" share type to count in notification menu
    :param count_successful: True to count successful transfers
    :param count_unsuccessful: True to count unsuccessful transfers
    :param notif_menu_already_opened: True, it assumes that the notification menu is already opened
    :param kwargs: timeout, version, no_log and standard kwargs for base_step
    """

    # ### initiate all required vars, according to params ###

    uidevice = Device(serial=serial)

    if share_type is "Sent":
        notification_title = "Bluetooth share: Sent files"
    elif share_type is "Received":
        notification_title = "Bluetooth share: Received files"
    else:
        raise Exception("Config error, not any of expected value for share_type")

    # ### call here all the required steps ###

    if not notif_menu_already_opened:
        bluetooth_steps.OpenNotificationsMenu(serial=serial, **kwargs)()

    notification = uidevice(resourceId="android:id/notification_main_column").child(
            textContains=notification_title)
    if notification.wait.exists(timeout=1000):
        file_count = bluetooth_steps.BtOppGetNotificationNumberUpdate(serial=serial,
                                                                      share_type=share_type,
                                                                      count_successful=count_successful,
                                                                      count_unsuccessful=count_unsuccessful,
                                                                      notif_menu_already_opened=True, **kwargs)()
    else:
        file_count = 0

    if not notif_menu_already_opened:
        time.sleep(1)
        bluetooth_steps.CloseNotificationsMenu(serial=serial, **kwargs)()

    # ### return computed value ###
    return file_count
Esempio n. 2
0
        share_type='Received',
        count_successful=False,
        count_unsuccessful=True,
        notif_menu_already_opened=True,
        version=DUT_VERSION,
        blocking=True)
    count_successful_received_initial = bt_utils.get_sent_received_count(
        serial=serial,
        share_type='Received',
        count_successful=True,
        count_unsuccessful=False,
        notif_menu_already_opened=True,
        version=DUT_VERSION,
        blocking=True)
    bluetooth_steps.CloseNotificationsMenu(serial=serial,
                                           version=DUT_VERSION,
                                           blocking=True)()

    bluetooth_steps.CheckBtVisibility(serial=serial,
                                      version=DUT_VERSION,
                                      blocking=True)()

    # ############### Test ####################
    # #########################################

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

    # send a file from dev to dut

    bluetooth_steps.NavigateToFileInPhotos(serial=serial_dev,
                                           local_folder_name=PHOTO_PATH,