27
27
class ActionBar(_common.UbuntuUIToolkitCustomProxyObjectBase):
28
28
"""ActionBar Autopilot custom proxy object."""
30
def _get_action_button(self, action_object_name):
32
object_name = action_object_name + "_action_button"
33
button = self.select_single(objectName=object_name)
34
except dbus.StateNotFoundError:
35
# the button is not in the ActionBar, but it may be in the overflow
37
button = self._get_action_button_in_overflow(
39
except dbus.StateNotFoundError:
40
raise _common.ToolkitException(
41
'Button not found in ActionBar or overflow')
45
def _get_action_button_in_overflow(self, action_object_name):
30
def _open_overflow(self):
31
"""Click the overflow button and return the overflow panel"""
46
32
actions_overflow_button = self.select_single(
47
objectName='actions_overflow_button')
33
objectName='overflow_action_button')
49
35
if not actions_overflow_button.visible:
50
36
raise _common.ToolkitException('No actions in overflow')
53
39
self.pointing_device.click_object(actions_overflow_button)
54
object_name = action_object_name + "_header_overflow_button"
56
41
# the popover is not a child of the ActionBar, so use the popover
57
42
# object to find the requested button
62
47
raise _common.ToolkitException(
63
48
'Failed to select overflow panel')
65
return popover.select_single(objectName=object_name)
67
52
@autopilot_logging.log_action(logger.info)
68
53
def click_action_button(self, action_object_name):
76
button = self._get_action_button(action_object_name)
77
self.pointing_device.click_object(button)
63
object_name = action_object_name + "_action_button"
64
button = self.select_single(objectName=object_name)
65
self.pointing_device.click_object(button)
66
except dbus.StateNotFoundError:
67
# the button is not in the ActionBar, but it may be in the overflow
69
popover = self._open_overflow()
70
popover.click_action_button(action_object_name)
71
except dbus.StateNotFoundError:
72
raise _common.ToolkitException(
73
'Button not found in ActionBar or overflow')