本文整理汇总了Python中autopilot.input.Pointer.drag方法的典型用法代码示例。如果您正苦于以下问题:Python Pointer.drag方法的具体用法?Python Pointer.drag怎么用?Python Pointer.drag使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类autopilot.input.Pointer
的用法示例。
在下文中一共展示了Pointer.drag方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_hiding
# 需要导入模块: from autopilot.input import Pointer [as 别名]
# 或者: from autopilot.input.Pointer import drag [as 别名]
def test_hiding(self):
"""Verify that the keyboard remains hidden after being dismissed from
a field that is no longer enabled.
"""
qml = dedent("""
import QtQuick 2.4
import Ubuntu.Components 1.1
import Ubuntu.Web 0.2
Rectangle {
id: window
objectName: "windowRectangle"
color: "lightgrey"
WebView {
anchors.fill: parent
objectName: "webview"
Component.onCompleted: {
loadHtml("
<html><body><div id='scroll' style='width: 100%;
height: 200%; position: absolute; background: green;
visibility: hidden;'></div><input id='input'
style='height: 50%; width: 100%' type='text'
onkeyup=\\\"if (event.keyCode == 13)
{document.getElementById('input').disabled=true;
document.getElementById('scroll').style.visibility=
'visible';}\\\" style='width: 100%%;
height: 100%%;' /></body></html>");
}
}
}
""")
app = self._start_qml_script(qml)
webview = app.select_single(objectName='webview')
self.ensure_focus_on_input(webview)
keyboard = Keyboard()
self.addCleanup(keyboard.dismiss)
keyboard.type('Test\n')
keyboard.dismiss()
pointer = Pointer(Touch.create())
pointer.drag(
webview.width / 2.0,
webview.height / 2.0,
webview.width / 2.0,
webview.height / 2.0 + 100
)
self.assertThat(
keyboard.is_available,
Eventually(Equals(False))
)
示例2: _select_extended_key
# 需要导入模块: from autopilot.input import Pointer [as 别名]
# 或者: from autopilot.input.Pointer import drag [as 别名]
def _select_extended_key(self, key_rect, offset, pointer=None):
if pointer is None:
pointer = Pointer(Touch.create())
gu = float(os.environ.get('GRID_UNIT_PX', 8))
pointer.drag(
key_rect.x + key_rect.w / 2.0,
key_rect.y + key_rect.h / 2.0,
key_rect.x + key_rect.w / 2.0 + offset,
key_rect.y + key_rect.h / 2.0,
rate=2.77 * gu, time_between_events=2)
示例3: Keyboard
# 需要导入模块: from autopilot.input import Pointer [as 别名]
# 或者: from autopilot.input.Pointer import drag [as 别名]
class Keyboard(object):
"""Emulator that provides the OSK as an input backend."""
_action_to_label = {
'SHIFT': 'shift',
'\b': 'backspace',
'ABC': 'symbols',
'?123': 'symbols',
' ': 'space',
'\n': 'return',
}
__maliit = None
def __init__(self, pointer=None):
try:
self.orientation = self.maliit.select_single(
"OrientationHelper"
)
except ValueError as e:
e.args += (
"More than one OrientationHelper object was found, aborting.",
)
raise
except StateNotFoundError:
logger.error("Unable to find the Orientation Helper, aborting.")
raise
try:
self.keyboard = self.maliit.select_single(
"QQuickItem",
objectName="ubuntuKeyboard"
)
except ValueError as e:
e.args += (
"There was more than one Keyboard object found, aborting.",
)
raise
except StateNotFoundError:
logger.error(
"Unable to find the Ubuntu Keyboard object within the "
"maliit server, aborting."
)
raise
self._keyboard_container = self.keyboard.select_single(
"KeyboardContainer"
)
self._stored_active_keypad_name = None
self._active_keypad = None
self._keys_position = defaultdict(dict)
self._keys_contained = defaultdict(dict)
self._store_current_orientation()
if pointer is None:
self.pointer = Pointer(Touch.create())
else:
self.pointer = pointer
@property
def maliit(self):
# We cache __mallit_server as a class attribute because
# get_proxy_object_for_existing_process clears backends for proxy
# objects, this means that if this is called twice within a test the
# first keyboard object created has now lost all its _Backends.
if Keyboard.__maliit is None:
try:
Keyboard.__maliit = get_proxy_object_for_existing_process(
connection_name='org.maliit.server',
emulator_base=UbuntuKeyboardEmulatorBase
)
if Keyboard.__maliit is None:
raise RuntimeError("Maliit Server could not be found.")
except ProcessSearchError as e:
e.args += (
"Unable to find maliit-server dbus object. Has it been "
"started with introspection enabled?",
)
raise
return Keyboard.__maliit
def dismiss(self):
"""Swipe the keyboard down to hide it.
:raises: *AssertionError* if the state.wait_for fails meaning that the
keyboard failed to hide.
"""
if self.is_available():
x, y, h, w = self._keyboard_container.globalRect
x_pos = int(w / 2)
# start_y: just inside the keyboard, must be a better way than +1px
start_y = y - 10
end_y = y + int(h / 2)
self.pointer.drag(x_pos, start_y, x_pos, end_y)
#.........这里部分代码省略.........
示例4: Keyboard
# 需要导入模块: from autopilot.input import Pointer [as 别名]
# 或者: from autopilot.input.Pointer import drag [as 别名]
class Keyboard(object):
"""Emulator that provides the OSK as an input backend."""
_action_to_label = {
'SHIFT': 'shift',
'\b': 'backspace',
'ABC': 'symbols',
'?123': 'symbols',
' ': 'space',
'\n': 'return',
'Enter': 'return',
'Backspace': 'backspace',
'Space': 'space',
'Shift': 'shift',
}
__maliit = None
def __init__(self, pointer=None):
try:
self.keyboard = self.maliit.select_single(
"QQuickItem",
objectName="ubuntuKeyboard"
)
except ValueError as e:
e.args += (
"There was more than one Keyboard object found, aborting.",
)
raise
except StateNotFoundError:
logger.error(
"Unable to find the Ubuntu Keyboard object within the "
"maliit server, aborting."
)
raise
self._keyboard_container = self.keyboard.select_single(
"KeyboardContainer"
)
self._stored_active_keypad_name = None
self._active_keypad = None
self._keys_position = defaultdict(dict)
self._keys_contained = defaultdict(dict)
if pointer is None:
self.pointer = Pointer(Touch.create())
else:
self.pointer = pointer
@property
def maliit(self):
# We cache __mallit_server as a class attribute because
# get_proxy_object_for_existing_process clears backends for proxy
# objects, this means that if this is called twice within a test the
# first keyboard object created has now lost all its _Backends.
if Keyboard.__maliit is None:
try:
Keyboard.__maliit = get_proxy_object_for_existing_process(
connection_name='org.maliit.server',
emulator_base=toolkit.UbuntuUIToolkitCustomProxyObjectBase
)
if Keyboard.__maliit is None:
raise RuntimeError("Maliit Server could not be found.")
except ProcessSearchError as e:
e.args += (
"Unable to find maliit-server dbus object. Has it been "
"started with introspection enabled?",
)
raise
return Keyboard.__maliit
def dismiss(self):
"""Swipe the keyboard down to hide it.
:raises: *AssertionError* if the state.wait_for fails meaning that the
keyboard failed to hide.
"""
if self.is_available():
x, y, h, w = self._keyboard_container.globalRect
x_pos = int(w / 2)
start_y = y + int(h / 2.5)
end_y = y + h
self.pointer.drag(x_pos, start_y, x_pos, end_y)
self.keyboard.state.wait_for("HIDDEN")
def is_available(self):
"""Returns true if the keyboard is shown and ready to use."""
return (self.keyboard.state == "SHOWN")
# Much like is_available, but attempts to wait for the keyboard to be
# ready.
def wait_for_keyboard_ready(self, timeout=10):
"""Waits for *timeout* for the keyboard to be ready and returns
true. Returns False if the keyboard fails to be considered ready within
the alloted time.
#.........这里部分代码省略.........