Beispiel #1
0
class CameraReliabilityTest(CameraTestBase):
    """
    @summary: This test used to test camera function
    """
    def setUp(self):
        """
        @summary: set up
        @return: None
        """
        super(CameraReliabilityTest, self).setUp()
        self._test_name = __name__
        print "[Setup]: %s" % self._test_name

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

    def appPrepareWithClearData(self):
        self.camera = CameraCommon().switchPlatform()
        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):
        CameraCommon().checkFileCorrupt(mediaFileCount)

    def stillCaptureWithCleanData(self, mode, lens, num):
        """
        This test used to test camera
        The test case spec is following:
        1. Launch camera
        2. Auto focus then still image capture
        """
        try:
            self.appPrepareWithClearData()
            self.camera.startCameraApp()
            self.camera.selectMode(mode)
            self.camera.switchRearOrFront(lens)
            self.camera.capturePhoto(num)
            self.checkFileCorrupt()
        except Exception as e:
            CameraCommon().checkCameraCrash()
            self.assertTrue(False, e)

    def stillCaptureAndCheckFile(self, mode, lens, num):
        """
        This test used to test camera
        The test case spec is following:
        1. Launch camera
        2. Auto focus then still image capture
        """
        try:
            self.appPrepareWithClearData()
            self.camera.startCameraApp()
            self.camera.selectMode(mode)
            self.camera.switchRearOrFront(lens)
            self.camera.capturePhoto(num)
            time.sleep(2)
            self.checkFileCorrupt(num)
        except Exception as e:
            CameraCommon().checkCameraCrash()
            self.assertTrue(False, e)

    def goThroughAllSettings(self, mode, lens, num):
        """
        This test used to test camera
        The test case spec is following:
        1. Launch camera
        2. change the camera setting
        """
        try:
            self.appPrepareWithClearData()
            self.camera.startCameraApp()
            self.camera.selectMode(mode)
            self.camera.switchRearOrFront(lens)
            for i in range(int(num)):
                self.logger.debug("******** Loop " + str(i + 1) + " ********")
                self.camera.clickAllSetting()
        except Exception as e:
            CameraCommon().checkCameraCrash()
            self.assertTrue(False, e)

    def terminateCameraWhenRecording(self, mode, lens, num):
        """
        This test used to test camera
        The test case spec is following:
        1. Launch camera from app launcher
        2. Switch to video mode
        3. Switch to back/front camera
        4. Start to record video
        5. Teminate camera in Recent Tasks when recording
        """
        try:
            self.appPrepareWithClearData()
            self.camera.startCameraApp()
            self.camera.selectMode(mode)
            self.camera.switchRearOrFront(lens)
            self.camera.clickRecordBtn()
            CameraCommon().checkCameraCrash()
            time.sleep(2)
            CameraCommon().pressBack(2)
            for i in range(int(num)):
                self.logger.debug("******** Loop " + str(i + 1) + " ********")
                self.camera.startCameraApp()
                self.camera.clickRecordBtn()
                CameraCommon().checkCameraCrash()
                time.sleep(2)
                CameraCommon().removeRecentApp()
            self.checkFileCorrupt(num)
        except Exception as e:
            CameraCommon().checkCameraCrash()
            self.assertTrue(False, e)

    def launchCameraTeminateRecent(self, num):
        """
        This test used to test camera
        The test case spec is following:
        1. Launch camera from app launcher
        2. Terminate the camera from recent tasks
        """
        try:
            self.appPrepareWithClearData()
            for i in range(int(num)):
                self.logger.debug("******** Loop " + str(i + 1) + " ********")
                self.camera.startCameraApp()
                CameraCommon().checkCameraCrash()
                CameraCommon().removeRecentApp()
        except Exception as e:
            CameraCommon().checkCameraCrash()
            self.assertTrue(False, e)

    def launchCameraFromHome(self, case_name):
        """
        This test used to test camera
        The test case spec is following:
        1. Launch camera from am command
        """
        try:
            self.logger.debug("run case is " + str(case_name))
            self.appPrepareWithClearData(case_name)
            for i in range(int(self.camera.cfg.get("loop_num"))):
                self.logger.debug("******** Loop " + str(i) + " ********")
                self.camera.enter_camera_from_home()
                self.camera.judge_if_camera_crash()
        except Exception as e:
            self.camera.judge_if_camera_crash()
            self.assertTrue(False, e)

    def launchCameraFromApp(self, num):
        """
        This test used to test camera
        The test case spec is following:
        1. Launch camera from app launcher
        """
        try:
            self.appPrepareWithClearData()
            for i in range(int(num)):
                self.logger.debug("******** Loop " + str(i + 1) + " ********")
                self.camera.startCameraApp()
                CameraCommon().pressBack()
        except Exception as e:
            CameraCommon().checkCameraCrash()
            self.assertTrue(False, e)

    def launchCameraFromRecentTasks(self, mode, num):
        """
        This test used to test camera
        The test case spec is following:
        1. Launch camera from recent tasks
        """
        try:
            self.appPrepareWithClearData()
            CameraCommon().removeAllAppFromRecentTask()
            self.camera.startCameraApp()
            CameraCommon().pressBack(2)
            for i in range(int(num)):
                self.logger.debug("******** Loop " + str(i + 1) + " ********")
                CameraCommon().enterAppFromRecentTask()
                CameraCommon().pressBack(2)
        except Exception as e:
            CameraCommon().checkCameraCrash()
            self.assertTrue(False, e)

    def manualAllExposureThenImageCapture(self, mode, lens, num):
        """
        This test used to test camera
        The test case spec is following:
        1. Launch camera
        2. open manual exposure
        3. set exposure then capture
        """
        try:
            self.appPrepareWithClearData()
            self.camera.startCameraApp()
            self.camera.selectMode(mode)
            self.camera.switchRearOrFront(lens)
            self.camera.openManualExposure()
            for i in range(int(num)):
                self.logger.debug("******** Loop " + str(i + 1) + " ********")
                self.camera.setExposure("+2")
                self.camera.capturePhoto()
                self.camera.setExposure("+1")
                self.camera.capturePhoto()
                self.camera.setExposure("0")
                self.camera.capturePhoto()
                self.camera.setExposure("-1")
                self.camera.capturePhoto()
                self.camera.setExposure("-2")
                self.camera.capturePhoto()
            self.checkFileCorrupt(num * 5)
        except Exception as e:
            CameraCommon().checkCameraCrash()
            self.assertTrue(False, e)

#     def clickScreenAnyAreaThenStillImageCapture(self, case_name):
#         """
#         This test used to test camera
#         The test case spec is following:
#         1. Launch camera
#         2. Manual focus then still image capture
#         """
#         try:
#             self.appPrepareWithClearData(case_name)
#             self.camera.enter_camera_from_home()
#             self.camera.switch_to_camera_options(self.camera.cfg.get("options"))
#             self.camera.change_front_back_camera(self.camera.cfg.get("back_or_front"))
#             for i in range(int(self.camera.cfg.get("loop_num"))):
#                 self.logger.debug("******** Loop " + str(i) + " ********")
#                 self.camera.click_screen_any_area()
#                 time.sleep(2)
#                 self.camera.removeDeivceFile()
#                 self.camera.capture_photo()
#                 time.sleep(2)
#                 self.checkFileCorrupt()
#         except Exception as e:
#             CameraCommon().checkCameraCrash()
#             self.assertTrue(False, e)

    def quickClickShutterButtonArea(self, mode, num):
        """
        This test used to test camera
        The test case spec is following:
        1. Launch camera
        2. Quick click shutter button area
        """
        try:
            self.appPrepareWithClearData()
            self.camera.startCameraApp()
            self.camera.selectMode(mode)
            time.sleep(2)
            mx, my = self.camera.clickShutterBtnArea(mode)
            self.logger.debug("width = " + str(mx) + ", height = " + str(my))
            for i in range(int(num)):
                self.logger.debug("******** Loop " + str(i + 1) + " ********")
                CameraCommon().clickBtn(mx, my)
                self.logger.debug("click " + str(mx) + ", " + str(my))
                CameraCommon().checkCameraCrash()
        except Exception as e:
            CameraCommon().checkCameraCrash()
            self.assertTrue(False, e)

    def startCounterAndStopCapture(self, case_name):
        """
        This test used to test camera
        The test case spec is following:
        1. Launch camera
        2. capture image
        """
        try:
            self.logger.debug("run case is " + str(case_name))
            self.appPrepareWithClearData(case_name)
            self.camera.enter_camera_from_home()
            self.camera.switch_module_in_camera(self.camera.cfg.get("options"))
            self.camera.change_front_back_camera(
                self.camera.cfg.get("back_or_front"))
            self.camera.counter_time()
            for i in range(int(self.camera.cfg.get("loop_num"))):
                self.logger.debug("********Loop " + str(i) + " ********")
                self.camera.capture_photo()
                self.camera.stop_counter_time()
                time.sleep(2)
        except Exception as e:
            self.camera.judge_if_camera_crash()
            self.assertTrue(False, e)

    def changeCameraSizeThenCapture(self, mode, lens, num):
        """
        This test used to test camera
        The test case spec is following:
        1. Launch camera
        2. capture image
        """
        try:
            self.appPrepareWithClearData()
            self.camera.startCameraApp()
            self.camera.selectMode(mode)
            self.camera.switchRearOrFront(lens)
            mDict = self.camera.getAllPhotoResolutions(lens)[0]
            for i in range(int(num)):
                self.logger.debug("********Loop " + str(i + 1) + " ********")
                for k in mDict:
                    self.camera.setPhotoResolution(mDict[k], lens)
                    self.camera.capturePhoto()
            self.checkFileCorrupt(num * len(mDict))
        except Exception as e:
            CameraCommon().checkCameraCrash()
            self.assertTrue(False, e)

    def longLastingImageCaptureMaxResolution(self, lens, wait_time):
        """
        This test used to test camera
        The test case spec is following:
        1. Launch camera
        2. capture image
        """
        try:
            self.appPrepareWithClearData()
            self.camera.startCameraApp()
            self.camera.selectMode("Camera")
            self.camera.switchRearOrFront(lens)
            mDict, mMax, mMin = self.camera.getAllPhotoResolutions(lens)
            #             print mMax,mMin
            self.camera.setPhotoResolution(mMax, lens)
            timeRecord = time.time()
            i = 0
            while time.time() - timeRecord < float(wait_time):
                i = i + 1
                self.logger.debug("******** Loop " + str(i + 1) + " ********")
                self.camera.capturePhoto()
            self.checkFileCorrupt()
            self.camera.reviewPhotoAndVideo(5)
        except Exception as e:
            CameraCommon().checkCameraCrash()
            self.assertTrue(False, e)

    def cameraSwitchCaptureUntilStorageFull(self, lens):
        """
        This test used to test camera
        The test case spec is following:
        1. Launch camera
        2. capture image
        """
        try:
            self.appPrepareWithClearData()
            CameraCommon().fillStorage(130)
            CameraCommon().unlockScreen()
            self.camera.startCameraApp()
            self.camera.selectMode(lens)
            mTime = time.time()
            while True:
                self.camera.switchRearOrFront("Front")
                self.camera.capturePhoto()
                self.camera.switchRearOrFront("Back")
                self.camera.capturePhoto()
                time.sleep(1)
                free = CameraCommon().getSdcardMemory()[2]
                if free < 70:
                    self.logger.debug("The memory is full")
                    break
                if time.time() - mTime > 5400:
                    break
        except Exception as e:
            CameraCommon().checkCameraCrash()
            CameraCommon().removeDeivceFile()
            self.assertTrue(False, e)

    def cameraCaptureUntilStorageFull(self, mode, lens):
        """
        This test used to test camera
        The test case spec is following:
        1. Launch camera
        2. capture image
        """
        try:
            self.appPrepareWithClearData()
            CameraCommon().fillStorage(130)
            CameraCommon().unlockScreen()
            self.camera.startCameraApp()
            self.camera.selectMode(mode)
            self.camera.switchRearOrFront(lens)
            i = 0
            mTime = time.time()
            while True:
                i = i + 1
                self.logger.debug("******** Loop " + str(i + 1) + " ********")
                time.sleep(1)
                self.camera.capturePhoto()
                total, used, free = CameraCommon().getSdcardMemory()
                if free < 70:
                    self.logger.debug("The memory is full")
                    break
                if time.time() - mTime > 5400:
                    break
        except Exception as e:
            CameraCommon().checkCameraCrash()
            self.assertTrue(False, e)

    def switchToRearOrFrontCameraIteratively(self, mode, num):
        """
        This test used to test camera
        The test case spec is following:
        1. Launch camera
        2. Switch to rear or front camera
        """
        try:
            self.appPrepareWithClearData()
            self.camera.startCameraApp()
            self.camera.selectMode(mode)
            for i in range(int(num)):
                self.logger.debug("******** Loop " + str(i + 1) + " ********")
                CameraCommon().checkCameraCrash()
                self.camera.switchRearOrFront("Back")
                time.sleep(1.5)
                CameraCommon().checkCameraCrash()
                self.camera.switchRearOrFront("Front")
            CameraCommon().removeDeivceFile()
        except Exception as e:
            CameraCommon().checkCameraCrash()
            self.assertTrue(False, e)

    def snapshotWhenRecording(self, lens, num):
        """
        This test used to test camera
        The test case spec is following:
        1. Launch camera
        2. Test video recording start and stop
        """
        try:
            self.appPrepareWithClearData()
            self.camera.startCameraApp()
            self.camera.selectMode("Video")
            self.camera.switchRearOrFront(lens)
            self.camera.snapShotDuringVideo(1, 5, num)
            self.checkFileCorrupt(num + 1)
        except Exception as e:
            CameraCommon().checkCameraCrash()
            self.assertTrue(False, e)

    def changeVideoSizeRecording(self, mode, lens, num):
        """
        This test used to test camera
        The test case spec is following:
        1. Launch camera
        2. Test video recording start and stop
        """
        try:
            self.appPrepareWithClearData()
            self.camera.startCameraApp()
            self.camera.selectMode(mode)
            self.camera.switchRearOrFront(lens)
            mDict = self.camera.getAllVideoResolutions(lens)[0]
            for i in range(int(num)):
                self.logger.debug("******** Loop " + str(i + 1) + " ********")
                for k in mDict:
                    print mDict[k]
                    self.camera.setVideoResolution(mDict[k], lens)
                    self.camera.recordVideo(1, 10)
                self.checkFileCorrupt()
                CameraCommon().removeDeivceFile()
        except Exception as e:
            CameraCommon().checkCameraCrash()
            self.assertTrue(False, e)

    def longLastingVideoRecording(self, lens, duration):
        """
        This test used to test camera
        The test case spec is following:
        1. Launch camera
        2. Test video recording start and stop
        """
        try:
            self.appPrepareWithClearData()
            self.camera.startCameraApp()
            self.camera.selectMode("Video")
            self.camera.switchRearOrFront(lens)
            self.camera.recordVideo(1, duration)
            self.checkFileCorrupt()
            self.camera.reviewPhotoAndVideo()
        except Exception as e:
            CameraCommon().checkCameraCrash()
            self.assertTrue(False, e)

    def videoRecordingIteration(self, lens, videoNum):
        """
        This test used to test camera
        The test case spec is following:
        1. Launch camera
        2. Test video recording start and stop
        """
        try:
            self.appPrepareWithClearData()
            self.camera.startCameraApp()
            self.camera.selectMode("Video")
            self.camera.switchRearOrFront(lens)
            time.sleep(1)
            for i in range(int(videoNum)):
                self.logger.debug("******** Loop " + str(i + 1) + " ********")
                self.camera.recordVideo(1, 1)
                time.sleep(1)
                CameraCommon().checkCameraCrash()
            self.checkFileCorrupt(videoNum)
        except Exception as e:
            CameraCommon().checkCameraCrash()
            self.assertTrue(False, e)

    def cameraFullStorageRecordModeTest(self):
        try:
            self.appPrepareWithClearData()
            CameraCommon().fillStorage(25)
            CameraCommon().unlockScreen()
            self.camera.startCameraApp()
            CameraCommon().checkCameraCrash()
            total, used, free = CameraCommon().getSdcardMemory()
            if free > 70:
                self.assertTrue(False, "since memory is not full")
            CameraCommon().removeBigFile()
            CameraCommon().checkCameraCrash()
        except Exception as e:
            CameraCommon().checkCameraCrash()
            CameraCommon().removeBigFile()
            self.assertTrue(False, e)

    def cameraLackStorageVideoModeTest(self):
        try:
            self.appPrepareWithClearData()
            self.camera.startCameraApp()
            self.camera.selectMode("Video")
            self.camera.switchRearOrFront("Back")
            CameraCommon().fillStorage(300)
            CameraCommon().unlockScreen()
            for i in range(5):
                self.camera.startCameraApp()
                CameraCommon().pressBack()
            self.camera.startCameraApp()
            self.camera.switchRearOrFront("Front")
            for i in range(5):
                self.camera.startCameraApp()
                CameraCommon().pressBack()
            CameraCommon().removeBigFile()
        except Exception as e:
            CameraCommon().checkCameraCrash()
            CameraCommon().removeBigFile()
            self.assertTrue(False, e)

    def cameraPressShutterKeyQuicklyVideoModeTest(self):
        try:
            self.appPrepareWithClearData()
            self.camera.startCameraApp()
            self.camera.selectMode("Video")
            self.camera.switchRearOrFront("Back")
            x, y = self.camera.clickShutterBtnArea()
            for i in range(200):
                CameraCommon().clickBtn(x, y)
                time.sleep(0.2)
                CameraCommon().clickBtn(x, y)
                time.sleep(0.2)
            CameraCommon().checkCameraCrash()
            if self.camera.isRecordTimeExists():
                self.camera.clickRecordBtn()
            self.checkFileCorrupt()
        except Exception as e:
            CameraCommon().checkCameraCrash()
            self.assertTrue(False, e)

    def cameraRebootDUTLaunchCamera20TimesTest(self):
        try:
            for i in range(20):
                g_common_obj2.system_reboot(90)
                CameraCommon().unlockScreen()
            self.appPrepareWithClearData()
            self.camera.startCameraApp()
            self.camera.selectMode("Camera")
            self.camera.switchRearOrFront("Back")
            self.camera.capturePhoto()
            self.camera.selectMode("Video")
            self.camera.recordVideo()
            if self.camera.checkModeExists("Panorama"):
                self.camera.selectMode("Panorama")
                self.camera.capturePhoto(1, False)
                self.camera.capturePhoto()
            if self.camera.checkModeExists("Lens Blur"):
                self.camera.selectMode("Lens Blur")
                self.camera.capturePhoto()
            if self.camera.checkModeExists("Photo Sphere"):
                self.camera.selectMode("Photo Sphere")
                self.camera.capturePhoto()
            self.checkFileCorrupt()
        except Exception as e:
            CameraCommon().checkCameraCrash()
            self.assertTrue(False, e)

    def cameraPreviewLockAndUnlock30minsTest(self, sleep_time):
        try:
            self.appPrepareWithClearData()
            self.camera.startCameraApp()
            self.camera.selectMode("Camera")
            self.camera.switchRearOrFront("Back")
            CameraCommon().pressPower()
            time.sleep(sleep_time)
            CameraCommon().unlockScreen()
            CameraCommon().checkCameraCrash()
        except Exception as e:
            CameraCommon().checkCameraCrash()
            self.assertTrue(False, e)

    def cameraTorchModeTest(self, sleep_time):
        try:
            self.appPrepareWithClearData()
            CameraCommon().pressHome()
            CameraCommon().flashlightOperation()
            time.sleep(sleep_time)
            CameraCommon().flashlightOperation()
            CameraCommon().pressBack(2)
        except Exception as e:
            CameraCommon().checkCameraCrash()
            self.assertTrue(False, e)

    def cameraSwitchQuickViewAndFOV20timesTest(self):
        try:
            self.appPrepareWithClearData()
            self.camera.startCameraApp()
            self.camera.selectMode("Camera")
            self.camera.switchRearOrFront("Back")
            self.camera.capturePhoto(3)
            self.camera.selectMode("Video")
            self.camera.recordVideo(2)
            if self.camera.checkModeExists("Panorama"):
                self.camera.selectMode("Panorama")
                self.camera.capturePhoto(1, False)
                self.camera.capturePhoto()
            self.checkFileCorrupt()
            self.camera.reviewPhotoAndVideo()
            CameraCommon().checkCameraCrash()
        except Exception as e:
            CameraCommon().checkCameraCrash()
            self.assertTrue(False, e)

    def switchAllCameraOptions(self, loop):
        """
        This test used to test camera
        The test case spec is following:
        1. Launch camera
        1. Switch to camera options one by one
        """
        try:
            self.appPrepareWithClearData()
            self.camera.startCameraApp()
            if "cht" in CameraCommon().getPlatform():
                cht_skip_flag = 1
            else:
                cht_skip_flag = 0
            for i in range(int(loop)):
                self.logger.debug("***** Loop " + str(i + 1) + " *****")
                self.camera.selectMode("Camera")
                self.camera.selectMode("Video")
                if cht_skip_flag == 1:
                    continue
                self.camera.selectMode("Lens Blur")
                self.camera.selectMode("Panorama")
                self.camera.selectMode("Photo Sphere")
        except Exception as e:
            CameraCommon().checkCameraCrash()
            self.assertTrue(False, e)

    def test_Camera_Rear_Capture_Iteration_5000cycles(self):
        """
        This test used to test auto focus then still image capture
        The test case spec is following:
        1. Launch camera
        2. still image capture
        """
        self.stillCaptureWithCleanData("Camera", "Back", 5000)

    def test_Camera_Rear_Capture_Iteration_500cycles(self):
        """
        This test used to test auto focus then still image capture
        The test case spec is following:
        1. Launch camera
        2. still image capture
        """
        self.stillCaptureAndCheckFile("Camera", "Back", 500)

    def test_Camera_TraverseSetting_Iteration_200cycles(self):
        """
        This test used to test camera
        The test case spec is following:
        1. Launch camera
        2. change the camera setting
        """
        self.goThroughAllSettings("Camera", "Front", 200)

    def test_Camera_VideoMode_Front_TerminateInRecentAppDuringRecord_Iteration_500cycles(
            self):
        """
        This test used to test launch camera
        1. Launch camera from app launcher
        2. Switch to video mode
        3. Switch to front camera
        4. Start to record video
        5. Teminate camera in Recent Tasks when recording
        """
        self.terminateCameraWhenRecording("Video", "Front", 500)

    def test_Camera_Front_TerminateInRecentAppAfterLaunch_500cycles(self):
        """
        This test used to test launch camera
        The test case spec is following:
        1. Launch camera from app launcher
        2. Terminate the camera from recent tasks
        """
        self.launchCameraTeminateRecent(500)

    def test_Camera_VideoMode_Rear_TerminateInRecentAppDuringRecording_Iteration_500cycles(
            self):
        """
        This test used to test launch camera
        1. Launch camera from app launcher
        2. Switch to video mode
        3. Switch to back camera
        4. Start to record video
        5. Teminate camera in Recent Tasks when recording
        """
        self.terminateCameraWhenRecording("Video", "Back", 500)

    def test_Camera_LaunchCameraViaAppIcon_Iteration_500cycles(self):
        """
        This test used to test launch camera
        The test case spec is following:
        1. Launch camera from app launcher
        """
        self.launchCameraFromApp(500)

    def test_Camera_LaunchCameraViaTaskManager_Iteration_500cycles(self):
        """
        This test used to test launch camera
        The test case spec is following:
        1. Launch camera from recent tasks
        """
        self.launchCameraFromRecentTasks("Camera", 500)

    def test_Camera_ExposureBias_Front_ExposureSwitchCapture_100cycles(self):
        """
        This test used to test camera
        The test case spec is following:
        1. Launch camera
        2. open manual exposure
        3. set exposure then capture
        """
        self.manualAllExposureThenImageCapture("Camera", "Front", 100)

    def test_Camera_ExposureBias_Rear_ExposureSwitchCapture_100cycles(self):
        """
        This test used to test camera
        The test case spec is following:
        1. Launch camera
        2. capture image
        """
        self.manualAllExposureThenImageCapture("Camera", "Back", 100)

#     def testCameraCapture_Iteration_ClickScreenCaptureImage_500cycles(self):
#         """
#         This test used to test manual focus then still image capture
#         The test case spec is following:
#         1. Launch camera
#         2. Manual focus then still image capture
#         """
#         self.clickScreenAnyAreaThenStillImageCapture('mum_camera_capture_054')

    def test_Camera_QuickPressShutter_CaptureMode_Iteration_500cycles(self):
        """
        This test used to test camera
        The test case spec is following:
        1. Launch camera
        2. Quick click shutter button area
        """
        self.quickClickShutterButtonArea("Camera", 500)

    def test_Camera_VideoMode_QuickShutterPress_Iteration_500cycles(self):
        """
        This test used to test camera
        The test case spec is following:
        1. Launch camera
        2. Quick click shutter button area
        """
        self.quickClickShutterButtonArea("Video", 500)

    def test_Camera_Front_Capture_Iteration_5000cycles(self):
        """
        This test used to test auto focus then still image capture
        The test case spec is following:
        1. Launch camera
        2. still image capture
        """
        self.stillCaptureWithCleanData("Camera", "Front", 5000)

    def test_Camera_Front_Capture_Iteration_500cycles(self):
        """
        This test used to test auto focus then still image capture
        The test case spec is following:
        1. Launch camera
        2. Still image capture
        """
        self.stillCaptureAndCheckFile("Camera", "Front", 500)

    def test_Camera_Front_ResolutionSwitchCapture_Iteration_500cycles(self):
        """
        This test used to test camera
        The test case spec is following:
        1. Launch camera
        2. capture image
        """
        self.changeCameraSizeThenCapture("Camera", "Front", 500)

    def test_Camera_Rear_ResolutionSwitchCapture_Iteration_500cycles(self):
        """
        This test used to test camera
        The test case spec is following:
        1. Launch camera
        2. capture image
        """
        self.changeCameraSizeThenCapture("Camera", "Back", 500)

    def test_Camera_Front_Capture_Longlasting_MaxResolution_8hrs(self):
        """
        This test used to test camera
        The test case spec is following:
        1. Launch camera
        2. capture image
        """
        self.longLastingImageCaptureMaxResolution("Front", 28800)

    def test_Camera_Rear_Capture_Longlasting_MaxResolution_8hrs(self):
        """
        This test used to test camera
        The test case spec is following:
        1. Launch camera
        2. capture image
        """
        self.longLastingImageCaptureMaxResolution("Back", 28800)

    def test_Camera_Front_Rear_SwitchCapture_Iteration_UntilStorageFull(self):
        """
        This test used to test camera
        The test case spec is following:
        1. Launch camera
        2. capture image
        """
        self.cameraSwitchCaptureUntilStorageFull("Camera")

    def test_Camera_Rear_Capture_Iteration_UntilStorageFull(self):
        """
        This test used to test camera
        The test case spec is following:
        1. Launch camera
        2. capture image
        """
        self.cameraCaptureUntilStorageFull("Camera", "Back")

    def test_Camera_SwitchFrontRear_Iteration_5000cycles(self):
        """
        This test used to test switch to rear camera or front camera
        The test case spec is following:
        1. Launch camera
        2. Switch to rear or front camera
        """
        self.switchToRearOrFrontCameraIteratively("Camera", 5000)

    def test_Camera_CaptureMode_SwitchFrontRear_Iteration_500cycles(self):
        """
        This test used to test switch to rear camera or front camera
        The test case spec is following:
        1. Launch camera
        2. Switch to rear or front camera
        """
        self.switchToRearOrFrontCameraIteratively("Camera", 500)

    def test_Camera_VideoMode_SwitchFrontRear_Iteration_5000cycles(self):
        """
        This test used to test switch to rear camera or front camera
        The test case spec is following:
        1. Launch camera
        2. Switch to rear or front camera
        """
        self.switchToRearOrFrontCameraIteratively("Video", 5000)

    def test_Camera_VideoMode_SwitchFrontRear_Iteration_500cycles(self):
        """
        This test used to test switch to rear camera or front camera
        The test case spec is following:
        1. Launch camera
        2. Switch to rear or front camera
        """
        self.switchToRearOrFrontCameraIteratively("Video", 500)

    def test_Camera_Snapshot_Front_Iteration_500cycles(self):
        """
        This test used to test video recording start and stop
        The test case spec is following:
        1. Launch camera
        2. Test video recording start and stop
        """
        self.snapshotWhenRecording("Front", 500)

    def test_Camera_Snapshot_Rear_Iteration_500cycles(self):
        """
        This test used to test video recording start and stop
        The test case spec is following:
        1. Launch camera
        2. Test video recording start and stop
        """
        self.snapshotWhenRecording("Back", 500)

    def test_Camera_VideoMode_Front_ResolutionSwitchRecord_10s_Iteration_500cycles(
            self):
        """
        This test used to test video recording start and stop
        The test case spec is following:
        1. Launch camera
        2. Test video recording start and stop
        """
        self.changeVideoSizeRecording("Video", "Front", 500)

    def test_Camera_VideoMode_Rear_SwitchResolutionRecord_10s_Iteration_500cycles(
            self):
        """
        This test used to test video recording start and stop
        The test case spec is following:
        1. Launch camera
        2. Test video recording start and stop
        """
        self.changeVideoSizeRecording("Video", "Back", 500)

    def test_Camera_VideoMode_Front_Longlasting_2hrs(self):
        """
        This test used to test video recording start and stop
        The test case spec is following:
        1. Launch camera
        2. Test video recording start and stop
        """
        self.longLastingVideoRecording("Front", 7200)

    def test_Camera_VideoMode_Rear_Longlasting_2hrs(self):
        """
        This test used to test video recording start and stop
        The test case spec is following:
        1. Launch camera
        2. Test video recording start and stop
        """
        self.longLastingVideoRecording("Back", 7200)

    def test_Camera_VideoMode_Front_ShortVideo_1s_Iteration_100cycles(self):
        """
        This test used to test video recording start and stop
        The test case spec is following:
        1. Launch camera
        2. Test video recording start and stop
        """
        self.videoRecordingIteration("Front", 100)

    def test_Camera_VideoMode_Rear_ShortVideo_1s_Iteration_100cycles(self):
        """
        This test used to test video recording start and stop
        The test case spec is following:
        1. Launch camera
        2. Test video recording start and stop
        """
        self.videoRecordingIteration("Back", 100)

    def test_Camera_VideoMode_FullStorage(self):
        self.cameraFullStorageRecordModeTest()

    def test_Camera_VideoMode_LackStorage_VideoMode(self):
        self.cameraLackStorageVideoModeTest()

    def test_Camera_VideoMode_PressShutterKeyQuickly(self):
        self.cameraPressShutterKeyQuicklyVideoModeTest()

    def test_Camera_RebootDUT_LaunchCamera_20Times(self):
        self.cameraRebootDUTLaunchCamera20TimesTest()

    def test_Camera_Preview_LockAndUnlock_30mins(self):
        self.cameraPreviewLockAndUnlock30minsTest(1800)

    def test_Camera_TorchMode_On10Min(self):
        self.cameraTorchModeTest(60)

    def test_Camera_switch_QuickViewAndFOV_20times(self):
        self.cameraSwitchQuickViewAndFOV20timesTest()

    def test_Camera_Iteration_Switch_Mode_500cycles(self):
        self.switchAllCameraOptions(500)
Beispiel #2
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()
class CameraReliabilityTest(CameraTestBase):
    """
    @summary: This test used to test camera function
    """
    def setUp(self):
        """
        @summary: set up
        @return: None
        """
        super(CameraReliabilityTest, self).setUp()
        self._test_name = __name__
        print "[Setup]: %s" % self._test_name

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

    def appPrepareWithClearData(self):
        self.camera = CameraCommon().switchPlatform()
        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):
        CameraCommon().checkFileCorrupt(mediaFileCount)

    def quickClickShutterButtonArea(self, loop):
        """
        This test used to test camera
        The test case spec is following:
        1. Launch camera
        2. Quick click shutter button area
        """
        try:
            self.appPrepareWithClearData()
            self.camera.startCameraApp()
            self.camera.selectMode("Panorama")
            x, y = self.camera.clickShutterBtnArea("Panorama")
            self.logger.debug("width = " + str(x) + ", height = " + str(y))
            for i in range(int(loop)):
                self.logger.debug("***** Loop " + str(i + 1) + " *****")
                CameraCommon().clickBtn(x, y)
                CameraCommon().checkCameraCrash()
        except Exception as e:
            CameraCommon().checkCameraCrash()
            self.assertTrue(False, e)

    def switchAllCameraOptions(self, loop):
        """
        This test used to test camera
        The test case spec is following:
        1. Launch camera
        1. Switch to camera options one by one
        """
        try:
            self.appPrepareWithClearData()
            self.camera.startCameraApp()
            for i in range(int(loop)):
                self.logger.debug("***** Loop " + str(i + 1) + " *****")
                self.camera.selectMode("Video")
                self.camera.selectMode("Lens Blur")
                self.camera.selectMode("Panorama")
                self.camera.selectMode("Photo Sphere")
        except Exception as e:
            CameraCommon().checkCameraCrash()
            self.assertTrue(False, e)

    def switchToRearOrFrontCameraIteratively(self, loop):
        """
        This test used to test camera
        The test case spec is following:
        1. Launch camera
        2. Switch to rear or front camera
        """
        try:
            self.appPrepareWithClearData()
            self.camera.startCameraApp()
            self.camera.selectMode("Lens Blur")
            for i in range(int(loop)):
                self.logger.debug("***** Loop " + str(i + 1) + " *****")
                CameraCommon().checkCameraCrash()
                self.camera.switchRearOrFront("Front")
                CameraCommon().checkCameraCrash()
                self.camera.switchRearOrFront("Back")
        except Exception as e:
            CameraCommon().checkCameraCrash()
            self.assertTrue(False, e)

    def cameraSwitchFrontAndRearCameraLensBlurMode(self, loop):
        try:
            self.appPrepareWithClearData()
            for i in range(int(loop)):
                self.logger.debug("***** Loop " + str(i + 1) + " *****")
                self.camera.startCameraApp()
                self.camera.selectMode("Lens Blur")
                self.camera.switchRearOrFront("Front")
                self.camera.capturePhoto()
                time.sleep(10)
                self.camera.switchRearOrFront("Back")
                self.camera.capturePhoto(1, False)
                time.sleep(10)
                CameraCommon().waitForTheFilesAreGenerated(1)
            self.checkFileCorrupt(int(loop))
        except Exception as e:
            CameraCommon().checkCameraCrash()
            self.assertTrue(False, e)

    def cameraPressShutterKeyQuicklyLensBlurModeTest(self):
        try:
            self.appPrepareWithClearData()
            self.camera.startCameraApp()
            self.camera.selectMode("Lens Blur")
            self.camera.switchRearOrFront("Back")
            x, y = self.camera.clickShutterBtnArea("Lens Blur")
            for i in range(20):
                CameraCommon().clickBtn(x, y)
                CameraCommon().checkCameraCrash()
            time.sleep(5)
            self.checkFileCorrupt()
        except Exception as e:
            CameraCommon().checkCameraCrash()
            self.assertTrue(False, e)

    def test_Camera_LensBlur_PressShutterKeyQuickly(self):
        self.cameraPressShutterKeyQuicklyLensBlurModeTest()

    def test_Camera_Panorama_Iteration_QuickShutterPress_500cycles(self):
        self.quickClickShutterButtonArea(500)

    def test_Camera_Iteration_Switch_Mode_500cycles(self):
        self.switchAllCameraOptions(500)

    def test_Camera_LensBlur_SwitchFrontRear_5000cycles(self):
        self.switchToRearOrFrontCameraIteratively(5000)

    def test_Camera_LensBlur_SwitchFrontRear_500cycles(self):
        self.switchToRearOrFrontCameraIteratively(500)

    def test_Camera_LensBlur_SwitchFrontAndRear(self):
        self.cameraSwitchFrontAndRearCameraLensBlurMode(20)
Beispiel #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, 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")