Esempio n. 1
0
def set_device_theme(dname, theme_type, number=0):
    """
    SET theme accroding to configration theme path in advance
    :param dname: device uid
    :param theme_type:  VLIFE OR SYSTEM
    :return: NONE
    """

    # log in theme app like i theme
    activity_name = theme_config.getValue(dname, 'set_theme_pkg')
    #DEVICE = device.Device(dname)
    #DEVICE.app_operation(action='LAUNCH', pkg=activity_name)
    DEVICE = adbtools.AdbTools(dname)
    #DEVICE.start_application(activity_name)
    find_text = [u'忽略本次']
    try:
        threads = []
        install_app = threading.Thread(target=DEVICE.start_application(),
                                       args=(activity_name, ))
        proc_process = threading.Thread(target=DEVICE.do_popup_windows,
                                        args=(5, find_text))
        threads.append(proc_process)
        threads.append(install_app)
        for t in threads:
            t.setDaemon(True)
            t.start()
            sleep(2)
        t.join()
    except Exception, ex:
        print ex
Esempio n. 2
0
def run(dname, loop, rtype):

    global DEVICENAME, DEVICE, LogPath
    global LOOP_NUM, RESULT_DICT, FAIL_CASE, RUN_ID

    DEVICENAME = dname
    DEVICE = adbtools.AdbTools(DEVICENAME)

    # run test case
    logname = desktop.get_log_name(dname, 'TestVivoBasicUI')
    LogPath = os.path.dirname(os.path.abspath(logname))
    utest_log = os.path.join(LogPath, 'unittest.html')

    # ##RESULT_DICT format {casename:{Result:['PASS','PASS'],Log:['','']}}#####
    RESULT_DICT = {}
    FAIL_CASE = []

    try:
        # insert run info to database

        vname = device_config.getValue(dname, 'version')
        RUN_ID = tc.insert_runinfo(17, dname, vname, loop, rtype)

        # start to test
        for LOOP_NUM in range(loop):

            fileobj = file(utest_log, 'a+')
            if LOOP_NUM == 0 or rtype.upper() == 'ALL':
                suite = unittest.TestLoader().loadTestsFromTestCase(
                    TestVivoBasicUI)
            else:
                suite = unittest.TestSuite()
                for name in FAIL_CASE:
                    suite.addTest(TestVivoBasicUI(name))
                FAIL_CASE = []

            if suite.countTestCases() > 0:

                runner = HTMLTestRunner.HTMLTestRunner(
                    stream=fileobj,
                    verbosity=2,
                    loop=LOOP_NUM,
                    title='VivoBasicUI Testing Report',
                    description='Test Result',
                )
                runner.run(suite)
                fileobj.close()
                sleep(5)
            # write log to summary report
            if LOOP_NUM == loop - 1:
                desktop.summary_result(utest_log, True, RESULT_DICT)
            else:
                desktop.summary_result(utest_log, False, RESULT_DICT)

    except Exception, ex:
        print ex
Esempio n. 3
0
def magazine_task_init_resource(dname, parameter):

    device = adbtools.AdbTools(dname)

    if parameter.upper() == 'SYSTEM':
        device.set_magazine_keyguard(False)
    else:
        #set_security_magazine_switch(dname, 'ON')
        device.set_magazine_keyguard(True)
        # start main process using start magazine apk or the third party app
        set_magazine_app_switch(dname, 'ON')
Esempio n. 4
0
    newParser = argparse.ArgumentParser()
    newParser.add_argument("uid", help="Your device uid")
    newParser.add_argument("-l",
                           "--ln",
                           dest="lnum",
                           default=1,
                           type=int,
                           help="Loop number")
    args = newParser.parse_args()
    uid = args.uid
    loop_number = args.lnum
    if uid is None:
        sys.exit(0)

    device = adbtools.AdbTools(uid)
    # verify if device is connected
    devices = device.get_devices()
    if uid not in devices:
        print "Device is not connected, please check"
        sys.exit(0)

    test_paths = module_config.getValue('SHELL_MODULE',
                                        'orig_shell_path').split(';')

    for tp in test_paths:
        index = test_paths.index(tp)
        logger.debug('***key step***:Start to test ========PATH_' + str(index))
        loop_result = []
        for i in range(loop_number):
            logger.debug('***key step***:========LOOP_' + str(i))
Esempio n. 5
0
    newParser.add_argument("uid", help="Your device uid")
    newParser.add_argument("slist", help="Suite List")
    newParser.add_argument("-l", "--ln", dest="lnum", default=1, type=int, help="Loop number")
    newParser.add_argument("-t", "--lt", dest="ltype", default='Only_Fail', type=str, help="Loop type")

    args = newParser.parse_args()
    uid = args.uid
    loop_number = args.lnum
    loop_type = args.ltype
    suite_list = args.slist

    if uid is None or suite_list is None:
        sys.exit(0)

    # verify if device is connected
    device_conn = adbtools.AdbTools()
    devices = device_conn.get_devices()
    if uid not in devices:
        print "Device is not connected, please check"
        sys.exit(0)

    try:
        # automation test database
        from testcases import test_tasks_new
        test_tasks_new.run(uid, loop_number, loop_type)
        # from testcases import monitor_memory_cpu
        # monitor_memory_cpu.run(uid, loop_number, loop_type)
        from testcases import test_module_update
        test_module_update.run(uid, loop_number, loop_type)
        from testcases import vivo_basic_ui
        vivo_basic_ui.run(uid, loop_number, loop_type)
Esempio n. 6
0
import argparse
from testcases import test_performance
from library import adbtools
from library.myglobal import performance_config

if __name__ == '__main__':

    # func_list = get_kw_list()

    newParser = argparse.ArgumentParser()

    newParser.add_argument("uid", help="Your device uid")

    args = newParser.parse_args()
    uid = args.uid

    devices = adbtools.AdbTools(uid).get_devices()
    if uid not in devices:
        print "Device is not connected, please check"
        sys.exit(0)

    try:
        loop = performance_config.getValue(uid, 'loop')
        process_name = performance_config.getValue(uid, 'app_process_name')
        case_list = performance_config.getValue(uid, 'case_list').split(';')
        case_exe = test_performance.CaseExecutor(int(loop), uid)
        case_exe.exec_test_cases(case_list)

    except Exception, ex:
        print ex