15
15
self.autopilot = autopilot
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")
21
def get_header_item(self):
23
return self.app.select_single("Header")
25
def get_slider_item(self, slider):
27
return self.app.select_single("Slider", objectName=slider)
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)
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)
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 {
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)
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 {
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")
72
labelList = ritem.select_many("LabelVisual")
73
for label in labelList:
74
if label.text == value:
75
self.autopilot.pointing_device.click_object(label)
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
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()
86
def drag_horizontal_slider(self, slider, pos):
87
"""Drag slider by delta value"""
88
# The slider is assumed to be the following format
93
slItem = self.get_slider_item(slider)
94
slRect = slItem.select_single("SliderStyle")
96
# calculate required shift per position
97
thumbSpace = slRect.thumbSpace
98
minVal = slItem.minimumValue
99
maxVal = slItem.maximumValue
100
shift = thumbSpace/(maxVal-minVal)
103
ushapes = slItem.select_many("UbuntuShape")
105
for ushape in ushapes:
106
if ushape.width == slRect.thumbWidth:
109
x, y, w, h = slThumb.globalRect
112
self.autopilot.pointing_device.drag(sx, sy, sx+(shift*pos), sy)