Ejemplo n.º 1
0
class SetYimeCase(unittest.TestCase):
    @classmethod
    def setUpClass(cls) -> None:
        cls.user_log = UserLog()
        cls.logger = cls.user_log.get_logger()

    @classmethod
    def tearDownClass(cls) -> None:
        cls.user_log.close_file_handler()

    #前置条件
    def setUp(self) -> None:
        self.coon = ConnectMobile()
        self.driver = self.coon.get_driver()
        self.screen_x = self.coon.get_screen_x()
        self.screen_y = self.coon.get_screen_y()
        self.setTime_handle = SetTimeHandle(self.driver, self.screen_x,
                                            self.screen_y)
        self.myDevice_p = MyDevicePage(self.driver)

    def test_setTime(self):
        self.setTime_handle.enter_setTime()

    # 后置条件
    def tearDown(self):
        for method_name, error in self._outcome.errors:
            if error:
                case_name = self._testMethodName
                now = time.strftime("%Y-%m-%d %H-%M-%S")
                image_name = setting.TEST_ERROR_Image + '/' + case_name + " " + now + ".png"
                self.driver.save_screenshot(image_name)
        # self.driver.close()
        print("测试结束")
Ejemplo n.º 2
0
class H616BMainCase(unittest.TestCase):
    @classmethod
    def setUpClass(self) -> None:
        self.user_log = UserLog('H616B')
        self.logger = self.user_log.get_logger()
        self.coon = ConnectMobile()
        self.driver = self.coon.get_driver()
        self.screen_x = self.coon.get_screen_x()
        self.screen_y = self.coon.get_screen_y()
        #设备名称
        self.device_name = ['H616B_5E80', 'H616B_2D64']
        self.h616BMain_h = H616BMainHandle(self.driver, self.screen_x, self.screen_y,self.logger,self.device_name[1])

    #前置条件
    def setUp(self) -> None:
        print('开始测试')

    # @unittest.skip('不执行')
    def test_ota(self):
        self.h616BMain_h.enter_H616B_main_face()
        times = 100
        n = 0
        for i in range(times):
            ota_result = self.h616BMain_h.ota()
            if ota_result:
                n += 1
                self.logger.info('第[%s]次OTA成功'%(i+1))
                print('第[%s]次OTA成功'%(i+1))
            else:
                self.logger.info('第[%s]次OTA失败'%(i+1))
                print('第[%s]次OTA失败'%(i+1))
        print('OTA升级[%s]次'%times+',成功了[%s]次!!!!!!!!' % n)
        self.logger.info('OTA升级[%s]次'%times+',成功了[%s]次!!!!!!!!' % n)

    # 后置条件
    def tearDown(self):
        # for method_name, error in self._outcome.errors:
        #     if error:
        #         case_name = self._testMethodName
        #         now = time.strftime("%Y-%m-%d %H-%M-%S")
        #         image_name = setting.TEST_ERROR_Image + '/' + case_name + " " + now + ".png"
        #         self.driver.save_screenshot(image_name)
        # self.driver.close()
        print("测试结束")
Ejemplo n.º 3
0
class DeviceConnectCase(unittest.TestCase):
    @classmethod
    def setUpClass(self) -> None:
        self.user_log = UserLog()
        self.logger = self.user_log.get_logger()
        self.coon = ConnectMobile()
        self.driver = self.coon.get_driver()
        self.screen_x = self.coon.get_screen_x()
        self.screen_y = self.coon.get_screen_y()
        self.deviceConnect_h = DeviceConnectHandle(self.driver, self.screen_x,
                                                   self.screen_y, self.logger)
        self.device_name = ['H6199_1540', 'H6199_1B2F']

    @classmethod
    def tearDownClass(self) -> None:
        self.user_log.close_file_handler()

    #前置条件
    def setUp(self) -> None:
        # self.adb_log.write_log()
        pass

    @unittest.skip("不执行")
    def test_connect_H5102(self):
        self.deviceConnect_h.connect_H5102()
        self.logger.info("---------连接H5102")
        #断言:对结果进行判断
        #self.assertTrue()

    @unittest.skip("不执行")
    def test_connect_H5103(self):
        self.deviceConnect_h.connect_H5103()
        self.logger.info("---------连接H5103")
        # 断言:对结果进行判断
        # self.assertTrue()

    @unittest.skip('不执行')
    def test_connect_H5182(self):
        self.deviceConnect_h.delete_H5182()
        self.logger.info("---------连接H5102")
        #断言:对结果进行判断
        #self.assertTrue()

    @unittest.skip('不执行')
    def test_connect_H5183(self):
        self.deviceConnect_h.connect_H5183()

    def test_connect_H6199(self):
        n = 0
        times = 500
        for i in range(times):
            try:
                connect = self.deviceConnect_h.connect_H6199(
                    self.device_name[1])
                if connect:
                    n += 1
                    self.logger.info('第[%s]次添加设备成功' % (i + 1))
                else:
                    self.logger.info('第[%s]次添加设备失败' % (i + 1))
            except Exception as e:
                self.logger.info(e)
        print('添加[%s]次,' % times + '成功了[%s]次!!!!!!!!' % n)
        self.logger.info('添加[%s]次,' % times + '成功了[%s]次!!!!!!!!' % n)

    @unittest.skip('不执行')
    def test_connect_H6056(self):
        n = 0
        for i in range(5):
            try:
                connect = self.deviceConnect_h.connect_sku6056()
                if connect:
                    n += 1
                    self.logger.info('添加设备成功')
                else:
                    self.logger.info('添加设备失败')
            except Exception as e:
                self.logger.info(e)
        print('添加5次,成功了[%s]次!!!!!!!!' % n)
        self.logger.info('添加5次,成功了[%s]次!!!!!!!!' % n)

    @unittest.skip('不执行')
    def test_connect_H6054(self):
        n = 0
        for i in range(5):
            try:
                connect = self.deviceConnect_h.connect_H6054()
                if connect:
                    n += 1
                    self.logger.info('第[%s]次添加设备成功' % (i + 1))
                else:
                    self.logger.info('第[%s]次添加设备失败' % (i + 1))
            except Exception as e:
                self.logger.info(e)
        print('添加5次,成功了[%s]次!!!!!!!!' % n)
        self.logger.info('添加5次,成功了[%s]次!!!!!!!!' % n)

    #后置条件
    def tearDown(self):
        for method_name, error in self._outcome.errors:
            if error:
                case_name = self._testMethodName
                now = time.strftime("%Y-%m-%d %H-%M-%S")
                image_name = setting.TEST_ERROR_Image + '/' + case_name + " " + now + ".png"
                self.driver.save_screenshot(image_name)
        # self.driver.close()
        print("测试结束")
Ejemplo n.º 4
0
class H6199MainCase(unittest.TestCase):
    @classmethod
    def setUpClass(self) -> None:
        self.user_log = UserLog()
        self.logger = self.user_log.get_logger()
        self.coon = ConnectMobile()
        self.driver = self.coon.get_driver()
        self.screen_x = self.coon.get_screen_x()
        self.screen_y = self.coon.get_screen_y()
        self.h6199Main_h = H6199MainHandle(self.driver, self.screen_x,
                                           self.screen_y, self.logger)
        self.wifi_check_h = StatusCheckHandle(self.driver, self.logger)
        self.wifi_set_h = WIFISetHandle(self.driver, self.screen_x,
                                        self.screen_y, self.logger)
        self.device_name = ['H6199_1540', 'H6199_1B2F']

        #创建串口
        # self.port = com
        # self.bps = bps
        # self.timeout = timeout
        # global Ret
        # try:
        #     # 打开串口,并得到串口对象
        #     self.main_engine = serial.Serial(self.port, self.bps, timeout=self.timeout)
        #     self.main_engine.flushInput()  # 清空缓冲区
        #     # 判断是否打开成功
        #     if (self.main_engine.is_open):
        #         Ret = True
        # except Exception as e:
        #     print("---异常---:", e)

    @classmethod
    def tearDownClass(self) -> None:
        self.user_log.close_file_handler()

    #前置条件
    def setUp(self) -> None:
        # self.adb_log.write_log()
        pass

    #模式切换
    def test_mode_switch(self):
        try:
            self.h6199Main_h.mode_switch()
        except Exception as e:
            print(e)

    @unittest.skip('不执行')
    def test_ota(self):
        self.h6199Main_h.enter_H6199_1540_main_face()
        n = 0
        for i in range(200):
            ota_result = self.h6199Main_h.ota()
            if ota_result:
                n += 1
                self.logger.info('第[%s]次OTA成功' % (i + 1))
            else:
                self.logger.info('第[%s]次OTA失败' % (i + 1))
        print('OTA升级200次,成功了[%s]次!!!!!!!!' % n)
        self.logger.info('OTA升级200次,成功了[%s]次!!!!!!!!' % n)

    @unittest.skip('不执行')
    def test_wifi_check(self):
        n = 0
        for i in range(500):
            try:
                connect = self.wifi_check_h.goin_H6199()
                if connect:
                    n += 1
            except Exception as e:
                self.logger.info(e)
        self.logger.info('蓝牙连接测试500次,成功了[%s]次!!!!!!!!' % n)

    @unittest.skip('不执行')
    def test_wifi_set(self):
        n = 0
        times = 200
        for i in range(times):
            try:
                connect = self.wifi_set_h.connect_wifi(self.device_name[1])
                if connect:
                    n += 1
                    self.logger.info('第[%s]次WiFi连接成功' % (i + 1))
                else:
                    self.logger.info('第[%s]次WiFi连接失败' % (i + 1))
            except Exception as e:
                self.logger.info(e)
        print('连接[%s]次,' % times + '成功了[%s]次!!!!!!!!' % n)
        self.logger.info('连接[%s]次,' % times + '成功了[%s]次!!!!!!!!' % n)

    @unittest.skip('不执行')
    #不断进入WIFI设置页
    def test_enter_wifiSetting(self):
        try:
            self.h6199Main_h.enter_wifiSetting()
        except Exception as e:
            print(e)

    # # 接收串口数据
    # def recv(self):
    #     print("开始接收数据:")
    #     while True:
    #         try:
    #             count = self.main_engine.inWaiting()  # 获取串口缓冲区数据
    #             if count != 0:
    #                 data = self.main_engine.read(self.main_engine.in_waiting).decode("gbk")  # 读出串口数据,数据采用gbk编码
    #                 time.sleep(0.1)  # 延时0.1秒,免得CPU出问题
    #                 self.dataList += data
    #         except Exception as e:
    #             print("异常报错:", e)

    # 后置条件
    def tearDown(self):
        for method_name, error in self._outcome.errors:
            if error:
                case_name = self._testMethodName
                now = time.strftime("%Y-%m-%d %H-%M-%S")
                image_name = setting.TEST_ERROR_Image + '/' + case_name + " " + now + ".png"
                self.driver.save_screenshot(image_name)
        # self.driver.close()
        print("测试结束")