Exemple #1
0
##############################################################################
#
# @filename:    .py
#
# @description: Install NotificationTrigger.apk which is needed by all
#               notification tests.
#
# @author:      [email protected]
#
##############################################################################

from testlib.scripts.android.adb import adb_steps
from testlib.scripts.android.adb import adb_utils
import os

import sys

from testlib.base.base_utils import get_args

globals().update(vars(get_args(sys.argv)))

adb_steps.connect_device(serial=serial, port=adb_server_port)()
globals().update({"version": adb_utils.get_android_version()})

apk_path = os.path.join(media_path, apks[0])

adb_steps.install_apk(print_error="Error - App was not installed",
                      blocking=False,
                      apk_path=apk_path)()
# Run Prerequisites
prerequisites.run_prereq(serial = serial,
                         pin = "1234",
                         set_wifi = True,
                         ap_name = "sp_gpt",
                         ap_password = "******")()

ui_steps.press_home(serial = serial)()
ui_steps.disable_options_from_developer_options(serial = serial,
                                                developer_options =
                                                ["Verify apps over USB"],
                                                blocking = True)()

# Install any application
adb_steps.install_apk(serial = serial, apk_path = widevine_apk)()

# Create a new user
ui_steps.create_new_user(serial = serial,
                         set_up_user = True,
                         user_name = "New user")()

# Check if user has access to Owner's application
ui_steps.find_app_from_allapps(serial = serial,
                               presence = False,
                               view_to_find = {"textContains": "ExoPlayer"})()

### Remake initial state #####
ui_steps.switch_user(serial = serial, user_name = "Owner")()
ui_steps.remove_user(serial = serial, user_name = "New user")()
Exemple #3
0
#                       --media-path /home/oane/Work/automation/\
#                       testlib/resources/apks/
#                       --apks com.shazam.android_408300.apk
#                       --script-args install-time=10000
#
#######################################################################

from testlib.scripts.android.adb import adb_steps
from testlib.scripts.android.ui import ui_steps
from testlib.scripts.file import file_steps
from testlib.base.base_utils import get_args
import sys
import time

globals().update(vars(get_args(sys.argv)))

adb_steps.connect_device(serial=serial, port=adb_server_port)()

args = {}
for entry in script_args:
    key, val = entry.split("=")
    args[key] = val

if "install-time" in args:
    install_time = int(args["install-time"])
else:
    install_time = None

adb_steps.install_apk(apk_path=media_path + apks[0],
                      install_time=install_time)()
                         ap_name="sp_gpt",
                         ap_password="******")()

ui_steps.press_home(serial=serial)()
ui_steps.disable_options_from_developer_options(
    serial=serial, developer_options=["Verify apps over USB"], blocking=True)()

if adb_utils.is_prop_set(serial=serial,
                         prop="ro.board.platform",
                         value="sofia_lte"):
    adb_steps.provision_sofia(serial=serial,
                              wvkeyboxtool=wvkeyboxtool,
                              keybox=keybox)()

# Install ExoPlayer
adb_steps.install_apk(serial=serial, apk_path=widevine_apk, blocking=True)()

# Check if video plays
ui_steps.close_app_from_recent(serial=serial,
                               view_to_find={"textContains": "ExoPlayer"},
                               blocking=True)()

ui_steps.open_app_from_allapps(serial=serial,
                               view_to_find={"textContains": "ExoPlayer"})()

# Scroll down to Widevine video
ui_steps.scroll_up_to_view(
    serial=serial,
    ey=200,
    view_to_check={"textContains": "WV: HDCP not specified"})()
ui_steps.click_button(serial=serial,
Exemple #5
0
def run_test(apk, serial, port, log_dir, log_file):

    # we need STDOUT ant STDERR to both STDOUT and to a file
    log_out_err_file = log_stdout_stderr(log_file)

    adb_connection = connection_adb(serial=serial, port=port)

    # start monitoring
    mon = monitor(adb_connection=adb_connection, apk=apk, results_path=log_dir)

    time.sleep(2)

    # install apk
    apk_path = os.path.join(APKS_PATH, apk)
    adb_steps.install_apk(apk_path=apk_path, install_time=120)()

    # monitor
    mon()

    print "TC-1"
    print "Start App - Home Screen - App"
    apk_path = os.path.join(APKS_PATH, apk)
    apk_label = get_app_label_from_apk(apk_path)
    apk_package = get_package_name_from_apk(apk_path)
    print apk_path
    print apk_label
    print apk_package

    command = "python homescreen_and_back.py --serial {0} --script-args app-to-test=\'{1}\' wait-time=2000 host-path={2}".format(
        serial, apk_label, log_dir)
    print command
    subp = subprocess.Popen(command.split(),
                            stdout=subprocess.PIPE,
                            stderr=subprocess.PIPE)
    ########### T OD SPLIT ###################
    get_output(subp)
    # monitor
    mon()
    time.sleep(2)

    print "TC-2"
    print "Start App - Start Another App - App"
    apk_path = os.path.join(APKS_PATH, apk)
    apk_label = get_app_label_from_apk(apk_path)
    command = "python app_and_back.py --serial {0} --script-args app-to-test={1} wait-time=2000 app-to-open=Calculator host-path={2}".format(
        serial, apk_label, log_dir)
    subp = subprocess.Popen(command.split(),
                            stdout=subprocess.PIPE,
                            stderr=subprocess.PIPE)
    get_output(subp)
    # monitor
    mon()
    time.sleep(2)

    print "TC-3"
    print "Start App - Rotate"
    apk_path = os.path.join(APKS_PATH, apk)
    apk_label = get_app_label_from_apk(apk_path)
    command = "python rotate_and_back.py --serial {0} --script-args app-to-test={1} wait-time=2000 host-path={2}".format(
        serial, apk_label, log_dir)
    subp = subprocess.Popen(command.split(),
                            stdout=subprocess.PIPE,
                            stderr=subprocess.PIPE)
    get_output(subp)
    # monitor
    mon()
    time.sleep(2)

    print "TC-5"
    print "Start App - Go through the objects tree"
    apk_path = os.path.join(APKS_PATH, apk)
    apk_label = get_app_label_from_apk(apk_path)

    # record
    remote_path = "/data/local/tmp/record.mp4"
    cmd = 'screenrecord --time-limit {0} {1}'.format(30, remote_path)
    record_p = adb_connection.run_cmd(cmd, mode='async')

    command = "python view_tree.py --serial {0} --script-args app-to-test={1} wait-time=2000".format(
        serial, apk_label)
    subp = subprocess.Popen(command.split(),
                            stdout=subprocess.PIPE,
                            stderr=subprocess.PIPE)
    get_output(subp)

    time.sleep(1)
    while record_p.poll() is None:
        pass
    adb_steps.pull_file(log_dir, remote_path)
    # monitor
    mon()

    print "TC-6"
    print "Assisted Monkey"
    apk_path = os.path.join(APKS_PATH, apk)
    apk_label = get_app_label_from_apk(apk_path)
    command = "python assisted_monkey.py --serial {0} --script-args app-to-test={1} wait-time=2000".format(
        serial, apk_label)
    subp = subprocess.Popen(command.split(),
                            stdout=subprocess.PIPE,
                            stderr=subprocess.PIPE)
    get_output(subp)
    # monitor
    mon()
    time.sleep(2)

    print "TC-7"
    print "Monkey"
    cmd = "monkey -p {0} --throttle 1000 --pct-motion 60 --pct-touch 40 300".format(
        apk_package)
    p_monkey = adb_connection.run_cmd(cmd, timeout=240)
    # monitor
    mon()
    time.sleep(2)

    print "TC-4"
    print "Start App - Sleep"
    apk_path = os.path.join(APKS_PATH, apk)
    apk_label = get_app_label_from_apk(apk_path)
    command = "python sleep_and_back.py --serial {0} --script-args app-to-test={1} wait-time=2000 sleep-time=10000 host-path={2}".format(
        serial, apk_label, log_dir)
    subp = subprocess.Popen(command.split(),
                            stdout=subprocess.PIPE,
                            stderr=subprocess.PIPE)
    get_output(subp)
    # monitor
    mon()
    time.sleep(2)

    del mon
    log_out_err_file.close()