~sergiusens/ubuntu-terminal-app/icon

« back to all changes in this revision

Viewing changes to tests/autopilot/ubuntu_terminal_app/emulators/main_window.py

Add more autopilot tests:
- test for font size
- test for color schemes
- test for Header shows/hides .

Approved by Ubuntu Phone Apps Jenkins Bot.

Show diffs side-by-side

added added

removed removed

Lines of Context:
14
14
        self.app = app
15
15
        self.autopilot = autopilot
16
16
 
17
 
    def click_popup_item(self, popupLable):
 
17
    def get_qml_view(self):
 
18
        """Get the main QML view"""
 
19
        return self.app.select_single("QQuickView")
 
20
 
 
21
    def get_header_item(self):
 
22
        """Get the header"""
 
23
        return  self.app.select_single("Header")
 
24
 
 
25
    def get_slider_item(self, slider):
 
26
        """Get the header"""
 
27
        return  self.app.select_single("Slider", objectName=slider)
 
28
 
 
29
    def expand_width(self, val):
 
30
        """Expand width of the main QML view"""
 
31
        qmlView = self.get_qml_view()
 
32
        startX = int(qmlView.x + qmlView.width)
 
33
        stopX = int(qmlView.x + qmlView.width + val)
 
34
        lineY = int(qmlView.height/2)
 
35
        self.autopilot.pointing_device.drag(startX, lineY, stopX, lineY)
 
36
 
 
37
    def expand_height(self, val):
 
38
        """Expand height of the main QML view"""
 
39
        qmlView = self.get_qml_view()
 
40
        startY = int(qmlView.y + qmlView.height)
 
41
        stopY = int(qmlView.y + qmlView.height + val)
 
42
        lineX = int(qmlView.width/2)
 
43
        self.autopilot.pointing_device.drag(lineX, startY, lineX, stopY)
 
44
 
 
45
    def click_action_selection_popup_item(self, popupLable):
18
46
        """Clicks the toolbar popup item with popupLable"""
 
47
        # The action selection is assumed to be the following format
 
48
        # ActionSelectionPopover {
 
49
        #    actions: ActionList {
 
50
        #        Action {
 
51
        #              text: 
19
52
        li  = self.app.select_single("ActionSelectionPopover")
20
53
        row = li.select_single("QQuickColumn")
21
54
        loaderList = row.select_many("QQuickLoader")
25
58
                if label.text == popupLable:
26
59
                    self.autopilot.pointing_device.click_object(label)
27
60
 
 
61
    def click_value_selector_item(self, selector, value):
 
62
        """Clicks value from value selector"""
 
63
        # The value selector is assumed to be the following format
 
64
        # ListItem.ValueSelector {
 
65
        #    objectName: 
 
66
        #    values:
 
67
        val_selector = self.app.select_single("ValueSelector", objectName=selector)
 
68
        self.autopilot.pointing_device.click_object(val_selector)
 
69
        rows = val_selector.select_single("QQuickColumn")
 
70
        rects = rows.select_many("QQuickRectangle")
 
71
        for ritem in rects:
 
72
            labelList = ritem.select_many("LabelVisual")
 
73
            for label in labelList:
 
74
                if label.text == value:
 
75
                    self.autopilot.pointing_device.click_object(label)
 
76
 
 
77
    def tap_horizontal_slider(self, slider, pos):
 
78
        """Tap slider at position"""
 
79
        slItem = self.get_slider_item(slider)
 
80
        x, y, w, h = slItem.globalRect
 
81
 
 
82
        # pos to click inside the slider, px  
 
83
        self.autopilot.pointing_device.move(x+pos, y+(h/2))
 
84
        self.autopilot.pointing_device.click()
 
85
 
 
86
    def drag_horizontal_slider(self, slider, pos):
 
87
        """Drag slider by delta value"""
 
88
        # The slider is assumed to be the following format
 
89
        # Slider {
 
90
        #    objectName: 
 
91
        #    minimumValue: 
 
92
        #    maximumValue:
 
93
        slItem = self.get_slider_item(slider)
 
94
        slRect = slItem.select_single("SliderStyle")
 
95
 
 
96
        # calculate required shift per position
 
97
        thumbSpace = slRect.thumbSpace
 
98
        minVal = slItem.minimumValue
 
99
        maxVal = slItem.maximumValue
 
100
        shift  = thumbSpace/(maxVal-minVal)
 
101
 
 
102
        # get thumb to drag
 
103
        ushapes = slItem.select_many("UbuntuShape")
 
104
        slThumb = ushapes[0]
 
105
        for ushape in ushapes:
 
106
            if ushape.width == slRect.thumbWidth:
 
107
                slThumb = ushape
 
108
 
 
109
        x, y, w, h = slThumb.globalRect
 
110
        sx = x+w/2
 
111
        sy = y+h/2 
 
112
        self.autopilot.pointing_device.drag(sx, sy, sx+(shift*pos), sy)
 
113
 
 
114