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
    def __init__(self, tc_name, global_config):
        """
        Constructor
        """
        # Call UseCase base Init function
        UseCaseBase.__init__(self, tc_name, global_config)

        self._image_filename = "DUTScreenshot"
        self._screenshot_path = ""
        self._screenshot_state = False
        self._swipe_timeout = 500

        #Read the path of image library from testcase
        self._library_image_path = self._tc_parameters.get_param_value("LIBRARY_IMAGE_PATH")

        #Read value of different image from testcase
        self._unlock_icon = self._tc_parameters.get_param_value("UNLOCK_ICON")

        #Read value of force_orientation form testcase
        self._force_orientation = self._tc_parameters.get_param_value("FORCE_ORIENTATION")

        #Image library
        self._dic_image = Imagecheck.generate_dictionary_image_path(self._library_image_path)

        # Get UECmdLayer
        self._image_api = self._device.get_uecmd("Image")
        self._phonesystem_api = self._device.get_uecmd("PhoneSystem")
        self._keyevent_api = self._device.get_uecmd("KeyEvent")
        self._system_api = self._device.get_uecmd("System")
        self._display_api = self._device.get_uecmd("Display")
Esempio n. 4
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):
        UseCaseBase.run_test(self)

        result = Global.SUCCESS
        return_message = ""

        # Take a picture with default settings
        picture_uri = self.__camera_api.take_picture(self.__save_directory)
        time.sleep(self._wait_btwn_cmd)

        # Download picture taken from DUT
        local_picture_uri = self.__camera_api.download_media_file(picture_uri, self.__save_folder)

        # Check if picture is corrupted
        corrupted = False

        if Imagecheck.check_image_corrupt(local_picture_uri):
            corrupted = True

        if corrupted:
            verdict = Global.FAILURE
            msg = "Picture taken is corrupted"
            return verdict, msg

        exif_value = Imagecheck.get_picture_exif_data(local_picture_uri, self.__exif_parameter_to_check)

        self._logger.info("Exif parameter has value " + str(exif_value))
        if self.__exif_parameter_value not in (None, ""):
            if str(exif_value) != str(self.__exif_parameter_value):
                result = Global.FAILURE
                return_message = "EXIF parameter {0} value is different than the one stated in the test case:"\
                    .format(self.__exif_parameter_to_check) + \
                "Expected: {0}, returned: {1}.".format(self.__exif_parameter_value,
                                                       exif_value)
        else:
            self._logger.info("No reference value for EXIF parameter was given. Only checking if it exists.")
            if exif_value in (None, ""):
                result = Global.FAILURE
                return_message = "EXIF parameter does not exist in picture."
            else:
                result = Global.SUCCESS
                return_message = "EXIF value for the given parameter exists: %s" % exif_value

        return result, return_message
    def __init__(self, tc_name, global_config):
        """
        Constructor
        """
        # Call UseCase base Init function
        UseCaseBase.__init__(self, tc_name, global_config)

        self._image_filename = "DUTScreenshot"
        self._screenshot_path = ""
        self._screenshot_state = False

        #Read the path of image library from testcase
        self._library_image_path = self._tc_parameters.get_param_value("LIBRARY_IMAGE_PATH")

        #Read four orientation from testcase
        self._first_orientation = self._tc_parameters.get_param_value("FIRST_ORIENTATION")
        self._second_orientation = self._tc_parameters.get_param_value("SECOND_ORIENTATION")
        self._third_orientation = self._tc_parameters.get_param_value("THIRD_ORIENTATION")
        self._final_orientation = self._tc_parameters.get_param_value("FINAL_ORIENTATION")

        #Read value of different image for first orientation from testcase
        self._camera_mode_first_orientation = self._tc_parameters.get_param_value("CAMERA_MODE_FIRST_ORIENTATION")
        self._take_photo_first_orientation = self._tc_parameters.get_param_value("TAKE_PHOTO_FIRST_ORIENTATION")
        self._option_camera_first_orientation = self._tc_parameters.get_param_value("OPTION_CAMERA_FIRST_ORIENTATION")


        #Read value of different image for second orientation from testcase
        self._camera_mode_second_orientation = self._tc_parameters.get_param_value("CAMERA_MODE_SECOND_ORIENTATION")
        self._take_photo_second_orientation = self._tc_parameters.get_param_value("TAKE_PHOTO_SECOND_ORIENTATION")
        self._option_camera_second_orientation = self._tc_parameters.get_param_value("OPTION_CAMERA_SECOND_ORIENTATION")

        #Read value of different image for third orientation from testcase
        self._camera_mode_third_orientation = self._tc_parameters.get_param_value("CAMERA_MODE_THIRD_ORIENTATION")
        self._take_photo_third_orientation = self._tc_parameters.get_param_value("TAKE_PHOTO_THIRD_ORIENTATION")
        self._option_camera_third_orientation = self._tc_parameters.get_param_value("OPTION_CAMERA_THIRD_ORIENTATION")

        #Image library
        self._dic_image = Imagecheck.generate_dictionary_image_path(self._library_image_path)

        # Get UECmdLayer
        self._image_api = self._device.get_uecmd("Image")
        self._display_api = self._device.get_uecmd("Display")
        self._phonesystem_api = self._device.get_uecmd("PhoneSystem")
        self._keyevent_api = self._device.get_uecmd("KeyEvent")
        self._camera_api = self._device.get_uecmd("Camera")

        # store initial Sleep Timeout value
        self._initial_sleep_timeout_value = self._phonesystem_api.get_screen_timeout()
        time.sleep(self._wait_btwn_cmd)
Esempio n. 7
0
    def __init__(self, tc_name, global_config):
        """
        Constructor
        """
        # Call UseCase base Init function
        UseCaseBase.__init__(self, tc_name, global_config)

        self._image_filename = "DUTScreenshot"
        self._screenshot_state = False
        self._screenshot_path = ""
        self._host_record_file = None
        self._host_record_device = None
        self._number_dict = {}
        self._flag_record = False

        #Read the path of image library from testcase
        self._library_image_path = self._tc_parameters.get_param_value("LIBRARY_IMAGE_PATH")

        #Read value of different image from testcase
        self._keypad_icon = self._tc_parameters.get_param_value("KEYPAD")
        self._number_dict = str_to_dict(self._tc_parameters.get_param_value("NUMBER_DICTIONARY"))

        #Read value of sequence from testcase
        self._sequence = self._tc_parameters.get_param_value("SEQUENCE")
        self._sequence_list = self._sequence.split(" ")

        #Image library
        self._dict_image = Imagecheck.generate_dictionary_image_path(self._library_image_path)

        #Generate the audio record name for each playback, self._host_record_file
        self._host_record_file = self.generate_audio_record_name()

        #Get UECmdLayer
        self._image_api = self._device.get_uecmd("Image")
        self._phone_system_api = self._device.get_uecmd("PhoneSystem")
        self._keyevent_api = self._device.get_uecmd("KeyEvent")
        self._audio_record_api = self._device.get_uecmd("AudioRecorderHost")
        self._system_api = self._device.get_uecmd("System")

        #Store initial Sleep Timeout value
        self._initial_sleep_timeout_value = self._phone_system_api.get_screen_timeout()
        time.sleep(self._wait_btwn_cmd)

        #Store initial audio output
        self._original_audio_output = self._phone_system_api.get_audio_output()
        time.sleep(self._wait_btwn_cmd)
    def __init__(self, tc_name, global_config):
        """
        Constructor
        """
        # Call UseCase base Init function
        UseCaseBase.__init__(self, tc_name, global_config)

        self._image_filename = "DUTScreenshot"
        self._screenshot_state = False
        self._screenshot_path = ""
        self._mediaStoreName = "external"

        #Read the path of image library from testcase
        self._library_image_path = self._tc_parameters.get_param_value(
            "LIBRARY_IMAGE_PATH")

        #Read value of different image from testcase
        self._album_icon = self._tc_parameters.get_param_value("ALBUM_VIDEO")
        self._pause_icon = self._tc_parameters.get_param_value("PAUSE_VIDEO")
        self._share_icon = self._tc_parameters.get_param_value("SHARE_VIDEO")

        #Read value of video path from testcase
        self._video_path = self._tc_parameters.get_param_value("VIDEO_PATH")
        self._video = "/storage/emulated/0/acs_files/" + self._video_path

        #Read value of video orientation from testcase
        self._video_orientation = self._tc_parameters.get_param_value(
            "VIDEO_ORIENTATION")

        #Image library
        self._dic_image = Imagecheck.generate_dictionary_image_path(
            self._library_image_path)

        # Get UECmdLayer
        self._image_api = self._device.get_uecmd("Image")
        self._phonesystem_api = self._device.get_uecmd("PhoneSystem")
        self._keyevent_api = self._device.get_uecmd("KeyEvent")
        self._multimedia_api = self._device.get_uecmd("Multimedia")

        # store initial Sleep Timeout value
        self._initial_sleep_timeout_value = self._phonesystem_api.get_screen_timeout(
        )
        time.sleep(self._wait_btwn_cmd)
    def run_test(self):
        """
        Execute the test
        """
        # Call UseCase base Run function
        UseCaseBase.run_test(self)

        verdict = Global.SUCCESS
        msg = ""

        # Start video record
        video_uri, picture_uri = self.__camera_api.record_video(
            self.__record_duration, self.__save_directory, 1)
        time.sleep(self._wait_btwn_cmd)

        # Download video recorded from the DUT
        local_video_uri = self.__camera_api.download_media_file(
            video_uri, self.__save_folder)

        # Download picture taken from the DUT
        local_picture_uri = self.__camera_api.download_media_file(
            picture_uri, self.__save_folder)

        # Check if video recorded is corrupted
        self._logger.info("Checking if video recorded is corrupted ...")
        video_state = VideoCheck.check_video_corrupt(local_video_uri)

        # Check if picture taken is corrupted
        self._logger.info("Checking if picture taken is corrupted ...")
        picture_state = Imagecheck.check_image_corrupt(local_picture_uri)

        if not video_state:
            verdict = Global.FAILURE
            msg = " Video recorded is corrupted, "

        if picture_state:
            verdict = Global.FAILURE
            msg += " Picture taken is corrupted, "

        if msg == "":
            msg = "No errors"

        return (verdict, msg)
Esempio n. 10
0
    def execute_icons_sequence(self,
                               icons,
                               pictures_save_directory,
                               time_between_action=0.5,
                               rotate=False):
        """
        Executes a sequence of tap on screen actions following a list of icons
        :type icons : list
        :param icons : icons to click on
        :type pictures_save_directory : str
        :param pictures_save_directory : directory where to save screen shots taken
        :type time_between_action : int
        :param time_between_action : time between tap on screen actions
        :type rotate : bool
        :param rotate : whether or not screen shots taken should be rotated.
        :rtype : None
        :return : None
        """

        for icon in icons:
            screen_shot_uri = self.__image_api.take_screenshot_and_pull_on_host(
                "screen_shot", pictures_save_directory)
            screen_shot_rotated = Imagecheck.set_orientation(
                screen_shot_uri, "landscape", pictures_save_directory, True)

            screen_shot_to_check = screen_shot_uri

            if rotate:
                screen_shot_to_check = screen_shot_rotated
            try:
                self.__image_api.touch_template_on_screen(
                    screen_shot_to_check, icon)
            except:
                os.remove(screen_shot_uri)
                os.remove(screen_shot_rotated)
                raise DeviceException(DeviceException.INVALID_DEVICE_STATE,
                                      "Doesn't match template in screenshot.")

            os.remove(screen_shot_uri)
            os.remove(screen_shot_rotated)

            time.sleep(time_between_action)
    def __init__(self, tc_name, global_config):
        """
        Constructor
        """
        LiveCellularWebBrowsing.__init__(self, tc_name, global_config)

        self._image_filename = "DUTScreenshot"
        self._screenshot_path = ""
        self._screenshot_state = False
        self._host_record_file = None
        self._host_record_device = None
        self._flag_record = False

        #Read different value from testcase.
        self._library_image_path = self._tc_parameters.get_param_value(
            "LIBRARY_IMAGE_PATH")
        self._volume = int(self._tc_parameters.get_param_value("VOLUME"))
        self._length = int(self._tc_parameters.get_param_value("LENGTH"))
        self._sequence = self._tc_parameters.get_param_value("SEQUENCE")
        self._play_picture = self._tc_parameters.get_param_value(
            "PLAY_PICTURE")
        self._screen_orientation = self._tc_parameters.get_param_value(
            "SCREEN_ORIENTATION")

        #Image library
        self._dic_image = Imagecheck.generate_dictionary_image_path(
            self._library_image_path)

        # Generate the audio record name for each playback, self._host_record_file
        self._host_record_file = self.generate_audio_record_name()

        # Get UECmdLayer
        self._image_api = self._device.get_uecmd("Image")
        self._display_api = self._device.get_uecmd("Display")
        self._audio_record_api = self._device.get_uecmd("AudioRecorderHost")
        self._system_api = self._device.get_uecmd("System")
        self._phone_system_api = self._device.get_uecmd("PhoneSystem")

        #Store initial audio output
        self._original_audio_output = self._phone_system_api.get_audio_output()
        time.sleep(self._wait_btwn_cmd)
    def run_test(self):
        """
        Execute the test
        """
        # Call UseCase base Run function
        UseCaseBase.run_test(self)

        verdict = Global.SUCCESS
        msg = "No errors"

       # Take pictures in burst mode
        pictures_uri = self.__camera_api.take_picture(self.__save_directory, self.__pictures_number)
        time.sleep(self._wait_btwn_cmd)

        # Check the number of pictures taken
        if len(pictures_uri.split(",")) != self.__pictures_number:
            verdict = Global.FAILURE
            msg = "Number of pictures taken is not as expected. expected %s, obtained : %s"  \
                                              % (str(self.__pictures_number), str(len(pictures_uri.split(","))))
            return verdict, msg

        # Download pictures taken from DUT
        local_pictures_uri = []
        for picture_uri in pictures_uri.split(","):
            local_pictures_uri.append(self.__camera_api.download_media_file(picture_uri, self.__save_folder))

        # Check if pictures are corrupted
        corrupted = False
        pictures_corrupted = 0

        for picture in local_pictures_uri:
            if Imagecheck.check_image_corrupt(picture):
                corrupted = True
                pictures_corrupted += 1

        if corrupted:
            verdict = Global.FAILURE
            msg = " %s pictures are corrupted" % str(pictures_corrupted)

        return (verdict, msg)
    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