diff options
| author | Marco Trevisan (Treviño) <mail@3v1n0.net> | 2015-08-18 13:11:32 +0200 |
|---|---|---|
| committer | Marco Trevisan (Treviño) <mail@3v1n0.net> | 2015-08-18 13:11:32 +0200 |
| commit | 76023b102ffb77a8a4bb721bb6024216803205ac (patch) | |
| tree | ab1c96ab17e590d97e3cec2d6fd077809ee9ba67 /tests | |
| parent | ba443af93b112b379d0d95e85b88305c12374d72 (diff) | |
UnityIntrospectionObject: make customization of repr easier
(bzr r3987.1.3)
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/autopilot/unity/emulators/__init__.py | 16 | ||||
| -rw-r--r-- | tests/autopilot/unity/emulators/icons.py | 5 | ||||
| -rw-r--r-- | tests/autopilot/unity/emulators/panel.py | 8 |
3 files changed, 23 insertions, 6 deletions
diff --git a/tests/autopilot/unity/emulators/__init__.py b/tests/autopilot/unity/emulators/__init__.py index 9f32530d2..305c31592 100644 --- a/tests/autopilot/unity/emulators/__init__.py +++ b/tests/autopilot/unity/emulators/__init__.py @@ -28,9 +28,23 @@ class UnityIntrospectionObject(CustomEmulatorBase): _Backend = DBusAddress.SessionBus(DBUS_SERVICE, DBUS_OBJECT) + def _repr_string(self, obj_details=""): + geostr = "" + if hasattr(self, 'globalRect'): + geostr = " geo=[{r.x}x{r.y} {r.width}x{r.height}]".format(r=self.globalRect) + + obj_details.strip() + obj_details = " "+obj_details if len(obj_details) else obj_details + + return "<{cls} {addr} id={id}{geo}{details}>".format(cls=self.__class__.__name__, + addr=hex(id(self)), + id=self.id, + geo=geostr, + details=obj_details) + def __repr__(self): with self.no_automatic_refreshing(): - return "<%s id=%d>" % (self.__class__.__name__, self.id) + return self._repr_string() def __eq__(self, other): return isinstance(other, self.__class__) and self.id == other.id diff --git a/tests/autopilot/unity/emulators/icons.py b/tests/autopilot/unity/emulators/icons.py index 8a93a0fd5..396a13230 100644 --- a/tests/autopilot/unity/emulators/icons.py +++ b/tests/autopilot/unity/emulators/icons.py @@ -76,10 +76,7 @@ class ApplicationLauncherIcon(SimpleLauncherIcon): def __repr__(self): with self.no_automatic_refreshing(): - return "<%s %s id=%d>" % ( - self.__class__.__name__, - self.desktop_id, - self.id) + return self._repr_string("{0.desktop_id}".format(self)) class TrashLauncherIcon(SimpleLauncherIcon): """Represents the trash launcher icon.""" diff --git a/tests/autopilot/unity/emulators/panel.py b/tests/autopilot/unity/emulators/panel.py index 5c196f6ca..28f80d710 100644 --- a/tests/autopilot/unity/emulators/panel.py +++ b/tests/autopilot/unity/emulators/panel.py @@ -283,6 +283,11 @@ class WindowButton(UnityIntrospectionObject): """Returns a tuple of (x,y,w,h) for the window button.""" return (self.x, self.y, self.width, self.height) + def __repr__(self): + with self.no_automatic_refreshing(): + details = "type={0.type} state={0.visual_state} sensitive={0.sensitive}".format(self) + return self._repr_string(details) + class GrabArea(UnityIntrospectionObject): """The grab area class""" @@ -349,7 +354,8 @@ class IndicatorEntry(UnityIntrospectionObject): def __repr__(self): with self.no_automatic_refreshing(): - return "<IndicatorEntry 0x%x (%s)>" % (id(self), self.label) + details = "label={0.label}".format(self) + return self._repr_string(details) class Tray(UnityIntrospectionObject): |
