def send_to_background_and_calculate_duration(self, duration):
    background_start_time = reporting.set_time_marker()

    interactions.send_app_to_background_for_a_duration(self, duration)
    background_end_time = reporting.set_time_marker()

    background_duration_in_seconds = reporting.get_duration_in_seconds(background_start_time, background_end_time)
    session_info.info_dict['background_duration_in_seconds'] = str(background_duration_in_seconds)

    return background_duration_in_seconds
def lock_and_calculate_duration(self, duration):
    lock_start_time = reporting.set_time_marker()

    interactions.lock_for_a_duration(self, duration)
    interactions.swipe_up(self)
    lock_end_time = reporting.set_time_marker()

    lock_duration_in_seconds = reporting.get_duration_in_seconds(lock_start_time, lock_end_time)
    session_info.info_dict['lock_duration_in_seconds'] = str(lock_duration_in_seconds)

    return lock_duration_in_seconds
Ejemplo n.º 3
0
def valid_session_conditional_helper(self, condition, session_type):
    interactions.wait(1)

    session_start_time = reporting.set_time_marker()
    session_info.info_dict['start_time'] = str(session_start_time)

    interactions.swipe_some_slides(self, 2, "left", 7)

    if condition == "swiping":
        pass

    elif condition == "locked":
        lock_duration = rules.lock_and_calculate_duration(self, 60)
        rules.dock_duration(lock_duration, 0)

    elif condition == "in_background":
        background_duration = rules.send_to_background_and_calculate_duration(
            self, 60)
        rules.dock_duration(0, background_duration)

    elif condition == "locked_and_in_background":
        lock_duration = rules.lock_and_calculate_duration(self, 60)
        interactions.swipe_some_slides(self, 2, "left", 7)
        background_duration = rules.send_to_background_and_calculate_duration(
            self, 60)
        rules.dock_duration(lock_duration, background_duration)

    elif condition == "thumbnails":
        rules.open_thumbnails_and_calculate_duration(self, 60, choice=None)

    interactions.wait(2)
    interactions.swipe_rest_of_slides(self, 3, "left", 7)
    interactions.wait(2)

    session_end_time = reporting.set_time_marker()
    session_info.info_dict['end_time'] = str(session_end_time)

    raw_duration_in_seconds = reporting.get_duration_in_seconds(
        session_start_time, session_end_time)
    session_info.info_dict['raw_duration_in_seconds'] = str(
        raw_duration_in_seconds)
    session_info.info_dict['duration_in_seconds'] = str(
        raw_duration_in_seconds)

    reporting.report_session(session_info.info_dict, session_type,
                             session_start_time)
def open_thumbnails_and_calculate_duration(self, duration, choice):
    thumbnails_start_time = reporting.set_time_marker()

    interactions.press(self, elements.thumbnails_btn)
    interactions.wait(duration)

    if duration > 300:
        answer_inactivity_prompt(self, duration, choice)
        interactions.wait(1)

    else:
        interactions.press(self, elements.thumbnails_btn)
        interactions.wait(1)

    thumbnails_end_time = reporting.set_time_marker()

    thumbnails_duration_in_seconds = reporting.get_duration_in_seconds(thumbnails_start_time, thumbnails_end_time)
    session_info.info_dict['thumbnails_duration_in_seconds'] = str(thumbnails_duration_in_seconds)
def valid_inactive_session_conditional_helper(self, condition, session_type,
                                              inactivity_duration,
                                              prompt_choice):
    interactions.wait(1)

    session_start_time = reporting.set_time_marker()
    session_info.info_dict['start_time'] = str(session_start_time)

    interactions.swipe_some_slides(self, 2, "left", 7)

    if condition == "swiping":
        swipe_and_answer_inactivity_prompt(self, inactivity_duration,
                                           prompt_choice)

    elif condition == "locked":
        interactions.swipe_rest_of_slides(self, 3, "left", 7)
        lock_duration = rules.lock_and_calculate_duration(
            self, inactivity_duration)
        rules.dock_duration(lock_duration, 0)
        rules.answer_inactivity_prompt(self, inactivity_duration,
                                       prompt_choice)

    elif condition == "in_background":
        interactions.swipe_rest_of_slides(self, 3, "left", 7)
        background_duration = rules.send_to_background_and_calculate_duration(
            self, inactivity_duration)
        rules.dock_duration(0, background_duration)
        rules.answer_inactivity_prompt(self, inactivity_duration,
                                       prompt_choice)

    elif condition == "locked_and_in_background":
        lock_duration = rules.lock_and_calculate_duration(
            self, inactivity_duration)
        rules.answer_inactivity_prompt(self, inactivity_duration, "cancel")

        interactions.swipe_some_slides(self, 2, "left", 7)

        background_duration = rules.send_to_background_and_calculate_duration(
            self, inactivity_duration)
        rules.dock_duration(lock_duration, background_duration)
        rules.answer_inactivity_prompt(self, inactivity_duration,
                                       prompt_choice)

        if prompt_choice == "cancel":
            interactions.swipe_rest_of_slides(self, 5, "left", 7)

    elif condition == "thumbnails":
        rules.open_thumbnails_and_calculate_duration(self, inactivity_duration,
                                                     prompt_choice)

        if prompt_choice == "cancel":
            interactions.wait(2)
            interactions.swipe_rest_of_slides(self, 3, "left", 7)

    elif condition == "crashed":
        interactions.swipe_rest_of_slides(self, 3, "left", 7)
        interactions.terminate_app(self)

    session_end_time = reporting.set_time_marker()
    session_info.info_dict['end_time'] = str(session_end_time)

    raw_duration_in_seconds = reporting.get_duration_in_seconds(
        session_start_time, session_end_time)
    session_info.info_dict['raw_duration_in_seconds'] = str(
        raw_duration_in_seconds)
    session_info.info_dict['duration_in_seconds'] = str(
        raw_duration_in_seconds)

    reporting.report_session(session_info.info_dict, session_type,
                             session_start_time)