Beispiel #1
0
    def _run_maxim(run, cases, command, actions, widget_black):
        log = Log()
        log.set_logger(run.get_device()['model'],
                       os.path.join(run.get_path(), 'client.log'))
        log.i('udid: %s', run.get_device()['udid'])

        # set cls.path, it must be call before operate on any page
        path = ReportPath()
        path.set_path(run.get_path())

        # set cls.driver, it must be call before operate on any page
        base_page = BasePage()
        if 'ip' in run.get_device():
            base_page.set_driver(run.get_device()['ip'])
        else:
            base_page.set_driver(run.get_device()['serial'])

        try:
            # run cases
            base_page.d.shell('logcat -c')  # 清空logcat
            if cases:
                run.run_cases(cases)
            Maxim().run_monkey(monkey_shell=command,
                               actions=actions,
                               widget_black=widget_black)

            base_page.d.shell('logcat -d > /sdcard/logcat.log')
            time.sleep(1)
            base_page.d.pull('/sdcard/logcat.log',
                             os.path.join(path.get_path(), 'logcat.log'))
            base_page.d.pull('/sdcard/monkeyerr.txt',
                             os.path.join(path.get_path(), 'monkeyerr.txt'))
            base_page.d.pull('/sdcard/monkeyout.txt',
                             os.path.join(path.get_path(), 'monkeyout.txt'))

            base_page.set_original_ime()
            base_page.identify()
            if 'ip' in run.get_device():
                log.i('release device %s ' % run.get_device()['serial'])
                atxserver2().release_device(run.get_device()['serial'])

        except AssertionError as e:
            log.e('AssertionError, %s', e)
Beispiel #2
0
    def _run_cases(run, cases, retry, save_last_try):
        log = Log()
        log.set_logger(run.get_device()['model'],
                       run.get_path() + '/' + 'client.log')
        log.i('udid: %s' % run.get_device()['udid'])

        # set cls.path, it must be call before operate on any page
        path = ReportPath()
        path.set_path(run.get_path())

        # set cls.driver, it must be call before operate on any page
        base_page = BasePage()
        if 'ip' in run.get_device():
            base_page.set_driver(run.get_device()['ip'])
        else:
            base_page.set_driver(run.get_device()['serial'])

        try:
            # print(run.get_device())
            # 运行前准备
            base_page.unlock_device()
            base_page.set_fastinput_ime()  # 设置fastime输入法
            # base_page.d.shell('logcat -c')  # 清空logcat
            # 开始执行测试
            run.run(cases, retry, save_last_try)

            # 结束后操作
            base_page.unwatch_device()
            base_page.set_original_ime()

            # 将logcat文件上传到报告
            # base_page.d.shell('logcat -d > /sdcard/logcat.log')
            # time.sleep(2)
            # base_page.d.pull('/sdcard/logcat.log', os.path.join(path.get_path(), 'logcat.log'))

            if 'ip' in run.get_device():
                log.i('release device %s ' % run.get_device()['serial'])
                atxserver2().release_device(run.get_device()['serial'])

        except AssertionError as e:
            log.e('AssertionError, %s' % e)
Beispiel #3
0
        cls.d.shell('rm -r /sdcard/monkeyerr.txt')
        cls.d.shell('rm -r /sdcard/monkeyout.txt')
        log.i('Clear monkey env success')

    @classmethod
    def set_AdbIME(cls):
        log.i('setting AdbIME as default')
        ime = cls.d.shell('ime list -s').output
        if 'adbkeyboard' in ime:
            cls.d.shell('ime set com.android.adbkeyboard/.AdbIME')
        else:
            cls.local_install(os.path.join(maxin_path, 'ADBKeyBoard.apk'))
            cls.d.shell('ime enable com.android.adbkeyboard/.AdbIME')
            cls.d.shell('ime set com.android.adbkeyboard/.AdbIME')
            log.i('install adbkeyboard and set as default')
        cls.push_string()


if __name__ == '__main__':
    log.set_logger('udid', './log.log')
    maxim = Maxim()
    maxim.set_driver(None)
    command = maxim.command(package='com.quvideo.xiaoying',
                            runtime=2,
                            mode='uiautomatormix',
                            throttle=100,
                            options=' -v -v ',
                            whitelist=True,
                            off_line=True)
    maxim.run_monkey(command)