示例#1
0
def qidongapp():
    start_tim = []
    cishu = []
    status_shebei = huoqushebeizhuangtai()
    if status_shebei == 'device':
        try:
            packname = conf_dict['packname']
            activty = conf_dict['activty']
            times = conf_dict['times']
        except:
            LOG.info('获取不到测试数据,请检查!')
        if times <= 1 or len(packname) <= 1:
            LOG.info('包命或者包名activity不能为空')
        else:
            if times <= 1:
                LOG.info('次数不能为空')
            else:
                sum = 0
                for i in range(int(times)):
                    start_time = starttime_app(packagename=packname,
                                               packagenameactivicy=activty)
                    start_tim.append(int(start_time[1]))

                    cishu.append(i)
                    if start_time is None:
                        break
                    LOG.info('第%s次启动时间:%s' % (i + 1, start_time[1]))
                    sum += int(start_time[1])
                qidongceshi(cishu=cishu, start=start_tim)
                LOG.info('测试报告已经生成,请到当前目录查看')
                LOG.info('测试已经完成')
    else:
        LOG.info('设备连接异常')
示例#2
0
def cpu_app():
    status_shebei = huoqushebeizhuangtai()
    if status_shebei == 'device':
        xingneng_bao = 'com.lalamove.'
        xing = 20
        if len(xingneng_bao) <= 5:
            LOG.info('包名必须真实有效')
        cishu_list = []
        cpu_list = []
        pass_list = []
        i = 0
        for i in range(int(xing)):
            nen_cun = getnencun(xingneng_bao)
            # rescv, send, liulang_sum = liulang(xingneng_bao)
            cpu_caiji = caijicpu(xingneng_bao)
            pass_list.append(int(nen_cun[:-1]))
            LOG.info('第%s次:Pass:%s' % (i, nen_cun))
            cpu_list.append(int(cpu_caiji.split('%')[0]))
            LOG.info('第%s次:CPU占用率:%s' % (i, cpu_caiji))
            # total_list.append(int(liulang_sum))
            # rescv_list.append(int(rescv))
            # send_list.append(int(send))
            # LOG.info('第%s次:总流量:%sk,上传流量:%sk,下载流量:%sk' % (i, liulang_sum, rescv, send))
            i += 1
            cishu_list.append(int(i))
        getcpu(cishu=cishu_list, start_cpu=cpu_list, Pass_list=pass_list)
        LOG.info('测试完成')
    else:
        LOG.info('测试的设备必须正常连接,请注意')
示例#3
0
def cpu_app():
    status_shebei = huoqushebeizhuangtai()
    if status_shebei == 'device':
        xingneng_bao = xingneng_baoming.get('0.0', END).split()[0]
        xing = xing_t.get()
        if len(xingneng_bao) <= 5:
            LOG.info('包名必须真实有效')
            messagebox.showwarning('警告', '请检查您的包名')
        cishu_list = []
        cpu_list = []
        rescv_list = []
        send_list = []
        total_list = []
        pass_list = []
        i = 0
        for i in range(int(xing)):
            nen_cun = getnencun(xingneng_bao)
            rescv, send, liulang_sum = liulang(xingneng_bao)
            cpu_caiji = caijicpu(xingneng_bao)
            neicun_t['state'] = 'normal'
            pass_list.append((nen_cun))
            neicun_t.insert(tkinter.END, ('Pass值:%s' % nen_cun))
            LOG.info('第%s次:Pass:%s' % (i, nen_cun))
            neicun_t.insert(tkinter.END, '\n')
            neicun_t.see(END)
            neicun_t['state'] = 'disabled'
            cpu_t['state'] = 'normal'
            cpu_list.append((cpu_caiji.split('%')[0]))
            cpu_t.insert(tkinter.END, ('CPU占有率:%s' % cpu_caiji))
            LOG.info('第%s次:CPU占用率:%s' % (i, cpu_caiji))
            cpu_t.insert(tkinter.END, '\n')
            cpu_t.see(END)
            cpu_t['state'] = 'disabled'
            liulang_t['state'] = 'normal'
            total_list.append((liulang_sum))
            rescv_list.append((rescv))
            send_list.append((send))
            liulang_t.insert(tkinter.END, ('总流量:%sk,上传流量:%sk,下载流量:%sk' %
                                           (liulang_sum, rescv, send)))
            LOG.info('第%s次:总流量:%sk,上传流量:%sk,下载流量:%sk' %
                     (i, liulang_sum, rescv, send))
            liulang_t.insert(tkinter.END, '\n')
            liulang_t.see(END)
            liulang_t['state'] = 'disabled'
            xingneng_btn['state'] = 'disabled'
            i += 1
            cishu_list.append(int(i))
        getcpu(cishu=cishu_list,
               start_cpu=cpu_list,
               recv_list=rescv_list,
               send_list=send_list,
               total_list=total_list,
               Pass_list=pass_list)
        xingneng_btn['state'] = 'normal'
        LOG.info('测试完成')
        messagebox.showinfo('提醒', '测试完毕,测试报告已经生成!')
    else:
        LOG.info('测试的设备必须正常连接,请注意')
        messagebox.showwarning('警告', '设备连接异常 请重新连接设备!')
示例#4
0
def qidongapp():
    start_tim = []
    cishu = []
    status_shebei = huoqushebeizhuangtai()
    if status_shebei == 'device':
        try:
            packname = baoming_t.get('0.0', END)
            acti = activ_t.get('0.0', END)
            cish = cishu_ac.get()
        except:
            LOG.info('获取不到测试数据,请检查!')
            messagebox.showinfo('提醒', '获取不到测试数据,请检查!')
        if len(acti) <= 1 or len(packname) <= 1:
            messagebox.showinfo('提醒', '包命或者包名activity不能为空')
            LOG.info('包命或者包名activity不能为空')
        else:
            if len(cish) <= 1:
                messagebox.showinfo('提醒', '次数不能为空')
                LOG.info('次数不能为空')
            else:
                i = 0
                e1['state'] = 'normal'
                e1.delete(1.0, tkinter.END)
                sum = 0
                for i in range(int(cish)):
                    start_time = starttime_app(packagename=packname,
                                               packagenameactivicy=acti)
                    start_tim.append(int(start_time[1]))

                    cishu.append(i)
                    if start_time is None:
                        messagebox.showwarning('警告', '请检查您输入的包或者包的启动activity')
                        break
                    text = '第%s次启动时间:%s' % (i + 1, start_time[1])
                    LOG.info('第%s次启动时间:%s' % (i + 1, start_time[1]))
                    sum += int(start_time[1])
                    e1['state'] = 'normal'
                    e1.insert(tkinter.END, text)
                    e1.insert(tkinter.END, '\n')
                    e1.see(END)
                    btn_start['state'] = 'disabled'
                e1.insert(tkinter.END, ('平均用时:%s' % (sum / int(cish))))
                LOG.info(('平均用时:%s' % (sum / int(cish))))
                qidongceshi(cishu=cishu, start=start_tim)
                messagebox.showinfo('提示', '测试报告已经生成,请到当前目录查看')
                LOG.info('测试报告已经生成,请到当前目录查看')
                e1['state'] = 'disabled'
                btn_start['state'] = 'normal'
                messagebox.showinfo('通知', '测试已经完成')
                LOG.info('测试已经完成')
    else:
        messagebox.showerror('警告', '设备连接异常')
        LOG.info('设备连接异常')
示例#5
0
def monkey_app():
    status_shebei = huoqushebeizhuangtai()
    if status_shebei == 'device':
        try:
            packname = baoming_t1.get('0.0', END).split()[0]
            zhongzi = zhongzi_t.get('0.0', END).split()[0]
            time = time_t.get().split()[0]
            touch = touch_t.get('0.0', END).split()[0]
            huadong = huadong_t.get('0.0', END).split()[0]
            guiji = guiji_t.get('0.0', END).split()[0]
            xitong = xitong_t.get('0.0', END).split()[0]
            acti = acti_t.get('0.0', END).split()[0]
            event = event_t.get('0.0', END).split()[0]
            log = log_t.get('0.0', END).split()[0]
            danghang = danghang_t.get('0.0', END).split()[0]
            if len(packname) <= 5:
                LOG.info('请正确填写包名')
                messagebox.showwarning('提醒', '请正确填写包名')
            if int(touch) + int(huadong) + int(guiji) + int(danghang) + int(
                    xitong) + int(acti) > 100:
                messagebox.showerror('提醒', '您输入的所有的事件的比例和不能超过100%')
                LOG.info('您输入的所有的事件的比例和不能超过100')
            adb_monkey(packagename=packname,
                       s_num=zhongzi,
                       throttle=time,
                       pct_touch=touch,
                       pct_motion=huadong,
                       pct_trackball=guiji,
                       pct_nav=danghang,
                       pct_syskeys=xitong,
                       pct_appswitch=acti,
                       num=event,
                       logfilepath=log)
        except:
            messagebox.showwarning('警告', '必须填写monkey相关数据')
            LOG.info('monkey 测试出错,原因:%s' % Exception)
    else:
        LOG.info('设备连接异常 请重新连接设备!')
        messagebox.showwarning('警告', '设备连接异常 请重新连接设备!')
示例#6
0
def monkey_app():
    status_shebei = huoqushebeizhuangtai()
    if status_shebei == 'device':
        try:
            packname = conf_dict['packname']
            seed = conf_dict['seed']
            throttle = conf_dict['throttle']
            touch = conf_dict['touch']
            motion = conf_dict['motion']
            majornav = conf_dict['majornav']
            appswitch = conf_dict['appswitch']
            trackball = conf_dict['trackball']
            syskeys = conf_dict['syskeys']
            count = conf_dict['count']
            log_file_path = conf_dict['log_file_path']

            if len(packname) <= 5:
                LOG.info('请正确填写包名')
            if int(touch) + int(motion) + int(trackball) + int(majornav) + int(
                    syskeys) + int(appswitch) > 100:
                LOG.info('您输入的所有的事件的比例和不能超过100')
            adb_monkey(packagename=packname,
                       s_num=seed,
                       throttle=throttle,
                       pct_touch=touch,
                       pct_motion=motion,
                       pct_trackball=trackball,
                       pct_nav=majornav,
                       pct_syskeys=syskeys,
                       pct_appswitch=appswitch,
                       num=count,
                       logfilepath=log_file_path)
        except:
            LOG.info('monkey 测试出错,原因:%s' % Exception)
    else:
        LOG.info('设备连接异常 请重新连接设备!')
示例#7
0
def teread_cpu():
    t3 = threading.Thread(target=qidongapp, args=())
    t3.start()
    t3.join()
    if not t3.is_alive():
        time.sleep(5)
        # threads = []
        # t1 = threading.Thread(target=monkey_app, args=())
        # t2 = threading.Thread(target=cpu_app, args=())
        # threads.append(t1)
        # threads.append(t2)
        # for th in threads:
        #     th.start()
        #     th.join()
        monkey_app()
        time.sleep(5)
        cpu_app()
    LOG.info('线程执行完成')


if __name__ == '__main__':
    LOG.info('测试小程序开始启动!测试开启!')
    try:
        status_shebei = huoqushebeizhuangtai()
        if status_shebei == 'device':
            teread_cpu()
        else:
            LOG('设备未连接或者连接异常!目前连接状态:%s' % status_shebei)
    except Exception as e:
        LOG.info('测试异常,原因:%s' % e)