def editImageInCamera(self): self.d(className="android.view.View").swipe.left() self.d(className="android.widget.ImageView").click.wait() if not self.d( resourceId= "com.android.camera2:id/filmstrip_bottom_control_edit").exists: CameraImpl().getScreenshotAndPullToHost( "assert.png", g_common_obj.get_user_log_dir()) assert self.d( resourceId="com.android.camera2:id/filmstrip_bottom_control_edit" ).exists, "[ERROR]: The button is not found!" self.d( resourceId="com.android.camera2:id/filmstrip_bottom_control_edit" ).click.wait() time.sleep(2) CameraLogger.instance().debug("edit") self.d(description="CROP").click.wait() time.sleep(2) CameraLogger.instance().debug("Done") self.d(description="Apply").click.wait() if not self.d(description="CROP").exists: CameraImpl().getScreenshotAndPullToHost( "assert.png", g_common_obj.get_user_log_dir()) assert self.d( description="CROP").exists, "[ERROR]: The button is not found!" time.sleep(2) self.d(text="Done").click.wait()
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 basic_test(self): """ Basic funtion test """ g_common_obj.launch_app_from_home_sc("Slides") if not self._locator.btn_add.exists: print "[WARNING:UI is changed! Just test launch function]" assert self.d( packageName="com.google.android.apps.docs.editors.slides" ).exists pth = g_common_obj.get_user_log_dir() self.d.screenshot(pth + "/slides.png") self.d.press.back() return self._locator.btn_add.click() time.sleep(10) if not self._locator.btn_overflow.exists: print "[WARNING:UI is changed! Just test add function]" assert self.d( packageName="com.google.android.apps.docs.editors.slides" ).exists pth = g_common_obj.get_user_log_dir() self.d.screenshot(pth + "/slides.png") self.d.press.back() return assert self._locator.btn_overflow.exists g_common_obj.back_home()
def basic_test(self): """ Basic funtion test """ self.d.watcher("SKIP").when(text="SKIP").click(text="SKIP") self.launch_from_am() if self._locator.btn_account.exists: self._locator.btn_tabhost.swipe.left() if not self._locator.btn_people.exists: print "[WARNING:UI is changed! Just test launch function]" assert self.d(packageName="com.google.android.talk").exists pth = g_common_obj.get_user_log_dir() self.d.screenshot(pth + "/hangouts.png") self.d.press.back() return self._locator.btn_people.click() if not self._locator.btn_conver.exists: print "[WARNING:UI is changed! Just test launch function]" assert self.d(packageName="com.google.android.talk").exists pth = g_common_obj.get_user_log_dir() self.d.screenshot(pth + "/hangouts.png") self.d.press.back() return self._locator.btn_conver.click() self.d.press.back()
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 pictureWallpaperContactIconTest(self): try: self.appPrepare() CameraCommon().pressHome() CameraCommon().getScreenshotAndPullToHost("sc1.png", self.host_path) self.camera.startCameraApp() self.camera.selectMode("Camera") self.camera.capturePhoto() CameraCommon().pressBack(2) CameraCommon().setWallpaper("picture") CameraCommon().getScreenshotAndPullToHost("sc2.png", self.host_path) if self.checkImage.compare_images(self.host_path + "/sc1.png", self.host_path + "/sc2.png"): os.system("cp " + self.host_path + "/sc1.png" + " " + g_common_obj.get_user_log_dir()) os.system("cp " + self.host_path + "/sc2.png" + " " + g_common_obj.get_user_log_dir()) self.assertTrue(False, "change wallpaper fail") except Exception as e: CameraCommon().checkCameraCrash() self.assertTrue(False, e) finally: CameraCommon().setWallpaper()
def checkFileCorrupt(self, mediaFileCount=1, checkSim=False): file_name_list = CameraCommon().pullFileAndCheckFileNumber(self.camera_dir, self.host_path, mediaFileCount) for i in range(len(file_name_list)): self.path = self.host_path + "/" + file_name_list[i] for j in range(10): if not CameraCommon().checkFile(self.path): CameraCommon().adbPullFile(self.camera_dir + file_name_list[i], self.host_path) time.sleep(2) else: self.logger.debug(str(file_name_list[i]) + " exists") break time.sleep(2) self.path = self.host_path + "/" + file_name_list[i] os.system("cp "+self.path+" "+g_common_obj.get_user_log_dir()) self.logger.debug("===picture path="+g_common_obj.get_user_log_dir()+"/"+file_name_list[i]+"===") if checkSim: panaFile = g_common_obj.get_user_log_dir()+"/"+file_name_list[i] self.logger.debug("===compare "+panaFile+" with the pano1.jpg====") #os.environ['LD_LIBRARY_PATH'] = "/lib:/usr/lib:/usr/local/lib" #os.putenv('LD_LIBRARY_PATH', "/lib:/usr/lib:/usr/local/lib") #currentDir = os.path.abspath(os.path.dirname(__file__)) #cmd = currentDir+os.sep+"GASServer "+currentDir+"/pano1.jpg "+panaFile #import subprocess #output=subprocess.Popen(cmd,shell=True,stdout=subprocess.PIPE).communicate() #self.logger.debug(output[0][:-1]) #s=output[0][:-1].split("\n")[2] #percent=int(s.split(" ")[2].split("%")[0]) #if percent < 30: # assert False, "similar checking result < 30% Fail! "+panaFile+" is not similar with pano1.jpg" #else: # self.logger.debug("similar checking result > 30% Pass!") str_name = file_name_list[i].split('.') suffix = str_name[1] if not suffix: assert False, "file name without the suffix" if suffix == "jpg": errMsg = self.checkImage.check_image_corrupt(self.path) if errMsg != "": assert False, errMsg else: self.info = CameraCommon().getExifInfo(file_name_list[i], self.host_path + "/") self.logger.debug("picture validation successful") continue elif suffix == "mp4" or suffix == "3gp": if self.video.check_video_corrupt(self.path): self.info = CameraCommon().getExifInfo(file_name_list[i], self.host_path + "/") self.logger.debug("video validation successful") else: self.logger.debug("video validation fails") # self.removeFile(self.host_path + "/*") # self.removeDeivceFile() return self.info, file_name_list[0]
def addFileHandler(self, mode="a+", filename=None, loglevel=5): filename = filename if filename else \ os.path.join(g_common_obj.get_user_log_dir(),MultimediaLogger.LOG_FILE) print "*****************************************************************" print g_common_obj.get_user_log_dir() loglevel = loglevel if loglevel else Logger.LOGLEVELS.get("DEBUG") self.format = logging.Formatter( "[%(asctime)s - tid:%(thread)d - Multimedia-debug - %(levelname)s] %(message)s" ) self.fileHandler = logging.FileHandler(filename=filename, mode=mode) self.fileHandler.setLevel(loglevel) self.fileHandler.setFormatter(self.format) self.handlers.append(self.fileHandler) self.logger._logobj.addHandler(self.fileHandler)
def testSurfaceTexture_YUV420Tiled(self): """ @summary: UFO-> testSurfaceTexture-YUV420-Tiled """ print "[RunTest]: %s" % self.__str__() cmd = self.cmd_path + " " + self.binary.cfg.get("running_cmd") key = self.binary.cfg.get("key_result") file_name = self.binary.cfg.get("file_name") result_name = self.binary.cfg.get("result_name") file_path = os.path.join(g_common_obj.get_user_log_dir(), file_name) result_path = os.path.join(g_common_obj.get_user_log_dir(), result_name) self.binary.run_cmd_and_collect_output(cmd, file_path) assert not self.binary.get_result_paragraph_from_log( key, file_path, result_path)
def youtube_first_movie_play(self, timeout=120): """ @summayr: play the first movie in youtube movie list @return: None """ g_common_obj.launch_app_from_home_sc("YouTube") if not self._locator.btn_youtube_firstmovie.exists: print "[WARNING:UI is changed! Just test launch function]" assert self.d(packageName=self.cfg.get("package_name")).exists pth = g_common_obj.get_user_log_dir() self.d.screenshot(pth + "/youtube.png") self.d.press.back() return while not self._locator.btn_youtube_firstmovie.exists: time.sleep(10) timeout -= 10 if timeout <= 0: break assert self._locator.btn_youtube_firstmovie.exists, \ "ERROR:There is no movie here!" self._locator.btn_youtube_firstmovie.click() time.sleep(5) assert self._locator.btn_player.exists, \ "No player coming out" time.sleep(10) self.youtube_quit_by_backkey()
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 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 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 startCameraApp(self): """ Used to start the camera application """ CameraCommon().unlockScreen() self.logger.debug("launch arcsoft camera start") os.system("adb shell am start -S %s/%s" % (self.PACKAGE_NAME_ARCSOFTCAMERA, self.ACTIVITY_NAME_ARCSOFTCAMERA)) time_left = 0 start = time.time() success = False while time_left < CameraCommon().waitStartAppTime + 5: if self.isShutterBtnExists(): success = True break CameraCommon().checkGuide() time_left = time.time() - start time.sleep(0.5) CameraCommon().checkCameraCrash() if (not success) or time_left > CameraCommon().waitStartAppTime: scname = g_common_obj.get_user_log_dir() + "/assert.png" g_common_obj.take_screenshot(scname) assert False, "arcsoft camera launch fail,launch time is greater than " \ + str(CameraCommon().waitStartAppTime + 5) + " seconds" self.logger.debug("launch arcsoft camera successfully")
def enter_camera_from_home(self): """ @summary: enter camera from home using am command """ # g_common_obj2.unlock() self.unlockScreen() time.sleep(3) self.d.press.home() self.logger.debug("launch camera start") os.system( "adb shell am start -n %s/%s" % (self.PACKAGE_NAME_AOSPCAMERA, self.ACTIVITY_NAME_AOSPCAMERA)) time_left = 0 start = time.time() success = False while time_left < 20: if self.isShutterBtnExists() or self.GoogleDefaultCamera( ).camera_photo_show_page_delete_button().exists(): success = True break self.checkCameraAccessDevicesLocation() if self.GoogleDefaultCamera().camera_page_text("NEXT").exists(): self.check_notification_after_switch_mode() time_left = time.time() - start time.sleep(0.5) self.judge_if_camera_crash() if (not success) or time_left > 20: self.getScreenshotAndPullToHost("assert.png", g_common_obj.get_user_log_dir()) assert False, "camera launch fail,launch time is greater than 20 seconds" self.logger.debug("launch camera success")
def startCameraApp(self): """ Used to start the camera application """ CameraCommon().unlockScreen() self.logger.debug("launch gms camera start") os.system("adb shell am start -n %s/%s" % (self.PACKAGE_NAME_GMSCAMERA, self.ACTIVITY_NAME_GMSCAMERA)) time_left = 0 start = time.time() success = False while time_left < CameraCommon().waitStartAppTime: if self.isShutterBtnExists() or self.GMSCameraWidget( ).photoPreviewPageDeleteBtn().exists: success = True break CameraCommon().checkCameraAccessDevicesLocation() CameraCommon().checkGuide() time_left = time.time() - start time.sleep(0.5) CameraCommon().checkCameraCrash() if (not success) or time_left > CameraCommon().waitStartAppTime: scname = g_common_obj.get_user_log_dir() + "/assert.png" g_common_obj.take_screenshot(scname) assert False, "gms camera launch fail,launch time is greater than " \ + str(CameraCommon().waitStartAppTime) + " seconds" time.sleep(2) if self.GMSCameraWidget().text("NEXT").exists: CameraCommon().checkGuide() self.logger.debug("launch gms camera successfully")
def add_sheets(self): ''' Click add button to add multiple Spreadsheet. ''' print "[Info] ---click add button to add spreadsheet." if not self.d(descriptionContains="New File").exists: print "[WARNING:UI is changed! Just test launch function]" assert self.d( packageName="com.google.android.apps.docs.editors.sheets" ).exists pth = g_common_obj.get_user_log_dir() self.d.screenshot(pth + "/sheet.png") self.d.press.back() return self.d(descriptionContains="New File").click.wait() time.sleep(5) self.d.click(400, 600) os.system("adb shell input text 'qwert'") os.system("adb shell input keyevent 66") if not self.d(resourceId="android:id/action_mode_close_button").exists: print "[WARNING:UI is changed! Just test launch function]" assert self.d( packageName="com.google.android.apps.docs.editors.sheets" ).exists return self.d(resourceId="android:id/action_mode_close_button").click.wait() assert not self.d( resourceId="android:id/action_mode_close_button").exists self.d.press.back() print "[Info] ----add spreadsheet success"
def launch_sheets(self): ''' Launch Docs app. ''' print "[Info] ---Launch sheets app" g_common_obj.launch_app_am("com.google.android.apps.docs.editors.sheets", \ "com.google.android.apps.docs.app.NewMainProxyActivity") time.sleep(15) while self.d( resourceId="com.google.android.apps.docs.editors.sheets:id/next" ).exists: self.d( resourceId="com.google.android.apps.docs.editors.sheets:id/next" ).click() if self.d( resourceId="com.google.android.apps.docs.editors.sheets:id/done" ).exists: self.d( resourceId="com.google.android.apps.docs.editors.sheets:id/donee" ).click() time.sleep(10) if not self.d(descriptionContains="New File").exists: print "[WARNING:UI is changed! Just test launch function]" assert self.d( packageName="com.google.android.apps.docs.editors.sheets" ).exists pth = g_common_obj.get_user_log_dir() self.d.screenshot(pth + "/doc.png") return assert_equals(self.d(descriptionContains="New File").exists, True) print "[Info] ---Launch sheets app success."
def testEXTCopyImage(self): """ @summary: test_KHR_blend_equation_advanced """ print "[RunTest]: %s" % self.__str__() cmd = self.cmd_path + " " + self.binary.cfg.get("running_cmd") key = self.binary.cfg.get("key") key_result = self.binary.cfg.get("key_result") file_name = self.binary.cfg.get("file_name") result_name = self.binary.cfg.get("result_name") line = self.binary.cfg.get("line") file_path = os.path.join(g_common_obj.get_user_log_dir(), file_name) result_path = os.path.join(g_common_obj.get_user_log_dir(), result_name) self.binary.run_cmd_and_collect_output(cmd, file_path) assert self.binary.get_result_paragraph_from_log( key, file_path, result_path, line) assert self.binary.check_key_in_file(key_result, result_path)
def assertTrue(self, expr, msg=None): """Check that the expression is true.""" camera = CameraImpl() if expr == False: self.logger.debug("=====Screen capture====") camera.getScreenshotAndPullToHost("assert.png", g_common_obj.get_user_log_dir()) assert expr, msg
def cameraExposureBracketIterativeCaptureMaxResolution(self, lens,run_time): try: self.appPrepare() self.camera.startCameraApp() self.camera.selectMode("Burst") self.camera.switchRearOrFront(lens) self.camera.setExposureBracket() resolution = self.camera.getAllPhotoResolutions(lens)[1] self.camera.setPhotoResolution(resolution, lens) CameraCommon().clickScreenCenter() self.error_msg = "" for i in range(int(run_time)): self.logger.debug("======loop %d ======" %(i+1)) self.camera.capturePhoto() time.sleep(1) self.checkFileCorrupt() fileNameList = CameraCommon().getFileName(self.camera_dir) print fileNameList iamge1 = self.host_path + "/" + fileNameList[0] iamge2 = self.host_path + "/" + fileNameList[1] iamge3 = self.host_path + "/" + fileNameList[2] image1_b = self.checkImage.brightness(iamge1) image2_b = self.checkImage.brightness(iamge2) image3_b = self.checkImage.brightness(iamge3) info1 = CameraCommon().getExifInfo(fileNameList[0], self.host_path + "/") info2 = CameraCommon().getExifInfo(fileNameList[1], self.host_path + "/") info3 = CameraCommon().getExifInfo(fileNameList[2], self.host_path + "/") ec1 = info1.get("Exposure Compensation") ec2 = info2.get("Exposure Compensation") ec3 = info3.get("Exposure Compensation") print ec1, ec2, ec3 self.logger.debug("Exposure Compensation check,pic1 is %s,pic2 is %s, pic3 is %s" %(str(ec1),str(ec2),str(ec3))) if ec1 != "-5": self.error_msg = self.error_msg + "first picture Exposure Compensation can't match -5;" os.system("cp " + iamge1 + " " + g_common_obj.get_user_log_dir()) if ec2 != "0": self.error_msg = self.error_msg + "second picture Exposure Compensation can't match 0;" os.system("cp " + iamge2 + " " + g_common_obj.get_user_log_dir()) if ec3 != "5": self.error_msg = self.error_msg + "third picture Exposure Compensation can't match 5;" os.system("cp " + iamge3 + " " + g_common_obj.get_user_log_dir()) if not self.checkImage.compare_images_brightness(iamge1, iamge2): self.error_msg = self.error_msg + "-1 compare 0 exposure check fail," + \ "-1(" + iamge1 + ") brightness=" + str(image1_b) + ", 0(" + iamge2 + ") brightness=" + str(image2_b) + "; " os.system("cp " + iamge1 + " " + g_common_obj.get_user_log_dir()) os.system("cp " + iamge2 + " " + g_common_obj.get_user_log_dir()) if not self.checkImage.compare_images_brightness(iamge2, iamge3): self.error_msg = self.error_msg + "0 compare 1 exposure check fail," + \ "0(" + iamge2 + ") brightness=" + str(image2_b) + ", 1(" + iamge3 + ") brightness=" + str(image3_b) + "; " os.system("cp " + iamge2 + " " + g_common_obj.get_user_log_dir()) os.system("cp " + iamge3 + " " + g_common_obj.get_user_log_dir()) CameraCommon().removeDeivceFile() CameraCommon().clickScreenCenter() if self.error_msg == "": self.logger.debug("exposure check successful") else: self.assertTrue(False, self.error_msg) except Exception as e: CameraCommon().checkCameraCrash() self.assertTrue(False, e)
def testAndroidExtensionPackes31(self): """ @summary: test_OES_shader_multisample_interpolation es 31 """ print "[RunTest]: %s" % self.__str__() cmd = self.cmd_path + " " + self.binary.cfg.get("running_cmd") key = self.binary.cfg.get("key") key_result = self.binary.cfg.get("key_result") file_name = self.binary.cfg.get("file_name") line = self.binary.cfg.get("line") result_name = self.binary.cfg.get("result_name") file_path = os.path.join(g_common_obj.get_user_log_dir(), file_name) result_path = os.path.join(g_common_obj.get_user_log_dir(), result_name) self.binary.run_cmd_and_collect_output(cmd, file_path) assert self.binary.get_result_paragraph_from_log( key, file_path, result_path, line) assert self.binary.check_key_in_file(key_result, result_path)
def cameraShutter(self): if not self.d(resourceId="com.android.camera2:id/shutter_button", enabled=True).exists: CameraImpl().getScreenshotAndPullToHost( "assert.png", g_common_obj.get_user_log_dir()) assert CameraImpl().d( resourceId="com.android.camera2:id/shutter_button", enabled=True).exists self.d(resourceId="com.android.camera2:id/shutter_button").click.wait()
def checkVideoDisplayWell(self, seconds=5): self.d().scroll.horiz.forward() if not self.d(resourceId="com.android.camera2:id/play_button").exists: CameraImpl().getScreenshotAndPullToHost( "assert.png", g_common_obj.get_user_log_dir()) assert self.d(resourceId="com.android.camera2:id/play_button" ).exists, "couldn't find preview video" self.d(resourceId="com.android.camera2:id/play_button").click.wait() time.sleep(seconds) self.d.press.back()
def testADFDeviceData(self): """ @summary: test_ADF.device_data """ print "[RunTest]: %s" % self.__str__() cmd = self.cmd_path + " " + self.binary.cfg.get("running_cmd") key_result = self.binary.cfg.get("key_result") file_name = self.binary.cfg.get("file_name") file_path = os.path.join(g_common_obj.get_user_log_dir(), file_name) self.binary.run_cmd_and_collect_output(cmd, file_path) assert not self.binary.check_key_in_file(key_result, file_path)
def checkImageDisplayWell(self): self.d().scroll.horiz.forward() if not self.d( resourceId= "com.android.camera2:id/filmstrip_bottom_control_edit").exists: CameraImpl().getScreenshotAndPullToHost( "assert.png", g_common_obj.get_user_log_dir()) assert self.d( resourceId="com.android.camera2:id/filmstrip_bottom_control_edit" ).exists, "couldn't find image" self.d.press.back()
def deleteVideo(self): self.d().scroll.horiz.forward() if not self.d(resourceId="com.android.camera2:id/play_button").exists: CameraImpl().getScreenshotAndPullToHost( "assert.png", g_common_obj.get_user_log_dir()) assert self.d(resourceId="com.android.camera2:id/play_button" ).exists, "couldn't find preview video" self.d( resourceId="com.android.camera2:id/filmstrip_bottom_control_delete" ).click() if self.d(text="ok").exists: self.d(text="ok").click()
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 checkVideoRecTestfile(self, encode_type='ST_VIDEO_REC_ENCODE_001', flag=True): import re size_pattern = re.compile("sdcard_rw(.*)20") file_path = '/sdcard/' + encode_type + '*' cmd = "shell ls -l %s" % (file_path) # result = g_common_obj.adb_cmd_capture_msg(cmd) result = self.multimedia_setting.execute_adb_command(cmd) size = re.findall(size_pattern, result) assert ("No such file or directory" not in result) == flag, "Record file status error! result=%s" % (result) if size != []: assert str(0) != size[0], "Record file size is zero, error!" g_common_obj.pull_file(g_common_obj.get_user_log_dir(), file_path) logger.debug(self.tag + "record file:" + result) logger.debug(self.tag + "record file exist") return True
def cameraExposureBracketEXIF(self, lens): try: self.appPrepare() self.camera.startCameraApp() self.camera.selectMode("Burst") self.camera.switchRearOrFront(lens) self.camera.setExposureBracket() self.camera.capturePhoto() self.checkFileCorrupt() fileNameList = CameraCommon().getFileName(self.camera_dir) print fileNameList iamge1 = self.host_path + "/" + fileNameList[0] iamge2 = self.host_path + "/" + fileNameList[1] iamge3 = self.host_path + "/" + fileNameList[2] image1_b = self.checkImage.brightness(iamge1) image2_b = self.checkImage.brightness(iamge2) image3_b = self.checkImage.brightness(iamge3) info1 = CameraCommon().getExifInfo(fileNameList[0], self.host_path + "/") info2 = CameraCommon().getExifInfo(fileNameList[1], self.host_path + "/") info3 = CameraCommon().getExifInfo(fileNameList[2], self.host_path + "/") ec1 = info1.get("Exposure Compensation") ec2 = info2.get("Exposure Compensation") ec3 = info3.get("Exposure Compensation") print ec1,ec2,ec3 self.error_msg = "" if ec1 != "-5": self.error_msg = self.error_msg + "first picture Exposure Compensation can't match -5;" os.system("cp " + iamge1 + " " + g_common_obj.get_user_log_dir()) if ec2 != "0": self.error_msg = self.error_msg + "second picture Exposure Compensation can't match 0;" os.system("cp " + iamge2 + " " + g_common_obj.get_user_log_dir()) if ec3 != "5": self.error_msg = self.error_msg + "third picture Exposure Compensation can't match 5;" os.system("cp " + iamge3 + " " + g_common_obj.get_user_log_dir()) if not self.checkImage.compare_images_brightness(iamge1, iamge2): self.error_msg = self.error_msg + "-1 compare 0 exposure check fail," + \ "-1(" + iamge1 + ") brightness=" + str(image1_b) + ", 0(" + iamge2 + ") brightness=" + str(image2_b) + "; " os.system("cp " + iamge1 + " " + g_common_obj.get_user_log_dir()) os.system("cp " + iamge2 + " " + g_common_obj.get_user_log_dir()) if not self.checkImage.compare_images_brightness(iamge2, iamge3): self.error_msg = self.error_msg + "0 compare 1 exposure check fail," + \ "0(" + iamge2 + ") brightness=" + str(image2_b) + ", 1(" + iamge3 + ") brightness=" + str(image3_b) + "; " os.system("cp " + iamge2 + " " + g_common_obj.get_user_log_dir()) os.system("cp " + iamge3 + " " + g_common_obj.get_user_log_dir()) if self.error_msg == "": self.logger.debug("exposure check successful") else: self.assertTrue(False, self.error_msg) except Exception as e: CameraCommon().checkCameraCrash() self.assertTrue(False, e)