~canonical-platform-qa/ubuntu-system-tests/scalability_video_tests

« back to all changes in this revision

Viewing changes to ubuntu_system_tests/helpers/system_settings/_cpo.py

  • Committer: Sergio Cazzolato
  • Date: 2016-03-14 14:17:58 UTC
  • mfrom: (332.2.20 trunk)
  • Revision ID: sergio.cazzolato@canonical.com-20160314141758-ro1wj8lc6fl6pbe1
Merge with trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
21
21
import logging
22
22
 
23
23
import autopilot.logging
 
24
import autopilot.exceptions as exceptions
24
25
 
25
26
import ubuntuuitoolkit as uitk
26
27
import ubuntu_system_settings as uss
27
28
 
28
 
from ubuntu_system_tests.helpers.autopilot import validate_dbus_object
 
29
from ubuntu_system_tests.helpers.autopilot import (
 
30
    validate_dbus_object, is_element)
29
31
 
30
32
logger = logging.getLogger(__name__)
31
33
 
111
113
        wifi_switch.swipe_into_view()
112
114
        self.pointing_device.click_object(wifi_switch)
113
115
        wifi_switch.checked.wait_for(False)
 
116
 
 
117
 
 
118
class AboutPage(uss.AboutPage):
 
119
    """Autopilot helper for the About page."""
 
120
 
 
121
    @classmethod
 
122
    def validate_dbus_object(cls, path, state):
 
123
        return validate_dbus_object(
 
124
            path, state, APP_PATH_ROOT, b'PageComponent',
 
125
            objectName='aboutPage')
 
126
 
 
127
    def get_wifi_address(self):
 
128
        """ Retrieve the wifi address value """
 
129
        return self.wait_select_single('SingleValue',
 
130
                                       text='Wi-Fi address').value
 
131
 
 
132
    def get_bluetooth_address(self):
 
133
        """ Retrieve the bluetooth address value """
 
134
        return self.wait_select_single('SingleValue',
 
135
                                       text='Bluetooth address').value
 
136
 
 
137
    def _get_storage(self):
 
138
        return self.wait_select_single('SingleValue', objectName='storageItem')
 
139
 
 
140
    def get_storage(self):
 
141
        """ Retrieve the storage item value """
 
142
        return self._get_storage().value
 
143
 
 
144
    def _go_to_page(self, itemname, pagename):
 
145
        item = self.select_single(objectName=itemname)
 
146
        item.swipe_into_view()
 
147
        self.pointing_device.click_object(item)
 
148
        page = self.get_root_instance().wait_select_single(
 
149
            objectName=pagename)
 
150
        page.active.wait_for(True)
 
151
        return page
 
152
 
 
153
    def go_to_os(self):
 
154
        """ Go to the OS version page and retrieve the page """
 
155
        return self._go_to_page('osItem', 'versionPage')
 
156
 
 
157
    def go_to_developer_mode(self):
 
158
        """ Go to the developer mode page and retrieve the page """
 
159
        return self._go_to_page('devmodeItem', 'devModePage')
 
160
 
 
161
    def go_to_storage(self):
 
162
        """ Go to the storage page and retrieve the page """
 
163
        return self._go_to_page('storageItem', 'storagePage')
 
164
 
 
165
 
 
166
class LicensesPage(uss.LicensesPage):
 
167
    """Autopilot helper for the Licenses page."""
 
168
 
 
169
    @classmethod
 
170
    def validate_dbus_object(cls, path, state):
 
171
        return validate_dbus_object(
 
172
            path, state, APP_PATH_ROOT, b'ItemPage',
 
173
            objectName='licensesPage')
 
174
 
 
175
    def _get_licenses_list(self):
 
176
        return self.wait_select_single('QQuickListView')
 
177
 
 
178
    def _get_license(self, text):
 
179
        return self.select_single('Standard', text=text)
 
180
 
 
181
    def get_license(self, text):
 
182
        """ Swipe until the object appears in the tree, it is not possible to
 
183
        use swipe_child_into_view because the license objects are not part of
 
184
        the tree
 
185
        """
 
186
        list = self._get_licenses_list()
 
187
        while not list.atYEnd:
 
188
            list.swipe_to_show_more_below()
 
189
            if is_element(self._get_license, text):
 
190
                return self._get_license(text)
 
191
 
 
192
        raise exceptions.StateNotFoundError(class_name='Standard', text=text)
 
193
 
 
194
 
 
195
class VersionPage(uitk.UbuntuUIToolkitCustomProxyObjectBase):
 
196
    """Autopilot helper for the Version page."""
 
197
 
 
198
    @classmethod
 
199
    def validate_dbus_object(cls, path, state):
 
200
        return validate_dbus_object(
 
201
            path, state, APP_PATH_ROOT, b'Version',
 
202
            objectName='versionPage')
 
203
 
 
204
    def get_build_number(self):
 
205
        return self.select_single('SingleValueStacked',
 
206
                                  objectName='versionBuildNumberItem').value
 
207
 
 
208
    def get_build_desc(self):
 
209
        return self.select_single('SingleValueStacked',
 
210
                                  objectName='ubuntuBuildIDItem').value
 
211
 
 
212
 
 
213
class DevModePage(uitk.UbuntuUIToolkitCustomProxyObjectBase):
 
214
    """Autopilot helper for the developer mode page."""
 
215
 
 
216
    @classmethod
 
217
    def validate_dbus_object(cls, path, state):
 
218
        return validate_dbus_object(
 
219
            path, state, APP_PATH_ROOT, b'ItemPage',
 
220
            objectName='devModePage')
 
221
 
 
222
    def _get_devmode_checkbox(self):
 
223
        return self.select_single('CheckBox',
 
224
                                  styleName='SwitchStyle')
 
225
 
 
226
    def is_devmode_on(self):
 
227
        return self._get_devmode_checkbox().checked
 
228
 
 
229
    def switch_devmode(self):
 
230
        switcher = self._get_devmode_checkbox()
 
231
        checked = switcher.checked
 
232
        self.pointing_device.click_object(switcher)
 
233
        switcher.checked.wait_for(not checked)
 
234
 
 
235
 
 
236
class StoragePage(uitk.UbuntuUIToolkitCustomProxyObjectBase):
 
237
    """Autopilot helper for the developer mode page."""
 
238
 
 
239
    @classmethod
 
240
    def validate_dbus_object(cls, path, state):
 
241
        return validate_dbus_object(
 
242
            path, state, APP_PATH_ROOT, b'Storage',
 
243
            objectName='storagePage')
 
244
 
 
245
    def get_pictures_storage(self):
 
246
        return self.select_single('StorageItem',
 
247
                                  objectName='picturesItem').value
 
248
 
 
249
    def get_videos_storage(self):
 
250
        return self.select_single('StorageItem',
 
251
                                  objectName='moviesItem').value
 
252
 
 
253
    def get_audio_storage(self):
 
254
        return self.select_single('StorageItem',
 
255
                                  objectName='audioItem').value
 
256
 
 
257
    def _get_gallery_app(self):
 
258
        return self.select_single('SingleValue', objectName='appItemGallery')
 
259
 
 
260
    def get_gallery_app_size_in_disk(self):
 
261
        return self._get_gallery_app().value
 
262
 
 
263
    def get_gallery_app_icon(self):
 
264
        return self._get_gallery_app().icon