本文整理汇总了Python中autopilot.input.Pointer.position方法的典型用法代码示例。如果您正苦于以下问题:Python Pointer.position方法的具体用法?Python Pointer.position怎么用?Python Pointer.position使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类autopilot.input.Pointer
的用法示例。
在下文中一共展示了Pointer.position方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: GtkSpinButton
# 需要导入模块: from autopilot.input import Pointer [as 别名]
# 或者: from autopilot.input.Pointer import position [as 别名]
class GtkSpinButton(AutopilotGtkEmulatorBase):
""" Emulator class for a GtSpinButton instance"""
def __init__(self, *args):
super(GtkSpinButton, self).__init__(*args)
self.pointing_device = Pointer(Mouse.create())
self.kbd = Keyboard.create()
def enter_value(self, value):
self._select_entry()
self.kbd.type(value)
expectThat(self.text).equals(
value,
msg="Expected spinbutton value '{0}' to equal {1}"
.format(self.text, value))
def _select_entry(self, ):
self.pointing_device.move_to_object(self)
pos = self.pointing_device.position()
x = pos[0]
y = pos[1]
x -= 15 # px
self.pointing_device.move(x, y)
self.pointing_device.click()
self.kbd.press_and_release('Ctrl+a')
self.kbd.press_and_release('Delete')
示例2: GtkBox
# 需要导入模块: from autopilot.input import Pointer [as 别名]
# 或者: from autopilot.input.Pointer import position [as 别名]
#.........这里部分代码省略.........
def _get_decode_ascii_item(self, items):
""" decodes a list of unicode items """
logger.debug("_get_decode_ascii_item()")
# at the moment we can't select all locales as this would be a pain
# to figure out all encodings for keyboard input
lang_item = None
l_ascii = None
while True:
lang_item = random.choice(items)
l_unicode = lang_item.accessible_name
logger.debug("Attempting to decode %s" % l_unicode)
lan = l_unicode[0:2]
try:
l_ascii = lan.encode('ascii')
except UnicodeEncodeError:
logger.debug("%s could not be decoded" % l_unicode)
pass
if l_ascii:
logger.debug("%s decoded successfully" % l_unicode)
break
logger.debug("Returning selected language: %s" % l_unicode)
return lang_item
def select_location(self, location):
""" Selects a location on the timezone map """
if self.name == 'stepLocation':
logger.debug("select_location({0})".format(location))
location_map = self.select_single('CcTimezoneMap')
self.pointing_device.move_to_object(location_map)
x1, y1, x2, y2 = location_map.globalRect
#hmmmm this is tricky! and really hacky
pos = self.pointing_device.position()
x = pos[0]
y = pos[1]
x -= 25 # px
self.pointing_device.move(x, y)
while True:
entry = self.select_single('GtkEntry')
if entry.text != location:
pos = self.pointing_device.position()
x = pos[0]
y = pos[1]
y -= 10 # px
self.pointing_device.move(x, y)
self.pointing_device.click()
if y < y1:
logger.warning("We missed the location on the map and "
"ended up outside the globalRect. Now "
"using the default selected location "
"instead")
break
else:
expectThat(entry.text).equals(location)
logger.debug("Location; '{0}' selected".format(location))
break
else:
raise ValueError("Function can only be called from a "
"stepLocation page object")
def create_user(self, name, password):
""" Creates a user account with password
:param name: Username
:param password: user password
示例3: CustomInstallTests
# 需要导入模块: from autopilot.input import Pointer [as 别名]
# 或者: from autopilot.input.Pointer import position [as 别名]
#.........这里部分代码省略.........
self.assertThat(self.partition_dialog.visible, Eventually(Equals(1)))
#Create swap partition
self.partition_dialog_create_partition('swap', '1000', 'end', 'primary')
self.assertThat(self.partition_dialog.visible, Eventually(Equals(0)))
self.wait_for_button_state_changed()
self.keyboard.press_and_release('Down')
self.keyboard.press_and_release('Enter')
#create root partition
self.partition_dialog_create_partition('/', '', 'beginning', 'primary')
self.assertThat(self.partition_dialog.visible, Eventually(Equals(0)))
self.wait_for_button_state_changed()
self.pointing_device.move_to_object(self.continue_button)
self.pointing_device.click()
def partition_dialog_create_partition(self, mount, size, partition_place, partition_type):
''' Create required partition
Params
::mount = a string val of the required mount point
for example
* 'swap'
* '/'
* '/home'
* '/boot'
::size = string val of partition size required in MB
AN empty string '' takes all the available space
::partition_place = a string val of position of partition
* 'beginning'
* 'end'
::partition_type = string val of the type of partition
* 'logical'
or
* 'primary'
Currently it uses the default partition format ext4
'''
#get the objects just to ensure id's have not changed
self.get_ubiquity_objects()
self.assertThat(self.partition_dialog.visible, Eventually(Equals(1)))
self.assertThat(self.partition_dialog.title, Eventually(Contains('Create partition')))
if mount == 'swap' :
self.select_spin_button()
self.keyboard.type(size)
if partition_place == 'beginning':
self.pointing_device.move_to_object(self.place_begin_radio_button)
elif partition_place == 'end' :
self.pointing_device.move_to_object(self.place_end_radio_button)
else: #if it matches neither lets place it at end by default as its a swap
self.pointing_device.move_to_object(self.place_end_radio_button)
self.pointing_device.click()
if partition_type == 'primary' :
self.pointing_device.move_to_object(self.primary_radio_button)
elif partition_type == 'logical' :
self.pointing_device.move_to_object(self.logical_radio_button)
else:
self.pointing_device.move_to_object(self.primary_radio_button)
self.pointing_device.click()