本文整理汇总了Python中PySide.QtTest.QTest.mouseClick方法的典型用法代码示例。如果您正苦于以下问题:Python QTest.mouseClick方法的具体用法?Python QTest.mouseClick怎么用?Python QTest.mouseClick使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PySide.QtTest.QTest
的用法示例。
在下文中一共展示了QTest.mouseClick方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_send_pushButton_will_warn_the_user_to_set_the_media_files_path_if_it_is_not_set_before
# 需要导入模块: from PySide.QtTest import QTest [as 别名]
# 或者: from PySide.QtTest.QTest import mouseClick [as 别名]
def test_send_pushButton_will_warn_the_user_to_set_the_media_files_path_if_it_is_not_set_before(self):
"""testing if send_pushButton will warn the user to set the media files
path in preferences if it is not set before
"""
# set a proper EDL file
edl_path = os.path.abspath('../previs/test_data/test_v001.edl')
self.dialog.edl_path_lineEdit.setText(edl_path)
# patch QMessageBox.critical method
original = QtGui.QMessageBox.critical
QtGui.QMessageBox = PatchedMessageBox
self.assertEqual(PatchedMessageBox.called_function, '')
self.assertEqual(PatchedMessageBox.title, '')
self.assertEqual(PatchedMessageBox.message, '')
# now hit it
QTest.mouseClick(self.dialog.send_pushButton, Qt.LeftButton)
# restore QMessageBox.critical
QtGui.QMessageBox.critical = original
self.assertEqual(PatchedMessageBox.called_function, 'critical')
self.assertEqual(PatchedMessageBox.title, 'Error')
self.assertEqual(
"Media path doesn't exists",
PatchedMessageBox.message
)
示例2: test_copy_button_clicked_with_no_selection_on_to_task_tree_view
# 需要导入模块: from PySide.QtTest import QTest [as 别名]
# 或者: from PySide.QtTest.QTest import mouseClick [as 别名]
def test_copy_button_clicked_with_no_selection_on_to_task_tree_view(self):
"""testing if a QMessageDialog will be displayed when the copy button
selected and no selection is made in to_task_tree_vie
"""
# select one task in from_task_tree_view
# Select Task4 in from_task_tree_view
selection_model = self.dialog.from_task_tree_view.selectionModel()
model = self.dialog.from_task_tree_view.model()
project1_item = model.item(0, 0)
self.dialog.from_task_tree_view.expand(project1_item.index())
task1_item = project1_item.child(0, 0)
self.dialog.from_task_tree_view.expand(task1_item.index())
task4_item = task1_item.child(0, 0)
selection_model.select(
task4_item.index(),
QtGui.QItemSelectionModel.Select
)
self.assertEqual(PatchedMessageBox.called_function, '')
# now try to copy it
QTest.mouseClick(self.dialog.copy_push_button, Qt.LeftButton)
self.assertEqual(PatchedMessageBox.called_function, 'critical')
self.assertEqual(PatchedMessageBox.title, 'Error')
self.assertEqual(PatchedMessageBox.message,
'Please select a task from <b>To Task</b> list')
示例3: test_place_item
# 需要导入模块: from PySide.QtTest import QTest [as 别名]
# 或者: from PySide.QtTest.QTest import mouseClick [as 别名]
def test_place_item(self):
"""
Tests the workflow of placing an item
"""
# Make sure the dockwidget is out of the way
self.mw.history_dock_widget.hide()
# Select insertion mode
QTest.keyClick(self.mw, QtCore.Qt.Key_F2)
self.app.processEvents()
# Place item
QTest.mouseClick(
self.mw._view.viewport(),
QtCore.Qt.LeftButton,
pos=self.mw._view.geometry().center()
)
self.app.processEvents()
logic_item_count = 0
for item in self.mw._view.scene().items():
if isinstance(item, logicitems.LogicItem):
logic_item_count += 1
self.assertEqual(1, logic_item_count)
示例4: test_clicking_picker_button_opens_picker_window
# 需要导入模块: from PySide.QtTest import QTest [as 别名]
# 或者: from PySide.QtTest.QTest import mouseClick [as 别名]
def test_clicking_picker_button_opens_picker_window(self):
QTest.mouseClick(self.controller.add_button, Qt.LeftButton)
picker_window_open = False
for widget in QApplication.topLevelWidgets():
if isinstance(widget, lyrical.LyricalPicker):
picker_window_open = True
self.assertTrue(picker_window_open)
示例5: test_add_task_without_description
# 需要导入模块: from PySide.QtTest import QTest [as 别名]
# 或者: from PySide.QtTest.QTest import mouseClick [as 别名]
def test_add_task_without_description(self):
itemsBefore = self.form.listWidget.count()
'''ensures AddTaskEdit is empty'''
QTest.keyClicks(self.form.AddTaskEdit, "")
addButton = self.form.AddTaskButton
QTest.mouseClick(addButton, Qt.LeftButton)
'''assert no items were added'''
self.assertEqual(self.form.listWidget.count(), itemsBefore)
示例6: test_add_task_with_description
# 需要导入模块: from PySide.QtTest import QTest [as 别名]
# 或者: from PySide.QtTest.QTest import mouseClick [as 别名]
def test_add_task_with_description(self):
itemsBefore = self.form.listWidget.count()
'''ensures AddTaskEdit contains text'''
QTest.keyClicks(self.form.AddTaskEdit, "task one")
addButton = self.form.AddTaskButton
QTest.mouseClick(addButton, Qt.LeftButton)
'''assert there is one more item'''
self.assertEqual(self.form.listWidget.count(), itemsBefore+1)
示例7: mouseClick
# 需要导入模块: from PySide.QtTest import QTest [as 别名]
# 或者: from PySide.QtTest.QTest import mouseClick [as 别名]
def mouseClick(widget, button, modifier=None, pos=None, delay=-1):
"""Simulate clicking a mouse button.
See QTest.mouseClick for details.
"""
if modifier is None:
modifier = qt.Qt.KeyboardModifiers()
pos = qt.QPoint(pos[0], pos[1]) if pos is not None else qt.QPoint()
QTest.mouseClick(widget, button, modifier, pos, delay)
示例8: test_close_button_closes_ui
# 需要导入模块: from PySide.QtTest import QTest [as 别名]
# 或者: from PySide.QtTest.QTest import mouseClick [as 别名]
def test_close_button_closes_ui(self):
"""testing if the close button is closing the ui
"""
self.dialog.show()
self.assertEqual(self.dialog.isVisible(), True)
# now run the UI
QTest.mouseClick(self.dialog.close_pushButton, Qt.LeftButton)
self.assertEqual(self.dialog.isVisible(), False)
示例9: testBasic
# 需要导入模块: from PySide.QtTest import QTest [as 别名]
# 或者: from PySide.QtTest.QTest import mouseClick [as 别名]
def testBasic(self):
'''QTest.mouseClick with QCheckBox'''
button = QPushButton()
button.setCheckable(True)
button.setChecked(False)
QTest.mouseClick(button, Qt.LeftButton)
self.assert_(button.isChecked())
QTest.mouseClick(button, Qt.LeftButton)
self.assertFalse(button.isChecked())
示例10: test_app_should_write_text_when_sample_button_click
# 需要导入模块: from PySide.QtTest import QTest [as 别名]
# 或者: from PySide.QtTest.QTest import mouseClick [as 别名]
def test_app_should_write_text_when_sample_button_click(simple_app, capsys):
"""
Given: A running app.
When: The init test button is clicked.
Then: A welcome test should return.
"""
button = simple_app.button
QTest.mouseClick(button, QtCore.Qt.LeftButton)
out, err = capsys.readouterr()
assert "Start coding for {{ cookiecutter.repo_name }}" in str(out)
示例11: test_copy_button_clicked_with_no_selection_on_from_task_tree_view
# 需要导入模块: from PySide.QtTest import QTest [as 别名]
# 或者: from PySide.QtTest.QTest import mouseClick [as 别名]
def test_copy_button_clicked_with_no_selection_on_from_task_tree_view(self):
"""testing if a QMessageDialog will be displayed when the copy button
selected and no selection is made in from_task_tree_view
"""
self.assertEqual(PatchedMessageBox.called_function, '')
# now try to copy it
QTest.mouseClick(self.dialog.copy_push_button, Qt.LeftButton)
self.assertEqual(PatchedMessageBox.called_function, 'critical')
self.assertEqual(PatchedMessageBox.title, 'Error')
self.assertEqual(PatchedMessageBox.message,
'Please select a task from <b>From Task</b> list')
示例12: test_add_two_tasks_correct_size
# 需要导入模块: from PySide.QtTest import QTest [as 别名]
# 或者: from PySide.QtTest.QTest import mouseClick [as 别名]
def test_add_two_tasks_correct_size(self):
itemsBefore = self.form.listWidget.count()
currentHeight = self.form.listWidget.parentWidget().size().height()
'''ensures AddTaskEdit contains text'''
QTest.keyClicks(self.form.AddTaskEdit, "task one")
addButton = self.form.AddTaskButton
QTest.mouseClick(addButton, Qt.LeftButton)
QTest.mouseClick(addButton, Qt.LeftButton)
'''assert there is two more items, and size grew'''
self.assertEqual(self.form.listWidget.count(), itemsBefore+2)
newHeight = self.form.listWidget.parentWidget().size().height()
twoLines = 2*21
twoSpaces = 2*2
self.assertEqual(currentHeight+twoLines+twoSpaces, newHeight)
示例13: test_copy_button_clicked_with_same_task_is_selected_in_both_sides
# 需要导入模块: from PySide.QtTest import QTest [as 别名]
# 或者: from PySide.QtTest.QTest import mouseClick [as 别名]
def test_copy_button_clicked_with_same_task_is_selected_in_both_sides(self):
"""testing if a QMessageDialog will warn the user about he/she selected
the same task in both tree views
"""
# select one task in from_task_tree_view
# Select Task4 in from_task_tree_view
selection_model = self.dialog.from_task_tree_view.selectionModel()
model = self.dialog.from_task_tree_view.model()
project1_item = model.item(0, 0)
self.dialog.from_task_tree_view.expand(project1_item.index())
task1_item = project1_item.child(0, 0)
self.dialog.from_task_tree_view.expand(task1_item.index())
task4_item = task1_item.child(0, 0)
selection_model.select(
task4_item.index(),
QtGui.QItemSelectionModel.Select
)
# Select Task4 in to_task_tree_view
selection_model = self.dialog.to_task_tree_view.selectionModel()
model = self.dialog.to_task_tree_view.model()
project1_item = model.item(0, 0)
self.dialog.to_task_tree_view.expand(project1_item.index())
task1_item = project1_item.child(0, 0)
self.dialog.to_task_tree_view.expand(task1_item.index())
task4_item = task1_item.child(0, 0)
selection_model.select(
task4_item.index(),
QtGui.QItemSelectionModel.Select
)
self.assertEqual(PatchedMessageBox.called_function, '')
# now try to copy it
QTest.mouseClick(self.dialog.copy_push_button, Qt.LeftButton)
self.assertEqual(PatchedMessageBox.called_function, 'critical')
self.assertEqual(PatchedMessageBox.title, 'Error')
self.assertEqual(PatchedMessageBox.message,
'Please select two different tasks')
示例14: test_lulu_about_qt_box
# 需要导入模块: from PySide.QtTest import QTest [as 别名]
# 或者: from PySide.QtTest.QTest import mouseClick [as 别名]
def test_lulu_about_qt_box(self):
"""
Tests whether the about Qt dialog opens correctly via the menu
"""
# Make sure the dock widget is out of the way
self.mw.history_dock_widget.hide()
# Open file menu
QTest.mouseClick(
self.mw.menu_bar,
QtCore.Qt.LeftButton,
pos=self.mw.menu_bar.actionGeometry(
self.mw.menu_help.menuAction()).center())
self.assertTrue(self.mw.menu_help.isVisible())
# As the modal about dialog will block in it's event queue,
# queue the check itself.
called = False
def check_open_and_dismiss(window):
nonlocal called
self.assertIsInstance(window, QtGui.QMessageBox)
QTest.keyClick(window, QtCore.Qt.Key_Escape)
QtGui.QApplication.instance().processEvents()
called = True
delayed_perform_on_modal(check_open_and_dismiss)
# Click about
QTest.mouseClick(
self.mw.menu_help,
QtCore.Qt.LeftButton,
pos=self.mw.menu_help.actionGeometry(
self.mw.action_about_qt).center())
#
# Modal event queue running here until dialog is dismissed
#
self.assertTrue(called)
def is_main_window_active_yet():
self.app.processEvents()
return self.app.activeWindow() == self.mw
try_repeatedly(is_main_window_active_yet)
self.assertEqual(self.app.activeWindow(), self.mw)
示例15: test_update_pushButton_will_call_environment_update_versions_method
# 需要导入模块: from PySide.QtTest import QTest [as 别名]
# 或者: from PySide.QtTest.QTest import mouseClick [as 别名]
def test_update_pushButton_will_call_environment_update_versions_method(self):
"""testing if update_pushButton will call
Test_Environment.update_versions method
"""
self.assertRaises(
KeyError,
self.test_environment.test_data.__getitem__, 'update_versions'
)
# self.show_dialog(self.dialog)
QTest.mouseClick(self.dialog.update_pushButton, Qt.LeftButton)
#print self.test_environment.test_data
self.assertEqual(
1,
self.test_environment.test_data['update_versions']['call_count']
)