diff options
Diffstat (limited to 'sources/pyside2/tests')
4 files changed, 67 insertions, 12 deletions
diff --git a/sources/pyside2/tests/QtCore/qsettings_test.py b/sources/pyside2/tests/QtCore/qsettings_test.py index 982ddc38d..639f6d276 100644 --- a/sources/pyside2/tests/QtCore/qsettings_test.py +++ b/sources/pyside2/tests/QtCore/qsettings_test.py @@ -75,10 +75,7 @@ class TestQSettings(unittest.TestCase): # Handling zero value r = settings.value('zero_value') - if py3k.IS_PY3K: - self.assertEqual(type(r), int) - else: - self.assertEqual(type(r), long) + self.assertEqual(type(r), int) r = settings.value('zero_value', type=int) self.assertEqual(type(r), int) diff --git a/sources/pyside2/tests/QtWebEngineWidgets/fox.html b/sources/pyside2/tests/QtWebEngineWidgets/fox.html new file mode 100644 index 000000000..da873b1cc --- /dev/null +++ b/sources/pyside2/tests/QtWebEngineWidgets/fox.html @@ -0,0 +1,7 @@ +<html> +<title>Title</title> +<meta name="description" content="PySide Test METADATA." /> +<body> +<p>The quick <b>brown</b> fox <i>jumps</i> over the lazy dog.</p> +</body> +</html> diff --git a/sources/pyside2/tests/QtWebEngineWidgets/pyside-474-qtwebengineview.py b/sources/pyside2/tests/QtWebEngineWidgets/pyside-474-qtwebengineview.py index a40e29887..c650a21d0 100644 --- a/sources/pyside2/tests/QtWebEngineWidgets/pyside-474-qtwebengineview.py +++ b/sources/pyside2/tests/QtWebEngineWidgets/pyside-474-qtwebengineview.py @@ -28,24 +28,59 @@ from __future__ import print_function +from functools import partial import os import sys import unittest -sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) +TEST_DIR = os.path.dirname(os.path.abspath(__file__)) + +sys.path.append(os.path.dirname(TEST_DIR)) from init_paths import init_test_paths init_test_paths(False) -from PySide2 import QtWidgets -from PySide2 import QtWebEngineWidgets +from PySide2.QtCore import QCoreApplication, QSize, QUrl, Qt +from PySide2.QtWidgets import QApplication, QVBoxLayout, QWidget +from PySide2.QtWebEngineWidgets import QWebEnginePage, QWebEngineView + class MainTest(unittest.TestCase): def test_WebEngineView_findText_exists(self): - qApp = (QtWidgets.QApplication.instance() or - QtWidgets.QApplication([])) - view = QtWebEngineWidgets.QWebEngineView() - view.findText("nothing") + QCoreApplication.setAttribute(Qt.AA_EnableHighDpiScaling) + app = QApplication.instance() or QApplication() + top_level = QWidget() + layout = QVBoxLayout(top_level) + self._view = QWebEngineView() + self._view.loadFinished.connect(self.loaded) + self._view.load(QUrl.fromLocalFile(os.path.join(TEST_DIR, "fox.html"))) + self._view.setMinimumSize(QSize(400, 300)) + self._callback_count = 0 + layout.addWidget(self._view) + top_level.show() + app.exec_() + + def found_callback(self, found): + self.assertTrue(found) + self._callback_count += 1 + if self._callback_count == 2: + QCoreApplication.quit() + + def javascript_callback(self, result): + self.assertEqual(result, "Title") + self._callback_count += 1 + if self._callback_count == 2: + QCoreApplication.quit() + + def loaded(self, ok): + self.assertTrue(ok) + if not ok: + QCoreApplication.quit() + self._view.page().runJavaScript("document.title", 1, + partial(self.javascript_callback)) + self._view.findText("fox", QWebEnginePage.FindFlags(), + partial(self.found_callback)) + if __name__ == '__main__': unittest.main() diff --git a/sources/pyside2/tests/pysidetest/delegatecreateseditor_test.py b/sources/pyside2/tests/pysidetest/delegatecreateseditor_test.py index 1378ca8ad..111d4ebbf 100644 --- a/sources/pyside2/tests/pysidetest/delegatecreateseditor_test.py +++ b/sources/pyside2/tests/pysidetest/delegatecreateseditor_test.py @@ -39,7 +39,10 @@ init_test_paths(True) from helper.usesqapplication import UsesQApplication from testbinding import TestView from PySide2.QtCore import Qt -from PySide2.QtWidgets import QAbstractItemDelegate, QComboBox +from PySide2.QtGui import QStandardItem, QStandardItemModel +from PySide2.QtWidgets import (QAbstractItemDelegate, QComboBox, + QSpinBox, QStyledItemDelegate, + QStyleOptionViewItem, QWidget) id_text = 'This is me' @@ -83,6 +86,19 @@ class EditorCreatedByDelegateTest(UsesQApplication): self.assertEqual(editor.itemData(0, Qt.DisplayRole), id_text) editor.metaObject() + def testIntDelegate(self): + """PYSIDE-1250: When creating a QVariant, use int instead of long long + for anything that fits into a int. Verify by checking that a spin + box is created as item view editor for int.""" + item = QStandardItem() + item.setData(123123, Qt.EditRole) # <-- QVariant conversion here + model = QStandardItemModel() + model.appendRow(item) + style_option = QStyleOptionViewItem() + delegate = QStyledItemDelegate() + editor = delegate.createEditor(None, style_option, model.index(0, 0)) + self.assertEqual(type(editor), QSpinBox) + if __name__ == '__main__': unittest.main() |