~lool/unity8/add-reverts-in-unity8-changelog

« back to all changes in this revision

Viewing changes to tests/autopilot/unity8/shell/emulators/hud.py

Add behaviours to the hud reveal. Fixes: https://bugs.launchpad.net/bugs/1224480, https://bugs.launchpad.net/bugs/1224633.

Approved by PS Jenkins bot, Michael Zanetti.

Show diffs side-by-side

added added

removed removed

Lines of Context:
21
21
 
22
22
from unity8 import get_grid_size
23
23
from unity8.shell.emulators import UnityEmulatorBase
 
24
from unity8.shell import DragMixin
24
25
from autopilot.input import Touch
25
26
 
26
 
 
27
27
SwipeCoords = namedtuple('SwipeCoords', 'start_x end_x start_y end_y')
28
28
 
29
 
 
30
 
class Hud(UnityEmulatorBase):
 
29
class Hud(UnityEmulatorBase, DragMixin):
31
30
 
32
31
    """An emulator that understands the Hud."""
33
32
 
34
33
    def show(self):
35
34
        """Swipes open the Hud."""
36
 
        touch = Touch.create()
 
35
        self.touch = Touch.create()
37
36
 
38
37
        window = self.get_root_instance().select_single('QQuickView')
39
38
        hud_show_button = window.select_single("HudButton")
40
39
 
41
40
        swipe_coords = self.get_button_swipe_coords(window, hud_show_button)
42
41
 
43
 
        touch.press(swipe_coords.start_x, swipe_coords.start_y)
44
 
        touch._finger_move(swipe_coords.end_x, swipe_coords.end_y)
 
42
        self.touch.press(swipe_coords.start_x, swipe_coords.start_y)
 
43
        self._drag(swipe_coords.start_x, swipe_coords.start_y, swipe_coords.start_x, swipe_coords.end_y)
45
44
        try:
46
45
            hud_show_button.opacity.wait_for(1.0)
47
 
            touch.release()
 
46
            self.touch.release()
48
47
            self.shown.wait_for(True)
49
48
        except AssertionError:
50
49
            raise
51
50
        finally:
52
 
            if touch._touch_finger is not None:
53
 
                touch.release()
 
51
            if self.touch._touch_finger is not None:
 
52
                self.touch.release()
54
53
 
55
54
    def dismiss(self):
56
55
        """Closes the open Hud."""