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

« back to all changes in this revision

Viewing changes to ubuntu_system_tests/helpers/indicators/battery.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:
 
1
# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
 
2
 
 
3
# Ubuntu System Tests
 
4
# Copyright (C) 2016 Canonical
 
5
#
 
6
# This program is free software: you can redistribute it and/or modify
 
7
# it under the terms of the GNU General Public License as published by
 
8
# the Free Software Foundation, either version 3 of the License, or
 
9
# (at your option) any later version.
 
10
#
 
11
# This program is distributed in the hope that it will be useful,
 
12
# but WITHOUT ANY WARRANTY; without even the implied warranty of
 
13
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
14
# GNU General Public License for more details.
 
15
#
 
16
# You should have received a copy of the GNU General Public License
 
17
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
18
 
 
19
from ubuntu_system_tests.helpers.ubuntuuitoolkit import slider
 
20
from ubuntu_system_tests.helpers.indicators import(
 
21
    IndicatorPage,
 
22
    INDICATOR_PAGE_PATH
 
23
)
 
24
from ubuntu_system_tests.helpers.autopilot import(
 
25
    validate_dbus_object,
 
26
    click_object
 
27
)
 
28
from ubuntu_system_tests.helpers import unity8
 
29
 
 
30
 
 
31
class BatteryIndicatorPage(IndicatorPage):
 
32
    """Autopilot helper for the battery indicator page."""
 
33
 
 
34
    @classmethod
 
35
    def validate_dbus_object(cls, path, state):
 
36
        return validate_dbus_object(
 
37
            path, state, unity8.UNITY8_PATH_ROOT, INDICATOR_PAGE_PATH,
 
38
            objectName='indicator-power-page')
 
39
 
 
40
    def _get_battery_settings_menu_item(self):
 
41
        """Return the battery settings list item."""
 
42
        return self.select_single(
 
43
            'StandardMenu',
 
44
            objectName='indicator.activate-phone-settings')
 
45
 
 
46
    @click_object
 
47
    def open_battery_settings(self):
 
48
        """Tap the battery settings menu item to open settings."""
 
49
        return self._get_battery_settings_menu_item()
 
50
 
 
51
    def get_brightness_slider_widget(self):
 
52
        """Return the slider widget on the battery indicator page."""
 
53
        return self.select_single(slider.Slider, objectName='slider')
 
54
 
 
55
    def get_current_brightness(self):
 
56
        return float(self.get_brightness_slider_widget().value)
 
57
 
 
58
    def _get_brightness_switch(self):
 
59
        """Return the auto brightness switch."""
 
60
        return self.select_single('SwitchMenu',
 
61
                                  objectName='indicator.auto-brightness')
 
62
 
 
63
    @click_object
 
64
    def click_brightness_switch(self):
 
65
        return self._get_brightness_switch()
 
66
 
 
67
    def enable_auto_brightness(self):
 
68
        """Enable auto brightness."""
 
69
        if not self._get_brightness_switch().checked:
 
70
            self.click_brightness_switch()
 
71
 
 
72
    def disable_auto_brightness(self):
 
73
        """Disable auto brightness."""
 
74
        if self._get_brightness_switch().checked:
 
75
            self.click_brightness_switch()