~jonas-drange/ubuntu-system-settings/hotspots-change-test-backend

« back to all changes in this revision

Viewing changes to tests/autopilot/ubuntu_system_settings/__init__.py

  • Committer: jonas-drange
  • Date: 2015-07-22 14:16:13 UTC
  • mfrom: (1312.3.74 tmp)
  • Revision ID: jonas.drange@canonical.com-20150722141613-4hz7rolyt8eei8ht
  Pete Woods 2015-07-16 Manage hotspots via connectity API

Show diffs side-by-side

added added

removed removed

Lines of Context:
306
306
        field.write(name)
307
307
        self.pointing_device.click_object(ok)
308
308
 
 
309
    """
 
310
    :returns: Whether or not hotspot can be used.
 
311
    """
 
312
    @autopilot.logging.log_action(logger.debug)
 
313
    def have_hotspot(self):
 
314
        return self.wait_select_single(objectName='hotspotEntry').visible
 
315
 
 
316
    """
 
317
    :param: Configuration with keys ssid and password.
 
318
    :returns: Hotspot page.
 
319
    """
 
320
    @autopilot.logging.log_action(logger.debug)
 
321
    def setup_hotspot(self, config=None):
 
322
        hotspot_page = self._enter_hotspot()
 
323
        hotspot_page.setup_hotspot(config)
 
324
        return hotspot_page
 
325
 
 
326
    """
 
327
    Enables hotspot.
 
328
    :returns: Hotspot page.
 
329
    """
 
330
    @autopilot.logging.log_action(logger.debug)
 
331
    def enable_hotspot(self):
 
332
        hotspot_page = self._enter_hotspot()
 
333
        hotspot_page.enable_hotspot()
 
334
        return hotspot_page
 
335
 
 
336
    """
 
337
    Disables hotspot.
 
338
    :returns: Hotspot page.
 
339
    """
 
340
    @autopilot.logging.log_action(logger.debug)
 
341
    def disable_hotspot(self):
 
342
        hotspot_page = self._enter_hotspot()
 
343
        hotspot_page.disable_hotspot()
 
344
        return hotspot_page
 
345
 
 
346
    @autopilot.logging.log_action(logger.debug)
 
347
    def _enter_hotspot(self):
 
348
        obj = self.wait_select_single(objectName="hotspotEntry")
 
349
        self.pointing_device.click_object(obj)
 
350
        return self.get_root_instance().wait_select_single(
 
351
            objectName='hotspotPage')
 
352
 
 
353
 
 
354
class Hotspot(ubuntuuitoolkit.UbuntuUIToolkitCustomProxyObjectBase):
 
355
 
 
356
    """Autopilot helper for Hotspot page."""
 
357
 
 
358
    @classmethod
 
359
    def validate_dbus_object(cls, path, state):
 
360
        name = introspection.get_classname_from_path(path)
 
361
        if name == b'ItemPage':
 
362
            if state['objectName'][1] == 'hotspotPage':
 
363
                return True
 
364
        return False
 
365
 
 
366
    @property
 
367
    def _switch(self):
 
368
        return self.wait_select_single(
 
369
            ubuntuuitoolkit.CheckBox,
 
370
            objectName='hotspotSwitch')
 
371
 
 
372
    @autopilot.logging.log_action(logger.debug)
 
373
    def enable_hotspot(self):
 
374
        self._switch.check()
 
375
 
 
376
    @autopilot.logging.log_action(logger.debug)
 
377
    def disable_hotspot(self):
 
378
        self._switch.uncheck()
 
379
 
 
380
    @autopilot.logging.log_action(logger.debug)
 
381
    def setup_hotspot(self, config):
 
382
        obj = self.select_single(objectName='hotspotSetupEntry')
 
383
        self.pointing_device.click_object(obj)
 
384
        setup = self.get_root_instance().wait_select_single(
 
385
            objectName='hotspotSetup')
 
386
        if config:
 
387
            if 'ssid' in config:
 
388
                setup.set_ssid(config['ssid'])
 
389
            if 'password' in config:
 
390
                setup.set_password(config['password'])
 
391
        setup.enable()
 
392
        if setup:
 
393
            setup.wait_until_destroyed()
 
394
 
 
395
    @autopilot.logging.log_action(logger.debug)
 
396
    def get_hotspot_status(self):
 
397
        return self._switch.checked
 
398
 
 
399
 
 
400
class HotspotSetup(ubuntuuitoolkit.UbuntuUIToolkitCustomProxyObjectBase):
 
401
 
 
402
    """Autopilot helper for Hotspot setup."""
 
403
 
 
404
    @classmethod
 
405
    def validate_dbus_object(cls, path, state):
 
406
        name = introspection.get_classname_from_path(path)
 
407
        if name == b'Dialog':
 
408
            if state['objectName'][1] == 'hotspotSetup':
 
409
                return True
 
410
        return False
 
411
 
 
412
    @property
 
413
    def _ssid_field(self):
 
414
        return self.wait_select_single(
 
415
            ubuntuuitoolkit.TextField,
 
416
            objectName='ssidField')
 
417
 
 
418
    @property
 
419
    def _password_field(self):
 
420
        return self.wait_select_single(
 
421
            ubuntuuitoolkit.TextField,
 
422
            objectName='passwordField')
 
423
 
 
424
    @property
 
425
    def _enable_button(self):
 
426
        return self.wait_select_single(
 
427
            'Button', objectName='confirmButton')
 
428
 
 
429
    @autopilot.logging.log_action(logger.debug)
 
430
    def set_ssid(self, ssid):
 
431
        self._ssid_field.write(ssid)
 
432
 
 
433
    @autopilot.logging.log_action(logger.debug)
 
434
    def set_password(self, password):
 
435
        self._password_field.write(password)
 
436
 
 
437
    @autopilot.logging.log_action(logger.debug)
 
438
    def enable(self):
 
439
        self.pointing_device.click_object(self._enable_button)
 
440
 
309
441
 
310
442
class BluetoothPage(ubuntuuitoolkit.UbuntuUIToolkitCustomProxyObjectBase):
311
443