Ejemplo n.º 1
0
    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
Ejemplo n.º 2
0
    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
Ejemplo n.º 3
0
    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