本文整理汇总了Python中autopilot.input.Pointer.move_to_object方法的典型用法代码示例。如果您正苦于以下问题:Python Pointer.move_to_object方法的具体用法?Python Pointer.move_to_object怎么用?Python Pointer.move_to_object使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类autopilot.input.Pointer
的用法示例。
在下文中一共展示了Pointer.move_to_object方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: GtkSpinButton
# 需要导入模块: from autopilot.input import Pointer [as 别名]
# 或者: from autopilot.input.Pointer import move_to_object [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: UbuntuHTML5TestCaseBase
# 需要导入模块: from autopilot.input import Pointer [as 别名]
# 或者: from autopilot.input.Pointer import move_to_object [as 别名]
class UbuntuHTML5TestCaseBase(AutopilotTestCase):
BROWSER_CONTAINER_PATH = "%s/%s" % (os.path.dirname(os.path.realpath(__file__)), '../../tools/qml/webview.qml')
INSTALLED_BROWSER_CONTAINER_PATH = '/usr/share/ubuntu-html5-theme/autopilot-tests/qml/webview.qml'
arch = subprocess.check_output(
["dpkg-architecture", "-qDEB_HOST_MULTIARCH"]).strip()
BROWSER_QML_APP_LAUNCHER = "/usr/lib/" + arch + "/qt5/bin/qmlscene"
# TODO: fix version
LOCAL_HTML_EXAMPLES_PATH = os.path.abspath("%s/%s" % (os.path.dirname(os.path.realpath(__file__)), '../../../../0.1/examples/'))
INSTALLED_HTML_EXAMPLES_PATH = '/usr/share/ubuntu-html5-theme/0.1/examples'
APPS_SUBFOLDER_NAME = 'apps'
BASE_PATH = ''
def get_browser_container_path(self):
if os.path.exists(self.BROWSER_CONTAINER_PATH):
return self.BROWSER_CONTAINER_PATH
return self.INSTALLED_BROWSER_CONTAINER_PATH
def create_file_url_from(self, filepath):
return 'file://' + filepath
def setup_base_path(self):
if os.path.exists(self.LOCAL_HTML_EXAMPLES_PATH):
self.BASE_PATH = self.LOCAL_HTML_EXAMPLES_PATH
else:
self.BASE_PATH = self.INSTALLED_HTML_EXAMPLES_PATH
def setUp(self):
self.setup_base_path()
self.pointer = Pointer(Mouse.create())
self.app = self.launch_test_application(self.BROWSER_QML_APP_LAUNCHER, self.get_browser_container_path())
self.webviewContainer = self.get_webviewContainer()
self.watcher = self.webviewContainer.watch_signal('resultUpdated(QString)')
super(UbuntuHTML5TestCaseBase, self).setUp()
def tearDown(self):
super(UbuntuHTML5TestCaseBase, self).tearDown()
def pick_app_launcher(self, app_path):
# force Qt app introspection:
from autopilot.introspection.qt import QtApplicationLauncher
return QtApplicationLauncher()
def get_webviewContainer(self):
return self.app.select_single(objectName="webviewContainer")
def get_webview(self):
return self.app.select_single(objectName="webview")
def get_addressbar(self):
return self.app.select_single(objectName="addressbar")
def get_button(self):
return self.app.select_single(objectName="browseButton")
def get_title(self):
return self.get_webview().title
def assert_url_eventually_loaded(self, url):
webview = self.get_webview()
self.assertThat(webview.loadProgress, Eventually(Equals(100)))
self.assertThat(webview.loading, Eventually(Equals(False)))
self.assertThat(webview.url, Eventually(Equals(url)))
def click_dom_node_with_id(self, id):
webview = self.get_webviewContainer()
webview.slots.clickElementById(id)
self.assertThat(lambda: self.watcher.num_emissions, Eventually(Equals(1)))
def click_any_dom_node_by_selector(self, selector):
webview = self.get_webviewContainer()
webview.slots.clickAnyElementBySelector(selector)
self.assertThat(lambda: self.watcher.num_emissions, Eventually(Equals(1)))
def is_dom_node_visible(self, id):
webview = self.get_webviewContainer()
prev_emissions = self.watcher.num_emissions
webview.slots.isNodeWithIdVisible(id)
self.assertThat(lambda: self.watcher.num_emissions, Eventually(GreaterThan(prev_emissions)))
return json.loads(webview.get_signal_emissions('resultUpdated(QString)')[-1][0])['result']
def eval_expression_in_page_unsafe(self, expr):
webview = self.get_webviewContainer()
prev_emissions = self.watcher.num_emissions
webview.slots.evalInPageUnsafe(expr)
self.assertThat(lambda: self.watcher.num_emissions, Eventually(GreaterThan(prev_emissions)))
return json.loads(webview.get_signal_emissions('resultUpdated(QString)')[-1][0])['result']
def get_dom_node_id_attribute(self, id, attribute):
webview = self.get_webviewContainer()
prev_emissions = self.watcher.num_emissions
webview.slots.getAttributeForElementWithId(id, attribute)
self.assertThat(lambda: self.watcher.num_emissions, Eventually(GreaterThan(prev_emissions)))
return json.loads(webview.get_signal_emissions('resultUpdated(QString)')[-1][0])['result']
def browse_to_url(self, url):
addressbar = self.get_addressbar()
self.pointer.move_to_object(addressbar)
#.........这里部分代码省略.........
示例3: DefaultInstallTests
# 需要导入模块: from autopilot.input import Pointer [as 别名]
# 或者: from autopilot.input.Pointer import move_to_object [as 别名]
class DefaultInstallTests(AutopilotTestCase):
def setUp(self):
super(DefaultInstallTests, self).setUp()
self.app = self.launch_application()
#properties = self.app.get_properties()
#print(properties)
self.pointing_device = Pointer(Mouse.create())
def launch_application(self):
'''
Hmm... launch ubiquity
:returns: The application proxy object.
'''
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_default_install(self):
'''
Test install using all default values
'''
#Ubuntu: Lets get the focus back to ubiquity window
#Comment out this line if running test on xubuntu/lubuntu and make sure terminal
# is not on top of ubiquity when starting the test.
#FIXME: Need setup and teardown to be implemented so we can lose this all together
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_default_install_test()
#Then finally here check that the complete dialog appears
self.ubiquity_did_install_complete()
def run_default_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 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()
#.........这里部分代码省略.........
示例4: UbiquityAutopilotTestCase
# 需要导入模块: from autopilot.input import Pointer [as 别名]
# 或者: from autopilot.input.Pointer import move_to_object [as 别名]
#.........这里部分代码省略.........
treeview = welcome_page.select_single('GtkTreeView')
#lets get all items
treeview_items = treeview.get_all_items()
#first lets check all the items are non-empty unicode strings
logger.debug("Checking all tree items are valid unicode")
for item in treeview_items:
logger.debug("Check tree item with name '%s' is unicode" %
item.accessible_name)
self.expectIsInstance(item.accessible_name, str,
"[Page:'stepLanguage'] Expected '%s' tree "
"view item to be unicode but it wasn't" %
item.accessible_name)
self.expectThat(item.accessible_name, NotEquals(u''),
"[Page:'stepLanguage'] Tree item found that "
"doesn't contain any text")
if lang:
if lang == 'English':
self.english_install = True
item = treeview.select_item(lang)
language = item
else:
language = welcome_page.get_random_language()
if language == 'English':
self.english_install = True
welcome_page.select_language(language)
self.assertThat(language.selected, Equals(True))
##Test release notes label is visible
logger.debug("Checking the release_notes_label")
self.check_visible_object_with_label('release_notes_label')
release_notes_label = welcome_page.select_single(
BuilderName='release_notes_label')
self.pointing_device.move_to_object(release_notes_label)
self._update_page_titles()
self._check_page_titles()
self._check_navigation_buttons()
def preparing_page_tests(self, updates=False, thirdParty=False,
networkConnection=True, sufficientSpace=True,
powerSource=False):
""" Runs the tests for the 'Preparing to install' page
:param updates: Boolean, if True selects install updates during install
:param thirdParty: Boolean, if True selects install third-party
software
:param networkConnection: Boolean if True checks the network state box
is visible and objects are correct, If
false will still check the objects are
correct but the state box is not visible
:param sufficientSpace: Boolean if True checks the network state box is
visible and objects are correct, If false
will still check the objects are correct
but the state box is not visible
:param powerSource: Boolean if True checks the network state box is
visible and objects are correct, If false
will still check the objects are correct
but the state box is not visible
"""
self._update_current_step('stepPrepare')
self._check_navigation_buttons()
示例5: GtkBox
# 需要导入模块: from autopilot.input import Pointer [as 别名]
# 或者: from autopilot.input.Pointer import move_to_object [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
示例6: UbuntuTouchAppTestCase
# 需要导入模块: from autopilot.input import Pointer [as 别名]
# 或者: from autopilot.input.Pointer import move_to_object [as 别名]
class UbuntuTouchAppTestCase(AutopilotTestCase):
"""A common test case class that provides several useful methods for the tests."""
if model() == 'Desktop':
scenarios = [
('with mouse', dict(input_device_class=Mouse))
]
else:
scenarios = [
('with touch', dict(input_device_class=Touch))
]
@property
def main_window(self):
return MainWindow(self.app)
def setUp(self):
self.pointing_device = Pointer(self.input_device_class.create())
super(UbuntuTouchAppTestCase, self).setUp()
self.launch_test_qml()
def launch_test_qml(self):
# If the test class has defined a 'test_qml' class attribute then we
# write it to disk and launch it inside the QML Scene. If not, then we
# silently do nothing (presumably the test has something else planned).
arch = subprocess.check_output(["dpkg-architecture",
"-qDEB_HOST_MULTIARCH"]).strip()
if hasattr(self, 'test_qml') and isinstance(self.test_qml, basestring):
qml_path = mktemp(suffix='.qml')
open(qml_path, 'w').write(self.test_qml)
self.addCleanup(remove, qml_path)
self.app = self.launch_test_application(
"/usr/lib/" + arch + "/qt5/bin/qmlscene",
"-I", get_module_include_path(),
qml_path,
app_type='qt')
if hasattr(self, 'test_qml_file') and isinstance(self.test_qml_file, basestring):
qml_path = self.test_qml_file
self.app = self.launch_test_application(
"/usr/lib/" + arch + "/qt5/bin/qmlscene",
"-I", get_module_include_path(),
qml_path,
app_type='qt')
self.assertThat(self.get_qml_view().visible, Eventually(Equals(True)))
def get_qml_view(self):
"""Get the main QML view"""
return self.app.select_single("QQuickView")
def get_mainview(self):
"""Get the QML MainView"""
mainView = self.app.select_single("MainView")
self.assertThat(mainView, Not(Is(None)))
return mainView
def get_object(self,objectName):
"""Get a object based on the objectName"""
obj = self.app.select_single(objectName=objectName)
self.assertThat(obj, Not(Is(None)))
return obj
def mouse_click(self,objectName):
"""Move mouse on top of the object and click on it"""
obj = self.get_object(objectName)
self.pointing_device.move_to_object(obj)
self.pointing_device.click()
def mouse_press(self,objectName):
"""Move mouse on top of the object and press mouse button (without releasing it)"""
obj = self.get_object(objectName)
self.pointing_device.move_to_object(obj)
self.pointing_device.press()
def mouse_release(self):
"""Release mouse button"""
self.pointing_device.release()
def type_string(self, string):
"""Type a string with keyboard"""
self.keyboard.type(string)
#.........这里部分代码省略.........
示例7: SaucyBaconTestCase
# 需要导入模块: from autopilot.input import Pointer [as 别名]
# 或者: from autopilot.input.Pointer import move_to_object [as 别名]
class SaucyBaconTestCase(AutopilotTestCase):
"""A common test case class that provides several useful methods for the tests."""
if model() == 'Desktop':
scenarios = [
('with mouse', dict(input_device_class=Mouse))
]
else:
scenarios = [
('with touch', dict(input_device_class=Touch))
]
local_location = get_qml_location() + "/saucybacon.qml"
@property
def main_window(self):
return MainWindow(self.app)
def setUp(self):
self.pointing_device = Pointer(self.input_device_class.create())
super(SaucyBaconTestCase, self).setUp()
print self.local_location
print get_module_include_path()
if os.path.exists(self.local_location):
self.launch_test_local()
elif os.path.exists('/usr/share/saucybacon/app/saucybacon.qml'):
self.launch_test_installed()
else:
self.launch_test_click()
def launch_test_local(self):
self.app = self.launch_test_application(
"qmlscene",
self.local_location,
"-I",
get_module_include_path(),
app_type='qt',
emulator_base=toolkit_emulators.UbuntuUIToolkitEmulatorBase)
def launch_test_installed(self):
self.app = self.launch_test_application(
"qmlscene",
"/usr/share/postino/postino.qml",
"--desktop_file_hint=/usr/share/applications/saucybacon.desktop",
app_type='qt',
emulator_base=toolkit_emulators.UbuntuUIToolkitEmulatorBase)
def launch_test_click(self):
self.app = self.launch_click_package(
'com.ubuntu.developers.gcollura.saucybacon',
emulator_base=toolkit_emulators.UbuntuUIToolkitEmulatorBase)
def get_qml_view(self):
"""Get the main QML view"""
return self.app.select_single("QQuickView")
def get_mainview(self):
"""Get the QML MainView"""
mainView = self.app.select_single("MainView")
self.assertThat(mainView, Not(Is(None)))
return mainView
def get_object(self,objectName):
"""Get a object based on the objectName"""
obj = self.app.select_single(objectName=objectName)
self.assertThat(obj, Not(Is(None)))
return obj
def mouse_click(self,objectName):
"""Move mouse on top of the object and click on it"""
obj = self.get_object(objectName)
self.pointing_device.move_to_object(obj)
self.pointing_device.click()
def mouse_press(self,objectName):
"""Move mouse on top of the object and press mouse button (without releasing it)"""
obj = self.get_object(objectName)
self.pointing_device.move_to_object(obj)
self.pointing_device.press()
def mouse_release(self):
"""Release mouse button"""
self.pointing_device.release()
def type_string(self, string):
"""Type a string with keyboard"""
#.........这里部分代码省略.........
示例8: CustomInstallTests
# 需要导入模块: from autopilot.input import Pointer [as 别名]
# 或者: from autopilot.input.Pointer import move_to_object [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()
#.........这里部分代码省略.........