Пример #1
0
class MulticameraApkHelper:

    MULTI_CAMERA_CONFIG_DICT = {
        "camera0_input_field": 1,
        "camera0_input_resolution": 3,
        "camera0_input_format": 4,
        "camera0_input_default": 5,
        "camera0_output_resolution": 0,
        "camera0_output_format": 2,
        "camera1_input_field": 7,
        "camera1_input_resolution": 9,
        "camera1_input_format": 10,
        "camera1_input_default": 11,
        "camera1_output_resolution": 6,
        "camera1_output_format": 8
    }

    def __init__(self):
        self.d = g_common_obj.get_device()
        self.camera_common = CameraCommon()
        self.get_cfg_file_helper = GetConfigFileHelper(
            "", "multicamera_apk_helper.conf")
        self.multimedia_setting = MultiMediaSetting(
            self.get_cfg_file_helper.cfg_file)
        need_install_result = self.multimedia_setting.install_apk(
            "multicamera_apk")
        if need_install_result:
            adb32._adb_reboot()
            time.sleep(15)
        self.multicamera_apk_package_name, _ = self.multimedia_setting.get_package_and_activity_name(
            "multicamera_apk")
        MULTI_CAMERA_PERMISSION_LIST = ["android.permission.CAMERA"]
        self.camera_common.grantPermission(self.multicamera_apk_package_name,
                                           MULTI_CAMERA_PERMISSION_LIST)

    def launch_multicamera_apk(self):
        return self.multimedia_setting.launch_apk("multicamera_apk")

    def stop_multicamera_apk(self):
        return self.multimedia_setting.stop_apk("multicamera_apk")

    def set_multicamera_config(self, config_list):
        logger.debug("set_multicamera_config start. config_list=%s" %
                     config_list)
        for config_str in config_list:
            config_item, config_value = config_str.split(":")
            if config_item not in self.MULTI_CAMERA_CONFIG_DICT.keys():
                continue
            logger.debug("config_item:%s, config_value:%s" %
                         (config_item, config_value))
            self.d(className="android.widget.Spinner")[
                self.MULTI_CAMERA_CONFIG_DICT[config_item]].click.wait()
            time.sleep(1)
            self.d(textContains=config_value).click.wait()
            time.sleep(1)
        logger.debug("set_multicamera_config end.")
Пример #2
0
class InstallAllVideoApp(UIATestBase):
    def setUp(self):
        super(InstallAllVideoApp, self).setUp()
        self._test_name = __name__
        print
        print "[Setup]: %s" % self._test_name
        cfg_file = 'tests.tablet.dut_init.conf'
        self.retry_num = self.config.read(
            cfg_file, 'init_list').get("delete_camera_folder_file")
        if self.retry_num is None:
            self.retry_num = 3
        self.retry_num = int(self.retry_num)
        cfg_file = os.path.join(os.environ.get('TEST_DATA_ROOT', ''), \
            'tests.tablet.mum_auto_video.conf')
        self.multimedia_setting = MultiMediaSetting(cfg_file)

    def tearDown(self):
        super(InstallAllVideoApp, self).tearDown()
        print "[Teardown]: %s" % self._test_name

    def testInstallAllVideoApp(self):
        """
        delete all camera folder files
        """
        print "[RunTest]: %s" % self.__str__()

        succeed = False
        for _ in range(self.retry_num):
            try:
                self.multimedia_setting.install_apk("video_apk")
                self.multimedia_setting.install_apk("alarm_apk")
                self.multimedia_setting.install_apk("photo_apk")
                succeed = True
                break
            except Exception as e:
                print e
        assert succeed
Пример #3
0
class CameraTest(CameraTestBase):
    """
    @summary: This test used to test camera function
    """
    def setUp(self):
        """
        @summary: set up
        @return: None
        """
        super(CameraTest, self).setUp()
        self._test_name = __name__
        self.logger.debug("[Setup]: %s" % self._test_name)

        g_common_obj.root_on_device()
        self.camera_common = CameraCommon()

        self.host_path = self.camera_common.getTmpDir()

        self.rvc_camera = ""
        self.aosp_camera = ""
        self.ref_camera = ""
        self.case_result = -1

        self.camera_common.removeDeivceFile()
        self.camera_common.removeFile(self.host_path + "/*")
        self.get_rvc_camera_class().stopCameraApp()
        self.camera_common.unlockScreen()
        self.get_rvc_camera_class().skipAccountLoginLyout()
        self.get_rvc_camera_class().backHome()
        self.d = g_common_obj.get_device()
        if self.d(text="Got it").exists:
            self.d(text="Got it").click.wait()

    def tearDown(self):
        """
        @summary: tearDown
        @return: None
        """
        super(CameraTest, self).tearDown()
        self.logger.debug("[Teardown]: %s" % self._test_name)
        g_common_obj.stop_exp_handle()

        if self.rvc_camera != "":
            self.rvc_camera.stopCameraApp()
        if self.aosp_camera != "":
            self.aosp_camera.cleanMediaFiles()
        self.camera_common.removeDeivceFile()
        if self.case_result == 0:
            self.reboot_device()
#         self.camera_common.removeFile(self.host_path + "/*")
        time.sleep(3)
        self.get_rvc_camera_class().backHome()

    def appPrepare(self, ):
        self.logger.debug("app prepare successfully")

    def check_file_corrupt(self, mediaFileCount=1):
        return self.camera_common.checkFileCorrupt(mediaFileCount)

    def get_rvc_camera_class(self):
        if self.rvc_camera == "":
            self.rvc_camera = MultiMediaSwitchCameraHelper().camera
        return self.rvc_camera

    def get_aosp_camera_class(self):
        if self.aosp_camera == "":
            self.aosp_camera = AOSPCamera()
        return self.aosp_camera

    def get_ref_camera_class(self):
        if self.ref_camera == "":
            self.ref_camera = RefCamCamera()
        return self.ref_camera

    def reboot_device(self):
        self.get_rvc_camera_class().reboot_device()

    def check_home_or_lock_layout(self, check_exist=True):
        if self.d(text="Got it").exists:
            self.d(text="Got it").click.wait()
        self.get_rvc_camera_class().skipAccountLoginLyout()
        assert self.get_rvc_camera_class().isHomeLayoutExists(
        ) or self.get_rvc_camera_class().isLockLayoutExists(
        ), "Home or Lock layout not exist!"

    def start_stop_camera_test(self, wait_time=5, check_success=1):
        self.logger.debug("start_stop_camera_test start")
        self.get_rvc_camera_class().startCameraApp(check_success)
        time.sleep(wait_time)
        self.get_rvc_camera_class().stopCameraApp()
        time.sleep(2)

    def check_gps(self):
        self.multimedia_setting = MultiMediaSetting(
            self.camera_common.DEFAULT_CONFIG_FILE)
        self.multimedia_setting.install_apk("gps_apk")
        self.camera_common.launchGpsApp()
        network_longitude, network_latitude = self.camera_common.getGPSLocation(
        )
        return network_longitude, network_latitude

    def check_logcat_data(self, data_list, expect_lower_limit_fps,
                          expect_upper_limit_fps):
        self.logger.debug("check_logcat_data data_list=%s" % data_list)
        if len(data_list) == 0:
            return False, -1
        for t_fps in data_list:
            t_fps = float(t_fps)
            if expect_lower_limit_fps > t_fps or t_fps > expect_upper_limit_fps:
                return False, t_fps
        return True, 1

    def check_aosp_camera_exif_info(self, check_info_dict):
        self.case_result = 0
        self.get_aosp_camera_class().startCameraApp()
        self.get_aosp_camera_class().selectMode("Camera")
        self.get_aosp_camera_class().capturePhoto(1)
        file_info, file_name = self.check_file_corrupt()
        for check_info_key in check_info_dict.keys():
            assert check_info_key in file_info.keys(
            ), "\"%s\" not in exif info!" % check_info_key
            actual_info = file_info[check_info_key]
            expect_info_parttern = re.compile(check_info_dict[check_info_key])
            self.logger.debug(
                "actual_info = \"%s\", expect_info_parttern = \"%s\"" %
                (actual_info, check_info_dict[check_info_key]))
            result_list = expect_info_parttern.findall(actual_info)
            self.logger.debug(result_list)
            assert result_list != [], "actual_info = \"%s\", expect_info_parttern = \"%s\", result_list = \"%s\"" % (
                actual_info, check_info_dict[check_info_key], result_list)
        self.logger.debug("info:%s" % file_info)
        self.get_aosp_camera_class().stopCameraApp()
        self.get_aosp_camera_class().cleanMediaFiles()
        self.case_result = 1

    def check_ref_camera_preview_with_format(self,
                                             preview_format,
                                             duration=10):
        self.android_version = MultiMediaSwitchCameraHelper(
            skip_import_camera=True).android_version.lower()
        if "o" in self.android_version:
            self.multimedia_setting = MultiMediaSetting(
                self.camera_common.DEFAULT_CONFIG_FILE)
            self.multimedia_setting.install_apk(
                "for_o_image_camera_preview_test_apk")
            from testlib.multimedia.get_device_port_helper import GetConfigFileHelper
            self.scale_test_cfg = GetConfigFileHelper(
                "", "multimedia_scale_test_helper.conf").get_section("config")
            self.o_image_play_cmd = self.scale_test_cfg.get("o_image_play_cmd")
            check_size_list = ["720x480", "640x480", "320x240", "176x144"]
            from testlib.graphics.common import adb32
            adb32._adb_reboot()
            time.sleep(15)
            for size in check_size_list:
                width, height = size.split("x")
                result = g_common_obj.adb_cmd_capture_msg(
                    self.o_image_play_cmd %
                    (width, height, preview_format, duration))
                assert "OK" in result, "play error! result=%s" % result
                time.sleep(2)
        else:
            self.get_ref_camera_class().startCameraApp()
            self.get_ref_camera_class().selectMode("SingleShot")
            self.get_ref_camera_class().setSettingsButton(
                "Preview Format", preview_format)
            check_size_list = [
                "1920x1080", "1280x720", "720x480", "640x480", "320x240",
                "176x144"
            ]
            for size in check_size_list:
                self.logger.debug("capture photo, format: %s, size: %s" %
                                  (preview_format, size))
                self.get_ref_camera_class().setSettingsButton(
                    "Picture Size", size)
                self.get_ref_camera_class().capturePhoto()
            self.camera_common.checkFileCorrupt(len(check_size_list))

    def test_Camera_Launch_With_Press_Power(self):
        self.get_rvc_camera_class.reboot_device()
        self.logger.debug("---start sleep---")
        #         time.sleep(3)
        #         self.logger.debug("---start pressPowerKey---")
        #         self.camera.pressPowerKey(2)
        #         self.wait_boot_completed()
        time.sleep(5)
        self.start_stop_camera_test(10)
        time.sleep(10)
        self.start_stop_camera_test()

    def test_Camera_IVI_RVC_Preview_Horizontal(self):
        self.get_rvc_camera_class().startCameraApp()
        time.sleep(5)
        d = g_common_obj.get_device()
        x = d.info["displayWidth"]
        y = d.info["displayHeight"]
        self.logger.debug("display size--- x:%s, y:%s" % (str(x), str(y)))
        assert int(x) > int(y), "RVC FOV not display as horizontal"
        self.get_rvc_camera_class().stopCameraApp()

    def test_Camera_IVI_RVC_ColdBoot_Available_10Mins(self):  ######
        self.reboot_device()
        self.get_rvc_camera_class().startCameraApp()
        self.logger.debug("Wait 10mins...")
        time.sleep(600)
        self.get_rvc_camera_class().startCameraApp()
        self.get_rvc_camera_class().stopCameraApp()
        time.sleep(5)
        self.check_home_or_lock_layout()

    def test_Camera_IVI_RVC_ColdBoot_off_Available(self):  ######
        self.reboot_device()
        for _ in range(5):
            self.start_stop_camera_test()
        self.check_home_or_lock_layout()

    def test_Camera_IVI_RVC_ColdBoot_Switch_Repeatly(self):  ######
        self.reboot_device()
        for _ in range(5):
            self.start_stop_camera_test()
        self.check_home_or_lock_layout()

    def test_Camera_IVI_RVC_ColdBoot_Repeatly(self):  ######
        for i in range(10):
            self.logger.debug("------loop %s------" % str(i + 1))
            self.reboot_device()
            self.get_rvc_camera_class().stopCameraApp()
            time.sleep(5)
            self.get_rvc_camera_class().startCameraApp()
        time.sleep(5)
        self.get_rvc_camera_class().stopCameraApp()

    def test_Camera_IVI_RVC_ColdBoot_on_Available(self):
        self.reboot_device()
        self.get_rvc_camera_class().backHome()
        self.check_home_or_lock_layout()
        self.start_stop_camera_test()

    def test_Camera_IVI_RVC_RunTime_Available(self):
        self.reboot_device()
        self.get_rvc_camera_class().startCameraApp()
        time.sleep(5)
        self.get_rvc_camera_class().stopCameraApp()
        time.sleep(5)
        self.check_home_or_lock_layout()

    def test_Camera_IVI_RVC_RunTime_Available_10Mins(self):
        self.reboot_device()
        self.get_rvc_camera_class().startCameraApp()
        self.logger.debug("Wait 10mins...")
        time.sleep(600)
        self.get_rvc_camera_class().stopCameraApp()
        time.sleep(5)
        self.check_home_or_lock_layout()
        self.get_rvc_camera_class().startCameraApp()
        self.get_rvc_camera_class().stopCameraApp()
        time.sleep(5)
        self.check_home_or_lock_layout()

    def test_Camera_IVI_RVC_RunTime_On_Quickly(self):
        self.reboot_device()
        for i in range(1, 6):
            self.logger.debug("------loop %s------" % i)
            self.get_rvc_camera_class().startCameraApp()
            self.get_rvc_camera_class().stopCameraApp()
            time.sleep(3)

    def test_Camera_IVI_RVC_Switch_From_CameraAPP(self):
        self.check_home_or_lock_layout()
        self.get_aosp_camera_class().startCameraApp()
        for i in range(1, 6):
            self.logger.debug("------loop %s------" % i)
            self.get_rvc_camera_class().startCameraApp()
            self.get_rvc_camera_class().stopCameraApp()
            self.get_aosp_camera_class().checkCameraApp()
            time.sleep(3)

    def test_Camera_IVI_AOSPCamera_Launch_Repeat(self):
        self.check_home_or_lock_layout()
        count = 20
        for i in range(1, count + 1):
            self.logger.debug("------loop %s------" % i)
            self.get_aosp_camera_class().startCameraApp()
            self.get_aosp_camera_class().checkCameraApp()
            self.get_aosp_camera_class().stopCameraApp()
            time.sleep(3)

    def test_Camera_IVI_AOSP_Rear_Launch(self):
        self.check_home_or_lock_layout()
        self.get_aosp_camera_class().startCameraApp()
        self.get_aosp_camera_class().checkCameraApp()
        self.get_aosp_camera_class().stopCameraApp()

    def test_Camera_IVI_Rear_Preview_CVBS1(self):
        self.test_Camera_IVI_AOSP_Rear_Launch()

    def test_Camera_FIT_RVC_Lock_With_PW(self):
        try:
            #             self.multimedia_setting.install_apk("unlock_app")
            self.camera_common.setLockScreenWithPasswd()
            time.sleep(1)
            self.camera_common.pressPower()
            time.sleep(2)
            d = g_common_obj.get_device()
            d.wakeup()
            time.sleep(2)
            for i in range(1, 6):
                self.logger.debug("------loop %s------" % i)
                self.get_rvc_camera_class().startCameraApp()
                time.sleep(5)
                self.get_rvc_camera_class().stopCameraApp()
                time.sleep(3)
            self.camera_common.unlockScreen()
#             self.camera_common.launchUnlockAppToUnlockScreen()
        except Exception as e:
            self.assertTrue(False, e)
        finally:
            self.get_rvc_camera_class().stopCameraApp()
            self.camera_common.setLockScreenWithPasswd(False)

    def test_Camera_IVI_AOSP_Metadata_EXIF_CameraModelName(self):
        self.check_aosp_camera_exif_info(
            {"Camera Model Name": "AOSP on Intel Platform"})

    def test_Camera_IVI_AOSP_Metadata_EXIF_DateTime(self):
        self.check_aosp_camera_exif_info(
            {"Create Date": "\d{4}:\d{2}:\d{2} \d{2}:\d{2}:\d{2}"})

    def test_Camera_IVI_AOSP_Metadata_EXIF_GPSLocation(self):
        self.check_gps()
        self.check_aosp_camera_exif_info({"GPS Position": ".*N,.*E"})

    def test_Camera_IVI_AOSP_Metadata_EXIF_ImageDescription(self):
        self.check_aosp_camera_exif_info({"Image Description": "Jpeg"})

    def test_Camera_IVI_AOSP_Metadata_EXIF_Make(self):
        self.check_aosp_camera_exif_info({"Make": "Intel"})

    def test_Camera_IVI_AOSP_Metadata_EXIF_Resolution(self):
        self.check_aosp_camera_exif_info({"Image Size": "\d{3,4}x\d{3,4}"})

    def test_Camera_Rear_PreviewFormat_NV21(self):
        self.check_ref_camera_preview_with_format("NV21")

    def test_Camera_Rear_PreviewFormat_YV12(self):
        self.check_ref_camera_preview_with_format("YV12")

    def test_Camera_IVI_Preview_PictureFormat_NTSC(self):
        self.check_ref_camera_preview_with_format("NV21")
        self.check_ref_camera_preview_with_format("YV12")

    def test_Camera_Rear_PreviewFormat_RGB565(self):
        self.check_ref_camera_preview_with_format("RGB_565")

    def test_Camera_Rear_PreviewFormat_YUY2(self):
        self.check_ref_camera_preview_with_format("YUY2")

    def test_Camera_IVI_AVM737_Preview_FPS_Range(self):
        self.multimedia_logcat_helper = MultiMediaLogcatHelper(
            "adb logcat CameraHardwareSoc:D *:S")
        self.get_ref_camera_class().startCameraApp()
        self.get_ref_camera_class().selectMode("SingleShot")
        self.get_ref_camera_class().setSettingsButton("Preview FPS Range",
                                                      "30000-30000")
        self.multimedia_logcat_helper.get_logcat_data_start()
        time.sleep(5)
        result_list = self.multimedia_logcat_helper.get_logcat_data_end(
            "total fps is (.*),")
        check_logcat_data_result, error_fps = self.check_logcat_data(
            result_list, 29, 31)
        assert check_logcat_data_result, "fps error! error_fps=%s, expect_fps=%s, result_list=%s" % (
            error_fps, "30000-30000", result_list)
        self.get_ref_camera_class().capturePhoto()
        self.get_ref_camera_class().setSettingsButton("Preview FPS Range",
                                                      "30000-60000")
        self.multimedia_logcat_helper.get_logcat_data_start()
        time.sleep(5)
        result_list = self.multimedia_logcat_helper.get_logcat_data_end(
            "total fps is (.*),")
        check_logcat_data_result, error_fps = self.check_logcat_data(
            result_list, 30, 60)
        assert check_logcat_data_result, "fps error! error_fps=%s, expect_fps=%s, result_list=%s" % (
            error_fps, "30000-60000", result_list)
        self.get_ref_camera_class().capturePhoto()
        self.camera_common.checkFileCorrupt(2)

    def test_ref_camera_with_different_format(self, preview_format):
        assert 0, "Need OV10635 senser!"
        self.multimedia_setting = MultiMediaSetting(
            self.camera_common.DEFAULT_CONFIG_FILE)
        self.multimedia_setting.executeCommandWithPopen(
            "setprop camera.hal.perf 3")
        self.get_ref_camera_class().startCameraApp()
        self.get_ref_camera_class().selectMode("SingleShot")
        self.get_ref_camera_class().setSettingsButton("Preview Format",
                                                      preview_format)
        preview_size_list = ["1280x800", "1280x720", "640x480"]
        for preview_size in preview_size_list:
            self.get_ref_camera_class().setSettingsButton(
                "Picture Size", preview_size)
            self.get_ref_camera_class().capturePhoto()
        self.camera_common.checkFileCorrupt(len(preview_size_list))

    def test_Camera_IVI_OV10635_Preview_NV21_Available(self):
        self.test_ref_camera_with_different_format("NV21")

    def test_Camera_IVI_OV10635_Preview_RGB565_Available(self):
        self.test_ref_camera_with_different_format("RGB565")

    def test_Camera_IVI_OV10635_Preview_YUY2_Available(self):
        self.test_ref_camera_with_different_format("YUY2")

    def test_Camera_IVI_OV10635_Preview_YV12_Available(self):
        self.test_ref_camera_with_different_format("YV12")

    def test_ref_camera_check_fps(self, preview_format):
        assert 0, "Need OV10635 senser!"
        self.multimedia_setting = MultiMediaSetting(
            self.camera_common.DEFAULT_CONFIG_FILE)
        self.multimedia_setting.executeCommandWithPopen(
            "setprop camera.hal.perf 3")
        self.multimedia_logcat_helper = MultiMediaLogcatHelper(
            "adb logcat CameraHardwareSoc:D *:S")
        self.get_ref_camera_class().startCameraApp()
        self.get_ref_camera_class().selectMode("SingleShot")
        self.get_ref_camera_class().setSettingsButton("Preview Format",
                                                      preview_format)
        self.multimedia_logcat_helper.get_logcat_data_start()
        time.sleep(1 * 60)
        preview_size_list = ["1280x800", "1280x720", "640x480"]
        for preview_size in preview_size_list:
            self.get_ref_camera_class().setSettingsButton(
                "Picture Size", preview_size)
            self.get_ref_camera_class().capturePhoto()
        self.camera_common.checkFileCorrupt(len(preview_size_list))
        result_list = self.multimedia_logcat_helper.get_logcat_data_end(
            "total fps is (.*),")
        check_logcat_data_result, error_fps = self.check_logcat_data(
            result_list, 29, 31)
        assert check_logcat_data_result, "fps error! error_fps=%s, expect_fps=%s, result_list=%s" % (
            error_fps, "29-31", result_list)

    def test_Camera_IVI_OV10635_Preview_NV21_30fps(self):
        self.test_ref_camera_check_fps("NV21")

    def test_Camera_IVI_OV10635_Preview_RGB565_30fps(self):
        self.test_ref_camera_check_fps("RGB565")

    def test_Camera_IVI_OV10635_Preview_YUY2_30fps(self):
        self.test_ref_camera_check_fps("YUY2")

    def test_Camera_IVI_OV10635_Preview_YV12_30fps(self):
        self.test_ref_camera_check_fps("YV12")

    def test_Camera_IVI_OV10635_AOSPCamera_Launch_Repeat(self):
        assert 0, "Need OV10635 senser!"
        self.check_home_or_lock_layout()
        count = 20
        for i in range(1, count + 1):
            self.logger.debug("------loop %s------" % i)
            self.get_aosp_camera_class().startCameraApp()
            self.get_aosp_camera_class().checkCameraApp()
            self.get_aosp_camera_class().stopCameraApp()
            time.sleep(3)

    def test_Camera_IVI_S3_WakeUp_AOSPCamera(self):
        self.get_rvc_camera_class().pressPowerKey(2)
        wait_time = 5 * 60
        self.logger.debug("------Wait %s s------" % str(wait_time))
        time.sleep(wait_time)
        self.get_rvc_camera_class().pressPowerKey(2)
        time.sleep(10)
        self.get_aosp_camera_class().startCameraApp()
        self.get_aosp_camera_class().stopCameraApp()

    def test_Camera_IVI_AOSP_Camera_S3_Available(self):
        self.get_aosp_camera_class().startCameraApp()
        self.get_rvc_camera_class().pressPowerKey(2)
        wait_time = 5 * 60
        self.logger.debug("------Wait %s s------" % str(wait_time))
        time.sleep(wait_time)
        self.get_rvc_camera_class().pressPowerKey(2)
        time.sleep(10)
        self.get_aosp_camera_class().checkCameraApp()
        self.get_aosp_camera_class().stopCameraApp()

    def test_Camera_IVI_AOSP_S3_WakeUp_With_DifferentTime_Interval(self):
        wait_time_list = [5 * 60, 20, 30, 5 * 60, 10 * 60]
        for wait_time in wait_time_list:
            self.get_aosp_camera_class().startCameraApp()
            self.get_rvc_camera_class().pressPowerKey(2)
            self.logger.debug("------Wait %s s------" % str(wait_time))
            time.sleep(wait_time)
            self.get_rvc_camera_class().pressPowerKey(2)
            time.sleep(10)
            self.get_aosp_camera_class().checkCameraApp()
            self.get_aosp_camera_class().stopCameraApp()

    def test_Camera_IVI_RunTime_RVC_S3_Available(self):
        self.get_rvc_camera_class().startCameraApp()
        self.get_rvc_camera_class().pressPowerKey(2)
        wait_time = 5 * 60
        self.logger.debug("------Wait %s s------" % str(wait_time))
        time.sleep(wait_time)
        self.get_rvc_camera_class().pressPowerKey(2)
        time.sleep(10)
        self.get_rvc_camera_class().stopCameraApp()

    def test_Camera_IVI_S3_WakeUp_RVC(self):
        self.get_rvc_camera_class().pressPowerKey(2)
        wait_time = 5 * 60
        self.logger.debug("------Wait %s s------" % str(wait_time))
        time.sleep(wait_time)
        self.get_rvc_camera_class().pressPowerKey(2)
        time.sleep(10)
        self.get_rvc_camera_class().startCameraApp()
        self.get_rvc_camera_class().stopCameraApp()

    def test0(self):
        self.reboot_device()

    def test1(self):
        self.multimedia_mplayer_helper = MultiMediaMplayerHelper()
        self.multimedia_checkiq_helper = MultiMediaCheckiqHelper(
            self.host_path)

        self.multimedia_mplayer_helper.play_video(
            "/home/auto1/tmp/video_20s.avi")
        time.sleep(2)
        self.multimedia_mplayer_helper.control_video(
            ["pause", "pausing seek 0 2", "frame_step"])
        self.get_aosp_camera_class().startCameraApp()
        self.get_aosp_camera_class().selectMode("Video")
        self.multimedia_mplayer_helper.control_video(["pause"])
        self.get_aosp_camera_class().recordVideo(1, 5)
        self.multimedia_mplayer_helper.close_video()
        file_info, file_name = self.check_file_corrupt()
        self.multimedia_checkiq_helper.check_video_with_barcode(file_name)

    def test2(self):
        from testlib.multimedia.multimedia_canbox_helper import MultiMediaCanboxHelper
        self.multimedia_canbox_helper = MultiMediaCanboxHelper()
        self.multimedia_canbox_helper.candump_start()
        time.sleep(3)
        self.multimedia_canbox_helper.cansend("00A#01")
        time.sleep(5)
        self.multimedia_canbox_helper.cansend("00A#00")
        time.sleep(3)
        t_str = self.multimedia_canbox_helper.candump_end()
        self.logger.debug("str=%s" % t_str)

    def test3(self):
        from testlib.graphics.common import adb32
        adb32.adb_disable_verity()
Пример #4
0
class CameraTest(CameraTestBase):
    """
    @summary: This test used to test camera function
    """

    def setUp(self):
        """
        @summary: set up
        @return: None
        """
        super(CameraTest, self).setUp()
        self._test_name = __name__
        print "[Setup]: %s" % self._test_name

    def tearDown(self):
        """
        @summary: tearDown
        @return: None
        """
        super(CameraTest, self).tearDown()
        print "[Teardown]: %s" % self._test_name
        g_common_obj.stop_exp_handle()
        time.sleep(3)

    def appPrepare(self):
        self.camera = CameraCommon().switchPlatform()
        self.checkImage = CheckImage()
        self.multimedia_setting = MultiMediaSetting(CameraCommon.DEFAULT_CONFIG_FILE)
        self.video = CheckVideo()
        self.host_path = CameraCommon().getTmpDir()
        self.makefileTime = CameraCommon().makefileTime
        self.camera_dir = CameraCommon().camera_dir
        CameraCommon().removeDeivceFile()
        CameraCommon().removeFile(self.host_path + "/*")
        self.camera.cleanMediaFiles()
        CameraCommon().setOrientationToVertical()
        self.logger.debug("app prepare successfully")

    def checkFileCorrupt(self, mediaFileCount=1):
        return CameraCommon().checkFileCorrupt(mediaFileCount)

    def markLocationTest(self):
        try:
            self.appPrepare()
            self.camera.startCameraApp()
            self.camera.setLocation("ON")
            self.camera.capturePhoto()
            self.checkFileCorrupt()
        except Exception as e:
            CameraCommon().checkCameraCrash()
            self.assertTrue(False, e)

    def capturePictureTimer(self, lens):
        try:
            self.appPrepare()
            self.camera.startCameraApp()
            self.camera.selectMode("Camera")
            self.camera.switchRearOrFront(lens)
            self.camera.setTimer("3s")
            self.camera.capturePhoto(1, False)
            if CameraCommon().checkDeviceFile():
                self.assertTrue(False, "file exists, check file failed")
            time.sleep(3)
            CameraCommon().waitForTheFilesAreGenerated()
            if not CameraCommon().checkDeviceFile():
                self.assertTrue(False, "file not exists, check file failed")
            self.checkFileCorrupt()
        except Exception as e:
            CameraCommon().checkCameraCrash()
            self.assertTrue(False, e)

    def goThroughImageQualityAndPanoResolution(self):
        try:
            self.appPrepare()
            self.camera.startCameraApp()
            self.camera.selectMode("Panorama")
            mDict = self.camera.getAllPanoramaResolution()[0]
            for k in mDict:
                self.camera.setPanoramaResolution(mDict[k])
                self.camera.capturePhoto(1,False)
                time.sleep(3)
                self.camera.clickPanoramaDoneBtn()
                time.sleep(3)
                CameraCommon().waitForTheFilesAreGenerated()
        except Exception as e:
            CameraCommon().checkCameraCrash()
            self.assertTrue(False, e)

    def cameraPressShutterKeyQuicklyPanoramaModeTest(self):
        try:
            self.appPrepare()
            self.camera.startCameraApp()
            self.camera.selectMode("Panorama")
            x,y = self.camera.clickShutterBtnArea("Panorama")
            CameraCommon().clickBtn(x, y)
            CameraCommon().checkCameraCrash()
            time.sleep(3)
            self.camera.clickPanoramaDoneBtn()
            time.sleep(20)
            self.checkFileCorrupt()
        except Exception as e:
            CameraCommon().checkCameraCrash()
            self.assertTrue(False, e)

    def cameraPanoramaModeRecentlyApplicationKeyTest(self,loop):
        try:
            self.appPrepare()
            CameraCommon().removeAllAppFromRecentTask()
            for i in range(int(loop)):
                self.logger.debug("***** loop %d *****" %(i + 1))
                self.camera.startCameraApp()
                self.camera.selectMode("Panorama")
                CameraCommon().enterAppFromRecentTask("Camera")
                self.camera.capturePhoto(1,False)
                CameraCommon().enterAppFromRecentTask("Camera")
                CameraCommon().checkCameraCrash()
                self.camera.capturePhoto(1,False)
                time.sleep(3)
                self.camera.clickPanoramaDoneBtn()
                time.sleep(2)
                CameraCommon().enterAppFromRecentTask("Camera")
                CameraCommon().checkCameraCrash()
        except Exception as e:
            CameraCommon().checkCameraCrash()
            self.assertTrue(False, e)

    def fullStorageBeforeCaptureTest(self, mode):
        """
        make the sdcard full, and to see the camera shutter button behavior
        @param mode: the camera mode, see the config file, tag is 
            low_resource_lensblur|low_resource_panorama|low_resource_photoSphere
        """
        try:
            self.appPrepare()
            self.logger.debug("fill the memory")
            CameraCommon().fillStorage(40)
            self.camera.startCameraApp()
            self.logger.debug("To get the internal memory capacity")
            self.camera.selectMode(mode)
            self.logger.debug("shutter button enabled or not: " + str(self.camera.checkShutterButtonAttribute("clickable")))
            assert self.camera.checkShutterButtonAttribute("clickable") == False, "The storage is full, but the shutterbutton is still workable"
        except Exception as e:
            CameraCommon().checkCameraCrash()
            self.assertTrue(False, e)

    def cameraPhotoSpherePressFinishButtonQuicklyTest(self):
        try:
            self.appPrepare()
            self.camera.startCameraApp()
            self.camera.selectMode("Photo Sphere")
            self.camera.capturePhoto()
            self.camera.clickDoneBtn()
            CameraCommon().checkCameraCrash()
        except Exception as e:
            CameraCommon().checkCameraCrash()
            self.assertTrue(False, e)

    def cameraPanoramaLackStorageTest(self):
        try:
            self.appPrepare()
            self.logger.debug("fill the memory")
            CameraCommon().fillStorage(350)
            self.camera.startCameraApp()
            self.camera.selectMode("Panorama")
            start_time = time.time()
            while True:
                run_time = time.time()
                free_space = CameraCommon().getSdcardMemory()[2]
                print free_space, run_time
                if free_space < 300 or run_time - start_time > 600:
                    break
                self.camera.capturePhoto()
                self.camera.clickDoneBtn()
            for i in range(5):
                CameraCommon().pressBack()
                self.camera.startCameraApp()
            CameraCommon().checkCameraCrash()
            self.checkFileCorrupt()
        except Exception as e:
            CameraCommon().checkCameraCrash()
            self.assertTrue(False, e)

    def cameraPanoramaLockAndUnlockTest(self,loop):
        try:
            self.appPrepare()
            self.multimedia_setting.install_apk("unlock_app")
            CameraCommon().lockScreen()
            self.camera.startCameraApp()
            self.camera.selectMode("Panorama")
            self.camera.switchRearOrFront("Back")
            for i in range(int(loop)):
                self.logger.debug("=====camera panorama mode lock and unlock test loop %d =====" % (i + 1))
                CameraCommon().clickScreenCenter()
                CameraCommon().pressPower()
                CameraCommon().getScreenshotAndPullToHost("sc1.png", self.host_path)
                time.sleep(2)
                self.logger.debug(str(self.checkImage.brightness(self.host_path + "/sc1.png")))
                if self.checkImage.brightness(self.host_path + "/sc1.png") > 30.0:
                    assert False, "front camera preview screen Lock fail"
#                 CameraCommon().unlockScreen()
                CameraCommon().launchUnlockAppToUnlockScreen()
                self.camera.capturePhoto()
                self.logger.debug("front camera capture photo")
                if not CameraCommon().waitForTheFilesAreGenerated(1):
                    self.camera.capturePhoto()
                CameraCommon().waitForTheFilesAreGenerated()
                self.camera.swipeScreen("left")
                CameraCommon().pressPower()
                CameraCommon().getScreenshotAndPullToHost("sc2.png", self.host_path)
                time.sleep(2)
                self.logger.debug(str(self.checkImage.brightness(self.host_path + "/sc2.png")))
                if self.checkImage.brightness(self.host_path + "/sc2.png") > 30.0:
                    assert False, "front camera preview screen Lock fail"
                CameraCommon().launchUnlockAppToUnlockScreen()
                CameraCommon().checkCameraCrash()
            self.checkFileCorrupt()
            self.camera.reviewPhotoAndVideo()
            CameraCommon().lockScreen(False)
        except Exception as e:
            CameraCommon().checkCameraCrash()
            CameraCommon().lockScreen(False)
            self.assertTrue(False, e)

    def cameraPanoramaPowerOffBySoftwareKeyTest(self):
        try:
            self.appPrepare()
            self.camera.startCameraApp()
            self.camera.selectMode("Panorama")
            g_common_obj2.system_reboot()
            CameraCommon().unlockScreen()
            self.camera.startCameraApp()
            self.camera.selectMode("Panorama")
            CameraCommon().clickScreenCenter()
            self.camera.capturePhoto()
            g_common_obj2.system_reboot()
            CameraCommon().unlockScreen()
            self.camera.startCameraApp()
            CameraCommon().clickScreenCenter()
            self.camera.enterPreviewPhotos()
            self.camera.capturePhoto()
            self.camera.enterPreviewPhotos()
            g_common_obj2.system_reboot()
            CameraCommon().unlockScreen()
            self.camera.startCameraApp()
            CameraCommon().clickScreenCenter()
            self.camera.enterPreviewPhotos()
            self.checkFileCorrupt()
        except Exception as e:
            CameraCommon().checkCameraCrash()
            self.camera.stopCameraApp()
            self.assertTrue(False, e)


    def test_Camera_LensBlur_FullStorage(self):
        self.fullStorageBeforeCaptureTest("Lens Blur")

    def test_Camera_Panorama_FullStorage(self):
        self.fullStorageBeforeCaptureTest("Panorama")

    def test_Camera_PhotoSphere_FullStorage(self):
        self.fullStorageBeforeCaptureTest("Photo Sphere")

    def test_Camera_Panorama_RecentlyApplicationKey(self):
        self.cameraPanoramaModeRecentlyApplicationKeyTest(20)

    def test_Camera_Panorama_PressShutterKeyQuickly(self):
        self.cameraPressShutterKeyQuicklyPanoramaModeTest()

    def test_Camera_Panorama_ResolutionSetting(self):
        self.goThroughImageQualityAndPanoResolution()

    def test_Camera_Launch_FirstLaunchCamera_MarkLocation(self):
        self.markLocationTest()

    def test_Camera_Timer_Front_3s(self):
        self.capturePictureTimer("Front")

    def test_Camera_Timer_Rear_3s(self):
        self.capturePictureTimer("Back")

    def test_Camera_PhotoSphere_PressFinishButtonQuickly(self):
        self.cameraPhotoSpherePressFinishButtonQuicklyTest()

    def test_Camera_Panorama_LackStorage(self):
        self.cameraPanoramaLackStorageTest()

    def test_Camera_Panorama_LockAndUnlock(self):
        self.cameraPanoramaLockAndUnlockTest(20)

    def test_Camera_Panorama_PowerOffBySoftwareKey(self):
        self.cameraPanoramaPowerOffBySoftwareKeyTest()
Пример #5
0
class VideoEncode(TestCaseBase):
    """
    @summary: Test Video encode
    """

    def setUp(self):
        """
        @summary: set up
        @return: None
        """
        super(VideoEncode, self).setUp()
        self.d = g_common_obj.get_device()
        self.x = self.d.info["displayWidth"]
        self.y = self.d.info["displayHeight"]
        self._test_name = __name__
        self.tag = "[Video Encode] "
        logger.debug(self.tag + 'run case name is ' + sys._getframe().f_back.f_code.co_name)
        logger.debug(self.tag + '[Setup]: ' + self._test_name)
        g_common_obj.stop_app_am("com.google.android.GoogleCamera")
        # Unlock screen
        g_common_obj.adb_cmd_capture_msg("input keyevent 82")

    def tearDown(self):
        """
        @summary: tearDown
        @return: None
        """
        super(VideoEncode, self).tearDown()
        print "[Teardown]: %s" % self._test_name
        g_common_obj.stop_exp_handle()
        time.sleep(3)
        g_common_obj.stop_app_am("com.google.android.GoogleCamera")
        time.sleep(3)
        g_common_obj.adb_cmd_capture_msg(" rm -rf /sdcard/DCIM/Camera/*")
        time.sleep(10)
        g_common_obj.adb_cmd_capture_msg(self.video.cfg.get("refresh_sd"))

    def appPrepare(self, case_name):
        cfg_file = os.path.join(os.environ.get('TEST_DATA_ROOT', ''), \
            'tests.tablet.mum_auto_video.conf')
        self.video = PhotosImpl(\
            self.config.read(cfg_file, case_name))
        self.camera = CameraImpl(\
            self.config.read(cfg_file, case_name))
        self.multimedia_handle = MultiMediaHandle()
        g_common_obj.adb_cmd_capture_msg(" rm -rf /sdcard/DCIM/Camera/*")
        g_common_obj.adb_cmd_capture_msg(self.video.cfg.get("refresh_sd"))
        
        self.multimedia_setting = MultiMediaSetting(cfg_file)
        self.multimedia_setting.install_apk("video_apk")
        self.multimedia_setting.install_apk("alarm_apk")
        self.multimedia_setting.install_apk("ffmpegCLI_apk")
        self.multimedia_setting.install_apk("EncodeAndMux_4K_Encode_apk")
        self.video.set_orientation_n()
        self.camera.clean_up_camera_data()
        if self.video.cfg.get("push_video") != None:
            self.multimedia_setting.clearFolder(self.video.cfg.get("remove_video"))
            self.push_path = self.multimedia_setting.push_file(self.video.cfg.get("push_video"), self.video.cfg.get("datapath"))

    def launchRecordAPP(self):
        SystemUI().unlock_screen()
        for _ in range(3):
            g_common_obj.launch_app_am("com.intel.vpg.tool", \
                                   "com.intel.vpg.tool.ConfActivity")
            time.sleep(3)
            if self.d(textContains="Vpg Media Tool").exists:
                return
        assert self.d(textContains="Vpg Media Tool").exists, "launch record app failed!"

    def launchVideoRecTestAPP(self):
        logger.debug(self.tag + "Start to launch VideoRecTest")
        for _ in range(3):
            g_common_obj.launch_app_am("com.intel.mchen33.videorectest", \
                                       ".MainActivity")
            time.sleep(3)
            if self.d(resourceId="com.intel.mchen33.videorectest:id/surfaceViewPreview").exists:
                return
        assert self.d(resourceId="com.intel.mchen33.videorectest:id/surfaceViewPreview").exists, "launch VideoRecTest app failed!"

    def videoRectTestRecod(self, encode_type='ST_VIDEO_REC_ENCODE_001'):
        for _ in range(3):
            self.d(resourceId="android:id/text1").click()
            self.d(scrollable=True).scroll.to(text=encode_type)
            self.d(text=encode_type).click()
            if self.d(text=encode_type).exists:
                logger.debug(self.tag + "set the encode type to %s" % encode_type)
                break
        try:
            self.d(text="Start").click()
            self.multimedia_setting.getScreenshotToHost("Video_Rec_Encode.png", g_common_obj.get_user_log_dir())
            time.sleep(2)
            assert not self.d(text="Failed").exists, "Cannot recoder this video"
            logger.debug(self.tag + "Start to record 15 seconds")
            time.sleep(15)
            self.d(text="Stop").click()
        except Exception as e:
            logger.error(self.tag + "Record fail, Exception:%s" % e)
            return False
        logger.debug(self.tag + "Record success")
        return True

    def checkVideoRecTestfile(self, encode_type='ST_VIDEO_REC_ENCODE_001', flag=True):
        import re
        size_pattern = re.compile("sdcard_rw(.*)20")
        file_path = '/sdcard/' + encode_type + '*'
        cmd = "shell ls -l %s" % (file_path)
        # result = g_common_obj.adb_cmd_capture_msg(cmd)
        result = self.multimedia_setting.execute_adb_command(cmd)
        size = re.findall(size_pattern, result)
        assert ("No such file or directory" not in result) == flag, "Record file status error! result=%s" % (result)
        if size != []:
            assert str(0) != size[0], "Record file size is zero, error!"
        g_common_obj.pull_file(g_common_obj.get_user_log_dir(), file_path)
        logger.debug(self.tag + "record file:" + result)
        logger.debug(self.tag + "record file exist")
        return True


    def clickRecordButton(self, record_file_name, record_type):
        self.d(className="android.widget.Spinner").click()
        self.d(textContains="VIDEO RECORDER").click()
        self.d(className="android.widget.EditText").set_text(record_file_name)
        self.d(className="android.widget.ScrollView").scroll.to(textContains="Use MediaCodec Encoder")
        self.d(textContains="Use MediaCodec Encoder").click()
        self.d(className="android.widget.ScrollView").scroll.to(textContains="APPLY")
        self.d(textContains="video/").click()
        self.d(text=record_type).click()
        self.d(className="android.widget.ScrollView").scroll.to(textContains="APPLY")
        self.d(textContains="APPLY").click()
        time.sleep(2)
        self.d.click(self.x/2,self.y/2)

    def deleteCameraRecordFile(self, file_name):
        cmd = "shell rm /sdcard/Pictures/VpgMediaTool/%s" % (file_name)
        g_common_obj.adb_cmd_common(cmd)

    def checkCameraRecordFile(self, file_name, flag=True):
        cmd = "shell ls /sdcard/Pictures/VpgMediaTool/%s" % (file_name)
        #result = g_common_obj.adb_cmd_capture_msg(cmd)
        result = self.multimedia_setting.execute_adb_command(cmd)
        logger.debug("camera file:" + result)
        assert ("No such file or directory" not in result) == flag, "Record file status error! result=%s" % (result)

    def changeCameraTypeStr(self, camera_type):
        if "Back" in camera_type:
            return "Back"
        return "Front"
            

    def videoEncodeThenPlayback(self, case_name):
        """
        This test used to test video encode then playback
        The test case spec is following:
        1. Launch camera
        2. record video
        3. playback
        """
        print "run case is " + str(case_name)
        self.appPrepare(case_name)
        self.multimedia_camera_helper = MultiMediaCameraHelper()
        self.multimedia_camera_helper.camera.startCameraApp()
        self.multimedia_camera_helper.camera.selectMode("Video")
        camera_type = self.changeCameraTypeStr(self.video.cfg.get("camera_type"))
        self.multimedia_camera_helper.camera.switchRearOrFront(camera_type)
        self.multimedia_camera_helper.camera.clickRecordBtn()
        time.sleep(int(self.video.cfg.get("record_time")))
        self.multimedia_camera_helper.camera.clickRecordBtn()
        time.sleep(5)
        self.multimedia_camera_helper.camera.reviewPhotoAndVideo()
        print "case " + str(case_name) + " is pass"

    def recordingWithVPGTool(self, case_name):
        print "run case is " + str(case_name)
        self.appPrepare(case_name)
        self.multimedia_setting.install_apk("vpg_apk")
        file_name = self.video.cfg.get("file_name")
        record_type = self.video.cfg.get("record_type")
        self.deleteCameraRecordFile(file_name)
        self.checkCameraRecordFile(file_name, False)
        self.launchRecordAPP()
        self.clickRecordButton(file_name.split(".")[0], record_type)
        time.sleep(2)
        assert not self.d(text="Unfortunately, Vpg Media Tool has stopped.").exists, "Vpg app error!!!"
        time.sleep(10)
        self.d.click(self.x/2,self.y/2)
        time.sleep(3)
        self.checkCameraRecordFile(file_name)
        print "case " + str(case_name) + " is pass"

    def recordingWithVideoRectest(self, case_name):
        logger.debug(self.tag + 'run case name is ' + sys._getframe().f_back.f_code.co_name)
        self.appPrepare(case_name)
        self.multimedia_setting.install_apk("rec_apk")
        encode_type = self.video.cfg.get("encode_type")
        g_common_obj.adb_cmd_capture_msg(self.video.cfg.get("remove_video"))
        #file_name = self.video.cfg.get("file_name")
        self.launchVideoRecTestAPP()
        assert self.videoRectTestRecod(encode_type) , "Record failed"
        assert self.checkVideoRecTestfile(encode_type), "Record file not exist"
        logger.debug(self.tag + 'run %s is pass '%sys._getframe().f_back.f_code.co_name)


    def videoEncodeSettingResolutionThenPlayback(self, case_name):
        """
        This test used to test video encode then playback
        The test case spec is following:
        1. Launch camera
        2. set resolution
        3. record video
        4. playback
        """
        print "run case is " + str(case_name)
        self.appPrepare(case_name)
        self.multimedia_camera_helper = MultiMediaCameraHelper()
        self.multimedia_camera_helper.camera.startCameraApp()
        self.multimedia_camera_helper.camera.selectMode("Video")
        camera_type = self.changeCameraTypeStr(self.video.cfg.get("camera_type"))
        print camera_type
        if "bxtp" in self.multimedia_setting.get_paltform_hardware():
            logger.debug("For BXT, do not switch Rear/Front")
        else:
            self.multimedia_camera_helper.camera.switchRearOrFront(camera_type)
        resolution = self.multimedia_camera_helper.changeResolution(self.camera.cfg.get("resolution"))
        self.multimedia_camera_helper.camera.setVideoResolution(resolution, camera_type)
        self.multimedia_camera_helper.camera.recordVideo(1, int(self.video.cfg.get("record_time")))
        self.multimedia_camera_helper.camera.reviewPhotoAndVideo()
        print "case " + str(case_name) + " is pass"

    def videoEncodeSettingResolution(self, case_name):
        """
        This test used to test video encode then playback
        The test case spec is following:
        1. Launch camera
        2. set resolution
        3. record video
        4. playback
        """
        print "run case is " + str(case_name)
        self.appPrepare(case_name)
        self.camera.enter_camera_from_home()
        self.camera.switch_module_in_camera()
        self.camera.change_front_back_camera(self.video.cfg.get("camera_type"))
        self.camera.click_camera_menu_setting_vert()
        self.camera.enter_camera_setting_video_quality()
        self.camera.set_camera_setting_video_quality(self.video.cfg.get("resolution"),self.video.cfg.get("camera_type"))
        self.camera.press_back()
        self.camera.press_back()
        self.camera.capture_video_camera_initial_page(recordTime=self.video.cfg.get("record_time"))
        print "case " + str(case_name) + " is pass"

    def videoEncodeCapturePauseMultipleTimes(self, case_name):
        """
        This test used to test video encode then playback
        The test case spec is following:
        1. Launch camera
        2. set resolution
        3. Start/stop capturing video for multiple times quickly
        """
        print "run case is " + str(case_name)
        self.appPrepare(case_name)
        self.camera.enter_camera_from_home()
        self.camera.switch_module_in_camera()
        self.camera.change_front_back_camera(self.video.cfg.get("camera_type"))
        self.camera.click_camera_menu_setting_vert()
        self.camera.enter_camera_setting_video_quality()
        self.camera.set_camera_setting_video_quality(self.video.cfg.get("resolution"),self.video.cfg.get("camera_type"))
        self.camera.press_back()
        self.camera.press_back()
        self.camera.camera_video_capture_pause(self.video.cfg.get("click_times"))
        print "case " + str(case_name) + " is pass"

    def videoEncodeLongLasting(self, case_name):
        """
        This test used to test video encode then playback
        The test case spec is following:
        1. Launch camera
        2. record video
        """
        print "run case is " + str(case_name)
        self.appPrepare(case_name)
        self.camera.enter_camera_from_home()
        self.camera.switch_module_in_camera()
        self.camera.change_front_back_camera(self.camera.cfg.get("camera_type"))
        self.camera.click_camera_menu_setting_vert()
        self.camera.enter_camera_setting_video_quality()
        self.camera.set_camera_setting_video_quality(self.camera.cfg.get("resolution"),self.camera.cfg.get("camera_type"))
        self.camera.press_back()
        self.camera.press_back()
        start_time = time.time()
        record_time = int(self.camera.cfg.get("record_time"))
        while record_time > 0:
            record_time = record_time - (time.time() - start_time)
            total, used, free = self.multimedia_setting.get_sdcard_memory()
            if free < (total/30):
                g_common_obj.adb_cmd_capture_msg(" rm -rf /sdcard/DCIM/Camera/*")
                g_common_obj.adb_cmd_capture_msg(self.camera.cfg.get("refresh_sd"))
            self.camera.capture_video_camera_initial_page(record_time)
            print "case " + str(case_name) + " is pass"
 
    def videoEncodeIteration(self, case_name):
        """
        This test used to test video encode then playback
        The test case spec is following:
        1. Launch camera
        2. record video
        3. playback
        """
        print "run case is " + str(case_name)
        self.appPrepare(case_name)
        self.multimedia_camera_helper = MultiMediaCameraHelper()
        self.multimedia_camera_helper.camera.startCameraApp()
        self.multimedia_camera_helper.camera.selectMode("Video")
        camera_type = self.changeCameraTypeStr(self.video.cfg.get("camera_type"))
        if "bxtp" in self.multimedia_setting.get_paltform_hardware():
            logger.debug("For BXT, do not switch Rear/Front")
        else:
            self.multimedia_camera_helper.camera.switchRearOrFront(camera_type)
        resolution = self.multimedia_camera_helper.changeResolution(self.camera.cfg.get("resolution"))
        self.multimedia_camera_helper.camera.setVideoResolution(resolution, camera_type)
        record_times = int(self.camera.cfg.get("record_times"))
        record_time = int(self.camera.cfg.get("record_time"))
        for index in range(record_times):
            print "record_times is ", index
            total, used, free = self.multimedia_setting.get_sdcard_memory()
            if free < (total/30):
                g_common_obj.adb_cmd_capture_msg(" rm -rf /sdcard/DCIM/Camera/*")
                g_common_obj.adb_cmd_capture_msg(self.camera.cfg.get("refresh_sd"))
                break
            self.multimedia_camera_helper.camera.recordVideo(1, record_time)
        print "case " + str(case_name) + " is pass"

    def videoEncodeTillFull(self, case_name):
        """
        This test used to test video encode then playback
        The test case spec is following:
        1. Launch camera
        2. record video till memory full
        3. playback
        """
        print "run case is " + str(case_name)
        self.appPrepare(case_name)
        self.multimedia_camera_helper = MultiMediaCameraHelper()
        self.multimedia_camera_helper.camera.startCameraApp()
        self.multimedia_camera_helper.camera.selectMode("Video")
        camera_type = self.changeCameraTypeStr(self.video.cfg.get("camera_type"))
        if "bxtp" in self.multimedia_setting.get_paltform_hardware():
            logger.debug("For BXT, do not switch Rear/Front")
        else:
            self.multimedia_camera_helper.camera.switchRearOrFront(camera_type)
        resolution = self.multimedia_camera_helper.changeResolution(self.camera.cfg.get("resolution"))
        self.multimedia_camera_helper.camera.setVideoResolution(resolution, camera_type)
        self.multimedia_camera_helper.camera.clickRecordBtn()
        time.sleep(5)
        record_time= int(self.video.cfg.get("lasting_time"))
        startTime=time.time()
        while True:
            if time.time() - startTime < record_time:
                if not self.multimedia_camera_helper.camera.isRecordTimeExists():
                    break
            else:
                self.multimedia_camera_helper.camera.clickRecordBtn()
                break
            time.sleep(10)
        time.sleep(5)
        self.multimedia_camera_helper.camera.reviewPhotoAndVideo()
        print "case " + str(case_name) + " is pass"

    def launchFFmpeg(self):
        SystemUI().unlock_screen()
        for _ in range(3):
            g_common_obj.launch_app_am("com.silentlexx.ffmpeggui", ".Gui")
            time.sleep(2)
            if self.d(textContains="Allow FFmpeg Media Encoder to access photo").exists:
                self.d(resourceId="com.android.packageinstaller:id/permission_allow_button").click()
            if self.d(text="FFmpeg Media Encoder").exists:
                return
        assert self.d(text="FFmpeg Media Encoder").exists, "launch FFmpeg app failed!"

    def encodevideo(self, in_file_path='', e_resolution='1080x720', e_type='3gp' ):
        input_file= self.d(resourceId='com.silentlexx.ffmpeggui:id/in_file')
        if input_file.exists and (in_file_path != input_file.text):
            input_file.click()
            while input_file.text != '':

                g_common_obj.adb_cmd_common("shell input keyevent DEL")
            g_common_obj.adb_cmd_common("shell input text %s" % in_file_path)

        output_type = self.d(resourceId='com.silentlexx.ffmpeggui:id/sp_ext').child(resourceId='android:id/text1')
        output_type.click()
        try:
            self.d(scrollable=True).scroll.to(text=e_type).click()
        except:
            self.d(text=e_type).click()

        encode_type = self.d(resourceId='com.silentlexx.ffmpeggui:id/preset').child(resourceId='android:id/text1')
        encode_type.click()
        try:
            self.d(scrollable=True).scroll.to(text="Video 3gp (h263/aac/qcif)").click()
        except:
            self.d(text='Video 3gp (h263/aac/qcif)').click()

        enable_setres = self.d(resourceId='com.silentlexx.ffmpeggui:id/setres')
        input_x = self.d(resourceId='com.silentlexx.ffmpeggui:id/rx')
        input_y = self.d(resourceId='com.silentlexx.ffmpeggui:id/ry')
        if input_x.exists and not input_file.click():
            enable_setres.click()

        iter_x = 5
        iter_y = 5
        if input_x.text !=  e_resolution.split('x')[0]:
            while input_x.text != '' and iter_x > 0:

                g_common_obj.adb_cmd_common("shell input keyevent DEL")
                iter_y -= 1
            input_x.click()
            g_common_obj.adb_cmd_common("shell input text %s" % e_resolution.split('x')[0])

        if input_y.text !=  e_resolution.split('y')[0]:
            while input_y.text != '' and iter_y > 0:
                g_common_obj.adb_cmd_common("shell input keyevent DEL")
                iter_y -= 1
            input_y.click()
            g_common_obj.adb_cmd_common("shell input text %s" % e_resolution.split('x')[1])

        self.d(resourceId='com.silentlexx.ffmpeggui:id/run').click()

    def recordingWithWithFFmpeg(self, casename=''):
        self.appPrepare(casename)
        self.launchFFmpeg()
        self.encodevideo(self.video.cfg.get("push_video").split('"')[-2], self.video.cfg.get("resolution"), \
                         self.video.cfg.get("encode_type"))

    def launchFFmpegCLI(self):
        SystemUI().unlock_screen()
        for _ in range(3):
            g_common_obj.launch_app_am("org.magiclen.ffmpeg.cli", ".activities.CommandActivity")
            time.sleep(2)
            if self.d(textContains="Allow FFmpeg CLI to access").exists:
                self.d(resourceId="com.android.packageinstaller:id/permission_allow_button").click()
            if self.d(text="FFmpeg CLI").exists:
                logger.debug(self.tag + "launch FFmpeg CLI app success!")
                return
        assert self.d(text="FFmpeg CLI").exists, "launch FFmpeg CLI app failed!"

    def encodevideoViaFFmpegCLI(self, encode_cmd=''):
        logger.debug(self.tag + "start to encode video via FFmpeg CLI APP!")
        encode_cmd_box= self.d(resourceId='org.magiclen.ffmpeg.cli:id/etCLI')
        if encode_cmd_box.exists :
            encode_cmd_box.click()
            if ("Input FFmpeg's parameters here." != encode_cmd_box.text):
                while encode_cmd_box.text != '':
                    g_common_obj.adb_cmd_common("shell input keyevent DEL")
            g_common_obj.adb_cmd_common("shell input text %s" % encode_cmd)

        try:
            self.d(resourceId='org.magiclen.ffmpeg.cli:id/bCLI').click()
        except Exception as e:
            logger.error(self.tag + "Click Run button failed ,Excetpion:%s" % e)

        out_screen = self.d(resourceId='org.magiclen.ffmpeg.cli:id/tvScreen')
        for _ in range(15):
            time.sleep(3)
            if "Qavg: 0.00" in out_screen.text:
                logger.debug(self.tag + "encode done")
                return True
        return False

    def checkEncodeVideo(self, play_file='', check_hang=True):
        if g_common_obj.adb_cmd_common("shell getprop ro.hardware") in ['gordon_peak']:
            assert self.multimedia_handle.playVideoviaOGallery(play_file), 'launch encode video failed'
            if check_hang:
                return self.multimedia_handle.checkVideoPlayHang()
            else:
                return True
        else:
            self.multimedia_handle.launchVideoApp()
            self.multimedia_handle.videoPlayBack(play_file)
            return self.multimedia_handle.checkVideoPlayBack()

    def recordingWithWithFFmpegCLI(self, casename=''):
        self.appPrepare(casename)
        self.launchFFmpegCLI()
        assert self.encodevideoViaFFmpegCLI(self.video.cfg.get("encode_cmd")), 'encode video failed'
        assert self.checkEncodeVideo(self.video.cfg.get("output_file")), "check encode video failed"


    def recordingWithWith4KEncode(self, casename=''):
        self.appPrepare(casename)
        self.launch4KEncode()
        self.encodevideoVia4KEncode(Encode_type=self.video.cfg.get("encode_type"))
        assert self.checkEncodeVideo(self.video.cfg.get("output_file"),check_hang=False), "check encode video failed"

    def launch4KEncode(self):
        """
        A method to launch testEncodeAndMux_4K_Encode.apk
        :return: True, launch success.
        """
        SystemUI().unlock_screen()
        for _ in range(3):
            g_common_obj.launch_app_am("com.intel.mchen33.testencodeandmux", ".MainActivity")
            time.sleep(1)
            if self.d(text="testEncodeAndMux").exists:
                logger.debug(self.tag + "launch testEncodeAndMux_4K_Encode app success!")
                return True
        assert self.d(text="testEncodeAndMux").exists, "launch testEncodeAndMux_4K_Encode app failed!"

    def encodevideoVia4KEncode(self,Encode_type='GO VP8 3840x2160 30fps'):
        """
        A method to encode via testEncodeAndMux_4K_Encode.apk
        :return: True, Encode finished.
        """
        if Encode_type=='VP8':
            if self.d(text='GO H.264 3840x2160 30fps').exists:
                logger.debug(self.tag + "try to encode GO H.264 3840x2160 30fps" )
                self.d(text='GO VP8 3840x2160 30fps').click()
        else:
            if self.d(text='GO H.264 3840x2160 30fps').exists:
                logger.debug(self.tag + "try to encode GO H.264 3840x2160 30fps " )
                self.d(text='GO VP8 3840x2160 30fps').click()

        for _ in range(40):
            time.sleep(1)
            if not self.d(text="testEncodeAndMux").exists:
                logger.debug(self.tag + "launch testEncodeAndMux_4K_Encode app success!")
                return True
        return False

    def testVideoEncode_Longlasting_FrontCamera_480p_30mins(self):
        """
        This test used to test video record and playback
        The test case spec is following:
        1. Former name: test_video_encode_playback_mum_001
        """
        self.videoEncodeSettingResolutionThenPlayback('mum_test_video_encode_playback_001')

    def testVideoEncode_Longlasting_RearCamera_480p_30mins(self):
        """
        This test used to test video record and playback
        The test case spec is following:
        1. Former name: test_video_encode_playback_mum_002
        """
        self.videoEncodeSettingResolutionThenPlayback('mum_test_video_encode_playback_002')

    def testVideoEncode_Longlasting_RearCamera_720p_1280x720_30mins(self):
        """
        This test used to test video record and playback
        The test case spec is following:
        1. Former name: test_video_encode_playback_mum_003
        """
        self.videoEncodeSettingResolutionThenPlayback('mum_test_video_encode_playback_003')

    def testVideoEncode_Longlasting_RearCamera_1080p_1920x1080_30mins(self):
        """
        This test used to test video record and playback
        The test case spec is following:
        1. Former name: test_video_encode_playback_mum_004
        """
        self.videoEncodeSettingResolutionThenPlayback('mum_test_video_encode_playback_004')

    def test_video_encode_playback_mum_005(self):
        """
        This test used to test video record long lasting
        The test case spec is following:
        """
        self.videoEncodeLongLasting('mum_test_video_encode_playback_005')

    def testVideoEncode_Longlasting_FrontCamera_480p_60mins(self):
        """
        This test used to test video record long lasting
        The test case spec is following:
        1. Former name: test_video_encode_playback_mum_006
        """
        self.videoEncodeSettingResolutionThenPlayback('mum_test_video_encode_playback_006')

    def test_video_encode_playback_mum_007(self):
        """
        This test used to test video record long lasting
        The test case spec is following:
        """
        self.videoEncodeCapturePauseMultipleTimes('mum_test_video_encode_playback_007')

    def testVideoEncode_Longlasting_RearCamera_720p_PlaybackCheck(self):
        """
        This test used to test video record and playback
        The test case spec is following:
        1. Former name: test_video_encode_playback_mum_008
        """
        self.videoEncodeSettingResolutionThenPlayback('mum_test_video_encode_playback_008')

    def test_video_encode_playback_mum_009(self):
        """
        This test used to test video record and playback
        The test case spec is following:
        """
        self.videoEncodeSettingResolutionThenPlayback('mum_test_video_encode_playback_009')

    def test_video_encode_playback_mum_010(self):
        """
        This test used to test video record and playback
        The test case spec is following:
        """
        self.videoEncodeSettingResolutionThenPlayback('mum_test_video_encode_playback_010')

    def testVideoEncode_Longlasting_RearCamera_720p_PlaybackInParallel(self):
        """
        This test used to test video record and playback
        The test case spec is following:
        1. Former name: test_video_encode_playback_mum_011
        """
        self.videoEncodeSettingResolutionThenPlayback('mum_test_video_encode_playback_011')

    def testVideoEncode_Longlasting_RearCamera_720p_30mins(self):
        """
        This test used to test video record and playback
        The test case spec is following:
        1. Former name: test_video_encode_playback_mum_012
        """
        self.videoEncodeSettingResolutionThenPlayback('mum_test_video_encode_playback_012')

    def test_video_encode_playback_mum_013(self):
        """
        This test used to test video record long lasting
        The test case spec is following:
        """
        self.videoEncodeCapturePauseMultipleTimes('mum_test_video_encode_playback_013')

    def test_video_encode_playback_mum_014(self):
        """
        This test used to test video record long lasting
        The test case spec is following:
        """
        self.videoEncodeIteration('mum_test_video_encode_playback_014')

    def test_video_encode_playback_mum_015(self):
        """
        This test used to test video record long lasting
        The test case spec is following:
        """
        self.videoEncodeTillFull('mum_test_video_encode_playback_015')

    def testVideoEncode_Longlasting_FrontCamera_480p_Storagefull_PlaybackCheck(self):
        """
        This test used to test video record long lasting
        The test case spec is following:
        1. Former name: test_video_encode_playback_mum_016
        """
        self.videoEncodeTillFull('mum_test_video_encode_playback_016')

    def testVideoEncode_Longlasting_RearCamera_720p_Storagefull_PlaybackCheck(self):
        """
        This test used to test video record long lasting
        The test case spec is following:
        1. Former name: test_video_encode_playback_mum_017
        """
        self.videoEncodeTillFull('mum_test_video_encode_playback_017')

    def testVideoEncode_Longlasting_RearCamera_480p_Storagefull_PlaybackCheck(self):
        """
        This test used to test video record long lasting
        The test case spec is following:
        1. Former name: test_video_encode_playback_mum_018
        """
        self.videoEncodeTillFull('mum_test_video_encode_playback_018')

    def testVideoEncode_Iteration_FrontCamera_RecordStartStop_AudibleTones(self):
        """
        This test used to test video record long lasting
        The test case spec is following:
        1. Former name: test_video_encode_playback_mum_019
        """
        self.videoEncodeIteration('mum_test_video_encode_playback_019')

    def testVideoEncode_Longlasting_RearCamera_1080p_10mins_PlaybackCheck(self):
        """
        This test used to test video record long lasting
        The test case spec is following:
        1. Former name: test_video_encode_playback_mum_020
        """
        self.videoEncodeSettingResolutionThenPlayback('mum_test_video_encode_playback_020')

    def testVideoEncode_Longlasting_FrontCamera_480p_10mins_PlaybackCheck(self):
        """
        This test used to test video record long lasting
        The test case spec is following:
        1. Former name: test_video_encode_playback_mum_021
        """
        self.videoEncodeSettingResolutionThenPlayback('mum_test_video_encode_playback_021')

    def testAudible_tones_are_heard_video_record_start_and_stop_default_settings_rear_camera(self):
        """
        This test used to test video record long lasting
        The test case spec is following:
        1. Former name: test_API_video_playback_060
        """
        self.videoEncodeThenPlayback('test_API_video_playback_060')

    def testSimultaneous_encode_2way_video_H264(self):
        """
        This test used to test Video playback
        The test case spec is following:
        1. Launch recording app
        3. Recording
        """
        self.recordingWithVPGTool("test_API_video_playback_085")

    def testSimultaneous_encode_2way_video_H263(self):
        """
        This test used to test Video playback
        The test case spec is following:
        1. Launch recording app
        3. Recording
        """
        self.recordingWithVPGTool("test_API_video_playback_097")

    def testSimultaneous_encode_2way_video_VP8(self):
        """
        This test used to test Video playback
        The test case spec is following:
        1. Launch recording app
        3. Recording
        """
        self.recordingWithVPGTool("test_API_video_playback_098")

    def testVideo_Encode_H264_1920x1080_30fps_mp4(self):
        """
            This test used to encode with videoRectest app
            The test case spec is following:
            1. Launch recording app
            3. Recording
        """
        self.recordingWithVideoRectest("test_API_video_playback_133")

    def testVideo_Encode_H264_320x240_30fps_mp4(self):
        """
            This test used to encode with videoRectest app
            The test case spec is following:
            1. Launch recording app
            3. Recording
        """
        self.recordingWithVideoRectest("test_API_video_playback_134")

    def testVideo_Encode_H264_352x288_30fps_mp4(self):
        """
            This test used to encode with videoRectest app
            The test case spec is following:
            1. Launch recording app
            3. Recording
        """
        self.recordingWithVideoRectest("test_API_video_playback_135")

    def testVideo_Encode_H264_1280x720_30fps_mp4(self):
        """
            This test used to encode with videoRectest app
            The test case spec is following:
            1. Launch recording app
            3. Recording
        """
        self.recordingWithVideoRectest("test_API_video_playback_136")

    def testVideo_Encode_H264_720x480_30fps_3gp(self):
        """
            This test used to encode with videoRectest app
            The test case spec is following:
            1. Launch recording app
            3. Recording
        """
        self.recordingWithVideoRectest("test_API_video_playback_137")

    def testVideo_Rec_Encode_VP8_1920x1080_30fps_webm(self):
        """
            This test used to encode with videoRectest app
            The test case spec is following:
            1. Launch recording app
            3. Recording
        """
        self.recordingWithVideoRectest("test_API_video_playback_138")

    def testVideo_Rec_Encode_VP8_720x480_30fps_webm(self):
        """
            This test used to encode with videoRectest app
            The test case spec is following:
            1. Launch recording app
            3. Recording
        """
        self.recordingWithVideoRectest("test_API_video_playback_139")

    def testEncode_H264_3gp(self):
        """
            This test used to encode with videoRectest app
            The test case spec is following:
            1. Launch recording app
            3. Recording
        """
        self.recordingWithVideoRectest("mum_test_video_encode_playback_025")

    def testVideo_Encode_H263_128x96_30fps_3gp(self):
        """
            This test used to encode with FFmpeg CLI app
            The test case spec is following:
            1. Launch recording app
            3. Recording
        """
        self.recordingWithWithFFmpegCLI("mum_test_video_encode_playback_022")

    def testVideo_Encode_H263_352x288_30fps_3gp(self):
        """
            This test used to encode with FFmpeg CLI app
            The test case spec is following:
            1. Launch recording app
            3. Recording
        """
        self.recordingWithWithFFmpegCLI("mum_test_video_encode_playback_023")

    def testVideo_Encode_H263_176x144_30fps_3gp(self):
        """
            This test used to encode with FFmpeg CLI app
            The test case spec is following:
            1. Launch recording app
            3. Recording
        """
        self.recordingWithWithFFmpegCLI("mum_test_video_encode_playback_024")

    def testVP8_HW_4K_Encode(self):
        """
            This test used to encode with 4k Encode app
            The test case spec is following:
            1. Launch recording app
            3. Recording
        """
        self.recordingWithWith4KEncode("mum_test_video_encode_playback_026")
Пример #6
0
class ImageAPITest(UIATestBase):
    """
    @summary: Test Video PlayBack
    """

    def setUp(self):
        """
        @summary: set up
        @return: None
        """
        super(ImageAPITest, self).setUp()
        self.d = g_common_obj.get_device()
        self._test_name = __name__
        self.x = self.d.info["displayWidth"]
        self.y = self.d.info["displayHeight"]
        print "[Setup]: %s" % self._test_name
        g_common_obj.stop_app_am("com.intel.otc.instrument.otcphotos")
        # Unlock screen
        g_common_obj.adb_cmd_capture_msg("input keyevent 82")

    def tearDown(self):
        """
        @summary: tear tearDown
        @return: None
        """
        super(ImageAPITest, self).tearDown()
        print "[Teardown]: %s" % self._test_name
        g_common_obj.stop_exp_handle()
        time.sleep(3)
        g_common_obj.stop_app_am("com.intel.otc.instrument.otcphotos")
        time.sleep(1)
        g_common_obj.adb_cmd_capture_msg(self.video.cfg.get("remove_video"))

    def setTimeToSec(self, time):
        time = time.split(":")
        i = 1
        temp = 0
        for s in time[::-1]:
            temp += int(s) * i
            i *= 60
        return int(temp)

    def getOrientation(self):
        d = self.get_device()
        width = d.info["displayWidth"]
        height = d.info["displayHeight"]
        if width > height:
            return 1
        else:
            return 0

    def appPrepare(self, case_name, model=1):
        cfg_file = os.path.join(os.environ.get('TEST_DATA_ROOT', ''), \
            'tests.tablet.mum_auto_image.conf')
        self.video = PhotosImpl(\
            self.config.read(cfg_file, case_name))
        self.camera = CameraImpl(\
            self.config.read(cfg_file, case_name))
        
        self.multimedia_setting = MultiMediaSetting(cfg_file)
        self.multimedia_setting.install_apk("photo_apk")
        self.multimedia_setting.install_apk("alarm_apk")
        self.video.set_orientation_n()
        # Unlock screen
        g_common_obj.adb_cmd_capture_msg("input keyevent 82")

    def launchPhotoAPP(self):
        SystemUI().unlock_screen()
        for _ in range(3):
            g_common_obj.launch_app_am("com.intel.otc.instrument.otcphotos", \
                                   "com.intel.otc.instrument.otcphotos.MainActivity")
            time.sleep(3)
            if self.d(textContains="/").exists:
                return
        assert self.d(textContains="/").exists, "launch photo app failed!"

    def launchPhotoAPPWithShortCut(self):
        self.d.press.home()
        self.d(description="Apps").click()
        for _ in range(3):
            if self.d(textContains="Choose some apps").exists:
                self.d(text="OK").click()
        assert not self.d(text="OK").exists, "skip the tips failed!"
        while not self.d(text="otcphoto-app").exists:
            self.d(className="android.view.View").swipe.left()
        self.d(text="otcphoto-app").click()
        time.sleep(3)
        assert self.d(textContains="/").exists, "launch photo app failed!"

    def wait_boot_completed(self, timeout=1000):
        ''' wait Android boot_completed
    
        args: timeout -- optional timeout in second, default 180s
        '''
        count = 0
        sleep_time = 5
        while count < timeout:
            prop_val = adb.adb_cmd_capture_msg('getprop sys.boot_completed')
            if '1' in prop_val:
                print 'boot_completed'
                return
            count += sleep_time
            time.sleep(sleep_time)
        raise Exception('%ds timeout waiting for boot_completed' % timeout)

    def enterPhotoPath(self, path):
        push_str = path.strip("\"").split("/")
        if push_str[0] == "" and push_str[1] == "sdcard":
            push_str = push_str[2:]
        print push_str
        for t_str in push_str:
            if t_str != "":
                self.d(text=t_str).click()
                time.sleep(2)

    def checkPictureExist(self, file_name):
        assert self.d(text=file_name).exists, file_name + " not find!"

    def getPictureSize(self):
        scaleLabel = self.d(resourceId="com.intel.otc.instrument.otcphotos:id/scaleLabel").info["text"]
        return int(scaleLabel.strip("%"))

    def imageViewCheckWithWallpaper(self, case_name):
        print "run case is " + str(case_name)
        self.appPrepare(case_name)
        path = self.video.cfg.get("push_picture").split(" ")[-1].strip("\"")
        print path
        self.multimedia_setting.push_file(self.video.cfg.get("push_picture"), self.video.cfg.get("datapath"))
        self.launchPhotoAPP()
        self.enterPhotoPath(path)
        file_name = os.path.split(path)[1]
        self.checkPictureExist(file_name)
        self.d.press.back()
        self.d(text=file_name).long_click()
        self.d(text="Wallpaper").click()
        time.sleep(5)
        assert self.d(text="WallPaper is updated.").exists, "Set wallpaper failed!"
        print "case " + str(case_name) + " is pass"

    def imageViewCheckWithDelete(self, case_name):
        print "run case is " + str(case_name)
        self.appPrepare(case_name)
        path = self.video.cfg.get("push_picture").split(" ")[-1].strip("\"")
        print path
        self.multimedia_setting.push_file(self.video.cfg.get("push_picture"), self.video.cfg.get("datapath"))
        self.launchPhotoAPP()
        self.enterPhotoPath(path)
        file_name = os.path.split(path)[1]
        self.checkPictureExist(file_name)
        g_common_obj.adb_cmd_capture_msg(self.video.cfg.get("remove_video"))
        self.d.press.home()
        self.launchPhotoAPP()
        self.enterPhotoPath(os.path.split(path)[0])
        assert not self.d(text=file_name).exists, "%s file exist!" % file_name
        print "case " + str(case_name) + " is pass"

    def imageViewCheckWithMonoryFull(self, case_name):
        print "run case is " + str(case_name)
        self.appPrepare(case_name)
        g_common_obj.adb_cmd_capture_msg("rm -rf /storage/sdcard0/DCIM/Camera/*")
        self.camera.clean_up_camera_data()
        make_big_file.fill_no_space_except(int(self.camera.cfg.get("device_storage_limited")))
        path = self.video.cfg.get("push_picture").split(" ")[-1].strip("\"")
        print path
        self.multimedia_setting.push_file(self.video.cfg.get("push_picture"), self.video.cfg.get("datapath"))
        self.launchPhotoAPP()
        self.enterPhotoPath(path)
        file_name = os.path.split(path)[1]
        self.checkPictureExist(file_name)
        g_common_obj.adb_cmd_capture_msg("rm -rf /mnt/sdcard/bigfile")
        print "case " + str(case_name) + " is pass"

    def imageViewCheckWithUnlock(self, case_name):
        print "run case is " + str(case_name)
        self.appPrepare(case_name)
        path = self.video.cfg.get("push_picture").split(" ")[-1].strip("\"")
        print path
        self.multimedia_setting.push_file(self.video.cfg.get("push_picture"), self.video.cfg.get("datapath"))
        self.launchPhotoAPP()
        self.enterPhotoPath(path)
        self.checkPictureExist(os.path.split(path)[1])
        if 'bxtp_abl' in self.multimedia_setting.get_paltform_hardware():
            #  For BXT use relay card press power to sleep
            self.multimedia_setting.pressPowerKey()
            time.sleep(10)
            self.multimedia_setting.pressPowerKey()
        else:
            self.d.press.power()
            time.sleep(2)
            self.d.press.power()
        self.lock = SystemUI()
        self.lock.unlock_screen()
        time.sleep(1)
        self.checkPictureExist(os.path.split(path)[1])
        print "case " + str(case_name) + " is pass"

    def imageViewTenTimes(self, case_name, t_time=10):
        print "run case is " + str(case_name)
        self.appPrepare(case_name)
        path = self.video.cfg.get("push_picture").split(" ")[-1].strip("\"")
        print path
        self.multimedia_setting.push_file(self.video.cfg.get("push_picture"), self.video.cfg.get("datapath"))
        self.launchPhotoAPP()
        self.enterPhotoPath(path)
        file_name = os.path.split(path)[1]
        self.checkPictureExist(file_name)
        for _ in range(10):
            self.d.press.back()
            self.d(text=file_name).click()
            self.checkPictureExist(file_name)
        print "case " + str(case_name) + " is pass"

    def testMultiMedia_Gallery_CropPicture_LockScreen(self):
        """
        This test used to test Image Decode
        The test case spec is following:
        1. Open a picture
        """
        self.imageViewCheckWithUnlock("test_API_image_032")

    def testMultiMedia_Gallery3D_Select_Unselected_Items_20_Times(self):
        """
        This test used to test Image Decode
        The test case spec is following:
        1. Open a picture
        """
        self.imageViewTenTimes("test_API_image_033", 20)

    def testImage_View_Edit_GIF(self):
        """
        This test used to test Image Decode
        The test case spec is following:
        1. Open a picture
        """
        self.imageViewCheckWithWallpaper("test_API_image_034")

    def testImage_View_Edit_JPG(self):
        """
        This test used to test Image Decode
        The test case spec is following:
        1. Open a picture
        """
        self.imageViewCheckWithWallpaper("test_API_image_035")

    def testImage_View_Edit_BMP(self):
        """
        This test used to test Image Decode
        The test case spec is following:
        1. Open a picture
        """
        self.imageViewCheckWithWallpaper("test_API_image_036")

    def testImage_View_Edit_WBMP(self):
        """
        This test used to test Image Decode
        The test case spec is following:
        1. Open a picture
        """
        self.imageViewCheckWithWallpaper("test_API_image_037")

    def testImage_Edit_Save_With_Memory_Full(self):
        """
        This test used to test Image Decode
        The test case spec is following:
        1. Open a picture
        """
        self.imageViewCheckWithMonoryFull("test_API_image_039")

    def testImage_View_Edit_WEBP(self):
        """
        This test used to test Image Decode
        The test case spec is following:
        1. Open a picture
        """
        self.imageViewCheckWithWallpaper("test_API_image_040")

    def testImage_View_Edit_PNG(self):
        """
        This test used to test Image Decode
        The test case spec is following:
        1. Open a picture
        """
        self.imageViewCheckWithWallpaper("test_API_image_041")

    def test_Album_Delete(self):
        """
        This test used to test Image Decode
        The test case spec is following:
        1. Open a picture
        """
        self.imageViewCheckWithDelete("test_API_image_042")
Пример #7
0
class NetflixTest(UIATestBase):
    """
    @summary: Test Widevine
    """
    
    config = TestConfig()

    def setUp(self):
        """
        @summary: set up
        @return: None
        """
        super(NetflixTest, self).setUp()
        self.d = g_common_obj.get_device()
        self._test_name = __name__
        self.playback_state_str = "playbackState"
        self.video_button_widget_dict={"play":"com.netflix.mediaclient:id/player",
                                       "pause":"com.netflix.mediaclient:id/player",
                                       "back_30s":"com.netflix.mediaclient:id/skip_back",
                                       "current_time":"com.netflix.mediaclient:id/current_timeLabel",
                                       "remain_time":"com.netflix.mediaclient:id/label_duration",
                                       "seek_bar":"com.netflix.mediaclient:id/timeline",
                                       "volume_up":"volume_up",
                                       "volume_down":"volume_down",
                                       "back":"back"}
        
        print "[Setup]: %s" % self._test_name

    def tearDown(self):
        """
        @summary: tear tearDown
        @return: None
        """
        super(NetflixTest, self).tearDown()
        print "[Teardown]: %s" % self._test_name
        g_common_obj.stop_exp_handle()

    def appPrepare(self, model=1):
        self.cfg_file = os.path.join(os.environ.get('TEST_DATA_ROOT', ''), \
            'tests.tablet.mum_auto_drm.conf')
        self.cfg = self.config.read(self.cfg_file, self.case_name)

        self.multimedia_setting = MultiMediaSetting(self.cfg_file)
        self.multimedia_drm_helper = MultiMediaDRMHelper()
        self.multimedia_video_quality_helper = MultiMediaVideoQualityHelper()
        
        self.multimedia_setting.install_apk("netflix_apk")
        self.netflix_package_name, self.netflix_activity_name = self.multimedia_setting.get_package_and_activity_name("netflix_apk")

#         g_common_obj.set_vertical_screen()
        g_common_obj.stop_app_am(self.netflix_package_name)
        SystemUI().unlock_screen()

    def clickScreen(self):
        self.multimedia_setting.clickScreen()

    def registerNetflix(self):
        t_email = "*****@*****.**"
        t_password = "******"
        if self.d(description="Choose a Credential").exists:
            if self.d(textContains=t_email).exists:
                self.d(textContains=t_email).click()
                for _ in range(10):
                    if self.d(textContains="Kids").exists:
                        self.d(textContains="Kids").click()
                        time.sleep(10)
                        return
                    time.sleep(3)
            else:
                self.d(textContains="None of the above").click()
                time.sleep(2)
        else:
            self.d(textContains="Sign In").click()
            time.sleep(5)
        self.d(className="android.widget.EditText", resourceId="com.netflix.mediaclient:id/login_email").set_text(t_email)
        self.d(className="android.widget.EditText", resourceId="com.netflix.mediaclient:id/login_password").set_text(t_password)
        self.d(textContains="Sign In").click()
        time.sleep(10) #wait DUT sign in
            

    def launchNetflixApp(self):
        SystemUI().unlock_screen()
        for _ in range(2):
            g_common_obj.launch_app_am(self.netflix_package_name, self.netflix_activity_name)
            time.sleep(5)
            for _ in range(6):
                if self.d(description="Search").exists:
                    return
                if self.d(textContains="New version of application").exists:
                    time.sleep(2)
                    self.d(textContains="Cancel").click(2)
                if self.d(textContains="Sign In").exists or self.d(description="Choose a Credential").exists:
                    self.registerNetflix()
                time.sleep(5)
                if self.d(description="test").exists:
                    self.d(description="test").click(3)
                if self.d(textContains="Notifications may include newly-added movi").exists:
                    self.d(textContains="No Thanks").click(2)
        assert self.d(description="Search").exists, "launch Netflix App failed!"

    def clickNetflixMenu(self, menu_str="Action"):
        self.d(description="Navigate up").click() #menu button
        time.sleep(2)
        self.d(className="android.widget.ScrollView").scroll.vert.to(textContains=menu_str)
        self.d(textContains=menu_str).click()
        time.sleep(5)

    def get_widget(self, t_str):
        logger.debug("get_widget---t_str=%s" % t_str)
        assert t_str in self.video_button_widget_dict, "%s not in video_button_widget_dict!" % t_str
        t_resource_id = self.video_button_widget_dict[t_str]
        if t_resource_id == t_str:
            return t_resource_id
        else:
            return self.d(resourceId=t_resource_id)

    @staticmethod
    def setTimeToSec(time):
        time = time.split(":")
        i = 1
        temp = 0
        for s in time[::-1]:
            temp += int(s) * i
            i *= 60
        return int(temp)

    def get_widget_text(self, t_widget):
        try:
            self.s_t_text = t_widget.text
        except Exception as e:
            logger.debug("get_widget_text error:%s" % e)
            self.s_t_text = -2

    def click_widget(self, t_widget):
        try:
            t_widget.click()
            self.s_t_text = 0
        except Exception as e:
            logger.debug("click_widget error:%s" % e)
            self.s_t_text = -2
            assert 0, "click_widget error:%s" % e

    def get_widget_bounds(self, t_widget):
        try:
            bounds = t_widget.info["bounds"]
            progress_bar_bounds = {}
            progress_bar_bounds["y"] = bounds["top"] + (bounds["bottom"] - bounds["top"])/2
            progress_bar_bounds["x_start"] = bounds["left"] + 10
            progress_bar_bounds["x_end"] = bounds["right"] - 10
            self.s_t_text = progress_bar_bounds
        except Exception as e:
            logger.debug("get_widget_text error:%s" % e)
            self.s_t_text = -2

    def widget_operation_with_thread(self, t_str, t_operation):
        self.s_t_text = -1
        t_widget = self.get_widget(t_str)
        if t_operation == "get_text":
            thread.start_new_thread(self.get_widget_text, (t_widget, ))
        elif t_operation == "click":
            thread.start_new_thread(self.click_widget, (t_widget, ))
        elif t_operation == "get_bounds":
            thread.start_new_thread(self.get_widget_bounds, (t_widget, ))
        else:
            assert 0, "Error operation!"
        while self.s_t_text == -1:
            if not t_widget.exists:
                self.clickScreen()
            time.sleep(1)
        return self.s_t_text

    def click_button(self, t_str):
        logger.debug("click_button---t_str=%s" % t_str)
#         t_widget = self.get_widget(t_str)
        t_widget = self.video_button_widget_dict[t_str]
        if t_str != t_widget:
            self.widget_operation_with_thread(t_str, "click")
        else:
            getattr(self.d.press, t_widget)()

    def get_play_time_coordinate(self, percent):
        if "progress_bar_bounds" not in dir(self):
            self.progress_bar_bounds = self.widget_operation_with_thread("seek_bar", "get_bounds")
        x = self.progress_bar_bounds["x_start"] + (self.progress_bar_bounds["x_end"] - self.progress_bar_bounds["x_start"]) * percent
        x = int(x)
        y = self.progress_bar_bounds["y"]
        y = int(y)
        logger.debug("progress_bar_bounds=%s, percent=%s" % (self.progress_bar_bounds, percent))
        return x, y

    def set_play_time(self, percent=0.5):
        x, y = self.get_play_time_coordinate(percent)
        seek_bar_widget = self.get_widget("seek_bar")
        if not seek_bar_widget.exists:
            self.clickScreen()
        self.d.click(x,y)

    def set_play_time_with_swipe(self, percent):
        ct, tt = self.get_play_time()
        ct = ct + 2
        if ct > tt:
            ct = tt
        start_x, start_y = self.get_play_time_coordinate(ct / float(tt))
        end_x, end_y = self.get_play_time_coordinate(percent)
        self.d.swipe(start_x, start_y, end_x, end_y)

    def get_play_time(self, t_time=60):
        logger.debug("get_play_time start")
        timeNow = time.time()
        while time.time() - timeNow < t_time:
            current_time_widget = self.get_widget("current_time")
            if current_time_widget.exists:
                ct = self.widget_operation_with_thread("current_time", "get_text")
                rt = self.widget_operation_with_thread("remain_time", "get_text")
                ct = self.setTimeToSec(ct)
                rt = self.setTimeToSec(rt)
                logger.debug("ct---tt:%s, %s" % (ct, ct + rt))
                return ct, ct + rt
            else:
                logger.debug("%s times, don't find current time or total time!" % str(time.time() - timeNow))
                assert not self.d(textContains="error").exists, "Play error!"
                time.sleep(1)
                self.clickScreen()
        assert not self.d(textContains="OTC Alarm is triggered").exists, "OTC Alarm is triggered! wait time=%d" % (t_time) 
        assert 0, "Play error! playback timeout %d s, network problem." % (t_time)

    def checkVideoPlayback(self, t_time, skip_flag=0, expect_resolution=480):
        flag = 0
        timeNow = time.time()
        if t_time >= 20 and skip_flag == 0:
            self.multimedia_video_quality_helper.checkSurfaceViewResolutionWithThread_start(expect_resolution)
        while time.time() - timeNow < t_time:
            if flag == 1 or self.d(textContains="Loading").exists:
                time.sleep(2)
            elif self.get_widget("current_time").exists:
                logger.debug("%s times, find current time and total time!!" % str(time.time() - timeNow))
                flag = 1
                if skip_flag:
                    break
            else:
                logger.debug("%s times, don't find current time or total time!!" % str(time.time() - timeNow))
                assert not self.d(textContains="error").exists, "Play error!"
                time.sleep(1)
                self.clickScreen()
        if t_time >=20 and skip_flag == 0 :
            assert self.multimedia_video_quality_helper.checkSurfaceViewResolutionWithThread_stop() == 1, "Looks like Video didn't reach HD(%d)..." % expect_resolution
        assert not self.d(textContains="OTC Alarm is triggered").exists, "OTC Alarm is triggered! wait time=%d" % (time.time() - timeNow) 
        assert flag, "Play error! playback timeout %d s, network problem.." % (t_time)

    def netflixPlayBack(self, t_index=0):
        #instance
        self.d(className="android.widget.ImageView", index=t_index).click()
        time.sleep(3)
        for _ in range(10):
            if self.d(className="android.widget.ImageView").exists:
                break
            time.sleep(3)
        self.d(className="android.widget.ImageView").click()
        time.sleep(5)
        for _ in range(20):
            if not self.d(textContains="Loading").exists:
                break
            time.sleep(5)
        assert not self.d(textContains="Loading").exists, "Error! loading %d s" % (5*20)

    def netflixLongPlayBack(self):
        self.d(scrollable=True).scroll.vert.to(description="The Lost World: Jurassic Park")
        for _ in range(10):
            if self.d(description="The Lost World: Jurassic Park").exists:
                break
            time.sleep(3)
        self.d(description="The Lost World: Jurassic Park").click()
        self.d(description="Play Video The Lost World: Jurassic Park").click()
        time.sleep(5)
        for _ in range(20):
            if not self.d(textContains="Loading").exists:
                break
            time.sleep(5)
        assert not self.d(textContains="Loading").exists, "Error! loading %d s" % (5 * 20)

    def wait_boot_completed(self, timeout=1000):
        ''' wait Android boot_completed
    
        args: timeout -- optional timeout in second, default 180s
        '''
        count = 0
        sleep_time = 5
        while count < timeout:
            prop_val = adb.adb_cmd_capture_msg('getprop sys.boot_completed')
            if '1' in prop_val:
                print 'boot_completed'
                return
            count += sleep_time
            time.sleep(sleep_time)
        raise Exception('%ds timeout waiting for boot_completed' % timeout)

    def clickRecentApp(self, app_name):
        self.multimedia_setting.click_recent_app(app_name)

    def test_video_playback(self, t_time=60):
        self.clickNetflixMenu()#open netflix menu
        self.netflixPlayBack()#play video with netflix app
        self.checkVideoPlayback(t_time)# check play status of video

    def test_video_playback_with_back(self, t_time=1):
        self.clickNetflixMenu()
        self.netflixPlayBack()
        self.checkVideoPlayback(60)
        for _ in range(t_time):
            self.click_button("back")
            self.d(className="android.widget.ImageView").click()
            time.sleep(5)
            self.checkVideoPlayback(60, 1)
            self.checkVideoPlayback(30, 0, 384)

    def test_video_playback_with_app_change(self):
        self.multimedia_setting.install_apk("video_apk")
        self.clickNetflixMenu()
        self.netflixPlayBack()
        self.checkVideoPlayback(60, 1)
        self.multimedia_handle = MultiMediaHandle()
        self.multimedia_handle.launchVideoApp()
        time.sleep(2)
        self.clickRecentApp("Netflix")
        self.d(className="android.widget.ImageView").click()
        time.sleep(5)
        self.checkVideoPlayback(60, 1)
        self.checkVideoPlayback(20)

    def test_video_playback_with_sleep_mode(self):
        self.clickNetflixMenu()
        self.netflixPlayBack()
        self.checkVideoPlayback(40, 1)
        ct, tt = self.get_play_time()
        if tt - ct <= 300:
            self.set_play_time(0.01)
            self.checkVideoPlayback(30, 1)
        self.click_button("pause")
        self.d.press.power()
        time.sleep(10)
        self.d.press.power()
        SystemUI().unlock_screen()
        time.sleep(5)
        self.click_button("play")
        self.checkVideoPlayback(20)

    def test_video_playback_with_repeatedly(self, click_list, t_time, step_skip_time=2, begin_check_time=30):
        self.clickNetflixMenu()
        self.netflixPlayBack()
        self.checkVideoPlayback(30, 1)
        ct, tt = self.get_play_time()
        logger.debug("ct, tt---%d, %d" % (ct, tt))
        if tt - ct <= 300:
            self.set_play_time(0.01)
            self.checkVideoPlayback(30, 1)
        for i in range(t_time):
            logger.debug("click_button---%d time" % i)
            for t_str in click_list:
                if t_str == "sleep":
                    time.sleep(5)
                elif "swipe" in t_str:
                    self.set_play_time_with_swipe(float(t_str.split(" ")[1]))
                    self.checkVideoPlayback(30, 1)
                else:
                    self.click_button(t_str)
                    time.sleep(step_skip_time)
        time.sleep(5)

    def test_video_playback_with_longtime(self,t_time=7200):
        '''
         This test used to test netflix app over 2 hours
         The case spec is following:
         1.select HD(or better) protected content clip
         2.Watch movices for about 2 hours
         3.Play Another Netflix movices for 10 minutes
         '''

        self.clickNetflixMenu('Home')
        self.netflixLongPlayBack()
        self.checkVideoPlayback(120)
        self.multimedia_drm_helper.stopRecord()
        time.sleep(5)
        logger.debug("Step 2: Watch movices for about 2 hours")
        self.set_play_time(0.01)
        ct, tt = self.get_play_time()
        while ct<= t_time:
            self.multimedia_drm_helper.startRecord(self.case_name + '_step2_' + str(ct/60) + '_mins')
            logger.debug("Current palytime is :%s seconds" %ct)
            self.checkVideoPlayback(1800)
            ct, tt = self.get_play_time()
            self.multimedia_drm_helper.stopRecord()
        logger.debug("Play time is %s seconds" % (tt-ct))
        logger.debug("Step 3: Play Another Netflix movices for 10 minutes")
        self.multimedia_drm_helper.startRecord(self.case_name + '_step3')
        for _ in range(2):
          self.d.press.back()
        #self.launchNetflixApp()
        self.clickNetflixMenu()
        self.netflixPlayBack(2)
        self.checkVideoPlayback(600)

    def test_video_playback_with_check_WVinfo(self,check_str='WVCdm'):
        '''
        This test used to test netflix app and check WVinfo
        The case spec is following:
        1.Play HD video via netflix
        2.Check its logs "adb logcat |grep WVCdm"
        '''
        self.multimedia_setting.clearLogs()
        self.launchNetflixApp()
        logger.debug("get WVCdm info:")
        self.multimedia_setting.checkLogs_start(check_str)
        self.clickNetflixMenu()  # open netflix menu
        self.netflixPlayBack()  # play video with netflix app
        self.checkVideoPlayback(120)  # check play status of video
        self.multimedia_setting.checkLogs_end(check_str)



    def netflix_main_test(self, sub_func_name="", *arg, **keywords):
        """
        This test used to test Exoplayer App
        The test case spec is following:
        1. Start record video
        2. do sub_func()
        3. Stop record video
        """
        self.case_name = sys._getframe().f_back.f_code.co_name
        if sub_func_name == "":
            sub_func_name = "%s_sub_func" % self.case_name
        logger.debug("case_name=%s" % self.case_name)
        logger.debug("netflix_main_test---sub_func_name=%s" % sub_func_name)
        self.appPrepare()
        try:
            self.multimedia_drm_helper.startRecord(self.case_name)#start record
            self.launchNetflixApp()#launch netflix app
            
            logger.debug("Arbitrary parameter is %s" % str(arg))
            logger.debug("keywords parameter is %s" % str(keywords))
            getattr(self, sub_func_name)(*arg, **keywords)
            
            time.sleep(10)
            self.d.press.back()
            self.d.press.home()
            time.sleep(1)
            self.multimedia_drm_helper.stopRecord()#stop record
        except Exception as e:
            self.multimedia_drm_helper.stopRecord()#stop record
            assert 0, e
        
        assert 0, "Playback complete! Please check video!"
        logger.debug("Case %s is pass!" % self.case_name)

    def testWVModular_Netflix_HD(self):
        self.netflix_main_test("test_video_playback", 120)

    def testWVModular_NetFlix_SD(self):
        self.netflix_main_test("test_video_playback", 120)

    def testWVModular_Netflix_Menu(self):
        self.netflix_main_test("test_video_playback", 120)

    def testWVModular_Netflix_Pause(self):
        self.netflix_main_test("test_video_playback_with_repeatedly", ["pause", "play"], 2, 4)

    def testWVModular_NetFlix_Volume_Change(self):
        self.netflix_main_test("test_video_playback_with_repeatedly", ["volume_up"]*4 + ["sleep"]*2 +["volume_down"]*4 , 1, 1)

    def testWVModular_Netflix_Volume_Pause(self):
        self.netflix_main_test("test_video_playback_with_repeatedly", ["pause"] + ["volume_up"]*4 + ["play"] + ["sleep"]*2 + 
                                                                      ["pause"] + ["volume_down"]*4 + ["play"] + ["sleep"], 1, 1)

    def testWVModular_NetFlix_AV_Synced(self):
        self.netflix_main_test("test_video_playback_with_repeatedly", ["pause"] + ["volume_up"]*4 + ["play"] + ["sleep"]*2 + 
                                                                      ["pause"] + ["volume_down"]*4 + ["play"] + ["sleep"], 1, 1)

    def testWVModular_Netflix_Rewind_10(self):
        self.netflix_main_test("test_video_playback_with_repeatedly", ["back_30s"], 1, 20, 40)

    def testWVModular_NetFlix_Resume_Sleep(self):
        self.netflix_main_test("test_video_playback_with_sleep_mode")

    def testWVModular_NetFlix_Power_Button(self):
        self.netflix_main_test("test_video_playback_with_sleep_mode")

    def testWVModular_Netflix_Back(self):
        self.netflix_main_test("test_video_playback_with_back", 1)

    def testWVModular_Netflix_Back_Stress(self):
        self.netflix_main_test("test_video_playback_with_back", 10)

    def testWVModular_NetFlix_Apps_Change(self):
        self.netflix_main_test("test_video_playback_with_app_change")

    def testWVModular_Netflix_Scrub(self):
        self.netflix_main_test("test_video_playback_with_repeatedly", ["swipe 0.7"] + ["sleep"]*2 + ["swipe 0.2"], 1, 1)

    def testWVModualr_Netflix_HD_Control(self):
        self.netflix_main_test("test_video_playback_with_repeatedly", ["pause", "play", "swipe 0.7"] + ["sleep"]*2 + ["swipe 0.2"], 1, 1)


    def testWVModular_Netflix_HD_WVinfo(self):
        self.netflix_main_test("test_video_playback_with_check_WVinfo")

    def testWVModular_Netflix_Long_Playback(self):
        self.netflix_main_test("test_video_playback_with_longtime", 7200)
Пример #8
0
class VideoPlayBack(TestCaseBase):
    """
    @summary: Test Video PlayBack
    """
    def setUp(self):
        """
        @summary: set up
        @return: None
        """
        super(VideoPlayBack, self).setUp()
        self.d = g_common_obj.get_device()
        self._test_name = __name__
        self.x = self.d.info["displayWidth"]
        self.y = self.d.info["displayHeight"]
        print "[Setup]: %s" % self._test_name
        g_common_obj.stop_app_am(
            "videoplayer.app.instrument.otc.intel.com.otcvideoplayer")
        # Unlock screen
        g_common_obj.adb_cmd_capture_msg("input keyevent 82")

    def tearDown(self):
        """
        @summary: tear tearDown
        @return: None
        """
        super(VideoPlayBack, self).tearDown()
        print "[Teardown]: %s" % self._test_name
        g_common_obj.stop_exp_handle()
        time.sleep(3)
        g_common_obj.stop_app_am(
            "videoplayer.app.instrument.otc.intel.com.otcvideoplayer")
        time.sleep(3)

    def appPrepare(self, case_name, model=1):
        self.cfg_file = os.path.join(os.environ.get('TEST_DATA_ROOT', ''), \
            'tests.tablet.mum_auto_video.conf')
        self.video = PhotosImpl(\
            self.config.read(self.cfg_file, case_name))
        g_common_obj.adb_cmd_capture_msg(" rm -rf /sdcard/DCIM/Camera/*")

        self.multimedia_handle = MultiMediaHandle()
        self.multimedia_setting = MultiMediaSetting(self.cfg_file)
        self.multimedia_setting.clearFolder(self.video.cfg.get("remove_video"))
        time.sleep(2)
        if model == 1:
            self.push_path = self.multimedia_setting.push_file(
                self.video.cfg.get("push_video"),
                self.video.cfg.get("datapath"))

        self.multimedia_setting.install_apk("video_apk")
        self.multimedia_setting.install_apk("alarm_apk")

        self.video.set_orientation_n()
        # Unlock screen
        g_common_obj.adb_cmd_capture_msg("input keyevent 82")

    def getNormalWifi(self):
        conf = self.config.read('tests.tablet.dut_init.conf', 'wifisetting')
        ssid = conf.get("ssid")
        passwd = conf.get("passwd")
        security = conf.get("security")
        print ssid, passwd, security
        return ssid, passwd, security

    def getRTPWifi(self):
        rtp_wifisetting = PhotosImpl(
            self.config.read(self.cfg_file, "rtp_wifisetting"))
        ssid = rtp_wifisetting.cfg.get("ssid")
        passwd = rtp_wifisetting.cfg.get("passwd")
        security = rtp_wifisetting.cfg.get("security")
        print ssid, passwd, security
        return ssid, passwd, security

    def launchRecordAPP(self):
        SystemUI().unlock_screen()
        for _ in range(3):
            g_common_obj.launch_app_am("com.intel.vpg.tool", \
                                   "com.intel.vpg.tool.ConfActivity")
            time.sleep(3)
            if self.d(textContains="Vpg Media Tool").exists:
                return
        assert self.d(
            textContains="Vpg Media Tool").exists, "launch record app failed!"

    def wait_boot_completed(self, timeout=1000):
        ''' wait Android boot_completed
    
        args: timeout -- optional timeout in second, default 180s
        '''
        count = 0
        sleep_time = 5
        while count < timeout:
            prop_val = adb.adb_cmd_capture_msg('getprop sys.boot_completed')
            if '1' in prop_val:
                print 'boot_completed'
                return
            count += sleep_time
            time.sleep(sleep_time)
        raise Exception('%ds timeout waiting for boot_completed' % timeout)

    def clickRecordButton(self):
        self.d(className="android.widget.Button").click()

    def deleteCameraRecordFile(self):
        cmd = "shell rm /storage/emulated/legacy/Android/data/com.example.android.camera2video/files/video.mp4"
        g_common_obj.adb_cmd_common(cmd)

    def checkCameraRecordFile(self, flag=1):
        cmd = "shell ls /storage/emulated/legacy/Android/data/com.example.android.camera2video/files/video.mp4"
        result = g_common_obj.adb_cmd_common(cmd)
        assert ("No such file or directory" not in result.stdout.read()
                ) == flag, "Record file status error! Flag=%s" % (flag)

    def enterBrowseVideo(self, path):
        self.d(className="android.widget.ImageButton").click()
        time.sleep(1)
        self.d(text="Browse Video").click()
        for _ in range(10):
            if self.d(textContains="Open").exists:
                break
            time.sleep(1)
        time.sleep(3)
        self.d.press.back()
        time.sleep(1)
        if self.multimedia_setting.getcheckIputMethod() != '':
            self.d.press.back()
        self.d(className="android.widget.EditText").set_text(path)
        time.sleep(1)
        if self.multimedia_setting.getcheckIputMethod() != '':
            self.d.press.back()
        self.d(text="OK").click()
        for _ in range(5):
            if self.d(text=path).exists:
                break
            time.sleep(5)
        assert self.d(text=path).exists, "can't enter path:%s" % path

    def setTimeToSec(self, time):
        time = time.split(":")
        i = 1
        temp = 0
        for s in time[::-1]:
            temp += int(s) * i
            i *= 60
        return int(temp)

    def setRotation(self, mode):
        self.d(className="android.widget.ImageButton").click()
        time.sleep(1)
        self.d(text=mode).click()
        time.sleep(1)

    def videoPlayBack(self, push_path=""):
        if push_path == "":
            push_path = self.push_path
        return self.multimedia_handle.videoPlayBack(push_path)

    def streamingVideoPlayBack(self, path="", flag=1):
        if path == "":
            path = self.video.cfg.get("video_path")
        return self.multimedia_handle.streamingVideoPlayBack(path, flag)

    def checkVideoPlayBack(self, s=60):
        return self.multimedia_handle.checkVideoPlayBack(s)

    def checkVideoPlayBackWithComparePicture(self,
                                             stoptime,
                                             bigfileskiptime=0):
        return self.multimedia_handle.checkVideoPlayBackWithComparePicture(
            stoptime, bigfileskiptime)

    def checkVideoPlayBackComplete(self, s=900):
        return self.multimedia_handle.checkVideoPlayBackComplete(s)

    def checkVideoFileExist(self, file_name):
        assert self.d(text=file_name).exists, file_name + "file not find!"

    def deleteVideoFile(self, file_name):
        assert self.d(text=file_name).exists, file_name + "file not find!"
        self.d(text=file_name).long_click()
        time.sleep(1)
        self.d(text="Delete").click()
        time.sleep(1)
        self.d(text="Yes").click()
        time.sleep(1)
        assert not self.d(
            text=file_name).exists, file_name + "file delete failed!"

    def checkVideoDetail(self, file_name):
        assert self.d(text=file_name).exists, file_name + "file not find!"
        self.d(text=file_name).long_click()
        time.sleep(1)
        self.d(text="Detail").click()
        time.sleep(1)
        assert self.d(
            textContains=file_name).exists, file_name + "check detail failed!"

    def renameVideoFile(self, file_name, new_name):
        assert self.d(text=file_name).exists, file_name + "file not find!"
        self.d(text=file_name).long_click()
        time.sleep(1)
        self.d(text="Rename").click()
        for _ in range(10):
            if self.d(textContains="Open").exists:
                break
            time.sleep(1)
        time.sleep(3)
        if self.multimedia_setting.getcheckIputMethod() != '':
            self.d.press.back()
        self.d(className="android.widget.EditText").set_text(new_name)
        time.sleep(1)
        if self.multimedia_setting.getcheckIputMethod() != '':
            self.d.press.back()
        self.d(text="OK").click()
        time.sleep(1)
        assert self.d(
            textContains=new_name).exists, file_name + "check detail failed!"

    def interuptionVideoPlayBack(self, case_name):
        print "run case is " + str(case_name)
        self.appPrepare(case_name)
        self.multimedia_handle.launchVideoApp()
        time.sleep(2)
        self.videoPlayBack()
        self.checkVideoPlayBack()
        time.sleep(1)
        hardware = self.multimedia_setting.get_paltform_hardware()
        if 'bxtp_abl' or 'gordon_peak' in hardware:
            #  For BXT use relay card press power to sleep
            self.multimedia_setting.pressPowerKey()
            time.sleep(10)
            self.multimedia_setting.pressPowerKey()
        # elif 'gordon_peak' in hardware:
        #     self.logger.error("Case failed due OAM-48191: adb lost in host when resume from S3")
        #     assert False, "case " + str(case_name) + " is Fail"
        else:
            self.d.press.power()
            time.sleep(2)
            self.d.press.power()
        self.lock = SystemUI()
        self.lock.unlock_screen()
        time.sleep(1)
        self.checkVideoPlayBack()
        print "case " + str(case_name) + " is pass"

    def interuptionStreamingVideoPlayBack(self, case_name):
        print "run case is " + str(case_name)
        self.appPrepare(case_name, 2)
        self.multimedia_handle.launchVideoApp()
        time.sleep(2)
        self.streamingVideoPlayBack()
        self.checkVideoPlayBack()
        time.sleep(1)
        hardware = self.multimedia_setting.get_paltform_hardware()
        if 'bxtp_abl' or 'gordon_peak' in hardware:
            #  For BXT use relay card press power to sleep
            self.multimedia_setting.pressPowerKey()
            time.sleep(10)
            self.multimedia_setting.pressPowerKey()
        # elif 'gordon_peak' in hardware:
        #     self.logger.error("Case failed due OAM-48191: adb lost in host when resume from S3")
        #     assert False, "case " + str(case_name) + " is Fail"
        else:
            self.d.press.power()
            time.sleep(2)
            self.d.press.power()
        self.lock = SystemUI()
        self.lock.unlock_screen()
        time.sleep(1)
        self.checkVideoPlayBack()
        print "case " + str(case_name) + " is pass"

    def testVideoPlayBack(self, case_name):
        MultiMediaBasicTestCase().testVideoPlayBack(case_name)

    def testStreamingVideoPlayBack(self, case_name):
        MultiMediaBasicTestCase().testStreamingVideoPlayBack(case_name)

    def testRTPStreamingVideoPlayBack(self, case_name):
        print "run case is " + str(case_name)
        self.appPrepare(case_name, 2)
        self.multimedia_handle.launchVideoApp()
        time.sleep(2)
        self.streamingVideoPlayBack()
        self.checkVideoPlayBack()
        print "case " + str(case_name) + " is pass"

    def testStreamingVideoPlayBackWithPowerOff(self, case_name):
        print "run case is " + str(case_name)
        self.appPrepare(case_name, 2)
        self.multimedia_handle.launchVideoApp()
        time.sleep(2)
        self.streamingVideoPlayBack()
        self.checkVideoPlayBack()
        adb.reboot_device()
        self.wait_boot_completed()
        time.sleep(20)
        self.lock = SystemUI()
        self.lock.unlock_screen()
        print "case " + str(case_name) + " is pass"

    def streamingVideoPlayControlProcess(self, case_name):
        MultiMediaBasicTestCase().streamingVideoPlayControlProcessLong(
            case_name)

    def lowAndHighFramestreamingVideoPlayControlProcess(self, case_name):
        print "run case is " + str(case_name)
        self.appPrepare(case_name, 2)
        self.multimedia_handle.launchVideoApp()
        time.sleep(2)
        self.streamingVideoPlayBack()
        time.sleep(10)
        self.checkVideoPlayBack()
        self.d.press.volume_up()
        self.checkVideoPlayBack()
        self.d.press.volume_down()
        self.checkVideoPlayBack()
        self.multimedia_setting.set_play_time(0.5)
        self.checkVideoPlayBack()
        self.d(resourceId="android:id/rew").click()
        self.checkVideoPlayBack()
        #         self.d(resourceId="android:id/ffwd").click()
        #         self.checkVideoPlayBack()
        self.d(resourceId="android:id/pause").click()
        self.checkVideoPlayBack()
        self.d.press.home()
        self.multimedia_handle.launchVideoApp()
        time.sleep(2)
        self.streamingVideoPlayBack(self.video.cfg.get("video_path_2"))
        time.sleep(10)
        self.checkVideoPlayBack()
        self.d.press.volume_up()
        self.checkVideoPlayBack()
        self.d.press.volume_down()
        self.checkVideoPlayBack()
        self.multimedia_setting.set_play_time(0.5)
        self.checkVideoPlayBack()
        self.d(resourceId="android:id/rew").click()
        self.checkVideoPlayBack()
        #         self.d(resourceId="android:id/ffwd").click()
        #         self.checkVideoPlayBack()
        self.d(resourceId="android:id/pause").click()
        self.checkVideoPlayBack()
        print "case " + str(case_name) + " is pass"

    def testVideoDurationThumbnail(self, case_name):
        print "run case is " + str(case_name)
        self.appPrepare(case_name)
        self.multimedia_handle.launchVideoApp()
        time.sleep(2)
        self.enterBrowseVideo(os.path.split(self.push_path)[0])
        time.sleep(2)
        file_name = os.path.split(
            self.video.cfg.get("push_video"))[1].strip("\"")
        self.checkVideoFileExist(file_name)
        self.d(text=file_name).click()
        time.sleep(1)
        self.checkVideoPlayBack()
        self.d.press.back()
        if not self.d(text=os.path.split(self.push_path)[0]).exists:
            self.d.press.back()
        time.sleep(1)
        self.checkVideoFileExist(file_name)
        print "case " + str(case_name) + " is pass"

    def testStreamingVideoDurationThumbnail(self, case_name):
        print "run case is " + str(case_name)
        self.appPrepare(case_name, 2)
        self.multimedia_handle.launchVideoApp()
        time.sleep(2)
        self.streamingVideoPlayBack()
        self.checkVideoPlayBack()
        self.d.press.back()
        assert self.d(text="OtcVideoPlayer").exists, "launch video app failed!"
        print "case " + str(case_name) + " is pass"

    def interuptionVideoPlayBackSwitchHome(self, case_name):
        print "run case is " + str(case_name)
        self.appPrepare(case_name)
        self.multimedia_handle.launchVideoApp()
        time.sleep(2)
        self.videoPlayBack()
        self.checkVideoPlayBack()
        time.sleep(1)
        self.d.press.home()
        self.multimedia_setting.click_recent_app("OtcVideoPlayer")
        time.sleep(1)
        self.checkVideoPlayBack()
        print "case " + str(case_name) + " is pass"

    def interuptionStreamingVideoPlayBackSwitchHome(self, case_name):
        print "run case is " + str(case_name)
        self.appPrepare(case_name, 2)
        self.multimedia_handle.launchVideoApp()
        time.sleep(2)
        self.streamingVideoPlayBack()
        self.checkVideoPlayBack()
        time.sleep(1)
        self.d.press.home()
        self.multimedia_setting.click_recent_app("OtcVideoPlayer")
        time.sleep(1)
        self.checkVideoPlayBack()
        print "case " + str(case_name) + " is pass"

    def deleteVideoFileCase(self, case_name):
        print "run case is " + str(case_name)
        self.appPrepare(case_name)
        self.multimedia_setting.push_file(self.video.cfg.get("push_video_2"),
                                          self.video.cfg.get("datapath_2"))
        self.multimedia_handle.launchVideoApp()
        time.sleep(2)
        self.enterBrowseVideo(os.path.split(self.push_path)[0])
        time.sleep(2)
        self.deleteVideoFile(
            os.path.split(self.video.cfg.get("push_video"))[1].strip("\""))
        self.deleteVideoFile(
            os.path.split(self.video.cfg.get("push_video_2"))[1].strip("\""))
        print "case " + str(case_name) + " is pass"

    def CheckVideoFileInThumbnail(self, case_name):
        print "run case is " + str(case_name)
        self.appPrepare(case_name)
        self.multimedia_setting.push_file(self.video.cfg.get("push_video_2"),
                                          self.video.cfg.get("datapath"))
        self.multimedia_setting.push_file(self.video.cfg.get("push_video_3"),
                                          self.video.cfg.get("datapath"))
        self.multimedia_setting.push_file(self.video.cfg.get("push_video_4"),
                                          self.video.cfg.get("datapath"))
        self.multimedia_setting.push_file(self.video.cfg.get("push_video_5"),
                                          self.video.cfg.get("datapath"))
        self.multimedia_handle.launchVideoApp()
        time.sleep(2)
        self.enterBrowseVideo(os.path.split(self.push_path)[0])
        time.sleep(2)
        self.checkVideoFileExist(
            os.path.split(self.video.cfg.get("push_video"))[1].strip("\""))
        self.checkVideoFileExist(
            os.path.split(self.video.cfg.get("push_video_2"))[1].strip("\""))
        self.checkVideoFileExist(
            os.path.split(self.video.cfg.get("push_video_3"))[1].strip("\""))
        self.checkVideoFileExist(
            os.path.split(self.video.cfg.get("push_video_4"))[1].strip("\""))
        self.checkVideoFileExist(
            os.path.split(self.video.cfg.get("push_video_5"))[1].strip("\""))
        print "case " + str(case_name) + " is pass"

    def CheckVideoFileInformationInThumbnail(self, case_name):
        print "run case is " + str(case_name)
        self.appPrepare(case_name)
        self.multimedia_handle.launchVideoApp()
        time.sleep(2)
        self.enterBrowseVideo(os.path.split(self.push_path)[0])
        time.sleep(2)
        self.checkVideoDetail(
            os.path.split(self.video.cfg.get("push_video"))[1].strip("\""))
        print "case " + str(case_name) + " is pass"

    def RenameVideoFileInThumbnail(self, case_name):
        print "run case is " + str(case_name)
        self.appPrepare(case_name)
        self.multimedia_handle.launchVideoApp()
        time.sleep(2)
        self.enterBrowseVideo(os.path.split(self.push_path)[0])
        time.sleep(2)
        self.renameVideoFile(
            os.path.split(self.video.cfg.get("push_video"))[1].strip("\""),
            self.video.cfg.get("new_name"))
        print "case " + str(case_name) + " is pass"

    def videoPlayBackWithAlarm(self, case_name):
        print "run case is " + str(case_name)
        self.appPrepare(case_name)
        self.multimedia_setting.launchAlarmAPP()
        self.multimedia_setting.setAlarmTime(40)
        self.multimedia_handle.launchVideoApp()
        time.sleep(1)
        self.videoPlayBack()
        self.checkVideoPlayBack()
        time.sleep(1)
        self.multimedia_setting.waitAlarmTriiggered(60, "Snooze")
        self.multimedia_setting.setAlarmTime(30)
        self.multimedia_setting.click_recent_app("OtcVideoPlayer")
        self.checkVideoPlayBack()
        self.multimedia_setting.waitAlarmTriiggered(50, "Dismiss")
        self.multimedia_setting.click_recent_app("OtcVideoPlayer")
        self.checkVideoPlayBack()
        print "case " + str(case_name) + " is pass"

    def streamingVideoPlayBackWithAlarm(self, case_name):
        print "run case is " + str(case_name)
        self.appPrepare(case_name, 2)
        self.multimedia_setting.launchAlarmAPP()
        self.multimedia_setting.setAlarmTime(60)
        self.multimedia_handle.launchVideoApp()
        time.sleep(1)
        self.streamingVideoPlayBack()
        self.checkVideoPlayBack()
        time.sleep(1)
        self.multimedia_setting.waitAlarmTriiggered(80, "Snooze")
        self.multimedia_setting.setAlarmTime(60)
        self.multimedia_setting.click_recent_app("OtcVideoPlayer")
        self.checkVideoPlayBack()
        self.multimedia_setting.waitAlarmTriiggered(80, "Dismiss")
        self.multimedia_setting.click_recent_app("OtcVideoPlayer")
        self.checkVideoPlayBack()
        print "case " + str(case_name) + " is pass"

    def testVideoPlaybackRotation(self, case_name):
        print "run case is " + str(case_name)
        self.appPrepare(case_name)
        self.multimedia_handle.launchVideoApp()
        time.sleep(2)
        self.videoPlayBack()
        self.checkVideoPlayBack()
        self.d.click(self.x / 2, self.y / 2)
        self.setRotation("Landscape View")
        self.checkVideoPlayBack()
        self.d.click(self.x / 2, self.y / 2)
        self.setRotation("Portrait View")
        self.checkVideoPlayBack()
        print "case " + str(case_name) + " is pass"

    def testStreamingVideoPlaybackRotation(self, case_name):
        print "run case is " + str(case_name)
        self.appPrepare(case_name, 2)
        self.multimedia_handle.launchVideoApp()
        time.sleep(2)
        self.streamingVideoPlayBack()
        self.checkVideoPlayBack()
        self.d.click(self.x / 2, self.y / 2)
        self.setRotation("Landscape View")
        self.checkVideoPlayBack()
        self.d.click(self.x / 2, self.y / 2)
        self.setRotation("Portrait View")
        self.checkVideoPlayBack()
        print "case " + str(case_name) + " is pass"

    def testStreamingVideoPlayBackWithDownloadFile(self, case_name):
        print "run case is " + str(case_name)
        self.appPrepare(case_name, 2)
        self.multimedia_handle.launchVideoApp()
        time.sleep(2)
        self.streamingVideoPlayBack()
        self.checkVideoPlayBack()
        self.push_path = self.multimedia_setting.push_file(
            self.video.cfg.get("push_video"), self.video.cfg.get("datapath"))
        time.sleep(3)
        self.checkVideoPlayBack()
        self.d.press.home()
        self.multimedia_handle.launchVideoApp()
        time.sleep(2)
        self.videoPlayBack()
        self.checkVideoPlayBack()
        print "case " + str(case_name) + " is pass"

    def cameraRecordWithAlarm(self, case_name):
        print "run case is " + str(case_name)
        self.deleteCameraRecordFile()
        self.checkCameraRecordFile(0)
        self.multimedia_setting.launchAlarmAPP()
        self.multimedia_setting.setAlarmTime(30)
        self.launchRecordAPP()
        time.sleep(1)
        self.clickRecordButton()
        self.multimedia_setting.waitAlarmTriiggered(50, "Dismiss")
        self.multimedia_setting.click_recent_app("Camera2Video")
        time.sleep(1)
        self.clickRecordButton()
        self.checkCameraRecordFile()
        print "case " + str(case_name) + " is pass"

    def videoPlayBackLonglasting(self, case_name, bigfileskiptime=0):
        print "run case is " + str(case_name)
        self.appPrepare(case_name)
        lasting_time = int(self.video.cfg.get("lasting_time"))
        push_folder = os.path.split(os.path.split(self.push_path)[0])[-1]
        self.video.launchPhotos(push_folder)
        time.sleep(2)
        self.multimedia_handle.checkVideoPlayBackWithPhotoApp(
            lasting_time, bigfileskiptime, 1)
        print "case " + str(case_name) + " is pass"

    def testPlaying_streaming_Music_Back(self):
        """
        This test used to test Video playback
        The test case spec is following:
        1. Launch play video app
        2. Play video
        3. Press back
        """
        self.testStreamingVideoDurationThumbnail("test_API_video_playback_012")

    def testSHALL_support_H264_video_stream_no_frame_rate_limitation(self):
        """
        This test used to test Video playback
        The test case spec is following:
        1. Launch play video app
        2. Play video
        3. Start/Stop
        """
        self.lowAndHighFramestreamingVideoPlayControlProcess(
            "test_API_video_playback_026")

    def testHTML5_video_playback_MP4_H264_BP(self):
        """
        This test used to test Video playback
        The test case spec is following:
        1. Launch play video app
        2. Play video
        """
        self.streamingVideoPlayControlProcess("test_API_video_playback_028")

    def testPFT_7098_VPG_HW_acceleratiof_HTML5_video_tag_H264(self):
        """
        This test used to test Video playback
        The test case spec is following:
        1. Launch play video app
        2. Play video
        """
        self.testStreamingVideoPlayBack("test_API_video_playback_029")

    def testHTML5_video_playback_MP4_H264_HP(self):
        """
        This test used to test Video playback
        The test case spec is following:
        1. Launch play video app
        2. Play video
        """
        self.streamingVideoPlayControlProcess("test_API_video_playback_037")

    def testLongTime_HTML5_video_playback_MP4_H264(self):
        """
        This test used to test Video playback
        The test case spec is following:
        1. Launch play video app
        2. Play video
        """
        self.streamingVideoPlayControlProcess("test_API_video_playback_042")

    def testPseudo_streaming_clock_alarm(self):
        """
        This test used to test Video playback
        The test case spec is following:
        1. Launch play video app
        2. Play video
        3. Alarm expired
        4. Snooze the alarm
        5. Dismiss the alarm
        """
        self.streamingVideoPlayBackWithAlarm("test_API_video_playback_047")

    def testPseudo_streaming_HTTP_H264_640x480_60fps_NoAudio_mkv(self):
        """
        This test used to test Video playback
        The test case spec is following:
        1. Launch play video app
        2. Play video
        """
        self.testStreamingVideoPlayBack("test_API_video_playback_048")

    def testPseudo_streaming_HTTP_H264_L4_0_HP_720x576_30fps_AAC_160kbps_48KHz(
            self):
        """
        This test used to test Video playback
        The test case spec is following:
        1. Launch play video app
        2. Play video
        """
        self.testStreamingVideoPlayBack("test_API_video_playback_049")

    def testPseudo_streaming_HTTP_VP8_176x144_15fps_334Kbps_NoAudio_webm(self):
        """
        This test used to test Video playback
        The test case spec is following:
        1. Launch play video app
        2. Play video
        """
        self.testStreamingVideoPlayBack("test_API_video_playback_050")

    def testPlaying_streaming_Music_Power_Off(self):
        """
        This test used to test Video playback
        The test case spec is following:
        1. Launch play video app
        2. Play video
        """
        self.testStreamingVideoPlayBackWithPowerOff(
            "test_API_video_playback_051")

    def testSHALL_support_H264_video_stream_with_no_size_limitation(self):
        """
        This test used to test Video playback
        The test case spec is following:
        1. Launch play video app
        2. Play video
        3. Start/Stop
        """
        self.lowAndHighFramestreamingVideoPlayControlProcess(
            "test_API_video_playback_055")

    def testPFT_7102_Network_streaming_protocols_HTTP_S_Live_Streaming(self):
        """
        This test used to test Video playback
        The test case spec is following:
        1. Launch play video app
        2. Play video
        """
        self.testStreamingVideoPlayBack("test_API_video_playback_086")

    def testVideo_MPEG4_ASP_L1_720p_30fps_AAC_128kb_48KHz_RTP_streaming(self):
        """
        This test used to test Video playback
        The test case spec is following:
        1. Launch play video app
        2. Play video
        """
        self.testStreamingVideoPlayBack("test_API_video_playback_089")

    def testVideo_H263_CIF_30FPS_AAC_44KHz_127Kbps_RTP_streaming(self):
        """
        This test used to test Video playback
        The test case spec is following:
        1. Launch play video app
        2. Play video
        """
        self.testStreamingVideoPlayBack("test_API_video_playback_090")

    def testVideo_H264_f4v_MP_L3_1_640x480_30fps_AAC_44_1KHz_128kbps_over_WLAN(
            self):
        """
        This test used to test Video playback
        The test case spec is following:
        1. Launch play video app
        2. Play video
        """
        self.testStreamingVideoPlayBack("test_API_video_playback_091")

    def testVideo_H264_L2_1_BP_CIF_30fps_AAC_Multimedia_56kb_48KHz_RTP_streaming(
            self):
        """
        This test used to test Video playback
        The test case spec is following:
        1. Launch play video app
        2. Play video
        """
        self.testStreamingVideoPlayBack("test_API_video_playback_092")

    def testPseudo_streaming_HTTP_H264_MP_320x240_15fps_211Kbps_NoAudio_3gp(
            self):
        """
        This test used to test Video playback
        The test case spec is following:
        1. Launch play video app
        2. Play video
        """
        self.testStreamingVideoPlayBack("test_API_video_playback_093")

    def testPseudo_streaming_HTTP_VP8_CIF_25fps_Vorbis_44_1KHz_128kbps_webm_rotate_sleep_resume(
            self):
        """
        This test used to test Video playback
        The test case spec is following:
        1. Launch play video app
        2. Play video
        """
        self.streamingVideoPlayControlProcess("test_API_video_playback_094")

    def testPseudo_streaming_file_downloading_in_background(self):
        """
        This test used to test Video playback
        The test case spec is following:
        1. Launch play video app
        2. Play video
        """
        self.testStreamingVideoPlayBackWithDownloadFile(
            "test_API_video_playback_103")

    def testPFT_7100_Network_streaming_protocols_RTSP_RTP_SDP(self):
        """
        This test used to test Video playback
        The test case spec is following:
        1. Launch play video app
        2. Play video
        """
        self.testRTPStreamingVideoPlayBack("test_API_video_playback_109")

    def testLongTime_video_playback_H264_HP_L4_1_1080P_30fps_4_5Mbps_noAudio_mp4(
            self):
        """
        This test used to test Video playback
        The test case spec is following:
        1. Launch photos
        2. Play video('Long-time Video playback: H264_HP_L4.1_1080P_30fps_4.5Mbps_na.mp4 (10 hours)')
        3. Former name: test_video_playback_long_lasting_mum_007
        """
        self.videoPlayBackLonglasting(
            "mum_test_video_playback_long_lasting_007", 20)

    def testLongTime_video_playback_VP8_VGA_20fps_2Mbps_Vorbis_48KHz_128kbps_webm(
            self):
        """
        This test used to test Video playback
        The test case spec is following:
        1. Launch photos
        2. Play video('Long-time Video playback: VP8_VGA_20fps_2Mbps_Vorbis_48KHz_128kbps.webm (10 hours)')
        3. Former name: test_video_playback_long_lasting_mum_008
        """
        self.videoPlayBackLonglasting(
            "mum_test_video_playback_long_lasting_008", 20)
Пример #9
0
class CameraTest(CameraTestBase):
    """
    @summary: This test used to test camera function
    """

    MULTI_CAMERA_CONFIG_DICT = {"input_field" : 1
                                ,"input_resolution" :3
                                ,"input_format" : 4
                                ,"input_default" : 5
                                ,"output_resolution" : 0
                                ,"output_format" : 2}

    def setUp(self):
        """
        @summary: set up
        @return: None
        """
        super(CameraTest, self).setUp()
        self._test_name = __name__
        self.logger.debug("[Setup]: %s" % self._test_name)

        g_common_obj.root_on_device()
        self.camera_common = CameraCommon()

        self.host_path = self.camera_common.getTmpDir()

        self.rvc_camera = MultiMediaSwitchCameraHelper().camera

        self.camera_common.removeDeivceFile()
        self.camera_common.removeFile(self.host_path + "/*")
        self.camera_common.unlockScreen()
        self.rvc_camera.skipAccountLoginLyout()
        self.rvc_camera.backHome()
        self.d = g_common_obj.get_device()
        if self.d(text="Got it").exists:
            self.d(text="Got it").click.wait()

        self.multimedia_setting = MultiMediaSetting(self.camera_common.DEFAULT_CONFIG_FILE)
        need_install_result = self.multimedia_setting.install_apk("multi_camera_apk")
        if need_install_result:
            self.reboot_device()
        self.multi_camera_package_name, _ = self.multimedia_setting.get_package_and_activity_name("multi_camera_apk")
        MULTI_CAMERA_PERMISSION_LIST = ["android.permission.CAMERA"]
        self.camera_common.grantPermission(self.multi_camera_package_name, MULTI_CAMERA_PERMISSION_LIST)

    def tearDown(self):
        """
        @summary: tearDown
        @return: None
        """
        super(CameraTest, self).tearDown()
        self.logger.debug("[Teardown]: %s" % self._test_name)
        g_common_obj.stop_exp_handle()

        self.camera_common.removeDeivceFile()
        self.camera_common.clean_app_data(self.multi_camera_package_name)
        time.sleep(3)
        self.rvc_camera.backHome()

    def reboot_device(self):
        self.rvc_camera.pressPowerKey(10)
        time.sleep(5)
        self.rvc_camera.pressPowerKey(2)
        time.sleep(30)
        g_common_obj.root_on_device()
        self.camera_common.unlockScreen()
        self.rvc_camera.backHome()
        self.check_home_or_lock_layout()

    def set_multicamera_input_config_format(self, input_config_format):
        if "multicamera_input_config_format" in os.environ:
            previous_input_config_format = os.environ["multicamera_input_config_format"]
            if previous_input_config_format == input_config_format:
                self.logger.debug("skip set multicamera_input_config_format")
                return False
        g_common_obj.adb_cmd("setprop camera.input.config.format %s" % input_config_format)
        os.environ["multicamera_input_config_format"] = input_config_format
        self.logger.debug("set multicamera_input_config_format = %s" % input_config_format)
        return True

    def launch_multi_camera_apk(self):
        return self.multimedia_setting.launch_apk("multi_camera_apk")

    def stop_multi_camera_apk(self):
        return self.multimedia_setting.stop_apk("multi_camera_apk")

    def check_home_or_lock_layout(self, check_exist=True):
        if self.d(text="Got it").exists:
            self.d(text="Got it").click.wait()
        assert self.rvc_camera.isHomeLayoutExists() or self.rvc_camera.isLockLayoutExists(), "Home or Lock layout not exist!"

    def check_logcat_data(self, data_list, fps):
        self.logger.debug("check_logcat_data data_list=%s" % data_list)
        for t_fps in data_list:
            t_fps = float(t_fps)
            if fps * 0.97 > t_fps or t_fps > fps * 1.03:
                return False, t_fps
        return True, 1

    def set_multi_camera_config(self, config_list):
        self.logger.debug("set_multi_camera_config start. config_list=%s" % config_list)
        for config_str in config_list:
            config_item, config_value = config_str.split(":")
            self.logger.debug("config_item:%s, config_value:%s" % (config_item, config_value))
            self.d(className="android.widget.Spinner")[self.MULTI_CAMERA_CONFIG_DICT[config_item]].click.wait()
            time.sleep(1)
            self.d(textContains=config_value).click.wait()
            time.sleep(1)
        self.logger.debug("set_multi_camera_config end.")

    def check_multi_camera(self, input_size, output_size):
        config_list = ["input_field:interlaced"
                       ,"input_resolution:%s" % input_size
                       ,"input_format:default"
                       ,"input_default:HW_Weaving"
                       ,"output_resolution:%s" % output_size
                       ,"output_format:NV21"
                       ]
        self.set_multicamera_input_config_format("uyvy")
        self.launch_multi_camera_apk()
        self.set_multi_camera_config(config_list)
        self.d(textContains="Camera0:OFF").click.wait()
        time.sleep(10)
        self.camera_common.checkCameraCrash()
        assert self.d(packageName="com.example.tim.multicamera").exists, "Can't find multicamera in layout, maybe apk crashed."
        self.stop_multi_camera_apk()

    def check_multi_camera_with_fps(self, input_size, output_size):
        config_list = ["input_field:interlaced"
                       ,"input_resolution:%s" % input_size
                       ,"input_format:default"
                       ,"input_default:HW_Weaving"
                       ,"output_resolution:%s" % output_size
                       ,"output_format:NV21"
                       ]
        expect_fps = 50
        self.set_multicamera_input_config_format("uyvy")
        self.launch_multi_camera_apk()
        self.set_multi_camera_config(config_list)
        g_common_obj.adb_cmd("setprop camera.hal.perf 3")
        time.sleep(2)
        self.d(textContains="Camera0:OFF").click.wait()
        self.camera_common.checkCameraCrash()
        self.multimedia_logcat_helper = MultiMediaLogcatHelper("adb logcat CameraHardwareSoc:D *:S")
        self.multimedia_logcat_helper.get_logcat_data_start()

        time.sleep(5*60)

        result_list = self.multimedia_logcat_helper.get_logcat_data_end("total fps is (.*),")
        check_logcat_data_result, error_fps = self.check_logcat_data(result_list, expect_fps)
        assert check_logcat_data_result, "Fps error! error_fps=%s, expect_fps=%s, result_list=%s" % (error_fps, expect_fps, result_list)
        self.camera_common.checkCameraCrash()
        self.stop_multi_camera_apk()

    def test_Camera_Scale_AVM737_720x480_to_1280x720(self):
        self.check_multi_camera("720x480", "1280x720")

    def test_Camera_Scale_AVM737_720x480_to_1920x1080(self):
        self.check_multi_camera("720x480", "1920x1080")

    def test_Camera_Scale_AVM737_720x480_to_640x480(self):
        self.check_multi_camera("720x480", "640x480")

    def test_Camera_Scale_AVM737_720x480_to_720x480(self):
        self.check_multi_camera("720x480", "720x480")

    def test_Camera_Scale_AVM737_720x480_to_320x240(self):
        self.check_multi_camera("720x480", "320x240")

    def test_Camera_Scale_AVM737_720x480_to_176x144(self):
        self.check_multi_camera("720x480", "176x144")

    def test_Camera_Scale_AVM737_720x480_to_1280x720_50fps(self):
        self.check_multi_camera_with_fps("720x480", "1280x720")

    def test_Camera_Scale_AVM737_720x480_to_1920x1080_50fps(self):
        self.check_multi_camera_with_fps("720x480", "1920x1080")

    def test_Camera_Scale_AVM737_720x480_to_640x480_50fps(self):
        self.check_multi_camera_with_fps("720x480", "640x480")

    def test_Camera_Scale_AVM737_720x480_to_720x480_50fps(self):
        self.check_multi_camera_with_fps("720x480", "720x480")

    def test_Camera_Scale_TP_UYVY_640x480_Progressive_fps_60(self):
        pass
Пример #10
0
class CameraTest(CameraTestBase):
    """
    @summary: This test used to test camera function
    """
    def setUp(self):
        """
        @summary: set up
        @return: None
        """
        super(CameraTest, self).setUp()
        self._test_name = __name__
        print "[Setup]: %s" % self._test_name

    def tearDown(self):
        """
        @summary: tearDown
        @return: None
        """
        super(CameraTest, self).tearDown()
        print "[Teardown]: %s" % self._test_name
        g_common_obj.stop_exp_handle()
        time.sleep(3)

    def appPrepare(self):
        self.camera = CameraCommon().switchPlatform()
        self.multimedia_setting = MultiMediaSetting(
            CameraCommon.DEFAULT_CONFIG_FILE)
        self.checkImage = CheckImage()
        self.video = CheckVideo()
        self.settings = SettingsImpl()
        self.host_path = CameraCommon().getTmpDir()
        self.makefileTime = CameraCommon().makefileTime
        self.camera_dir = CameraCommon().camera_dir
        CameraCommon().removeDeivceFile()
        CameraCommon().removeFile(self.host_path + "/*")
        self.camera.cleanMediaFiles()
        CameraCommon().setOrientationToVertical()
        self.logger.debug("app prepare successfully")

    def checkFileCorrupt(self, mediaFileCount=1):
        return CameraCommon().checkFileCorrupt(mediaFileCount)

    def pictureWallpaperContactIconTest(self):
        try:
            self.appPrepare()
            CameraCommon().pressHome()
            CameraCommon().getScreenshotAndPullToHost("sc1.png",
                                                      self.host_path)
            self.camera.startCameraApp()
            self.camera.selectMode("Camera")
            self.camera.capturePhoto()
            CameraCommon().pressBack(2)
            CameraCommon().setWallpaper("picture")
            CameraCommon().getScreenshotAndPullToHost("sc2.png",
                                                      self.host_path)
            if self.checkImage.compare_images(self.host_path + "/sc1.png",
                                              self.host_path + "/sc2.png"):
                os.system("cp " + self.host_path + "/sc1.png" + " " +
                          g_common_obj.get_user_log_dir())
                os.system("cp " + self.host_path + "/sc2.png" + " " +
                          g_common_obj.get_user_log_dir())
                self.assertTrue(False, "change wallpaper fail")
        except Exception as e:
            CameraCommon().checkCameraCrash()
            self.assertTrue(False, e)
        finally:
            CameraCommon().setWallpaper()

    def cameraworkairplaneModeOnTest(self):
        try:
            self.appPrepare()
            self.settings.launch_settings()
            self.settings.set_airplane_mode("ON")
            self.camera.startCameraApp()
            self.camera.selectMode("Camera")
            self.camera.capturePhoto()
            time.sleep(2)
            file_name = self.checkFileCorrupt()[1]
            self.path = self.host_path + "/" + file_name
            errMsg = self.checkImage.check_image_corrupt(self.path)
            if errMsg != "":
                self.assertTrue(False, errMsg)
            CameraCommon().removeFile(self.path)
            CameraCommon().removeDeivceFile()
        except Exception as e:
            CameraCommon().checkCameraCrash()
            self.assertTrue(False, e)
        finally:
            self.settings.launch_settings()
            self.settings.set_airplane_mode("OFF")

    def push_file(self, cmd, datapath):
        if "http" not in datapath and "ftp" not in datapath:
            datapath = self.multimedia_setting.resource_file_path + datapath
        file_name = cmd.split("/")[-1].replace("\"", "")
        push_path = cmd.split("\" \"")[1].replace("\"", "")
        if "http" not in datapath and "ftp" not in datapath:
            file_path = os.path.join(datapath, file_name)
            file_path = file_path.replace("%20", " ")
            assert os.path.exists(
                file_path), "resource file not exist! path=%s" % file_path
            ret_file = file_path
        else:
            ret_file = Artifactory(datapath).get(file_name)
        if os.path.exists(ret_file):
            self.logger.debug("[Download]: Artifactory method")
            g_common_obj.adb_cmd_common(
                "push \"" + ret_file + "\" " + "\"" + push_path + "\"", 1000)
            return ret_file
        else:
            assert 0, "Download filed!"

    def cameraFITAddFilesCameraFolderTest(self):
        try:
            self.appPrepare()
            self.logger.debug("push image file")
            self.image_path = self.push_file(
                self.camera.cfg.get("fit_image_name"),
                self.camera.cfg.get("fit_image_url"))
            CameraCommon().refreshCameraDir()
            self.camera.startCameraApp()
            self.camera.reviewPhotoAndVideo()
            CameraCommon().removeDeivceFile()
            CameraCommon().pressBack(2)
            self.camera.stopCameraApp()
            self.logger.debug("push video file")
            self.push_file(self.camera.cfg.get("fit_video_name"),
                           self.camera.cfg.get("fit_video_url"))
            CameraCommon().refreshCameraDir()
            time.sleep(3)
            self.camera.startCameraApp()
            self.camera.reviewPhotoAndVideo()
        except Exception as e:
            CameraCommon().checkCameraCrash()
            self.assertTrue(False, e)

    def cameraFITLaunchFromScreenLockTest(self):
        try:
            self.appPrepare()
            self.camera.startCameraApp()
            CameraCommon().clickScreenCenter()
            CameraCommon().pressBack(2)
        except Exception as e:
            CameraCommon().checkCameraCrash()
            self.assertTrue(False, e)

        platform = CameraCommon().getPlatform()
        try:
            self.camera.startCameraApp()
            CameraCommon().clickScreenCenter()
            CameraCommon().pressBack(2)
            if "3gr" not in platform:
                CameraCommon().lockPIN()
            else:
                CameraCommon().lockScreen()
            CameraCommon().pressPower()
            CameraCommon().pressPower()
            CameraCommon().swipeCorner()
            time.sleep(3)
            CameraCommon().switchCamera(platform)
            time.sleep(2)
            CameraCommon().checkCameraCrash()
            CameraCommon().pressBack(2)
            CameraCommon().unlockPIN()
        except Exception as e:
            CameraCommon().unlockPIN()
            CameraCommon().checkCameraCrash()
            self.assertTrue(False, e)

    def cameraFITVideoModeAlarmTest(self):
        try:
            self.appPrepare()
            self.multimedia_setting.install_apk("alarm_apk")
            CameraCommon().launchAlarmApp()
            CameraCommon().setAlarmTime(70)
            self.camera.startCameraApp()
            self.camera.selectMode("Video")
            self.camera.switchRearOrFront("Back")
            self.camera.clickRecordBtn()
            mTime = time.time()
            while time.time() - mTime < 180:
                time.sleep(5)
                if CameraCommon().alarmDismissOrSnooze():
                    break
            CameraCommon().checkCameraCrash()
            CameraCommon().launchAlarmApp()
            CameraCommon().setAlarmTime(70)
            self.camera.startCameraApp()
            self.camera.selectMode("Video")
            self.camera.switchRearOrFront("Front")
            self.camera.clickRecordBtn()
            mTime = time.time()
            while time.time() - mTime < 180:
                time.sleep(5)
                if CameraCommon().alarmDismissOrSnooze():
                    break
            CameraCommon().checkCameraCrash()
            self.checkFileCorrupt()
        except Exception as e:
            CameraCommon().checkCameraCrash()
            self.assertTrue(False, e)

    def cameraLaunchVia3rdPartAppsTest(self):
        try:
            self.appPrepare()
            self.multimedia_setting.install_apk("thirdpartapk")
            CameraCommon().launchThirdPartApp()
            CameraCommon().captureImageOrRecordingVia3rdPartApp("image")
            CameraCommon().checkGuide()
            self.camera.capturePhoto(wait_time=20, flag=1)
            self.camera.clickDoneBtn()
            #             if self.camera.isShutterBtnExists():
            #                 CameraCommon().pressBack()
            CameraCommon().launchThirdPartApp()
            CameraCommon().captureImageOrRecordingVia3rdPartApp("video")
            CameraCommon().pressBack(2)
        except Exception as e:
            CameraCommon().checkCameraCrash()
            self.assertTrue(False, e)

    def test_Camera_Picture_Wallpaper_ContactIcon(self):
        self.pictureWallpaperContactIconTest()

    def test_Camera_Work_AirplaneModeOn(self):
        self.cameraworkairplaneModeOnTest()

    def test_Camera_FIT_AddFile_CameraFolder(self):
        self.cameraFITAddFilesCameraFolderTest()

    def test_Camera_FIT_launch_From_Screen_Lock(self):
        self.cameraFITLaunchFromScreenLockTest()

    def test_Camera_FIT_VideoMode_Alarm(self):
        self.cameraFITVideoModeAlarmTest()

    def test_Camera_Launch_Via_3rd_Part_Apps(self):
        self.cameraLaunchVia3rdPartAppsTest()
Пример #11
0
class CameraTest(CameraTestBase):
    """
    @summary: This test used to test camera function
    """
    def setUp(self):
        """
        @summary: set up
        @return: None
        """
        super(CameraTest, self).setUp()
        self._test_name = __name__
        print "[Setup]: %s" % self._test_name

    def tearDown(self):
        """
        @summary: tearDown
        @return: None
        """
        super(CameraTest, self).tearDown()
        print "[Teardown]: %s" % self._test_name
        g_common_obj.stop_exp_handle()
        time.sleep(3)

    def appPrepare(self):
        self.camera = ArcSoftCamera()
        self.checkImage = CheckImage()
        self.video = CheckVideo()
        self.host_path = CameraCommon().getTmpDir()
        self.makefileTime = CameraCommon().makefileTime
        self.camera_dir = CameraCommon().camera_dir
        CameraCommon().removeDeivceFile()
        CameraCommon().removeFile(self.host_path + "/*")
        self.camera.cleanMediaFiles()
        CameraCommon().setOrientationToVertical()
        self.multimedia_setting = MultiMediaSetting(
            CameraCommon.DEFAULT_CONFIG_FILE)
        self.multimedia_setting.install_apk("quickpic_apk")
        self.logger.debug("app prepare successfully")

    def checkFileCorrupt(self, mediaFileCount=1):
        return CameraCommon().checkFileCorrupt(mediaFileCount)

    def cameraInformationCameraTest(self, category, lens):
        try:
            self.appPrepare()
            self.camera.startCameraApp()
            self.camera.switchRearOrFront(lens)
            self.camera.setCaptureModeValue(category, "low")
            self.camera.capturePhoto()
            info1 = self.checkFileCorrupt()[0]
            low = info1.get(category)
            CameraCommon().removeDeivceFile()
            self.logger.debug(low)
            if low != "Low":
                self.assertTrue(False,
                                "picture %s info is not soft" % category)
            self.camera.setCaptureModeValue(category, "middle")
            self.camera.capturePhoto()
            info2 = self.checkFileCorrupt()[0]
            middle = info2.get(category)
            CameraCommon().removeDeivceFile()
            self.logger.debug(middle)
            if middle != "Normal":
                self.assertTrue(False,
                                "picture %s info is not Normal" % category)
            self.camera.setCaptureModeValue(category, "high")
            self.camera.capturePhoto()
            info3 = self.checkFileCorrupt()[0]
            high = info3.get(category)
            CameraCommon().removeDeivceFile()
            self.logger.debug(high)
            if high != "High":
                self.assertTrue(False,
                                "picture %s info is not high" % category)
        except Exception as e:
            CameraCommon().checkCameraCrash()
            self.assertTrue(False, e)

    def cameraSharpnessInformationCameraTest(self, category, lens):
        try:
            self.appPrepare()
            self.camera.startCameraApp()
            self.camera.switchRearOrFront(lens)
            self.camera.setCaptureModeValue(category, "low")
            self.camera.capturePhoto()
            info1 = self.checkFileCorrupt()[0]
            soft = info1.get(category)
            CameraCommon().removeDeivceFile()
            print soft
            if soft != "Soft":
                self.assertTrue(False,
                                "picture %s info is not soft" % category)
            self.camera.setCaptureModeValue(category, "middle")
            self.camera.capturePhoto()
            info2 = self.checkFileCorrupt()[0]
            middle = info2.get(category)
            CameraCommon().removeDeivceFile()
            print middle
            if middle != "Normal":
                self.assertTrue(False,
                                "picture %s info is not normal" % category)
            self.camera.setCaptureModeValue(category, "high")
            self.camera.capturePhoto()
            info3 = self.checkFileCorrupt()[0]
            hard = info3.get(category)
            CameraCommon().removeDeivceFile()
            print hard
            if hard != "Hard":
                self.assertTrue(False,
                                "picture %s info is not hard" % category)
        except Exception as e:
            CameraCommon().checkCameraCrash()
            self.assertTrue(False, e)

    def cameraBestShotRearPreviewTest(self):
        try:
            self.appPrepare()
            self.camera.startCameraApp()
            self.camera.switchRearOrFront("Rear")
            self.camera.setCaptureMode("Best photo")
            self.camera.capturePhoto(1, False)
            self.camera.clickbestPhotoApproveBtn()
            CameraCommon().waitForTheFilesAreGenerated()
            self.checkFileCorrupt()
            self.camera.reviewPhotoAndVideo()
        except Exception as e:
            CameraCommon().checkCameraCrash()
            self.assertTrue(False, e)

    def cameraBestShotRearEXIFTest(self):
        try:
            self.appPrepare()
            self.camera.startCameraApp()
            self.camera.switchRearOrFront("Back")
            self.camera.setCaptureMode("Best photo")
            self.camera.capturePhoto(1, False)
            self.camera.clickbestPhotoApproveBtn()
            CameraCommon().waitForTheFilesAreGenerated()
            info, file_name = self.checkFileCorrupt()
            CameraCommon().checkEXIFInfo(info, file_name)
        except Exception as e:
            CameraCommon().checkCameraCrash()
            self.assertTrue(False, e)

    def cameraSetBrightnessEXIFTest(self, category, lens):
        try:
            self.appPrepare()
            self.camera.startCameraApp()
            self.camera.switchRearOrFront(lens)
            self.camera.setCaptureModeValue(category, "low")
            self.camera.capturePhoto()
            info1, file_name1 = self.checkFileCorrupt()
            low = info1.get("Brightness Value")
            CameraCommon().removeDeivceFile()
            error_msg = ""
            if low != "0":
                os.system("cp " + self.host_path + "/" + file_name1 + " " +
                          g_common_obj.get_user_log_dir())
                error_msg += "check low brightness value fail,low brightness value=%s" % low
            self.camera.setCaptureModeValue(category, "middle")
            self.camera.capturePhoto()
            info2, file_name2 = self.checkFileCorrupt()
            middle = info2.get("Brightness Value")
            CameraCommon().removeDeivceFile()
            if middle != "0":
                os.system("cp " + self.host_path + "/" + file_name2 + " " +
                          g_common_obj.get_user_log_dir())
                error_msg += "check normal brightness value fail,normal brightness value=%s" % middle
            self.camera.setCaptureModeValue(category, "high")
            self.camera.capturePhoto()
            info3, file_name3 = self.checkFileCorrupt()
            high = info3.get("Brightness Value")
            CameraCommon().removeDeivceFile()
            if high != "0":
                os.system("cp " + self.host_path + "/" + file_name3 + " " +
                          g_common_obj.get_user_log_dir())
                error_msg += "check high brightness value fail,high brightness value=%s" % high
            if low == middle or low == high or middle == high:
                os.system("cp " + self.host_path + "/" + file_name3 + " " +
                          g_common_obj.get_user_log_dir())
                os.system("cp " + self.host_path + "/" + file_name3 + " " +
                          g_common_obj.get_user_log_dir())
                os.system("cp " + self.host_path + "/" + file_name3 + " " +
                          g_common_obj.get_user_log_dir())
                error_msg += "compare %s camera brightness value fail,low=%s,normal=%s,high=%s;" \
                                % (lens, low, middle, high)
                self.assertTrue(False, error_msg)
        except Exception as e:
            CameraCommon().checkCameraCrash()
            self.assertTrue(False, e)

    def cameraUniPreviewTapShutterWhenRecordingTest(self, lens):
        try:
            self.appPrepare()
            self.camera.startCameraApp()
            self.camera.switchRearOrFront(lens)
            self.camera.snapShotDuringVideo(1, 5, 1)
            self.checkFileCorrupt()
        except Exception as e:
            CameraCommon().checkCameraCrash()
            self.assertTrue(False, e)

    def cameraUniPreviewVideoRecordTest(self, lens):
        try:
            self.appPrepare()
            self.camera.startCameraApp()
            self.camera.switchRearOrFront(lens)
            self.camera.clickRecordBtn()
            self.camera.checkVideoRecordingButtonStatus()
            time.sleep(5)
            self.camera.clickRecordBtn()
            self.checkFileCorrupt()
            self.camera.reviewPhotoAndVideo()
        except Exception as e:
            CameraCommon().checkCameraCrash()
            self.assertTrue(False, e)

    def cameraUniPreviewVideoRecordOtherModeTest(self, lens):
        try:
            self.appPrepare()
            self.camera.startCameraApp()
            self.camera.switchRearOrFront(lens)
            self.camera.setCaptureMode("Smart")
            self.camera.clickRecordBtn()
            time.sleep(2)
            self.camera.checkVideoRecordingButtonStatus()
            time.sleep(3)
            self.camera.clickRecordBtn()
            CameraCommon().waitForTheFilesAreGenerated(1)
            self.camera.setCaptureMode("Best photo")
            self.camera.clickRecordBtn()
            time.sleep(2)
            self.camera.checkVideoRecordingButtonStatus()
            time.sleep(3)
            self.camera.clickRecordBtn()
            CameraCommon().waitForTheFilesAreGenerated(2)
            if CameraCommon().isWidgetExists(
                    self.camera.ArcSoftCameraWidget().text("HDR")):
                self.camera.setCaptureMode("HDR")
                self.camera.clickRecordBtn()
                time.sleep(2)
                self.camera.checkVideoRecordingButtonStatus()
                time.sleep(3)
                self.camera.clickRecordBtn()
                CameraCommon().waitForTheFilesAreGenerated(3)
            self.camera.setCaptureMode("Smile")
            self.camera.clickRecordBtn()
            time.sleep(2)
            self.camera.checkVideoRecordingButtonStatus()
            time.sleep(3)
            self.camera.clickRecordBtn()
            CameraCommon().waitForTheFilesAreGenerated(4)
            self.camera.reviewPhotoAndVideo()
            self.checkFileCorrupt()
        except Exception as e:
            CameraCommon().checkCameraCrash()
            self.assertTrue(False, e)

    def cameraBestShotRearIterativeCaptureTest(self, lens):
        try:
            self.appPrepare()
            self.camera.startCameraApp()
            self.camera.switchRearOrFront(lens)
            self.camera.setCaptureMode("Best photo")
            for i in range(20):
                self.camera.capturePhoto()
                self.camera.clickbestPhotoApproveBtn()
                CameraCommon().waitForTheFilesAreGenerated(i + 1)
            self.camera.reviewPhotoAndVideo()
            self.checkFileCorrupt()
        except Exception as e:
            CameraCommon().checkCameraCrash()
            self.assertTrue(False, e)

    def cameraRestoreDefaultTest(self):
        try:
            self.appPrepare()
            self.camera.startCameraApp()
            self.camera.switchRearOrFront("Rear")
            self.camera.setColorEffect("Mono")
            self.camera.capturePhoto()
            file_name = self.checkFileCorrupt()[1]
            self.color_effect = self.checkImage.is_mono(self.host_path + "/" +
                                                        file_name)
            if not self.color_effect:
                os.system("cp " + self.host_path + "/" + file_name + " " +
                          g_common_obj.get_user_log_dir())
                self.assertTrue(False,
                                "check Rear camera color effect to mono fail")
            CameraCommon().removeDeivceFile()
            self.camera.resetCameraSetting()
            self.camera.capturePhoto()
            file_name2 = self.checkFileCorrupt()[1]
            self.color_effect = self.checkImage.is_mono(self.host_path + "/" +
                                                        file_name2)
            if self.color_effect:
                os.system("cp " + self.host_path + "/" + file_name + " " +
                          g_common_obj.get_user_log_dir())
                self.assertTrue(False,
                                "check Rear camera color effect to mono fail")
            self.camera.reviewPhotoAndVideo()
        except Exception as e:
            CameraCommon().checkCameraCrash()
            self.assertTrue(False, e)

    def cameraUniPreviewTapOtherButtonTest(self, lens):
        try:
            self.appPrepare()
            self.camera.startCameraApp()
            self.camera.switchRearOrFront(lens)

            def clickRecordingButton(self, rtime=""):
                print time.time()
                ArcSoftCamera().clickShutterBtnWithoutRelease("Video", 4)
                ArcSoftCamera().recordVideo(1, 3)

            def clickCaptureButton(self, rtime=""):
                print time.time()
                time.sleep(2)
                ArcSoftCamera().capturePhoto()
                ArcSoftCamera().clickShutterBtnWithoutRelease("Camera", 3)

            threads = []
            t1 = threading.Thread(target=clickRecordingButton, args=('', ))
            threads.append(t1)
            t2 = threading.Thread(target=clickCaptureButton, args=('', ))
            threads.append(t2)

            for t in threads:
                t.start()
            t.join()
            print time.time()
            self.checkFileCorrupt()
        except Exception as e:
            CameraCommon().checkCameraCrash()
            self.assertTrue(False, e)

    def test_Camera_BestShot_Rear_Preview(self):
        self.cameraBestShotRearPreviewTest()

    def test_Camera_SetSaturation_Front_EXIF(self):
        self.cameraInformationCameraTest("Saturation", "Front")

    def test_Camera_SetSaturation_Rear_EXIF(self):
        self.cameraInformationCameraTest("Saturation", "Back")

    def test_Camera_SetSharpness_Front_EXIF(self):
        self.cameraSharpnessInformationCameraTest("Sharpness", "Front")

    def test_Camera_SetSharpness_Rear_EXIF(self):
        self.cameraSharpnessInformationCameraTest("Sharpness", "Back")

    def test_Camera_SetContrast_Front_EXIF(self):
        self.cameraInformationCameraTest("Contrast", "Front")

    def test_Camera_SetContrast_Rear_EXIF(self):
        self.cameraInformationCameraTest("Contrast", "Back")

    def test_Camera_BestShot_Rear_EXIF(self):
        self.cameraBestShotRearEXIFTest()

    def test_Camera_SetBrightness_Front_EXIF(self):
        self.cameraSetBrightnessEXIFTest("Brightness", "Front")

    def test_Camera_SetBrightness_Rear_EXIF(self):
        self.cameraSetBrightnessEXIFTest("Brightness", "Back")

    def test_Camera_UniPreview_Front_TapShutterWhenRecording(self):
        self.cameraUniPreviewTapShutterWhenRecordingTest("Front")

    def test_Camera_UniPreview_Rear_TapShutterWhenRecording(self):
        self.cameraUniPreviewTapShutterWhenRecordingTest("Back")

    def test_Camera_UniPreview_Front_VideoRecord_AfterLaunch(self):
        self.cameraUniPreviewVideoRecordTest("Front")

    def test_Camera_UniPreview_Rear_VideoRecord_AfterLaunch(self):
        self.cameraUniPreviewVideoRecordTest("Back")

    def test_Camera_UniPreview_Front_VideoRecord_OtherMode(self):
        self.cameraUniPreviewVideoRecordOtherModeTest("Front")

    def test_Camera_UniPreview_Rear_VideoRecord_OtherMode(self):
        self.cameraUniPreviewVideoRecordOtherModeTest("Back")

    def test_Camera_BestShot_Rear_IterativeCapture(self):
        self.cameraBestShotRearIterativeCaptureTest("Back")

    def test_Camera_RestoreDefault(self):
        self.cameraRestoreDefaultTest()

    def test_Camera_UniPreview_Front_TapOtherButton(self):
        self.cameraUniPreviewTapOtherButtonTest("Front")
class MultiMediaScaleTestHelper:
    def __init__(self, host_path):
        self.logger = Logger.getlogger()
        self.host_path = host_path
        self.camera_helper = MultiMediaSwitchCameraHelper(
            skip_import_camera=True)
        self.target_folder = os.path.join(self.host_path,
                                          self.camera_helper.device,
                                          self.camera_helper.android_version)
        self.expect_folder = os.path.join(self.target_folder, "expect")
        self.actual_folder = os.path.join(self.target_folder, "actual")
        if not os.path.exists(self.expect_folder):
            os.makedirs(self.expect_folder)
        if not os.path.exists(self.actual_folder):
            os.makedirs(self.actual_folder)

        self.ffmpeg_cmd = "ffmpeg -i %s -ss 00:00.02 -y -q:v 2 -vframes 1 %s"
        self.movies_folder_device_path = "/sdcard/Movies/"
        self.scale_test_xml_value_dict = {1: 30, 2: 50, 3: 60}
        self.play_result = -1

        self.get_cfg_file_helper = GetConfigFileHelper(
            "", "multimedia_scale_test_helper.conf")
        self.scale_test_cfg = self.get_cfg_file_helper.get_section("config")
        self.multimedia_setting = MultiMediaSetting(
            self.get_cfg_file_helper.cfg_file)
        self.generated_reference_library = int(
            self.scale_test_cfg.get("generated_reference_library"))
        self.reference_library_folder = self.scale_test_cfg.get(
            "reference_library_folder")
        self.reference_library_folder = os.path.join(
            self.reference_library_folder, self.camera_helper.device,
            self.camera_helper.android_version)
        self.xml_file_dst_path = self.scale_test_cfg.get("xml_file_dst_path")
        self.o_image_camera3_xml_file_dst_path = self.scale_test_cfg.get(
            "o_image_camera3_xml_file_dst_path")

    def __execute_command_with_popen(self, cmd, t_shell=False):
        self.logger.debug("__execute_command_with_popen cmd=%s" % cmd)
        if not t_shell:
            cmd = cmd.split()
        return subprocess.Popen(cmd,
                                stdin=subprocess.PIPE,
                                stdout=subprocess.PIPE,
                                stderr=subprocess.STDOUT,
                                shell=t_shell)

    def remount_device(self):
        if self.camera_helper.android_version == "o":
            from testlib.graphics.common import adb32
            adb32.adb_disable_verity()
        else:
            from testlib.common.common import g_common_obj2
            self.serial = g_common_obj2.getSerialNumber()
            os.system("adb -s %s root" % self.serial)
            os.system("adb -s %s root" % self.serial)
            os.system("adb -s %s disable-verity" % self.serial)
            os.system("adb -s %s reboot" % self.serial)
            time.sleep(60)
            os.system("adb -s %s root" % self.serial)
            time.sleep(30)
            os.system("adb -s %s root" % self.serial)
            result = 'remount succeeded'
            remount_result = os.popen("adb -s %s remount" %
                                      self.serial).read().strip()
            print "[Info] --- remount result is %s" % remount_result
            if result == remount_result:
                print "[Info] --- remount successfull"
            else:
                assert False, "[Info] --- remount fail"

    def backup_file(self, dst_path_string, backup_name_postfix="_backup"):
        dst_path = self.scale_test_cfg.get(dst_path_string)
        dst_path_root, dst_path_ext = os.path.splitext(dst_path)
        backup_dst_path = "%s%s%s" % (dst_path_root, backup_name_postfix,
                                      dst_path_ext)
        self.logger.debug("backup_file backup_dst_path=%s" % backup_dst_path)
        t_result = g_common_obj.adb_cmd_capture_msg("ls %s" % backup_dst_path)
        if backup_dst_path not in t_result:
            g_common_obj.adb_cmd_capture_msg("cp %s %s" %
                                             (dst_path, backup_dst_path))
            t_result = g_common_obj.adb_cmd_capture_msg("ls %s" %
                                                        backup_dst_path)
            assert backup_dst_path in t_result, "cp failed! t_result=%s" % t_result
        return (dst_path, backup_dst_path)

    def restore_file(self, dst_path_string, backup_name_postfix="_backup"):
        dst_path = self.scale_test_cfg.get(dst_path_string)
        dst_path_root, dst_path_ext = os.path.splitext(dst_path)
        backup_dst_path = "%s%s%s" % (dst_path_root, backup_name_postfix,
                                      dst_path_ext)
        t_result = g_common_obj.adb_cmd_capture_msg("ls %s" % backup_dst_path)
        if backup_dst_path in t_result:
            g_common_obj.adb_cmd_capture_msg("cp %s %s" %
                                             (backup_dst_path, dst_path))
            t_result = g_common_obj.adb_cmd_capture_msg("ls %s" % dst_path)
            self.logger.debug("backup_file t_result=%s" % t_result)
            return True
        return False

    def replace_file(self, src_path_string, dst_path_string):
        src_path = self.scale_test_cfg.get(src_path_string)
        dst_path = self.scale_test_cfg.get(dst_path_string)
        g_common_obj.adb_cmd_capture_msg("rm -rf %s" % dst_path)
        t_result = g_common_obj.adb_cmd_capture_msg("ls %s" % dst_path)
        assert dst_path not in t_result, "rm failed! t_result=%s" % t_result
        dst_path = self.multimedia_setting.push_file_new(src_path, dst_path)
        t_result = g_common_obj.adb_cmd_capture_msg("ls %s" % dst_path)
        assert dst_path in t_result, "push failed! t_result=%s" % t_result
        return dst_path

    def scale_test_o_image_prepare(self):
        package_name, _ = self.multimedia_setting.get_package_and_activity_name(
            "for_o_image_camera_preview_test_apk")
        self.o_image_play_cmd = self.scale_test_cfg.get("o_image_play_cmd")
        result = verify_apps(package_name)

        self.remount_device()
        self.backup_file("o_image_media_xml_file_dst_path")
        self.o_image_media_xml_file_dst_path = self.replace_file(
            "o_image_media_xml_file_src_path",
            "o_image_media_xml_file_dst_path")
        self.backup_file("o_image_libcamhal_xml_file_dst_path")
        self.o_image_libcamhal_xml_file_dst_path = self.replace_file(
            "o_image_libcamhal_xml_file_src_path",
            "o_image_libcamhal_xml_file_dst_path")
        self.o_image_camera3_xml_file_dst_path = self.backup_file(
            "o_image_camera3_xml_file_dst_path")[0]
        self.restore_file("o_image_camera3_xml_file_dst_path", "_hdmi")

        if not result:
            self.multimedia_setting.install_apk(
                "for_o_image_camera_preview_test_apk")
        return True

    def scale_test_default_image_prepare(self, fps="60fps"):
        self.sh_file_src_path = self.scale_test_cfg.get("sh_file_src_path")
        self.sh_file_dst_path = self.scale_test_cfg.get("sh_file_dst_path")
        self.backup_file("xml_file_dst_path")
        package_name, _ = self.multimedia_setting.get_package_and_activity_name(
            "camera_preview_test_apk")
        result = verify_apps(package_name)
        if not result:
            self.remount_device()

            g_common_obj.adb_cmd_capture_msg("rm -rf %s" %
                                             self.sh_file_dst_path)
            t_result = g_common_obj.adb_cmd_capture_msg("ls %s" %
                                                        self.sh_file_dst_path)
            assert "No such file or directory" in t_result, "rm failed! t_result=%s" % t_result
            self.sh_file_dst_path = self.multimedia_setting.push_file_new(
                self.sh_file_src_path, self.sh_file_dst_path)
            t_result = g_common_obj.adb_cmd_capture_msg("ls %s" %
                                                        self.sh_file_dst_path)
            assert "No such file or directory" not in t_result, "push failed! t_result=%s" % t_result
            g_common_obj.adb_cmd_capture_msg("chmod 777 %s" %
                                             self.sh_file_dst_path)

            self.multimedia_setting.install_apk("camera_preview_test_apk")
        return not result

    def scale_test_prepare(self, fps="60fps"):
        self.logger.debug("scale_test_prepare")
        if self.camera_helper.android_version == "o":
            result = self.scale_test_o_image_prepare()
        else:
            result = self.scale_test_default_image_prepare(fps)
        return result

    def scale_test_o_image_teardown(self):
        self.remount_device()
        self.restore_file("o_image_media_xml_file_dst_path")
        self.restore_file("o_image_libcamhal_xml_file_dst_path")
        self.restore_file("o_image_camera3_xml_file_dst_path")
        return 1

    def scale_test_teardown(self):
        self.logger.debug("scale_test_teardown")
        self.remount_device()
        if self.camera_helper.android_version == "o":
            self.restore_file("o_image_media_xml_file_dst_path")
            self.restore_file("o_image_libcamhal_xml_file_dst_path")
            self.restore_file("o_image_camera3_xml_file_dst_path")
        else:
            self.restore_file("xml_file_dst_path")
        return 1

    def change_scale_test_xml(self, fps):
        fps = str(fps)
        self.logger.debug("change_scale_test_xml fps=%s" % fps)
        if "fps" not in fps and "default" not in fps:
            fps = fps + "fps"
        self.remount_device()
        xml_file_src_path = self.scale_test_cfg.get("%s_xml_file_src_path" %
                                                    fps)
        xml_file_dst_path = self.scale_test_cfg.get("%s_xml_file_dst_path" %
                                                    fps)
        g_common_obj.adb_cmd_capture_msg("rm -rf %s" % xml_file_dst_path)
        t_result = g_common_obj.adb_cmd_capture_msg("ls %s" %
                                                    xml_file_dst_path)
        assert "No such file or directory" in t_result, "rm failed! t_result=%s" % t_result
        self.xml_file_dst_path = self.multimedia_setting.push_file_new(
            xml_file_src_path, xml_file_dst_path)
        t_result = g_common_obj.adb_cmd_capture_msg("ls %s" %
                                                    self.xml_file_dst_path)
        assert self.xml_file_dst_path in t_result, "push failed! t_result=%s" % t_result

    def change_scale_test_xml_param_handle(self, param, str1, str2):
        return " -e 's#%s#%s#g' " % (param % str1, param % str2)

    def change_scale_test_xml_for_o_image(self, dst_path, case_name):
        self.logger.debug("change_scale_test_xml_for_o_image")
        field, input_size, input_format, deinterlace_mode = self.analyze_case_name(
            case_name)
        main_param = ""
        main_param += self.change_scale_test_xml_param_handle(
            "intel.sensorprop.field\ value=\\\"%s\\\"", ".*", field)
        main_param += self.change_scale_test_xml_param_handle(
            "intel.sensorprop.inputSize\ value=\\\"%s\\\"", ".*", input_size)
        main_param += self.change_scale_test_xml_param_handle(
            "intel.sensorprop.inputFormat\ value=\\\"%s\\\"", ".*",
            input_format)
        main_param += self.change_scale_test_xml_param_handle(
            "intel.sensorprop.deinterlaceMode\ value=\\\"%s\\\"", ".*",
            deinterlace_mode)
        cmd = "sed -i %s %s" % (main_param, dst_path)
        self.logger.debug("change_scale_test_xml_for_o_image cmd=%s" % cmd)
        g_common_obj.adb_cmd_capture_msg(cmd)

    def change_libcamhal_xml_for_o_image(self, dst_path, case_name):
        self.logger.debug("change_libcamhal_xml_for_o_image")
        actual_fps = self.check_string_with_regular_expression(
            case_name, r"_(\d*)[fps]{0,3}$", "")[1][0]
        for t_key in self.scale_test_xml_value_dict.keys():
            if actual_fps == str(self.scale_test_xml_value_dict[t_key]):
                break
        main_param = ""
        main_param += self.change_scale_test_xml_param_handle(
            "ctrlId=\\\"V4L2_CID_TEST_PATTERN\\\"\ value=\\\"%s\\\"\ ctrlName=",
            ".*", str(t_key))
        cmd = "sed -i %s %s" % (main_param, dst_path)
        self.logger.debug("change_libcamhal_xml_for_o_image cmd=%s" % cmd)
        g_common_obj.adb_cmd_capture_msg(cmd)

    def check_string_with_regular_expression(self, string, parttern,
                                             expect_value):
        get_value_parttern = re.compile(parttern)
        value_list = get_value_parttern.findall(string)

        assert len(
            value_list) != 0, "Can't find parttern(%s) in string!" % parttern

        actual_value = value_list[0]
        self.logger.debug(
            "check_string_with_regular_expression actual_value=%s, expect_value=%s"
            % (actual_value, expect_value))
        result = 0 if actual_value == expect_value else -1
        return (result, value_list)

    def analyze_case_name(self, case_name):
        field = "ANY" if "progressive" in case_name.lower() else "ALTERNATE"
        deinterlace_mode = "OFF" if "progressive" in case_name.lower(
        ) else "ON"
        input_size = self.check_string_with_regular_expression(
            case_name, r"_(\d*x\d*)", "")[1][0]
        input_size = input_size.replace("x", ",")
        input_format = "YUY2" if "YUYV" in case_name else "UYVY"

        self.logger.debug(
            "analyze_case_name field=%s, input_size=%s, input_format=%s, deinterlace_mode=%s"
            % (field, input_size, input_format, deinterlace_mode))
        return field, input_size, input_format, deinterlace_mode

    def check_scale_test_xml_for_o_image(self, case_name):
        self.logger.debug("check_scale_test_xml_for_o_image case_name=%s" %
                          case_name)
        field, input_size, input_format, deinterlace_mode = self.analyze_case_name(
            case_name)
        check_scale_test_xml_cmd = "cat %s" % self.o_image_camera3_xml_file_dst_path
        t_result = g_common_obj.adb_cmd_capture_msg(check_scale_test_xml_cmd)

        result = 0
        result += self.check_string_with_regular_expression(
            t_result, r"<intel.sensorprop.field value=\"(.*)\" />", field)[0]
        result += self.check_string_with_regular_expression(
            t_result, r"<intel.sensorprop.inputSize value=\"(.*)\" />",
            input_size)[0]
        result += self.check_string_with_regular_expression(
            t_result, r"<intel.sensorprop.inputFormat value=\"(.*)\" />",
            input_format)[0]
        result += self.check_string_with_regular_expression(
            t_result, r"<intel.sensorprop.deinterlaceMode value=\"(.*)\" />",
            deinterlace_mode)[0]
        return True if result == 0 else False

    def check_libcamhal_xml_for_o_image(self, case_name):
        self.logger.debug("check_libcamhal_xml_for_o_image case_name=%s" %
                          case_name)
        check_libcamhal_xml_cmd = "cat %s" % self.o_image_libcamhal_xml_file_dst_path
        t_result = g_common_obj.adb_cmd_capture_msg(check_libcamhal_xml_cmd)
        actual_fps = self.check_string_with_regular_expression(
            case_name, r"_(\d*)[fps]{0,3}$", "")[1][0]
        for t_key in self.scale_test_xml_value_dict.keys():
            if actual_fps == str(self.scale_test_xml_value_dict[t_key]):
                break
        result = 0
        result += self.check_string_with_regular_expression(
            t_result,
            r"ctrlId=\"V4L2_CID_TEST_PATTERN\" value=\"(.*)\" ctrlName=",
            str(t_key))[0]
        return True if result == 0 else False

    def check_scale_test_xml_for_default_image(self,
                                               expect_fps,
                                               special_str=""):
        expect_fps = str(expect_fps)
        if special_str != "":
            expect_fps = "default"
        check_scale_test_xml_cmd = "cat %s" % self.xml_file_dst_path
        t_result = g_common_obj.adb_cmd_capture_msg(check_scale_test_xml_cmd)
        get_scale_xml_fps_value_parttern = re.compile(
            r"<control name=\"adv7481-hdmi pixel array 0-00e0\".*value=\"(.)\".*/>"
        )
        fps_value_result_list = get_scale_xml_fps_value_parttern.findall(
            t_result)
        self.logger.debug("check_scale_test_xml fps_value_result_list=%s" %
                          fps_value_result_list)
        if len(fps_value_result_list) == 0:
            actual_fps = "default"
        else:
            fps_value_result = fps_value_result_list[0]
            self.logger.debug("check_scale_test_xml fps_value_result=%s" %
                              fps_value_result)
            actual_fps = str(self.scale_test_xml_value_dict[int(
                fps_value_result[0])])
        self.logger.debug("check_scale_test_xml actual_fps=%s, expect_fps=%s" %
                          (actual_fps, expect_fps))
        if actual_fps != expect_fps:
            self.change_scale_test_xml(expect_fps)
            return True
        else:
            return False

    def check_scale_test_xml(self, expect_fps, case_name=""):
        if self.camera_helper.android_version == "o":
            need_reboot = False
            if "AVM737" in case_name:
                need_reboot = True
                self.o_image_libcamhal_xml_file_dst_path = self.replace_file(
                    "o_image_avm737_libcamhal_xml_file_src_path",
                    "o_image_avm737_libcamhal_xml_file_dst_path")
            elif "fps" in case_name.lower():
                result = self.check_libcamhal_xml_for_o_image(case_name)
                if not result:
                    need_reboot = True
                    self.change_libcamhal_xml_for_o_image(
                        self.o_image_libcamhal_xml_file_dst_path, case_name)
                    assert self.check_libcamhal_xml_for_o_image(
                        case_name), "Fail change libcamhal xml!"

            result = self.check_scale_test_xml_for_o_image(case_name)
            if not result:
                need_reboot = True
                self.change_scale_test_xml_for_o_image(
                    self.o_image_camera3_xml_file_dst_path, case_name)
                assert self.check_scale_test_xml_for_o_image(
                    case_name), "Fail change scale test xml!"

            return need_reboot
        else:
            special_str = "AVM737" if "AVM737" in case_name else ""
            result = self.check_scale_test_xml_for_default_image(
                expect_fps, special_str)
            return result

    def download_reference_library_file(self, file_path):
        file_name = os.path.split(file_path)[1]
        t_file_path = self.multimedia_setting.download_file_to_host(
            os.path.join(self.reference_library_folder, file_name))
        shutil.copyfile(t_file_path, file_path)
        return file_path

    def pull_video_file_to_host(self):
        movies_file_name = g_common_obj.adb_cmd_capture_msg(
            "ls %s" % self.movies_folder_device_path)
        self.logger.debug(
            "play_and_record_video_with_instrument movies_file_device_path=%s"
            % movies_file_name)
        g_common_obj.adb_cmd_common(
            "pull %s/%s %s/%s" %
            (self.movies_folder_device_path, movies_file_name, self.host_path,
             movies_file_name))
        movies_file_host_path = os.path.join(self.host_path, movies_file_name)
        return movies_file_host_path

    def play_and_record_video_with_instrument(self, cmd_arguments, case_name):
        duration = 12
        self.play_result = -1
        if self.camera_helper.android_version == "o":
            self.logger.debug(
                "play_and_record_video_with_instrument case_name=%s" %
                case_name)
            if "fps" in case_name.lower():
                cmd_arguments_list = cmd_arguments.split(" ")
                width, height = cmd_arguments_list[4], cmd_arguments_list[5]
            else:
                output_size = self.check_string_with_regular_expression(
                    case_name, r"_(\d*x\d*)", "")[1][1]
                width, height = output_size.split("x")
            t_format = "NV21" if "NV21" in case_name else "NV21"  #need extend
            cmd_result = g_common_obj.adb_cmd_capture_msg(
                self.o_image_play_cmd % (width, height, t_format, duration))
        else:
            self.logger.debug(
                "play_and_record_video_with_instrument cmd=%s %s" %
                (self.sh_file_dst_path, cmd_arguments))
            cmd_result = g_common_obj.adb_cmd_capture_msg(
                "%s %s" % (self.sh_file_dst_path, cmd_arguments))
        self.logger.debug(
            "play_and_record_video_with_instrument cmd_result = %s" %
            cmd_result)
        if "OK" not in cmd_result:
            self.play_result = 0
        else:
            self.play_result = 1

    def get_jpg_from_video(self,
                           video_file_path,
                           output_file_name="output.jpg",
                           output_folder=""):
        if output_folder == "":
            if self.generated_reference_library == 1:
                output_folder = self.expect_folder
            else:
                output_folder = self.actual_folder
        output_file_path = os.path.join(output_folder, output_file_name)
        t_ffmpeg_cmd = self.ffmpeg_cmd % (video_file_path, output_file_path)
        self.logger.debug("t_ffmpeg_cmd = %s" % t_ffmpeg_cmd)
        result = self.__execute_command_with_popen(t_ffmpeg_cmd).stdout.read()
        assert "Invalid" not in result and "error" not in result, "Generate jpg failed! result=%s" % result
        return output_file_path
Пример #13
0
class ImageAPITest(UIATestBase):
    """
    @summary: Test Video PlayBack
    """
    def setUp(self):
        """
        @summary: set up
        @return: None
        """
        super(ImageAPITest, self).setUp()
        self.d = g_common_obj.get_device()
        self._test_name = __name__
        self.x = self.d.info["displayWidth"]
        self.y = self.d.info["displayHeight"]
        print "[Setup]: %s" % self._test_name
        g_common_obj.stop_app_am("com.google.android.GoogleCamera")
        g_common_obj.stop_app_am("com.intel.otc.instrument.otcphotos")
        # Unlock screen
        g_common_obj.adb_cmd_capture_msg("input keyevent 82")

    def tearDown(self):
        """
        @summary: tear tearDown
        @return: None
        """
        super(ImageAPITest, self).tearDown()
        print "[Teardown]: %s" % self._test_name
        g_common_obj.stop_exp_handle()
        time.sleep(3)
        g_common_obj.stop_app_am("com.google.android.GoogleCamera")
        g_common_obj.stop_app_am("com.intel.otc.instrument.otcphotos")

    def launchPhotoAPP(self):
        g_common_obj.launch_app_am("com.intel.otc.instrument.otcphotos", \
                                   "com.intel.otc.instrument.otcphotos.MainActivity")
        time.sleep(3)
        assert self.d(textContains="/").exists, "launch photo app failed!"

    def enterPhotoPath(self, path):
        push_str = path.strip("\"").split("/")
        if push_str[0] == "" and push_str[1] == "sdcard":
            push_str = push_str[2:]
        print push_str
        for t_str in push_str:
            if t_str != "":
                self.d(text=t_str).click()
                time.sleep(2)

    def checkPictureExist(self, file_name):
        assert self.d(text=file_name).exists, file_name + " not find!"

    def appPrepare(self, case_name, model=1):
        cfg_file = os.path.join(os.environ.get('TEST_DATA_ROOT', ''), \
            'tests.tablet.mum_auto_image.conf')
        self.video = CameraImpl(\
            self.config.read(cfg_file, case_name))

        self.multimedia_setting = MultiMediaSetting(cfg_file)
        self.multimedia_setting.install_apk("photo_apk")
        self.video.set_orientation_n()
        # Unlock screen
        g_common_obj.adb_cmd_capture_msg("input keyevent 82")

    def imageViewCaptureJPEG(self, case_name):
        print "run case is " + str(case_name)
        self.appPrepare(case_name)
        self.multimedia_camera_helper = MultiMediaCameraHelper()
        self.multimedia_camera_helper.camera.startCameraApp()
        self.multimedia_camera_helper.camera.selectMode("Camera")
        # bxt-p do not support set Front camera
        if g_common_obj.adb_cmd_capture_msg("getprop ro.hardware") not in (
                'bxtp_abl', 'gordon_peak'):
            self.multimedia_camera_helper.camera.switchRearOrFront()
        self.multimedia_camera_helper.camera.capturePhoto()
        self.multimedia_camera_helper.camera.reviewPhotoAndVideo()
        print "case " + str(case_name) + " is pass"

    def imageViewCheck(self, case_name):
        print "run case is " + str(case_name)
        self.appPrepare(case_name)
        path = self.video.cfg.get("push_picture").split(" ")[-1].strip("\"")
        print path
        self.multimedia_setting.push_file(self.video.cfg.get("push_picture"),
                                          self.video.cfg.get("datapath"))
        self.launchPhotoAPP()
        self.enterPhotoPath(path)
        self.checkPictureExist(os.path.split(path)[1])
        assert self.d(text=self.video.cfg.get(
            "picture_size")).exists, "Orientation is wrong!"
        print "case " + str(case_name) + " is pass"

    def testImage_Capture_JPEG(self):
        """
        This test used to test Image
        The test case spec is following:
        1. Launch Camera to take pictures.
        """
        self.imageViewCaptureJPEG("test_API_image_003")

    def testImage_Capture_Portrait_Orientation(self):
        """
        This test used to test Image Decode
        The test case spec is following:
        1. Open a picture
        """
        self.imageViewCheck("test_API_image_038")
Пример #14
0
class RefCamCamera(CameraAppInterface, CameraTestBase):
    PACKAGE_NAME_REFCAMCAMERA = "com.intel.refcam"
    ACTIVITY_NAME_REFCAMCAMERA = ".CameraActivity"

    PERMISSION_LIST = [
        "android.permission.ACCESS_FINE_LOCATION", "android.permission.CAMERA",
        "android.permission.WRITE_EXTERNAL_STORAGE",
        "android.permission.READ_EXTERNAL_STORAGE",
        "android.permission.RECORD_AUDIO"
    ]

    def __init__(self, cfg=None):
        if cfg == None:
            self.cfg = self.config.read(CameraCommon.DEFAULT_CONFIG_FILE,
                                        "multimedia_camera")
        else:
            self.cfg = cfg
        self.d = g_common_obj.get_device()
        self.logger = CameraLogger.instance()
        self.x = self.d.info["displayWidth"]
        self.y = self.d.info["displayHeight"]

        self.camera_widget = self.CameraWidget()

        self.camera_common = CameraCommon()
        self.multimedia_setting = MultiMediaSetting(
            self.camera_common.DEFAULT_CONFIG_FILE)
        self.multimedia_setting.install_apk("ref_camera_1_apk")
        self.camera_common.grantPermission(self.PACKAGE_NAME_REFCAMCAMERA,
                                           self.PERMISSION_LIST)

    class CameraWidget:
        def __init__(self):
            self.d = g_common_obj.get_device()

        def frontback(self):
            '''
            front back button
            '''
            return self.d(resourceId="com.intel.refcam:id/switch_frontback")

        def itemChildMenu(self):
            '''
            item clild menu
            '''
            return self.d(
                resourceId="com.intel.refcam:id/setting_item_child_menu_text")

        def seekBar(self):
            '''
            menu seek bar
            '''
            return self.d(
                resourceId="com.intel.refcam:id/setting_item_child_menu_seekbar"
            )

        def shutterBtn(self):
            '''
            shutter button
            '''
            return self.d(resourceId="com.intel.refcam:id/shutter")

        def shotlist(self):
            '''
            front back button
            '''
            return self.d(resourceId="com.intel.refcam:id/open_shot_list")

        def settingsBtn(self):
            '''
            settings
            '''
            return self.d(resourceId="com.intel.refcam:id/setting")

        def text(self, _text):
            '''
            page text
            '''
            return self.d(textContains=_text)

        def itemChildMenuText(self, _text):
            '''
            page text
            '''
            return self.d(
                resourceId="com.intel.refcam:id/setting_item_child_menu_text",
                textContains=_text)

        def zoomLayer(self):
            '''
            zoom layer
            '''
            return self.d(resourceId="com.intel.refcam:id/zoom_layer")

#=============================================================

    def clickScreen(self):
        d = g_common_obj.get_device()
        x = d.info["displayWidth"]
        self.camera_common.clickBtn(x - 100, 300)

    def isShutterBtnExists(self):
        return self.camera_common.isWidgetExists(
            self.camera_widget.shutterBtn())

    def setCaptureMode(self, value):
        self.camera_common.waitForWidgetToAppear(self.camera_widget.shotlist(),
                                                 "mode button")
        self.camera_widget.shotlist().click.wait()
        self.camera_widget.text(value).click.wait()
        self.logger.debug("set capture mode to %s successfully" % value)
        self.camera_common.clickScreenCenter()

#------------------------------------------------------------
# Interfaces' implementations are from here

    def cleanMediaFiles(self):
        """
        Used to clean the media files in some folders; eg. /mnt/sdcard/DCIM/Camera
        """
        self.logger.debug("clean media files start")
        g_common_obj.stop_app_am(self.PACKAGE_NAME_REFCAMCAMERA)
        g_common_obj.adb_cmd("pm clear %s" % self.PACKAGE_NAME_REFCAMCAMERA)
        self.logger.debug("clean media files successfully")

    def startCameraApp(self):
        """
        Used to start the camera application
        """
        self.camera_common.unlockScreen()
        self.logger.debug("launch refcam2 camera start")
        os.system(
            "adb shell am start -S %s/%s" %
            (self.PACKAGE_NAME_REFCAMCAMERA, self.ACTIVITY_NAME_REFCAMCAMERA))
        time_left = 0
        start = time.time()
        success = False
        while time_left < self.camera_common.waitStartAppTime + 15:
            if self.isShutterBtnExists() or self.camera_widget.shotlist(
            ).exists:
                success = True
                break
            if self.camera_widget.text(
                    "Allow").exists or self.camera_widget.text("ALLOW").exists:
                self.camera_common.checkGuide()
                if self.camera_common.getAndroidVersion() == "N":
                    self.stopCameraApp()
                    os.system("adb shell am start -S %s/%s" %
                              (self.PACKAGE_NAME_REFCAMCAMERA,
                               self.ACTIVITY_NAME_REFCAMCAMERA))
            time_left = time.time() - start
            time.sleep(0.5)
            self.camera_common.checkCameraCrash()
        if (not success
            ) or time_left > self.camera_common.waitStartAppTime + 15:
            scname = g_common_obj.get_user_log_dir() + "/assert.png"
            g_common_obj.take_screenshot(scname)
            assert False, "refcam2 camera launch fail,launch time is greater than " \
                        + str(self.camera_common.waitStartAppTime + 15) + " seconds"
        self.logger.debug("launch refcam2 camera successfully")

    def stopCameraApp(self):
        """
        Used to stop the camera application
        """
        g_common_obj.stop_app_am(self.PACKAGE_NAME_REFCAMCAMERA)
        self.logger.debug("stop arcsoft camera app successfully")

    def selectMode(self, mode="Camera"):
        """
        Used to select a mode such as camera, video, panorama, lens blur, photo sphere and so on...
        """
        self.camera_common.waitForWidgetToAppear(
            self.camera_widget.shutterBtn(), "shutter button")
        self.camera_widget.shotlist().click.wait()
        self.camera_widget.text(mode).click.wait()
        self.camera_common.clickScreenCenter()
        self.logger.debug("Change to %s mode" % mode)

    def switchRearOrFront(self, lens="Back"):
        """
        Used to switch rear or front camera
        lens = Back / Front
        """
        self.camera_common.waitForWidgetToAppear(
            self.camera_widget.shutterBtn(), "shutter button")
        if lens == "Front":
            self.camera_widget.frontback().click.wait()
            self.logger.debug("change to " + str(lens) + " camera")
        if lens == "Back" or lens == "Rear":
            self.logger.debug("change to " + str(lens) + " camera")
        time.sleep(2)

    def setExposure(self, value):
        pass

    def setFlash(self, flash="off"):
        """
        Used to control the flash; on, off, auto
        """
        pass

    def setGrid(self, grid="off"):
        """
        Used to control the grid; on, off
        """
        pass

    def setTimer(self, timer="off"):
        """
        Used to control the timer
        value: off/2s/3s/10s
        """
        pass

    def getAllVideoResolutions(self, lens):
        """
        Return all of the video resolutions
        """
        pass

    def setVideoResolution(self, resolution, lens):
        """
        Used to control the video resolution, used with the getAllVideoResolutions
        """
        pass

    def getAllCameraMode(self):
        pass

    def getAllPhotoResolutions(self, lens, type="Capture Size (JPEG)"):
        """
        Return all of the photo resolutions
        """
        self.camera_common.waitForWidgetToAppear(
            self.camera_widget.settingsBtn(), "setting button")
        self.camera_widget.settingsBtn().click.wait()
        if not self.camera_widget.text(type).exists:
            self.d(scrollable=True).scroll.vert.to(textContains=type)
        self.camera_common.waitForWidgetToAppear(self.camera_widget.text(type),
                                                 "capture size button")
        self.camera_widget.text(type).click.wait()
        mCount = self.camera_widget.itemChildMenu().count
        mList = []
        for i in range(mCount):
            mList.append(self.camera_widget.itemChildMenu()[i].info["text"])
        self.clickScreen()
        self.logger.debug("mList=%s" % mList)
        if mList == []:
            self.logger.debug(
                "can't find  photo resolutions with \"%s\" type!" % type)
            return [], -1, -1
        else:
            return mList, mList[0], mList[mCount - 1]

    def setSettingsButton(self, main_click_button, sub_click_button):
        self.camera_common.waitForWidgetToAppear(
            self.camera_widget.settingsBtn(), "setting button")
        self.camera_widget.settingsBtn().click.wait()
        if not self.camera_widget.text(main_click_button).exists:
            self.d(scrollable=True).scroll.vert.to(
                textContains=main_click_button)
        self.camera_common.waitForWidgetToAppear(
            self.camera_widget.text(main_click_button),
            "click main button: %s" % main_click_button)
        self.camera_widget.text(main_click_button).click.wait()
        self.camera_widget.itemChildMenuText(sub_click_button).click.wait()
        self.logger.debug("click sub button: %s" % sub_click_button)
        self.clickScreen()

    def setPhotoResolution(self, resolution, lens, type="Capture Size (JPEG)"):
        """
        Used to control the photo resolution, used with the getAllPhotoResolutions
        """
        self.camera_common.waitForWidgetToAppear(
            self.camera_widget.settingsBtn(), "setting button")
        self.camera_widget.settingsBtn().click.wait()
        if not self.camera_widget.text(type).exists:
            self.d(scrollable=True).scroll.vert.to(textContains=type)
        self.camera_common.waitForWidgetToAppear(self.camera_widget.text(type),
                                                 "capture size button")
        self.camera_widget.text(type).click.wait()
        self.camera_widget.itemChildMenuText(resolution).click.wait()
        self.logger.debug("set resolution to " + resolution)
        self.clickScreen()

    def capturePhoto(self, num=1, generated=True):
        """
        Used to capture num photos
        """
        self.camera_common.waitForWidgetToAppear(
            self.camera_widget.shutterBtn(), "shutter button")
        for i in range(int(num)):
            if self.camera_widget.shutterBtn().exists:
                self.camera_widget.shutterBtn().click.wait()
                self.logger.debug("capture photo %d" % (i + 1))
                if generated:
                    self.camera_common.waitForTheFilesAreGenerated()
                time.sleep(1.5)
            else:
                self.camera_common.checkCameraCrash()

    def reviewPhoto(self, num=1):
        """
        Used to review num photos
        """
        pass

    def reviewPhotoAndVideo(self, num=1, timeout=10):
        """
        Used to review num photos
        """
        pass

    def recordVideo(self, videoNum=1, duration=5):
        """
        Used to capture num duration videos
        """
        pass

    def reviewVideo(self, num=1, duration=1):
        """
        Used to review num duration videos
        """
        pass

    def snapShotDuringVideo(self, videoNum=1, duration=5, snapShotNum=1):
        """
        Used to snapshot num pictures during a duration videos
        """
        pass
Пример #15
0
class VideoPlayBack(TestCaseBase):
    """
    @summary: Test Video PlayBack
    """
    def setUp(self):
        """
        @summary: set up
        @return: None
        """
        super(VideoPlayBack, self).setUp()
        self.d = g_common_obj.get_device()
        self._test_name = __name__
        print "[Setup]: %s" % self._test_name
        g_common_obj.stop_app_am("com.google.android.apps.plus")
        g_common_obj.stop_app_am("com.google.android.apps.photos")
        # Unlock screen
        g_common_obj.adb_cmd_capture_msg("input keyevent 82")

    def tearDown(self):
        """
        @summary: tear tearDown
        @return: None
        """
        super(VideoPlayBack, self).tearDown()
        print "[Teardown]: %s" % self._test_name
        g_common_obj.stop_exp_handle()
        time.sleep(3)

    def appPrepare(self, case_name):
        cfg_file = os.path.join(os.environ.get('TEST_DATA_ROOT', ''), \
            'tests.tablet.mum_auto_video.conf')
        self.video = PhotosImpl(\
            self.config.read(cfg_file, case_name))
        self.file_name = self.video.cfg.get("push_video").split(
            "/")[-1].replace("\"", "")
        self.push_path = self.video.cfg.get("push_video").split(
            "\" \"")[1].replace("\"", "")

        self.multimedia_handle = MultiMediaHandle()
        self.multimedia_setting = MultiMediaSetting(cfg_file)
        self.multimedia_setting.clearFolder(self.video.cfg.get("remove_video"))
        time.sleep(2)
        self.multimedia_setting.push_file(self.video.cfg.get("push_video"),
                                          self.video.cfg.get("datapath"))
        self.video.set_orientation_n()
        # Unlock screen
        g_common_obj.adb_cmd_capture_msg(self.video.cfg.get("refresh_sd"))
        g_common_obj.adb_cmd_capture_msg("input keyevent 82")

    def appPrepare2(self, case_name, model=1):
        cfg_file = os.path.join(os.environ.get('TEST_DATA_ROOT', ''), \
            'tests.tablet.mum_auto_video.conf')
        self.video = PhotosImpl(\
            self.config.read(cfg_file, case_name))

        self.multimedia_handle = MultiMediaHandle()
        self.multimedia_setting = MultiMediaSetting(cfg_file)
        self.multimedia_setting.clearFolder(self.video.cfg.get("remove_video"))
        time.sleep(2)
        if model == 1:
            self.push_path = self.multimedia_setting.push_file(
                self.video.cfg.get("push_video"),
                self.video.cfg.get("datapath"))

        self.multimedia_setting.install_apk("video_apk")
        self.multimedia_setting.install_apk("alarm_apk")
        self.video.set_orientation_n()
        # Unlock screen
        g_common_obj.adb_cmd_capture_msg(self.video.cfg.get("refresh_sd"))
        g_common_obj.adb_cmd_capture_msg("input keyevent 82")

    def videoPlayBack(self, case_name, t_bigfileskiptime=0):
        print "run case is " + str(case_name)
        self.appPrepare2(case_name)
        push_folder = os.path.split(os.path.split(self.push_path)[0])[-1]
        if self.multimedia_setting.get_android_version() == "O":
            self.multimedia_handle.launchVideoApp()
            self.multimedia_handle.videoPlayBack(self.push_path)
            assert self.multimedia_handle.checkVideoPlayBack(
            ), 'video play failed'
        else:
            self.video.launchPhotos(push_folder)
            time.sleep(2)
            self.multimedia_handle.checkVideoPlayBackWithPhotoApp(
                stoptime=self.video.cfg.get("stop_time"),
                bigfileskiptime=t_bigfileskiptime)
        print "case " + str(case_name) + " is pass"

    def testVideoPlayBack(self, case_name):
        MultiMediaBasicTestCase().testVideoPlayBack(case_name)

    def checkVideoPlayBack(self, s=60):
        return self.multimedia_handle.checkVideoPlayBack(s)

    def checkVideoPlayBackWithComparePicture(self,
                                             stoptime,
                                             bigfileskiptime=0):
        return self.multimedia_handle.checkVideoPlayBackWithComparePicture(
            stoptime, bigfileskiptime)

    def checkVideoPlayBackComplete(self, s=900):
        tt = -1
        for _ in range(s / 10):
            time.sleep(10)
            if self.d(textContains="Completed").exists:
                return
            else:
                try:
                    if tt == -1:
                        for _ in range(10):
                            if self.d(resourceId="android:id/time").exists:
                                break
                            self.d.click(self.x / 2, self.y / 2)
                        tt = self.d(resourceId="android:id/time").text
                        tt = self.setTimeToSec(tt)
                    for _ in range(10):
                        if self.d(resourceId="android:id/time_current").exists:
                            break
                        self.d.click(self.x / 2, self.y / 2)
                    ct = self.d(resourceId="android:id/time_current").text
                    ct = self.setTimeToSec(ct)
                except Exception as e:
                    if self.d(textContains="Completed").exists:
                        return
                    else:
                        assert False, e
                if ct == tt:
                    assert not self.d(
                        textContains="error").exists or not self.d(
                            textContains="fail"
                        ).exists, "Play back error! please check it."
                    return

    def setTimeToSec(self, time):
        time = time.split(":")
        i = 1
        temp = 0
        for s in time[::-1]:
            temp += int(s) * i
            i *= 60
        return int(temp)

    def videoPlayBackNoTime(self, case_name):
        print "run case is " + str(case_name)
        self.appPrepare2(case_name)
        push_folder = os.path.split(os.path.split(self.push_path)[0])[-1]
        self.video.launchPhotos(push_folder)
        time.sleep(2)
        #         self.multimedia_handle.launchVideoApp()
        #         self.multimedia_handle.videoPlayBack(self.push_path)
        self.multimedia_handle.checkVideoPlayBackWithPhotoApp(
            stoptime=self.video.cfg.get("stop_time"))
        #         self.video.playback_video_un_QR_code_photoplus(playTime=self.video.cfg.get("wait_time"), stoptime=self.video.cfg.get("stop_time"), flag=True)
        print "case " + str(case_name) + " is pass"

    def testVideoPlayback_3GP_H263_720x450_30fps_no_audio(self):
        """
        This test used to test Video playback
        The test case spec is following:
        1. Launch photos
        2. Play video('H263 Decoder, H263_720x450_30fps_no_audio')
        3. Former name: testVideoPlayBack_001
        """
        self.videoPlayBack("test_video_playback_001")

    def testVideoPlayback_3GP_H264_128_94_25fps_145kbps_AAC_LC_22_05kHz_48kbps_Stereo(
            self):
        """
        This test used to test Video playback
        The test case spec is following:
        1. Launch photos
        2. Play video
        3. Former name: testVideoPlayBack_002
        """
        self.videoPlayBack("test_video_playback_002")

    def testVideoPlayback_MP4_H264_176_144_12_5fps_627kbps_ALAC_44_1kHz_352kbps_Stereo(
            self):
        """
        This test used to test Video playback
        The test case spec is following:
        1. Launch photos
        2. Play video
        3. Former name: testVideoPlayBack_003
        """
        self.videoPlayBack("test_video_playback_003")

    def testVideoPlayBack_004(self):
        """
        This test used to test Video playback
        The test case spec is following:
        1. Launch photos
        2. Play video
        """
        self.videoPlayBack("test_video_playback_004")

    def testVideoPlayBack_005(self):
        """
        This test used to test Video playback
        The test case spec is following:
        1. Launch photos
        2. Play video
        """
        self.videoPlayBack("test_video_playback_005")

    def testVideoPlayBack_006(self):
        """
        This test used to test Video playback
        The test case spec is following:
        1. Launch photos
        2. Play video
        """
        self.videoPlayBack("test_video_playback_006")

    def testVideoPlayBack_007(self):
        """
        This test used to test Video playback
        The test case spec is following:
        1. Launch photos
        2. Play video
        """
        self.videoPlayBack("test_video_playback_007")

    def testVideoPlayBack_008(self):
        """
        This test used to test Video playback
        The test case spec is following:
        1. Launch photos
        2. Play video
        """
        self.videoPlayBack("test_video_playback_008")

    def testVideoPlayback_MP4_H264_320_240_25fps_3566kbps_AAC_Main_48kHz_165kbps_Stereo(
            self):
        """
        This test used to test Video playback
        The test case spec is following:
        1. Launch photos
        2. Play video
        3. Former name: testVideoPlayBack_009
        """
        self.videoPlayBack("test_video_playback_009")

    def testVideoPlayBack_010(self):
        """
        This test used to test Video playback
        The test case spec is following:
        1. Launch photos
        2. Play video
        """
        self.videoPlayBack("test_video_playback_010")

    def testVideoPlayBack_011(self):
        """
        This test used to test Video playback
        The test case spec is following:
        1. Launch photos
        2. Play video
        """
        self.videoPlayBack("test_video_playback_011")

    def testVideoPlayBack_012(self):
        """
        This test used to test Video playback
        The test case spec is following:
        1. Launch photos
        2. Play video
        """
        self.videoPlayBack("test_video_playback_012")

    def testVideoPlayback_MP4_H264_800_600_30fps_1641kbps_AAC_LC_Stereo_44_1kHz_152kbps_Stereo(
            self):
        """
        This test used to test Video playback
        The test case spec is following:
        1. Launch photos
        2. Play video
        3. Former name: testVideoPlayBack_013
        """
        self.videoPlayBack("test_video_playback_013")

    def testVideoPlayback_MP4_L1_0_SP_QCIF_15fps_AACplus_112kbp_32KHz(self):
        """
        This test used to test Video playback
        The test case spec is following:
        1. Launch photos
        2. Play video
        3. Former name: testVideoPlayBack_014
        """
        self.videoPlayBack("test_video_playback_014")

    def testVideoPlayback_MP4_L2_0_SP_QVGA_15fps_eAACplus_96kbp_48KHz(self):
        """
        This test used to test Video playback
        The test case spec is following:
        1. Launch photos
        2. Play video
        3. Former name: testVideoPlayBack_015
        """
        self.videoPlayBack("test_video_playback_015")

    def testVideoPlayBack_016(self):
        """
        This test used to test Video playback
        The test case spec is following:
        1. Launch photos
        2. Play video
        """
        self.videoPlayBack("test_video_playback_016")

    def testVideoPlayback_3GP_MPEG4_SP_480P_30fps_AAC_ELD_48KHz_192kbps(self):
        """
        This test used to test Video playback
        The test case spec is following:
        1. Launch photos
        2. Play video
        3. Former name: testVideoPlayBack_017
        """
        self.videoPlayBack("test_video_playback_017")

    def testVideoPlayback_3GP_MPEG4_SP_720x480_30fps_AMR_NB_8KHz_12_2kbps(
            self):
        """
        This test used to test Video playback
        The test case spec is following:
        1. Launch photos
        2. Play video
        3. Former name: testVideoPlayBack_018
        """
        self.videoPlayBack("test_video_playback_018")

    def testVideoPlayback_MP4_MPEG4_SP_L1_1080_30fps_AACplus_160kbps_48KHz(
            self):
        """
        This test used to test Video playback
        The test case spec is following:
        1. Launch photos
        2. Play video
        3. Former name: testVideoPlayBack_019
        """
        self.videoPlayBack("test_video_playback_019")

    def testVideoPlayBack_020(self):
        """
        This test used to test Video playback
        The test case spec is following:
        1. Launch photos
        2. Play video
        """
        self.videoPlayBack("test_video_playback_020")

    def testVideoPlayback_MP4_H264_L1_3_HP_CIF_30fps_eAACplus_128kb_44KHz(
            self):
        """
        This test used to test Video playback
        The test case spec is following:
        1. Launch photos
        2. Play video
        3. Former name: testVideoPlayBack_021
        """
        self.videoPlayBack("test_video_playback_021")

    def testVideoPlayback_MP4_H264_L3_1_BP_720p_30fps_AAC_96kb_32KHz(self):
        """
        This test used to test Video playback
        The test case spec is following:
        1. Launch photos
        2. Play video
        3. Former name: testVideoPlayBack_022
        """
        self.videoPlayBack("test_video_playback_022")

    def testVideoPlayback_MP4_H264_852_480_30fps_7763kbps_ALAC_44_1kHz_352kbps_Stereo(
            self):
        """
        This test used to test Video playback
        The test case spec is following:
        1. Launch photos
        2. Play video
        3. Former name: testVideoPlayBack_023
        """
        self.videoPlayBack("test_video_playback_023", 20)

    def testVideoPlayBack_024(self):
        """
        This test used to test Video playback
        The test case spec is following:
        1. Launch photos
        2. Play video
        """
        self.videoPlayBack("test_video_playback_024")

    def testVideoPlayback_MP4_H264_L1_0_BP_QCIF_10fps_AAC_64kb_32KHz(self):
        """
        This test used to test Video playback
        The test case spec is following:
        1. Launch photos
        2. Play video
        3. Former name: testVideoPlayBack_025
        """
        self.videoPlayBack("test_video_playback_025")

    def testVideoPlayback_MP4_H264_L2_2_MP_VGA_15fps_AAC_112kb_48K(self):
        """
        This test used to test Video playback
        The test case spec is following:
        1. Launch photos
        2. Play video
        3. Former name: testVideoPlayBack_026
        """
        self.videoPlayBack("test_video_playback_026")

    def testVideoPlayback_MP4_H264_L3_0_HP_D1SD_30fps_eAACplus_128kb_48KHz(
            self):
        """
        This test used to test Video playback
        The test case spec is following:
        1. Launch photos
        2. Play video
        3. Former name: testVideoPlayBack_027
        """
        self.videoPlayBack("test_video_playback_027")

    def testVideoPlayBack_028(self):
        """
        This test used to test Video playback
        The test case spec is following:
        1. Launch photos
        2. Play video
        """
        self.videoPlayBack("test_video_playback_028")

    def testVideoPlayback_TS_H264_BP_720x576_25fps_AACplus_128kbps_22_05KHz(
            self):
        """
        This test used to test Video playback
        The test case spec is following:
        1. Launch photos
        2. Play video
        3. Former name: testVideoPlayBack_029
        """
        self.videoPlayBack("test_video_playback_029")

    def testVideoPlayback_TS_H264_HP_1280x960_51fps_AACplus_192kbps_44_1KHz(
            self):
        """
        This test used to test Video playback
        The test case spec is following:
        1. Launch photos
        2. Play video
        3. Former name: testVideoPlayBack_030
        """
        self.videoPlayBack("test_video_playback_030")

    def testVideoPlayback_TS_H264_HP_1408x1152_38fps_eAACplus_128kbps_48KHz(
            self):
        """
        This test used to test Video playback
        The test case spec is following:
        1. Launch photos
        2. Play video
        3. Former name: testVideoPlayBack_031
        """
        self.videoPlayBack("test_video_playback_031")

    def testVideoPlayback_3GP_H264_HP_L3_2_720P_60fps_AAC_LC_48KHz_320kbps(
            self):
        """
        This test used to test Video playback
        The test case spec is following:
        1. Launch photos
        2. Play video
        3. Former name: testVideoPlayBack_032
        """
        self.videoPlayBack("test_video_playback_032")

    def testVideoPlayback_MKV_VP8_30fps_852_480_AAC_LC_44_1kHz(self):
        """
        This test used to test Video playback
        The test case spec is following:
        1. Launch photos
        2. Play video
        3. Former name: testVideoPlayBack_033
        """
        self.videoPlayBack("test_video_playback_033")

    def testVideoPlayback_MKV_VP8_640x360_25fps_Vorbis_44KHz_128Kbps(self):
        """
        This test used to test Video playback
        The test case spec is following:
        1. Launch photos
        2. Play video
        3. Former name: testVideoPlayBack_034
        """
        self.videoPlayBack("test_video_playback_034")

    def testVideoPlayback_MP4_H264_1920x1080_30fps_24_7Mbps_AAC_352_8Kbps_44_1KHz(
            self):
        """
        This test used to test Video playback
        The test case spec is following:
        1. Launch photos
        2. Play video
        3. Former name: testVideoPlayBack_035
        """
        self.videoPlayBack("test_video_playback_035")

    def testVideoPlayBack_036(self):
        """
        This test used to test Video playback
        The test case spec is following:
        1. Launch photos
        2. Play video
        """
        self.videoPlayBack("test_video_playback_036")

    def testVideoPlayBack_037(self):
        """
        This test used to test Video playback
        The test case spec is following:
        1. Launch photos
        2. Play video
        """
        self.videoPlayBack("test_video_playback_037")

    def testVideoPlayBack_038(self):
        """
        This test used to test Video playback
        The test case spec is following:
        1. Launch photos
        2. Play video
        """
        self.videoPlayBack("test_video_playback_038")

    def testVideoPlayBack_039(self):
        """
        This test used to test Video playback
        The test case spec is following:
        1. Launch photos
        2. Play video
        """
        self.videoPlayBack("test_video_playback_039")

    def testVideoPlayback_MP4_MPEG4_800_600_30fps_2075kbps_AAC_LC_48kHz_165kbps_Stereo(
            self):
        """
        This test used to test Video playback
        The test case spec is following:
        1. Launch photos
        2. Play video
        3. Former name: testVideoPlayBack_040
        """
        self.videoPlayBack("test_video_playback_040")

    def testVideoPlayBack_041(self):
        """
        This test used to test Video playback
        The test case spec is following:
        1. Launch photos
        2. Play video
        """
        self.videoPlayBack("test_video_playback_041")

    def testVideoPlayback_WEBM_VP8_QCIF_25fps_Vorbis_44_1KHz_128kbps(self):
        """
        This test used to test Video playback
        The test case spec is following:
        1. Launch photos
        2. Play video
        3. Former name: testVideoPlayBack_042
        """
        self.videoPlayBack("test_video_playback_042")

    def testVideoPlayBack_043(self):
        """
        This test used to test Video playback
        The test case spec is following:
        1. Launch photos
        2. Play video
        """
        self.videoPlayBack("test_video_playback_043")

    def testVideoPlayBack_044(self):
        """
        This test used to test Video playback
        The test case spec is following:
        1. Launch photos
        2. Play video
        """
        self.videoPlayBack("test_video_playback_044")

    def testVideoPlayBack_045(self):
        """
        This test used to test Video playback
        The test case spec is following:
        1. Launch photos
        2. Play video
        """
        self.videoPlayBack("test_video_playback_045")

    def testVideoPlayback_WEBM_VP9_936Kbps_640x360_30fps_vorbis_224kbps_48khz_2channel(
            self):
        """
        This test used to test Video playback
        The test case spec is following:
        1. Launch photos
        2. Play video
        3. Former name: testVideoPlayBack_046
        """
        self.videoPlayBack("test_video_playback_046")

    def testVideoPlayback_MP4_H264_BP_1080P_24fps_25Mbps_AAC_ELD_48KHz_192kbps(
            self):
        """
        This test used to test Video playback
        The test case spec is following:
        1. Launch photos
        2. Play video
        3. Former name: testVideoPlayBack_047
        """
        self.videoPlayBack("test_video_playback_047")

    def testVideoPlayBack_048(self):
        """
        This test used to test Video playback
        The test case spec is following:
        1. Launch photos
        2. Play video
        """
        self.videoPlayBack("test_video_playback_048")

    def testVideoPlayBack_049(self):
        """
        This test used to test Video playback
        The test case spec is following:
        1. Launch photos
        2. Play video
        """
        self.videoPlayBack("test_video_playback_049")

    def testVideoPlayback_MP4_H264_L3_1_HP_720p_30fps_AAC_160kb_48KHz(self):
        """
        This test used to test Video playback
        The test case spec is following:
        1. Launch photos
        2. Play video
        3. Former name: testVideoPlayBack_050
        """
        self.videoPlayBack("test_video_playback_050")

    def testVideoPlayback_3GP_H263_Decoder_Level_30_CIF_352_288_30fps_384_Kbs(
            self):
        """
        This test used to test Video playback
        The test case spec is following:
        1. Launch photos
        2. Play video
        3. Former name: testVideoPlayBack_051
        """
        self.videoPlayBack("test_video_playback_051")

    def testVideoPlayback_3GP_H263_Level_40_0_None_352_288_30_0fps_2048kbps_aac_stereo_48khz_192kbps(
            self):
        """
        This test used to test Video playback
        The test case spec is following:
        1. Launch photos
        2. Play video
        3. Former name: testVideoPlayBack_052
        """
        self.videoPlayBack("test_video_playback_052")

    def testVideoPlayback_WEBM_VP8_CIF_25fps_Vorbis_44_1KHz_128kbps(self):
        """
        This test used to test Video playback
        The test case spec is following:
        1. Launch photos
        2. Play video
        3. Former name: testVideoPlayBack_053
        """
        self.videoPlayBack("test_video_playback_053")

    def testVideoPlayback_MP4_H264_L4_1_HP_720p_30fps_eAACplus_128kb_48KHz(
            self):
        """
        This test used to test Video playback
        The test case spec is following:
        1. Launch photos
        2. Play video
        3. Former name: testVideoPlayBack_054
        """
        self.videoPlayBack("test_video_playback_054")

    def testVideoPlayBack_055(self):
        """
        This test used to test Video playback
        The test case spec is following:
        1. Launch photos
        2. Play video
        """
        self.videoPlayBack("test_video_playback_055")

    def testVideoPlayBack_056(self):
        """
        This test used to test Video playback
        The test case spec is following:
        1. Launch photos
        2. Play video
        """
        self.videoPlayBack("test_video_playback_056")

    def testVideoPlayback_MP4_H264_Primary_Output_Video_Playback_Content_QVGA_15_fps(
            self):
        """
        This test used to test Video playback
        The test case spec is following:
        1. Launch photos
        2. Play video
        3. Former name: testVideoPlayBack_057
        """
        self.videoPlayBack("test_video_playback_057")

    def testVideoPlayBack_058(self):
        """
        This test used to test Video playback
        The test case spec is following:
        1. Launch photos
        2. Play video
        """
        self.videoPlayBack("test_video_playback_058")

    def testVideoPlayBack_059(self):
        """
        This test used to test Video playback
        The test case spec is following:
        1. Launch photos
        2. Play video
        """
        self.videoPlayBack("test_video_playback_059")

    def testVideoPlayBack_060(self):
        """
        This test used to test Video playback
        The test case spec is following:
        1. Launch photos
        2. Play video
        """
        self.videoPlayBack("test_video_playback_060")

    def testVideoPlayBack_061(self):
        """
        This test used to test Video playback
        The test case spec is following:
        1. Launch photos
        2. Play video
        """
        self.videoPlayBack("test_video_playback_061")

    def testVideoPlayBack_062(self):
        """
        This test used to test Video playback
        The test case spec is following:
        1. Launch photos
        2. Play video
        """
        self.videoPlayBack("test_video_playback_062")

    def testVideoPlayBack_063(self):
        """
        This test used to test Video playback
        The test case spec is following:
        1. Launch photos
        2. Play video
        """
        self.videoPlayBack("test_video_playback_063")

    def testVideoPlayBack_064(self):
        """
        This test used to test Video playback
        The test case spec is following:
        1. Launch photos
        2. Play video
        """
        self.videoPlayBack("test_video_playback_064")

    def testVideoPlayBack_065(self):
        """
        This test used to test Video playback
        The test case spec is following:
        1. Launch photos
        2. Play video
        """
        self.videoPlayBack("test_video_playback_065")

    def testVideoPlayBack_066(self):
        """
        This test used to test Video playback
        The test case spec is following:
        1. Launch photos
        2. Play video
        """
        self.videoPlayBack("test_video_playback_066")

    def testVideoPlayBack_067(self):
        """
        This test used to test Video playback
        The test case spec is following:
        1. Launch photos
        2. Play video
        """
        self.videoPlayBack("test_video_playback_067")

    def testVideoPlayBack_068(self):
        """
        This test used to test Video playback
        The test case spec is following:
        1. Launch photos
        2. Play video
        """
        self.videoPlayBack("test_video_playback_068")

    def testVideoPlayBack_069(self):
        """
        This test used to test Video playback
        The test case spec is following:
        1. Launch photos
        2. Play video
        """
        self.videoPlayBack("test_video_playback_069")

    def testVideoPlayBack_070(self):
        """
        This test used to test Video playback
        The test case spec is following:
        1. Launch photos
        2. Play video
        """
        self.videoPlayBack("test_video_playback_070")

    def testVideoPlayBack_071(self):
        """
        This test used to test Video playback
        The test case spec is following:
        1. Launch photos
        2. Play video
        """
        self.videoPlayBack("test_video_playback_071")

    def testVideoPlayBack_072(self):
        """
        This test used to test Video playback
        The test case spec is following:
        1. Launch photos
        2. Play video
        """
        self.videoPlayBack("test_video_playback_072")

    def testVideoPlayBack_073(self):
        """
        This test used to test Video playback
        The test case spec is following:
        1. Launch photos
        2. Play video
        """
        self.videoPlayBack("test_video_playback_073")

    def testVideoPlayBack_074(self):
        """
        This test used to test Video playback
        The test case spec is following:
        1. Launch photos
        2. Play video
        """
        self.videoPlayBack("test_video_playback_074")

    def testVideoPlayBack_075(self):
        """
        This test used to test Video playback
        The test case spec is following:
        1. Launch photos
        2. Play video
        """
        self.videoPlayBack("test_video_playback_075")

    def testVideoPlayBack_076(self):
        """
        This test used to test Video playback
        The test case spec is following:
        1. Launch photos
        2. Play video
        """
        self.videoPlayBack("test_video_playback_076")

    def testVideoPlayBack_077(self):
        """
        This test used to test Video playback
        The test case spec is following:
        1. Launch photos
        2. Play video
        """
        self.videoPlayBack("test_video_playback_077")

    def testVideoPlayBack_078(self):
        """
        This test used to test Video playback
        The test case spec is following:
        1. Launch photos
        2. Play video
        """
        self.videoPlayBack("test_video_playback_078")

    def testVideoPlayBack_079(self):
        """
        This test used to test Video playback
        The test case spec is following:
        1. Launch photos
        2. Play video
        """
        self.videoPlayBack("test_video_playback_079")

    def testVideoPlayBack_080(self):
        """
        This test used to test Video playback
        The test case spec is following:
        1. Launch photos
        2. Play video
        """
        self.videoPlayBack("test_video_playback_080")

    def testVideoPlayBack_081(self):
        """
        This test used to test Video playback
        The test case spec is following:
        1. Launch photos
        2. Play video
        """
        self.videoPlayBack("test_video_playback_081")

    def testVideoPlayBack_082(self):
        """
        This test used to test Video playback
        The test case spec is following:
        1. Launch photos
        2. Play video
        """
        self.videoPlayBack("test_video_playback_082")

    def testVideoPlayBack_083(self):
        """
        This test used to test Video playback
        The test case spec is following:
        1. Launch photos
        2. Play video
        """
        self.videoPlayBack("test_video_playback_083")

    def testVideoPlayBack_084(self):
        """
        This test used to test Video playback
        The test case spec is following:
        1. Launch photos
        2. Play video
        """
        self.videoPlayBack("test_video_playback_084")

    def testVideoPlayBack_085(self):
        """
        This test used to test Video playback
        The test case spec is following:
        1. Launch photos
        2. Play video
        """
        self.videoPlayBack("test_video_playback_085")

    def testVideoPlayBack_086(self):
        """
        This test used to test Video playback
        The test case spec is following:
        1. Launch photos
        2. Play video
        """
        self.videoPlayBack("test_video_playback_086")

    def testVideoPlayBack_087(self):
        """
        This test used to test Video playback
        The test case spec is following:
        1. Launch photos
        2. Play video
        """
        self.videoPlayBack("test_video_playback_087")

    def testVideoPlayBack_088(self):
        """
        This test used to test Video playback
        The test case spec is following:
        1. Launch photos
        2. Play video
        """
        self.videoPlayBack("test_video_playback_088")

    def testVideoPlayBack_089(self):
        """
        This test used to test Video playback
        The test case spec is following:
        1. Launch photos
        2. Play video
        """
        self.videoPlayBack("test_video_playback_089")

    def testVideoPlayBack_090(self):
        """
        This test used to test Video playback
        The test case spec is following:
        1. Launch photos
        2. Play video
        """
        self.videoPlayBack("test_video_playback_090")

    def testVideoPlayBack_091(self):
        """
        This test used to test Video playback
        The test case spec is following:
        1. Launch photos
        2. Play video
        """
        self.videoPlayBack("test_video_playback_091")

    def testVideoPlayBack_092(self):
        """
        This test used to test Video playback
        The test case spec is following:
        1. Launch photos
        2. Play video
        """
        self.videoPlayBack("test_video_playback_092")

    def testVideoPlayBack_093(self):
        """
        This test used to test Video playback
        The test case spec is following:
        1. Launch photos
        2. Play video
        """
        self.videoPlayBack("test_video_playback_093")

    def testVideoPlayBack_094(self):
        """
        This test used to test Video playback
        The test case spec is following:
        1. Launch photos
        2. Play video
        """
        self.videoPlayBack("test_video_playback_094")

    def testVideoPlayBack_095(self):
        """
        This test used to test Video playback
        The test case spec is following:
        1. Launch photos
        2. Play video
        """
        self.videoPlayBack("test_video_playback_095")

    def testVideoPlayBack_096(self):
        """
        This test used to test Video playback
        The test case spec is following:
        1. Launch photos
        2. Play video
        """
        self.videoPlayBack("test_video_playback_096")

    def testVideoPlayBack_097(self):
        """
        This test used to test Video playback
        The test case spec is following:
        1. Launch photos
        2. Play video
        """
        self.videoPlayBack("test_video_playback_097")

    def testVideoPlayBack_098(self):
        """
        This test used to test Video playback
        The test case spec is following:
        1. Launch photos
        2. Play video
        """
        self.videoPlayBack("test_video_playback_098")

    def testVideoPlayBack_099(self):
        """
        This test used to test Video playback
        The test case spec is following:
        1. Launch photos
        2. Play video
        """
        self.videoPlayBack("test_video_playback_099")

    def testVideoPlayBack_100(self):
        """
        This test used to test Video playback
        The test case spec is following:
        1. Launch photos
        2. Play video
        """
        self.videoPlayBack("test_video_playback_100")

    def testVideoPlayBack_101(self):
        """
        This test used to test Video playback
        The test case spec is following:
        1. Launch photos
        2. Play video
        """
        self.videoPlayBack("test_video_playback_101")

    def testVideoPlayBack_102(self):
        """
        This test used to test Video playback
        The test case spec is following:
        1. Launch photos
        2. Play video
        """
        self.videoPlayBack("test_video_playback_102")

    def testVideoPlayBack_103(self):
        """
        This test used to test Video playback
        The test case spec is following:
        1. Launch photos
        2. Play video
        """
        self.videoPlayBack("test_video_playback_103")

    def testVideoPlayBack_104(self):
        """
        This test used to test Video playback
        The test case spec is following:
        1. Launch photos
        2. Play video
        """
        self.videoPlayBack("test_video_playback_104")

    def testVideoPlayBack_105(self):
        """
        This test used to test Video playback
        The test case spec is following:
        1. Launch photos
        2. Play video
        """
        self.videoPlayBack("test_video_playback_105")

    def testVideoPlayBack_106(self):
        """
        This test used to test Video playback
        The test case spec is following:
        1. Launch photos
        2. Play video
        """
        self.videoPlayBack("test_video_playback_106")

    def testVideoPlayBack_107(self):
        """
        This test used to test Video playback
        The test case spec is following:
        1. Launch photos
        2. Play video
        """
        self.videoPlayBack("test_video_playback_107")

    def testVideoPlayBack_108(self):
        """
        This test used to test Video playback
        The test case spec is following:
        1. Launch photos
        2. Play video
        """
        self.videoPlayBack("test_video_playback_108")

    def testVideoPlayBack_109(self):
        """
        This test used to test Video playback
        The test case spec is following:
        1. Launch photos
        2. Play video
        """
        self.videoPlayBack("test_video_playback_109")

    def testVideoPlayback_MKV_MPEG4_ASP_720P_30fps_4_5Mbps_AAC_128kbps_32KHz(
            self):
        """
        This test used to test Video playback
        The test case spec is following:
        1. Launch photos
        2. Play video
        """
        self.videoPlayBack("mum_test_video_playback_047")

    def testMPEG4_352_288_24fps_144kbps_aaclc_22_05kHz_38kbps_Mono_3GP(self):
        """
        This test used to test Video playback
        The test case spec is following:
        1. Launch play video app
        2. Play video
        """
        self.testVideoPlayBack("test_API_video_playback_008")

    def testMPEG4_part_2_SP_Simple_Profile_Level3_CIF_352x288_30fps_NO_audio(
            self):
        """
        This test used to test Video playback
        The test case spec is following:
        1. Launch play video app
        2. Play video
        """
        self.testVideoPlayBack("test_API_video_playback_009")

    def testVideo_Playback_Mp3_Mkv(self):
        """
        This test used to test Video playback
        The test case spec is following:
        1. Launch play video app
        2. Play video
        """
        self.testVideoPlayBack("test_video_playback_110")

    def testVideo_Playback_HEAAC_V2_Mp4(self):
        """
        This test used to test Video playback
        The test case spec is following:
        1. Launch play video app
        2. Play video
        """
        self.testVideoPlayBack("test_video_playback_111")
Пример #16
0
class VideoPlayBack(TestCaseBase):
    """
    @summary: Test Video PlayBack
    """
    def setUp(self):
        """
        @summary: set up
        @return: None
        """
        super(VideoPlayBack, self).setUp()
        self.d = g_common_obj.get_device()
        self._test_name = __name__
        print "[Setup]: %s" % self._test_name
        g_common_obj.stop_app_am("com.google.android.apps.plus")
        g_common_obj.stop_app_am("com.google.android.apps.photos")
        # Unlock screen
        g_common_obj.adb_cmd_capture_msg("input keyevent 82")

    def tearDown(self):
        """
        @summary: tear tearDown
        @return: None
        """
        super(VideoPlayBack, self).tearDown()
        print "[Teardown]: %s" % self._test_name
        g_common_obj.stop_exp_handle()
        time.sleep(3)

    def appPrepare2(self, case_name, model=1):
        cfg_file = os.path.join(os.environ.get('TEST_DATA_ROOT', ''),
                                'tests.tablet.mum_auto_video.conf')
        self.video = PhotosImpl(self.config.read(cfg_file, case_name))

        self.multimedia_handle = MultiMediaHandle()
        self.multimedia_setting = MultiMediaSetting(cfg_file)
        self.multimedia_setting.clearFolder(self.video.cfg.get("remove_video"))
        time.sleep(2)
        if model == 1:
            self.push_path = self.multimedia_setting.push_file(
                self.video.cfg.get("push_video"),
                self.video.cfg.get("datapath"))

        self.multimedia_setting.install_apk("video_apk")
        self.multimedia_setting.install_apk("alarm_apk")
        self.video.set_orientation_n()
        # Unlock screen
        g_common_obj.adb_cmd_capture_msg(self.video.cfg.get("refresh_sd"))
        g_common_obj.adb_cmd_capture_msg("input keyevent 82")

    def videoPlayBack(self, case_name, t_bigfileskiptime=0):
        print "run case is " + str(case_name)
        self.appPrepare2(case_name)
        push_folder = os.path.split(os.path.split(self.push_path)[0])[-1]
        if self.multimedia_setting.get_android_version() == "O":
            self.multimedia_handle.launchVideoApp()
            self.multimedia_handle.videoPlayBack(self.push_path)
            assert self.multimedia_handle.checkVideoPlayBack(
            ), 'video play failed'
        else:
            self.video.launchPhotos(push_folder)
            time.sleep(2)
            self.multimedia_handle.checkVideoPlayBackWithPhotoApp(
                stoptime=self.video.cfg.get("stop_time"),
                bigfileskiptime=t_bigfileskiptime)
        print "case " + str(case_name) + " is pass"

    def testVideoPlayBack(self, case_name):
        MultiMediaBasicTestCase().testVideoPlayBack(case_name)

    def checkVideoPlayBack(self, s=60):
        return self.multimedia_handle.checkVideoPlayBack(s)

    def testMPEG4_352_288_24fps_144kbps_aaclc_22_05kHz_38kbps_Mono_3GP(self):
        """
        This test used to test Video playback
        The test case spec is following:
        1. Launch play video app
        2. Play video
        """
        self.testVideoPlayBack("test_API_video_playback_008")

    def testVideoPlayback_MKV_VP8_640x360_25fps_Vorbis_44KHz_128Kbps(self):
        """
        This test used to test Video playback
        The test case spec is following:
        1. Launch photos
        2. Play video
        3. Former name: testVideoPlayBack_034
        """
        self.videoPlayBack("test_video_playback_034")

    def testPlayback_H264_HP_1080P_60fps_50Mbps_AAC_LC_48KHz_320Kbps_mp4(self):
        """
        This test used to test Video playback
        The test case spec is following:
        1. Launch play video app
        2. Play video
        """
        self.videoPlayBack("test_API_video_playback_035")
Пример #17
0
class ImageAPITest(TestCaseBase):
    """
    @summary: Test Video PlayBack
    """
    def setUp(self):
        """
        @summary: set up
        @return: None
        """
        super(ImageAPITest, self).setUp()
        self.d = g_common_obj.get_device()
        self._test_name = __name__
        self.x = self.d.info["displayWidth"]
        self.y = self.d.info["displayHeight"]
        self.dpx = self.d.info["displaySizeDpX"]
        self.dpy = self.d.info["displaySizeDpY"]
        self.tag = "[Image Decode image_api_test] "
        self.serial = self.d.server.adb.device_serial()
        logger.debug(self.tag + "[Setup]: %s" % self._test_name)
        g_common_obj.stop_app_am("com.intel.otc.instrument.otcphotos")
        # Unlock screen
        g_common_obj.adb_cmd_capture_msg("input keyevent 82")

    def tearDown(self):
        """
        @summary: tear tearDown
        @return: None
        """
        super(ImageAPITest, self).tearDown()
        print "[Teardown]: %s" % self._test_name
        g_common_obj.stop_exp_handle()
        time.sleep(3)
        g_common_obj.stop_app_am("com.intel.otc.instrument.otcphotos")
        time.sleep(1)
        g_common_obj.adb_cmd_capture_msg(self.video.cfg.get("remove_video"))

    def setTimeToSec(self, time):
        time = time.split(":")
        i = 1
        temp = 0
        for s in time[::-1]:
            temp += int(s) * i
            i *= 60
        return int(temp)

    def getOrientation(self):
        d = self.get_device()
        width = d.info["displayWidth"]
        height = d.info["displayHeight"]
        if width > height:
            return 1
        else:
            return 0

    def appPrepare(self, case_name, model=1):
        cfg_file = os.path.join(os.environ.get('TEST_DATA_ROOT', ''), \
            'tests.tablet.mum_auto_image.conf')
        self.video = PhotosImpl(\
            self.config.read(cfg_file, case_name))

        self.multimedia_handle = MultiMediaHandle()
        self.multimedia_setting = MultiMediaSetting(cfg_file)
        self.multimedia_setting.install_apk("photo_apk")
        self.multimedia_setting.install_apk("alarm_apk")
        self.video.set_orientation_n()
        if self.video.cfg.get("push_picture") is not None:
            self.multimedia_setting.push_file(
                self.video.cfg.get("push_picture"),
                self.video.cfg.get("datapath"))
        refresh_sd_cmd = self.config.read(cfg_file, 'common_cmd')['refresh_sd']
        g_common_obj.adb_cmd_capture_msg(refresh_sd_cmd)
        # Unlock screen
        g_common_obj.adb_cmd_capture_msg("input keyevent 82")

    def launchPhotoAPP(self):
        logger.debug(self.tag + "launch otcphotos app")
        SystemUI().unlock_screen()
        for _ in range(3):
            g_common_obj.launch_app_am("com.intel.otc.instrument.otcphotos", \
                                   "com.intel.otc.instrument.otcphotos.MainActivity")
            time.sleep(3)
            if self.d(textContains="/").exists:
                return
        assert self.d(textContains="/").exists, "launch photo app failed!"

    def checkPhotosBackupAndHandle(self):
        """
        check 'back up & sync' exist and handle it
        :return:
        """
        for _ in range(3):
            if self.d(textContains="Update Google Photos").exists:
                logger.debug("Ignore update google photos")
                self.d(textMatches="NOT NOW").click()
            time.sleep(1)
            if self.d(resourceId=
                      'com.android.packageinstaller:id/permission_allow_button'
                      ).exists:
                self.d(
                    resourceId=
                    'com.android.packageinstaller:id/permission_allow_button'
                ).click()
                time.sleep(1)
            if self.d(textContains='Google Photos uses face').exists and \
                    self.d(textMatches='[O|o][N|n]').exists:
                logger.debug("back up & sync display, try to init photos")
                x = self.d.info['displayHeight'] / 2
                y = self.d.info['displayWidth'] / 2
                self.d.click(x, y)
            if self.d(textContains="Keep backup off").exists:
                self.d(textMatches="Keep off|KEEP OFF").click()
            if self.d(textStartsWith="Never show").exists:
                self.d(textStartsWith="Never show").click()
            if self.d(textMatches="SKIP|Skip").exists:
                self.d(textMatches="SKIP|Skip").click()
            if self.d(textMatches="CANCEL|Cancel").exists:
                self.d(textMatches="CANCEL|Cancel").click()
            if self.d(description="Photos, selected, tab, 2 of 3").exists or\
                                self.d(resourceId="com.google.android.apps.photos:id/toolbar").exists:
                logger.debug("init completed")
                break

    def launchPhotoAPPWithShortCut(self):
        logger.debug(self.tag + "Launch Photos")
        self.d.press.home()
        if self.get_android_version() == "7.1.1":
            logger.debug("DUT android version is 7.1.1")
            self.d(description="Apps list").click()
        elif self.get_android_version() < "7.1.1":
            logger.debug("DUT android version is beloww 7.1.1")
            if self.d(text="GOT IT").exists:
                self.d(text="GOT IT").click()
            self.d(description="Apps").click()
        elif self.multimedia_setting.get_paltform_hardware() == 'androidia_64':
            logger.debug("For AIA, Photos in Google folder")
            self.d(description="Folder: Google").click()
            self.d(description="Photos").click()
            self.checkPhotosBackupAndHandle()
            assert self.d(
                resourceId="com.google.android.apps.photos:id/toolbar"
            ).exists, "launch photo app failed!"
            return True
        #for N build,firstly go into apps list,skip the tips
        for _ in range(3):
            if self.d(textContains="Choose some apps").exists:
                self.d(text="OK").click()
        assert not self.d(text="OK").exists, "skip the tips failed!"
        while not self.d(text="otcphoto-app").exists:
            self.d(className="android.view.View").swipe.left()
        self.d(text="otcphoto-app").click()
        time.sleep(3)
        assert self.d(textContains="/").exists, "launch photo app failed!"

    def launchGalleryAPPWithShortCut(self):
        # for bxtp o car, launch Gallery
        self.d.press.home()
        app_list_cmd = "adb -s %s shell input tap '%d' '%d'" % (
            self.serial, int(self.dpx * 0.78), int(self.dpy * 0.97))
        print app_list_cmd
        for _ in range(3):
            os.system(app_list_cmd)
            if self.d(resourceId=
                      "com.android.support.car.lenspicker:id/dismiss_area"
                      ).wait.exists(timeout=3000):
                try:
                    self.d(resourceId=
                           "com.android.support.car.lenspicker:id/dismiss_area"
                           ).scroll.vert.to(text='Gallery')
                except:
                    self.d.swipe(self.x / 2, self.y * 0.75, self.x / 2,
                                 self.y * 0.25)
                self.d(text="Gallery").click()
                if self.d(resourceId="com.android.gallery3d:id/gl_root_view"
                          ).wait.exists(timeout=3000):
                    logger.debug("Launch Gallery success!")
                    return True
        logger.debug("Launch Gallery Failed!")
        return False

    def get_android_version(self):

        prop = "ro.build.version.release"
        buf = g_common_obj.adb_cmd_capture_msg("getprop " + prop)
        v_str = buf.strip()
        return v_str

    def wait_boot_completed(self, timeout=1000):
        ''' wait Android boot_completed
    
        args: timeout -- optional timeout in second, default 180s
        '''
        count = 0
        sleep_time = 5
        while count < timeout:
            prop_val = adb.adb_cmd_capture_msg('getprop sys.boot_completed')
            if '1' in prop_val:
                print 'boot_completed'
                return
            count += sleep_time
            time.sleep(sleep_time)
        raise Exception('%ds timeout waiting for boot_completed' % timeout)

    def enterPhotoPath(self, path):
        logger.debug(self.tag + "enter picture path :" + path)
        push_str = path.strip("\"").split("/")
        if push_str[0] == "" and push_str[1] == "sdcard":
            push_str = push_str[2:]
        for t_str in push_str:
            logger.debug(self.tag + "try to click %s" % t_str)
            if t_str != "":
                self.d(text=t_str).click()
                time.sleep(2)

    def checkPictureExist(self, file_name):
        logger.debug(self.tag + "check picture exist, filename:" + file_name)
        if self.d(text=file_name).exists:
            logger.debug(self.tag + file_name + " found!")
            return True
        else:
            logger.debug(self.tag + file_name + " not find!")
            return False

    def openPictureWithGallery(self, file):
        print file
        open_picture_cmd = "shell am start -a android.intent.action.VIEW -d file://%s " \
                   " -t image/* -n com.android.gallery3d/.app.GalleryActivity" % (file)
        for _ in range(3):
            g_common_obj.adb_cmd_common(open_picture_cmd)
            time.sleep(1)
            if self.d(resourceId=
                      "com.android.gallery3d:id/photopage_bottom_controls"):
                return True
        logger.debug(self.tag + "open %s failed" % file)
        return False

    def openPictureWithPhotosCmd(self, file):
        logger.debug("Try to open %s with command" % file)
        open_picture_cmd = "shell am start -a android.intent.action.VIEW -d file://%s " \
                           " -t image/* -n com.google.android.apps.photos/.pager.HostPhotoPagerActivity" % (file)
        for _ in range(3):
            g_common_obj.adb_cmd_common(open_picture_cmd)
            time.sleep(1)
            if self.d(
                    resourceId=
                    "com.google.android.apps.photos:id/video_player_controller_fragment_container"
            ):
                logger.debug(self.tag + 'Open picture success.')
                return True
        logger.debug(self.tag + "open %s failed" % file)
        return False

    def getPictureSize(self):
        scaleLabel = self.d(
            resourceId="com.intel.otc.instrument.otcphotos:id/scaleLabel"
        ).info["text"]
        return int(scaleLabel.strip("%"))

    def checkVideoPlayBack(self, s=60):
        return self.multimedia_handle.checkVideoPlayBack(s)

    def imageViewRotatePicture(self, case_name):
        print "run case is " + str(case_name)
        self.appPrepare(case_name)
        path = self.video.cfg.get("push_picture").split(" ")[-1].strip("\"")
        print path
        self.launchPhotoAPP()
        self.enterPhotoPath(path)
        self.checkPictureExist(os.path.split(path)[1])
        self.d.orientation = "n"
        time.sleep(2)
        self.checkPictureExist(os.path.split(path)[1])
        self.video.set_orientation_n()
        time.sleep(2)
        self.checkPictureExist(os.path.split(path)[1])
        print "case " + str(case_name) + " is pass"

    def imageViewRotatePictureManyTimes(self, case_name, count):
        print "run case is " + str(case_name)
        self.appPrepare(case_name)
        path = self.video.cfg.get("push_picture").split(" ")[-1].strip("\"")
        print path
        self.launchPhotoAPP()
        self.enterPhotoPath(path)
        self.checkPictureExist(os.path.split(path)[1])
        for _ in range(count):
            self.d.orientation = "n"
            time.sleep(2)
            self.checkPictureExist(os.path.split(path)[1])
            self.video.set_orientation_n()
            time.sleep(2)
            self.checkPictureExist(os.path.split(path)[1])
        print "case " + str(case_name) + " is pass"

    def imageViewCheck(self, case_name):
        print "run case is " + str(case_name)
        self.appPrepare(case_name)
        path = self.video.cfg.get("push_picture").split(" ")[-1].strip("\"")
        print path
        self.launchPhotoAPP()
        self.enterPhotoPath(path)
        self.checkPictureExist(os.path.split(path)[1])
        print "case " + str(case_name) + " is pass"

    def imageViewCheckAfterDeleteFile(self, case_name):
        print "run case is " + str(case_name)
        self.appPrepare(case_name)
        path = self.video.cfg.get("push_picture").split(" ")[-1].strip("\"")
        print path
        self.launchPhotoAPP()
        self.enterPhotoPath(path)
        file_name = os.path.split(path)[1]
        self.checkPictureExist(file_name)
        self.multimedia_setting.clearFolder(self.video.cfg.get("remove_video"))
        time.sleep(2)
        self.d.press.back()
        self.d(text=file_name).click()
        assert not self.d(
            resourceId='com.intel.otc.instrument.otcphotos:id/sizeLabel'
        ).exists, "no warning messsage pop up"
        for _ in range(3):
            self.d.press.back()
        print "case " + str(case_name) + " is pass"

    def imageViewCheckWithUnlock(self, case_name):
        print "run case is " + str(case_name)
        self.appPrepare(case_name)
        path = self.video.cfg.get("push_picture").split(" ")[-1].strip("\"")
        print path
        self.launchPhotoAPP()
        self.enterPhotoPath(path)
        self.checkPictureExist(os.path.split(path)[1])
        if 'bxtp_abl' in self.multimedia_setting.get_paltform_hardware():
            #  For BXT use relay card press power to sleep
            self.multimedia_setting.pressPowerKey()
            time.sleep(10)
            self.multimedia_setting.pressPowerKey()
        else:
            self.d.press.power()
            time.sleep(2)
            self.d.press.power()
        self.lock = SystemUI()
        self.lock.unlock_screen()
        time.sleep(1)
        self.checkPictureExist(os.path.split(path)[1])
        print "case " + str(case_name) + " is pass"

    def imageViewCheckWithRotation(self, case_name):
        print "run case is " + str(case_name)
        self.appPrepare(case_name)
        path = self.video.cfg.get("push_picture").split(" ")[-1].strip("\"")
        print path
        self.launchPhotoAPP()
        self.d.orientation = "n"
        self.d.press.home()
        self.multimedia_setting.click_recent_app("otcphoto-app")
        time.sleep(1)
        assert self.d(textContains="/").exists, "launch photo app failed!"
        self.multimedia_setting.launchAlarmAPP()
        self.video.set_orientation_n()
        self.multimedia_setting.click_recent_app("otcphoto-app")
        time.sleep(1)
        assert self.d(textContains="/").exists, "launch photo app failed!"
        self.enterPhotoPath(path)
        self.checkPictureExist(os.path.split(path)[1])
        print "case " + str(case_name) + " is pass"

    def imageViewCheckWithInstallApp(self, case_name, flag=1):
        print "run case is " + str(case_name)
        self.appPrepare(case_name)
        path = self.video.cfg.get("push_picture").split(" ")[-1].strip("\"")
        print path
        if flag != 1:
            self.multimedia_setting.push_file(
                self.video.cfg.get("push_picture_2"),
                self.video.cfg.get("datapath"))
        self.launchPhotoAPP()
        self.enterPhotoPath(path)
        self.multimedia_setting.install_apk("video_apk")
        self.checkPictureExist(os.path.split(path)[1])
        if flag != 1:
            self.d(className="android.widget.ImageView").swipe.left()
            path_2 = self.video.cfg.get("push_picture_2").split(" ")[-1].strip(
                "\"")
            self.checkPictureExist(os.path.split(path_2)[1])
        self.push_path = self.multimedia_setting.push_file(
            self.video.cfg.get("push_video_2"),
            self.video.cfg.get("datapath_2"))
        self.multimedia_handle.launchVideoApp()
        time.sleep(2)
        self.multimedia_handle.videoPlayBack(self.push_path)
        self.multimedia_setting.install_apk("vpg_apk")
        self.checkVideoPlayBack(30)
        adb.adb_cmd_common(
            'uninstall videoplayer.app.instrument.otc.intel.com.otcvideoplayer'
        )
        adb.adb_cmd_common('uninstall com.intel.vpg.tool')
        print "case " + str(case_name) + " is pass"

    def imageViewCheckWithShortCut(self, case_name):
        print "run case is " + str(case_name)
        self.appPrepare(case_name)
        path = self.video.cfg.get("push_picture").split(" ")[-1].strip("\"")
        if "androidia_64" in self.multimedia_setting.get_paltform_hardware():
            self.launchPhotoAPPWithShortCut()
            assert self.openPictureWithPhotosCmd(path), "Picture not exists!"
        elif self.multimedia_setting.get_android_version() == "O":
            self.launchGalleryAPPWithShortCut()
            assert self.openPictureWithGallery(path), "Picture not exists!"
        else:
            self.launchPhotoAPPWithShortCut()
            self.enterPhotoPath(path)
            assert self.checkPictureExist(
                os.path.split(path)[1]), "Picture not exists!"
        print "case " + str(case_name) + " is pass"

    def imageViewCheckFolder(self, case_name):
        print "run case is " + str(case_name)
        self.appPrepare(case_name)
        path = self.video.cfg.get("push_picture").split(" ")[-1].strip("\"")
        path_2 = self.video.cfg.get("push_picture_2").split(" ")[-1].strip(
            "\"")
        print path, path_2
        self.multimedia_setting.push_file(self.video.cfg.get("push_picture_2"),
                                          self.video.cfg.get("datapath"))
        self.launchPhotoAPP()
        self.enterPhotoPath(path)
        file_name = os.path.split(path)[1]
        file_name_2 = os.path.split(path_2)[1]
        self.checkPictureExist(file_name)
        self.d.press.back()
        self.checkPictureExist(file_name)
        self.checkPictureExist(file_name_2)
        print "case " + str(case_name) + " is pass"

    def imageViewCheckSlideShow(self, case_name):
        print "run case is " + str(case_name)
        self.appPrepare(case_name)
        path = self.video.cfg.get("push_picture").split(" ")[-1].strip("\"")
        path_2 = self.video.cfg.get("push_picture_2").split(" ")[-1].strip(
            "\"")
        print path, path_2
        self.multimedia_setting.push_file(self.video.cfg.get("push_picture_2"),
                                          self.video.cfg.get("datapath"))
        self.launchPhotoAPP()
        self.enterPhotoPath(path)
        file_name = os.path.split(path)[1]
        file_name_2 = os.path.split(path_2)[1]
        self.checkPictureExist(file_name)
        self.d(className="android.widget.ImageView").swipe.left()
        self.checkPictureExist(file_name_2)
        print "case " + str(case_name) + " is pass"

    def imageViewTenTimes(self, case_name, t_time=10):
        print "run case is " + str(case_name)
        self.appPrepare(case_name)
        path = self.video.cfg.get("push_picture").split(" ")[-1].strip("\"")
        print path
        self.launchPhotoAPP()
        self.enterPhotoPath(path)
        file_name = os.path.split(path)[1]
        self.checkPictureExist(file_name)
        for _ in range(10):
            self.d.press.back()
            self.d(text=file_name).click()
            self.checkPictureExist(file_name)
        print "case " + str(case_name) + " is pass"

    def getCpuConsumption(self):
        cmd = "shell top -m 1 -n 1"
        t_pattern = re.compile("User (.*)%, System (.*)%, IOW.*")
        result = g_common_obj.adb_cmd_common(cmd)
        print result
        if t_pattern.findall(result) != []:
            (t_user, t_system) = t_pattern.findall(result)[0]
            return int(t_user) + int(t_system)
        else:
            return 0

    def imageViewWithManyTimes(self, case_name, times):
        print "run case is " + str(case_name)
        self.appPrepare(case_name)
        cpu_1 = self.getCpuConsumption()
        for iteration in range(times):
            logger.debug("Execute {0} times, total {1} times".format(
                iteration + 1, times))
            self.launchPhotoAPP()
            time.sleep(5)
            g_common_obj.stop_app_am("com.intel.otc.instrument.otcphotos")
            time.sleep(4)
        time.sleep(10)
        cpu_2 = self.getCpuConsumption()
        logger.info("cpu_1={0}, cpu_2={1}".format(cpu_1, cpu_2))
        assert cpu_1 + 10 >= cpu_2, "Cpu Consumption error! cpu_1=%s, cpu_2=%s" % (
            cpu_1, cpu_2)
        print "case " + str(case_name) + " is pass"

    def imageViewBackHome(self, case_name, flag=1):
        print "run case is " + str(case_name)
        self.appPrepare(case_name)
        path = self.video.cfg.get("push_picture").split(" ")[-1].strip("\"")
        print path
        if flag != 1:
            self.multimedia_setting.push_file(
                self.video.cfg.get("push_picture_2"),
                self.video.cfg.get("datapath"))
        self.launchPhotoAPP()
        self.enterPhotoPath(path)
        self.checkPictureExist(os.path.split(path)[1])
        self.d.press.home()
        self.multimedia_setting.click_recent_app("otcphoto-app")
        time.sleep(1)
        self.checkPictureExist(os.path.split(path)[1])
        if flag != 1:
            self.d(className="android.widget.ImageView").swipe.left()
            path_2 = self.video.cfg.get("push_picture_2").split(" ")[-1].strip(
                "\"")
            self.checkPictureExist(os.path.split(path_2)[1])
        print "case " + str(case_name) + " is pass"

    def imageViewWithAlarm(self, case_name, flag=1):
        print "run case is " + str(case_name)
        self.appPrepare(case_name)
        path = self.video.cfg.get("push_picture").split(" ")[-1].strip("\"")
        print path
        if flag != 1:
            self.multimedia_setting.push_file(
                self.video.cfg.get("push_picture_2"),
                self.video.cfg.get("datapath"))
        self.multimedia_setting.launchAlarmAPP()
        self.multimedia_setting.setAlarmTime(30)
        self.launchPhotoAPP()
        self.enterPhotoPath(path)
        self.checkPictureExist(os.path.split(path)[1])
        self.multimedia_setting.waitAlarmTriiggered(50, "Snooze")
        self.multimedia_setting.setAlarmTime(30)
        self.multimedia_setting.click_recent_app("otcphoto-app")
        time.sleep(1)
        self.checkPictureExist(os.path.split(path)[1])
        self.multimedia_setting.waitAlarmTriiggered(50, "Dismiss")
        self.multimedia_setting.click_recent_app("otcphoto-app")
        time.sleep(1)
        self.checkPictureExist(os.path.split(path)[1])
        if flag != 1:
            self.d(className="android.widget.ImageView").swipe.left()
            path_2 = self.video.cfg.get("push_picture_2").split(" ")[-1].strip(
                "\"")
            self.checkPictureExist(os.path.split(path_2)[1])
        print "case " + str(case_name) + " is pass"

    def imageViewWithReboot(self, case_name, flag=1):
        print "run case is " + str(case_name)
        self.appPrepare(case_name)
        path = self.video.cfg.get("push_picture").split(" ")[-1].strip("\"")
        logger.debug(self.tag + "path:" + path)
        if flag != 1:
            self.multimedia_setting.push_file(
                self.video.cfg.get("push_picture_2"),
                self.video.cfg.get("datapath"))
        self.launchPhotoAPP()
        self.enterPhotoPath(path)
        self.checkPictureExist(os.path.split(path)[1])
        adb.reboot_device()
        self.wait_boot_completed()
        time.sleep(20)
        if self.d(textContains="Drive safely").exists:
            logger.debug(self.tag + "Drive saftely exist , click owner")
            self.d(text="Owner").click()
            time.sleep(3)
        self.lock = SystemUI()
        self.lock.unlock_screen()
        self.launchPhotoAPP()
        self.enterPhotoPath(path)
        self.checkPictureExist(os.path.split(path)[1])
        if flag != 1:
            self.d(className="android.widget.ImageView").swipe.left()
            path_2 = self.video.cfg.get("push_picture_2").split(" ")[-1].strip(
                "\"")
            self.checkPictureExist(os.path.split(path_2)[1])
        print "case " + str(case_name) + " is pass"

    def imageViewWithInvalidFile(self, case_name):
        print "run case is " + str(case_name)
        self.appPrepare(case_name)
        path = self.video.cfg.get("push_picture").split(" ")[-1].strip("\"")
        logger.debug(self.tag + "test file patch:%s" % path)
        self.launchPhotoAPP()
        self.enterPhotoPath(os.path.split(path)[0])
        assert not self.d(text=os.path.split(path)[1]).exists, os.path.split(
            path)[1] + "Invalid file can be find! error!"
        print "case " + str(case_name) + " is pass"

    def imageViewZoomIn_ZoomOut(self, case_name):
        print "run case is " + str(case_name)
        self.appPrepare(case_name)
        path = self.video.cfg.get("push_picture").split(" ")[-1].strip("\"")
        print path
        self.launchPhotoAPP()
        self.enterPhotoPath(path)
        self.checkPictureExist(os.path.split(path)[1])
        self.d(className="android.widget.ImageView").gesture(
            (self.x / 2, self.y / 2 - 20), (self.x / 2, self.y / 2)).to(
                (self.x / 2, self.y / 4), (self.x / 2, self.y * 3 / 4))
        self.checkPictureExist(os.path.split(path)[1])
        x1 = self.getPictureSize()
        assert x1 > 100, "ZoomIn error"
        time.sleep(2)
        self.d(className="android.widget.ImageView").gesture(
            (self.x / 2, self.y / 4), (self.x / 2, self.y * 3 / 4)).to(
                (self.x / 2, self.y / 2 - 20), (self.x / 2, self.y / 2))
        self.checkPictureExist(os.path.split(path)[1])
        x2 = self.getPictureSize()
        assert x1 > x2, "ZoomOut error"
        print "case " + str(case_name) + " is pass"

    def testImage_View_RotatePicture(self):
        """
        This test used to test Image Decode
        The test case spec is following:
        1. Open a picture
        2. Rotate picture to landscape mode
        3. Rotate picture to Portrait mode
        """
        self.imageViewRotatePicture("test_API_image_001")

    def testMultiMedia_Gallery_SlideShow_Continue_Idle(self):
        """
        This test used to test Image Decode
        The test case spec is following:
        1. Open a picture
        2. Press home
        """
        self.imageViewBackHome("test_API_image_002", 2)

    def testMultiMedia_Gallery3D_GIF_87a_ZoomIn_ZoomOut(self):
        """
        This test used to test Image Decode
        The test case spec is following:
        1. Open a picture
        2. Press home
        """
        self.imageViewZoomIn_ZoomOut("test_API_image_004")

    def testMultiMedia_Gallery3D_GIF_89a_ZoomIn_ZoomOut(self):
        """
        This test used to test Image Decode
        The test case spec is following:
        1. Open a picture
        2. Press home
        """
        self.imageViewZoomIn_ZoomOut("test_API_image_005")

    def testImage_ViewMode_Full_And_non_FullScreen_Switch(self):
        """
        This test used to test Image Decode
        The test case spec is following:
        1. Open a picture
        """
        self.imageViewTenTimes("test_API_image_006", 10)

    def testMultiMedia_Gallery3D_SlideShow_AlarmReminder(self):
        """
        This test used to test Image Decode
        The test case spec is following:
        1. Open a picture
        """
        self.imageViewWithAlarm("test_API_image_007", 2)

    def testImage_View_InvalidFile(self):
        """
        This test used to test Image Decode
        The test case spec is following:
        1. Open a picture
        """
        self.imageViewWithInvalidFile("test_API_image_008")

    def testMultiMedia_Gallery_Format_UnSupportPicture(self):
        """
        This test used to test Image Decode
        The test case spec is following:
        1. Open a picture
        """
        self.imageViewWithInvalidFile("test_API_image_009")

    def testMultiMedia_Gallery_SlideShow_Then_PowerOff_ON(self):
        """
        This test used to test Image Decode
        The test case spec is following:
        1. Open a picture
        """
        self.imageViewWithReboot("test_API_image_010", 2)

    def testMultiMedia_Gallery_Format_ErrorPicture(self):
        """
        This test used to test Image Decode
        The test case spec is following:
        1. Open a picture
        """
        self.imageViewWithInvalidFile("test_API_image_011")

    def testMultiMedia_Gallery3D_SlideShow_Multiple_Events(self):
        """
        This test used to test Image Decode
        The test case spec is following:
        1. Open a picture
        """
        self.imageViewWithAlarm("test_API_image_012", 2)

    def testMultiMedia_MediaFramework_Display_Picture(self):
        """
        This test used to test Image Decode
        The test case spec is following:
        1. Open a picture
        """
        self.imageViewWithInvalidFile("test_API_image_013")

    def testMultiMedia_Gallery3D_ViewImage_Larger_Than_5_or_8_MB(self):
        """
        This test used to test Image Decode
        The test case spec is following:
        1. Open a picture
        """
        self.imageViewCheck("test_API_image_014")

    def test_Calendar_Alarm_EmailNote_When_SlideShow(self):
        """
        This test used to test Image Decode
        The test case spec is following:
        1. Open a picture
        """
        self.imageViewWithAlarm("test_API_image_015", 2)

    def testMultiMedia_Gallery3D_Launch_Exit_30_Times(self):
        """
        This test used to test Image Decode
        The test case spec is following:
        1. Open a picture
        """
        self.imageViewWithManyTimes("test_API_image_016", 30)

    def testMultiMedia_Gallery_Launch_Exit_100_Times(self):
        """
        This test used to test Image Decode
        The test case spec is following:
        1. Open a picture
        """
        self.imageViewWithManyTimes("test_API_image_017", 100)

    def testImage_Number_Indicator(self):
        """
        This test used to test Image Decode
        The test case spec is following:
        1. Open a picture
        """
        self.imageViewCheckFolder("test_API_image_018")

    def testCalendar_Interact_When_View_Picture(self):
        """
        This test used to test Image Decode
        The test case spec is following:
        1. Open a picture
        """
        self.imageViewWithAlarm("test_API_image_019")

    def testMultiMedia_Gallery_SlideShow_Long_Time(self):
        """
        This test used to test Image Decode
        The test case spec is following:
        1. Open a picture
        """
        self.imageViewCheckSlideShow("test_API_image_020")

    def testMultiMedia_Gallery_DifferentResolutions_3072x2304(self):
        """
        This test used to test Image Decode
        The test case spec is following:
        1. Open a picture
        """
        self.imageViewCheck("test_API_image_021")

    def testMultiMedia_MediaFramework_Display_BigSize_Picture(self):
        """
        This test used to test Image Decode
        The test case spec is following:
        1. Open a picture
        """
        self.imageViewCheck("test_API_image_022")

    def testMultiMedia_MediaFramework_Display_LittleSize_Picture(self):
        """
        This test used to test Image Decode
        The test case spec is following:
        1. Open a picture
        """
        self.imageViewCheck("test_API_image_023")

    def testMultiMedia_Gallery_Enter_By_ShortCut(self):
        """
        This test used to test Image Decode
        The test case spec is following:
        1. Open a picture
        """
        self.imageViewCheckWithShortCut("test_API_image_024")

    def testJPEG_HW_Decode(self):
        """
        This test used to test Image Decode
        The test case spec is following:
        1. Open a picture
        """
        self.imageViewCheck("test_API_image_025")

    def testMultiMedia_Gallery3D_Unsupported_Images_Videos(self):
        """
        This test used to test Image Decode
        The test case spec is following:
        1. Open a picture
        """
        self.imageViewWithInvalidFile("test_API_image_026")

    def testMultiMedia_Gallery3D_Gesturing_Screen(self):
        """
        This test used to test Image Decode
        The test case spec is following:
        1. Open a picture
        """
        self.imageViewCheckSlideShow("test_API_image_027")

    def testMultiMedia_Gallery_Panning_Single(self):
        """
        This test used to test Image Decode
        The test case spec is following:
        1. Open a picture
        2. Press home
        """
        self.imageViewZoomIn_ZoomOut("test_API_image_028")

    def testApp_Install_When_View_Picture_Video_SlideShow(self):
        """
        This test used to test Image Decode
        The test case spec is following:
        1. Open a picture
        """
        self.imageViewCheckWithInstallApp("test_API_image_029", 2)

    def testMultiMedia_Gallery_Rotation_Background(self):
        """
        This test used to test Image Decode
        The test case spec is following:
        1. Open a picture
        """
        self.imageViewCheckWithRotation("test_API_image_030")

    def testMultiMedia_Gallery_Image_Review_SD_USB(self):
        """
        This test used to test Image Decode
        The test case spec is following:
        1. Open a picture
        """
        self.imageViewCheck("test_API_image_031")

    def testImage_View_RotatePicture_ManyTimes(self):
        """
        This test used to test Image Decode
        The test case spec is following:
        1. Open a picture
        """
        self.imageViewRotatePictureManyTimes("test_API_image_043", 20)

    def testVideo_NonExist(self):
        """
        This test used to test Image Decode
        The test case spec is following:
        1. Open a picture
        """
        self.imageViewCheckAfterDeleteFile("test_API_image_044")
Пример #18
0
class WidevineTest(UIATestBase):
    """
    @summary: Test Widevine
    """

    config = TestConfig()

    def setUp(self):
        """
        @summary: set up
        @return: None
        """
        super(WidevineTest, self).setUp()
        self.d = g_common_obj.get_device()
        self._test_name = __name__
        self.video_button_widget_dict = {
            "play": "android:id/pause",
            "pause": "android:id/pause",
            "volume_up": "volume_up",
            "volume_down": "volume_down",
            "back": "back"
        }
        print "[Setup]: %s" % self._test_name

    def tearDown(self):
        """
        @summary: tear tearDown
        @return: None
        """
        super(WidevineTest, self).tearDown()
        print "[Teardown]: %s" % self._test_name
        g_common_obj.stop_exp_handle()

    def appPrepare(self, model=1):
        self.cfg_file = os.path.join(os.environ.get('TEST_DATA_ROOT', ''), \
            'tests.tablet.mum_auto_drm.conf')
        self.cfg = self.config.read(self.cfg_file, self.case_name)

        self.multimedia_handle = MultiMediaHandle()
        self.multimedia_setting = MultiMediaSetting(self.cfg_file)
        self.multimedia_drm_helper = MultiMediaDRMHelper()

        self.multimedia_setting.install_apk(
            "widevine_apk")  #install widevine apk
        self.widevine_package_name, self.widevine_activity_name = self.multimedia_setting.get_package_and_activity_name(
            "widevine_apk")

        if model == 1:  # play local video mode
            self.dst_path = self.cfg.get("dst_path")
            self.clearResourcefolder()
            self.dst_path = self.multimedia_setting.push_file_new(
                self.cfg.get("src_path"),
                self.dst_path)  #push video file to device
        elif model == 2:  # play network video mode
            self.src_path = self.cfg.get("src_path")

#         g_common_obj.set_vertical_screen()
        g_common_obj.stop_app_am(self.widevine_package_name)
        g_common_obj.adb_cmd_capture_msg("input keyevent 82")  #Unlock screen

    def disableVerityDUT(self):
        serial = self.d.server.adb.device_serial()
        result = os.popen("adb -s %s disable-verity" % serial).read()
        logger.debug("result=%s" % result)
        assert "version" not in result and "error" not in result, "Please update sdk version!"
        assert "fail" not in result and "error" not in result, "The DUT can't disable-verity, please reboot and check it"

    def remountDUT(self):
        serial = self.d.server.adb.device_serial()
        os.system("adb -s %s remount" % serial)
        time.sleep(3)
        result = os.popen("adb -s %s remount" % serial).read()
        logger.debug("result=%s" % result)
        assert "fail" not in result and "error" not in result, "The DUT can't remount, please reboot and check it"

    def getDeviceTypeMapCfg(self):
        if "device_type_map" not in dir(self):
            self.device_type_map_cfg = self.config.read(
                self.cfg_file, "device_type_map")
        return self.device_type_map_cfg

    def executeCommandWithPopen(self, cmd):
        logger.debug(cmd)
        #         return subprocess.Popen(cmd, shell=True)
        return subprocess.Popen(cmd,
                                stdin=subprocess.PIPE,
                                stdout=subprocess.PIPE,
                                stderr=subprocess.STDOUT,
                                shell=True)

    def clearResourcefolder(self):
        g_common_obj.adb_cmd_capture_msg("rm -rf %s" %
                                         os.path.split(self.dst_path)[0])

    def launchWidevineApp(self):
        SystemUI().unlock_screen()
        #         g_common_obj.stop_app_am(self.widevine_package_name)
        g_common_obj.launch_app_am(self.widevine_package_name,
                                   self.widevine_activity_name)
        time.sleep(5)
        for _ in range(5):
            if self.d(textContains="Downloads").exists:
                return
            time.sleep(5)
        assert self.d(
            textContains="Downloads").exists, "launch Winevine App failed!"

    def findVideoExistInWidevineApp(self, video_name):
        logger.debug("findVideoExistInWidevineApp video_name=%s" % video_name)
        time.sleep(5)
        for _ in range(10):
            if self.d(textContains=video_name).exists:
                break
            self.d(text=">>").click()
            time.sleep(20)
        assert self.d(textContains=video_name
                      ).exists, "Video not exist! video_name=%s" % video_name
        bounds = self.d(textContains=video_name).info["bounds"]
        x = bounds["left"] + (bounds["right"] - bounds["left"]) / 2
        y = bounds["top"] - (bounds["bottom"] - bounds["top"]) / 2
        self.d.click(x, y)

    def clear_edit_text_layout(self, layout):
        while layout.text != "":
            layout.clear_text()

    def setContentPage(self, path):
        self.d(text="Settings").click()
        time.sleep(2)
        edit_text_layout = self.d(
            className="android.widget.EditText",
            resourceId="com.widevine.demo:id/content_page")
        if edit_text_layout.text != path:
            self.clear_edit_text_layout(edit_text_layout)
            edit_text_layout.set_text(path)
            self.d.press.back()
            time.sleep(1)
            self.d(text="Update Button").click()
            self.d(text="Ok").click()

    def wait_boot_completed(self, timeout=1000):
        ''' wait Android boot_completed
    
        args: timeout -- optional timeout in second, default 1000s
        '''
        count = 0
        sleep_time = 5
        while count < timeout:
            prop_val = adb.adb_cmd_capture_msg('getprop sys.boot_completed')
            if '1' in prop_val:
                print 'boot_completed'
                return
            count += sleep_time
            time.sleep(sleep_time)
        raise Exception('%ds timeout waiting for boot_completed' % timeout)

    def widevineVideoPlayBack(self):
        self.d(text="Downloads").click()
        time.sleep(5)
        dst_name = os.path.split(self.dst_path)[1]
        assert self.d(
            textContains=dst_name
        ).exists, "resource file not exist! file_name=%s" % dst_name
        self.d(className="android.widget.ImageView", index="0").click()
        time.sleep(5)
        self.d(text="Acquire Rights").click()
        time.sleep(3)
        acquire_rights_value = -1
        for _ in range(3):
            widevine_value = self.getWidevineValue()
            logger.debug("widevine_value=%s" % widevine_value)
            if "acquireRights" in widevine_value and "Rights installed" in widevine_value:
                acquire_rights_value = self.getWidevineValue_acquireRights()
                logger.debug("acquire_rights_value=%s" %
                             str(acquire_rights_value))
                break
            time.sleep(3)
        assert "error" not in widevine_value and "fail" not in widevine_value, "error widevine_value!! widevine_value=%s" % widevine_value
        assert acquire_rights_value == 0, "error acquire_rights_value!!! acquire_rights_value=%d" % acquire_rights_value
        self.d(text="Play").click()

    def widevineStreamingVideoPlayBack(self):
        self.d(text="Streaming").click()
        time.sleep(5)
        video_index = self.findVideoExistInWidevineApp(self.src_path)
        self.d(className="android.widget.ImageView", index=video_index).click()
        time.sleep(5)
        self.d(text="Acquire Rights").click()
        time.sleep(3)
        acquire_rights_value = -1
        for _ in range(10):
            widevine_value = self.getWidevineValue()
            logger.debug("widevine_value=%s" % widevine_value)
            if "acquireRights" in widevine_value and "Rights installed" in widevine_value:
                acquire_rights_value = self.getWidevineValue_acquireRights()
                logger.debug("acquire_rights_value=%s" %
                             str(acquire_rights_value))
                break
            time.sleep(3)
        assert "error" not in widevine_value and "fail" not in widevine_value, "error widevine_value!! widevine_value=%s" % widevine_value
        assert acquire_rights_value == 0, "error acquire_rights_value!!! acquire_rights_value=%d" % acquire_rights_value
        self.d(text="Play").click()

    def getWidevineValue(self):
        self.widevine_value_text = self.d(
            className="android.widget.TextView").text
        return self.widevine_value_text

    def get_acquire_rights_pattern(self):
        if "acquire_rights_pattern" not in dir(self):
            GET_ACQUIRERIGHTS_PATTERN = ".*acquireRights = (.*)\n.*"
            self.acquire_rights_pattern = re.compile(GET_ACQUIRERIGHTS_PATTERN)
        return self.acquire_rights_pattern

    def getWidevineValue_acquireRights(self):
        try:
            acquire_rights_pattern = self.get_acquire_rights_pattern()
            widevine_value = self.getWidevineValue()
            acquire_rights_value = acquire_rights_pattern.findall(
                widevine_value)
            acquire_rights_value = int(acquire_rights_value[0])
        except Exception as e:
            logger.debug("widevine_value=%s" % widevine_value)
            logger.debug("acquire_rights_value=%s" % str(acquire_rights_value))
            assert 0, e
        return acquire_rights_value

    def getPlatform(self):
        cmd = "adb shell getprop ro.board.platform"
        platform = os.popen(cmd).read()
        platform = platform.replace("\n", "", 1)
        return platform.strip()

    def getDeviceTypeMapNum(self):
        device_platform = self.getPlatform()
        device_platform = device_platform.lower()
        if "sofia_lte" in device_platform:
            num = 2
        else:
            num = 1
#         num = self.getDeviceTypeMapCfg().get(device_platform)
        return num

    def clickScreen(self):
        self.multimedia_setting.clickScreen()

    def click_widget(self, t_widget):
        try:
            t_widget.click()
            self.s_t_text = 0
        except Exception as e:
            logger.debug("click_widget error:%s" % e)
            self.s_t_text = -2
            assert 0, "click_widget error:%s" % e

    def get_widget(self, t_str):
        logger.debug("get_widget---t_str=%s" % t_str)
        assert t_str in self.video_button_widget_dict, "%s not in video_button_widget_dict!" % t_str
        t_resource_id = self.video_button_widget_dict[t_str]
        if t_resource_id == t_str:
            return t_resource_id
        else:
            return self.d(resourceId=t_resource_id)

    def widget_operation_with_thread(self, t_str, t_operation):
        self.s_t_text = -1
        t_widget = self.get_widget(t_str)
        if t_operation == "click":
            thread.start_new_thread(self.click_widget, (t_widget, ))
        else:
            assert 0, "Error operation!"
        while self.s_t_text == -1:
            if not t_widget.exists:
                self.clickScreen()
            time.sleep(1)
        return self.s_t_text

    def click_button(self, t_str):
        logger.debug("click_button---t_str=%s" % t_str)
        t_widget = self.video_button_widget_dict[t_str]
        if t_str != t_widget:
            result = self.widget_operation_with_thread(t_str, "click")
            assert result == 0, "click failed! reselt=%d" % result
        else:
            getattr(self.d.press, t_widget)()

    def checkVideoPlayBackWithWidevine(self):
        self.launchWidevineApp()  # launch widevine app
        self.widevineVideoPlayBack()  # play video file
        time.sleep(10)
        assert not self.d(
            textContains="can't"
        ).exists, "video playback failed!"  #check play status of video
        time.sleep(140)
        assert not self.d(
            textContains="can't"
        ).exists, "video playback failed!"  #check play status of video

    def checkStreamingVideoPlayBackWithWidevine(self):
        self.launchWidevineApp()
        self.setContentPage(self.cfg.get("web_page"))
        self.widevineStreamingVideoPlayBack()
        time.sleep(10)
        assert not self.d(
            textContains="can't").exists, "video playback failed!"
        time.sleep(140)
        assert not self.d(
            textContains="can't").exists, "video playback failed!"

    def checkVideoPlayBackWithClickButton(self, click_list):
        self.launchWidevineApp()  # launch widevine app
        self.widevineVideoPlayBack()  # play video file
        time.sleep(10)
        assert not self.d(
            textContains="can't"
        ).exists, "video playback failed!"  #check play status of video
        for t_str in click_list:
            if t_str == "sleep":
                time.sleep(5)
            else:
                self.click_button(t_str)
                time.sleep(2)
        time.sleep(60)
        assert not self.d(
            textContains="can't"
        ).exists, "video playback failed!"  #check play status of video

    def winevine_main_test(self, sub_func_name="", model=1, *arg, **keywords):
        """
        This test used to test WinevineApp App
        The test case spec is following:
        1. Start record video
        2. do sub_func()
        3. Stop record video
        """
        self.case_name = sys._getframe().f_back.f_code.co_name
        if sub_func_name == "":
            sub_func_name = "%s_sub_func" % self.case_name
        logger.debug("case_name=%s" % self.case_name)
        logger.debug("exoplayer_main_test---sub_func_name=%s" % sub_func_name)
        self.appPrepare(model)
        try:
            self.multimedia_drm_helper.startRecord(
                self.case_name)  #start record

            logger.debug("Arbitrary parameter is %s" % str(arg))
            logger.debug("keywords parameter is %s" % str(keywords))
            getattr(self, sub_func_name)(*arg, **keywords)

            self.d.press.back()
            self.d.press.back()
            self.d.press.home()
            if model == 1:
                self.clearResourcefolder()
            time.sleep(1)
            self.multimedia_drm_helper.stopRecord()  #stop record
        except Exception as e:
            self.multimedia_drm_helper.stopRecord()
            assert 0, e

        assert 0, "Playback complete! Please check video!"
        logger.debug("Case %s is pass!" % self.case_name)

    def test_video_playback_with_check_S0I3(self):
        self.case_name = sys._getframe().f_back.f_code.co_name
        self.appPrepare()
        after_S0I3_str = self.multimedia_setting.getS0I3()
        self.launchWidevineApp()
        self.widevineVideoPlayBack()
        time.sleep(10)
        assert not self.d(
            textContains="can't").exists, "video playback failed!"
        self.d.press.power()
        logger.debug("Step: sleep 800s, please wait...")
        time.sleep(800)
        logger.debug("Step: sleep 800s, complete!")
        self.d.press.power()
        SystemUI().unlock_screen()
        self.d.press.back()
        self.d.press.home()
        before_S0I3_str = self.multimedia_setting.getS0I3()
        assert after_S0I3_str != before_S0I3_str, "after_S0I3_str=%s, before_S0I3_str=%s" % (
            after_S0I3_str, before_S0I3_str)

    def checkVideoPlayBackWithWidevineWithReboot(self, t_time):
        self.case_name = sys._getframe().f_back.f_code.co_name
        self.appPrepare()
        self.launchWidevineApp()
        self.widevineVideoPlayBack()
        time.sleep(20)
        assert not self.d(
            textContains="can't").exists, "video playback failed!"
        for _ in range(t_time):
            adb.reboot_device()
            self.wait_boot_completed()
        time.sleep(20)
        self.launchWidevineApp()
        self.widevineVideoPlayBack()
        time.sleep(20)
        assert not self.d(
            textContains="can't").exists, "video playback failed!"

    def checkProvision(self):
        self.case_name = sys._getframe().f_back.f_code.co_name
        logger.debug("case_name=%s" % self.case_name)
        self.appPrepare(0)
        if "false" == self.cfg.get("test"):
            logger.debug("Case %s is skip auto test!" % self.case_name)
            return
        num = self.getDeviceTypeMapNum()
        if num == 1:
            g_common_obj.root_on_device()
            self.disableVerityDUT()
            adb.reboot_device()
            self.wait_boot_completed()
        g_common_obj.root_on_device()
        self.remountDUT()
        time.sleep(3)
        bin_src_path = self.getDeviceTypeMapCfg().get("%s_bin_src_path" %
                                                      (num))
        bin_dst_path = self.getDeviceTypeMapCfg().get("%s_bin_src_path" %
                                                      (num))
        bin_src_path = self.multimedia_setting.download_file_to_host(
            bin_src_path)
        bin_src_folder = os.path.split(bin_src_path)[0]
        bin_dst_filename = os.path.split(bin_dst_path)[1]
        unzip_cmd = self.getDeviceTypeMapCfg().get("unzip_command")
        self.executeCommandWithPopen(unzip_cmd %
                                     (bin_src_path, bin_src_folder))
        bin_src_path = os.path.join(bin_src_folder, bin_dst_filename)
        bin_dst_path = self.multimedia_setting.push_file_to_dut(
            bin_src_path, bin_dst_path)

        tools_src_path = self.getDeviceTypeMapCfg().get("%s_tool_src_path" %
                                                        (num))
        tools_dst_path = self.getDeviceTypeMapCfg().get("%s_tool_dst_path" %
                                                        (num))
        tools_dst_path = self.multimedia_setting.push_file_new(
            tools_src_path, tools_dst_path)
        g_common_obj.adb_cmd_capture_msg("chmod 777 %s" % tools_dst_path)
        time.sleep(5)
        i = 1
        while "%s_execute_command_%s" % (num, i) in self.getDeviceTypeMapCfg():
            cmd = self.getDeviceTypeMapCfg().get("%s_execute_command_%s" %
                                                 (num, i))
            fdp = self.executeCommandWithPopen(cmd)
            time.sleep(3)
            stdout_log = fdp.stdout.read()
            assert "cannot" not in stdout_log and "error" not in stdout_log and "fail" not in stdout_log and "not found" not in stdout_log, "(%s) cmd error: %s" % (
                cmd, stdout_log)
            i += 1
        logger.debug("Case %s is pass!" % self.case_name)

    def testWVClassicPlayback_WVDemo_Local_720p(self):
        self.winevine_main_test("checkVideoPlayBackWithWidevine")

    def testWVClassic_WVDemo_Local_1080p(self):
        self.winevine_main_test("checkVideoPlayBackWithWidevine")

    def testWVClassic_WVDemo_Local_360(self):
        self.winevine_main_test("checkVideoPlayBackWithWidevine")

    def testWVClassic_WVDemo_SD(self):
        self.winevine_main_test("checkVideoPlayBackWithWidevine")

    def testWVClassic_WVDemo_Local_480p(self):
        self.winevine_main_test("checkVideoPlayBackWithWidevine")

    def testWVClassic_WVDemo_HD_Local(self):
        self.winevine_main_test("checkVideoPlayBackWithWidevine")

    def testWVClassic_WVDemo_WiFi_360p(self):
        self.winevine_main_test("checkStreamingVideoPlayBackWithWidevine", 2)

    def testWVClassic_WVDemo_WiFi_480P(self):
        self.winevine_main_test("checkStreamingVideoPlayBackWithWidevine", 2)

    def testWVClassic_WVDemo_WiFi_720p(self):
        self.winevine_main_test("checkStreamingVideoPlayBackWithWidevine", 2)

    def testWVClassic_WVDemo_WiFi_1080p(self):
        self.winevine_main_test("checkStreamingVideoPlayBackWithWidevine", 2)

    def testWVClassic_WVDemo_Menu_Interaction(self):
        self.winevine_main_test("checkVideoPlayBackWithClickButton", 1,
                                ["volume_up"] * 4 + ["sleep"] +
                                ["volume_down"] * 4)

    def testWVClassic_WVDemo_Volume_Adjustment_Paused(self):
        self.winevine_main_test("checkVideoPlayBackWithClickButton", 1,
                                ["pause"] + ["volume_up"] * 10 + ["sleep"] +
                                ["volume_down"] * 10 + ["play"] +
                                ["volume_down"] * 10 + ["pause"])

    def testWVClassic_Reboot_Multi_Times(self):
        self.checkVideoPlayBackWithWidevineWithReboot(20)

    def testWVClassic_Resume_S0i3(self):
        self.test_video_playback_with_check_S0I3()

    def testProvisionKeyBox_Reboot(self):
        self.checkProvision()

    def testWVClassic_Provision(self):
        self.checkProvision()
Пример #19
0
class ExoPlayerTest(UIATestBase):
    """
    @summary: Test Widevine
    """

    config = TestConfig()

    def setUp(self):
        """
        @summary: set up
        @return: None
        """
        super(ExoPlayerTest, self).setUp()
        self.d = g_common_obj.get_device()
        self._test_name = __name__
        self.playback_state_str = "playbackState"
        self.video_button_index_dict = {
            "Paused": 1,
            "Play": 1,
            "Forward": 2,
            "Backward": 0
        }

        print "[Setup]: %s" % self._test_name

    def tearDown(self):
        """
        @summary: tear tearDown
        @return: None
        """
        super(ExoPlayerTest, self).tearDown()
        print "[Teardown]: %s" % self._test_name
        g_common_obj.stop_exp_handle()

    def appPrepare(self, model=1):
        self.cfg_file = os.path.join(os.environ.get('TEST_DATA_ROOT', ''), \
            'tests.tablet.mum_auto_drm.conf')
        self.cfg = self.config.read(self.cfg_file,
                                    self.case_name)  # read config file

        self.multimedia_setting = MultiMediaSetting(self.cfg_file)
        self.multimedia_drm_helper = MultiMediaDRMHelper()
        self.multimedia_video_quality_helper = MultiMediaVideoQualityHelper()

        self.multimedia_setting.install_apk(
            "exoplayer_apk")  #install exoplayer apk
        self.exoplayer_package_name, self.exoplayer_activity_name = self.multimedia_setting.get_package_and_activity_name(
            "exoplayer_apk")  #get app info

        #         g_common_obj.set_vertical_screen()
        g_common_obj.stop_app_am(self.exoplayer_package_name)
        g_common_obj.adb_cmd_capture_msg("input keyevent 82")  #Unlock screen

    def clickScreen(self):
        self.multimedia_setting.clickScreen()

    def launchEXOPlayerApp(self):
        SystemUI().unlock_screen()
        #         g_common_obj.stop_app_am(self.widevine_package_name)
        g_common_obj.launch_app_am(self.exoplayer_package_name,
                                   self.exoplayer_activity_name)
        time.sleep(5)
        for _ in range(5):
            if self.d(textContains="ExoPlayer Demo").exists:
                return
            time.sleep(5)
        assert self.d(textContains="ExoPlayer Demo"
                      ).exists, "launch Exoplayer App failed!"

    def get_playback_state_pattern(self):
        if "playback_state_pattern" not in dir(self):
            GET_PLAYBACKSTATE_PATTERN = "playbackState=(.*)"
            self.playback_state_pattern = re.compile(GET_PLAYBACKSTATE_PATTERN)
        return self.playback_state_pattern

    def getPlaybackState(self):
        playback_state_str = self.playback_state_str
        for _ in range(3):
            if not self.d(textContains=playback_state_str).exists:
                self.clickScreen()
            time.sleep(1)
        assert self.d(textContains=playback_state_str
                      ).exists, "playbackState not exist! please check it!"
        status = self.d(textContains=playback_state_str).text
        logger.debug("all_status=%s" % status)
        playback_state_pattern = self.get_playback_state_pattern()
        playback_state = playback_state_pattern.findall(status)
        logger.debug("playback_state=%s" % str(playback_state))
        return playback_state[0]

    def checkPlaybackState(self):
        for _ in range(5):
            playback_state = self.getPlaybackState()
            if playback_state == "ready":
                return 0
            time.sleep(5)
        assert 0, "Error! playback_state=%s" % playback_state

    def clickVideoButton(self, t_str):
        logger.debug("clickVideoButton---t_str=%s" % t_str)
        assert t_str in self.video_button_index_dict, "%s not in video_button_index_dict!" % t_str
        t_index = self.video_button_index_dict[t_str]
        if not self.d(className="android.widget.ImageButton",
                      index=t_index).exists:
            self.clickScreen()
        self.d(className="android.widget.ImageButton", index=t_index).click()

    def wait_boot_completed(self, timeout=1000):
        ''' wait Android boot_completed
    
        args: timeout -- optional timeout in second, default 180s
        '''
        count = 0
        sleep_time = 5
        while count < timeout:
            prop_val = adb.adb_cmd_capture_msg('getprop sys.boot_completed')
            if '1' in prop_val:
                print 'boot_completed'
                return
            count += sleep_time
            time.sleep(sleep_time)
        raise Exception('%ds timeout waiting for boot_completed' % timeout)

    def clickRetryButton(self):
        retry_str = "Retry"
        if not self.d(text=retry_str).exists:
            self.clickScreen()
            time.sleep(3)
            if not self.d(text=retry_str).exists:
                self.clickVideoButton("Paused")
                time.sleep(1)
                self.clickVideoButton("Play")
                time.sleep(5)
        if self.d(text=retry_str).exists:
            logger.debug("Click retry button!")
            self.d(text=retry_str).click()
            time.sleep(1)
        else:
            logger.debug("Can't find retry button!")

    def clickRecentApp(self, app_name):
        self.multimedia_setting.click_recent_app(app_name)

    def checkVideoPlayback(self, t_time, expect_resolution=532):
        timeNow = time.time()
        if t_time >= 20:
            self.multimedia_video_quality_helper.checkSurfaceViewResolutionWithThread_start(
                expect_resolution)
        while time.time() - timeNow < t_time:
            playback_state = self.getPlaybackState()
            if playback_state == "end":
                logger.debug("Video playback finish!")
                break
            elif playback_state != "ready":
                logger.debug("checkVideoPlayback-- playback_state=%s" %
                             playback_state)
                self.clickRetryButton()
            time.sleep(3)
        if t_time >= 20:
            assert self.multimedia_video_quality_helper.checkSurfaceViewResolutionWithThread_stop(
            ) == 1, "Looks like Video didn't reach HD(%d)..." % expect_resolution

    def exoplayerPlayBack(self, mode=""):
        if mode == "":
            mode = "WV: Secure video path required"
        elif mode == "HDCP":
            mode = "WV: HDCP + secure video path required"
        self.d(scrollable=True).scroll.vert.to(text=mode)
        self.d(text=mode).click()
        time.sleep(5)
        self.checkPlaybackState()

    def test_video_playback(self, t_time=60, mode="", expect_resolution=532):
        self.exoplayerPlayBack(mode)  # play video with exoplayer app
        time.sleep(20)
        self.checkVideoPlayback(
            t_time, expect_resolution)  # check play status of video

    def test_video_playback_with_pause(self, t_time=60):
        self.exoplayerPlayBack()  # play video with exoplayer app
        time.sleep(20)
        self.checkVideoPlayback(20)
        self.clickVideoButton("Paused")  #click paused button
        time.sleep(t_time)
        self.clickVideoButton("Play")  #click play button
        self.checkVideoPlayback(20)  # check play status of video

    def test_video_playback_with_control(self):
        self.exoplayerPlayBack()
        time.sleep(20)
        self.checkVideoPlayback(20)
        self.clickVideoButton("Paused")
        time.sleep(5)
        self.clickVideoButton("Play")
        time.sleep(5)
        self.clickVideoButton("Forward")
        time.sleep(5)
        self.clickVideoButton("Backward")
        time.sleep(10)

    def test_video_playback_with_repeatedly(self, click_list, t_time, mode=""):
        self.exoplayerPlayBack(mode)
        time.sleep(10)
        self.checkVideoPlayback(20)
        for i in range(t_time):
            logger.debug("clickVideoButton---%d time" % i)
            for t_str in click_list:
                self.clickVideoButton(t_str)
                time.sleep(2)
        time.sleep(5)

    def test_video_playback_with_background(self):
        self.exoplayerPlayBack()
        time.sleep(20)
        self.checkVideoPlayback(20)
        self.clickVideoButton("Paused")
        time.sleep(5)
        self.clickVideoButton("Play")
        time.sleep(5)
        self.d.press.home()
        time.sleep(3)
        self.clickRecentApp("ExoPlayer Demo")

    def test_video_playback_with_swipe(self, t_time, percent, mode=""):
        self.exoplayerPlayBack(mode)
        time.sleep(20)
        self.checkVideoPlayback(t_time)
        self.multimedia_setting.set_play_time(percent)
        self.checkVideoPlayback(20)

    def test_video_playback_with_sleep_mode(self, mode=""):
        self.exoplayerPlayBack(mode)
        time.sleep(20)
        self.checkVideoPlayback(10)
        self.d.press.power()
        time.sleep(5)
        self.d.press.power()
        SystemUI().unlock_screen()
        self.checkVideoPlayback(20)

    def test_video_playback_with_orientation(self,
                                             orientation_list,
                                             t_time,
                                             mode=""):
        self.exoplayerPlayBack(mode)
        time.sleep(10)

        self.checkVideoPlayback(20)
        for i in range(t_time):
            logger.debug("change orientation---%d time" % i)
            for t_str in orientation_list:
                self.d.orientation = t_str
                time.sleep(5)
        self.d.freeze_rotation(False)
        time.sleep(5)

    def test_video_playback_with_reboot(self, t_time):
        self.case_name = sys._getframe().f_back.f_code.co_name
        self.appPrepare()
        self.launchEXOPlayerApp()
        self.exoplayerPlayBack()
        time.sleep(20)
        self.checkVideoPlayback(10)
        for _ in range(t_time):
            adb.reboot_device()
            self.wait_boot_completed()
        time.sleep(20)
        self.lock = SystemUI()
        self.lock.unlock_screen()
        self.launchEXOPlayerApp()
        self.exoplayerPlayBack()
        time.sleep(20)
        self.checkVideoPlayback(10)
        self.d.press.back()
        self.d.press.home()

    def test_video_playback_with_check_S0I3(self):
        self.case_name = sys._getframe().f_back.f_code.co_name
        self.appPrepare()
        after_S0I3_str = self.multimedia_setting.getS0I3()
        self.launchEXOPlayerApp()
        self.exoplayerPlayBack()
        time.sleep(20)
        self.checkVideoPlayback(10)
        self.d.press.power()
        logger.debug("Step: sleep 800s, please wait...")
        time.sleep(800)
        logger.debug("Step: sleep 800s, complete!")
        self.d.press.power()
        SystemUI().unlock_screen()
        self.d.press.back()
        self.d.press.home()
        before_S0I3_str = self.multimedia_setting.getS0I3()
        assert after_S0I3_str != before_S0I3_str, "after_S0I3_str=%s, before_S0I3_str=%s" % (
            after_S0I3_str, before_S0I3_str)

    def test_video_playback_with_check_log(self,
                                           mode="",
                                           check_str="CopyBuffer"):
        self.multimedia_setting.clearLogs()
        self.multimedia_setting.checkLogs_start(check_str)
        self.exoplayerPlayBack(mode)
        time.sleep(20)
        self.checkVideoPlayback(20)
        self.multimedia_setting.checkLogs_end(check_str)

    def test_video_playback_with_pause_1hour(self, delay_time=3600):
        '''

        This test used to pause play 1 hours and resume
        test cases spec is following:
        1.pause palying video
        2.stop record video
        3.resume video
        4.start record the second video

        '''
        self.exoplayerPlayBack()
        time.sleep(20)
        self.clickVideoButton("Paused")
        self.multimedia_drm_helper.stopRecord()
        logger.debug("Step: sleep 1 hours, please wait...")
        time.sleep(delay_time)
        self.multimedia_drm_helper.startRecord(self.case_name + '_2')
        time.sleep(10)
        self.clickVideoButton("Paused")
        time.sleep(5)
        self.checkVideoPlayback(20)

    def exoplayer_main_test(self, sub_func_name="", *arg, **keywords):
        """
        This test used to test Exoplayer App
        The test case spec is following:
        1. Start record video
        2. do sub_func()
        3. Stop record video
        """
        self.case_name = sys._getframe().f_back.f_code.co_name
        if sub_func_name == "":
            sub_func_name = "%s_sub_func" % self.case_name
        logger.debug("case_name=%s" % self.case_name)
        logger.debug("exoplayer_main_test---sub_func_name=%s" % sub_func_name)
        self.appPrepare()
        try:
            self.multimedia_drm_helper.startRecord(
                self.case_name)  #start record
            self.launchEXOPlayerApp()  #launch exoplayer app

            logger.debug("Arbitrary parameter is %s" % str(arg))
            logger.debug("keywords parameter is %s" % str(keywords))
            getattr(self, sub_func_name)(*arg, **keywords)

            time.sleep(10)
            self.d.press.back()
            self.d.press.home()
            time.sleep(1)
            self.multimedia_drm_helper.stopRecord()  #stop record
        except Exception as e:
            self.multimedia_drm_helper.stopRecord()
            assert 0, e

        assert 0, "Playback complete! Please check video!"
        logger.debug("Case %s is pass!" % self.case_name)

    def testWVModular_Exoplayer_Display(self):
        self.exoplayer_main_test("test_video_playback", 20)

    def testWVModular_Exoplayer_Video_Playback(self):
        self.exoplayer_main_test("test_video_playback", 20)

    def testWVModualr_Exoplayer_Audio_Video_Synchronization(self):
        self.exoplayer_main_test("test_video_playback", 20)

    def testWVModular_Exoplayer_Play(self):
        self.exoplayer_main_test("test_video_playback", 20)

    def testWVModular_Exoplayer_End(self):
        self.exoplayer_main_test("test_video_playback", 600)

    def testWVModular_Exoplayer_Secure_HD_MP4_H264(self):
        self.exoplayer_main_test("test_video_playback", 20,
                                 "WV: Secure HD (MP4,H264)", 500)

    def testWVModular_ExoPlayer_Control(self):
        self.exoplayer_main_test("test_video_playback_with_control")

    def testWVModular_Exoplayer_Pause_Play_Repeatedly(self):
        self.exoplayer_main_test("test_video_playback_with_repeatedly",
                                 ["Paused", "Play"], 20)

    def testWVModular_Exoplayer_Forward_Rewind_Repeatedly(self):
        self.exoplayer_main_test("test_video_playback_with_repeatedly",
                                 ["Forward", "Backward"], 20)

    def testWVModular_Exoplayer_Forward_Rewind_Paused(self):
        self.exoplayer_main_test("test_video_playback_with_repeatedly",
                                 ["Paused", "Forward", "Backward", "Play"], 1)

    def testWVModular_Exoplayer_Forward_Rewind(self):
        self.exoplayer_main_test("test_video_playback_with_repeatedly",
                                 ["Forward", "Backward"], 1)

    def testWVModular_Exoplayer_Rewind_Less_10s(self):
        self.exoplayer_main_test("test_video_playback_with_repeatedly",
                                 ["Forward", "Backward"], 1, "HDCP")

    def testWVModular_Exoplayer_Pause_One_Minute(self):
        self.exoplayer_main_test("test_video_playback_with_pause")

    def testWVModular_Exoplayer_Resume_Background(self):
        self.exoplayer_main_test("test_video_playback_with_background")

    def testRewind_WVModular_Exoplayer(self):
        self.exoplayer_main_test("test_video_playback_with_swipe", 10, 0.01)

    def testWVModular_Exoplayer_Forward_Till_End(self):
        self.exoplayer_main_test("test_video_playback_with_swipe", 10, 0.98)

    def testWVModular_Exoplayer_Sleep_Paused(self):
        self.exoplayer_main_test("test_video_playback_with_sleep_mode")

    def testWVModular_Exoplayer_Power_Button(self):
        self.exoplayer_main_test("test_video_playback_with_sleep_mode", "HDCP")

    def testWVModular_Exoplayer_Changeorientation(self):
        self.exoplayer_main_test("test_video_playback_with_orientation",
                                 ["l", "r", "n", "l"], 1, "HDCP")

    def testWVModular_Verify_WV10_Copy_Buffer(self):
        self.exoplayer_main_test("test_video_playback_with_check_log", "HDCP",
                                 "CopyBuffer")

    def testWVModular_HDCP_Capability(self):
        self.exoplayer_main_test("test_video_playback_with_check_log", "HDCP",
                                 "GetHDCPCapability")

    def testWVClassic_Reboot_Multi_Times(self):
        self.test_video_playback_with_reboot(20)

    def testWVModular_Exoplayer_Resume_S0i3(self):
        self.test_video_playback_with_check_S0I3()

    def testWVModular_Resume_1hour_Paused(self):
        self.exoplayer_main_test("test_video_playback_with_pause_1hour",
                                 delay_time=3600)
Пример #20
0
class VideoHeadsetTest(TestCaseBase):
    """
    @summary: Test Video PlayBack
    """

    def setUp(self):
        """
        @summary: set up
        @return: None
        """
        super(VideoHeadsetTest, self).setUp()
        self.d = g_common_obj.get_device()
        self._test_name = __name__
        print "[Setup]: %s" % self._test_name
        g_common_obj.stop_app_am("videoplayer.app.instrument.otc.intel.com.otcvideoplayer")
        # Unlock screen
        g_common_obj.adb_cmd_capture_msg("input keyevent 82")
        
        self.hs = Headset("/dev/ttyUSB0")
        self.hs.reset()

    def tearDown(self):
        """
        @summary: tear tearDown
        @return: None
        """
        super(VideoHeadsetTest, self).tearDown()
        print "[Teardown]: %s" % self._test_name
        g_common_obj.stop_exp_handle()
        time.sleep(3)
        g_common_obj.stop_app_am("videoplayer.app.instrument.otc.intel.com.otcvideoplayer")
        time.sleep(3)
        
        self.hs.reset()

    def appPrepare(self, case_name, model=1):
        self.cfg_file = os.path.join(os.environ.get('TEST_DATA_ROOT', ''), \
            'tests.tablet.mum_auto_video.conf')
        self.video = PhotosImpl(\
            self.config.read(self.cfg_file, case_name))
        g_common_obj.adb_cmd_capture_msg(" rm -rf /sdcard/DCIM/Camera/*")
        
        self.multimedia_handle = MultiMediaHandle()
        self.multimedia_setting = MultiMediaSetting(self.cfg_file)
        self.multimedia_setting.clearFolder(self.video.cfg.get("remove_video"))
        time.sleep(2)
        if model == 1:
            self.push_path = self.multimedia_setting.push_file(self.video.cfg.get("push_video"), self.video.cfg.get("datapath"))
            
        self.multimedia_setting.install_apk("video_apk")
        self.video.set_orientation_n()
        # Unlock screen
        g_common_obj.adb_cmd_capture_msg("input keyevent 82")

    def videoPlayBack(self, push_path=""):
        if push_path == "":
            push_path = self.push_path
        return self.multimedia_handle.videoPlayBack(push_path)

    def checkVideoPlayBack(self, s=60):
        return self.multimedia_handle.checkVideoPlayBack(s)
    
    def checkVideoPlayBackWithComparePicture(self, stoptime, bigfileskiptime=0):
        return self.multimedia_handle.checkVideoPlayBackWithComparePicture(stoptime, bigfileskiptime)

    def checkVideoPlayBackWithHeadset(self, case_name):
        print "run case is " + str(case_name)
        self.appPrepare(case_name)
        
        self.hs.plug_in()
        time.sleep(2)
        
        self.multimedia_handle.launchVideoApp()
        time.sleep(2)
        self.videoPlayBack()
        self.checkVideoPlayBack()
        time.sleep(1)
        
        assert self.rpc.isStreamActive("music", 500), "music not active when headset plug in"
        print "case " + str(case_name) + " is pass"

    def testVideo_Playback_1080P_Check_Audio_HS(self):
        """
        This test used to test Video playback
        The test case spec is following:
        1. Launch play video app
        2. Play video
        3. Check headset
        """
        self.checkVideoPlayBackWithHeadset("test_API_video_playback_with_headset_001")

    def testVideo_Playback_720P_Check_Audio_HS(self):
        """
        This test used to test Video playback
        The test case spec is following:
        1. Launch play video app
        2. Play video
        3. Check headset
        """
        self.checkVideoPlayBackWithHeadset("test_API_video_playback_with_headset_002")
class VideoPlayBackIteration(TestCaseBase):
    """
    @summary: Test Video PlayBack
    """

    def setUp(self):
        """
        @summary: set up
        @return: None
        """
        super(VideoPlayBackIteration, self).setUp()
        self._test_name = __name__
        print "[Setup]: %s" % self._test_name
        g_common_obj.stop_app_am("com.google.android.apps.plus")
        g_common_obj.stop_app_am("com.google.android.apps.photos")
        # Unlock screen
        g_common_obj.adb_cmd_capture_msg("input keyevent 82")

    def tearDown(self):
        """
        @summary: tear tearDown
        @return: None
        """
        super(VideoPlayBackIteration, self).tearDown()
        print "[Teardown]: %s" % self._test_name
        g_common_obj.stop_exp_handle()
        time.sleep(3)

    def appPrepare(self, case_name):
        cfg_file = os.path.join(os.environ.get('TEST_DATA_ROOT', ''), \
            'tests.tablet.mum_auto_video.conf')
        self.video = PhotosImpl(\
            self.config.read(cfg_file, case_name))
        self.setting = SettingImpl(\
            self.config.read(cfg_file, case_name))
        g_common_obj.adb_cmd_capture_msg(" rm -rf /sdcard/DCIM/Camera/*")
        
        self.multimedia_handle = MultiMediaHandle()
        self.multimedia_setting = MultiMediaSetting(cfg_file)
        self.multimedia_setting.clearFolder(self.video.cfg.get("remove_video"))
        self.multimedia_setting.install_apk("video_apk")
        time.sleep(2)
        self.push_path = self.multimedia_setting.push_file(self.video.cfg.get("push_video"), self.video.cfg.get("datapath"))
        
        g_common_obj.adb_cmd_capture_msg(self.video.cfg.get("refresh_sd"))
        self.video.set_orientation_n()
        # Unlock screen
        g_common_obj.adb_cmd_capture_msg("input keyevent 82")

    def videoPlayBackIteration(self, case_name, bigfileskiptime=0):
        print "run case is " + str(case_name)
        self.appPrepare(case_name)
        push_folder = os.path.split(os.path.split(self.push_path)[0])[-1]
        for iteration in range(int(self.video.cfg.get("iteration_times"))):
            logger.info("Playback video iteration: {0} ".format(iteration + 1))
            if self.multimedia_setting.get_android_version() == "O":
                self.multimedia_handle.launchVideoApp()
                self.multimedia_handle.videoPlayBack(self.push_path)
                assert self.multimedia_handle.checkVideoPlayBackWithComparePicture(60), 'video play failed'
            else:
                self.video.launchPhotos(push_folder)
                time.sleep(2)
                self.multimedia_handle.checkVideoPlayBackWithPhotoApp(int(self.video.cfg.get("iteration_last_time")), bigfileskiptime)
                self.setting.recent_app()
                self.setting.remove_recent_app("OtcVideoPlayer")
        print "case " + str(case_name) + " is pass"

    def testVideoPlayback_Iteration_3GP_H263_20cycles(self):
        """
        This test used to test Video playback
        The test case spec is following:
        1. Launch photos
        2. Play video('H263 for 3GP continuouly play 20 times')
        3. Former name: test_video_playback_iteration_mum_001
        """
        self.videoPlayBackIteration("mum_test_video_playback_iteration_001")

    def testVideoPlayback_Iteration_MP4_H264_HP_1080P_30fps_50Mbps_AAC_LC_48KHz_320Kbps(self):
        """
        This test used to test Video playback
        The test case spec is following:
        1. Launch photos
        2. Play video('H263 for 3GP continuouly play 20 times')
        3. Former name: test_video_playback_iteration_mum_002
        """
        self.videoPlayBackIteration("mum_test_video_playback_iteration_002")

    def testVideoPlayback_Iteration_MP4_H264_HP_1080P_30fps_25Mbps_AAC_ELD_48KHz_192kbps(self):
        """
        This test used to test Video playback
        The test case spec is following:
        1. Launch photos
        2. Play video('Iterative Video playback: H264_HP_1080P_30fps_25Mbps_AAC_ELD_48KHz_192kbps.mp4, iteratively')
        3. Former name: test_video_playback_iteration_mum_003
        """
        self.videoPlayBackIteration("mum_test_video_playback_iteration_003", 20)

    def test_video_playback_iteration_mum_004(self):
        """
        This test used to test Video playback
        The test case spec is following:
        1. Launch photos
        2. Play video('H263 for 3GP continuouly play 20 times')
        """
        self.videoPlayBackIteration("mum_test_video_playback_iteration_004")

    def test_video_playback_iteration_mum_005(self):
        """
        This test used to test Video playback
        The test case spec is following:
        1. Launch photos
        2. Play video('MPEG4 part 2 SP (Simple Profile) and (Advanced Simple Profile) play 20 times continuoously')
        """
        self.videoPlayBackIteration("mum_test_video_playback_iteration_005")

    def testVideoPlayback_Iteration_3GP_H264_Part2v4_20cycles(self):
        """
        This test used to test Video playback
        The test case spec is following:
        1. Launch photos
        2. Play video('H264 Part 2 For .3GPv4 continuouly play 20 times')
        3. Former name: test_video_playback_iteration_mum_006
        """
        self.videoPlayBackIteration("mum_test_video_playback_iteration_006")

    def testVideoPlayback_Iteration_H264_L3_0_L4_0_HP_20cycles(self):
        """
        This test used to test Video playback
        The test case spec is following:
        1. Launch photos
        2. Play video('Video Playback H.264 Level 3.0, 4.0 High Profile play contnuously 20 times')
        3. Former name: test_video_playback_iteration_mum_007
        """
        self.videoPlayBackIteration("mum_test_video_playback_iteration_007")

    def testVideoPlayback_Iteration_H264_L1_0_L2_0_BP_20cycles(self):
        """
        This test used to test Video playback
        The test case spec is following:
        1. Launch photos
        2. Play video('Video Playback H.264 Level 1.0, 2.0 Baseline Profile play continuously 20 times')
        3. Former name: test_video_playback_iteration_mum_008
        """
        self.videoPlayBackIteration("mum_test_video_playback_iteration_008")

    def testVideoPlayback_Iteration_MP4_H263_20cycles(self):
        """
        This test used to test Video playback
        The test case spec is following:
        1. Launch photos
        2. Play video('Video Codec : H263 For .Mp4 play 20 times')
        3. Former name: test_video_playback_iteration_mum_009
        """
        self.videoPlayBackIteration("mum_test_video_playback_iteration_009")

    def testVideoPlayback_Iteration_3GP_MPEG4_Part2_3GPv5_20cycles(self):
        """
        This test used to test Video playback
        The test case spec is following:
        1. Launch photos
        2. Play video('MPEG4 Part 2 For .3GPv5 continuouly play 20 times')
        3. Former name: test_video_playback_iteration_mum_010
        """
        self.videoPlayBackIteration("mum_test_video_playback_iteration_010")

    def test_video_playback_iteration_mum_011(self):
        """
        This test used to test Video playback
        The test case spec is following:
        1. Launch photos
        2. Play video('MPEG4 Part 2 For .3GPv5 continuouly play 20 times')
        """
        self.videoPlayBackIteration("mum_test_video_playback_iteration_011")

    def test_video_playback_iteration_mum_012(self):
        """
        This test used to test Video playback
        The test case spec is following:
        1. Launch photos
        2. Play video('MPEG4 Part 2 For .3GPv5 continuouly play 20 times')
        """
        self.videoPlayBackIteration("mum_test_video_playback_iteration_012")

    def test_video_playback_iteration_mum_013(self):
        """
        This test used to test Video playback
        The test case spec is following:
        1. Launch photos
        2. Play video('MPEG4 Part 2 For .3GPv5 continuouly play 20 times')
        """
        self.videoPlayBackIteration("mum_test_video_playback_iteration_013")

    def test_video_playback_iteration_001(self):
        """
        This test used to test Video playback
        The test case spec is following:
        1. Launch photos
        2. Play video('H263 Decoder, H263_720x450_30fps_no_audio')
        """
        self.videoPlayBackIteration("test_video_playback_iteration_001")

    def test_video_playback_iteration_004(self):
        """
        This test used to test Video playback
        The test case spec is following:
        1. Launch photos
        2. Play video
        """
        self.videoPlayBackIteration("test_video_playback_iteration_004")

    def test_video_playback_iteration_005(self):
        """
        This test used to test Video playback
        The test case spec is following:
        1. Launch photos
        2. Play video
        """
        self.videoPlayBackIteration("test_video_playback_iteration_005")

    def test_video_playback_iteration_006(self):
        """
        This test used to test Video playback
        The test case spec is following:
        1. Launch photos
        2. Play video
        """
        self.videoPlayBackIteration("test_video_playback_iteration_006")

    def test_video_playback_iteration_007(self):
        """
        This test used to test Video playback
        The test case spec is following:
        1. Launch photos
        2. Play video
        """
        self.videoPlayBackIteration("test_video_playback_iteration_007")

    def test_video_playback_iteration_008(self):
        """
        This test used to test Video playback
        The test case spec is following:
        1. Launch photos
        2. Play video
        """
        self.videoPlayBackIteration("test_video_playback_iteration_008")

    def test_video_playback_iteration_010(self):
        """
        This test used to test Video playback
        The test case spec is following:
        1. Launch photos
        2. Play video
        """
        self.videoPlayBackIteration("test_video_playback_iteration_010")

    def test_video_playback_iteration_011(self):
        """
        This test used to test Video playback
        The test case spec is following:
        1. Launch photos
        2. Play video
        """
        self.videoPlayBackIteration("test_video_playback_iteration_011")

    def test_video_playback_iteration_012(self):
        """
        This test used to test Video playback
        The test case spec is following:
        1. Launch photos
        2. Play video
        """
        self.videoPlayBackIteration("test_video_playback_iteration_012")

    def test_video_playback_iteration_013(self):
        """
        This test used to test Video playback
        The test case spec is following:
        1. Launch photos
        2. Play video
        """
        self.videoPlayBackIteration("test_video_playback_iteration_013")

    def test_video_playback_iteration_014(self):
        """
        This test used to test Video playback
        The test case spec is following:
        1. Launch photos
        2. Play video
        """
        self.videoPlayBackIteration("test_video_playback_iteration_014")

    def test_video_playback_iteration_015(self):
        """
        This test used to test Video playback
        The test case spec is following:
        1. Launch photos
        2. Play video
        """
        self.videoPlayBackIteration("test_video_playback_iteration_015")

    def test_video_playback_iteration_017(self):
        """
        This test used to test Video playback
        The test case spec is following:
        1. Launch photos
        2. Play video
        """
        self.videoPlayBackIteration("test_video_playback_iteration_017")

    def test_video_playback_iteration_018(self):
        """
        This test used to test Video playback
        The test case spec is following:
        1. Launch photos
        2. Play video
        """
        self.videoPlayBackIteration("test_video_playback_iteration_018")

    def test_video_playback_iteration_019(self):
        """
        This test used to test Video playback
        The test case spec is following:
        1. Launch photos
        2. Play video
        """
        self.videoPlayBackIteration("test_video_playback_iteration_019")

    def test_video_playback_iteration_021(self):
        """
        This test used to test Video playback
        The test case spec is following:
        1. Launch photos
        2. Play video
        """
        self.videoPlayBackIteration("test_video_playback_iteration_021")

    def test_video_playback_iteration_022(self):
        """
        This test used to test Video playback
        The test case spec is following:
        1. Launch photos
        2. Play video
        """
        self.videoPlayBackIteration("test_video_playback_iteration_022")

    def test_video_playback_iteration_024(self):
        """
        This test used to test Video playback
        The test case spec is following:
        1. Launch photos
        2. Play video
        """
        self.videoPlayBackIteration("test_video_playback_iteration_024")

    def test_video_playback_iteration_025(self):
        """
        This test used to test Video playback
        The test case spec is following:
        1. Launch photos
        2. Play video
        """
        self.videoPlayBackIteration("test_video_playback_iteration_025")

    def test_video_playback_iteration_026(self):
        """
        This test used to test Video playback
        The test case spec is following:
        1. Launch photos
        2. Play video
        """
        self.videoPlayBackIteration("test_video_playback_iteration_026")

    def test_video_playback_iteration_027(self):
        """
        This test used to test Video playback
        The test case spec is following:
        1. Launch photos
        2. Play video
        """
        self.videoPlayBackIteration("test_video_playback_iteration_027")

    def test_video_playback_iteration_028(self):
        """
        This test used to test Video playback
        The test case spec is following:
        1. Launch photos
        2. Play video
        """
        self.videoPlayBackIteration("test_video_playback_iteration_028")

    def test_video_playback_iteration_029(self):
        """
        This test used to test Video playback
        The test case spec is following:
        1. Launch photos
        2. Play video
        """
        self.videoPlayBackIteration("test_video_playback_iteration_029")

    def test_video_playback_iteration_030(self):
        """
        This test used to test Video playback
        The test case spec is following:
        1. Launch photos
        2. Play video
        """
        self.videoPlayBackIteration("test_video_playback_iteration_030")

    def test_video_playback_iteration_031(self):
        """
        This test used to test Video playback
        The test case spec is following:
        1. Launch photos
        2. Play video
        """
        self.videoPlayBackIteration("test_video_playback_iteration_031")

    def test_video_playback_iteration_032(self):
        """
        This test used to test Video playback
        The test case spec is following:
        1. Launch photos
        2. Play video
        """
        self.videoPlayBackIteration("test_video_playback_iteration_032")

    def test_video_playback_iteration_033(self):
        """
        This test used to test Video playback
        The test case spec is following:
        1. Launch photos
        2. Play video
        """
        self.videoPlayBackIteration("test_video_playback_iteration_033")

    def test_video_playback_iteration_034(self):
        """
        This test used to test Video playback
        The test case spec is following:
        1. Launch photos
        2. Play video
        """
        self.videoPlayBackIteration("test_video_playback_iteration_034")

    def test_video_playback_iteration_035(self):
        """
        This test used to test Video playback
        The test case spec is following:
        1. Launch photos
        2. Play video
        """
        self.videoPlayBackIteration("test_video_playback_iteration_035")

    def test_video_playback_iteration_036(self):
        """
        This test used to test Video playback
        The test case spec is following:
        1. Launch photos
        2. Play video
        """
        self.videoPlayBackIteration("test_video_playback_iteration_036")

    def test_video_playback_iteration_037(self):
        """
        This test used to test Video playback
        The test case spec is following:
        1. Launch photos
        2. Play video
        """
        self.videoPlayBackIteration("test_video_playback_iteration_037")

    def test_video_playback_iteration_038(self):
        """
        This test used to test Video playback
        The test case spec is following:
        1. Launch photos
        2. Play video
        """
        self.videoPlayBackIteration("test_video_playback_iteration_038")

    def test_video_playback_iteration_039(self):
        """
        This test used to test Video playback
        The test case spec is following:
        1. Launch photos
        2. Play video
        """
        self.videoPlayBackIteration("test_video_playback_iteration_039")

    def test_video_playback_iteration_040(self):
        """
        This test used to test Video playback
        The test case spec is following:
        1. Launch photos
        2. Play video
        """
        self.videoPlayBackIteration("test_video_playback_iteration_040")

    def test_video_playback_iteration_041(self):
        """
        This test used to test Video playback
        The test case spec is following:
        1. Launch photos
        2. Play video
        """
        self.videoPlayBackIteration("test_video_playback_iteration_041")

    def test_video_playback_iteration_042(self):
        """
        This test used to test Video playback
        The test case spec is following:
        1. Launch photos
        2. Play video
        """
        self.videoPlayBackIteration("test_video_playback_iteration_042")

    def test_video_playback_iteration_043(self):
        """
        This test used to test Video playback
        The test case spec is following:
        1. Launch photos
        2. Play video
        """
        self.videoPlayBackIteration("test_video_playback_iteration_043")

    def test_video_playback_iteration_044(self):
        """
        This test used to test Video playback
        The test case spec is following:
        1. Launch photos
        2. Play video
        """
        self.videoPlayBackIteration("test_video_playback_iteration_044")

    def test_video_playback_iteration_045(self):
        """
        This test used to test Video playback
        The test case spec is following:
        1. Launch photos
        2. Play video
        """
        self.videoPlayBackIteration("test_video_playback_iteration_045")

    def test_video_playback_iteration_046(self):
        """
        This test used to test Video playback
        The test case spec is following:
        1. Launch photos
        2. Play video
        """
        self.videoPlayBackIteration("test_video_playback_iteration_046")
Пример #22
0
class VideoAPITest(TestCaseBase):
    """
    @summary: Test Video PlayBack
    """
    def setUp(self):
        """
        @summary: set up
        @return: None
        """
        super(VideoAPITest, self).setUp()
        self.d = g_common_obj.get_device()
        self._test_name = __name__
        self.x = self.d.info["displayWidth"]
        self.y = self.d.info["displayHeight"]
        print "[Setup]: %s" % self._test_name
        g_common_obj.stop_app_am(
            "videoplayer.app.instrument.otc.intel.com.otcvideoplayer")
        # Unlock screen
        g_common_obj.adb_cmd_capture_msg("input keyevent 82")
        self.cfg_file = os.path.join(os.environ.get('TEST_DATA_ROOT', ''), \
                                'tests.tablet.mum_auto_video.conf')

        self.multimedia_setting = MultiMediaSetting(self.cfg_file)
        self.hardware = self.multimedia_setting.get_paltform_hardware()
        self.tag = "[Decode API] "

    def tearDown(self):
        """
        @summary: tear tearDown
        @return: None
        """
        super(VideoAPITest, self).tearDown()
        print "[Teardown]: %s" % self._test_name
        g_common_obj.stop_exp_handle()
        time.sleep(3)
        g_common_obj.stop_app_am(
            "videoplayer.app.instrument.otc.intel.com.otcvideoplayer")
        time.sleep(3)

    def appPrepare(self, case_name, model=1):
        # cfg_file = os.path.join(os.environ.get('TEST_DATA_ROOT', ''), \
        #     'tests.tablet.mum_auto_video.conf')
        self.video = PhotosImpl(\
            self.config.read(self.cfg_file, case_name))
        g_common_obj.adb_cmd_capture_msg(" rm -rf /sdcard/DCIM/Camera/*")

        self.multimedia_handle = MultiMediaHandle()
        # self.multimedia_setting = MultiMediaSetting(cfg_file)
        self.multimedia_setting.clearFolder(self.video.cfg.get("remove_video"))
        time.sleep(2)
        if model == 1:
            self.push_path = self.multimedia_setting.push_file(
                self.video.cfg.get("push_video"),
                self.video.cfg.get("datapath"))

        self.multimedia_setting.install_apk("video_apk")
        self.multimedia_setting.install_apk("alarm_apk")

        self.video.set_orientation_n()
        # Unlock screen
        g_common_obj.adb_cmd_capture_msg("input keyevent 82")

    def setTimeToSec(self, time):
        time = time.split(":")
        i = 1
        temp = 0
        for s in time[::-1]:
            temp += int(s) * i
            i *= 60
        return int(temp)

    def setRotation(self, mode):
        self.d(className="android.widget.ImageButton").click()
        time.sleep(1)
        self.d(text=mode).click()
        time.sleep(1)

    def videoPlayBack(self, push_path=""):
        if push_path == "":
            push_path = self.push_path
        return self.multimedia_handle.videoPlayBack(push_path)

    def streamingVideoPlayBack(self, path="", flag=1):
        if path == "":
            path = self.video.cfg.get("video_path")
        return self.multimedia_handle.streamingVideoPlayBack(path, flag)

    def checkVideoPlayBack(self, s=30):
        return self.multimedia_handle.checkVideoPlayBack(s)

    def checkVideoPlayBackWithComparePicture(self,
                                             stoptime,
                                             bigfileskiptime=0):
        return self.multimedia_handle.checkVideoPlayBackWithComparePicture(
            stoptime, bigfileskiptime)

    def checkVideoPlayBackComplete(self, s=900):
        tt = -1
        for _ in range(s / 10):
            time.sleep(10)
            if self.d(textContains="Completed").exists:
                return
            else:
                try:
                    if tt == -1:
                        for _ in range(10):
                            if self.d(resourceId="android:id/time").exists:
                                break
                            self.d.click(self.x / 2, self.y / 2)
                        tt = self.d(resourceId="android:id/time").text
                        tt = self.setTimeToSec(tt)
                    for _ in range(10):
                        if self.d(resourceId="android:id/time_current").exists:
                            break
                        self.d.click(self.x / 2, self.y / 2)
                    ct = self.d(resourceId="android:id/time_current").text
                    ct = self.setTimeToSec(ct)
                except Exception as e:
                    if self.d(textContains="Completed").exists:
                        return
                    else:
                        assert False, e
                if ct == tt:
                    assert not self.d(
                        textContains="error").exists or not self.d(
                            textContains="fail"
                        ).exists, "Play back error! please check it."
                    return

    def checkVideoNotSupport(self, s=60):
        for _ in range(s):
            if self.d(text="Can't play this video.").exists:
                return
            assert not self.d(
                resourceId="android:id/time_current").exists and not self.d(
                    resourceId="android:id/time").exists, "error!can play it!"
            time.sleep(1)
            self.d.click(self.x / 2, self.y / 2)

    def testVideoPlayBack(self, case_name):
        assert MultiMediaBasicTestCase().testVideoPlayBack(
            case_name), 'video play failed'

    def testVideoPlayBackAudio(self, case_name):
        assert MultiMediaBasicTestCase().testVideoPlayBack(
            case_name, check_hang=False), 'video play failed'

    def testVideoPlayBackViaVLC(self, case_name, change_file_flag=False):
        MultiMediaBasicTestCase().testVideoPlayBackViaVLC(
            case_name, change_file_flag)

    def testVideoPlayBackViaGallery(self, case_name):
        MultiMediaBasicTestCase().testVideoPlayBackViaGallery(case_name)

    def testVideoPlayBackLongIteration(self, case_name):
        MultiMediaBasicTestCase().testVideoPlayBackLongIterationTimes(
            case_name)

    def testVideoPlayBackWithManyTimes(self, case_name):
        print "run case is " + str(case_name)
        self.appPrepare(case_name)
        self.multimedia_handle.launchVideoApp()
        assert self.checkVideoPlayBack(), 'video play failed'
        time.sleep(2)
        for _ in range(100):
            self.videoPlayBack()
            self.checkVideoPlayBack()
            self.d.press("back")
            time.sleep(2)
        print "case " + str(case_name) + " is pass"

    def testVideoPlayBackWithManyTimes_ASP_file(self, case_name):
        print "run case is " + str(case_name)
        self.appPrepare(case_name)
        self.multimedia_handle.launchVideoApp()
        time.sleep(2)
        for _ in range(20):
            self.videoPlayBack()
            assert self.checkVideoPlayBack(), "video play failed"
            self.d.press("back")
            self.d.press("back")
            time.sleep(2)
            if not self.d(textContains="OtcVideoPlayer").exists:
                self.multimedia_handle.launchVideoApp()
        self.push_path = self.multimedia_setting.push_file(
            self.video.cfg.get("push_video_2"), self.video.cfg.get("datapath"))
        for _ in range(20):
            self.videoPlayBack()
            assert self.checkVideoPlayBack(), "video play failed"
            self.d.press("back")
            self.d.press("back")
            time.sleep(2)
            if not self.d(textContains="OtcVideoPlayer").exists:
                self.multimedia_handle.launchVideoApp()
        print "case " + str(case_name) + " is pass"

    def interuptionVideoPlayBackSwitchHome(self, case_name):
        print "run case is " + str(case_name)
        self.appPrepare(case_name)
        self.multimedia_handle.launchVideoApp()
        time.sleep(2)
        self.videoPlayBack()
        self.checkVideoPlayBack()
        time.sleep(1)
        self.d.press.home()
        self.multimedia_setting.click_recent_app("OtcVideoPlayer")
        time.sleep(1)
        self.checkVideoPlayBack()
        print "case " + str(case_name) + " is pass"

    def testStreamingVideoPlayBack(self, case_name):
        MultiMediaBasicTestCase().testStreamingVideoPlayBack(case_name)

    def interuptionStreamingVideoPlayBackSwitchHome(self, case_name):
        print "run case is " + str(case_name)
        self.appPrepare(case_name, 2)
        self.multimedia_handle.launchVideoApp()
        time.sleep(2)
        self.streamingVideoPlayBack()
        assert self.checkVideoPlayBack(), "Video play failed"
        time.sleep(1)
        self.d.press.home()
        self.multimedia_setting.click_recent_app("OtcVideoPlayer")
        time.sleep(1)
        self.checkVideoPlayBack()
        print "case " + str(case_name) + " is pass"

    def videoPlayControlProcess(self, case_name):
        logger.debug(self.tag + 'run case name is ' +
                     sys._getframe().f_back.f_code.co_name)
        MultiMediaBasicTestCase().videoPlayControlProcess(case_name)

    def videoPlayVP8CodecProcess(self, case_name):
        logger.debug(self.tag + 'run case name is ' +
                     sys._getframe().f_back.f_code.co_name)
        MultiMediaBasicTestCase().videoPlayCodecProcess(case_name,
                                                        msg='OMX.*.vp8')

    def videoPlayControlProcess_complte_pasue(self, case_name):
        assert MultiMediaBasicTestCase(
        ).videoPlayControlProcess_Complete_pasue(case_name)

    def videoPlayControlProcessWithVolume(self, case_name):
        print "run case is " + str(case_name)
        self.appPrepare(case_name)
        self.multimedia_handle.launchVideoApp()
        time.sleep(2)
        self.videoPlayBack()
        assert self.checkVideoPlayBack(), "video play failed"
        self.multimedia_setting.set_play_time(0.5)
        assert self.checkVideoPlayBack(), "video play failed"
        self.multimedia_handle.clickOtcVideoPlayer_Control(
            resourceId="android:id/rew")
        self.multimedia_handle.clickOtcVideoPlayer_Control(
            resourceId="android:id/ffwd")
        self.multimedia_setting.set_play_time_with_swipe(0.2)
        assert self.checkVideoPlayBack(), "video play failed"
        self.multimedia_handle.clickOtcVideoPlayer_Control(
            resourceId="android:id/pause")
        self.d.press.volume_up()
        self.checkVideoPlayBack()
        self.d.press.volume_down()
        assert self.checkVideoPlayBack(), "video play failed"
        print "case " + str(case_name) + " is pass"

    def videoDecodeSecondDisplay(self, case_name):
        logger.debug(self.tag + 'run case name is ' +
                     sys._getframe().f_back.f_code.co_name)
        self.appPrepare(case_name)
        g_common_obj.adb_cmd_capture_msg('am force-stop com.android.gallery3d')
        assert self.checkSecondDisplay(
        ), 'Cannot find the second display screen'
        assert self.playVideoSecondDisplay(
            self.push_path), 'cannot launch the video'
        g_common_obj.adb_cmd_capture_msg('am force-stop com.android.gallery3d')
        assert self.playVideoMainDisplay(
            self.push_path), 'cannot launch the video'
        logger.debug(self.tag + 'run case ' +
                     sys._getframe().f_back.f_code.co_name + ' is pass')

    def checkSecondDisplay(self):
        """
        check the DUT has two display screen
        :return: True, has two display screen
        """
        display2_out = g_common_obj.adb_cmd_capture_msg(
            "dumpsys |grep mExternalTouchViewport")
        if 'valid=false' in display2_out:
            logger.warning(self.tag +
                           "Cannot find the second display screen:%s" %
                           display2_out)
            return False
        else:
            logger.debug(self.tag + "The second display screen exits.")
            return True

    def playVideoSecondDisplay(self, file_path):
        """
        Play the video using the second display in Gallery
        :return: True, launch success
        """
        g_common_obj.adb_cmd_common("logcat -c")
        play_cmd = 'am start --display 1 -a android.intent.action.VIEW -d "file://%s" -t "video/*" -n com.android.gallery3d/.app.MovieActivity' % file_path
        g_common_obj.adb_cmd_capture_msg(play_cmd)
        time.sleep(5)
        gallery_play_act = 'com.android.gallery3d/com.android.gallery3d.app.MovieActivity'
        display1_surface = g_common_obj.adb_cmd_capture_msg(
            "dumpsys SurfaceFlinger|grep  -A10 'Display 0 HWC layers' ")
        display2_surface = g_common_obj.adb_cmd_capture_msg(
            "dumpsys SurfaceFlinger|grep  -A10 'Display 1 HWC layers' ")
        logger.debug(
            self.tag +
            "Video play failed, display1_surface:\n {0},\ndisplay2_surface:\n{1}"
            .format(display1_surface, display2_surface))
        if gallery_play_act not in display1_surface and gallery_play_act in display2_surface:
            logger.debug(self.tag + "Video play in the second display")
        else:
            logger.debug(self.tag + "Video play failed")
            return False
        # check video play
        return self.checkVideoInfoFromLogcat()

    def playVideoMainDisplay(self, file_path):
        """
        Play the video using the second display in Gallery
        :return: True, launch success
        """
        g_common_obj.adb_cmd_common("logcat -c")
        play_cmd = 'am start --display 0 -a android.intent.action.VIEW -d "file://%s" -t "video/*" -n com.android.gallery3d/.app.MovieActivity' % file_path
        g_common_obj.adb_cmd_capture_msg(play_cmd)
        time.sleep(6)
        gallery_play_act = 'com.android.gallery3d/com.android.gallery3d.app.MovieActivity'
        display1_surface = g_common_obj.adb_cmd_capture_msg(
            "dumpsys SurfaceFlinger|grep  -A10 'Display 0 HWC layers' ")
        display2_surface = g_common_obj.adb_cmd_capture_msg(
            "dumpsys SurfaceFlinger|grep  -A10 'Display 1 HWC layers' ")
        logger.debug(
            self.tag +
            "Video play failed, display1_surface:\n {0} \ndisplay2_surface:\n{1}"
            .format(display1_surface, display2_surface))
        if gallery_play_act in display1_surface and gallery_play_act in display2_surface:
            logger.debug(self.tag + "Video play in the main display")
        else:
            logger.debug(self.tag + "Video play failed")
            return False
        return self.checkVideoInfoFromLogcat()

    def checkVideoInfoFromLogcat(self):
        hardware_decode_msg = g_common_obj.adb_cmd_capture_msg(
            "logcat -d |grep 'I libva'")
        ur_decode_msg = g_common_obj.adb_cmd_capture_msg(
            "logcat -d |grep 'OMXMaster: makeComponentInstance'")
        logger.debug(
            self.tag +
            "Video play failed, hardware_decode_msg:\n {0},\nur_decode_msg:\n{1}"
            .format(hardware_decode_msg, ur_decode_msg))
        if not hardware_decode_msg and not ur_decode_msg:
            logger.debug(
                self.tag +
                "cannot find the libva or OMXMaster, video play abnormal")
            return False
        else:
            return True

    def testVideoNotSupport(self, case_name):
        print "run case is " + str(case_name)
        self.appPrepare(case_name, 2)
        self.multimedia_handle.launchVideoApp()
        time.sleep(2)
        self.streamingVideoPlayBack(flag=2)
        self.checkVideoNotSupport()
        print "case " + str(case_name) + " is pass"

    def testPlayback_VP8_640x480_20fps_Vorbis_48KHz_192Kbps_mkv_check_pause_resume_seek_rotate_sleep(
            self):
        """
        This test used to test Video playback
        The test case spec is following:
        1. Launch play video app
        2. Play video
        """
        self.videoPlayControlProcess("test_API_video_playback_033")

    def testPlayback_H264_MP_1080P_60fps_50Mbps_AAC_LC_48KHz_320Kbps_mp4_check_pause_resume_seek_rotate_sleep(
            self):
        """
        This test used to test Video playback
        The test case spec is following:
        1. Launch play video app
        2. Play video
        """
        self.videoPlayControlProcess("test_API_video_playback_034")

    def testPlayback_H264_HP_1080P_60fps_50Mbps_AAC_LC_48KHz_320Kbps_mp4_check_pause_resume_seek_rotate_sleep(
            self):
        """
        This test used to test Video playback
        The test case spec is following:
        1. Launch play video app
        2. Play video
        """
        self.videoPlayControlProcess("test_API_video_playback_035")

    def testPlayback_H264_BP_1080P_60fps_50Mbps_AAC_LC_48KHz_320Kbps_mp4_check_pause_resume_seek_rotate_sleep(
            self):
        """
        This test used to test Video playback
        The test case spec is following:
        1. Launch play video app
        2. Play video
        """
        self.videoPlayControlProcess("test_API_video_playback_036")

    def testh265_HEVC_With_10Bit_2160P_30Fps(self):
        """
        This test used to test Video playback
        The test case spec is following:
        1. Launch play video app
        2. Play video
        """
        self.videoPlayControlProcess_complte_pasue(
            "test_API_video_playback_128")

    def testh265_HEVC_With_10Bit_1080p_30Fps_8Mbps(self):
        """
        This test used to test Video playback
        The test case spec is following:
        1. Launch play video app
        2. Play video
        """
        self.videoPlayControlProcess_complte_pasue(
            "test_API_video_playback_129")

    def testh265_HEVC_With_10Bit_2160P_30Fps_60Mbps(self):
        """
        This test used to test Video playback
        The test case spec is following:
        1. Launch play video app
        2. Play video
        """
        self.videoPlayControlProcess_complte_pasue(
            "test_API_video_playback_130")

    def testCheck_SeparateCard_for_each_apps_with_multi_tasking(self):
        """
        This test used to test Video playback
        The test case spec is following:
        1. Launch play video app
        2. Switch to Home, then back from Home
        """
        self.interuptionVideoPlayBackSwitchHome("test_API_video_playback_038")

    def testPlay_H263_MP4_container(self):
        """
        This test used to test Video playback
        The test case spec is following:
        1. Launch play video app
        2. Play video
        """
        self.testVideoPlayBack("test_API_video_playback_043")

    def testSHALL_support_m4v_extension_MP4_video_file(self):
        """
        This test used to test Video playback
        The test case spec is following:
        1. Launch play video app
        2. Play video
        """
        self.videoPlayControlProcessWithVolume("test_API_video_playback_045")

    def testPlaying_streaming_Music_Home(self):
        """
        This test used to test Video playback
        The test case spec is following:
        1. Launch play video app
        2. Switch to Home, then back from Home
        """
        self.interuptionStreamingVideoPlayBackSwitchHome(
            "test_API_video_playback_058")

    def testSupport_native_display_resolution_FWVGA_854x480_30fps(self):
        """
        This test used to test Video playback
        The test case spec is following:
        1. Launch play video app
        2. Play video
        """
        self.testVideoPlayBack("test_API_video_playback_074")

    def testPlayback_H263_3GPv5_L1_0_BP_QCIF_15fps_AMR_WB_256kb_16KHz(self):
        """
        This test used to test Video playback
        The test case spec is following:
        1. Launch play video app
        2. Play video
        """
        self.testVideoPlayBack("test_API_video_playback_075")

    def testPlayback_H264_Level1_0_Main_Profile_QCIF_176x144_10fps_AAC_Multimedia_96kb_48KHz(
            self):
        """
        This test used to test Video playback
        The test case spec is following:
        1. Launch play video app
        2. Play video
        """
        self.testVideoPlayBack("test_API_video_playback_076")

    def testIterative_video_playback_H264_HP_1080P_60fps_50Mbps_AAC_LC_48KHz_320Kbps_mp4_iteratively(
            self):
        """
        This test used to test Video playback
        The test case spec is following:
        1. Launch play video app
        2. Play video
        """
        self.testVideoPlayBackLongIteration("test_API_video_playback_077")

    def testPlayback_H264_Level4_0_Main_Profile_HD_1920x1080_30fps_AAC_Multimedia_128kb_48KHz_and_pause_resume(
            self):
        """
        This test used to test Video playback
        The test case spec is following:
        1. Launch play video app
        2. Play video
        """
        self.testVideoPlayBack("test_API_video_playback_078")

    def testH263_352_288_30fps_858kbps_No_Audio_mp4(self):
        """
        This test used to test Video playback
        The test case spec is following:
        1. Launch play video app
        2. Play video
        """
        self.testVideoPlayBack("test_API_video_playback_079")

    def testH263_Level20_Sub_QCIF_30fps_128_KbS(self):
        """
        This test used to test Video playback
        The test case spec is following:
        1. Launch play video app
        2. Play video
        """
        self.testVideoPlayBack("test_API_video_playback_080")

    def testPlay_H263_20F_QQVGA_AMRNB_12_2k(self):
        """
        This test used to test Video playback
        The test case spec is following:
        1. Launch play video app
        2. Play video
        """
        self.testVideoPlayBack("test_API_video_playback_131")

    def testPlayback_VP8_CIF_25fps_Vorbis_44_1KHz_128kbps_webm_iteratively(
            self):
        """
        This test used to test Video playback
        The test case spec is following:
        1. Launch play video app
        2. Play video
        """
        self.testVideoPlayBackLongIteration("test_API_video_playback_081")

    def testVideo_H264_29_970fps_5mn29s_640x480_MP4_RTP_streaming(self):
        """
        This test used to test Video playback
        The test case spec is following:
        1. Launch play video app
        2. Play video
        """
        self.testStreamingVideoPlayBack("test_API_video_playback_088")

    def testPlayback_MP4_h264_HiP_4_0_1080p_30FPS_25Mbps_AAC_LC_48KHz_256Kbps_1Min_179MB_BBB_mp4(
            self):
        """
        This test used to test Video playback
        The test case spec is following:
        1. Launch play video app
        2. Play video
        """
        self.videoPlayControlProcessWithVolume("test_API_video_playback_101")

    def testPlayback_MPEG4_ASP_1080P_30fps_6Mbps_AAC_LC_48KHz_128Kbps(self):
        """
        This test used to test Video playback
        The test case spec is following:
        1. Launch play video app
        2. Play video
        """
        self.testVideoPlayBack("test_API_video_playback_111")

    def testPlayback_MPEG4_ASP_Lv5_720X480_30fps_AAC_ST_160kbp_48KHZ(self):
        """
        This test used to test Video playback
        The test case spec is following:
        1. Launch play video app
        2. Play video
        """
        self.testVideoPlayBack("test_API_video_playback_112")

    def testPlayback_MPEG4_SP_and_MEPG4_ASP_Continuously(self):
        """
        This test used to test Video playback
        The test case spec is following:
        1. Launch play video app
        2. Play video
        """
        self.testVideoPlayBackWithManyTimes_ASP_file(
            "test_API_video_playback_114")

    def testCorrupt_File_Playback(self):
        """
        This test used to test Video playback
        The test case spec is following:
        1. Launch play video app
        2. Play video
        """
        self.testVideoNotSupport("test_API_video_playback_115")

    def testPlayback_MPEG4_ASP_Lv0_176X144_30fps_AAC_Plus_ST_64kbp_32KHz(self):
        """
        This test used to test Video playback
        The test case spec is following:
        1. Launch play video app
        2. Play video
        """
        self.testVideoPlayBack("test_API_video_playback_116")

    def testH264_480X320_Playback(self):
        """
        This test used to test Video playback
        The test case spec is following:
        1. Launch play video app
        2. Play video
        """
        self.testVideoPlayBack("test_API_video_playback_118")

    def testH264_854x480_Playback(self):
        """
        This test used to test Video playback
        The test case spec is following:
        1. Launch play video app
        2. Play video
        """
        self.testVideoPlayBack("test_API_video_playback_119")

    def testH265_480X320_Playback(self):
        """
        This test used to test Video playback
        The test case spec is following:
        1. Launch play video app
        2. Play video
        """
        self.testVideoPlayBack("test_API_video_playback_120")

    def testH265_854x480_Playback(self):
        """
        This test used to test Video playback
        The test case spec is following:
        1. Launch play video app
        2. Play video
        """
        self.testVideoPlayBack("test_API_video_playback_121")

    def testh265_simple_10bit_lowbitrat_mkv(self):
        """
            This test used to test Video playback
            The test case spec is following:
            1. Launch VLC app
            2. Play video
            """
        self.testVideoPlayBackViaVLC("test_API_video_playback_140")

    def testh265_HEVC_With_10Bit_medium_mp4(self):
        """
            This test used to test Video playback
            The test case spec is following:
            1. Launch VLC app
            2. Play video
            """
        self.testVideoPlayBackViaVLC("test_API_video_playback_141")

    def testVideo_Playback_MPEG4_SPL0_QCIF_176x144_15Fps(self):
        """
            This test used to test Video playback
            The test case spec is following:
            1. Launch VLC app
            2. Play video
            """
        if self.hardware == "gordon_peak":
            self.testVideoPlayBackViaGallery("test_API_video_playback_142")
        elif self.hardware in ["androidia_64", "r2_cht_mrd"]:
            self.testVideoPlayBack("test_API_video_playback_142")
        else:
            self.testVideoPlayBackViaVLC("test_API_video_playback_142")

    def testPlayback_H264_4K_External_Storage(self):
        """
            This test used to test Video playback
            The test case spec is following:
            1. Launch VLC app
            2. Play video
            """
        if self.hardware in ["androidia_64", "r2_cht_mrd"]:
            self.testVideoPlayBack("test_API_video_playback_143")
        else:
            self.testVideoPlayBackViaVLC("test_API_video_playback_143",
                                         change_file_flag=True)

    def testVideo_Playback_DIVX5_720p_30Fps(self):
        """
        This test used to test DIVX Video playback
        he test case spec is following:
        1. Launch VLC app
        2. Play video
        """
        self.testVideoPlayBackViaVLC("test_API_video_playback_144")

    def testVideo_Playback_DIVX6_1080p_23Fps(self):
        """
        This test used to test DIVX Video playback
        he test case spec is following:
        1. Launch VLC app
        2. Play video
        """
        self.testVideoPlayBackViaVLC("test_API_video_playback_145")

    def testVideo_Playback_Xvid_960x720_30Fps(self):
        """
        This test used to test DIVX Video playback
        he test case spec is following:
        1. Launch VLC app
        2. Play video
        """
        self.testVideoPlayBackViaVLC("test_API_video_playback_153")

    def testVP8_480X320_Playback(self):
        """
        This test used to test Video playback
        The test case spec is following:
        1. Launch play video app
        2. Play video
        """
        self.testVideoPlayBack("test_API_video_playback_122")

    def testVP8_854x480_Playback(self):
        """
        This test used to test Video playback
        The test case spec is following:
        1. Launch play video app
        2. Play video
        """
        self.testVideoPlayBack("test_API_video_playback_123")

    def testVP8_HW_4K_Decode(self):
        """
        This test used to test Video playback
        The test case spec is following:
        1. Launch play video app
        2. Play video
        """
        self.videoPlayVP8CodecProcess("test_API_video_playback_151")

    def testVP9_480X320_Playback(self):
        """
        This test used to test Video playback
        The test case spec is following:
        1. Launch play video app
        2. Play video
        """
        self.testVideoPlayBack("test_API_video_playback_124")

    def testVP9_854x480_Playback(self):
        """
        This test used to test Video playback
        The test case spec is following:
        1. Launch play video app
        2. Play video
        """
        self.testVideoPlayBack("test_API_video_playback_125")

    def testMPEG4_480X320_Playback(self):
        """
        This test used to test Video playback
        The test case spec is following:
        1. Launch play video app
        2. Play video
        """
        self.testVideoPlayBack("test_API_video_playback_126")

    def testMPEG4_854x480_Playback(self):
        """
        This test used to test Video playback
        The test case spec is following:
        1. Launch play video app
        2. Play video
        """
        self.testVideoPlayBack("test_API_video_playback_127")

    def testVideo_Playback_H264_HP_1408x1152_Ts_Pause_Resume_Rotate_Sleep(
            self):
        """
            This test used to test Video playback
            The test case spec is following:
            1. Launch play video app
            2. Play video and check
            3. rotate screen and press power key to suspeng/resume
        """
        self.videoPlayControlProcess("test_video_playback_031")

    def testVideo_Playback_H264_1080P_Ts_Pause_Resume_Rotate_Sleep(self):
        """
            This test used to test Video playback
            The test case spec is following:
            1. Launch play video app
            2. Play video and check
            3. rotate screen and press power key to suspeng/resume
        """
        self.videoPlayControlProcess("test_API_video_playback_146")

    def testVideo_Playback_H264_1080_Mkv_Local(self):
        """
            This test used to test Video playback
            The test case spec is following:
            1. Launch play video app
            2. Play video and check
            3. rotate screen and press power key to suspeng/resume
        """
        self.videoPlayControlProcess("test_API_video_playback_154")

    def testVideo_Playback_HEAAC_V2_Mp4(self):
        """
            This test used to test Video playback
            The test case spec is following:
            1. Launch play video app
            2. Play video and check
        """
        self.testVideoPlayBackAudio("test_API_video_playback_152")

    def testVideo_Playback_Mp3_Mkv(self):
        """
            This test used to test Video playback
            The test case spec is following:
            1. Launch play video app
            2. Play video and check
        """
        self.testVideoPlayBackAudio("test_video_playback_110")

    def testVideo_Playback_MPEG4_SPL2_QVGA_15Fps(self):
        """
            This test used to test Video playback
            The test case spec is following:
            1. Launch play video app
            2. Play video and check
            3. rotate screen and press power key to suspeng/resume
        """
        self.videoPlayControlProcess("test_video_playback_015")

    def testVideo_Playback_MPEG4_SP_VGA_30Fps(self):
        """
            This test used to test Video playback
            The test case spec is following:
            1. Launch play video app
            2. Play video and check
            3. rotate screen and press power key to suspeng/resume
        """
        self.videoPlayControlProcess("test_video_playback_098")

    def testVideo_Playback_MPEG4_SP2_CIF_3gp(self):
        """
            This test used to test Video playback
            The test case spec is following:
            1. Launch play video app
            2. Play video and check
            3. rotate screen and press power key to suspeng/resume
        """
        self.videoPlayControlProcess("test_video_playback_101")

    def testVideo_Playback_MPEG4_SP1_CIF(self):
        """
            This test used to test Video playback
            The test case spec is following:
            1. Launch play video app
            2. Play video and check
            3. rotate screen and press power key to suspeng/resume
        """
        self.videoPlayControlProcess("test_API_video_playback_132")

    def testVideo_Decode_Second_Display_H264_1080P(self):
        """
            This test used to test Video playback
            The test case spec is following:
            1. Connect two screen.
            2. Play video on the second screen.
        """
        self.videoDecodeSecondDisplay("test_API_video_playback_147")

    def testVideo_Decode_Second_Display_VP8_720P(self):
        """
            This test used to test Video playback
            The test case spec is following:
            1. Connect two screen.
            2. Play video on the second screen.
        """
        self.videoDecodeSecondDisplay("test_API_video_playback_148")

    def testVideo_Decode_Second_Display_MPEG4_480P(self):
        """
            This test used to test Video playback
            The test case spec is following:
            1. Connect two screen.
            2. Play video on the second screen.
        """
        self.videoDecodeSecondDisplay("test_video_playback_017")

    def testVideo_Decode_Second_Display_H264_720P_60fps(self):
        """
            This test used to test Video playback
            The test case spec is following:
            1. Connect two screen.
            2. Play video on the second screen.
        """
        self.videoDecodeSecondDisplay("test_API_video_playback_149")

    def testVideo_Decode_Second_Display_H265_480x360(self):
        """
            This test used to test Video playback
            The test case spec is following:
            1. Connect two screen.
            2. Play video on the second screen.
        """
        self.videoDecodeSecondDisplay("test_API_video_playback_150")