Beispiel #1
0
def flash_a_device(device, db_props, env_props):

    build_number = SP_IMG_PATH.split("-")[-1].split(".")[0]
    image_path = SP_IMG_PATH

    adb_steps.connect_device(serial=device["ip"] + ":5555",
                             port=device["adb_port"])()

    repair_steps.flash_device(print_error="Device could not be flashed!",
                              ip=device["ip"],
                              image_path=image_path,
                              build_number=build_number)()

    repair_steps.after_repair_operations(db_prop_list=db_props,
                                         env_prop_list=env_props,
                                         ip=device["ip"])()
Beispiel #2
0
    def do(self):
        adb_steps.root_connect_device(serial=self.serial)()
        device_prepair_for_repair(serial=self.serial,
                                  image_path=self.image_path,
                                  blocking=True)()

        adb_steps.reboot(serial=self.serial,
                         blocking=True,
                         reboot_timeout=600,
                         command="recovery")()
        ssh_repair(ip=self.ip, blocking=True)()

        adb_steps.kill_server(serial=self.serial, blocking=True)()
        adb_steps.connect_device(serial=self.serial, blocking=True,
                                 timeout=50)()
        adb_steps.root_connect_device(serial=self.serial, blocking=True)()
Beispiel #3
0
#                   is displayed as expected
#               Will check if apps displayed on screen are sorted
#                   alphabetically.
# @author:      [email protected]
#
##############################################################################

from testlib.scripts.android.ui.interface import steps
from testlib.scripts.android.ui import ui_steps
from testlib.scripts.android.adb import adb_steps
from testlib.scripts.android.adb import adb_utils

from testlib.base.base_utils import get_args
import sys

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()})

ui_steps.press_home()()

ui_steps.press_all_apps(print_error="Error - The connection to the device "
                        "was not established",
                        blocking=True)()
steps.check_apps_are_sorted(print_error="Error - Apps are not sorted in "
                            "android all apps screen.",
                            version=version)()

ui_steps.press_home()()
Beispiel #4
0
import sys

from testlib.scripts.android.adb import adb_steps
from testlib.scripts.android.ui import ui_steps
from testlib.scripts.gms.Gmail import gmail_steps
from testlib.scripts.gms import gms_utils

from testlib.base.base_utils import get_args
from testlib.scripts.android.adb import adb_utils
from testlib.utils.ui.uiandroid import UIDevice as ui_device

args = get_args(sys.argv)
globals().update(vars(args))
globals().update(eval(script_args[0]))
adb_steps.connect_device(serial=serial)()
globals().update({"version": adb_utils.get_android_version()})

uidevice = ui_device(serial=serial)

ui_steps.close_app_from_recent(serial = serial,\
                view_to_find = {"text": "Sheets"})()

if (gms_utils.get_google_account_number(serial=serial) == 0):
    ui_steps.add_google_account_for_L(serial = serial,version = "L",\
                 account = account,
                 password = password)()
if (gms_utils.get_google_account_number(serial=serial) > 1):
    ui_steps.remove_all_google_accounts(serial=serial)()
    ui_steps.add_google_account_for_L(serial = serial,version = "L",\
                 account = account,
Beispiel #5
0
#!/usr/bin/env python

#######################################################################
#
# @filename:    Bluetooth_Power_OFF_Settings.py
# @description: Tests if Bluetooth module is turned off when disabling it
#                  from the Settings application menu
# @author:      [email protected]
#
#######################################################################

import sys
from testlib.scripts.wireless.bluetooth import bluetooth_steps_old
from testlib.scripts.android.adb import adb_steps
from testlib.scripts.android.ui import ui_steps

adb_steps.connect_device(serial = sys.argv[1] + ":5555")()

###############################################################
# Turn the bluetooth module off from the Settings app
###############################################################
bluetooth_steps_old.set_from_settings(state = "OFF")()

###############################################################
# Reset the system to initial status
###############################################################
ui_steps.press_home()()
Beispiel #6
0
    fastboot_utils.download_file(url=conf_url,
                                 local_filename="./temp/fastboot.conf")
    config = ConfigParser.ConfigParser()
    config.read("./temp/fastboot.conf")
    fastboot_path = config.get("fastboot", "path")

    test_apk_path = config.get("files", "test_apk")
    test_apk_name = test_apk_path.split("/")[-1]
    fastboot_utils.download_file(url=fastboot_path + test_apk_path,
                                 local_filename="./temp/files/resources/" +
                                 test_apk_name)

    fastboot_utils.push_uiautomator_jar(serial=serial)  # noqa
    fastboot_steps.config_first_boot_wizard(serial=serial)()  # noqa

    adb_steps.connect_device(serial=serial)()  # noqa
    adb_steps.root_connect_device(serial=serial)()  # noqa
    time.sleep(5)
    platform_name = fastboot_utils.get_platform_name(serial=serial)  # noqa
    install_command = "adb -s {0} install ./temp/files/resources/{1}  > ./temp/files/temp.txt 2>&1".format(
        serial, test_apk_name)  # noqa
    os.system(install_command)
    return_result = fastboot_utils.adb_install_apk(
        platform_name=platform_name, file_path="./temp/files/temp.txt")

    if not return_result:
        raise Exception("The test result did not achieve the desired results")

    fastboot_steps.factory_data_reset(serial=serial)()  # noqa
    adb_steps.connect_device(serial=serial)()  # noqa
    adb_steps.root_connect_device(serial=serial)()  # noqa
#!/usr/bin/env python

#######################################################################
#
# @filename:    test_03_sp_update_boot_loader_prefs.py
# @description: Checks sp_update_boot_loader_prefs is available on DUT
# @author:      [email protected]
#
#######################################################################

from testlib.scripts.android.adb import adb_steps

import sys

adb_steps.connect_device(serial=sys.argv[1] + ":5555", port=sys.argv[2])()

adb_steps.command(command="ls /system/bin/sp_update_boot_loader_prefs",
                  stdout_grep="/system/bin/sp_update_boot_loader_prefs",
                  stdout_not_grep="No such file or directory",
                  blocking=False)()
Beispiel #8
0
def pnp_runner(unique_id, machine_ip, adb_port):

    ############################################################################
    # Set env. variables for adb -P commands
    ############################################################################
    os.environ["ADB_PORT"] = sys.argv[3]
    os.environ['ANDROID_ADB_SERVER_PORT'] = str(sys.argv[3])

    ############################################################################
    # Set runner parameters
    ############################################################################
    runnerini = "./{0}runner.ini".format(unique_id)

    adb_handler = adb_steps.connect_device(
        serial="{0}:5555".format(machine_ip), port=adb_port)
    adb_connection = adb_handler.adb_connection
    adb_handler()

    query = 'update `machines` set status=2,last_update=now() where ip="{0}"'.format(
        machine_ip)
    pnp_utils.run_query(query)

    next_test = pnp_utils.decide_next_test(adb_connection)
    pnp_utils.set_next_test(runnerini, machine_ip, next_test)
    runner_props = pnp_utils.set_runner_props(runnerini)

    if runner_props["benchmark"] == "Antutu":
        result = pnp_steps.antutu(local_port=(int(adb_port) + 1000),
                                  port=adb_port,
                                  serial=runner_props["serial"],
                                  benchmark=runner_props["benchmark"],
                                  test_case=runner_props["test"])()
    elif runner_props["benchmark"] == "Quadrant":
        result = pnp_steps.quadrant(local_port=(int(adb_port) + 1000),
                                    port=adb_port,
                                    serial=runner_props["serial"],
                                    benchmark=runner_props["benchmark"],
                                    test_case=runner_props["test"])()
    elif runner_props["benchmark"] == "3D Mark":
        result = pnp_steps.threedmark(local_port=(int(adb_port) + 1000),
                                      port=adb_port,
                                      serial=runner_props["serial"],
                                      benchmark=runner_props["benchmark"],
                                      test_case=runner_props["test"])()
    elif runner_props["benchmark"] == "GL Benchmark":
        result = pnp_steps.glbenchmark(local_port=(int(adb_port) + 1000),
                                       port=adb_port,
                                       serial=runner_props["serial"],
                                       benchmark=runner_props["benchmark"],
                                       test_case=runner_props["test"])()
    elif runner_props["benchmark"] == "Flash":
        result = pnp_steps.pnp_flasher(local_port=(int(adb_port) + 1000),
                                       port=adb_port,
                                       serial=runner_props["serial"],
                                       benchmark=runner_props["benchmark"],
                                       test_case=runner_props["test"])()
    query = 'update `machines` set status=1,retries=0 where ip="{0}"'.format(
        machine_ip)
    pnp_utils.run_query(query)

    for k, r in result.iteritems():
        if runner_props["benchmark"] == "3D Mark":
            runner_props["benchmark"] = runner_props["test"]
        build_specific = pnp_utils.get_report_details(
            adb_connection, runner_props["benchmark"], k, r, "t100",
            runner_props["serial"])
        query = pnp_utils.create_push_result_query("measurements_test",
                                                   build_specific)
        pnp_utils.run_query(query)
Beispiel #9
0
    def do(self):

        ui_steps.open_quick_settings(
            print_error="Error - Quick settings page as not displayed")()

        if self.verbose:
            print bluetooth_utils.check_airplane_mode_on()

        if bluetooth_utils.check_airplane_mode_on() == self.state:
            if self.state == "0":
                ui_steps.press_home()()
                ui_steps.open_settings()()
            ui_steps.open_app_from_settings(
                view_to_find={"text": "Bluetooth"},
                view_to_check={"description": "Bluetooth, Navigate up"})()
            Bluetooth_state = bluetooth_utils.get_switch_state(self)

        if Bluetooth_state == "OFF":
            if self.verbose:
                print ">>> Bluetooth is already OFF, enabling it first"
                bluetooth_set_from_status_bar(state="ON")()

            if self.verbose:
                print ">>> Airplane mode is already in the required state, inverting it first..."
        ui_steps.open_quick_settings(
            print_error="Error - Quick settings page as not displayed")()
        ui_steps.click_button(print_error="Error - Airplane Mode not found",
                              view_to_find={"text": "Airplane mode"})()
        time.sleep(10)
        adb_steps.connect_device(serial=sys.argv[1] + ":5555")()

        if self.state == "1":
            ui_steps.press_home()()
            ui_steps.open_settings()()
        ui_steps.open_app_from_settings(
            view_to_find={"text": "Bluetooth"},
            view_to_check={"description": "Bluetooth, Navigate up"})()
        Bluetooth_state = bluetooth_utils.get_switch_state(self)

        if Bluetooth_state == "OFF":
            if self.verbose:
                print ">>> Bluetooth is already OFF, enabling it first"
                bluetooth_set_from_status_bar(state="ON")()

        if self.state == "0":
            ui_steps.press_home()()
            ui_steps.open_settings()()
            ui_steps.open_app_from_settings(
                view_to_find={"text": "Bluetooth"},
                view_to_check={"description": "Bluetooth, Navigate up"})()
        Bluetooth_state = bluetooth_utils.get_switch_state(self)

        if Bluetooth_state == "ON":
            if self.verbose:
                print ">>> Bluetooth radio is enabled whereas Flight Mode is active, disabling then enabling again Flight Mode to reset Bluetooth radio state..."
                ui_steps.open_quick_settings(
                    print_error="Error - Quick settings page as not displayed"
                )()
            ui_steps.click_button(
                print_error="Error - Airplane Mode not found",
                view_to_find={"text": "Airplane mode"})()
            ui_steps.open_quick_settings(
                print_error="Error - Quick settings page as not displayed")()
            ui_steps.click_button(
                print_error="Error - Airplane Mode not found",
                view_to_find={"text": "Airplane mode"})()

        ui_steps.open_quick_settings(
            print_error="Error - Quick settings page as not displayed")()
        ui_steps.click_button(print_error="Error - Airplane Mode not found",
                              view_to_find={"text": "Airplane mode"})()
        time.sleep(10)
        adb_steps.connect_device(serial=sys.argv[1] + ":5555")()

        if self.state == "0":
            ui_steps.press_home()()
            ui_steps.open_settings()()
            ui_steps.open_app_from_settings(
                view_to_find={"text": "Bluetooth"},
                view_to_check={"description": "Bluetooth, Navigate up"})()
            Bluetooth_state = bluetooth_utils.get_switch_state(self)

        if Bluetooth_state == "OFF":
            if self.verbose:
                print ">>> Bluetooth radio stays OFF whereas Flight Mode has been deactivated, checking if not a special case..."
                bluetooth_set_from_status_bar(state="ON")()
            ui_steps.open_quick_settings(
                print_error="Error - Quick settings page as not displayed")()
            ui_steps.click_button(
                print_error="Error - Airplane Mode not found",
                view_to_find={"text": "Airplane mode"})()
            time.sleep(10)
        adb_steps.connect_device(serial=sys.argv[1] + ":5555")()
        ui_steps.open_quick_settings(
            print_error="Error - Quick settings page as not displayed")()
        ui_steps.click_button(print_error="Error - Airplane Mode not found",
                              view_to_find={"text": "Airplane mode"})()
        time.sleep(10)
Beispiel #10
0
PAIRING_DEV = script_args[0]
DUT_NAME = 'DUT'
PAIRING_DEV_NAME = 'Smartphone'
BLUETOOTH_PATH = '/storage/emulated/0/bluetooth/'
PHOTO_URL = 'http://www.mobileworldmag.com/wp-content/uploads/2013/11/' \
            'intel-logo.jpg'
PHOTO_NAME = 'intel-logo.jpg'
PHOTO_PATH = 'storage/emulated/0/DCIM/'
REFRESH_MEDIA_COMMAND = 'am broadcast -a android.intent.action.MEDIA_MOUNTED'\
                        ' -d file:///'

########### Preconditions ###############
#########################################

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

adb_steps.connect_device(
    serial=PAIRING_DEV,
    local_port=adb_server_port,
)()

bluetooth_steps_old.bt_change_device_name(serial=serial,
                                          port=adb_server_port,
                                          name=DUT_NAME)()
bluetooth_steps_old.bt_make_discoverable(serial=serial,
                                         port=adb_server_port,
                                         name=DUT_NAME)()

bluetooth_steps_old.bt_change_device_name(serial=PAIRING_DEV,
Beispiel #11
0
def ftp_download_file(serial, condition, event, mode='bg', security='none',
                      ddwrt_ap_name='ddwrt', ddwrt_ap_pass='******',
                      encryption=None, file_name='generated.bin',
                      file_size=102400, protocol='ftp', port_number='20211',
                      dut_security=None, conf_security='NONE',
                      compare_method='md5', adb_server_port='5037',
                      iteration=1,
                      q=None):
    result = []
    try:
        platform = statics.Device(serial=serial)

        adb_steps.connect_device(serial=serial, port=adb_server_port)()
        for _ in range(0, iteration):
            if iteration > 1:
                log.info("Ftp download: Iteration #{}".format(_ + 1))
            if priority == 'wifi' and _ == 0:
                # print 'wifi 1st event wait'
                # print e.is_set()
                event.wait(CONDITION_EVENT_TIMEOUT)
                event.clear()
            elif not priority == 'toggle':
                # print 'wifi 1st event set'
                event.set()

            if _ == 0:
                with condition:
                    if priority == 'bt' and _ == 0:
                        condition.wait(CONDITION_EVENT_TIMEOUT)
                    if not connect_to_ap(serial, condition):
                        raise Exception("Not able to connect to AP")

                    # generate URL
                    (URL, IP) = wifi_generic_steps.create_download_url(
                        file_name, file_size, local_path=".", protocol=protocol,
                        port=port_number, serial=serial)()
                    if priority == 'wifi' and _ == 0:
                        # print 'Notify wifi process'
                        condition.notify()

            # print 'Notified after creating url'
            if priority == 'wifi' and _ == 0:
                # print e.is_set()
                # print 'wifi 2nd event wait'
                event.wait(CONDITION_EVENT_TIMEOUT)
            elif not priority == 'toggle':
                # print 'wifi 2nd event set'
                event.set()

            wifi_instance = None
            with condition:
                if priority == 'bt' and _ == 0:
                    condition.wait(CONDITION_EVENT_TIMEOUT)
                # start download
                wifi_instance = wifi_generic_steps.download_file(URL, file_name,
                                                                 file_size,
                                                                 protocol,
                                                                 serial=serial,
                                                                 check_file_downloaded=False)
                wifi_instance()

                if priority == 'wifi' and _ == 0:
                    condition.notify()

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

            # This notify bt operation to start validating receiving file as
            #  this should not happen parallel to wifi download as both
            # rely on UI
            if initiator == "dev" and priority == "bt" and _ == 0:
                event.set()

            wifi_instance.check_file_downloaded = True
            if wifi_instance.check_condition():
                # check download integrity
                if wifi_generic_steps.check_file_integrity(mode=compare_method,
                                                           local_file=file_name,
                                                           serial=serial,
                                                           remote_file=platform.download_path + file_name)():
                    result.append('Pass')
                    log.info("Download file is completed")
                else:
                    raise Exception('File integrity check failed')
            else:
                raise Exception("Error during FTP Download")
            #q.put(['WifiDownloadFile', True])
    except Exception:
        log.error(Exception.message)
        log.error(traceback.format_exc())
        result.append('Fail')
    except:
        log.error('FtpDownloadFile: Unexpected Error')
        log.error(traceback.format_exc())
        result.append('Fail')

    if False in result:
        q.put(['FtpDownloadFile', 'Fail', result])
    else:
        q.put(['FtpDownloadFile', 'Pass'])

    log.info("Wifi Ftp download completed")
Beispiel #12
0
 def do(self):
     adb_steps.connect_device(serial=self.serial, port=self.port)()
     adb_steps.root_connect_device(serial=self.serial, port=self.port)()
     adb_steps.reboot(serial=self.serial, port=self.port)()
     pnp_utils.wait_for_cooldown(self.adb_connection, "t100")