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