20 """unity shell autopilot tests and emulators - sub level package."""
22 from time
import sleep
23 from functools
import wraps
24 from gi.repository
import Notify
28 logger = logging.getLogger(__name__)
31 def disable_qml_mocking(fn):
32 """Simple decorator that disables the QML mocks from being loaded."""
34 def wrapper(*args, **kwargs):
36 tests_self._qml_mock_enabled =
False
37 return fn(*args, **kwargs)
41 class DragMixin(object):
42 def _drag(self, x1, y1, x2, y2):
48 dx = 1.0 * (x2 - x1) / 100
49 dy = 1.0 * (y2 - y1) / 100
50 for i
in range(0, 100):
52 self.touch._finger_move(int(cur_x), int(cur_y))
53 except AttributeError:
54 self.touch._device.finger_move(int(cur_x), int(cur_y))
59 self.touch._finger_move(int(x2), int(y2))
60 except AttributeError:
61 self.touch._device.finger_move(int(x2), int(y2))
64 def create_ephemeral_notification(
71 """Create an ephemeral (non-interactive) notification
73 :param summary: Summary text for the notification
74 :param body: Body text to display in the notification
75 :param icon: Path string to the icon to use
76 :param hint_strings: List of tuples containing the 'name' and value
77 for setting the hint strings for the notification
78 :param urgency: Urgency string for the noticiation, either: 'LOW',
84 "Creating ephemeral: summary(%s), body(%s), urgency(%r) "
92 notification = Notify.Notification.new(summary, body, icon)
96 notification.set_hint_string(key, value)
97 logger.info(
"Adding hint to notification: (%s, %s)", key, value)
98 notification.set_urgency(_get_urgency(urgency))
103 def _get_urgency(urgency):
104 """Translates urgency string to enum."""
105 _urgency_enums = {
'LOW': Notify.Urgency.LOW,
106 'NORMAL': Notify.Urgency.NORMAL,
107 'CRITICAL': Notify.Urgency.CRITICAL}
108 return _urgency_enums.get(urgency.upper())