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 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 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 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 setUp(self): """ @summary: set up @return: None """ super(CameraTest, self).setUp() self._test_name = __name__ self.logger.debug("[Setup]: %s" % self._test_name) self.camera_common = CameraCommon() self.host_path = self.camera_common.getTmpDir() self.relay08_helper = Relay08Helper() self.multimedia_lightbox_helper = MultiMediaLightBoxHelper() self.multimedia_robot_helper = MultiMediaRobotHelper() self.multimedia_mplayer_helper = MultiMediaMplayerHelper() self.multimedia_checkiq_helper = MultiMediaCheckiqHelper( self.host_path) self.multimedia_high_speed_helper = MultiMediaHighSpeedCameraHelper() self.multimedia_high_speed_helper.clear_temp_dir() self.rvc_camera = "" self.aosp_camera = "" self.case_result = -1 self.camera_common.removeDeivceFile() self.camera_common.removeFile(self.host_path + "/*") self.camera_common.unlockScreen() self.get_rvc_camera_class().skipAccountLoginLyout() self.get_rvc_camera_class().backHome() self.multimedia_high_speed_helper.connect()
def getAllPhotoResolutions(self, lens, type=""): """ Return all of the photo resolutions """ self.switchRearOrFront(lens) if not self.ArcSoftCameraWidget().settingCommonBtn().exists: self.ArcSoftCameraWidget().settingBtn().click.wait() self.ArcSoftCameraWidget().settingCameraBtn().click.wait() self.ArcSoftCameraWidget().text("Resolution").click.wait() mList = [] mx, my, sx, sy = CameraCommon().getBounds( self.ArcSoftCameraWidget().settingScrollView()) for j in range(2): try: for i in range(5): if self.ArcSoftCameraWidget().settingExpandText( )[i].exists: mList.append( self.ArcSoftCameraWidget().settingExpandText() [i].info["text"]) self.d.swipe(sx + mx - 150, sy + my - 30, sx + mx - 150, my - 40, steps=50) except: break # print "===list len = " + str(len(mList)) mDict = {} for i in range(len(mList)): mDict.setdefault(i + 1, mList[i]) CameraCommon().clickScreenCenter() self.logger.debug("get all photo resolution successfully") print mDict return mDict, mDict[len(mList)], mDict[1]
def snapShotDuringVideo(self, videoNum=1, duration=5, snapShotNum=1): """ Used to snapshot num pictures during a duration videos """ CameraCommon().waitForWidgetToAppear( self.ArcSoftCameraWidget().recordBtn(), "record button") for i in range(int(videoNum)): if self.ArcSoftCameraWidget().recordBtn().exists: if not self.isShutterBtnEnabled(): time.sleep(1) if not self.isShutterBtnEnabled(): self.assertTrue(False, "record button is not enabled") self.ArcSoftCameraWidget().recordBtn().click.wait() self.logger.debug("recording video start") time.sleep(2) for j in range(int(snapShotNum)): self.ArcSoftCameraWidget().snapshotImageView().click.wait() self.logger.debug("snapshot while video recording %d" % (j + 1)) if self.ArcSoftCameraWidget().snapshotImageView( ).clickable: time.sleep(0.5) else: time.sleep(1) if int(duration) > (int(snapShotNum) * 2 + 2): time.sleep(int(duration) - 2 - int(snapShotNum) * 2) else: duration = int(snapShotNum) * 2 + 2 self.ArcSoftCameraWidget().shutterBtn().click.wait() self.logger.debug("video duration is %ds" % int(duration)) self.logger.debug("recording video end") time.sleep(2) else: CameraCommon().checkCameraCrash()
def setVideoResolution(self, resolution, lens): """ Used to control the video resolution, used with the getAllVideoResolutions """ if not self.ArcSoftCameraWidget().settingVideoBtn().exists: self.ArcSoftCameraWidget().settingBtn().click.wait() CameraCommon().waitForWidgetToAppear( self.ArcSoftCameraWidget().settingVideoBtn(), "setting video button") self.ArcSoftCameraWidget().settingVideoBtn().click.wait() if not self.ArcSoftCameraWidget().videoQualityText().exists: self.ArcSoftCameraWidget().text("Video quality").click.wait() CameraCommon().waitForWidgetToAppear( self.ArcSoftCameraWidget().videoQualityText(), "video quality text") mCount = self.ArcSoftCameraWidget().videoQualityText().count if mCount > 0: if self.ArcSoftCameraWidget().text(resolution).exists: self.ArcSoftCameraWidget().text(resolution).click.wait() self.logger.debug("set video resolution to " + resolution) else: self.assertTrue( False, "camera not found " + resolution + " resolution") else: self.logger.debug("camera not found " + resolution + " resolution")
def setExposure(self, value): self.logger.debug("enter setting") if not self.ArcSoftCameraWidget().settingCommonBtn().exists: self.ArcSoftCameraWidget().settingBtn().click.wait() CameraCommon().waitForWidgetToAppear( self.ArcSoftCameraWidget().settingCameraBtn(), "setting common button") self.ArcSoftCameraWidget().settingCameraBtn().click.wait() if self.ArcSoftCameraWidget().settingScrollView().scrollable: self.d(scrollable=True).scroll.vert.to(textContains="Exposure") self.ArcSoftCameraWidget().text("Exposure").click.wait() mx, my, sx, sy = CameraCommon().getBounds( self.ArcSoftCameraWidget().settingProgressSeekBar()) ax = mx + sx / 2 ay = my + sy / 2 if value == "0": self.d.click(ax, ay) elif value == "-1": self.d.click(ax - 30, ay) elif value == "-2": self.d.click(ax - 60, ay) elif value == "+1": self.d.click(ax + 30, ay) elif value == "+2": self.d.click(ax + 60, ay) else: assert False, "The Exposure is not found!" self.logger.debug("set exposure to " + str(value)) CameraCommon().clickScreenCenter() self.logger.debug("exit setting")
def setCaptureModeValue(self, category, value="middle"): if not self.ArcSoftCameraWidget().settingVideoBtn().exists: self.ArcSoftCameraWidget().settingBtn().click.wait() CameraCommon().waitForWidgetToAppear( self.ArcSoftCameraWidget().settingCameraBtn(), "setting capture button") self.ArcSoftCameraWidget().settingCameraBtn().click.wait() if self.ArcSoftCameraWidget().settingScrollView().scrollable: self.d(scrollable=True).scroll.vert.to(textContains=category) CameraCommon().waitForWidgetToAppear( self.ArcSoftCameraWidget().text(category), "setting %s button" % category) self.ArcSoftCameraWidget().text(category).click.wait() if self.ArcSoftCameraWidget().text(value).exists: self.ArcSoftCameraWidget().text(value).click.wait() else: CameraCommon().waitForWidgetToAppear( self.ArcSoftCameraWidget().settingProgressSeekBar(), "setting %s seek bar" % category) bounds = self.ArcSoftCameraWidget().settingProgressSeekBar().bounds # print bounds["left"], bounds["right"], bounds["top"], bounds["bottom"] if value == "middle": self.d.click(((bounds["right"] - bounds["left"]) / 2 + bounds["left"]) + 5, \ (bounds["bottom"] - bounds["top"]) / 2 + bounds["top"]) elif value == "low": self.d.click(bounds["left"] + 45, \ (bounds["bottom"] - bounds["top"]) / 2 + bounds["top"]) elif value == "high": self.d.click(bounds["right"] - 45, \ (bounds["bottom"] - bounds["top"]) / 2 + bounds["top"]) else: self.logger.debug("set %s value failure" % category) self.logger.debug("set %s to %s successfully" % (category, value)) CameraCommon().clickScreenCenter()
def setUp(self): """ @summary: set up @return: None """ super(CameraTest, self).setUp() self._test_name = __name__ self.logger.debug("[Setup]: %s" % self._test_name) g_common_obj.root_on_device() self.camera_common = CameraCommon() self.host_path = self.camera_common.getTmpDir() self.rvc_camera = MultiMediaSwitchCameraHelper().camera self.camera_common.removeDeivceFile() self.camera_common.removeFile(self.host_path + "/*") self.camera_common.unlockScreen() self.rvc_camera.skipAccountLoginLyout() self.rvc_camera.backHome() self.d = g_common_obj.get_device() if self.d(text="Got it").exists: self.d(text="Got it").click.wait() self.multimedia_setting = MultiMediaSetting(self.camera_common.DEFAULT_CONFIG_FILE) need_install_result = self.multimedia_setting.install_apk("multi_camera_apk") if need_install_result: self.reboot_device() self.multi_camera_package_name, _ = self.multimedia_setting.get_package_and_activity_name("multi_camera_apk") MULTI_CAMERA_PERMISSION_LIST = ["android.permission.CAMERA"] self.camera_common.grantPermission(self.multi_camera_package_name, MULTI_CAMERA_PERMISSION_LIST)
def setUp(self): """ @summary: set up @return: None """ super(CameraTest, self).setUp() self._test_name = __name__ self.logger.debug("[Setup]: %s" % self._test_name) g_common_obj.root_on_device() self.camera_common = CameraCommon() self.host_path = self.camera_common.getTmpDir() self.rvc_camera = "" self.aosp_camera = "" self.ref_camera = "" self.case_result = -1 self.camera_common.removeDeivceFile() self.camera_common.removeFile(self.host_path + "/*") self.get_rvc_camera_class().stopCameraApp() self.camera_common.unlockScreen() self.get_rvc_camera_class().skipAccountLoginLyout() self.get_rvc_camera_class().backHome() self.d = g_common_obj.get_device() if self.d(text="Got it").exists: self.d(text="Got it").click.wait()
def setPhotoResolution(self, resolution, lens, type=""): """ Used to control the photo resolution, used with the getAllPhotoResolutions """ CameraCommon().waitForWidgetToAppear( self.GMSCameraWidget().shutterBtn(), "shutter button") self.swipeScreen("right") CameraCommon().waitForWidgetToAppear( self.GMSCameraWidget().settingsBtn(), "settings button") self.GMSCameraWidget().settingsBtn().click.wait() CameraCommon().waitForWidgetToAppear( self.GMSCameraWidget().text("Resolution & quality"), "resolution text") self.GMSCameraWidget().text("Resolution & quality").click.wait() self.GMSCameraWidget().text(str(lens) + " camera photo").click.wait() if self.GMSCameraWidget().text(resolution).exists: self.GMSCameraWidget().text(resolution).click.wait() self.logger.debug("set resolution to " + resolution) else: CameraCommon().getScreenshotAndPullToHost( "assert.png", g_common_obj.get_user_log_dir()) assert False, "This resolution is not found!" for i in range(3): if not self.isShutterBtnExists(): CameraCommon().pressBack() time.sleep(1)
def getFOVRegion(self): width = self.d.info["displayWidth"] height = self.d.info["displayHeight"] rotate = False if width < height: rotate = True [x1, y1, w1, h1] = CameraCommon().getBounds( self.ArcSoftCameraWidget().captureLayout()) print[x1, y1, w1, h1] if rotate == False: w1 += 20 x = w1 y = (height - h1) / 2 w = width - 2 * w1 h = h1 else: h1 += 20 x = (width - w1) / 2 y = h1 w = w1 h = height - 2 * h1 if rotate == True: [x, y, w, h] = CameraCommon().rotateRegion([x, y, w, h], width, height, 90) return rotate, [x, y, w, h]
def setLocation(self, location="ON"): self.logger.debug("enter camera setting") CameraCommon().waitForWidgetToAppear( self.GMSCameraWidget().shutterBtn(), "shutter button") self.swipeScreen("right") CameraCommon().waitForWidgetToAppear( self.GMSCameraWidget().settingsBtn(), "settings button") self.GMSCameraWidget().settingsBtn().click.wait() CameraCommon().waitForWidgetToAppear( self.GMSCameraWidget().text("Save location"), "Save location") time.sleep(1) if self.GMSCameraWidget().settingAdvancedSwitchWidget().exists: if self.GMSCameraWidget().settingAdvancedSwitchWidget( ).text != location: self.GMSCameraWidget().settingAdvancedSwitchWidget( ).click.wait() elif self.GMSCameraWidget().settingAdvancedSwitchWidgetForN().exists: if self.GMSCameraWidget().settingAdvancedSwitchWidgetForN( ).text != location: self.GMSCameraWidget().settingAdvancedSwitchWidgetForN( ).click.wait() for i in range(3): if not self.isShutterBtnExists(): CameraCommon().pressBack() else: break time.sleep(1) self.logger.debug("exit camera setting")
def getAllVideoResolutions(self, lens): """ Return all of the video resolutions """ CameraCommon().waitForWidgetToAppear( self.GMSCameraWidget().shutterBtn(), "shutter button") self.swipeScreen("right") CameraCommon().waitForWidgetToAppear( self.GMSCameraWidget().settingsBtn(), "settings button") self.GMSCameraWidget().settingsBtn().click.wait() CameraCommon().waitForWidgetToAppear( self.GMSCameraWidget().text("Resolution & quality"), "resolution text") self.GMSCameraWidget().text("Resolution & quality").click.wait() self.GMSCameraWidget().text(str(lens) + " camera video").click.wait() mDict = {} mCount = self.GMSCameraWidget().resolution().count for i in range(mCount): if self.GMSCameraWidget().resolutionText(i).exists: mText = self.GMSCameraWidget().resolutionText(i).info["text"] mDict.setdefault(i + 1, mText) else: break for i in range(3): if not self.isShutterBtnExists(): CameraCommon().pressBack() time.sleep(1) self.logger.debug("get all video resolution successfully") print mDict return mDict, mDict[1], mDict[mCount]
def setUp(self): """ @summary: set up @return: None """ super(CameraTest, self).setUp() self._test_name = __name__ self.logger.debug("[Setup]: %s" % self._test_name) g_common_obj.root_on_device() g_common_obj.remount_device() self.camera_common = CameraCommon() self.host_path = self.camera_common.getTmpDir() self.camera_common.removeDeivceFile() self.camera_common.removeFile(self.host_path + "/*") self.multimedia_setting = MultiMediaSetting(self.camera_common.DEFAULT_CONFIG_FILE) self.multimedia_scale_test_helper = MultiMediaScaleTestHelper(self.host_path) self.aosp_camera = AOSPCamera() self.aosp_camera.cleanMediaFiles() self.multimedia_scale_test_helper.remount_device() self.multimedia_scale_test_helper.backup_file("o_image_media_xml_file_dst_path") self.multimedia_scale_test_helper.replace_file("o_image_media_xml_file_src_path", "o_image_media_xml_file_dst_path") self.multimedia_scale_test_helper.backup_file("o_image_camera3_xml_file_dst_path")[0] self.multimedia_scale_test_helper.restore_file("o_image_camera3_xml_file_dst_path", "_hdmi") adb32._adb_reboot()
def switchRearOrFront(self, lens="Back"): """ Used to switch rear or front camera lens = Back / Front """ if lens == "Rear" or lens == "rear": lens = "Back" if self.GMSCameraWidget().threeDots().exists: self.GMSCameraWidget().threeDots().click.wait() elif self.d(description="Options").exists: self.d(description="Options").click.wait() time.sleep(1) CameraCommon().waitForWidgetToAppear( self.GMSCameraWidget().toggleBtn(), "switch camera lens button") description = self.GMSCameraWidget().toggleBtn().contentDescription time.sleep(1) if (("Back" in description) and lens == "Front") or ( ("Front" in description) and lens == "Back"): self.GMSCameraWidget().toggleBtn().click.wait() self.logger.debug("change to " + str(lens) + " camera") CameraCommon().clickScreenCenter() CameraCommon().waitForWidgetToAppear( self.GMSCameraWidget().shutterBtn(), "shutter button") time.sleep(1) return description
def snapShotDuringVideo(self, videoNum=1, duration=5, snapShotNum=1): """ Used to snapshot num pictures during a duration videos """ CameraCommon().waitForWidgetToAppear( self.GMSCameraWidget().shutterBtn(), "shutter button") for i in range(int(videoNum)): if self.GMSCameraWidget().shutterBtn().exists: self.GMSCameraWidget().shutterBtn().click.wait() self.logger.debug("video recording start") time.sleep(2) for j in range(int(snapShotNum)): CameraCommon().clickScreenCenter() self.logger.debug("snapshot while video recording %d" % (j + 1)) if self.GMSCameraWidget().shutterBtn().clickable: time.sleep(0.5) else: time.sleep(1) if int(duration) > (int(snapShotNum) * 2 + 2): time.sleep(int(duration) - 2 - int(snapShotNum) * 2) else: duration = int(snapShotNum) * 2 + 2 self.GMSCameraWidget().shutterBtn().click.wait() self.logger.debug("video duration is %ds" % int(duration)) self.logger.debug("video recording end") CameraCommon().waitForTheFilesAreGenerated() time.sleep(1.5) else: self.checkCameraCrash()
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 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 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 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 setUp(self): """ @summary: set up @return: None """ super(CameraTest, self).setUp() self._test_name = __name__ self.logger.debug("[Setup]: %s" % self._test_name) self.case_result = -1 g_common_obj.root_on_device() g_common_obj.remount_device() self.camera_common = CameraCommon() self.multimedia_setting = MultiMediaSetting(self.camera_common.DEFAULT_CONFIG_FILE) self.host_path = self.camera_common.getTmpDir() self.multimedia_scale_test_helper = MultiMediaScaleTestHelper(self.host_path) self.multimedia_checkiq_helper = MultiMediaCheckiqHelper(self.host_path) self.android_version = MultiMediaSwitchCameraHelper(skip_import_camera=True).android_version.lower() self.multimedia_scale_test_helper.scale_test_prepare() self.camera_common.removeDeivceFile() self.camera_common.removeDeivceFile(self.multimedia_scale_test_helper.movies_folder_device_path + "*") self.camera_common.removeFile(self.host_path + "/*.mp4") self.camera_common.unlockScreen() self.d = g_common_obj.get_device() self.skipAccountLoginLyout() g_common_obj.back_home() if self.d(text="Got it").exists: self.d(text="Got it").click.wait()
def checkModeExists(self, mode): self.swipeScreen() if self.GMSCameraWidget().text(mode).exists: CameraCommon().clickScreenCenter() return True else: CameraCommon().clickScreenCenter() return False
def setCaptureMode(self, value): CameraCommon().waitForWidgetToAppear( self.ArcSoftCameraWidget().modeBtn(), "mode button") self.ArcSoftCameraWidget().modeBtn().click.wait() CameraCommon().waitForWidgetToAppear( self.ArcSoftCameraWidget().text(value), value) self.ArcSoftCameraWidget().text(value).click.wait() self.logger.debug("set capture mode to %s successfully" % value) CameraCommon().clickScreenCenter()
class MulticameraApkHelper: MULTI_CAMERA_CONFIG_DICT = { "camera0_input_field": 1, "camera0_input_resolution": 3, "camera0_input_format": 4, "camera0_input_default": 5, "camera0_output_resolution": 0, "camera0_output_format": 2, "camera1_input_field": 7, "camera1_input_resolution": 9, "camera1_input_format": 10, "camera1_input_default": 11, "camera1_output_resolution": 6, "camera1_output_format": 8 } def __init__(self): self.d = g_common_obj.get_device() self.camera_common = CameraCommon() self.get_cfg_file_helper = GetConfigFileHelper( "", "multicamera_apk_helper.conf") self.multimedia_setting = MultiMediaSetting( self.get_cfg_file_helper.cfg_file) need_install_result = self.multimedia_setting.install_apk( "multicamera_apk") if need_install_result: adb32._adb_reboot() time.sleep(15) self.multicamera_apk_package_name, _ = self.multimedia_setting.get_package_and_activity_name( "multicamera_apk") MULTI_CAMERA_PERMISSION_LIST = ["android.permission.CAMERA"] self.camera_common.grantPermission(self.multicamera_apk_package_name, MULTI_CAMERA_PERMISSION_LIST) def launch_multicamera_apk(self): return self.multimedia_setting.launch_apk("multicamera_apk") def stop_multicamera_apk(self): return self.multimedia_setting.stop_apk("multicamera_apk") def set_multicamera_config(self, config_list): logger.debug("set_multicamera_config start. config_list=%s" % config_list) for config_str in config_list: config_item, config_value = config_str.split(":") if config_item not in self.MULTI_CAMERA_CONFIG_DICT.keys(): continue logger.debug("config_item:%s, config_value:%s" % (config_item, config_value)) self.d(className="android.widget.Spinner")[ self.MULTI_CAMERA_CONFIG_DICT[config_item]].click.wait() time.sleep(1) self.d(textContains=config_value).click.wait() time.sleep(1) logger.debug("set_multicamera_config end.")
def startQuickPicApp(self): """ Used to start the camera application """ CameraCommon().unlockScreen() self.logger.debug("launch quickpic app start") os.system("adb shell am start -n %s/%s" % (self.PACKAGE_NAME_QUICKPIC, self.ACTIVITY_NAME_QUICKPIC)) CameraCommon().waitForWidgetToAppear(self.QuickPicWidget().searchBtn(), "search button") self.logger.debug("launch quickpic app successfully") time.sleep(1)