diff options
author | Alexandre Marie <alexandre.marie@synchrotron-soleil.fr> | 2018-12-17 12:28:24 +0100 |
---|---|---|
committer | Alexandre Marie <alexandre.marie@synchrotron-soleil.fr> | 2018-12-17 12:28:24 +0100 |
commit | cebdc9244c019224846cb8d2668080fe386a6adc (patch) | |
tree | aedec55da0f9dd4fc4d6c7eb0f58489a956e2e8c /silx/gui/test/test_qt.py | |
parent | 159ef14fb9e198bb0066ea14e6b980f065de63dd (diff) |
New upstream version 0.9.0+dfsg
Diffstat (limited to 'silx/gui/test/test_qt.py')
-rw-r--r-- | silx/gui/test/test_qt.py | 63 |
1 files changed, 60 insertions, 3 deletions
diff --git a/silx/gui/test/test_qt.py b/silx/gui/test/test_qt.py index 3a89a33..0d10620 100644 --- a/silx/gui/test/test_qt.py +++ b/silx/gui/test/test_qt.py @@ -1,7 +1,7 @@ # coding: utf-8 # /*########################################################################## # -# Copyright (c) 2016 European Synchrotron Radiation Facility +# Copyright (c) 2016-2018 European Synchrotron Radiation Facility # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal @@ -33,9 +33,13 @@ import os.path import unittest from silx.test.utils import temp_dir -from silx.gui.test.utils import TestCaseQt +from silx.gui.utils.testutils import TestCaseQt from silx.gui import qt +try: + from silx.gui.qt import inspect as qt_inspect +except ImportError: + qt_inspect = None class TestQtWrapper(unittest.TestCase): @@ -92,6 +96,32 @@ class TestLoadUi(TestCaseQt): <string>Button 2</string> </property> </widget> + <widget class="Line" name="line"> + <property name="geometry"> + <rect> + <x>10</x> + <y>90</y> + <width>118</width> + <height>3</height> + </rect> + </property> + <property name="orientation"> + <enum>Qt::Horizontal</enum> + </property> + </widget> + <widget class="Line" name="line_2"> + <property name="geometry"> + <rect> + <x>150</x> + <y>20</y> + <width>3</width> + <height>61</height> + </rect> + </property> + <property name="orientation"> + <enum>Qt::Vertical</enum> + </property> + </widget> </widget> <widget class="QMenuBar" name="menubar"> <property name="geometry"> @@ -110,6 +140,7 @@ class TestLoadUi(TestCaseQt): </ui> """ + @unittest.skipIf(qt.BINDING == "PySide", "Not fully working with PySide") def testLoadUi(self): """Create a QMainWindow from an ui file""" with temp_dir() as tmp: @@ -132,9 +163,35 @@ class TestLoadUi(TestCaseQt): testMainWindow.close() +class TestQtInspect(unittest.TestCase): + """Test functions of silx.gui.qt.inspect module""" + + # shiboken module is not always available + @unittest.skipIf(qt.BINDING == 'PySide' and qt_inspect is None, + reason="shiboken module not available") + def test(self): + """Test functions of silx.gui.qt.inspect module""" + self.assertIsNotNone(qt_inspect) + + parent = qt.QObject() + + self.assertTrue(qt_inspect.isValid(parent)) + self.assertTrue(qt_inspect.createdByPython(parent)) + self.assertTrue(qt_inspect.ownedByPython(parent)) + + obj = qt.QObject(parent) + + self.assertTrue(qt_inspect.isValid(obj)) + self.assertTrue(qt_inspect.createdByPython(obj)) + self.assertFalse(qt_inspect.ownedByPython(obj)) + + del parent + self.assertFalse(qt_inspect.isValid(obj)) + + def suite(): test_suite = unittest.TestSuite() - for TestCaseCls in (TestQtWrapper, TestLoadUi): + for TestCaseCls in (TestQtWrapper, TestLoadUi, TestQtInspect): test_suite.addTest( unittest.defaultTestLoader.loadTestsFromTestCase(TestCaseCls)) return test_suite |