Esempio n. 1
0
 def __init__(self):
     cmd1 = "adb connect 192.168.0.2:5555"
     cmd2 = "python -m uiautomator2 init"
     subprocess.call(cmd1, shell=True)
     subprocess.call(cmd2, shell=True)
     self.GDL = gdl.Get_device_log()
     self.driver = u.connect("192.168.0.2:5555")
Esempio n. 2
0
    def test_case1(self):
        GDL = gdl.Get_device_log()  # 初始化

        play('man_wake_up', path.wake_up_file)  # 播放唤醒词
        wake_finish_time = GDL.get_local_time()
        print(wake_finish_time)
        time.sleep(2)
        self.driver.screenshot(path.Cache_img_path2)
        time.sleep(28)
        GDL.get_device_log()
        time.sleep(1)
        start_time = GDL.get_begin_parse()
        print("\033[7;31m收到唤醒词的时间:\033[0m", start_time)
        end_time, new_result = GDL.get_device_wake()
        print("返回%s的时间是%f" % (new_result, end_time))
        if len(new_result) >10:
            wait_limit_time = 4
        else:
            wait_limit_time = 2
        wait_time = end_time - start_time
        check_time = abs(wake_finish_time - start_time)
        print("唤醒耗时", wait_time)
        print("本地时间误差", check_time)
        if wait_time >= wait_limit_time or check_time >= 7:
            fail_dir_name = time.strftime("%d_%H_%M_%S")
            dir_path = path.DIR_PATH + "\\report\\error_log\\" + fail_dir_name + "men_wake_up\\"
            os.makedirs(dir_path)
            cmd = "adb pull sdcard/txz/log " + dir_path
            print(cmd)
            os.system(cmd)
            raise Exception("没有唤醒或唤醒响应时间超过2s")
        else:
            print("case pass...")
Esempio n. 3
0
    def setup_class(cls):

        dr = Driver()

        cls.driver = dr.init_driver(device_name)

        cls.GDL = gdl.Get_device_log()
Esempio n. 4
0
def wake_rate():
    GDL = gdl.Get_device_log()  #初始化
    test_num = 0
    pass_num = 0
    fail_num = 0

    while True:
        test_num +=1
        play('woman_wake_up',path.wake_up_file)  #播放唤醒词
        wake_finish_time = GDL.get_local_time()
        print(wake_finish_time)
        time.sleep(30)
        GDL.get_device_log()
        time.sleep(1)
        start_time = GDL.get_begin_parse()
        print("\033[7;31m收到唤醒词的时间:\033[0m",start_time)
        end_time,new_result = GDL.get_device_wake()
        print("返回%s的时间是%f"%(new_result,end_time))
        wait_time = end_time -start_time
        check_time = abs(wake_finish_time-start_time)
        print("唤醒耗时",wait_time)
        print("本地时间误差",check_time)
        try:
            if wait_time >=2 or check_time>=5:
                raise Exception("唤醒异常")
            else:
                pass_num+=1
        except Exception as e:
            print(e)
            fail_dir_name = time.strftime("%y_%m_%d_%H_%M_%S")
            cmd = "xcopy /D "+path.DIR_PATH+"\\logs\\log "+path.DIR_PATH+"\\report\\error_log\\"+fail_dir_name+"\ /e"
            subprocess.call(cmd)
        print("\033[7;31m总共测试%s次,成功%s次\033[0m"%(test_num,pass_num))
# -*- coding: utf-8 -*-
from utils.play_aidio import play
import time, subprocess, os
import settings.DIR_PATH as path
from utils import get_device_log as gdl
import uiautomator2 as u
from utils import img_match
import pytest, time, allure, sys
from config import *

GDL = gdl.Get_device_log()


@allure.feature("测试发现")
@pytest.mark.usefixtures('driver_setup')
@pytest.mark.P1
class Wake_ask:
    def test_case1(self):
        play('你好小西', path.wake_up_file)
        wake_finish_time = GDL.get_local_time()
        print("wake_finish_time", wake_finish_time)
        time.sleep(2)
        play("打开导航", path.men_qa_file)
        time.sleep(15)
        result = img_match.picture_match(self.driver, "03.png")

        GDL.get_device_log()
        start_time = self.GDL.get_begin_parse()
        print("atart_time", start_time)
        check_time = abs(wake_finish_time - start_time)
        print(check_time)
# -*- coding: utf-8 -*-