1
# -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
4
# Copyright (C) 2016 Canonical
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.
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.
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/>.
19
from ubuntu_system_tests.helpers.ubuntuuitoolkit import slider
20
from ubuntu_system_tests.helpers.indicators import(
24
from ubuntu_system_tests.helpers.autopilot import(
28
from ubuntu_system_tests.helpers import unity8
31
class BatteryIndicatorPage(IndicatorPage):
32
"""Autopilot helper for the battery indicator page."""
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')
40
def _get_battery_settings_menu_item(self):
41
"""Return the battery settings list item."""
42
return self.select_single(
44
objectName='indicator.activate-phone-settings')
47
def open_battery_settings(self):
48
"""Tap the battery settings menu item to open settings."""
49
return self._get_battery_settings_menu_item()
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')
55
def get_current_brightness(self):
56
return float(self.get_brightness_slider_widget().value)
58
def _get_brightness_switch(self):
59
"""Return the auto brightness switch."""
60
return self.select_single('SwitchMenu',
61
objectName='indicator.auto-brightness')
64
def click_brightness_switch(self):
65
return self._get_brightness_switch()
67
def enable_auto_brightness(self):
68
"""Enable auto brightness."""
69
if not self._get_brightness_switch().checked:
70
self.click_brightness_switch()
72
def disable_auto_brightness(self):
73
"""Disable auto brightness."""
74
if self._get_brightness_switch().checked:
75
self.click_brightness_switch()