Beispiel #1
0
def wait_for_database_open():
    # Wait for the list view to pop up in the main Glom window:
    # Note that the Window title of the Glom Window changes when the file
    # has loaded. If we use wildcards for the Window title (*Glom*) here,
    # then objectexist does not find the notebook_data
    # (ptlListOrDetailsView) widget, even when it has actually appeared.
    # TODO: Maybe we can use setcontext(), to avoid this.
    # TODO: Or maybe this has been fixed in LDTP in the meanwhile,
    # see bug #583021.
    while not ldtp.guiexist('Glom-Test') or not ldtp.objectexist(
            'Glom-Test', 'ptlListOrDetailsView'):
        # onwindowcreate calls the callback in a new thread, which
        # does not really help us since we don't have a mainloop the
        # callback thread could notify, so we would need to have to
        # poll an event anyway. Instead, we can simply poll directly
        # the existance of an error dialog.
        # Plus, there seems to be a bug in LDTP when running a test
        # sequence of multiple tests using onwindowcreate:
        # http://bugzilla.gnome.org/show_bug.cgi?id=586291.
        if ldtp.guiexist('Warning') or ldtp.guiexist('Error'):
            # TODO: Read error message from error dialog
            raise ldtp.LdtpExecutionError('Failed to create new database')

        # Wait a bit and then try again:
        ldtp.wait()
Beispiel #2
0
 def setUp(self):
     """docstring for setUp"""
     self.mv_name = "frmOrd-enLey"
     self.new_c_button_name = "btnNew"
     self.delete_c_button_name = "btnDelete"
     self.tree_name_mv = "tbl0"
     ldtp.launchapp('python', args=['/home/skar/projects/python/orden-ley/ordenley/tests/run.py'])
     ldtp.guiexist(self.mv_name)
Beispiel #3
0
	def gui_exists(self, window_name, object_name="NOT_SET"):
		'''
			Checks if a window or an object exits.
		'''		
		gui_existing = 0
		if object_name == "NOT_SET":
			gui_existing = ldtp.guiexist(window_name)
		else:
			gui_existing = ldtp.guiexist(window_name, object_name)
		if not gui_existing:
			raise Exception("%s:%s does not exist" % (window_name, object_name))
Beispiel #4
0
    def revert_font(self):
        appearance = ooldtp.context(self.name)
        appearance.getchild(self.PTABLE).selecttab(self.PTAB_FONTS)
       
        font_btn = [self.BTN_APPLICATIONFONT, self.BTN_DOCUMENTFONT, self.BTN_DESKTOPFONT, self.BTN_WINDOWTITLEFONT, self.BTN_FIXEDWIDTHFONT]
        for btn in font_btn:
            appearance.getchild(btn).click()
            ldtp.wait()

            if ldtp.guiexist(self.DLG_PICKAFONT):
                pickaFont = ooldtp.context(self.DLG_PICKAFONT)
                if btn == self.BTN_WINDOWTITLEFONT:
                    pickaFont.getchild(self.TBL_FAMILY).selectrow('Sans')
                    pickaFont.getchild(self.TBL_STYLE).selectrow('Bold')
                elif btn == self.BTN_FIXEDWIDTHFONT:
                    pickaFont.getchild(self.TBL_FAMILY).selectrow('Monospace')
                    pickaFont.getchild(self.TBL_STYLE).selectrow('Regular')
                else:
                    pickaFont.getchild(self.TBL_FAMILY).selectrow('Sans')
                    pickaFont.getchild(self.TBL_STYLE).selectrow('Regular')
                pickaFont.getchild(self.TBL_SIZE).selectrow('10')
                pickaFont.getchild(self.BTN_OK).click()
                if platform.processor() == 'sparc':
                    ldtp.waittillguiexist(self.WINDOW, 30)
                else:
                    ldtp.waittillguiexist(self.WINDOW, 10)
            else:
                raise ldtp.LdtpExecutionError, "Failed to restore the default font settings"
Beispiel #5
0
    def start_help(self, app_name, help_widget, help_window):
        """
        It will try to launch the application, and then open application content help 
        window after application is invoked
        help_widget: application help widget, which includes menuitem and pushbutton
        help_window: application help window name

        """

        ldtp.launchapp(app_name)
        ldtp.waittillguiexist(self.name)

        app = ooldtp.context(self.name)
        mnu = True

        if app.verifypushbutton(help_widget) == 1 and app.hasstate(help_widget, 'enabled') == 1:
            mnu = False

        if mnu == True:
            app.getchild(help_widget).selectmenuitem()
        else:
            app.getchild(help_widget).click()

        if platform.processor() == 'sparc':
            ldtp.wait(45)
        else:
            ldtp.wait(30)

        if ldtp.guiexist(help_window) == 0:
            raise ldtp.LdtpExecutionError, "The help window " + help_window + " can't be invoked, something wrong with the application help."
Beispiel #6
0
 def click_type_file_name_button(self):
     if ldtp.guiexist(RHSMGuiLocator().get_locator("import-cert-dialog"), RHSMGuiLocator().get_locator("location-text")) == 1:
         return
     else:
         logger.info("click_type_file_name_button")
         self.click_button("import-cert-dialog", "type-file-name-button")
         ldtp.waittillguiexist(RHSMGuiLocator().get_locator("import-cert-dialog"), RHSMGuiLocator().get_locator("location-text"))
Beispiel #7
0
def guiexist(frm, obj, prefix=False):
  if not prefix:
    return obj if ldtp.guiexist(frm, obj) else None
  else:
    objs = ldtp.getobjectlist(frm)
    objs = filter(lambda x: x.startswith(obj), objs)
    return objs[0] if objs else None
Beispiel #8
0
    def change_font(self, category):
        appearance = ooldtp.context(self.name)
        appearance.getchild(self.PTABLE).selecttab(self.PTAB_FONTS)
        appearance.getchild(self.FONTS[category]["BTN"]).click()
        ldtp.wait(2)

        if (ldtp.guiexist(self.DLG_PICKAFONT)):
            pickaFont = ooldtp.context(self.DLG_PICKAFONT)
            pickaFont.getchild(self.TBL_FAMILY).selectrow(self.FONTS[category]["FAMILY"])
            pickaFont.getchild(self.TBL_STYLE).selectrow(self.FONTS[category]["STYLE"])
            pickaFont.getchild(self.TBL_SIZE).selectrow(self.FONTS[category]["SIZE"])
            pickaFont.getchild(self.BTN_OK).click()
        else:
            raise ldtp.LdtpExecutionError, "Failed to setup font properties"

        ldtp.waittillguiexist(self.WINDOW)

        #To check the change has been made as expected
        font_prop = appearance.getchild(self.FONTS[category]["BTN"]).getobjectproperty('children').split(' ')
        for i in range(len(font_prop)):
            if (font_prop[i].__contains__(self.FONTS[category]["FAMILY"]) and \
               font_prop[i].__contains__(self.FONTS[category]["STYLE"].replace(' ',''))) or \
               (font_prop[i] == ('lbl' + self.FONTS[category]["FAMILY"] + self.FONTS[category]["STYLE"].replace(' ',''))) or \
               (font_prop[i] == ('lbl' + self.FONTS[category]["FAMILY"])) or \
               (font_prop[i].__contains__(self.FONTS[category]["FAMILY"])) or \
               (font_prop[i].__contains__(self.FONTS[category]["SIZE"])):
                pass
            else:
                raise ldtp.LdtpExecutionError, "Font properties not changed correctly"
    def list( self, name ):
	#先判断是不是特殊的,如果是就修改成真正要查找的名字 
	self.parent = None
	self.lst_map={}
	if(name in define.special_dlg.keys()):
		name=self.to_list(name)
	if(name in define.special_updlg.keys()):
	    	name=self.to_uplist(name)
	print name
        try :
  	    if 0 == len( name ):
                self.ls = ldtp.getwindowlist()
            elif 1 == ldtp.guiexist( name ):
                self.ls = ldtp.getobjectlist( name )
		self.lst_map=self.cope_lst(name)
            else:
                self.msg = "没有找到窗口"
                return False
        except :
            self.msg = "没有找到窗口"
            return False

        v = len( self.ls )
        if 0 == v:
            self.msg = "没有找到窗口"
            return False
     
        self.msg = "找到" + "%i"%v + "个窗口"
        self.parent = name
        return True
Beispiel #10
0
def wait_for_finish(dlg, obj, max_count, prefix=False):
  count = 0
  while count < max_count:
    if obj is not None and guivisible(dlg, obj, prefix):
      break
    elif obj is None and not ldtp.guiexist(dlg):
      break
    ldtp.wait(1)
    count += 1
  assert count < max_count, max_count
Beispiel #11
0
 def setUp(self):
     """Display an ERROR if the pane is not closed.
        It is closed in setUpClass() but cannot be checked there because
        unittest asserts must be called with a MenuTest2 instance.
        In practice, this assert should not fail.
        It adds to the run time and may be commented out.
     """
     # check linux only since it runs much faster than windows
     if not os.name == "nt":
         pane_exists = ldtp.guiexist('frmAStyleWx', 'panecontrol')
         self.assertFalse(pane_exists, 'The panecontrol should not exist')
Beispiel #12
0
 def setUp(self):
     """Display an ERROR if the pane is not closed.
        It is closed in setUpClass() but cannot be checked there because
        unittest asserts must be called with a MenuTest2 instance.
        In practice, this assert should not fail.
        It adds to the run time and may be commented out.
     """
     # check linux only since it runs much faster than windows
     if not os.name == "nt":
         pane_exists = ldtp.guiexist('frmAStyleWx', 'panecontrol')
         self.assertFalse(pane_exists, 'The panecontrol should not exist')
Beispiel #13
0
    def notification_preview(self, theme, position):
        """
        This method invokes notification dialog according to preferred theme
        and position
        @theme: Standard theme
        @position: Top Left, Top Right, Bottom Left, Bottom Right
        """
        notif = ooldtp.context(self.WINDOW)
        mnu_theme = ldtp.getchild(self.WINDOW, theme, 'menu item')
        mnu_position = ldtp.getchild(self.WINDOW, position, 'menu item')

        notif.getchild(self.CBO_THEME).comboselect(mnu_theme)
        notif.getchild(self.CBO_POSITION).comboselect(mnu_position)
        if notif.getchild(self.CBO_THEME).verifyselect(theme) == 0:
            raise ldtp.LdtpExecutionError, "Failed to select " + theme + " on Theme combobox."
        if notif.getchild(self.CBO_POSITION).verifyselect(position) == 0:
            raise ldtp.LdtpExecutionError, "Failed to select " + position + " on Position combobox."

        shown = False
        timer = 1
        ldtp.wait(1)
        while (not shown) and (timer < 3):
            notif.getchild(self.BTN_PREVIEW).click()
            ldtp.wait(1)
            if ldtp.guiexist(self.DLG_NOTIFICATION):
                shown = True
            else:
                ldtp.wait(8)
                if ldtp.guiexist(self.DLG_ERROR):
                    error = ooldtp.context(self.DLG_ERROR)
                    error.getchild(self.BTN_CLOSE).click()
                    if ldtp.guiexist(self.DLG_ERROR) == 0:
                        ldtp.wait(1)
                        timer = timer + 1
                    else:
                        raise ldtp.LdtpExecutionError, "Error dialog can't be dismissed, there is something wrong with the application."
                else:
                    raise ldtp.LdtpExecutionError, "Something wrong with the application, error dialog didn't popup, please check it manually."

        if (not shown) and timer >= 3:
            raise ldtp.LdtpExecutionError, "Notification dialog can't be popup, function fails."
Beispiel #14
0
        def testPmHelp(self):
                ldtp.launchapp(self.pm_str,["-R", self.get_img_path()])
                ldtp.waittillguiexist('Package Manager', state = ldtp.state.ENABLED)

                ldtp.selectmenuitem('Package Manager', 'mnuHelp;mnuContents')

                # Verify result
                ldtp.waittillguiexist('*Online Help')
                self.assertEqual(ldtp.guiexist('*Online Help'), 1)

                ldtp.selectmenuitem('*Online Help', 'mnuCloseWindow')

                ldtp.selectmenuitem('Package Manager', 'mnuHelp;mnuAbout')

                # Verify result
                self.assertEqual(ldtp.guiexist('About Package Manager'), 1)

                ldtp.waittillguiexist('dlgAboutPackageManager')
                ldtp.click('dlgAboutPackageManager', 'btnClose')

                # Quit Package Manager
                ldtp.selectmenuitem('Package Manager', 'mnuFile;mnuQuit')
Beispiel #15
0
def wait_for_database_open():
	# Wait for the list view to pop up in the main Glom window:
	# Note that the Window title of the Glom Window changes when the file
	# has loaded. If we use wildcards for the Window title (*Glom*) here,
	# then objectexist does not find the notebook_data
	# (ptlListOrDetailsView) widget, even when it has actually appeared.
	# TODO: Maybe we can use setcontext(), to avoid this.
	# TODO: Or maybe this has been fixed in LDTP in the meanwhile,
	# see bug #583021.
	while not ldtp.guiexist('Glom-Test') or not ldtp.objectexist('Glom-Test', 'ptlListOrDetailsView'):
		# onwindowcreate calls the callback in a new thread, which
		# does not really help us since we don't have a mainloop the
		# callback thread could notify, so we would need to have to
		# poll an event anyway. Instead, we can simply poll directly
		# the existance of an error dialog.
		# Plus, there seems to be a bug in LDTP when running a test
		# sequence of multiple tests using onwindowcreate:
		# http://bugzilla.gnome.org/show_bug.cgi?id=586291.
		if ldtp.guiexist('Warning') or ldtp.guiexist('Error'):
			# TODO: Read error message from error dialog
			raise ldtp.LdtpExecutionError('Failed to create new database')

		# Wait a bit and then try again:
		ldtp.wait()
    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)
Beispiel #17
0
    def baobab_scan_folder(self, path):
        baobab = ooldtp.context(self.name)

        baobab.getchild(self.BTN_SCANFOLDER).click()

        ldtp.waittillguiexist(self.DLG_SELECTFOLDER)

        if (ldtp.guiexist(self.DLG_SELECTFOLDER)):
            selectFiles = ooldtp.context(self.DLG_SELECTFOLDER)
            if not (selectFiles.getchild(self.TXT_LOCATION)):
                ldtp.generatekeyevent('<ctrl>l')
            textLocation = selectFiles.getchild(self.TXT_LOCATION)
            textLocation.settextvalue(path)
            ldtp.generatekeyevent('<return>')
        ldtp.wait(2)

        buttonStop = baobab.getchild(self.BTN_STOP)

        while buttonStop.stateenabled():
            ldtp.wait()

        self.baobab_change_views()
Beispiel #18
0
    def baobab_scan_folder(self, path):
        baobab = ooldtp.context(self.name)
        
        baobab.getchild(self.BTN_SCANFOLDER).click()

        ldtp.waittillguiexist(self.DLG_SELECTFOLDER)
        
        if (ldtp.guiexist(self.DLG_SELECTFOLDER)):
            selectFiles = ooldtp.context(self.DLG_SELECTFOLDER)
            if not (selectFiles.getchild(self.TXT_LOCATION)):
                ldtp.generatekeyevent('<ctrl>l')
            textLocation = selectFiles.getchild(self.TXT_LOCATION)
            textLocation.settextvalue(path)
            ldtp.generatekeyevent('<return>')
        ldtp.wait(2)
                
        buttonStop = baobab.getchild(self.BTN_STOP)
        
        while buttonStop.stateenabled():
            ldtp.wait()
        
        self.baobab_change_views()
Beispiel #19
0
    def gui_exist(self, window_name, object_name=''):
        """
        [关键字概要] 检查窗口或者组件对象是否存在

        :@参数 window_name: 窗口名称

        :@参数 object_name: 对象名称

        :@返回值: 存在返回 1,不存在返回 0

        Examples:

        |  *Test Cases*  |        *Action*       |    *Argument*   |    *Argument*   |
        |  Example_Test  |       GUI Exist       |  ${window_name} |                 |
        |                |       GUI Exist       |  ${window_name} |  ${object_name} |

        """
        try:
            self._info("gui exist (%s, %s)" % (window_name, object_name))
            return ldtp.guiexist(window_name, object_name)
        except LdtpExecutionError:
            raise LdtpExecutionError(
                "gui exist failed, please check if the input parameters are correct. "
            )
Beispiel #20
0
 def is_opened(self):
     """
     Returns 1, if the application is opened. 0, otherwise
     """
     return ldtp.guiexist(self.name)
Beispiel #21
0
def quit():
  if ldtp.guiexist('frmBackup'):
    ldtp.closewindow('frmBackup')
  if ldtp.guiexist('frmBackUp'):
    ldtp.closewindow('frmBackUp')
Beispiel #22
0
 def check_element_exist(self, window, type, name):
     logger.info("check_element_exist")
     logger.info(ldtp.getobjectlist(RHSMGuiLocator().get_locator(window)))
     return ldtp.guiexist(RHSMGuiLocator().get_locator(window), type + name)
Beispiel #23
0
 def check_window_open(self, window):
     self.check_window_exist(window)
     return ldtp.guiexist(RHSMGuiLocator().get_locator(window))
Beispiel #24
0
 def is_opened(self):
     """
     Returns 1, if the application is opened. 0, otherwise
     """
     return ldtp.guiexist(self.name)
Beispiel #25
0
 def check_object_exist(self, window, object_name):
     logger.info("check_object_exist")
     return ldtp.guiexist(RHSMGuiLocator().get_locator(window), RHSMGuiLocator().get_locator(object_name))
Beispiel #26
0
    def test_insert_clientfromUI(self):
        """docstring for test_insert_clientfromUI"""
        ldtp.click(self.mv_name, self.new_c_button_name)
        ldtp.guiexist("frmNewclient1")
        ldtp.click("frmNewclient1", "btnCancel")
        ldtp.click(self.mv_name, self.new_c_button_name)
        ldtp.guiexist("frmNewclient2")
        new_c_name = "frmNewclient2"
        dni = "12345678R"
        ldtp.settextvalue("frmNewclient2", "txt4", "Alice")
        ldtp.settextvalue("frmNewclient2", "txt3", "Pound")
        ldtp.click("frmNewclient2", "btnOK")
        ldtp.settextvalue("frmNewclient2", "txt2", dni)
        ldtp.click("frmNewclient2", "btnOK")
        ldtp.singleclickrow(self.mv_name, self.tree_name_mv, "Alice")

        #Alice client changing
        ldtp.doubleclickrow(self.mv_name, self.tree_name_mv, "Alice")
        alice_title = "*DNI:12345678R"
        ldtp.guiexist(alice_title)
        ldtp.click(alice_title, "btnCancel")
        ldtp.doubleclickrow(self.mv_name, self.tree_name_mv, "Alice")
        #alice_title += "1"
        ldtp.guiexist(alice_title)
        ldtp.click(alice_title, "btnOK")

        ldtp.doubleclickrow(self.mv_name, self.tree_name_mv, "Alice")
        ldtp.guiexist(alice_title)
        ldtp.settextvalue(alice_title, "txt3", "Poundssss")
        ldtp.click(alice_title, "btnCancel")
        ldtp.doubleclickrow(self.mv_name, self.tree_name_mv, "Alice")
        ldtp.guiexist(alice_title)
        ldtp.settextvalue(alice_title, "txt3", "Poundssss")
        ldtp.settextvalue(alice_title, "txt2", "678R")
        ldtp.click(alice_title, "btnOK")



        #delete Alice from UI
        ldtp.selectrow(self.mv_name, self.tree_name_mv, "Alice")
        delete_dlg = "dlgDeleteclient"
        ldtp.click(self.mv_name, self.delete_c_button_name)
        ldtp.guiexist(delete_dlg)
        ldtp.click(delete_dlg, "btnNo")

        ldtp.click(self.mv_name, self.delete_c_button_name)
        ldtp.singleclickrow(self.mv_name, self.tree_name_mv, "Alice")
        ldtp.guiexist(delete_dlg)
        ldtp.click(delete_dlg, "btnYes")
Beispiel #27
0
 def exist(self, control):
     if control.parent: self.renew(control.parent)
     return ldtp.guiexist(*_ldtp_args(control))
Beispiel #28
0
 def exist(self, control):
     if control.parent: self.renew(control.parent)
     return ldtp.guiexist(*_ldtp_args(control))