Exemple #1
0
 def appPrepare(self,):
     self.camera = RefCam2Camera()
     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.logger.debug("app prepare successfully")
Exemple #2
0
 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")
Exemple #3
0
    def appPrepare(self,):
#         cfg_file = os.path.join(os.environ.get('TEST_DATA_ROOT', ''), \
#             'tests.testplan.camera.conf')
#         current_platform = CameraCommon().getPlatform()
#         self.camera = GMSCamera(self.config.read(cfg_file, "multimedia_camera"))
        #self.camera = ArcSoftCamera(self.config.read(cfg_file, "multimedia_camera"))
        self.camera = CameraCommon().switchPlatform()
        self.multimedia_setting = MultiMediaSetting(CameraCommon().DEFAULT_CONFIG_FILE)
        self.video = CheckVideo()
        self.checkImage = CheckImage()
        self.deviceControl = DeviceControl()
        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 test_camera_with_scroll(self):
     self.case_result = 1
     self.multimedia_scroll_helper = MultiMediaScrollHelper()
     time.sleep(1)
     self.multimedia_scroll_helper.reset()
     my_input()
     self.set_lightbox_operation(light_port_list=[
         "Power", "F", "D65", "TL84", "UV", "CWF", "TL83/U30", "F", "D65",
         "TL84", "UV", "TL83/U30"
     ],
                                 position=210,
                                 pause=1)
     self.multimedia_robot_helper.rotate(-180)
     my_input()
     self.multimedia_scroll_helper.goto_page(1)
     my_input()
     self.multimedia_scroll_helper.goto_page(0)
     my_input()
     self.get_aosp_camera_class().startCameraApp()
     self.get_aosp_camera_class().capturePhoto()
     t_file = self.camera_common.getMediaFilesFromDevice(0, 1)[0]
     fisheyecorrection_folder = "/home/auto1/tmp/fisheyecorrection/fisheyecorrection/"
     subprocess.Popen("./fisheye %s" % t_file,
                      cwd=fisheyecorrection_folder,
                      shell=True)
     dest_adjusted_file = "/home/auto1/tmp/logs/adjusted.jpg"
     os.system("cp %sadjusted.jpg %s" %
               (fisheyecorrection_folder, dest_adjusted_file))
     dest_file = dest_adjusted_file if os.path.exists(
         dest_adjusted_file) else t_file
     ret = self.multimedia_checkiq_helper.check_IQ.detectRect(dest_file)
     ret = int(ret)
     self.logger.debug("detectRect ret=%s" % ret)
     ret = self.multimedia_checkiq_helper.check_IQ.getTemp(dest_file)
     #os.system("cp /home/auto1/tmp/checkiq_temp_dir/rects.jpg /home/auto1/tmp/logs/rects.jpg")
     print "==================Result==================="
     t_result = 0
     t_result += self.check_data(ret, 6200, 0.05, "check color temperature")
     ret = CheckImage().brightness(dest_file)
     t_result += self.check_data(ret, 130, 0.15, "check brightness")
     self.get_aosp_camera_class().stopCameraApp()
     self.multimedia_scroll_helper.reset()
     #         os.system("eog -s %s" % "/home/auto1/tmp/rects_adjusted.jpg")
     os.system("eog -s %s" % dest_file)
     assert t_result == 0, "check color temperature or check brightness failed! t_result=%s" % str(
         t_result)
     self.case_result = 1
Exemple #5
0
 def appPrepare(self):
     self.camera = CameraCommon().switchPlatform(None, False, True, False,
                                                 True)
     #         self.camera = RefCam2Camera()
     self.common = CameraCommon()
     self.multimedia_setting = MultiMediaSetting(
         CameraCommon.DEFAULT_CONFIG_FILE)
     #         self.camera = self.common.switchPlatform()
     self.checkImage = CheckImage()
     self.video = CheckVideo()
     #         self.checkIQ = CheckIQ()
     self.host_path = self.common.getTmpDir()
     self.makefileTime = self.common.makefileTime
     self.camera_dir = self.common.camera_dir
     self.common.removeDeivceFile()
     self.common.removeFile(self.host_path + "/*")
     self.camera.cleanMediaFiles()
     #         self.common.setOrientationToVertical()
     self.logger.debug("app prepare successfully")
     self.device = self.common.initDevice()
     self.common.resetDevice(self.device)
Exemple #6
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()
Exemple #7
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 = RefCam2Camera()
        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.logger.debug("app prepare successfully")

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

    def defaultSizeRepeatlyTest(self, lens):
        try:
            self.appPrepare()
            self.camera.startCameraApp()
            self.camera.selectMode("Burst")
            self.camera.switchRearOrFront(lens)
            self.camera.capturePhoto(100)
            self.checkFileCorrupt()
        except Exception as e:
            CameraCommon().checkCameraCrash()
            self.assertTrue(False, e)

    def cameraBSTScreenLockTest(self, lens):
        try:
            self.appPrepare()
            self.camera.startCameraApp()
            self.camera.selectMode("Burst")
            for i in range(5):
                CameraCommon().pressPower()
                time.sleep(1)
            CameraCommon().checkCameraCrash()
        except Exception as e:
            CameraCommon().checkCameraCrash()
            self.assertTrue(False, e)

    def cameraExposureBracketEXIF(self, lens):
        try:
            self.appPrepare()
            self.camera.startCameraApp()
            self.camera.selectMode("Burst")
            self.camera.switchRearOrFront(lens)
            self.camera.setExposureBracket()
            self.camera.capturePhoto()
            self.checkFileCorrupt()
            fileNameList = CameraCommon().getFileName(self.camera_dir)
            print fileNameList
            iamge1 = self.host_path + "/" + fileNameList[0]
            iamge2 = self.host_path + "/" + fileNameList[1]
            iamge3 = self.host_path + "/" + fileNameList[2]
            image1_b = self.checkImage.brightness(iamge1)
            image2_b = self.checkImage.brightness(iamge2)
            image3_b = self.checkImage.brightness(iamge3)
            info1 = CameraCommon().getExifInfo(fileNameList[0], self.host_path + "/")
            info2 = CameraCommon().getExifInfo(fileNameList[1], self.host_path + "/")
            info3 = CameraCommon().getExifInfo(fileNameList[2], self.host_path + "/")
            ec1 = info1.get("Exposure Compensation")
            ec2 = info2.get("Exposure Compensation")
            ec3 = info3.get("Exposure Compensation")
            print ec1,ec2,ec3
            self.error_msg = ""
            if ec1 != "-5":
                self.error_msg = self.error_msg + "first picture Exposure Compensation can't match -5;"
                os.system("cp " + iamge1 + " " + g_common_obj.get_user_log_dir())
            if ec2 != "0":
                self.error_msg = self.error_msg + "second picture Exposure Compensation can't match 0;"
                os.system("cp " + iamge2 + " " + g_common_obj.get_user_log_dir())
            if ec3 != "5":
                self.error_msg = self.error_msg + "third picture Exposure Compensation can't match 5;"
                os.system("cp " + iamge3 + " " + g_common_obj.get_user_log_dir())
            if not self.checkImage.compare_images_brightness(iamge1, iamge2):
                self.error_msg = self.error_msg + "-1 compare 0 exposure check fail," + \
                    "-1(" + iamge1 + ") brightness=" + str(image1_b) + ", 0(" + iamge2 + ") brightness=" + str(image2_b) + "; "
                os.system("cp " + iamge1 + " " + g_common_obj.get_user_log_dir())
                os.system("cp " + iamge2 + " " + g_common_obj.get_user_log_dir())
            if not self.checkImage.compare_images_brightness(iamge2, iamge3):
                self.error_msg = self.error_msg + "0 compare 1 exposure check fail," + \
                    "0(" + iamge2 + ") brightness=" + str(image2_b) + ", 1(" + iamge3 + ") brightness=" + str(image3_b) + "; "
                os.system("cp " + iamge2 + " " + g_common_obj.get_user_log_dir())
                os.system("cp " + iamge3 + " " + g_common_obj.get_user_log_dir())
            if self.error_msg == "":
                    self.logger.debug("exposure check successful")
            else:
                self.assertTrue(False, self.error_msg)
        except Exception as e:
            CameraCommon().checkCameraCrash()
            self.assertTrue(False, e)

    def cameraExposureBracketIterativeCaptureMaxResolution(self, lens,run_time):
        try:
            self.appPrepare()
            self.camera.startCameraApp()
            self.camera.selectMode("Burst")
            self.camera.switchRearOrFront(lens)
            self.camera.setExposureBracket()
            resolution = self.camera.getAllPhotoResolutions(lens)[1]
            self.camera.setPhotoResolution(resolution, lens)
            CameraCommon().clickScreenCenter()
            self.error_msg = ""
            for i in range(int(run_time)):
                self.logger.debug("======loop %d ======" %(i+1))
                self.camera.capturePhoto()
                time.sleep(1)
                self.checkFileCorrupt()
                fileNameList = CameraCommon().getFileName(self.camera_dir)
                print fileNameList
                iamge1 = self.host_path + "/" + fileNameList[0]
                iamge2 = self.host_path + "/" + fileNameList[1]
                iamge3 = self.host_path + "/" + fileNameList[2]
                image1_b = self.checkImage.brightness(iamge1)
                image2_b = self.checkImage.brightness(iamge2)
                image3_b = self.checkImage.brightness(iamge3)
                info1 = CameraCommon().getExifInfo(fileNameList[0], self.host_path + "/")
                info2 = CameraCommon().getExifInfo(fileNameList[1], self.host_path + "/")
                info3 = CameraCommon().getExifInfo(fileNameList[2], self.host_path + "/")
                ec1 = info1.get("Exposure Compensation")
                ec2 = info2.get("Exposure Compensation")
                ec3 = info3.get("Exposure Compensation")
                print ec1, ec2, ec3
                self.logger.debug("Exposure Compensation check,pic1 is %s,pic2 is %s, pic3 is %s" %(str(ec1),str(ec2),str(ec3)))
                if ec1 != "-5":
                    self.error_msg = self.error_msg + "first picture Exposure Compensation can't match -5;"
                    os.system("cp " + iamge1 + " " + g_common_obj.get_user_log_dir())
                if ec2 != "0":
                    self.error_msg = self.error_msg + "second picture Exposure Compensation can't match 0;"
                    os.system("cp " + iamge2 + " " + g_common_obj.get_user_log_dir())
                if ec3 != "5":
                    self.error_msg = self.error_msg + "third picture Exposure Compensation can't match 5;"
                    os.system("cp " + iamge3 + " " + g_common_obj.get_user_log_dir())
                if not self.checkImage.compare_images_brightness(iamge1, iamge2):
                    self.error_msg = self.error_msg + "-1 compare 0 exposure check fail," + \
                        "-1(" + iamge1 + ") brightness=" + str(image1_b) + ", 0(" + iamge2 + ") brightness=" + str(image2_b) + "; "
                    os.system("cp " + iamge1 + " " + g_common_obj.get_user_log_dir())
                    os.system("cp " + iamge2 + " " + g_common_obj.get_user_log_dir())
                if not self.checkImage.compare_images_brightness(iamge2, iamge3):
                    self.error_msg = self.error_msg + "0 compare 1 exposure check fail," + \
                        "0(" + iamge2 + ") brightness=" + str(image2_b) + ", 1(" + iamge3 + ") brightness=" + str(image3_b) + "; "
                    os.system("cp " + iamge2 + " " + g_common_obj.get_user_log_dir())
                    os.system("cp " + iamge3 + " " + g_common_obj.get_user_log_dir())
                CameraCommon().removeDeivceFile()
                CameraCommon().clickScreenCenter()
            if self.error_msg == "":
                    self.logger.debug("exposure check successful")
            else:
                self.assertTrue(False, self.error_msg)
        except Exception as e:
            CameraCommon().checkCameraCrash()
            self.assertTrue(False, e)

    def test_BST_Front_defaut_size_repeatly(self):
        self.defaultSizeRepeatlyTest("Front")

    def test_BST_Rear_defaut_size_repeatly(self):
        self.defaultSizeRepeatlyTest("Back")

    def test_Camera_BST_Rear_ScreenLock(self):
        self.cameraBSTScreenLockTest("Back")

    def test_Camera_BST_Front_ScreenLock(self):
        self.cameraBSTScreenLockTest("Front")

    def test_Camera_ExposureBracket_Front_EXIF(self):
        self.cameraExposureBracketEXIF("Front")

    def test_Camera_ExposureBracket_Rear_EXIF(self):
        self.cameraExposureBracketEXIF("Back")

    def test_Camera_ExposureBracket_Front_IterativeCapture_MaxResolution(self):
        self.cameraExposureBracketIterativeCaptureMaxResolution("Front", 20)

    def test_Camera_ExposureBracket_Rear_IterativeCapture_MaxResolution(self):
        self.cameraExposureBracketIterativeCaptureMaxResolution("Back", 20)
Exemple #8
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()
Exemple #9
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")
Exemple #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, mode_option=""):
        #         self.camera = ArcSoftCamera()
        #         self.multimedia_setting = MultiMediaSetting(CameraCommon.DEFAULT_CONFIG_FILE)
        self.camera = CameraCommon().switchPlatform(None, False, True, False,
                                                    True, mode_option)
        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.logger.debug("app prepare successfully")

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

    def setColorEffectNoneCaptureImageCameraTest(self, lens):
        try:
            self.appPrepare()
            self.camera.startCameraApp()
            self.camera.switchRearOrFront(lens)
            self.camera.setColorEffect("None")
            self.camera.capturePhoto()
            name1 = self.checkFileCorrupt()[1]
            image1_path = self.host_path + "/" + name1
            CameraCommon().removeDeivceFile()
            self.camera.setColorEffect("Negative")
            self.camera.capturePhoto()
            name2 = self.checkFileCorrupt()[1]
            image2_path = self.host_path + "/" + name2
            CameraCommon().removeDeivceFile()
            self.color_effect = self.checkImage.is_negative(
                image1_path, image2_path)
            self.camera.setColorEffect("None")
            self.camera.capturePhoto()
            name3 = self.checkFileCorrupt()[1]
            image3_path = self.host_path + "/" + name3
            self.color_effect2 = self.checkImage.is_negative(
                image2_path, image3_path)
            print self.color_effect, self.color_effect2
            if not (self.color_effect and self.color_effect2):
                os.system("cp " + self.host_path + "/" + name1 + " " +
                          g_common_obj.get_user_log_dir())
                os.system("cp " + self.host_path + "/" + name2 + " " +
                          g_common_obj.get_user_log_dir())
                os.system("cp " + self.host_path + "/" + name3 + " " +
                          g_common_obj.get_user_log_dir())
                self.assertTrue(False, "check color effect to none fail")
        except Exception as e:
            CameraCommon().checkCameraCrash()
            self.assertTrue(False, e)

    def cameraContinuousExitRelaunchTest(self, lens):
        try:
            self.appPrepare()
            self.camera.startCameraApp()
            for i in range(5):
                self.camera.switchRearOrFront(lens)
                self.camera.clickShutterBtnWithoutRelease("Camera", 5)
                CameraCommon().pressHome()
                self.camera.startCameraApp()
            self.checkFileCorrupt()
        except Exception as e:
            CameraCommon().checkCameraCrash()
            self.assertTrue(False, e)

    def cameraContinuousMaxoneTimeTest(self, lens):
        try:
            self.appPrepare()
            self.camera.startCameraApp()
            self.camera.switchRearOrFront(lens)
            self.camera.clickShutterBtnWithoutRelease("Camera")
            CameraCommon().checkCameraCrash()
            self.checkFileCorrupt(99)
        except Exception as e:
            CameraCommon().checkCameraCrash()
            self.assertTrue(False, e)

    def setColorEffectMonoCaptureImageCameraTest(self, lens):
        try:
            self.appPrepare()
            self.camera.startCameraApp()
            self.camera.switchRearOrFront(lens)
            self.camera.setColorEffect("Mono")
            self.camera.capturePhoto()
            name1 = self.checkFileCorrupt()[1]
            image1_path = self.host_path + "/" + name1
            self.camera.capturePhoto()
            self.is_mono = self.checkImage.is_mono(image1_path)
            if not self.is_mono:
                os.system("cp " + self.host_path + "/" + name1 + " " +
                          g_common_obj.get_user_log_dir())
                self.assertTrue(False,
                                "check camera color effect to mono fail")
        except Exception as e:
            CameraCommon().checkCameraCrash()
            self.assertTrue(False, e)

    def setColorEffectNEGATIVECaptureImageCameraTest(self, lens):
        try:
            self.appPrepare()
            self.camera.startCameraApp()
            self.camera.switchRearOrFront(lens)
            self.camera.capturePhoto()
            name1 = self.checkFileCorrupt()[1]
            image1_path = self.host_path + "/" + name1
            CameraCommon().removeDeivceFile()
            self.camera.setColorEffect("Negative")
            self.camera.capturePhoto()
            name2 = self.checkFileCorrupt()[1]
            image2_path = self.host_path + "/" + name2
            self.color_effect = self.checkImage.is_negative(
                image1_path, image2_path)
            if not self.color_effect:
                os.system("cp " + self.host_path + "/" + name1 + " " +
                          g_common_obj.get_user_log_dir())
                os.system("cp " + self.host_path + "/" + name2 + " " +
                          g_common_obj.get_user_log_dir())
                self.assertTrue(
                    False,
                    "compare %s camera color effect to negative fail" % lens)
        except Exception as e:
            CameraCommon().checkCameraCrash()
            self.assertTrue(False, e)

    def cameraHDRCaptureTest(self, lens):
        try:
            self.appPrepare("HDR")
            self.camera.startCameraApp()
            self.camera.switchRearOrFront(lens)
            self.camera.setCaptureMode("HDR")

            for t_type in ["YUV_420_888", "JPEG"]:
                self.camera.setSettingsButton("Source Format(PP)", t_type)

                for t_type in ["Capture Size (JPEG)", "Capture Size (YUV)"]:
                    self.logger.debug("type=%s" % t_type)
                    size_list, max_size, min_size = self.camera.getAllPhotoResolutions(
                        lens, t_type)
                    if max_size == -1:
                        self.logger.debug("No \"%s\" type! skip!" % t_type)
                        continue
                    for size in size_list[0], size_list[1], min_size:
                        self.logger.debug("size=%s" % size)
                        self.camera.setPhotoResolution(size, lens, t_type)
                        self.camera.capturePhoto()
                        time.sleep(3)
                        info, fileName = self.checkFileCorrupt()
                        self.logger.debug("info: %s" % info)
                        width = info.get("Image Width")
                        height = info.get("Image Height")
                        size = info.get("Image Size")
                        self.logger.debug(
                            str(width) + ", " + str(height) + ", " + str(size))
                        self.assertTrue(size == width + "x" + height,
                                        "image size is null")
                        exposure_time = info.get("Exposure Time")
                        self.logger.debug("Exposure Time: %s" % exposure_time)
                        error_msg = ""
                        if exposure_time:
                            value = exposure_time.split('/')
                            mValue = float(value[0]) / float(value[1])
                            if mValue < (1 / 2500) or mValue > 1:
                                error_msg += "check exposure time fail,actual=%s,expected=1/2500<=value<=1; " % mValue
                        else:
                            self.logger.debug("Exposure Time is not found")
                        if error_msg != "":
                            os.system("cp " + self.host_path + "/" + fileName +
                                      " " + g_common_obj.get_user_log_dir())
                            self.assertTrue(False, error_msg)
        except Exception as e:
            CameraCommon().checkCameraCrash()
            self.assertTrue(False, e)

    def cameraHDRExifTest(self, lens):
        try:
            self.appPrepare("HDR")
            self.camera.startCameraApp()
            self.camera.switchRearOrFront(lens)
            self.camera.setCaptureMode("HDR")
            for i in range(10):
                self.logger.debug("capture time: %s" % i)
                self.camera.capturePhoto()
                time.sleep(3)
                info, fileName = self.checkFileCorrupt()
                width = info.get("Image Width")
                height = info.get("Image Height")
                size = info.get("Image Size")
                self.logger.debug(
                    str(width) + ", " + str(height) + ", " + str(size))
                self.assertTrue(size == width + "x" + height,
                                "image size is null")
                exposure_time = info.get("Exposure Time")
                self.logger.debug("Exposure Time: %s" % exposure_time)
                error_msg = ""
                if exposure_time:
                    value = exposure_time.split('/')
                    mValue = float(value[0]) / float(value[1])
                    if mValue < (1 / 2500) or mValue > 1:
                        error_msg += "check exposure time fail,actual=%s,expected=1/2500<=value<=1; " % mValue
                else:
                    self.logger.debug("Exposure Time is not found")
                if error_msg != "":
                    os.system("cp " + self.host_path + "/" + fileName + " " +
                              g_common_obj.get_user_log_dir())
                    self.assertTrue(False, error_msg)
        except Exception as e:
            CameraCommon().checkCameraCrash()
            self.assertTrue(False, e)

    def cameraContinuousLowStorage(self, lens):
        try:
            self.appPrepare()
            CameraCommon().fillStorage(130)
            self.camera.startCameraApp()
            self.camera.switchRearOrFront(lens)
            self.camera.setFlash("off")
            mTime = time.time()
            while True:
                self.camera.clickShutterBtnWithoutRelease()
                time.sleep(2)
                free = CameraCommon().getSdcardMemory()[2]
                if free < 70:
                    self.logger.debug("The memory is full")
                    break
                if time.time() - mTime > 1800:
                    break
        except Exception as e:
            CameraCommon().checkCameraCrash()
            self.assertTrue(False, e)

    def cameraHDRIterativeCaptureMaxResolutionLowRAMTest(self, lens):
        try:
            self.appPrepare("HDR")
            type = "Capture Size (YUV)"
            CameraCommon().fillStorage(180)
            self.camera.startCameraApp()
            self.camera.selectMode("Camera")
            self.camera.switchRearOrFront(lens)
            self.camera.setCaptureMode("HDR")
            mResulotion = self.camera.getAllPhotoResolutions(lens, type)[1]
            self.logger.debug("max resolution is " + mResulotion)
            self.camera.setPhotoResolution(mResulotion, lens, type)
            self.camera.capturePhoto(200)
            self.checkFileCorrupt()
        except Exception as e:
            CameraCommon().checkCameraCrash()
            self.assertTrue(False, e)

    def cameraHDRIterativeExitTapHome(self, lens):
        try:
            self.appPrepare("HDR")
            self.camera.startCameraApp()
            self.camera.selectMode("Camera")
            self.camera.switchRearOrFront(lens)
            self.camera.setCaptureMode("HDR")
            self.camera.clickShutterBtnArea()
            CameraCommon().pressHome()
            CameraCommon().checkCameraCrash()
        except Exception as e:
            CameraCommon().checkCameraCrash()
            self.assertTrue(False, e)

    def cameraEffectCaptureRepeatedlyTest(self):
        try:
            self.appPrepare()
            self.camera.startCameraApp()
            self.camera.switchRearOrFront("Back")
            for i in range(2):
                self.camera.setColorEffect("None")
                self.camera.capturePhoto()
                name1 = self.checkFileCorrupt()[1]
                image1_path = self.host_path + "/" + name1
                CameraCommon().removeDeivceFile()
                self.camera.setColorEffect("Mono")
                self.camera.capturePhoto()
                name2 = self.checkFileCorrupt()[1]
                image2_path = self.host_path + "/" + name2
                CameraCommon().removeDeivceFile()
                self.is_mono = self.checkImage.is_mono(image2_path)
                if not self.is_mono:
                    os.system("cp " + self.host_path + "/" + name2 + " " +
                              g_common_obj.get_user_log_dir())
                    self.assertTrue(False,
                                    "check camera color effect to mono fail")
                self.camera.setColorEffect("Negative")
                self.camera.capturePhoto()
                name3 = self.checkFileCorrupt()[1]
                image3_path = self.host_path + "/" + name3
                CameraCommon().removeDeivceFile()
                self.color_effect2 = self.checkImage.is_negative(
                    image1_path, image3_path)
                if not self.color_effect2:
                    os.system("cp " + self.host_path + "/" + name1 + " " +
                              g_common_obj.get_user_log_dir())
                    os.system("cp " + self.host_path + "/" + name3 + " " +
                              g_common_obj.get_user_log_dir())
                    self.assertTrue(False, "check color effect to none fail")
                self.camera.switchRearOrFront("Front")
        except Exception as e:
            CameraCommon().checkCameraCrash()
            self.assertTrue(False, e)

    def cameraEffectFrontSepiarepeatlyRearFrontSwitchTest(self):
        try:
            self.appPrepare()
            self.camera.startCameraApp()
            for i in range(5):
                self.camera.switchRearOrFront("Back")
                self.camera.setColorEffect("Sepia")
                self.camera.capturePhoto()
                self.camera.checkColorEffect("Sepia")
                self.camera.switchRearOrFront("Front")
                self.camera.setColorEffect("Negative")
                self.camera.capturePhoto()
                self.camera.checkColorEffect("Negative")
            CameraCommon().checkFileCorrupt()
        except Exception as e:
            CameraCommon().checkCameraCrash()
            self.assertTrue(False, e)

    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 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 test_Camera_Effect_Front_NEGATIVE_CaptureImage(self):
        self.setColorEffectNEGATIVECaptureImageCameraTest("Front")

    def test_Camera_Effect_Rear_NEGATIVE_CaptureImage(self):
        self.setColorEffectNEGATIVECaptureImageCameraTest("Back")

    def test_Camera_Effect_Front_None_CaptureImage(self):
        self.setColorEffectNoneCaptureImageCameraTest("Front")

    def test_Camera_Effect_Rear_None_CaptureImage(self):
        self.setColorEffectNoneCaptureImageCameraTest("Back")

    def test_Camera_Effect_Front_Mono_CaptureImage(self):
        self.setColorEffectMonoCaptureImageCameraTest("Front")

    def test_Camera_Effect_Rear_Mono_CaptureImage(self):
        self.setColorEffectMonoCaptureImageCameraTest("Back")

    def test_Camera_Continuous_Front_MaxoneTime(self):
        self.cameraContinuousMaxoneTimeTest("Front")

    def test_Camera_Continuous_Rear_MaxoneTime(self):
        self.cameraContinuousMaxoneTimeTest("Back")

    def test_Camera_Continuous_Front_ExitRelaunch(self):
        self.cameraContinuousExitRelaunchTest("Front")

    def test_Camera_Continuous_Rear_ExitRelaunch(self):
        self.cameraContinuousExitRelaunchTest("Back")

    def test_Camera_HDR_Rear_Capture(self):
        self.cameraHDRCaptureTest("Back")

    def test_Camera_HDR_Front_Capture(self):
        self.cameraHDRCaptureTest("Front")

    def test_Camera_HDR_Rear_EXIF(self):
        self.cameraHDRExifTest("Back")

    def test_Camera_HDR_Front_EXIF(self):
        self.cameraHDRExifTest("Front")

    def test_Camera_Continuous_Rear_LowStorage(self):
        self.cameraContinuousLowStorage("Back")

    def test_Camera_HDR_Front_IterativeCapture_MaxResolution_LowRAM(self):
        self.cameraHDRIterativeCaptureMaxResolutionLowRAMTest("Front")

    def test_Camera_HDR_Rear_IterativeCapture_MaxResolution_LowRAM(self):
        self.cameraHDRIterativeCaptureMaxResolutionLowRAMTest("Back")

    def test_Camera_HDR_Front_IterativeExit_TapHome(self):
        self.cameraHDRIterativeExitTapHome("Front")

    def test_Camera_HDR_Rear_IterativeExit_TapHome(self):
        self.cameraHDRIterativeExitTapHome("Back")

    def test_Camera_Effect_Rear_Capture_repeatedly(self):
        self.cameraEffectCaptureRepeatedlyTest()

    def test_Camera_Effect_Front_Sepia_repeatly_RearFrontSwitch(self):
        self.cameraEffectFrontSepiarepeatlyRearFrontSwitchTest()

    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_SetBrightness_Front_EXIF(self):
        self.cameraSetBrightnessEXIFTest("Brightness", "Front")

    def test_Camera_SetBrightness_Rear_EXIF(self):
        self.cameraSetBrightnessEXIFTest("Brightness", "Back")
Exemple #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__
        self.light_port = "0"
        self.file_index = 0
        self.test_object = 0
        print "[Setup]: %s" % self._test_name

    def tearDown(self):
        """
        @summary: tearDown
        @return: None
        """
        if self.light_port!="0":
            self.deviceControl.pressLightBoxButton(self.light_port)
            self.deviceControl.pressLightBoxButton("1")
        if self.test_object!=0:
            #return to the first picture
            pass
        super(CameraTest, self).tearDown()
        print "[Teardown]: %s" % self._test_name
        g_common_obj.stop_exp_handle()
        time.sleep(3)

    def appPrepare(self,):
#         cfg_file = os.path.join(os.environ.get('TEST_DATA_ROOT', ''), \
#             'tests.testplan.camera.conf')
#         current_platform = CameraCommon().getPlatform()
#         self.camera = GMSCamera(self.config.read(cfg_file, "multimedia_camera"))
        #self.camera = ArcSoftCamera(self.config.read(cfg_file, "multimedia_camera"))
        self.camera = CameraCommon().switchPlatform()
        self.multimedia_setting = MultiMediaSetting(CameraCommon().DEFAULT_CONFIG_FILE)
        self.video = CheckVideo()
        self.checkImage = CheckImage()
        self.deviceControl = DeviceControl()
        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 switchplatform(self, platform, cfg_file):
#         platform_list1 = self.camera.cfg.get("platform1").split(';')
#         platform_list2 = self.camera.cfg.get("platform2").split(';')
#         if platform in platform_list1:
#             self.camera = ArcSoftCamera(self.config.read(cfg_file, "multimedia_camera"))
#             self.logger.debug("the platform is %s" % platform)
#             self.multimedia_setting = MultiMediaSetting(cfg_file)
#             self.multimedia_setting.install_apk("quickpic_apk")
#         if platform in platform_list2:
#             self.camera = AOSPCamera(self.config.read(cfg_file, "multimedia_camera"))
#             self.logger.debug("the platform is %s" % platform)
#         self.multimedia_setting.install_apk("alarm_apk")
#         self.multimedia_setting.install_apk("gps_apk")

    def checkFileCorrupt(self, mediaFileCount=1, checkSim=False):
        file_name_list = CameraCommon().pullFileAndCheckFileNumber(self.camera_dir, self.host_path, mediaFileCount)
        for i in range(len(file_name_list)):
            self.path = self.host_path + "/" + file_name_list[i]
            for j in range(10):
                if not CameraCommon().checkFile(self.path):
                    CameraCommon().adbPullFile(self.camera_dir + file_name_list[i], self.host_path)
                    time.sleep(2)
                else:
                    self.logger.debug(str(file_name_list[i]) + " exists")
                    break
                time.sleep(2)
            self.path = self.host_path + "/" + file_name_list[i]
            os.system("cp "+self.path+" "+g_common_obj.get_user_log_dir())
            self.logger.debug("===picture path="+g_common_obj.get_user_log_dir()+"/"+file_name_list[i]+"===")
            if checkSim:
                panaFile = g_common_obj.get_user_log_dir()+"/"+file_name_list[i]
                self.logger.debug("===compare "+panaFile+" with the pano1.jpg====")
                #os.environ['LD_LIBRARY_PATH'] = "/lib:/usr/lib:/usr/local/lib"
                #os.putenv('LD_LIBRARY_PATH', "/lib:/usr/lib:/usr/local/lib")
                #currentDir = os.path.abspath(os.path.dirname(__file__))
                #cmd = currentDir+os.sep+"GASServer "+currentDir+"/pano1.jpg "+panaFile
                #import subprocess
                #output=subprocess.Popen(cmd,shell=True,stdout=subprocess.PIPE).communicate()
                #self.logger.debug(output[0][:-1])
                #s=output[0][:-1].split("\n")[2]
                #percent=int(s.split(" ")[2].split("%")[0])
                #if percent < 30:
                #    assert False, "similar checking result < 30% Fail! "+panaFile+" is not similar with pano1.jpg"
                #else:
                #    self.logger.debug("similar checking result > 30% Pass!")
            str_name = file_name_list[i].split('.')
            suffix = str_name[1]
            if not suffix:
                assert False, "file name without the suffix"
            if suffix == "jpg":
                errMsg = self.checkImage.check_image_corrupt(self.path)
                if errMsg != "":
                    assert False, errMsg
                else:
                    self.info = CameraCommon().getExifInfo(file_name_list[i], self.host_path + "/")
                    self.logger.debug("picture validation successful")
                continue
            elif suffix == "mp4" or suffix == "3gp":
                if self.video.check_video_corrupt(self.path):
                    self.info = CameraCommon().getExifInfo(file_name_list[i], self.host_path + "/")
                    self.logger.debug("video validation successful")
                else:
                    self.logger.debug("video validation fails")
#             self.removeFile(self.host_path + "/*")
#         self.removeDeivceFile()
        return self.info, file_name_list[0]

    def flashTest(self):
        try:
            self.appPrepare()
            self.camera.startCameraApp()
            self.camera.selectMode("Camera")
            self.camera.switchRearOrFront("Back")
            self.camera.setFlash("on")
            #If light box is ready, here should set flash to auto and set dark light first and then set bright light
            self.camera.capturePhoto(1)
            time.sleep(1)
            ret = self.checkFileCorrupt(1)
            fileName = ret[1]
            flashInfo = ret[0].get("Flash")
            self.logger.info("===fileName=%s, flashInfo=%s" %(fileName, flashInfo))
            CameraCommon().moveFilesFromCameraFolder()
            self.camera.setFlash("off")
            self.camera.capturePhoto(1)
            time.sleep(1)
            ret=self.checkFileCorrupt(1)
            fileName = ret[1]
            flashInfo = ret[0].get("Flash")
            self.logger.info("===fileName=%s, flashInfo=%s" %(fileName, flashInfo))
            CameraCommon().recoverFilesFromCameraTemp()
        except Exception as e:
            CameraCommon().checkCameraCrash()
            self.assertTrue(False, e)

    def panoramaTest(self):
        try:
            self.appPrepare()
            self.camera.startCameraApp()
            self.camera.selectMode("Panorama")
            self.camera.capturePanorama()
            self.checkFileCorrupt(1, True)
        except Exception as e:
            CameraCommon().checkCameraCrash()
            self.assertTrue(False, e)
            
    def zoomDemo(self):
        #print CameraCommon().getTestEntryName()
        #return 
        self.appPrepare()
        mlist = self.deviceControl.getZoomCommands()
        
        self.camera.startCameraApp()
        self.camera.selectMode("Camera")
        CameraCommon().clickScreenCenter()
        self.camera.capturePhoto()
        time.sleep(2)
        ori_name = self.checkFileCorrupt()[1]
        CameraCommon().removeDeivceFile()
        print ori_name, mlist[0], mlist[1]
        ori_name = self.host_path + "/" + ori_name
        zoom_name = CameraCommon().zoomInOrOut(self.camera, mlist[0])[0]
        print ori_name,zoom_name
#         file1 = "/data/debug/zoom/zoom/3gr/IMG_20160323_125326.jpg"
#         file2 = "/data/debug/zoom/zoom/3gr/IMG_20160323_125403.jpg"
        checkZoom = CheckZoom()
#         self.assertTrue(checkZoom.checkZoomEffect(file1, file2), "Zoom effect is not correct")
        self.assertTrue(checkZoom.checkZoomEffect(ori_name, zoom_name), "Zoom effect is not correct")

    def benchTest(self):
        self.appPrepare()
        localPath = CameraCommon().getTmpDir()
        self.camera.startCameraApp()
        self.camera.selectMode("Camera")
        checkIQ = CheckIQ("", localPath)
        """
        change to the CWF light
        """
        self.light_port="6"
        self.deviceControl.pressLightBoxButton("1")
        self.deviceControl.pressLightBoxButton(self.light_port)
        """
        change the test object
        """
        self.test_object=0
        self.deviceControl.selectTestObject(0)
        """
        initialize robot
        """
        from testaid.robot import Robot
        deviceName = self.deviceControl.getRobotDeviceName()
        robot = Robot(deviceName)
        robot.reset()
        """
        Adjust FOV content
        """
        l = self.camera.getFOVRegion()
        region = CheckIQ.Region(l[0], l[1], l[2], l[3], False)
        self.deviceControl.adjustFOV(localPath, region, robot)
        """
        Main test code, capture picture
        """
        CameraCommon().clickScreenCenter()
        self.camera.capturePhoto()
        time.sleep(2)
        files = CameraCommon().getMediaFilesFromDevice(self.file_index, 1)
        self.file_index += len(files)
        #CameraCommon().moveFilesFromCameraFolder()
        errMsg = ""
        for f in files:
            ret = checkIQ.checkCorrupt(f)
            if ret!="":
                errMsg += "file:"+f+" is abnormal! "+ret
        #CameraCommon().recoverFilesFromCameraTemp()
        robot.reset()
        self.assertTrue(errMsg=="", errMsg) 
        
    def benchTest1(self):
        self.appPrepare()
        localPath = CameraCommon().getTmpDir()
        self.camera.startCameraApp()
        self.camera.selectMode("Camera")
        checkIQ = CheckIQ("", localPath)
        CameraCommon().clickScreenCenter()
        self.camera.capturePhoto()
        time.sleep(2)
        files = CameraCommon().getMediaFilesFromDevice(self.file_index, 1)
        self.file_index += len(files)
        CameraCommon().moveFilesFromCameraFolder()
        errMsg = ""
        #for f in files:
        #    ret = checkIQ.checkCorrupt(f)
        #    if ret!="":
        CameraCommon().clickScreenCenter()
        self.camera.capturePhoto()
        time.sleep(2)
        files = CameraCommon().getMediaFilesFromDevice(self.file_index, 1)
        self.file_index += len(files)
        CameraCommon().recoverFilesFromCameraTemp()
        self.assertTrue(errMsg=="", errMsg) 
    
    def testPanorama(self):
        self.panoramaTest()

    def testFlash(self):
        #self.zoomDemo() 
        self.flashTest()

    def test_Camera_Zoom(self):
        #self.appPrepare()
        #localPath = CameraCommon().getTmpDir()
        #checkIQ = CheckIQ("", localPath)
        #self.benchTest1()
        self.zoomDemo()