def assertMethod(name, checkShowing=True, retry=False, recursive=True, breadthFirst=False, raiseException=False): def descendantFound(): dontCheckShowing = not checkShowing return utils.findDescendant(self, lambda x: x.role == v[a] and utils.equalsOrMatches(x.name, name) and (dontCheckShowing or x.showing), \ retry=retry, recursive=recursive, breadthFirst=breadthFirst, raiseException=raiseException) != None assert utils.retryUntilTrue(descendantFound)
def assertSelected(self, log=True): 'Raise an exception if this tab is not selected' if log: procedurelogger.expectedResult('%s is selected.' % self) def selected(): return self.selected assert utils.retryUntilTrue(selected)
def doActionMethod(log=False): def sensitive(): return self.sensitive if not utils.retryUntilTrue(sensitive): raise errors.NotSensitiveError if log: procedurelogger.action('Perform "%s" action for %s.' % (iaction.getName(i), self)) iaction.doAction(i)
def assertClosed(self): 'Raise an exception if the application is still open' procedurelogger.expectedResult('The application closes.') if self.subproc is not None: def closed(): return self.subproc.poll() == 0 assert utils.retryUntilTrue(closed)
def assertSelected(self, log=True): 'Raise an exception if this tab is not selected' if log: procedurelogger.expectedResult('The %s is selected.' % self) def selected(): return self.selected assert utils.retryUntilTrue(selected)
def assertTextAttribute(self, attr, value, charPos): 'Assert attr:value string on text at position charPos (i.e. attr="fg-color", value="0,0,0")' itext = self._accessible.queryText() def checkAttribute(): if attr in self.getTextAttributes(charPos): if self.getTextAttributes(charPos)[attr] == value: return True return False assert utils.retryUntilTrue(checkAttribute)
def assertClosed(self): 'Raise an exception if the alert is still open' procedurelogger.expectedResult('The %s disappears.' % self) def closed(): try: return not self.showing except (LookupError, KeyError, pyatspi.ORBit.CORBA.COMM_FAILURE): return True assert utils.retryUntilTrue(closed)
def _doAction(self, action): 'Wrapper for doAction method in IAction interface' iaction = self._accessible.queryAction() for i in xrange(iaction.nActions): if iaction.getName(i) == action: def sensitive(): return self.sensitive if not utils.retryUntilTrue(sensitive): raise errors.NotSensitiveError iaction.doAction(i)
def waitForEvent(self, target=None, type=None, qty=None): ''' Waits until the event occurs and returns True. If the event does not occur within config.RETRY_TIMES * config.RETRY_INTERVAL seconds, returns False. @param target: the requested event target, or None @param type: the type of event to listen to, or None @param qty: how many events should be fired @return: returns True if the event occured, False otherwise @rtype: boolean ''' return utils.retryUntilTrue(self.containsEvent, \ args=(self._unwrapAccessible(target), type, qty))
def _doAction(self, action): ''' Wrapper for doAction method in IAction interface All actions are now bound automagically; this method is deprecated and may be removed in the future. ''' iaction = self._accessible.queryAction() for i in xrange(iaction.nActions): if iaction.getName(i) == action: def sensitive(): return self.sensitive if not utils.retryUntilTrue(sensitive): raise errors.NotSensitiveError iaction.doAction(i)
def assertTableCellAt(self, row, col, text): assert utils.retryUntilTrue( lambda: self.getAccessibleAt(row, col).name == text)
def assertSelectedText(self, text, index=0): assert utils.retryUntilTrue( lambda: self.getSelectedText(index) == text)
def assertTableCellAt(self, row, col, text): assert utils.retryUntilTrue(lambda : self.getAccessibleAt(row, col).name == text)
def assertSelectedText(self, text, index=0): assert utils.retryUntilTrue(lambda: self.getSelectedText(index) == text)