def run_test(self): """ Execute the test """ # Call UseCase base Run function UseCaseBase.run_test(self) verdict = Global.SUCCESS msg = "No errors" # set camera flash mode self.__camera_api.set_flash_mode(self.__camera_flash_mode) time.sleep(self._wait_btwn_cmd) # take picture with flash picture_file_with_flash = self.__camera_api.take_picture(self.__save_directory) time.sleep(self._wait_btwn_cmd) # download picture taken from the DUT self.__local_picture_file_with_flash = self.__camera_api.download_media_file(picture_file_with_flash, self.__save_folder) time.sleep(self._wait_btwn_cmd) # Check if the picture with flash's brightness is higher than the ref picture's one result = Imagecheck.compare_images_brightness(self.__local_ref_picture_file, self.__local_picture_file_with_flash) if not result: msg = "Flash was not fired" verdict = Global.FAILURE return (verdict, msg)
def run_test(self): """ Execute the test """ # Call UseCase base Run function UseCaseBase.run_test(self) verdict = Global.SUCCESS msg = "No errors" # take picture picture_file = self.__camera_api.take_picture(self.__save_directory) time.sleep(self._wait_btwn_cmd) # download picture taken from the DUT local_picture_file = self.__camera_api.download_media_file(picture_file, self.__save_folder) time.sleep(self._wait_btwn_cmd) # Check if the picture taken is corrupted result = Imagecheck.check_image_corrupt(local_picture_file) if result: msg = "Image file is corrupted !" verdict = Global.FAILURE return (verdict, msg)
def run_test(self): """ Execute the test """ # Call UseCase base Run function UseCaseBase.run_test(self) verdict = Global.SUCCESS msg = "No errors" # Start face detection on DUT dut_faces = self.__camera_api.start_face_detection() time.sleep(self._wait_btwn_cmd) # Take a screen shot for what is displayed by the DUT screen_shot = self.__image_api.take_screenshot_and_pull_on_host("screen_shot", os.getcwd()) time.sleep(self._wait_btwn_cmd) # Check the number of faces detected in the screen shot taken host_faces = Imagecheck.face_detection(screen_shot) # Remove Screen shot taken os.remove(screen_shot) if host_faces != dut_faces: msg = "%s face(s) checked by the Camera, %s face(s) checked by host" % (str(dut_faces), str(host_faces)) verdict = Global.FAILURE return verdict, msg
def disable_post_processing_video_effect(self, wait_btwn_cmd, library_image_path, on_off_image): """ Disable post processing video effect :type wait_btwn_cmd: int :param wait_btwn_cmd: time between command :type library_image_path: str :param library_image_path: path to the image library on host. :type on_off_image: dict :param on_off_image: Dictionary with two Key (ON : name of On image, OFF : nome of Off image) :rtype: None :return: None """ # Generate image dictionary dic_image = Imagecheck.generate_dictionary_image_path(library_image_path) # Open Intel Smart Video self._open_smart_video() time.sleep(wait_btwn_cmd) # Click on first off button # Click on two off button icons = [dic_image[on_off_image["ON"]], dic_image[on_off_image["ON"]]] multimedia_api = self._device.get_uecmd("Multimedia", True) multimedia_api.execute_icons_sequence(icons, os.getcwd()) # Close Intel Smart Video self._close_smart_video()
def __init__(self, tc_name, global_config): """ Constructor """ # Call UseCase base Init function UseCaseBase.__init__(self, tc_name, global_config) # get IMAGE_URI from TC parameters self.__image_to_display_uri = self._tc_parameters.get_param_value( "IMAGE_URI") # get SCRIPT_PATH from TC parameters self.__script = \ str(self._tc_parameters.get_param_value("SCRIPT_PATH")) # get ERROR_MANAGEMENT_POLICY from TC parameters self._error_policy = str( self._tc_parameters.get_param_value("ERROR_MANAGEMENT_POLICY")) # get ENABLE_UI_AUTOMATOR_EVENT from TC parameters self._ui_automator_event = self._tc_parameters.get_param_value( "ENABLE_UI_AUTOMATOR_EVENT", default_value=False, default_cast_type="str_to_bool") # get LIBRARY_IMAGE_PATH from TC parameters self.__library_image_path = self._tc_parameters.get_param_value( "LIBRARY_IMAGE_PATH") # get REFERENCE_IMAGE_ZOOM_IN from TC parameters self.__ref_image_zoom_in = self._tc_parameters.get_param_value( "REFERENCE_IMAGE_ZOOM_IN") # get PHOTOS_ICON from TC parameters self.__photos_icon = self._tc_parameters.get_param_value("PHOTOS_ICON") # get JUST_ONCE_ICON from TC parameters self.__just_once_icon = self._tc_parameters.get_param_value( "JUST_ONCE_ICON") # get DEFAULT_ORIENTATION from TC parameters self.__default_orientation = self._tc_parameters.get_param_value( "DEFAULT_ORIENTATION") # Get UECmdLayer. self.__image_api = self._device.get_uecmd("Image") self.__phone_system_api = self._device.get_uecmd("PhoneSystem") self.__display_api = self._device.get_uecmd("Display") self.__multimedia_api = self._device.get_uecmd("Multimedia") self.__key_event_api = self._device.get_uecmd("KeyEvent") self._ui_api = self._device.get_uecmd("Ui") self._ui_api.set_global_config(global_config) #Image library self.__dic_image = Imagecheck.generate_dictionary_image_path( self.__library_image_path) self.__pictures_uri = [] self.__wait_for_icons = 5 self.__time_for_display = 3
def set_up(self): """ Initialize the test """ # Call UseCase base Setup function UseCaseBase.set_up(self) # Open camera self.__camera_api.launch_camera(self.__camera) time.sleep(self._wait_btwn_cmd) # set Picture Size if self.__picture_size: self.__picture_size = self.__picture_size.upper() if not Imagecheck.check_picture_resolution(self.__camera, self.__picture_size): error_msg = "Invalid resolution %s for camera %s" % (self.__picture_size, self.__camera) raise AcsConfigException(AcsConfigException.INVALID_PARAMETER, error_msg) (width, height) = Imagecheck.get_size_from_resolution(self.__camera, self.__picture_size) self.__camera_api.set_picture_size(width, height) time.sleep(self._wait_btwn_cmd) # set camera flash mode if self.__camera_flash_mode: self.__camera_api.set_flash_mode(self.__camera_flash_mode) time.sleep(self._wait_btwn_cmd) # set camera white balance mode if self.__camera_white_balance: self.__camera_api.set_white_balance(self.__camera_white_balance) time.sleep(self._wait_btwn_cmd) # take picture picture_file = self.__camera_api.take_picture(self.__save_directory) time.sleep(self._wait_btwn_cmd) # download picture taken from the DUT self.__picture_file = self.__camera_api.download_media_file(picture_file, self.__save_folder) time.sleep(self._wait_btwn_cmd) return (Global.SUCCESS, "No errors")
def run_test(self): """ Execute the test """ # Call UseCase base Run function UseCaseBase.run_test(self) result_msg = "" result = Global.SUCCESS # Check Picture size on picture's EXIF data if self.__picture_size: check_result = Imagecheck.check_picture_size(self.__camera, self.__picture_file, self.__picture_size) if not check_result: result_msg = "Picture Size was not correctly set," result = Global.FAILURE # Check Flash on picture's EXIF data if self.__camera_flash_mode: check_result = Imagecheck.get_picture_exif_data(self.__picture_file, "Flash") if check_result == 0: result_msg += " Flash mode was not correctly set in picture details," result = Global.FAILURE # Check white balance on picture's EXIF data if self.__camera_white_balance: check_result = Imagecheck.get_picture_exif_data(self.__picture_file, "WhiteBalance") if self.__camera_white_balance.lower() == "auto": if check_result == 1: result_msg += " White balance was not correctly set in picture details," result = Global.FAILURE else: if check_result == 0: result_msg += " White balance was not correctly set in picture details," result = Global.FAILURE if result_msg == "": result_msg = "No errors" return (result, result_msg)
def enable_post_processing_video_effect(self, wait_btwn_cmd, library_image_path, on_off_image): """ Enable post processing video effect :type wait_btwn_cmd: int :param wait_btwn_cmd: time between command :type library_image_path: str :param library_image_path: path to the image library on host. :type on_off_image: dict :param on_off_image: Dictionary with two Key (ON : name of On image, OFF : nome of Off image) :rtype: None :return: None """ image_filename = "DUTScreenshot" # Generate image dictionary dic_image = Imagecheck.generate_dictionary_image_path(library_image_path) # Open Intel Smart Video self._open_smart_video() time.sleep(wait_btwn_cmd) # Check if two effects is already On image_api = self._device.get_uecmd("Image", True) for _ in range(2): screenshot_path = image_api.take_screenshot_and_pull_on_host(image_filename, os.getcwd()) time.sleep(wait_btwn_cmd) # Search On image in screen matching = Imagecheck.match_template_in_image(screenshot_path, dic_image[on_off_image["ON"]]) # If On is displayed on the screen, set to Off if matching[0]: image_api.touch_template_on_screen(screenshot_path, dic_image[on_off_image["ON"]]) os.remove(screenshot_path) # Click on two off button icons = [dic_image[on_off_image["OFF"]], dic_image[on_off_image["OFF"]]] multimedia_api = self._device.get_uecmd("Multimedia", True) multimedia_api.execute_icons_sequence(icons, os.getcwd()) # Close Intel Smart Video self._close_smart_video()
def __init__(self, tc_name, global_config): """ Constructor """ # Call UseCase base Init function UseCaseBase.__init__(self, tc_name, global_config) # get IMAGE_URI from TC parameters self.__image_to_display_uri = self._tc_parameters.get_param_value( "IMAGE_URI") # get LIBRARY_IMAGE_PATH from TC parameters self.__library_image_path = self._tc_parameters.get_param_value( "LIBRARY_IMAGE_PATH") # get GALLERY3D_ICON from TC parameters self.__icons = self._tc_parameters.get_param_value("ICONS") # get VIDEO_REFERENCE self.__video_reference = self._tc_parameters.get_param_value( "VIDEO_REFERENCE") # get DEFAULT_ORIENTATION from TC parameters self.__default_orientation = self._tc_parameters.get_param_value( "DEFAULT_ORIENTATION") # Get UECmdLayer. self.__image_api = self._device.get_uecmd("Image") self.__phone_system_api = self._device.get_uecmd("PhoneSystem") self.__multimedia_api = self._device.get_uecmd("Multimedia") self.__networking_api = self._device.get_uecmd("Networking") self.__camera_api = self._device.get_uecmd("Camera") # Image library self.__dic_image = Imagecheck.generate_dictionary_image_path( self.__library_image_path) self.__icons_paths = [] self.__local_video_file = None self.__initial_pdp_context_status = None self.__initial_wifi_status = None self.__rotate_screen_shot = False self.__screen_record = "run_run_3d.mp4" self.__dut_save_directory = "/sdcard/" self.__video_duration = 3 self.__bit_rate = 16000000
def __init__(self, tc_name, global_config): """ Constructor """ # Call UseCase base Init function UseCaseBase.__init__(self, tc_name, global_config) # get IMAGE_URI from TC parameters self.__image_to_display_uri = self._tc_parameters.get_param_value( "IMAGE_URI") # get LIBRARY_IMAGE_PATH from TC parameters self.__library_image_path = self._tc_parameters.get_param_value( "LIBRARY_IMAGE_PATH") # get PHOTOS_ICON from TC parameters self.__photos_icon = self._tc_parameters.get_param_value("PHOTOS_ICON") # get JUST_ONCE_ICON from TC parameters self.__just_once_icon = self._tc_parameters.get_param_value( "JUST_ONCE_ICON") # get DEFAULT_ORIENTATION from TC parameters self.__default_orientation = self._tc_parameters.get_param_value( "DEFAULT_ORIENTATION") # Get UECmdLayer. self.__image_api = self._device.get_uecmd("Image") self.__phone_system_api = self._device.get_uecmd("PhoneSystem") self.__display_api = self._device.get_uecmd("Display") self.__multimedia_api = self._device.get_uecmd("Multimedia") self.__key_event_api = self._device.get_uecmd("KeyEvent") # Image library self.__dic_image = Imagecheck.generate_dictionary_image_path( self.__library_image_path) self.__pictures_uri = [] self.__time_for_display = 2 self.__rotate_generated_pictures = False self.__matching_threshold = 0.6 self.__wait_for_icons = 5
def run_test(self): """ Execute the test """ # Call UseCase base Run function UseCaseBase.run_test verdict = Global.SUCCESS msg = "No errors" # Open the image to display self._logger.info("Displaying image ...") self.__multimedia_api.display_image_photos( self.__image_uri, self.__dic_image[self.__photos_icon], self.__dic_image[self.__just_once_icon], os.getcwd()) time.sleep(self.__time_for_display) # Zoom In self._logger.info("Zoom in ...") self._ui_api.run_action_from_script(self.__script) time.sleep(self.__time_for_display) # wait for icons self._logger.info("Waiting for icons ...") time.sleep(self.__wait_for_icons) # Take screen shot self._logger.info("Taking screen shot ...") zoom_in_screen_shot_uri = self.__image_api.take_screenshot_and_pull_on_host( "zoom_in_screen_shot", os.getcwd()) self.__pictures_uri.append(zoom_in_screen_shot_uri) # Check that the zoom in is correctly displayed result = Imagecheck.match_template_in_image( self.__dic_image[self.__ref_image_zoom_in], zoom_in_screen_shot_uri, 0.9) if not result: verdict = Global.FAILURE msg = "Zoom in did not match" return verdict, msg
def run_test(self): """ Execute the test """ # Call UseCase base Run function UseCaseBase.run_test verdict = Global.SUCCESS msg = "No errors" self._logger.info("Downloading the picture to display ...") # Get the image to display from DUT local_image_to_display = self.__image_api.pull_on_host( self.__image_uri, os.getcwd()) time.sleep(self._wait_btwn_cmd) if local_image_to_display: self.__pictures_uri.append(local_image_to_display) self._logger.info("Opening the picture to display on Gallery...") # Open the image to display self.__multimedia_api.display_image_photos( self.__image_uri, self.__dic_image[self.__photos_icon], self.__dic_image[self.__just_once_icon], os.getcwd()) time.sleep(self.__time_for_display) # Take a screen shot of the image displayed to check its # resolution and tap on the center of the screen to display off icons screen_shot_with_icons_uri = self.__image_api.take_screenshot_and_pull_on_host( "screen_shot_with_icons", os.getcwd()) self.__pictures_uri.append(screen_shot_with_icons_uri) # get screen size (screen_shot_width, screen_shot_height ) = Imagecheck.get_picture_size(screen_shot_with_icons_uri) # tap on the center of the screen self.__key_event_api.tap_on_screen(screen_shot_width / 2, screen_shot_height / 2) # wait for icons self._logger.info("Waiting for icons ...") time.sleep(self.__wait_for_icons) # Take a screen shot of the image displayed without icons self._logger.info("Taking screen shot ...") screen_shot_uri = self.__image_api.take_screenshot_and_pull_on_host( "screen_shot", os.getcwd()) time.sleep(self._wait_btwn_cmd) if screen_shot_uri: self.__pictures_uri.append(screen_shot_uri) # Resize the image to display to match screen shot's resolution local_image_to_display_resized = Imagecheck.resize_picture( local_image_to_display, screen_shot_width, screen_shot_height, os.getcwd(), self.__rotate_generated_pictures) self.__pictures_uri.append(local_image_to_display_resized) # Check if screen shot correctly displays image match = Imagecheck.match_template_in_image( screen_shot_uri, local_image_to_display_resized, self.__matching_threshold) if not match[0]: verdict = Global.FAILURE msg = "Image displayed did not match with the original one" else: verdict = Global.FAILURE msg = "Can't take screen shot" else: verdict = Global.FAILURE msg = "Can't get the picture to display from DUT" return verdict, msg
def run_test(self): """ Execute the test """ # Call UseCase base Run function UseCaseBase.run_test verdict = Global.SUCCESS msg = "No errors" self._logger.info("Downloading the picture to display ...") # Get the image to display from DUT local_image_to_display = self.__image_api.pull_on_host(self.__image_uri, os.getcwd()) time.sleep(self._wait_btwn_cmd) if local_image_to_display: self.__pictures_uri.append(local_image_to_display) self._logger.info("Opening the picture to display on Gallery...") # Open the image to display self.__multimedia_api.display_image_photos(self.__image_uri, self.__dic_image[self.__photos_icon], self.__dic_image[self.__just_once_icon], os.getcwd()) time.sleep(self.__time_for_display) # Take a screen shot of the image displayed to check its # resolution and tap on the center of the screen to display off icons screen_shot_with_icons_uri = self.__image_api.take_screenshot_and_pull_on_host("screen_shot_with_icons", os.getcwd()) self.__pictures_uri.append(screen_shot_with_icons_uri) # get screen size (screen_shot_width, screen_shot_height) = Imagecheck.get_picture_size(screen_shot_with_icons_uri) # tap on the center of the screen self.__key_event_api.tap_on_screen(screen_shot_width / 2, screen_shot_height / 2) # wait for icons self._logger.info("Waiting for icons ...") time.sleep(self.__wait_for_icons) # Change orientation self.__display_api.set_display_orientation(self.__orientations[0].lower()) time.sleep(self.__time_for_display) # Take screen shot landscape_screen_shot_uri = self.__image_api.take_screenshot_and_pull_on_host("landscape_screen_shot", os.getcwd()) self.__pictures_uri.append(landscape_screen_shot_uri) # Change orientation self.__display_api.set_display_orientation(self.__orientations[1].lower()) time.sleep(self.__time_for_display) # Take screen shot reverse_landscape_screen_shot_uri = self.__image_api. \ take_screenshot_and_pull_on_host("reverse_landscape_screen_shot", os.getcwd()) self.__pictures_uri.append(reverse_landscape_screen_shot_uri) if landscape_screen_shot_uri and reverse_landscape_screen_shot_uri: # Get screen shots's resolutions (landscape_screen_shot_width, landscape_screen_shot_height) = Imagecheck. \ get_picture_size(landscape_screen_shot_uri) (reverse_landscape_screen_shot_width, reverse_landscape_screen_shot_height) = Imagecheck. \ get_picture_size(reverse_landscape_screen_shot_uri) # Create local landscape picture using the original one local_landscape_picture = Imagecheck.set_orientation(local_image_to_display, "landscape", os.getcwd()) self.__pictures_uri.append(local_landscape_picture) local_landscape_picture_resized = Imagecheck.resize_picture(local_landscape_picture, landscape_screen_shot_width, landscape_screen_shot_height, os.getcwd(), self.__rotate_generated_pictures, True) self.__pictures_uri.append(local_landscape_picture_resized) # Create local reverse landscape picture using the original one local_reverse_landscape_picture = Imagecheck. \ set_orientation(local_image_to_display, "reverse_landscape", os.getcwd()) self.__pictures_uri.append(local_reverse_landscape_picture) local_reverse_landscape_picture_resized = Imagecheck.resize_picture(local_reverse_landscape_picture, reverse_landscape_screen_shot_width, reverse_landscape_screen_shot_height , os.getcwd(), self.__rotate_generated_pictures, True) self.__pictures_uri.append(local_reverse_landscape_picture_resized) match_landscape = Imagecheck.match_template_in_image(landscape_screen_shot_uri, local_landscape_picture_resized, 0.9) match_reverse_landscape = Imagecheck.match_template_in_image(reverse_landscape_screen_shot_uri, local_reverse_landscape_picture_resized, 0.9) if not match_landscape[0] or not match_reverse_landscape[0]: verdict = Global.FAILURE msg = "Fail to correctly display picture" else: verdict = Global.FAILURE msg = "Can't get Screen Shots" else: verdict = Global.FAILURE msg = "Can't get the picture to display from DUT" return verdict, msg
def run_test(self): """ Execute the test """ # Call UseCase base Run function UseCaseBase.run_test(self) verdict = Global.SUCCESS msg = "" # Open the image to display self._logger.info("Displaying image ...") self.__multimedia_api.display_image_photos( self.__image_uri, self.__dic_image[self.__photos_icon], self.__dic_image[self.__just_once_icon], os.getcwd()) time.sleep(self.__time_for_display) # Take screen shot of the image displayed to check its resolution screen_shot_with_icons_uri = self.__image_api.take_screenshot_and_pull_on_host( "screen_shot_with_icons", os.getcwd()) self.__pictures_uri.append(screen_shot_with_icons_uri) # get screen size from picture size (screen_shot_width, screen_shot_height ) = Imagecheck.get_picture_size(screen_shot_with_icons_uri) # Take a screen shot before zoom in screen_shot_before_zoom_in_uri = self.__image_api.take_screenshot_and_pull_on_host( "first_screen_shot", os.getcwd()) self.__pictures_uri.append(screen_shot_before_zoom_in_uri) # wait for icons self._logger.info("Waiting for icons ...") time.sleep(self.__wait_for_icons) # Zoom In self._logger.info("Zoom in ...") self._ui_api.run_action_from_script(self.__script) time.sleep(self.__time_for_display) # wait for icons self._logger.info("Waiting for icons ...") time.sleep(self.__wait_for_icons) # Take screen shot self._logger.info("Taking screen shot ...") zoom_in_screen_shot_uri = self.__image_api.take_screenshot_and_pull_on_host( "zoom_in_screen_shot", os.getcwd()) self.__pictures_uri.append(zoom_in_screen_shot_uri) # Swipe to navigate on screen self.__key_event_api.swipe((screen_shot_width / 2), (screen_shot_height / 2), 500, 1) time.sleep(self.__time_for_display) # TaKe a screen shot after swipe self._logger.info("Taking screen shot after swipe...") screen_shot_after_swipe_uri = self.__image_api.take_screenshot_and_pull_on_host( "screen_shot_after_swipe", os.getcwd()) self.__pictures_uri.append(screen_shot_after_swipe_uri) # Zoom Out self._logger.info("Zoom out ...") self._ui_api.run_action_from_script(self.__script) time.sleep(self.__time_for_display) # wait for icons self._logger.info("Waiting for icons ...") time.sleep(self.__wait_for_icons) # Take screen shot after zoom out self._logger.info("Taking screen shot ...") zoom_out_screen_shot_uri = self.__image_api.take_screenshot_and_pull_on_host( "zoom_out_screen_shot", os.getcwd()) self.__pictures_uri.append(zoom_out_screen_shot_uri) # Check that the zoom in is correctly displayed result = Imagecheck.match_template_in_image( self.__dic_image[self.__ref_image_zoom_in], zoom_in_screen_shot_uri, 0.9) if not result: verdict = Global.FAILURE msg = "Zoom in did not match, " # Check that the zoom out is correctly displayed result = Imagecheck.match_template_in_image( screen_shot_before_zoom_in_uri, zoom_out_screen_shot_uri, 0.9) if not result: verdict = Global.FAILURE msg += "Zoom out did not match, " # Check that picture after swipe is correctly displayed result = Imagecheck.match_template_in_image( self.__dic_image[self.__ref_image_swipe], screen_shot_after_swipe_uri, 0.9) if not result[0]: verdict = Global.FAILURE msg += "Swipe did not match, " if msg == "": msg = "No errors" return verdict, msg