class CameraTest(CameraTestBase): """ @summary: This test used to test camera function """ MULTI_CAMERA_CONFIG_DICT = {"input_field" : 1 ,"input_resolution" :3 ,"input_format" : 4 ,"input_default" : 5 ,"output_resolution" : 0 ,"output_format" : 2} def setUp(self): """ @summary: set up @return: None """ super(CameraTest, self).setUp() self._test_name = __name__ self.logger.debug("[Setup]: %s" % self._test_name) g_common_obj.root_on_device() self.camera_common = CameraCommon() self.host_path = self.camera_common.getTmpDir() self.rvc_camera = MultiMediaSwitchCameraHelper().camera self.camera_common.removeDeivceFile() self.camera_common.removeFile(self.host_path + "/*") self.camera_common.unlockScreen() self.rvc_camera.skipAccountLoginLyout() self.rvc_camera.backHome() self.d = g_common_obj.get_device() if self.d(text="Got it").exists: self.d(text="Got it").click.wait() self.multimedia_setting = MultiMediaSetting(self.camera_common.DEFAULT_CONFIG_FILE) need_install_result = self.multimedia_setting.install_apk("multi_camera_apk") if need_install_result: self.reboot_device() self.multi_camera_package_name, _ = self.multimedia_setting.get_package_and_activity_name("multi_camera_apk") MULTI_CAMERA_PERMISSION_LIST = ["android.permission.CAMERA"] self.camera_common.grantPermission(self.multi_camera_package_name, MULTI_CAMERA_PERMISSION_LIST) def tearDown(self): """ @summary: tearDown @return: None """ super(CameraTest, self).tearDown() self.logger.debug("[Teardown]: %s" % self._test_name) g_common_obj.stop_exp_handle() self.camera_common.removeDeivceFile() self.camera_common.clean_app_data(self.multi_camera_package_name) time.sleep(3) self.rvc_camera.backHome() def reboot_device(self): self.rvc_camera.pressPowerKey(10) time.sleep(5) self.rvc_camera.pressPowerKey(2) time.sleep(30) g_common_obj.root_on_device() self.camera_common.unlockScreen() self.rvc_camera.backHome() self.check_home_or_lock_layout() def set_multicamera_input_config_format(self, input_config_format): if "multicamera_input_config_format" in os.environ: previous_input_config_format = os.environ["multicamera_input_config_format"] if previous_input_config_format == input_config_format: self.logger.debug("skip set multicamera_input_config_format") return False g_common_obj.adb_cmd("setprop camera.input.config.format %s" % input_config_format) os.environ["multicamera_input_config_format"] = input_config_format self.logger.debug("set multicamera_input_config_format = %s" % input_config_format) return True def launch_multi_camera_apk(self): return self.multimedia_setting.launch_apk("multi_camera_apk") def stop_multi_camera_apk(self): return self.multimedia_setting.stop_apk("multi_camera_apk") def check_home_or_lock_layout(self, check_exist=True): if self.d(text="Got it").exists: self.d(text="Got it").click.wait() assert self.rvc_camera.isHomeLayoutExists() or self.rvc_camera.isLockLayoutExists(), "Home or Lock layout not exist!" def check_logcat_data(self, data_list, fps): self.logger.debug("check_logcat_data data_list=%s" % data_list) for t_fps in data_list: t_fps = float(t_fps) if fps * 0.97 > t_fps or t_fps > fps * 1.03: return False, t_fps return True, 1 def set_multi_camera_config(self, config_list): self.logger.debug("set_multi_camera_config start. config_list=%s" % config_list) for config_str in config_list: config_item, config_value = config_str.split(":") self.logger.debug("config_item:%s, config_value:%s" % (config_item, config_value)) self.d(className="android.widget.Spinner")[self.MULTI_CAMERA_CONFIG_DICT[config_item]].click.wait() time.sleep(1) self.d(textContains=config_value).click.wait() time.sleep(1) self.logger.debug("set_multi_camera_config end.") def check_multi_camera(self, input_size, output_size): config_list = ["input_field:interlaced" ,"input_resolution:%s" % input_size ,"input_format:default" ,"input_default:HW_Weaving" ,"output_resolution:%s" % output_size ,"output_format:NV21" ] self.set_multicamera_input_config_format("uyvy") self.launch_multi_camera_apk() self.set_multi_camera_config(config_list) self.d(textContains="Camera0:OFF").click.wait() time.sleep(10) self.camera_common.checkCameraCrash() assert self.d(packageName="com.example.tim.multicamera").exists, "Can't find multicamera in layout, maybe apk crashed." self.stop_multi_camera_apk() def check_multi_camera_with_fps(self, input_size, output_size): config_list = ["input_field:interlaced" ,"input_resolution:%s" % input_size ,"input_format:default" ,"input_default:HW_Weaving" ,"output_resolution:%s" % output_size ,"output_format:NV21" ] expect_fps = 50 self.set_multicamera_input_config_format("uyvy") self.launch_multi_camera_apk() self.set_multi_camera_config(config_list) g_common_obj.adb_cmd("setprop camera.hal.perf 3") time.sleep(2) self.d(textContains="Camera0:OFF").click.wait() self.camera_common.checkCameraCrash() self.multimedia_logcat_helper = MultiMediaLogcatHelper("adb logcat CameraHardwareSoc:D *:S") self.multimedia_logcat_helper.get_logcat_data_start() time.sleep(5*60) result_list = self.multimedia_logcat_helper.get_logcat_data_end("total fps is (.*),") check_logcat_data_result, error_fps = self.check_logcat_data(result_list, expect_fps) assert check_logcat_data_result, "Fps error! error_fps=%s, expect_fps=%s, result_list=%s" % (error_fps, expect_fps, result_list) self.camera_common.checkCameraCrash() self.stop_multi_camera_apk() def test_Camera_Scale_AVM737_720x480_to_1280x720(self): self.check_multi_camera("720x480", "1280x720") def test_Camera_Scale_AVM737_720x480_to_1920x1080(self): self.check_multi_camera("720x480", "1920x1080") def test_Camera_Scale_AVM737_720x480_to_640x480(self): self.check_multi_camera("720x480", "640x480") def test_Camera_Scale_AVM737_720x480_to_720x480(self): self.check_multi_camera("720x480", "720x480") def test_Camera_Scale_AVM737_720x480_to_320x240(self): self.check_multi_camera("720x480", "320x240") def test_Camera_Scale_AVM737_720x480_to_176x144(self): self.check_multi_camera("720x480", "176x144") def test_Camera_Scale_AVM737_720x480_to_1280x720_50fps(self): self.check_multi_camera_with_fps("720x480", "1280x720") def test_Camera_Scale_AVM737_720x480_to_1920x1080_50fps(self): self.check_multi_camera_with_fps("720x480", "1920x1080") def test_Camera_Scale_AVM737_720x480_to_640x480_50fps(self): self.check_multi_camera_with_fps("720x480", "640x480") def test_Camera_Scale_AVM737_720x480_to_720x480_50fps(self): self.check_multi_camera_with_fps("720x480", "720x480") def test_Camera_Scale_TP_UYVY_640x480_Progressive_fps_60(self): pass
class IVICamera(CameraTestBase): POWER_REALY = "power_relay" CAMERA_RELAY = "camera_relay" def __init__(self, cfg=None): if cfg == None: self.cfg = self.config.read(CameraCommon.DEFAULT_CONFIG_FILE, "multimedia_camera") else: self.cfg = cfg self.d = g_common_obj.get_device() self.camera_common = CameraCommon() self.logger = CameraLogger.instance() self.x = self.d.info["displayWidth"] self.y = self.d.info["displayHeight"] self.relay08_helper = Relay08Helper() self.waitStartCameraTime = 15 class IVICameraWidget: def __init__(self): self.d = g_common_obj.get_device() def homeLayout(self): ''' layout capture ''' return self.d(packageName="com.android.launcher") def lockLayout(self): ''' layout capture ''' return self.d(packageName="com.android.systemui") def cameraLayout(self): ''' layout capture ''' return self.d(packageName="com.intel.rvc") #============================================================= def checkCameraCrash(self): self.camera_common.checkCameraCrash() def isHomeLayoutExists(self): if self.d(text="Got it").exists: self.d(text="Got it").click.wait() if self.camera_common.isWidgetExists(self.IVICameraWidget().homeLayout()) == True: return True else: return self.camera_common.isWidgetExists(self.d(packageName="com.android.launcher3")) def isLockLayoutExists(self): return self.camera_common.isWidgetExists(self.IVICameraWidget().lockLayout()) def isCameraLayoutExists(self): return self.camera_common.isWidgetExists(self.IVICameraWidget().cameraLayout()) def swipeScreen(self, orientation="right"): # Don't need to implement pass #------------------------------------------------------------ # Interfaces' implementations are from here def clean_media_files(self): """ Used to clean the media files in some folders; eg. /mnt/sdcard/DCIM/Camera """ self.logger.debug("clean media files start") g_common_obj.stop_app_am(self.PACKAGE_NAME_ARCSOFTCAMERA) g_common_obj.adb_cmd("pm clear %s" % self.PACKAGE_NAME_ARCSOFTCAMERA) self.logger.debug("clean media files successfully") def reboot_device(self): self.pressPowerKey(10) time.sleep(5) self.pressPowerKey(2) # from testlib.common.common import g_common_obj2 # g_common_obj2.system_reboot(30) time.sleep(40) g_common_obj.root_on_device() # g_common_obj.remount_device() os.system("adb shell uiautomator dump /data/local/tmp/uidump.xml")#get layout, 20170822 has bug, can't find layout! self.camera_common.unlockScreen() self.backHome() self.check_home_or_lock_layout() def startCameraApp(self, check_success=1): """ Used to start the camera application """ self.logger.debug("launch ivi camera start") self.relay08_helper.set_relay_NO(IVICamera.CAMERA_RELAY) start = time.time() success = False if check_success == 1: while time.time() - start < self.waitStartCameraTime: if self.isCameraLayoutExists(): success = True break time.sleep(1) self.checkCameraCrash() if not success: scname = g_common_obj.get_user_log_dir() + "/assert.png" g_common_obj.take_screenshot(scname) assert False, "ivi camera launch fail,launch time is greater than " \ + str(self.waitStartCameraTime) + " seconds" self.logger.debug("launch ivi camera successfully") else: self.logger.debug("launch ivi camera, skip check function") def stopCameraApp(self): """ Used to stop the camera application """ self.relay08_helper.set_relay_NC(IVICamera.CAMERA_RELAY) self.logger.debug("stop ivi camera app successfully") def pressPowerKey(self, duration=4): self.logger.debug("press power key start") self.relay08_helper.set_relay_NO(IVICamera.POWER_REALY) time.sleep(duration) self.relay08_helper.set_relay_NC(IVICamera.POWER_REALY) def backHome(self): self.d.press.home() def skipAccountLoginLyout(self): pass def check_home_or_lock_layout(self, check_exist=True): assert self.isHomeLayoutExists() or self.isLockLayoutExists(), "Home or Lock layout not exist!"
class RefCamCamera(CameraAppInterface, CameraTestBase): PACKAGE_NAME_REFCAMCAMERA = "com.intel.refcam" ACTIVITY_NAME_REFCAMCAMERA = ".CameraActivity" PERMISSION_LIST = [ "android.permission.ACCESS_FINE_LOCATION", "android.permission.CAMERA", "android.permission.WRITE_EXTERNAL_STORAGE", "android.permission.READ_EXTERNAL_STORAGE", "android.permission.RECORD_AUDIO" ] def __init__(self, cfg=None): if cfg == None: self.cfg = self.config.read(CameraCommon.DEFAULT_CONFIG_FILE, "multimedia_camera") else: self.cfg = cfg self.d = g_common_obj.get_device() self.logger = CameraLogger.instance() self.x = self.d.info["displayWidth"] self.y = self.d.info["displayHeight"] self.camera_widget = self.CameraWidget() self.camera_common = CameraCommon() self.multimedia_setting = MultiMediaSetting( self.camera_common.DEFAULT_CONFIG_FILE) self.multimedia_setting.install_apk("ref_camera_1_apk") self.camera_common.grantPermission(self.PACKAGE_NAME_REFCAMCAMERA, self.PERMISSION_LIST) class CameraWidget: def __init__(self): self.d = g_common_obj.get_device() def frontback(self): ''' front back button ''' return self.d(resourceId="com.intel.refcam:id/switch_frontback") def itemChildMenu(self): ''' item clild menu ''' return self.d( resourceId="com.intel.refcam:id/setting_item_child_menu_text") def seekBar(self): ''' menu seek bar ''' return self.d( resourceId="com.intel.refcam:id/setting_item_child_menu_seekbar" ) def shutterBtn(self): ''' shutter button ''' return self.d(resourceId="com.intel.refcam:id/shutter") def shotlist(self): ''' front back button ''' return self.d(resourceId="com.intel.refcam:id/open_shot_list") def settingsBtn(self): ''' settings ''' return self.d(resourceId="com.intel.refcam:id/setting") def text(self, _text): ''' page text ''' return self.d(textContains=_text) def itemChildMenuText(self, _text): ''' page text ''' return self.d( resourceId="com.intel.refcam:id/setting_item_child_menu_text", textContains=_text) def zoomLayer(self): ''' zoom layer ''' return self.d(resourceId="com.intel.refcam:id/zoom_layer") #============================================================= def clickScreen(self): d = g_common_obj.get_device() x = d.info["displayWidth"] self.camera_common.clickBtn(x - 100, 300) def isShutterBtnExists(self): return self.camera_common.isWidgetExists( self.camera_widget.shutterBtn()) def setCaptureMode(self, value): self.camera_common.waitForWidgetToAppear(self.camera_widget.shotlist(), "mode button") self.camera_widget.shotlist().click.wait() self.camera_widget.text(value).click.wait() self.logger.debug("set capture mode to %s successfully" % value) self.camera_common.clickScreenCenter() #------------------------------------------------------------ # Interfaces' implementations are from here def cleanMediaFiles(self): """ Used to clean the media files in some folders; eg. /mnt/sdcard/DCIM/Camera """ self.logger.debug("clean media files start") g_common_obj.stop_app_am(self.PACKAGE_NAME_REFCAMCAMERA) g_common_obj.adb_cmd("pm clear %s" % self.PACKAGE_NAME_REFCAMCAMERA) self.logger.debug("clean media files successfully") def startCameraApp(self): """ Used to start the camera application """ self.camera_common.unlockScreen() self.logger.debug("launch refcam2 camera start") os.system( "adb shell am start -S %s/%s" % (self.PACKAGE_NAME_REFCAMCAMERA, self.ACTIVITY_NAME_REFCAMCAMERA)) time_left = 0 start = time.time() success = False while time_left < self.camera_common.waitStartAppTime + 15: if self.isShutterBtnExists() or self.camera_widget.shotlist( ).exists: success = True break if self.camera_widget.text( "Allow").exists or self.camera_widget.text("ALLOW").exists: self.camera_common.checkGuide() if self.camera_common.getAndroidVersion() == "N": self.stopCameraApp() os.system("adb shell am start -S %s/%s" % (self.PACKAGE_NAME_REFCAMCAMERA, self.ACTIVITY_NAME_REFCAMCAMERA)) time_left = time.time() - start time.sleep(0.5) self.camera_common.checkCameraCrash() if (not success ) or time_left > self.camera_common.waitStartAppTime + 15: scname = g_common_obj.get_user_log_dir() + "/assert.png" g_common_obj.take_screenshot(scname) assert False, "refcam2 camera launch fail,launch time is greater than " \ + str(self.camera_common.waitStartAppTime + 15) + " seconds" self.logger.debug("launch refcam2 camera successfully") def stopCameraApp(self): """ Used to stop the camera application """ g_common_obj.stop_app_am(self.PACKAGE_NAME_REFCAMCAMERA) self.logger.debug("stop arcsoft camera app successfully") def selectMode(self, mode="Camera"): """ Used to select a mode such as camera, video, panorama, lens blur, photo sphere and so on... """ self.camera_common.waitForWidgetToAppear( self.camera_widget.shutterBtn(), "shutter button") self.camera_widget.shotlist().click.wait() self.camera_widget.text(mode).click.wait() self.camera_common.clickScreenCenter() self.logger.debug("Change to %s mode" % mode) def switchRearOrFront(self, lens="Back"): """ Used to switch rear or front camera lens = Back / Front """ self.camera_common.waitForWidgetToAppear( self.camera_widget.shutterBtn(), "shutter button") if lens == "Front": self.camera_widget.frontback().click.wait() self.logger.debug("change to " + str(lens) + " camera") if lens == "Back" or lens == "Rear": self.logger.debug("change to " + str(lens) + " camera") time.sleep(2) def setExposure(self, value): pass def setFlash(self, flash="off"): """ Used to control the flash; on, off, auto """ pass def setGrid(self, grid="off"): """ Used to control the grid; on, off """ pass def setTimer(self, timer="off"): """ Used to control the timer value: off/2s/3s/10s """ pass def getAllVideoResolutions(self, lens): """ Return all of the video resolutions """ pass def setVideoResolution(self, resolution, lens): """ Used to control the video resolution, used with the getAllVideoResolutions """ pass def getAllCameraMode(self): pass def getAllPhotoResolutions(self, lens, type="Capture Size (JPEG)"): """ Return all of the photo resolutions """ self.camera_common.waitForWidgetToAppear( self.camera_widget.settingsBtn(), "setting button") self.camera_widget.settingsBtn().click.wait() if not self.camera_widget.text(type).exists: self.d(scrollable=True).scroll.vert.to(textContains=type) self.camera_common.waitForWidgetToAppear(self.camera_widget.text(type), "capture size button") self.camera_widget.text(type).click.wait() mCount = self.camera_widget.itemChildMenu().count mList = [] for i in range(mCount): mList.append(self.camera_widget.itemChildMenu()[i].info["text"]) self.clickScreen() self.logger.debug("mList=%s" % mList) if mList == []: self.logger.debug( "can't find photo resolutions with \"%s\" type!" % type) return [], -1, -1 else: return mList, mList[0], mList[mCount - 1] def setSettingsButton(self, main_click_button, sub_click_button): self.camera_common.waitForWidgetToAppear( self.camera_widget.settingsBtn(), "setting button") self.camera_widget.settingsBtn().click.wait() if not self.camera_widget.text(main_click_button).exists: self.d(scrollable=True).scroll.vert.to( textContains=main_click_button) self.camera_common.waitForWidgetToAppear( self.camera_widget.text(main_click_button), "click main button: %s" % main_click_button) self.camera_widget.text(main_click_button).click.wait() self.camera_widget.itemChildMenuText(sub_click_button).click.wait() self.logger.debug("click sub button: %s" % sub_click_button) self.clickScreen() def setPhotoResolution(self, resolution, lens, type="Capture Size (JPEG)"): """ Used to control the photo resolution, used with the getAllPhotoResolutions """ self.camera_common.waitForWidgetToAppear( self.camera_widget.settingsBtn(), "setting button") self.camera_widget.settingsBtn().click.wait() if not self.camera_widget.text(type).exists: self.d(scrollable=True).scroll.vert.to(textContains=type) self.camera_common.waitForWidgetToAppear(self.camera_widget.text(type), "capture size button") self.camera_widget.text(type).click.wait() self.camera_widget.itemChildMenuText(resolution).click.wait() self.logger.debug("set resolution to " + resolution) self.clickScreen() def capturePhoto(self, num=1, generated=True): """ Used to capture num photos """ self.camera_common.waitForWidgetToAppear( self.camera_widget.shutterBtn(), "shutter button") for i in range(int(num)): if self.camera_widget.shutterBtn().exists: self.camera_widget.shutterBtn().click.wait() self.logger.debug("capture photo %d" % (i + 1)) if generated: self.camera_common.waitForTheFilesAreGenerated() time.sleep(1.5) else: self.camera_common.checkCameraCrash() def reviewPhoto(self, num=1): """ Used to review num photos """ pass def reviewPhotoAndVideo(self, num=1, timeout=10): """ Used to review num photos """ pass def recordVideo(self, videoNum=1, duration=5): """ Used to capture num duration videos """ pass def reviewVideo(self, num=1, duration=1): """ Used to review num duration videos """ pass def snapShotDuringVideo(self, videoNum=1, duration=5, snapShotNum=1): """ Used to snapshot num pictures during a duration videos """ pass
class CameraBenchTest(CameraTestBase): """ @summary: This test used to test camera function """ def setUp(self): """ @summary: set up @return: None """ super(CameraBenchTest, self).setUp() self._test_name = __name__ print "[Setup]: %s" % self._test_name def tearDown(self): """ @summary: tearDown @return: None """ super(CameraBenchTest, self).tearDown() print "[Teardown]: %s" % self._test_name g_common_obj.stop_exp_handle() time.sleep(3) def appPrepare(self): self.camera = CameraCommon().switchPlatform(None, False, True, False, True) # self.camera = RefCam2Camera() self.common = CameraCommon() self.multimedia_setting = MultiMediaSetting( CameraCommon.DEFAULT_CONFIG_FILE) # self.camera = self.common.switchPlatform() self.checkImage = CheckImage() self.video = CheckVideo() # self.checkIQ = CheckIQ() self.host_path = self.common.getTmpDir() self.makefileTime = self.common.makefileTime self.camera_dir = self.common.camera_dir self.common.removeDeivceFile() self.common.removeFile(self.host_path + "/*") self.camera.cleanMediaFiles() # self.common.setOrientationToVertical() self.logger.debug("app prepare successfully") self.device = self.common.initDevice() self.common.resetDevice(self.device) def checkFileCorrupt(self, mediaFileCount=1): return self.common.checkFileCorrupt(mediaFileCount) def cameraExtendPanoramaRearLeft2RightAutoStopTest(self): try: self.appPrepare() # self.common.controlLightBox(1) # self.common.controlLightBox(6) # device = self.common.initDevice() self.camera.startCameraApp() self.camera.switchRearOrFront("Back") self.camera.setCaptureMode("Panorama") self.camera.capturePhoto(1, False) time.sleep(3) self.common.rotateDevice(self.device, -180) self.common.resetDevice(self.device) self.checkFileCorrupt() # self.common.controlLightBox(6) # self.common.controlLightBox(1) except Exception as e: self.common.resetDevice(self.device) self.common.checkCameraCrash() self.assertTrue(False, e) def cameraFaceTrackTurnOnAndOffTest(self, lens): try: self.appPrepare() self.camera.startCameraApp() self.camera.switchRearOrFront(lens) if lens == "Back": self.common.rotateDevice(self.device, -90) else: self.common.rotateDevice(self.device, 90) self.camera.faceDetectionOnAndOff() time.sleep(5) self.common.clickScreenCenter() self.common.getScreenshotAndPullToHost("sc_enable_ft1.png", self.host_path) self.camera.faceDetectionOnAndOff() time.sleep(5) self.common.clickScreenCenter() self.common.pressBack(2) self.camera.startCameraApp() self.common.getScreenshotAndPullToHost("sc_disable_ft2.png", self.host_path) self.camera.faceDetectionOnAndOff() time.sleep(5) self.common.clickScreenCenter() self.common.getScreenshotAndPullToHost("sc_enable_ft2.png", self.host_path) self.common.resetDevice(self.device) remotejarFile = self.multimedia_setting.download_file_to_host( "Multimedia_Camera/apk/IQCheck") print remotejarFile iqcheckDir = self.host_path + os.sep + "IQCheck" print iqcheckDir if os.path.exists(iqcheckDir) == False: os.system("cp " + remotejarFile + " " + iqcheckDir) os.system("chmod 777 " + iqcheckDir) checkIQ = CheckIQ("", self.host_path) l = self.camera.getFOVRegion() region = CheckIQ.Region(l[0], l[1], l[2], l[3], False) enable_number1 = checkIQ.detectRect( self.host_path + "/sc_enable_ft1.png", region) disable_number = checkIQ.detectRect( self.host_path + "/sc_disable_ft2.png", region) enable_number2 = checkIQ.detectRect( self.host_path + "/sc_enable_ft2.png", region) if enable_number1 > disable_number: self.logger.debug("face detect success") else: os.system("cp " + self.host_path + "/sc_enable_ft1.png " + g_common_obj.get_user_log_dir()) os.system("cp " + self.host_path + "/sc_disable_ft2.png " + g_common_obj.get_user_log_dir()) self.logger.debug("enable_number1=" + str(enable_number1)) self.logger.debug("disable_number=" + str(disable_number)) self.assertTrue(False, "face detect failure") if enable_number2 > disable_number: self.logger.debug("face detect success") else: os.system("cp " + self.host_path + "/sc_enable_ft1.png " + g_common_obj.get_user_log_dir()) os.system("cp " + self.host_path + "/sc_disable_ft2.png " + g_common_obj.get_user_log_dir()) self.logger.debug("enable_number2=" + str(enable_number2)) self.logger.debug("disable_number=" + str(disable_number)) self.assertTrue(False, "face detect failure") # print self.checkIQ.detectRect("/tmp/logs/sc_disable_ft2.png",self.checkIQ.Region(self.camera.getFOVRegion(),False)) # print self.checkIQ.detectRect("/tmp/logs/sc_enable_ft2.png", self.checkIQ.Region(self.camera.getFOVRegion(), False)) except Exception as e: self.common.resetDevice(self.device) self.common.checkCameraCrash() self.assertTrue(False, e) def cameraSceneDetectPortraitCaptureTest(self): try: self.appPrepare() self.camera.startCameraApp() self.camera.switchRearOrFront("Back") self.camera.capturePhoto() info = self.checkFileCorrupt()[0] value = info.get("Scene Capture Type") if None != value: if value != "Standard": self.assertTrue(False, "scene capture type is not standard") else: self.assertTrue(False, "scene capture type info is none") self.common.removeDeivceFile() self.camera.setCaptureMode("Smart") self.common.clickScreenCenter() self.camera.capturePhoto() info = self.checkFileCorrupt()[0] value = info.get("Scene Capture Type") if None != value: if value != "Portrait": self.assertTrue(False, "scene capture type is not portrait") else: self.logger.debug( "check scene capture type is portrait success") else: self.assertTrue(False, "scene capture type info is none") self.camera.switchRearOrFront("Front") self.camera.capturePhoto() info = self.checkFileCorrupt()[0] value = info.get("Scene Capture Type") if None != value: # print "=====================front value3=" + value if value != "Standard": self.assertTrue(False, "scene capture type is not standard") else: self.assertTrue(False, "scene capture type info is none") self.common.removeDeivceFile() self.camera.setCaptureMode("Smart") self.common.clickScreenCenter() self.camera.capturePhoto() info = self.checkFileCorrupt()[0] value = info.get("Scene Capture Type") if None != value: # print "====================front value4=" + value if value != "Portrait": self.assertTrue(False, "scene capture type is not portrait") else: self.logger.debug( "check scene capture type is portrait success") else: self.assertTrue(False, "scene capture type info is none") self.common.resetDevice(self.device) except Exception as e: self.common.resetDevice(self.device) self.common.checkCameraCrash() self.assertTrue(False, e) def cameraSmileShotSmileDetectTest(self, lens): try: self.appPrepare() self.camera.startCameraApp() self.camera.switchRearOrFront(lens) if lens == "Back": self.common.rotateDevice(self.device, -90) else: self.common.rotateDevice(self.device, 90) self.camera.setCaptureMode("Smile") time.sleep(10) if self.common.checkDeviceFile(): self.assertTrue(False, "file exists, check file failed") self.camera.capturePhoto() self.checkFileCorrupt() self.common.removeDeivceFile() if lens == "Back": self.common.rotateDevice(self.device, 90) else: self.common.rotateDevice(self.device, 90) if not self.common.checkDeviceFile(): self.assertTrue(False, "file not exists, check file failed") self.checkFileCorrupt() self.common.resetDevice(self.device) except Exception as e: self.common.resetDevice(self.device) self.common.checkCameraCrash() self.assertTrue(False, e) def test_Camera_ExtendPanorama_Rear_Left2Right_AutoStop(self): self.cameraExtendPanoramaRearLeft2RightAutoStopTest() def test_Camera_FaceTrack_Front_TurnOnAndOff(self): self.cameraFaceTrackTurnOnAndOffTest("Front") def test_Camera_FaceTrack_Rear_TurnOnAndOff(self): self.cameraFaceTrackTurnOnAndOffTest("Back") def test_Camera_SceneDetect_Portrait_Capture(self): self.cameraSceneDetectPortraitCaptureTest() def test_Camera_SmileShot_Front_SmileDetect(self): self.cameraSmileShotSmileDetectTest("Front") def test_Camera_SmileShot_Rear_SmileDetect(self): self.cameraSmileShotSmileDetectTest("Back")