예제 #1
0
    def save(self, filename):
        """
        It tries to save the current opened buffer to the filename passed as parameter.

        TODO: It does not manage the overwrite dialog yet.

        @type filename: string
        @param filename: The name of the file to save the buffer to.
        """
        Application.save(self, self.MNU_SAVE)
        ooldtp.context(self.name)

        ldtp.waittillguiexist(self.SAVE_DLG)
        save_dialog = ooldtp.context(self.SAVE_DLG)
        
        save_dlg_txt_filename = save_dialog.getchild(self.SAVE_DLG_TXT_NAME)
        ldtp.wait(2)
        save_dlg_txt_filename.settextvalue(filename)

        save_dlg_btn_save = save_dialog.getchild(self.SAVE_DLG_BTN_SAVE)
        
        save_dlg_btn_save.click()

        ldtp.waittillguinotexist(self.SAVE_DLG)
        ldtp.wait(1)
예제 #2
0
    def test_startUI(self):
        ldtp.launchapp("./netzob")

        selectWorkspaceFrame = "SelectWorkspace"
        ldtp.waittillguiexist(selectWorkspaceFrame, guiTimeOut=30)
        ldtp.click(selectWorkspaceFrame, "btnCancel")
        ldtp.waittillguinotexist(selectWorkspaceFrame)
예제 #3
0
파일: t_pm_rmrepo.py 프로젝트: aszeszo/test
        def testRmRepository(self):
                repo_name = "test2"
                pm_str = "%s/usr/bin/packagemanager" % pkg5unittest.g_proto_area
                ldtp.launchapp(pm_str,["-R", self.get_img_path()])
                ldtp.waittillguiexist('Package Manager', state = ldtp.state.ENABLED)

                ldtp.selectmenuitem('Package Manager', 'mnuFile;mnuManage Publishers...')
                
                ldtp.waittillguiexist('dlgManage Publishers')

                ldtp.selectrow('dlgManage Publishers', 'Publishers', repo_name)

                ldtp.click('dlgManage Publishers', 'btnRemove')

                ldtp.click('dlgManage Publishers', 'btnOK')

                ldtp.waittillguiexist('dlgManage Publishers Confirmation')

                ldtp.click('dlgManage Publishers Confirmation', 'btnOK')

                ldtp.waittillguinotexist('dlgManage Publishers')

                # Verify result
                self.pkg('publisher | grep %s' % repo_name, exit=1)

                # Quit Package Manager
                ldtp.selectmenuitem('Package Manager', 'mnuFile;mnuQuit')
예제 #4
0
    def save(self, filename):
        """
        It tries to save the current opened buffer to the filename passed as parameter.

        TODO: It does not manage the overwrite dialog yet.

        @type filename: string
        @param filename: The name of the file to save the buffer to.
        """
        Application.save(self, self.MNU_SAVE)
        ooldtp.context(self.name)

        ldtp.waittillguiexist(self.SAVE_DLG)
        save_dialog = ooldtp.context(self.SAVE_DLG)

        save_dlg_txt_filename = save_dialog.getchild(self.SAVE_DLG_TXT_NAME)
        ldtp.wait(2)
        save_dlg_txt_filename.settextvalue(filename)

        save_dlg_btn_save = save_dialog.getchild(self.SAVE_DLG_BTN_SAVE)

        save_dlg_btn_save.click()

        ldtp.waittillguinotexist(self.SAVE_DLG)
        ldtp.wait(1)
예제 #5
0
    def test_startUI(self):
        ldtp.launchapp("./netzob")

        selectWorkspaceFrame = "SelectWorkspace"
        ldtp.waittillguiexist(selectWorkspaceFrame, guiTimeOut=30)
        ldtp.click(selectWorkspaceFrame, "btnCancel")
        ldtp.waittillguinotexist(selectWorkspaceFrame)
예제 #6
0
파일: base.py 프로젝트: feiying/Deja-dup
def restore_specific(files, path, date=None, backend = None, encrypt = True, dest = None):
  global srcdir
  files = [os.path.join(srcdir, f) for f in files]
  args = ['--restore'] + files
  start_deja_dup(args=args, waitfor='frmRestore')

  if backend is not None:
    walk_restore_prefs('frmRestore', backend=backend, dest=dest)
  ldtp.click('frmRestore', 'btnForward')

  wait_for_finish('frmRestore', 'lblRestoreFromWhen?', 200)
  if date:
    ldtp.comboselect('frmRestore', 'cboDate', date)
  ldtp.click('frmRestore', 'btnForward')
  ldtp.click('frmRestore', 'btnRestore')

  if encrypt is not None:
    wait_for_encryption('frmRestore', encrypt)

  if len(files) == 1:
    lbl = 'lblYourfilewassuccessfullyrestored'
  else:
    lbl = 'lblYourfilesweresuccessfullyrestored'
  wait_for_finish('frmRestore', lbl, 400)

  ldtp.click('frmRestore', 'btnClose')
  ldtp.waittillguinotexist('frmRestore')
예제 #7
0
        def testInstallSimplePackage(self):
                pkgname = 'package1'
                pm_str = "%s/usr/bin/packagemanager" % pkg5unittest.g_proto_area

                self.pkgsend_bulk(self.rurl, self.foo10)
                self.image_create(self.rurl)

                ldtp.launchapp(pm_str,["-R", self.get_img_path()])
                ldtp.waittillguiexist('Package Manager', state = ldtp.state.ENABLED)
                ldtp.selectindex('Package Manager', 'Publisher', 0)
                ldtp.selectrow('Package Manager', 'Packages', pkgname)
                ldtp.selectmenuitem('Package Manager', 'mnuEdit;mnuSelect All')
                ldtp.click('Package Manager', 'btnInstall/Update')
                ldtp.waittillguiexist('dlgInstall Confirmation')
                ldtp.click('dlgInstall Confirmation', 'btnProceed')

                while (ldtp.objectexist('dlgInstall/Update', 'btnClose') == 0):
                        ldtp.wait(0.1)

                ldtp.click('dlgInstall/Update', 'btnClose')

                ldtp.waittillguinotexist('dlgInstall/Update')

                # Verify result
                self.pkg('verify')

                # Quit packagemanager
                ldtp.selectmenuitem('Package Manager', 'mnuFile;mnuQuit')
예제 #8
0
    def close(self, save=False, filename=''):
        """
        Given a gedit window, it tries to close the application.
        By default, it closes without saving. This behaviour can be changed to save (or save as) on close.
         
        @type save: boolean
        @param save: If True, the edited file will be saved on close.

        @type filename: string
        @param filename: The file name to save the buffer to 
        """

        # Exit using the Quit menu 
        gedit = ooldtp.context(self.name)
        quit_menu = gedit.getchild(self.MNU_QUIT)
        quit_menu.selectmenuitem()

        question_dialog = None
        count = 0
        while not gedit.waittillguinotexist(guiTimeOut=1) and \
                count < 10:
            try:
                question_dialog = ooldtp.context(self.QUESTION_DLG)
            except:
                count += 1
            else:
                break

        # If the text has changed, the save dialog will appear
        if question_dialog:
            # Test if the file needs to be saved
            if save:
                try:
                    question_dlg_btn_save = question_dialog.getchild(self.QUESTION_DLG_BTN_SAVE)
                    question_dlg_btn_save.click()
                except ldtp.LdtpExecutionError:
                    # If the Save button was not found, we will try to find the Save As
                    question_dlg_btn_save = question_dialog.getchild(self.QUESTION_DLG_BTN_SAVE_AS)
                    question_dlg_btn_save.click()

                    ldtp.waittillguiexist(self.SAVE_DLG)
                    save_dialog = ooldtp.context(self.SAVE_DLG)
                    
                    save_dlg_txt_filename = save_dialog.getchild(self.SAVE_DLG_TXT_NAME)
                    ldtp.wait(2)
                    save_dlg_txt_filename.settextvalue(filename)

                    save_dlg_btn_save = save_dialog.getchild(self.SAVE_DLG_BTN_SAVE)
                    save_dlg_btn_save.click()

                    ldtp.waittillguinotexist(self.SAVE_DLG)
            
            else:
                question_dlg_btn_close = question_dialog.getchild(self.QUESTION_DLG_BTN_CLOSE)
                question_dlg_btn_close.click()

            gedit.waittillguinotexist(guiTimeOut=20)
예제 #9
0
    def wait_till_gui_not_exist(self,
                                window_name,
                                object_name='',
                                gui_time_out=30):
        """
        Wait till a window or component doesn't exist.

        :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 window_name: string

        :param gui_time_out: Wait timeout in seconds.

        @type gui_time_out: integer

        :return: 1 if GUI has gone away, 0 if not

        @rtype: integer
        """
        try:
            self._info("wait till a window or component exists. [%s, %s, %d]" %
                       (window_name, object_name, gui_time_out))
            return ldtp.waittillguinotexist(window_name, object_name,
                                            gui_time_out)
        except LdtpExecutionError:
            raise LdtpExecutionError("exec ldtp.waittillguinotexist failed")
예제 #10
0
def close_astylewx_ldtp():
    """Close the test project astylewx program.
    """
    #print("Closing astylewx ldtp")
    ldtp.closewindow('frmAStyleWx')
    if not ldtp.waittillguinotexist('*AStyleWx'):
        terminate_program("Error in waittillguinotexist")
예제 #11
0
def close_astylewx_ldtp():
    """Close the test project astylewx program.
    """
    #print("Closing astylewx ldtp")
    ldtp.closewindow('frmAStyleWx')
    if not ldtp.waittillguinotexist('*AStyleWx'):
        terminate_program("Error in waittillguinotexist")
예제 #12
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)
예제 #13
0
 def tearDown(self):
     ldtp.selectmenuitem('frmUbuntuSoftwareCent*', 'mnuClose')
     assert ldtp.waittillguinotexist('frmUbuntuSoftwareCent*')
     c = "This test took a total of " + str(
         time.time() - start_time) + " Cpu percentage: " + str(
             ldtp.getcpustat(
                 'software-center')) + " Memory usage in MB: " + str(
                     ldtp.getmemorystat('software-center'))
     self.msgs.append(c)
     print '\n'.join(self.msgs)
예제 #14
0
    def close_help(self, help_window):
        """
        It tries to close the help window(gnome-help), which is invoked by start_help method.
        help_window: application help window name
        """
        helpApp = ooldtp.context(help_window)
        helpApp.getchild('mnuCloseWindow').selectmenuitem()

        if ldtp.waittillguinotexist(help_window) == 0:
            raise ldtp.LdtpExecutionError, "The " + help_window + " does not quit as expected, there is something wrong..."
예제 #15
0
파일: base.py 프로젝트: feiying/Deja-dup
def restore_simple(path, date=None, backend = None, encrypt=True, dest = None):
  start_deja_dup(executable='deja-dup-preferences')

  if guivisible('frmBackup', 'btnIwanttorestorefilesfromapreviousbackup…'):
    ldtp.click('frmBackup', 'btnIwanttorestorefilesfromapreviousbackup…')
  else:
    ldtp.selecttab('frmBackup', 'ptlCategories', 'Overview')
    ldtp.click('frmBackup', 'btnRestore…')

  waitforgui('frmRestore')

  if backend is not None:
    walk_restore_prefs('frmRestore', backend, dest)  
  ldtp.click('frmRestore', 'btnForward')

  wait_for_finish('frmRestore', 'lblRestoreFromWhen?', 200)
  if date:
    ldtp.comboselect('frmRestore', 'cboDate', date)
  ldtp.click('frmRestore', 'btnForward')

  ldtp.click('frmRestore', 'rbtnRestoretospecificfolder')
  ldtp.comboselect('frmRestore', 'cboRestorefolder', 'Other...')
  waitforgui('dlgChoosedestinationforrestoredfiles')
  # Make sure path ends in '/'
  if path[-1] != '/':
    path += '/'
  ldtp.selectlastrow('dlgChoosedestinationforrestoredfiles', 'tblPlaces') # must switch away from Recent Files view to get txtLocation
  ldtp.wait(1) # give the dlg a second to settle
  ldtp.settextvalue('dlgChoosedestinationforrestoredfiles', 'txtLocation', path)
  ldtp.click('dlgChoosedestinationforrestoredfiles', 'btnOpen')
  ldtp.wait(1) # give the combo a second to settle
  ldtp.click('frmRestore', 'btnForward')
  ldtp.wait(1) # give the dlg a second to settle
  ldtp.click('frmRestore', 'btnRestore')

  if encrypt is not None:
    wait_for_encryption('frmRestore', encrypt)

  wait_for_finish('frmRestore', 'lblYourfilesweresuccessfullyrestored', 400)
  ldtp.click('frmRestore', 'btnClose')
  ldtp.waittillguinotexist('frmRestore')
예제 #16
0
    def save_to_file(self, filename):
        """
        Complete the save to file dialog.  You must have completed a grab_* already

        @type filename: string
        @param filename: The name of the file to save.  This file will be saved 
                         into the current users home folder.  You cannot
                         specify a directory.
        """
        ldtp.wait()
        if ldtp.waittillguiexist(self.SAVE_FILE_WINDOW):
            save_dialog = ooldtp.context(self.SAVE_FILE_WINDOW)
        else:
            raise ldtp.LdtpExecutionError, "Failed to get " + self.SAVE_FILE_WINDOW + " dialog"
        # Set save file name
        save_dialog.getchild(self.SAVE_FILE_NAME_TEXT).settextvalue(filename)
        # Set save file directory to user's home
        save_dialog.getchild(self.CBO_SAVE).selectindex(0)
        save_dialog.getchild(self.SAVE_FILE_BUTTON).click()

        ldtp.waittillguinotexist(self.SAVE_FILE_WINDOW)
예제 #17
0
    def close_app(self, app_windowname):
        """
        It tries to close the appliation
        """
        app = ooldtp.context(app_windowname)
          
        app.closewindow()

        ldtp.wait(2)
       	
        response = ldtp.waittillguinotexist(self.name, '', 100)    
        if response == 0:
            raise ldtp.LdtpExecutionError, "The " + self.name + " window was not closed." 
예제 #18
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"
예제 #19
0
def main():
    """Main processing function.
    """
    if os.name == "nt":
        exepath = "C:/Users/jimp/Projects/AStyleWx/build/vs2013_3.0/debug/AStyleWxd.exe"
    else:
        exepath = "../../AStyleWx/build/cb-gcc/wx3.0/bin/astylewxd"
    exepath = exepath.replace('/', os.sep)

    #print(sys.path[0])
    os.chdir(sys.path[0])

    if not os.path.exists(exepath):
        print("Cannot find executable: " + exepath)
        print("The script has terminated!")
        sys.exit(1)

    print("Launching AStyleWx")
    try:
        ldtp.launchapp(exepath)
    except ldtp.client_exception.LdtpExecutionError as err:
        print("Error in launchapp: " + exepath)
        print(err)
        print("The script has terminated!")
        sys.exit(1)
    if not ldtp.waittillguiexist('*AStyleWx'):
        print("Error in waittillguiexist")
        print("The script has terminated!")
        sys.exit(1)

    print('\nFile')
    print(ldtp.listsubmenus('frmAStyleWx', 'mnuFile'))
    print('\nEdit')
    print(ldtp.listsubmenus('frmAStyleWx', 'mnuEdit'))
    print('\nSearch')
    print(ldtp.listsubmenus('frmAStyleWx', 'mnuSearch'))
    print('\nView')
    print(ldtp.listsubmenus('frmAStyleWx', 'mnuView'))
    print('\nTools')
    print(ldtp.listsubmenus('frmAStyleWx', 'mnuTools'))
    print('\nHelp')
    print(ldtp.listsubmenus('frmAStyleWx', 'mnuHelp'))
    print()

    print("Closing AStyleWx")
    ldtp.selectmenuitem('frmAStyleWx', 'mnuFile;mnuExit')
    if not ldtp.waittillguinotexist('*AStyleWx'):
        print("Error in waittillguinotexist")
        print("The script has terminated!")
        sys.exit(1)
예제 #20
0
def main():
    """Main processing function.
    """
    if os.name == "nt":
        exepath = "C:/Users/jimp/Projects/AStyleWx/build/vs2013_3.0/debug/AStyleWxd.exe"
    else:
        exepath = "../../AStyleWx/build/cb-gcc/wx3.0/bin/astylewxd"
    exepath = exepath.replace('/', os.sep)

    #print(sys.path[0])
    os.chdir(sys.path[0])

    if not os.path.exists(exepath):
        print("Cannot find executable: " + exepath)
        print("The script has terminated!")
        sys.exit(1)

    print("Launching AStyleWx")
    try:
        ldtp.launchapp(exepath)
    except ldtp.client_exception.LdtpExecutionError as err:
        print("Error in launchapp: " + exepath)
        print(err)
        print("The script has terminated!")
        sys.exit(1)
    if not ldtp.waittillguiexist('*AStyleWx'):
        print("Error in waittillguiexist")
        print("The script has terminated!")
        sys.exit(1)

    print('\nFile')
    print(ldtp.listsubmenus('frmAStyleWx', 'mnuFile'))
    print('\nEdit')
    print(ldtp.listsubmenus('frmAStyleWx', 'mnuEdit'))
    print('\nSearch')
    print(ldtp.listsubmenus('frmAStyleWx', 'mnuSearch'))
    print('\nView')
    print(ldtp.listsubmenus('frmAStyleWx', 'mnuView'))
    print('\nTools')
    print(ldtp.listsubmenus('frmAStyleWx', 'mnuTools'))
    print('\nHelp')
    print(ldtp.listsubmenus('frmAStyleWx', 'mnuHelp'))
    print()

    print("Closing AStyleWx")
    ldtp.selectmenuitem('frmAStyleWx', 'mnuFile;mnuExit')
    if not ldtp.waittillguinotexist('*AStyleWx'):
        print("Error in waittillguinotexist")
        print("The script has terminated!")
        sys.exit(1)
예제 #21
0
    def open_file(self, filename):
        gedit = ooldtp.context(self.name)
        gedit.selectmenuitem(self.MNU_OPEN)
        response = ldtp.waittillguiexist(self.OPEN_DLG)
        if not response:
            raise "can not open the dialog of open-a-file."
        openfile_dialog = ooldtp.context(self.OPEN_DLG)
        if not openfile_dialog.objectexist('txtLocation'):
            print "Location text exist"
            openfile_dialog.click('btnOpen')
        openfile_dialog.settextvalue('txtLocation', filename)
        openfile_dialog.click('btnOpen')

        response = ldtp.waittillguinotexist('dlgOpenaFile', '', 30)
        if not response:
            raise "can not open the dialog of open-a-file."
예제 #22
0
    def open_file(self,filename):
        gedit = ooldtp.context(self.name)
        gedit.selectmenuitem(self.MNU_OPEN)
        response = ldtp.waittillguiexist(self.OPEN_DLG)
        if not response:
            raise "can not open the dialog of open-a-file."
        openfile_dialog = ooldtp.context(self.OPEN_DLG)
        if not openfile_dialog.objectexist('txtLocation'): 
             print "Location text exist"
             openfile_dialog.click('btnOpen')
        openfile_dialog.settextvalue('txtLocation',filename)
        openfile_dialog.click('btnOpen')

        response = ldtp.waittillguinotexist('dlgOpenaFile','',30)
        if not response:
            raise "can not open the dialog of open-a-file."
예제 #23
0
    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!"
예제 #24
0
    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!"
예제 #25
0
파일: main.py 프로젝트: zoushidong/mago
 def close(self):
     """
     Given an application, it tries to close it.
     """
     app = ooldtp.context(self.name)
     close_widget = app.getchild(self.close_name)
     ldtp.wait(5)
     if self.close_type == 'menu':
         close_widget.selectmenuitem()
     elif self.close_type == 'button':
         close_widget.click()
     else:
         raise ldtp.LdtpExecutionError, "Wrong close item type."
     ldtp.wait(10)
     response = ldtp.waittillguinotexist(self.name, '', 20)
     if response == 0:
         raise ldtp.LdtpExecutionError, "Mmm, something went wrong when closing the application."
     ldtp.wait(2)
예제 #26
0
파일: main.py 프로젝트: zoushidong/mago
 def close(self):
     """
     Given an application, it tries to close it.
     """
     app = ooldtp.context(self.name)
     close_widget = app.getchild(self.close_name)
     ldtp.wait(5)
     if self.close_type == 'menu':
         close_widget.selectmenuitem()
     elif self.close_type == 'button':
         close_widget.click()
     else:
         raise ldtp.LdtpExecutionError, "Wrong close item type."
     ldtp.wait(10)
     response = ldtp.waittillguinotexist(self.name, '', 20)
     if response == 0:
         raise ldtp.LdtpExecutionError, "Mmm, something went wrong when closing the application."
     ldtp.wait(2)
예제 #27
0
파일: common.py 프로젝트: UIKit0/glom
def enter_connection_credentials(backend_name):
	if backend_name == 'PostgresCentral':
		if ldtp.waittillguiexist('Connection Details') == 0:
			raise ldtp.LdtpExecutionError('The Glom connection details dialog did not appear.')

		(hostname, username, password) = read_central_info()

		# Set connection details
		ldtp.settextvalue('Connection Details', 'txtHost', hostname)
		ldtp.settextvalue('Connection Details', 'txtUser', username)
		ldtp.settextvalue('Connection Details', 'txtPassword', password)

		# Acknowledge the dialog
		ldtp.click('Connection Details', 'btnConnect')

		# Make sure it's gone
		if ldtp.waittillguinotexist('Connection Details') == 0:
			raise ldtp.LdtpExecutionError('The cnnection details dialog did not disappear')
예제 #28
0
def enter_connection_credentials(backend_name):
    if backend_name == 'PostgresCentral':
        if ldtp.waittillguiexist('Connection Details') == 0:
            raise ldtp.LdtpExecutionError(
                'The Glom connection details dialog did not appear.')

        (hostname, username, password) = read_central_info()

        # Set connection details
        ldtp.settextvalue('Connection Details', 'txtHost', hostname)
        ldtp.settextvalue('Connection Details', 'txtUser', username)
        ldtp.settextvalue('Connection Details', 'txtPassword', password)

        # Acknowledge the dialog
        ldtp.click('Connection Details', 'btnConnect')

        # Make sure it's gone
        if ldtp.waittillguinotexist('Connection Details') == 0:
            raise ldtp.LdtpExecutionError(
                'The cnnection details dialog did not disappear')
예제 #29
0
    def close_about(self, about_window):
        """
        It tries to close the about window, which is invoked by start_about method.
        about_window: application about window name
        """
        CLOSE_NAME_1 = "btnClose"
        CLOSE_NAME_2 = "btnOK"

        aboutApp = ooldtp.context(about_window)

        if aboutApp.verifypushbutton(CLOSE_NAME_1) == 1 and aboutApp.hasstate(CLOSE_NAME_1, 'enabled'):
            CLOSE_WIDGET = CLOSE_NAME_1
        elif aboutApp.verifypushbutton(CLOSE_NAME_2) == 1 and aboutApp.hasstate(CLOSE_NAME_2, 'enabled'):
            CLOSE_WIDGET = CLOSE_NAME_2
        else:
            raise ldtp.LdtpExecutionError, "Can not find enabled Close/OK button in About dialog." 

        aboutApp.getchild(CLOSE_WIDGET).click()
        ldtp.wait(10)
        if ldtp.waittillguinotexist(about_window) == 0:
            raise ldtp.LdtpExecutionError, "The " + about_window + " does not quit as expected, there is something wrong..."
예제 #30
0
    def close_about(self, about_window):
        """
        It tries to close the about window, which is invoked by start_about method.
        about_window: application about window name
        """
        CLOSE_NAME_1 = "btnClose"
        CLOSE_NAME_2 = "btnOK"

        aboutApp = ooldtp.context(about_window)

        if aboutApp.verifypushbutton(CLOSE_NAME_1) == 1 and aboutApp.hasstate(
                CLOSE_NAME_1, 'enabled'):
            CLOSE_WIDGET = CLOSE_NAME_1
        elif aboutApp.verifypushbutton(
                CLOSE_NAME_2) == 1 and aboutApp.hasstate(
                    CLOSE_NAME_2, 'enabled'):
            CLOSE_WIDGET = CLOSE_NAME_2
        else:
            raise ldtp.LdtpExecutionError, "Can not find enabled Close/OK button in About dialog."

        aboutApp.getchild(CLOSE_WIDGET).click()
        ldtp.wait(10)
        if ldtp.waittillguinotexist(about_window) == 0:
            raise ldtp.LdtpExecutionError, "The " + about_window + " does not quit as expected, there is something wrong..."
예제 #31
0
파일: common.py 프로젝트: UIKit0/glom
def exit_glom():
	ldtp.selectmenuitem(main_window, 'mnuFile;mnuClose')

	if ldtp.waittillguinotexist('*Glom*') == 0:
		raise ldtp.LdtpExecutionError('The Glom Window did not disappear after closing the application.')
 def tearDown(self):
     ldtp.selectmenuitem('frmUbuntuSoftwareCent*', 'mnuClose')
     assert ldtp.waittillguinotexist('frmUbuntuSoftwareCent*')
     c = "This test took a total of " + str(time.time() - start_time)
     self.msgs.append(c)
     print '\n'.join(self.msgs)
예제 #33
0
def step_impl(context, win):
    time.sleep(2) # closing usually needs a task switch to some UI thread to process it
    assert(l.waittillguinotexist(win) == 1)
예제 #34
0
 def check_window_closed(self, window):
     ldtp.waittillguinotexist(RHSMGuiLocator().get_locator(window))
예제 #35
0
 def cleanup(self):
     ldtp.waittillguinotexist(self.application.WINDOW, guiTimeOut=70)
예제 #36
0
 def teardown(self):
     ldtp.waittillguinotexist(self.application.WINDOW, guiTimeOut=70)
예제 #37
0
def exit_glom():
    ldtp.selectmenuitem(main_window, 'mnuFile;mnuClose')

    if ldtp.waittillguinotexist('*Glom*') == 0:
        raise ldtp.LdtpExecutionError(
            'The Glom Window did not disappear after closing the application.')
예제 #38
0
    def close(self, save=False, filename=''):
        """
        Given a gedit window, it tries to close the application.
        By default, it closes without saving. This behaviour can be changed to save (or save as) on close.
         
        @type save: boolean
        @param save: If True, the edited file will be saved on close.

        @type filename: string
        @param filename: The file name to save the buffer to 
        """

        # Exit using the Quit menu
        gedit = ooldtp.context(self.name)
        quit_menu = gedit.getchild(self.MNU_QUIT)
        quit_menu.selectmenuitem()

        question_dialog = None
        count = 0
        while not gedit.waittillguinotexist(guiTimeOut=1) and \
                count < 10:
            try:
                question_dialog = ooldtp.context(self.QUESTION_DLG)
            except:
                count += 1
            else:
                break

        # If the text has changed, the save dialog will appear
        if question_dialog:
            # Test if the file needs to be saved
            if save:
                try:
                    question_dlg_btn_save = question_dialog.getchild(
                        self.QUESTION_DLG_BTN_SAVE)
                    question_dlg_btn_save.click()
                except ldtp.LdtpExecutionError:
                    # If the Save button was not found, we will try to find the Save As
                    question_dlg_btn_save = question_dialog.getchild(
                        self.QUESTION_DLG_BTN_SAVE_AS)
                    question_dlg_btn_save.click()

                    ldtp.waittillguiexist(self.SAVE_DLG)
                    save_dialog = ooldtp.context(self.SAVE_DLG)

                    save_dlg_txt_filename = save_dialog.getchild(
                        self.SAVE_DLG_TXT_NAME)
                    ldtp.wait(2)
                    save_dlg_txt_filename.settextvalue(filename)

                    save_dlg_btn_save = save_dialog.getchild(
                        self.SAVE_DLG_BTN_SAVE)
                    save_dlg_btn_save.click()

                    ldtp.waittillguinotexist(self.SAVE_DLG)

            else:
                question_dlg_btn_close = question_dialog.getchild(
                    self.QUESTION_DLG_BTN_CLOSE)
                question_dlg_btn_close.click()

            gedit.waittillguinotexist(guiTimeOut=20)
예제 #39
0
 def cleanup(self):
     ldtp.waittillguinotexist(self.application.WINDOW, guiTimeOut=70)
예제 #40
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!"
예제 #41
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!"
예제 #42
0
 def teardown(self):
     ldtp.waittillguinotexist(self.application.WINDOW, guiTimeOut=70)
예제 #43
0
파일: gcalctool.py 프로젝트: eeejay/ldtp2
 def tearDown(self):
     ldtp.selectmenuitem('frmCalculator*', 'mnuQuit')
     ldtp.waittillguinotexist('frmCalculator*')
예제 #44
0
 def tearDown(self):
     ldtp.selectmenuitem("frmCalculator*", "mnuQuit")
     ldtp.waittillguinotexist("frmCalculator*")
예제 #45
0
    def take_screenshot(self, option, effects, delay):
        """
        Complete the "Take Screenshot" dialog box by choosing one option
        from whole desktop, current window and select area to grab,
        then clicking Take Screenshot.

        You must have started the application already.

        @type option: char
        @param option: the different name of the radio button
        @type effects: int 
        @param effects: 1 to set effects on, 0 to set effects off
        @type delay: int
        @param delay: The number of seconds to delay before taking the 
                      screenshot.
        """
        screenshot = ooldtp.context(self.WINDOW)

        """
        To choose the radio button according to test case
        """
        if option.__contains__("desktop"):
            radio_button = self.GRAB_THE_WHOLE_DESKTOP_RADIO
        elif option.__contains__("window"):
            radio_button = self.GRAB_THE_CURRENT_WINDOW_RADIO
        elif option.__contains__("area"):
            radio_button = self.GRAB_A_SELECTED_AREA

        # To click the radio button
        while screenshot.getchild(radio_button).verifyuncheck():
            screenshot.getchild(radio_button).click()

        # To set the effects on/off according to test case
        if option.__contains__("desktop"):
            if effects == 1:
                while screenshot.getchild(self.CHK_INCLUDE_POINTER).verifyuncheck():
                    screenshot.getchild(self.CHK_INCLUDE_POINTER).check()
            elif effects == 0:
                while screenshot.getchild(self.CHK_INCLUDE_POINTER).verifycheck():
                    screenshot.getchild(self.CHK_INCLUDE_POINTER).uncheck()
        elif option.__contains__("window"):
            if effects == 1:
                while screenshot.getchild(self.CHK_INCLUDE_POINTER).verifyuncheck():
                    screenshot.getchild(self.CHK_INCLUDE_POINTER).check()
                while screenshot.getchild(self.CHK_INCLUDE_THE_WINDOW_BORDER).verifyuncheck():
                    screenshot.getchild(self.CHK_INCLUDE_THE_WINDOW_BORDER).check()
                screenshot.getchild(self.CBO_APPLY_EFFECT).selectindex(random.randint(1, 2))
            elif effects == 0:
                while screenshot.getchild(self.CHK_INCLUDE_POINTER).verifycheck():
                    screenshot.getchild(self.CHK_INCLUDE_POINTER).uncheck()
                while screenshot.getchild(self.CHK_INCLUDE_THE_WINDOW_BORDER).verifycheck():
                    screenshot.getchild(self.CHK_INCLUDE_THE_WINDOW_BORDER).uncheck()
                screenshot.getchild(self.CBO_APPLY_EFFECT).selectindex(0)

        # To set the delay seconds
        if screenshot.getchild(self.GRAB_AFTER_DELAY_FIELD).hasstate("enabled"):
            while int(screenshot.getchild(self.GRAB_AFTER_DELAY_FIELD).getvalue()) != delay:
                screenshot.getchild(self.GRAB_AFTER_DELAY_FIELD).setvalue(delay)

        screenshot.getchild(self.TAKE_SCREENSHOT_BUTTON).click()
        ldtp.waittillguinotexist(self.WINDOW)

        # Select the area of the screen for the screenshot.  As long as your screen is
        # larger than 200x200px this should work fine.
        if option.__contains__("area"):
            try:
                ldtp.generatemouseevent(100, 100, "b1p")  # button 1 press
                ldtp.generatemouseevent(200, 200, "abs")  # move mouse to 200,200
                ldtp.generatemouseevent(200, 200, "b1r")  # button 1 release
            except ldtp.LdtpExecutionError:
                raise ldtp.LdtpExecutionError, "Error selecting screen area"
 def tearDown(self):
     ldtp.selectmenuitem('frmUbuntuSoftwareCent*', 'mnuClose')
     assert ldtp.waittillguinotexist('frmUbuntuSoftwareCent*')
     c = "This test took a total of " + str(time.time() - start_time) + " Cpu percentage: " + str(ldtp.getcpustat('software-center')) + " Memory usage in MB: " + str(ldtp.getmemorystat('software-center'))
     self.msgs.append(c)
     print '\n'.join(self.msgs)
예제 #47
0
 def tearDown(self):
     ldtp.selectmenuitem('frmCalculator*', 'mnuQuit')
     ldtp.waittillguinotexist('frmCalculator*')