def requestSetAccessible(self, path, text=None, value=None): ''' Sends a request setting the given text or value in an accessible object of the specified path. :param path: A path to the accessible object :type path: tadek.core.accessible.Path :param text: New text for the accessible object :type text: string :param value: A new value for the accessible object :type value: float :return: Id of the sent request :rtype: integer ''' if text is None and value is None: raise ValueError("Text or value must be specified") params = { "path": path } if text is not None: params["text"] = escape(text, self) else: params["value"] = value return self.request(protocol.MSG_TARGET_ACCESSIBILITY, protocol.MSG_NAME_PUT, params)
def run(self, test, device, **args): ''' Runs the corresponding test step function with the given arguments. ''' for name, value in args.iteritems(): args[name] = escape(value, device) return self.func(test, device, **args)
def run(self, test, device): ''' Runs the corresponding test step function with provided arguments. ''' args = {} for name, value in self.args.iteritems(): args[name] = escape(value, device) test["result"] = self.func(test, device, **args)
def hasText(self, device, text, expectedFailure=False): ''' Checks if the represented widget contains the specified text. :param device: A device to perform the operation on :type device: tadek.connection.device.Device :param text: Text to find in the widget :type text: string :param expectedFailure: It specifies if the widget is not expected to contain the text :type expectedFailure: boolean :return: True if the widget contains the text, False otherwise :rtype: boolean ''' widget = self.getWidget(device) if widget is None: return False # Finalize translation and decode string text = decode(escape(text, device)) return delay.text(self._WidgetText(widget, text), expectedFailure)
def requestSetAccessible(self, path, text=None, value=None): ''' Sends a request setting the given text or value in an accessible object of the specified path. :param path: A path to the accessible object :type path: tadek.core.accessible.Path :param text: New text for the accessible object :type text: string :param value: A new value for the accessible object :type value: float :return: Id of the sent request :rtype: integer ''' if text is None and value is None: raise ValueError("Text or value must be specified") params = {"path": path} if text is not None: params["text"] = escape(text, self) else: params["value"] = value return self.request(protocol.MSG_TARGET_ACCESSIBILITY, protocol.MSG_NAME_PUT, params)
def testStrEscape(self): device = _Device() self.failUnlessEqual(locale.escape(_MSG2_ID, device), _MSG2_ID)
def testMsg1LazyEscape(self): self._addLocaleDir("locale1") device = _Device() msg = locale.gettext__(_MSG1_ID) self.failUnless(isinstance(msg, locale.LazyTranslation)) self.failUnlessEqual(locale.escape(msg, device), _TRANS1)
def requestSearchAccessible(self, path, method, name=None, description=None, role=None, index=None, count=None, action=None, relation=None, state=None, text=None, nth=0, **attrs): ''' Sends a request for searching an accessible object starting from the given path and using the specified search method. :param path: A starting path for the searching of accessible object :type path: tadek.core.accessible.Path :param method: A search method of accessible :type method: string :param name: A name of searched accessible or None :type name: string or NoneType :param description: A description of searched accessible or None :type description: string or NoneType :param role: A role of searched accessible or None :type role: string or NoneType :param index: An index of searched accessible or None :type index: integer or NoneType :param count: A child count of searched accessible or None :type count: string or NoneType :param action: An action of searched accessible or None :type action: string or NoneType :param relation: A relation of searched accessible or None :type relation: string or NoneType :param state: A state of searched accessible or None :type state: string or NoneType :param text: Text of searched accessible or None :type text: string or NoneType :param nth: A nth matched accessible :type nth: integer :param attrs: Attributes of searched accessible :type attrs: dictionary :return: Id of the sent request :rtype: integer ''' predicates = {"nth": nth} if name is not None: predicates["name"] = escape(name, self) if description is not None: predicates["description"] = escape(description, self) if role is not None: predicates["role"] = role if index is not None: predicates["index"] = index if count is not None: predicates["count"] = count if action is not None: predicates["action"] = action if relation is not None: predicates["relation"] = relation if state is not None: predicates["state"] = state if text is not None: predicates["text"] = escape(text, self) predicates.update(attrs) for attr, value in attrs.iteritems(): predicates[attr] = escape(value, self) params = {"path": path, "method": method, "predicates": predicates} return self.request(protocol.MSG_TARGET_ACCESSIBILITY, protocol.MSG_NAME_SEARCH, params)
def requestSearchAccessible(self, path, method, name=None, description=None, role=None, index=None, count=None, action=None, relation=None, state=None, text=None, nth=0, **attrs): ''' Sends a request for searching an accessible object starting from the given path and using the specified search method. :param path: A starting path for the searching of accessible object :type path: tadek.core.accessible.Path :param method: A search method of accessible :type method: string :param name: A name of searched accessible or None :type name: string or NoneType :param description: A description of searched accessible or None :type description: string or NoneType :param role: A role of searched accessible or None :type role: string or NoneType :param index: An index of searched accessible or None :type index: integer or NoneType :param count: A child count of searched accessible or None :type count: string or NoneType :param action: An action of searched accessible or None :type action: string or NoneType :param relation: A relation of searched accessible or None :type relation: string or NoneType :param state: A state of searched accessible or None :type state: string or NoneType :param text: Text of searched accessible or None :type text: string or NoneType :param nth: A nth matched accessible :type nth: integer :param attrs: Attributes of searched accessible :type attrs: dictionary :return: Id of the sent request :rtype: integer ''' predicates = { "nth": nth } if name is not None: predicates["name"] = escape(name, self) if description is not None: predicates["description"] = escape(description, self) if role is not None: predicates["role"] = role if index is not None: predicates["index"] = index if count is not None: predicates["count"] = count if action is not None: predicates["action"] = action if relation is not None: predicates["relation"] = relation if state is not None: predicates["state"] = state if text is not None: predicates["text"] = escape(text, self) predicates.update(attrs) for attr, value in attrs.iteritems(): predicates[attr] = escape(value, self) params = { "path": path, "method": method, "predicates": predicates } return self.request(protocol.MSG_TARGET_ACCESSIBILITY, protocol.MSG_NAME_SEARCH, params)