def open_archive(self, file_path):
        """
        To test open the archive file and extract files to /tmp folder

        @type file_path: char
        @param file_path: the archive file path
        """
        archive = ooldtp.context(self.WINDOW)
        archive.getchild(self.BTN_OPEN).click()
        ldtp.waittillguiexist(self.DLG_OPEN)
        open_dlg = ooldtp.context(self.DLG_OPEN)
        while open_dlg.getchild(self.TBTN_TYPE_A_FILE_NAME).press():
            if ldtp.hasstate(self.DLG_OPEN, self.TXT_LOCATION, 'SHOWING'):
                break
        else:
            raise ldtp.LdtpExecutionError, "Failed to toggle the " + self.DLG_OPEN + " dialog Location button"
        open_dlg.settextvalue(self.TXT_LOCATION,file_path)
        open_dlg.enterstring(self.TXT_LOCATION, '<enter>')
        ldtp.waittillguinotexist(self.DLG_OPEN)

        win_name = 'frm' + self.FILE_NAME + '*'
        ldtp.waittillguiexist(win_name)
        archive = ooldtp.context(win_name)
        archive.getchild(self.BTN_EXTRACT).click()
        ldtp.waittillguiexist(self.DLG_EXTRACT)
        extract = ooldtp.context(self.DLG_EXTRACT)
        while extract.getchild(self.TBTN_TYPE_A_FILE_NAME).press():
            if ldtp.hasstate(self.DLG_EXTRACT, self.TXT_LOCATION, 'SHOWING'):
                break
        else:
            raise ldtp.LdtpExecutionError, "Failed to toggle the " + self.DLG_EXTRACT + " dialog Location button"
        extract.settextvalue(self.TXT_LOCATION,self.EXTRACT_PATH)
        extract.enterstring(self.TXT_LOCATION, '<enter>')
        ldtp.waittillguinotexist(self.DLG_EXTRACT)

        ldtp.waittillguiexist(self.DLG_EXTRACTING_FILES_FROM_ARCHIVE)
        finish = ooldtp.context(self.DLG_EXTRACTING_FILES_FROM_ARCHIVE)
        if finish.getchild(self.LBL_EXTRACTION).hasstate('SHOWING') != 1:
            raise ldtp.LdtpExecutionError, "Failed to extract the archive file"
        finish.getchild(self.BTN_CLOSE).click()
        ldtp.waittillguinotexist(self.DLG_EXTRACTING_FILES_FROM_ARCHIVE)
        """
        Verify the extract action does have outputs
        """
        if archive.getchild(self.MNU_LASTOUTPUT).hasstate('enabled'):
            archive.getchild(self.MNU_LASTOUTPUT).selectmenuitem()
            ldtp.waittillguiexist(self.DLG_LASTOUTPUT) 
            output = ooldtp.context(self.DLG_LASTOUTPUT)
            if output.getchild(self.TXT_0).gettextvalue() == None:
                raise ldtp.LdtpExecutionError, "Last output is none!"
            else:
                output.getchild(self.BTN_CLOSE).click()
        else:
            raise ldtp.LdtpExecutionError, "Nothing output after extraction!"
    def open_archive(self, file_path):
        """
        To test open the archive file and extract files to /tmp folder

        @type file_path: char
        @param file_path: the archive file path
        """
        archive = ooldtp.context(self.WINDOW)
        archive.getchild(self.BTN_OPEN).click()
        ldtp.waittillguiexist(self.DLG_OPEN)
        open_dlg = ooldtp.context(self.DLG_OPEN)
        while open_dlg.getchild(self.TBTN_TYPE_A_FILE_NAME).press():
            if ldtp.hasstate(self.DLG_OPEN, self.TXT_LOCATION, 'SHOWING'):
                break
        else:
            raise ldtp.LdtpExecutionError, "Failed to toggle the " + self.DLG_OPEN + " dialog Location button"
        open_dlg.settextvalue(self.TXT_LOCATION, file_path)
        open_dlg.enterstring(self.TXT_LOCATION, '<enter>')
        ldtp.waittillguinotexist(self.DLG_OPEN)

        win_name = 'frm' + self.FILE_NAME + '*'
        ldtp.waittillguiexist(win_name)
        archive = ooldtp.context(win_name)
        archive.getchild(self.BTN_EXTRACT).click()
        ldtp.waittillguiexist(self.DLG_EXTRACT)
        extract = ooldtp.context(self.DLG_EXTRACT)
        while extract.getchild(self.TBTN_TYPE_A_FILE_NAME).press():
            if ldtp.hasstate(self.DLG_EXTRACT, self.TXT_LOCATION, 'SHOWING'):
                break
        else:
            raise ldtp.LdtpExecutionError, "Failed to toggle the " + self.DLG_EXTRACT + " dialog Location button"
        extract.settextvalue(self.TXT_LOCATION, self.EXTRACT_PATH)
        extract.enterstring(self.TXT_LOCATION, '<enter>')
        ldtp.waittillguinotexist(self.DLG_EXTRACT)

        ldtp.waittillguiexist(self.DLG_EXTRACTING_FILES_FROM_ARCHIVE)
        finish = ooldtp.context(self.DLG_EXTRACTING_FILES_FROM_ARCHIVE)
        if finish.getchild(self.LBL_EXTRACTION).hasstate('SHOWING') != 1:
            raise ldtp.LdtpExecutionError, "Failed to extract the archive file"
        finish.getchild(self.BTN_CLOSE).click()
        ldtp.waittillguinotexist(self.DLG_EXTRACTING_FILES_FROM_ARCHIVE)
        """
        Verify the extract action does have outputs
        """
        if archive.getchild(self.MNU_LASTOUTPUT).hasstate('enabled'):
            archive.getchild(self.MNU_LASTOUTPUT).selectmenuitem()
            ldtp.waittillguiexist(self.DLG_LASTOUTPUT)
            output = ooldtp.context(self.DLG_LASTOUTPUT)
            if output.getchild(self.TXT_0).gettextvalue() == None:
                raise ldtp.LdtpExecutionError, "Last output is none!"
            else:
                output.getchild(self.BTN_CLOSE).click()
        else:
            raise ldtp.LdtpExecutionError, "Nothing output after extraction!"
示例#3
0
    def has_state(self, window_name, object_name, state, gui_time_out=0):
        """
        has state

        @param window_name: Window name to look for, either full name,
        LDTP's name convention, or a Unix glob.

        @type window_name: string

        @param object_name: Object name to look for, either full name,
        LDTP's name convention, or a Unix glob.

        @type object_name: string

        @param state: State of the current object.

        @type object_name: string

        @param gui_time_out: Wait timeout in seconds

        @type gui_time_out: integer

        @return: 1 on success.

        @rtype: integer
        """
        try:
            self._info('(%s,%s) has state (%s) or not.' %
                       (window_name, object_name, state))
            return ldtp.hasstate(window_name, object_name, state, gui_time_out)
        except LdtpExecutionError:
            raise LdtpExecutionError('has state failed.')
示例#4
0
    def revert_default(self):
        appearance = ooldtp.context(self.name)
        appearance.getchild(self.PTABLE).selecttab(self.PTAB_BACKGROUND)
        appearance.getchild(self.BTN_ADD).click()

        ldtp.waittillguiexist(self.DLG_ADDWALLPAPER)

        selectWallpaper = ooldtp.context(self.DLG_ADDWALLPAPER)
        while selectWallpaper.getchild(self.TBTN).press():
            if ldtp.hasstate(self.DLG_ADDWALLPAPER,self.TXT_LOCATION,'SHOWING'):
                selectWallpaper.settextvalue(self.TXT_LOCATION, self.Default)
                break

        selectWallpaper.getchild(self.BTN_OPEN).click()
        ldtp.wait(2)
        ldtp.waittillguinotexist(self.DLG_ADDWALLPAPER)
        ldtp.waittillguiexist(self.WINDOW)
示例#5
0
    def change_picture(self, photo_path):
        about_me = ooldtp.context(self.WINDOW)
        
        about_me.getchild(self.BTN_0).click()
        
        ldtp.wait(2)

        if (ldtp.guiexist(self.DLG_SELECTIMAGE)):
            selectImage = ooldtp.context(self.DLG_SELECTIMAGE)
            while selectImage.getchild(self.TBTN).press():
                if ldtp.hasstate(self.DLG_SELECTIMAGE,self.TXT_LOCATION,'SHOWING'):
                    break
            else:
                raise ldtp.LdtpExecutionError, "Failed to toggle the Location button"
 
            selectImage.settextvalue(self.TXT_LOCATION, photo_path)
            ldtp.wait(2)
            selectImage.getchild(self.BTN_OPEN).click()
            ldtp.wait(2)
        ldtp.waittillguiexist(self.WINDOW)
示例#6
0
    def change_background(self, background_path):
        appearance = ooldtp.context(self.name)
        appearance.getchild(self.PTABLE).selecttab(self.PTAB_BACKGROUND)
        appearance.remap()
        num = len(appearance.getchild(self.LP).getobjectproperty('children').split(' '))
        appearance.getchild(self.BTN_ADD).click()

        ldtp.waittillguiexist(self.DLG_ADDWALLPAPER)
        
        selectWallpaper = ooldtp.context(self.DLG_ADDWALLPAPER)
        while selectWallpaper.getchild(self.TBTN).press():
            if ldtp.hasstate(self.DLG_ADDWALLPAPER,self.TXT_LOCATION,'SHOWING'):
                selectWallpaper.settextvalue(self.TXT_LOCATION, background_path)
                break

        selectWallpaper.getchild(self.BTN_OPEN).click()
        ldtp.waittillguinotexist(self.DLG_ADDWALLPAPER)

        appearance.remap()
        num_aft = len(appearance.getchild(self.LP).getobjectproperty('children').split(' '))
        if (num_aft - num) != 1:
            raise ldtp.LdtpExecutionError, "Failed to add new background"
示例#7
0
 def wait_until_button_enabled(self, window, button_name):
     if RHSMGuiLocator().get_os_serials() == "5" or RHSMGuiLocator().get_os_serials() == "6":
         while ldtp.hasstate(RHSMGuiLocator().get_locator(window), RHSMGuiLocator().get_locator(button_name), ldtp.state.ENABLED) == 0:
             ldtp.wait(5)
示例#8
0
 def check_object_status(self, window, object_name, status):
     if status == "ENABLED":
         real_status = ldtp.state.ENABLED
     elif status == "VISIBLE":
         real_status = ldtp.state.VISIBLE
     return ldtp.hasstate(RHSMGuiLocator().get_locator(window), RHSMGuiLocator().get_locator(object_name), real_status)
    def create_archive(self, src_path, tag):
        """
        To create a new archive file in user's home directory

        @type src_path: char
        @param src_path: source file/folder path
        @type tag: int
        @param tag: 0 for folder, 1 for file
        """
        archive = ooldtp.context(self.WINDOW)

        archive.getchild(self.BTN_NEW).click()

        ldtp.waittillguiexist(self.DLG_NEW)

        """
        Remove the file which might have same file name
        A workaround to the bug #7151417
        """
        exist_file_path = os.getenv('HOME') + '/' + self.ARCH_NAME
        if os.access(exist_file_path, os.F_OK):
            os.remove(exist_file_path)

        """
        Give a archive file name, then create this file.
        """
        new = ooldtp.context(self.DLG_NEW)
        new.getchild(self.TXT_NAME).settextvalue(self.ARCH_NAME)
        new.getchild(self.CBO_SAVE_IN_FOLDER).selectindex(0)
        new.getchild(self.BTN_CREATE).click()
        ldtp.waittillguinotexist(self.DLG_NEW)
        """
        If tag == 1, add a file to archive file
        If tag == 0, add a folder to archive file
        """
        if tag == 1:
            btn = self.BTN_ADDFILES
            window = self.DLG_ADD_FILES
        elif tag == 0:
            btn = self.BTN_ADDFOLDER
            window = self.DLG_ADD_A_FOLDER
        else:
            raise ldtp.LdtpExecutionError, "Wrong file tag given"

        win_name = 'frm' + self.ARCH_NAME
        archive = ooldtp.context(win_name)
        archive.getchild(btn).click()

        ldtp.waittillguiexist(window)
        add = ooldtp.context(window)
        """
        Add file/folder to the archive file
        """
        while add.getchild(self.TBTN_TYPE_A_FILE_NAME).press():
            if ldtp.hasstate(window, self.TXT_LOCATION, 'SHOWING'):
                break
        else:
            raise ldtp.LdtpExecutionError, "Failed to toggle the " + window + " dialog Location button"

        if tag == 0:
            while add.getchild(self.TBTN_FILESYSTEMROOT).verifytoggled() == 0:
                add.getchild(self.TBTN_FILESYSTEMROOT).click()
        add.settextvalue(self.TXT_LOCATION,src_path)
        add.enterstring(self.TXT_LOCATION,'<enter>')
        ldtp.waittillguinotexist(window)
        """
        Verify filed added
        """
        if archive.getchild(self.MNU_LASTOUTPUT).hasstate('enabled'):
            archive.getchild(self.MNU_LASTOUTPUT).selectmenuitem()
            ldtp.waittillguiexist(self.DLG_LASTOUTPUT)
            output = ooldtp.context(self.DLG_LASTOUTPUT)
            if output.getchild(self.TXT_0).gettextvalue() == None:
                raise ldtp.LdtpExecutionError, "None file was added!"
            else:
                output.getchild(self.BTN_CLOSE).click()
        else:
            raise ldtp.LdtpExecutionError, "Nothing added, last output menu is not enabled!"
示例#10
0
    def create_archive(self, src_path, tag):
        """
        To create a new archive file in user's home directory

        @type src_path: char
        @param src_path: source file/folder path
        @type tag: int
        @param tag: 0 for folder, 1 for file
        """
        archive = ooldtp.context(self.WINDOW)

        archive.getchild(self.BTN_NEW).click()

        ldtp.waittillguiexist(self.DLG_NEW)
        """
        Remove the file which might have same file name
        A workaround to the bug #7151417
        """
        exist_file_path = os.getenv('HOME') + '/' + self.ARCH_NAME
        if os.access(exist_file_path, os.F_OK):
            os.remove(exist_file_path)
        """
        Give a archive file name, then create this file.
        """
        new = ooldtp.context(self.DLG_NEW)
        new.getchild(self.TXT_NAME).settextvalue(self.ARCH_NAME)
        new.getchild(self.CBO_SAVE_IN_FOLDER).selectindex(0)
        new.getchild(self.BTN_CREATE).click()
        ldtp.waittillguinotexist(self.DLG_NEW)
        """
        If tag == 1, add a file to archive file
        If tag == 0, add a folder to archive file
        """
        if tag == 1:
            btn = self.BTN_ADDFILES
            window = self.DLG_ADD_FILES
        elif tag == 0:
            btn = self.BTN_ADDFOLDER
            window = self.DLG_ADD_A_FOLDER
        else:
            raise ldtp.LdtpExecutionError, "Wrong file tag given"

        win_name = 'frm' + self.ARCH_NAME
        archive = ooldtp.context(win_name)
        archive.getchild(btn).click()

        ldtp.waittillguiexist(window)
        add = ooldtp.context(window)
        """
        Add file/folder to the archive file
        """
        while add.getchild(self.TBTN_TYPE_A_FILE_NAME).press():
            if ldtp.hasstate(window, self.TXT_LOCATION, 'SHOWING'):
                break
        else:
            raise ldtp.LdtpExecutionError, "Failed to toggle the " + window + " dialog Location button"

        if tag == 0:
            while add.getchild(self.TBTN_FILESYSTEMROOT).verifytoggled() == 0:
                add.getchild(self.TBTN_FILESYSTEMROOT).click()
        add.settextvalue(self.TXT_LOCATION, src_path)
        add.enterstring(self.TXT_LOCATION, '<enter>')
        ldtp.waittillguinotexist(window)
        """
        Verify filed added
        """
        if archive.getchild(self.MNU_LASTOUTPUT).hasstate('enabled'):
            archive.getchild(self.MNU_LASTOUTPUT).selectmenuitem()
            ldtp.waittillguiexist(self.DLG_LASTOUTPUT)
            output = ooldtp.context(self.DLG_LASTOUTPUT)
            if output.getchild(self.TXT_0).gettextvalue() == None:
                raise ldtp.LdtpExecutionError, "None file was added!"
            else:
                output.getchild(self.BTN_CLOSE).click()
        else:
            raise ldtp.LdtpExecutionError, "Nothing added, last output menu is not enabled!"