~zsombi/ubuntu-ui-toolkit/listitemSelectModeBugs

« back to all changes in this revision

Viewing changes to tests/autopilot/ubuntuuitoolkit/_custom_proxy_objects/_actionbar.py

  • Committer: Zsombor Egri
  • Date: 2015-11-16 06:35:05 UTC
  • mfrom: (1664.1.1 listitemSelectModeBugs)
  • Revision ID: zsombor.egri@canonical.com-20151116063505-cwn2qfks7qzk10g9
re-sync

Show diffs side-by-side

added added

removed removed

Lines of Context:
27
27
class ActionBar(_common.UbuntuUIToolkitCustomProxyObjectBase):
28
28
    """ActionBar Autopilot custom proxy object."""
29
29
 
30
 
    def _get_action_button(self, action_object_name):
31
 
        try:
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
36
 
            try:
37
 
                button = self._get_action_button_in_overflow(
38
 
                    action_object_name)
39
 
            except dbus.StateNotFoundError:
40
 
                raise _common.ToolkitException(
41
 
                    'Button not found in ActionBar or overflow')
42
 
 
43
 
        return button
44
 
 
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')
48
34
 
49
35
        if not actions_overflow_button.visible:
50
36
            raise _common.ToolkitException('No actions in overflow')
51
37
 
52
38
        # open the popover
53
39
        self.pointing_device.click_object(actions_overflow_button)
54
 
        object_name = action_object_name + "_header_overflow_button"
55
40
 
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')
64
49
 
65
 
        return popover.select_single(objectName=object_name)
 
50
        return popover
66
51
 
67
52
    @autopilot_logging.log_action(logger.info)
68
53
    def click_action_button(self, action_object_name):
73
58
            name.
74
59
 
75
60
        """
76
 
        button = self._get_action_button(action_object_name)
77
 
        self.pointing_device.click_object(button)
 
61
 
 
62
        try:
 
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
 
68
            try:
 
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')