Debian Codegraph @

tests/autopilot/lomiriuitoolkit/_custom_proxy_objects/_checkbox.py

raw
1 # -*- Mode: Python; coding: utf-8; indent-tabs-mode: nil; tab-width: 4 -*-
2 #
3 # Copyright (C) 2012, 2013, 2014 Canonical Ltd.
4 #
5 # This program is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU Lesser General Public License as published by
7 # the Free Software Foundation; version 3.
8 #
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU Lesser General Public License for more details.
13 #
14 # You should have received a copy of the GNU Lesser General Public License
15 # along with this program. If not, see <http://www.gnu.org/licenses/>.
16
17 import logging
18
19 from autopilot import logging as autopilot_logging
20
21 from lomiriuitoolkit._custom_proxy_objects import _common
22
23
24 logger = logging.getLogger(__name__)
25
26
27 class CheckBox(_common.LomiriUIToolkitCustomProxyObjectBase):
28 """CheckBox Autopilot custom proxy object."""
29
30 @autopilot_logging.log_action(logger.info)
31 def check(self, timeout=10):
32 """Check a CheckBox, if its not already checked.
33
34 :parameter timeout: number of seconds to wait for the CheckBox to be
35 checked. Default is 10.
36
37 """
38 if not self.checked:
39 self.change_state(timeout)
40
41 @autopilot_logging.log_action(logger.info)
42 def uncheck(self, timeout=10):
43 """Uncheck a CheckBox, if its not already unchecked.
44
45 :parameter timeout: number of seconds to wait for the CheckBox to be
46 unchecked. Default is 10.
47
48 """
49 if self.checked:
50 self.change_state(timeout)
51
52 @autopilot_logging.log_action(logger.info)
53 def change_state(self, timeout=10):
54 """Change the state of a CheckBox.
55
56 If it is checked, it will be unchecked. If it is unchecked, it will be
57 checked.
58
59 :parameter time_out: number of seconds to wait for the CheckBox state
60 to change. Default is 10.
61
62 """
63 original_state = self.checked
64 self.pointing_device.click_object(self)
65 self.checked.wait_for(not original_state, timeout)