本文整理汇总了Python中autopilot.input.Pointer.move方法的典型用法代码示例。如果您正苦于以下问题:Python Pointer.move方法的具体用法?Python Pointer.move怎么用?Python Pointer.move使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类autopilot.input.Pointer
的用法示例。
在下文中一共展示了Pointer.move方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: GtkSpinButton
# 需要导入模块: from autopilot.input import Pointer [as 别名]
# 或者: from autopilot.input.Pointer import move [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: _long_press_key
# 需要导入模块: from autopilot.input import Pointer [as 别名]
# 或者: from autopilot.input.Pointer import move [as 别名]
def _long_press_key(self, key_rect, pointer=None):
if pointer is None:
pointer = Pointer(Touch.create())
pointer.move(
key_rect.x + key_rect.w / 2.0, key_rect.y + key_rect.h / 2.0)
pointer.press()
sleep(0.5)
pointer.release()
示例3: GtkBox
# 需要导入模块: from autopilot.input import Pointer [as 别名]
# 或者: from autopilot.input.Pointer import move [as 别名]
#.........这里部分代码省略.........
#get a language which the first two chars can be ascii decoded
test_language = self._get_decode_ascii_item(treeview_items)
return test_language
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
示例4: CustomInstallTests
# 需要导入模块: from autopilot.input import Pointer [as 别名]
# 或者: from autopilot.input.Pointer import move [as 别名]
class CustomInstallTests(AutopilotTestCase):
def setUp(self):
super(CustomInstallTests, self).setUp()
self.app = self.launch_application()
self.pointing_device = Pointer(Mouse.create())
def launch_application(self):
my_process = int(os.environ['UBIQUITY_PID'])
my_dbus = str(os.environ['DBUS_SESSION_BUS_ADDRESS'])
return get_proxy_object_for_existing_process(
pid=my_process, dbus_bus=my_dbus)
def test_custom_install(self):
'''
Test install using Custom partition configuration
'''
self.keyboard.press_and_release('Super+1')
main_window = self.app.select_single(
'GtkWindow', name='live_installer')
self.assertThat(main_window.title, Equals("Install"))
# This method runs the ubiquity_ methods to navigate
# testing through the install pages
self.run_custom_install_test()
#Then finally here check that the complete dialog appears
self.ubiquity_did_install_complete()
def run_custom_install_test(self):
'''
this can be easily used when debugging. If the test exits on a
particular page, you can comment out the pages prior to the exit point
and reset current page to its default state, then run test again.
The test will start from the page it exited on. This can save alot of
hassle having to setup the whole test again, just to fix a small error.
'''
#Page 1
self.ubiquity_welcome_page_test()
#Page 2
self.ubiquity_preparing_page_test()
##Page 3
self.ubiquity_install_type_page_test()
##Page 3 extended
self.ubiquity_advanced_partition_page()
#Page 4
self.ubiquity_where_are_you_page_test()
#Page 5
self.ubiquity_keyboard_page_test()
#Page 6
self.ubiquity_who_are_you_page_test()
#page 7
self.ubiquity_progress_bar_test()
def ubiquity_welcome_page_test(self):
'''
Tests that all needed objects on the Welcome page are accessible
And can also be navigated to.
Once confirmed continue with install accepting all defaults
'''
self.get_ubiquity_objects()
self.assertThat(self.headerlabel.label, Eventually(Contains('Welcome')))
#Can we navigate to the quit button? This fails the test if object
# has no position attribs
self.pointing_device.move_to_object(self.quit_button)
self.assertThat(self.continue_button.label, Equals('Continue'))
#Can we navigate to the continue button?
self.pointing_device.move_to_object(self.continue_button)
#Finally lets move on to the next page
self.pointing_device.click()
def ubiquity_preparing_page_test(self):
self.wait_for_button_state_changed()
#Check the next page title
self.assertThat(self.headerlabel.label,
Eventually(Contains('Preparing to install')))
#lets get all the page objects
self.get_ubiquity_objects()
'''
Lets test we can go back to the welcome page and come back here
'''
#Click back
self.pointing_device.move_to_object(self.back_button)
self.pointing_device.click()
self.wait_for_button_state_changed()
#check we went back
self.assertThat(self.headerlabel.label, Eventually(Contains('Welcome')))
#go back to the page we were on
self.get_ubiquity_objects()
self.assertThat(self.continue_button.label, Equals('Continue'))
self.pointing_device.move_to_object(self.continue_button)
self.pointing_device.click()
#.........这里部分代码省略.........