~timo-jyrinki/gallery-app/allow_translating_date_strings

« back to all changes in this revision

Viewing changes to tests/autopilot/gallery_app/emulators/photo_viewer.py

Fix AP tests
Approved by: Federico Gimenez

Show diffs side-by-side

added added

removed removed

Lines of Context:
5
5
# under the terms of the GNU General Public License version 3, as published
6
6
# by the Free Software Foundation.
7
7
 
8
 
from gallery_app.emulators.gallery_utils import GalleryUtils
 
8
import logging
 
9
 
 
10
import autopilot.logging
 
11
import ubuntuuitoolkit
 
12
 
 
13
from gallery_app.emulators import main_screen
 
14
from gallery_app.emulators.gallery_utils import(
 
15
    GalleryAppException,
 
16
    GalleryUtils
 
17
)
 
18
 
 
19
 
 
20
logger = logging.getLogger(__name__)
 
21
 
 
22
 
 
23
class PopupPhotoViewer(ubuntuuitoolkit.UbuntuUIToolkitCustomProxyObjectBase):
 
24
 
 
25
    @autopilot.logging.log_action(logger.info)
 
26
    def delete_current_photo(self, confirm=True):
 
27
        header = self.get_root_instance().select_single(
 
28
            main_screen.MainScreen).get_header()
 
29
        header.click_action_button("deleteButton")
 
30
        if confirm:
 
31
            self.confirm_delete_photo()
 
32
        else:
 
33
            self.cancel_delete_photo()
 
34
 
 
35
    @autopilot.logging.log_action(logger.debug)
 
36
    def confirm_delete_photo(self):
 
37
        self._click_delete_dialog_button("Yes")
 
38
 
 
39
    def _click_delete_dialog_button(self, name):
 
40
        delete_dialog = self._get_delete_dialog()
 
41
        button = delete_dialog.wait_select_single(
 
42
            "Button", objectName="deletePhotoDialog" + name, visible=True)
 
43
        self.pointing_device.click_object(button)
 
44
        delete_dialog.wait_until_destroyed()
 
45
 
 
46
    def _get_delete_dialog(self):
 
47
        delete_dialog = self.get_root_instance().wait_select_single(
 
48
            objectName="deletePhotoDialog")
 
49
        delete_dialog.visible.wait_for(True)
 
50
        delete_dialog.opacity.wait_for(1)
 
51
        return delete_dialog
 
52
 
 
53
    @autopilot.logging.log_action(logger.debug)
 
54
    def cancel_delete_photo(self):
 
55
        self._click_delete_dialog_button('No')
9
56
 
10
57
 
11
58
class PhotoViewer(GalleryUtils):
14
61
        super(PhotoViewer, self).__init__(self)
15
62
        self.app = app
16
63
 
17
 
    def get_delete_dialog(self):
18
 
        """Returns the photo viewer delete dialog."""
19
 
        return self.app.wait_select_single("Dialog",
20
 
                                           objectName="deletePhotoDialog")
21
 
 
22
 
    def delete_dialog_shown(self):
23
 
        dialog = self.app.select_many("Dialog",
24
 
                                      objectName="deletePhotoDialog")
25
 
        return len(dialog) >= 1
26
 
 
27
64
    def get_popup_album_picker(self):
28
65
        """Returns the photo viewer album pickers."""
29
66
        return self.app.wait_select_single("PopupAlbumPicker",
54
91
    def get_cancel_revert_to_original_button(self):
55
92
        """Returns the revert to original cancel button."""
56
93
        return self.get_revert_to_original_dialog().wait_select_single(
57
 
           "Button",
58
 
           objectName="cancelRevertButton",
59
 
           visible=True)
 
94
            "Button",
 
95
            objectName="cancelRevertButton",
 
96
            visible=True)
60
97
 
61
98
    def get_confirm_revert_to_original_button(self):
62
99
        """Returns the revert to original confirm button."""
63
100
        return self.get_revert_to_original_dialog().wait_select_single(
64
 
           "Button",
65
 
           objectName="confirmRevertButton",
66
 
           visible=True)
 
101
            "Button",
 
102
            objectName="confirmRevertButton",
 
103
            visible=True)
67
104
 
68
105
    def get_photo_component(self):
69
106
        # Was using a list index (lp:1247711). Still needs fixing, I'm not
78
115
 
79
116
    def get_editor_actions_bar(self):
80
117
        """Returns the actions bar for the editor."""
81
 
        return self.app.select_single("ActionsBar", objectName="editorActionsBar")
 
118
        return self.app.select_single("ActionsBar",
 
119
                                      objectName="editorActionsBar")
82
120
 
83
121
    def get_editor_action_button_by_text(self, button_text):
84
122
        """Returns the action button from the editor by text."""
114
152
        """Returns the 'auto enhance' menu item in the edit dialog."""
115
153
        return self.app.select_single("Standard", objectName='enhanceListItem')
116
154
 
117
 
    def get_delete_popover_delete_item(self):
118
 
        """Returns the delete button of the delete popover."""
119
 
        return self.app.select_single("Button",
120
 
                                      objectName="deletePhotoDialogYes",
121
 
                                      visible=True)
122
 
 
123
155
    def get_delete_popover_cancel_item(self):
124
156
        """Returns the cancel button of the delete popover."""
125
 
        return self.app.select_single("Button",
126
 
                                      objectName="deletePhotoDialogNo",
127
 
                                      visible=True)
 
157
        return self.app.wait_select_single("Button",
 
158
                                           objectName="deletePhotoDialogNo",
 
159
                                           visible=True)
128
160
 
129
161
    def get_opened_photo(self):
130
162
        """Returns the first opened photo."""