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__)
30 def disable_qml_mocking(fn):
31 """Simple decorator that disables the QML mocks from being loaded."""
33 def wrapper(*args, **kwargs):
35 tests_self._qml_mock_enabled =
False
36 return fn(*args, **kwargs)
40 class DragMixin(object):
41 def _drag(self, x1, y1, x2, y2):
47 dx = 1.0 * (x2 - x1) / 100
48 dy = 1.0 * (y2 - y1) / 100
49 for i
in range(0, 100):
51 self.touch._finger_move(int(cur_x), int(cur_y))
52 except AttributeError:
53 self.touch._device.finger_move(int(cur_x), int(cur_y))
58 self.touch._finger_move(int(x2), int(y2))
59 except AttributeError:
60 self.touch._device.finger_move(int(x2), int(y2))
63 def create_ephemeral_notification(
70 """Create an ephemeral (non-interactive) notification
72 :param summary: Summary text for the notification
73 :param body: Body text to display in the notification
74 :param icon: Path string to the icon to use
75 :param hint_strings: List of tuples containing the 'name' and value
76 for setting the hint strings for the notification
77 :param urgency: Urgency string for the noticiation, either: 'LOW',
83 "Creating ephemeral: summary(%s), body(%s), urgency(%r) "
91 notification = Notify.Notification.new(summary, body, icon)
95 notification.set_hint_string(key, value)
96 logger.info(
"Adding hint to notification: (%s, %s)", key, value)
97 notification.set_urgency(_get_urgency(urgency))
102 def _get_urgency(urgency):
103 """Translates urgency string to enum."""
104 _urgency_enums = {
'LOW': Notify.Urgency.LOW,
105 'NORMAL': Notify.Urgency.NORMAL,
106 'CRITICAL': Notify.Urgency.CRITICAL}
107 return _urgency_enums.get(urgency.upper())