def match_template_video(self, screenshot, album_icon, pause_icon,
                             share_icon):
        """
            Check if icon of camera application is correctly display.

            :type orientation: str
            :param orientation: set the screen orientation (portrait, landscape or reverse landscape.
            :type screenshot: str
            :param screenshot: path of the DUT screenshot
            :type camera_mode_icon: str
            :param camera_mode_icon: name of camera_mode_icon image in images library.
            :type take_photo_icon: str
            :param take_photo_icon: name of take_photo_icon image in images library.
            :type option_camera_icon: str
            :param option_camera_icon: name of option_camera_icon image in images library.
            :rtype: tuple
            :return: (str, str) verdict : True if all icon is displayed correctly or false if one or more doesn't
            and msg : Output message
            """

        msg = ""
        verdict = Global.SUCCESS

        self._logger.info("Match the template in screenshot.")
        #Ckeck album icon
        self._logger.debug("Check album icon in video pause.")
        template = self._dic_image[album_icon]
        matching, x, y = Imagecheck.match_template_in_image(
            screenshot, template)
        if not matching:
            verdict = Global.FAILURE
            msg = msg + "Doesn't match album icon, "

        #Ckeck pause icon
        self._logger.debug("Check pause icon  in video pause.")
        template = self._dic_image[pause_icon]
        matching, x, y = Imagecheck.match_template_in_image(
            screenshot, template)
        if not matching:
            verdict = Global.FAILURE
            msg = msg + "Doesn't match pause icon, "

        #Ckeck share icon
        self._logger.debug("Check share icon in video pause.")
        template = self._dic_image[share_icon]
        matching, x, y = Imagecheck.match_template_in_image(
            screenshot, template)
        if not matching:
            verdict = Global.FAILURE
            msg = msg + "Doesn't match share icon. "

        #Concatenate result
        if verdict == Global.SUCCESS:
            msg = "No errors"

        return verdict, msg
    def match_template_camera(self, orientation, screenshot, camera_mode_icon, take_photo_icon, option_camera_icon):
        """
            Check if icon of camera application is correctly display.

            :type orientation: str
            :param orientation: set the screen orientation (portrait, landscape or reverse landscape.
            :type screenshot: str
            :param screenshot: path of the DUT screenshot
            :type camera_mode_icon: str
            :param camera_mode_icon: name of camera_mode_icon image in images library.
            :type take_photo_icon: str
            :param take_photo_icon: name of take_photo_icon image in images library.
            :type option_camera_icon: str
            :param option_camera_icon: name of option_camera_icon image in images library.
            :rtype: tuple
            :return: (str, str) verdict : True if all icon is displayed correctly or false if one or more doesn't
            and msg : Output message
            """

        msg = ""
        verdict = True

        self._logger.info("Match the template in screenshot.")
        #Ckeck camera mode icon
        self._logger.debug("Check camera mode icon in " + orientation + " orientation.")
        template = self._dic_image[camera_mode_icon]
        matching, x, y = Imagecheck.match_template_in_image(screenshot, template)
        if not matching:
            verdict = False
            msg = msg + "Doesn't match camera mode icon in " + orientation + " orientation, "

        #Ckeck take photo icon
        self._logger.debug("Check take photo icon  in " + orientation + " orientation.")
        template = self._dic_image[take_photo_icon]
        matching, x, y = Imagecheck.match_template_in_image(screenshot, template)
        if not matching:
            verdict = False
            msg = msg + "Doesn't match take photo icon in " + orientation + " orientation, "

        #Ckeck camera option icon
        self._logger.debug("Check camera option icon in " + orientation + " orientation.")
        template = self._dic_image[option_camera_icon]
        matching, x, y = Imagecheck.match_template_in_image(screenshot, template)
        if not matching:
            verdict = False
            msg = msg + "Doesn't match camera option icon in " + orientation + " orientation, "

        #Concatenate result
        if verdict:
            msg = "No error in " + orientation + " orientation, "

        return verdict, msg
Beispiel #3
0
 def touch_template_on_screen(self, screenshot, template, tap_number=1):
     """
     This function search if the template is in screenshot. If the template is match, it realize an input tap on
     template coordinate.
     :type screenshot: str
     :param screenshot: path of the screenshot
     :type template: str
     :param template: path of the template
     :rtype: Bool
     :return: matching, True if match template or False if doesn't.
     """
     self._logger.info("Search template in DUT screenshot.")
     matching, x, y = Imagecheck.match_template_in_image(
         screenshot, template)
     if matching:
         count = 0
         while count < tap_number:
             self._logger.info("Touch screen on template coordinate.")
             cmd = "adb shell input tap " + str(x) + " " + str(y)
             self._exec(cmd)
             count += 1
     else:
         raise DeviceException(DeviceException.INVALID_DEVICE_STATE,
                               "Doesn't match template in screenshot.")
     return matching
    def run_test(self):
        """
        Execute the test
        """

        # Call UseCase base Run function.
        UseCaseBase.run_test(self)

        #set display orientation
        self._logger.info("Force screen orientation.")
        self._display_api.set_display_orientation(self._force_orientation)
        time.sleep(self._wait_btwn_cmd)

        self._logger.info("Check if unlock icon is correctly display.")
        self._screenshot_path = self._image_api.take_screenshot_and_pull_on_host(self._image_filename, os.getcwd())
        self._screenshot_state = True

        template = self._dic_image[self._unlock_icon]

        matching, x, y = Imagecheck.match_template_in_image(self._screenshot_path, template)
        if matching:
            #try to unlock phone with swipe
            self._logger.debug("Trying to unlock the phone with swipe.")
            self._phonesystem_api.unlock_phone_with_swipe(x,y,self._swipe_timeout)
            #Now verify if DUT is unlock
            if not self._system_api.check_Activity("Keyguard"):
                verdict = Global.SUCCESS
                msg = "No errors"
            else:
                verdict = Global.FAILURE
                msg = "Device is always lock, unlock fail."
        else:
            verdict = Global.FAILURE
            msg = "Doesn't match unlock icon."

        return verdict, msg
    def match_template_gallery(self, orientation, screenshot, album_icon,
                               album_text, camera_icon, option_icon, preview):
        """
            Check if icon of gallery application is correctly display.

            :type orientation: str
            :param orientation: set the screen orientation (portrait, landscape or reverse landscape
            :type screenshot: str
            :param screenshot: path of the DUT screenshot
            :type album_icon: str
            :param album_icon: name of album_icon image in images library.
            :type album_text: str
            :param album_text: name of album_text image in images library.
            :type camera_icon: str
            :param camera_icon: name of camera_icon image in images library.
            :type option_icon: str
            :param option_icon: name of option_icon image in images library.
            :type preview: str
            :param preview: name of preview image in images library.
            :rtype: tuple
            :return: (str, str) verdict : True if all icon is displayed correctly or false if one or more doesn't
            and msg : Output message
            """

        msg = ""
        verdict = True

        self._logger.info("Match the template in screenshot.")
        #Ckeck album icon
        self._logger.debug("Check album icon in " + orientation +
                           " orientation.")
        template = self._dic_image[album_icon]
        matching, x, y = Imagecheck.match_template_in_image(
            screenshot, template)
        if not matching:
            verdict = False
            msg = msg + "Doesn't match album icon in " + orientation + " orientation, "

        #Ckeck album text
        self._logger.debug("Check album  in " + orientation + " orientation.")
        template = self._dic_image[album_text]
        matching, x, y = Imagecheck.match_template_in_image(
            screenshot, template)
        if not matching:
            verdict = False
            msg = msg + "Doesn't match album text in " + orientation + " orientation, "

        #Ckeck camera icon
        self._logger.debug("Check camera icon in " + orientation +
                           " orientation.")
        template = self._dic_image[camera_icon]
        matching, x, y = Imagecheck.match_template_in_image(
            screenshot, template)
        if not matching:
            verdict = False
            msg = msg + "Doesn't match camera icon in " + orientation + " orientation, "

        #Ckeck option icon
        self._logger.debug("Check option icon in " + orientation +
                           " orientation.")
        template = self._dic_image[option_icon]
        matching, x, y = Imagecheck.match_template_in_image(
            screenshot, template)
        if not matching:
            verdict = False
            msg = msg + "Doesn't match option icon in " + orientation + " orientation, "

        #Ckeck preview
        self._logger.debug("Check preview image in " + orientation +
                           " orientation.")
        template = self._dic_image[preview]
        matching, x, y = Imagecheck.match_template_in_image(
            screenshot, template)
        if not matching:
            verdict = False
            msg = msg + "Doesn't match preview image in " + orientation + " orientation, "

        #Concatenate result
        if verdict:
            msg = "No error in " + orientation + " orientation, "

        return verdict, msg