~canonical-platform-qa/ubuntu-system-tests/initial-ap1.6-porting

« back to all changes in this revision

Viewing changes to ubuntu_system_tests/helpers/webbrowser.py

Implementation of the test case to download an image frem the web browser and see this in the gallery app.

Approved by Brendan Donegan, PS Jenkins bot.

Show diffs side-by-side

added added

removed removed

Lines of Context:
20
20
 
21
21
import logging
22
22
import os
23
 
import shutil
24
23
 
25
24
from webbrowser_app.emulators import browser
26
25
 
 
26
from ubuntu_system_tests.helpers import file_system as fs
 
27
 
27
28
logger = logging.getLogger(__name__)
28
29
 
29
30
 
32
33
 
33
34
    data_dir = os.path.join(os.path.expanduser("~"), ".local", "share",
34
35
                            "webbrowser-app")
35
 
    shutil.rmtree(data_dir, True)
36
 
    os.makedirs(data_dir)
 
36
    fs.clean_dir(data_dir)
37
37
 
38
38
 
39
39
class Browser(browser.Browser):
56
56
        The clear method and the retry mechanism are are executes to avoid an
57
57
        sporadic error that happen when is being written the url
58
58
        """
 
59
        self.pointing_device.click_object(self.address_bar.text_field)
59
60
        for i in range(3):
60
61
            if not self.address_bar.text_field.text == url:
61
62
                self.address_bar.clear()
98
99
                                            iconName="tab-new")
99
100
        self.pointing_device.click_object(new_tab_button)
100
101
        return self.get_new_tab_view()
 
102
 
 
103
    def get_popover_foreground_dialog(self):
 
104
        self.select_single('UCStyledItemBase', objectName='popover_foreground')
 
105
 
 
106
    def get_popover_foreground_dialog_item(self, text):
 
107
        elems = self.select_many('Empty', visible=True)
 
108
        return next(elem for elem in elems if elem.text == text)
 
109
 
 
110
    def get_gallery_button(self):
 
111
        dialog = self.wait_select_single('ContentDownloadDialog')
 
112
        buttons = dialog.select_many('AbstractButton', visible=True)
 
113
        for button in buttons:
 
114
            gallery = self.get_gallery(button)
 
115
            if gallery is not None:
 
116
                return button
 
117
 
 
118
        return None
 
119
 
 
120
    def get_gallery(self, button):
 
121
        images = button.select_many('QQuickImage', objectName='image')
 
122
        for img in images:
 
123
            if img.source.find('gallery') >= 0:
 
124
                return img
 
125
        return None