Example #1
0
    def testQMLFunctionCall(self):
        app = QtGui.QGuiApplication(sys.argv)
        view = QtQuick.QQuickView()

        obj = PythonObject()
        context = view.rootContext()
        context.setContextProperty("python", obj)
        view.setSource(
            QtCore.QUrl.fromLocalFile(adjust_filename('bug_451.qml',
                                                      __file__)))
        root = view.rootObject()
        root.simpleFunction()
        self.assertEqual(obj.called, "simpleFunction")

        root.oneArgFunction(42)
        self.assertEqual(obj.called, "oneArgFunction")
        self.assertEqual(obj.arg1, 42)

        root.twoArgFunction(10, app)
        self.assertEqual(obj.called, "twoArgFunction")
        self.assertEqual(obj.arg1, 10)
        self.assertEqual(obj.arg2, app)

        rvalue = root.returnFunction()
        self.assertEqual(obj.called, "returnFunction")
        self.assertEqual(rvalue, 42)
Example #2
0
    def testIt(self):
        app = QApplication([])

        loader = QUiLoader()
        widget = loader.load(adjust_filename('bug_913.ui', __file__))
        widget.tabWidget.currentIndex() # direct child is available as member
        widget.le_first.setText('foo') # child of QTabWidget must also be available!
Example #3
0
 def testMetaData(self):
     self.view = QWebView()
     QObject.connect(self.view, SIGNAL('loadFinished(bool)'),
                     self.load_finished)
     url = QUrl.fromLocalFile(adjust_filename('fox.html', __file__))
     self.view.setUrl(url)
     self.app.exec_()
Example #4
0
 def testMetaData(self):
     self.view = QWebView()
     QObject.connect(self.view, SIGNAL('loadFinished(bool)'),
                     self.load_finished)
     url = QUrl.fromLocalFile(adjust_filename('fox.html', __file__))
     self.view.setUrl(url)
     self.app.exec_()
Example #5
0
 def testDictionary(self):
     s = QSettings(adjust_filename('bug_829.conf', __file__), QSettings.IniFormat)
     #Save value 
     s.setValue('x', {1: 'a'})
     s.sync()
     #Restore value
     self.assertEqual(s.value('x'), {1: 'a'})
Example #6
0
 def testAbstractItemModelTransferToQML(self):
     view = QQuickView()
     view.setSource(QUrl.fromLocalFile(adjust_filename('bug_814.qml', __file__)))
     root = view.rootObject()
     model = ListModel()
     root.setProperty('model', model)
     view.show()
    def testIncubateWhileCall(self):
        app = QGuiApplication(sys.argv)
        view = QQuickView()
        controller = CustomIncubationController(self)
        view.engine().setIncubationController(controller)
        view.setResizeMode(QQuickView.SizeRootObjectToView)
        view.setSource(
            QUrl.fromLocalFile(
                adjust_filename('qqmlincubator_incubateWhile.qml', __file__)))
        view.show()

        root = view.rootObject()
        # The QML code will issue an interrupt signal after half of its items are loaded.
        root.shouldInterrupt.connect(controller.interrupter)
        res = app.exec_()

        itemsToCreate = root.property("itemsToCreate")
        loadedItems = root.property("loadedItems")
        self.assertEqual(loadedItems, itemsToCreate / 2)

        # Finish incubating the remaining items.
        controller.incubateFor(1000)
        loadedItems = root.property("loadedItems")
        self.assertEqual(loadedItems, itemsToCreate)

        # Deleting the view before it goes out of scope is required to make sure all child QML
        # instances are destroyed in the correct order.
        del view
        del app
Example #8
0
 def testAbstractItemModelTransferToQML(self):
     view = QQuickView()
     model = ListModel()
     view.rootContext().setContextProperty("pythonModel", model)
     view.setSource(QUrl.fromLocalFile(adjust_filename('bug_814.qml', __file__)))
     root = view.rootObject()
     view.show()
Example #9
0
    def testIt(self):
        app = QApplication([])

        loader = QUiLoader()
        widget = loader.load(adjust_filename('bug_913.ui', __file__))
        widget.tabWidget.currentIndex() # direct child is available as member
        widget.le_first.setText('foo') # child of QTabWidget must also be available!
Example #10
0
    def testSignalEmission(self):
        qmlRegisterType(MyItem, "my.item", 1, 0, "MyItem")

        view = QDeclarativeView()
        view.setSource(QUrl.fromLocalFile(adjust_filename('bug_951.qml', __file__)))

        self.app.exec_()
        self.assertTrue(MyItem.COMPONENT_COMPLETE_CALLED)
Example #11
0
 def testAbstractItemModelTransferToQML(self):
     view = QDeclarativeView()
     view.setSource(
         QUrl.fromLocalFile(adjust_filename('bug_814.qml', __file__)))
     root = view.rootObject()
     model = ListModel()
     root.setProperty('model', model)
     view.show()
Example #12
0
    def __init__(self, parent=None):
        super(Gui_Qt, self).__init__(parent)

        lLoader = QtUiTools.QUiLoader()

        # this used to cause a segfault because the old inject code used to destroy the parent layout
        self._cw = lLoader.load(adjust_filename('bug_958.ui', __file__), self)

        self.setCentralWidget(self._cw)
Example #13
0
 def testIt(self):
     app = QApplication([])
     qmlRegisterType(MyClass,'Example',1,0,'MyClass')
     view = QDeclarativeView()
     view.setSource(QUrl.fromLocalFile(adjust_filename('bug_926.qml', __file__)))
     self.assertEqual(len(view.errors()), 0)
     view.show()
     QTimer.singleShot(0, app.quit)
     app.exec_()
Example #14
0
    def __init__(self, parent=None):
        super(Gui_Qt, self).__init__(parent)

        lLoader = QtUiTools.QUiLoader()

        # this used to cause a segfault because the old inject code used to destroy the parent layout
        self._cw = lLoader.load(adjust_filename('bug_958.ui', __file__),  self)

        self.setCentralWidget(self._cw)
Example #15
0
 def __init__(self):
     QtGui.QWidget.__init__(self)
     loader = QUiLoader()
     widget = loader.load(adjust_filename('bug_552.ui', __file__), self)
     self.children = []
     for child in widget.findChildren(QtCore.QObject, None):
         self.children.append(child)
     self.t = widget.tabWidget
     self.t.removeTab(0)
Example #16
0
 def testIt(self):
     app = QApplication([])
     qmlRegisterType(MyClass,'Example',1,0,'MyClass')
     view = QDeclarativeView()
     view.setSource(QUrl.fromLocalFile(adjust_filename('bug_926.qml', __file__)))
     self.assertEqual(len(view.errors()), 0)
     view.show()
     QTimer.singleShot(0, app.quit)
     app.exec_()
Example #17
0
 def __init__(self):
     QtGui.QWidget.__init__(self)
     loader = QUiLoader()
     widget = loader.load(adjust_filename('bug_552.ui', __file__), self)
     self.children = []
     for child in widget.findChildren(QtCore.QObject, None):
         self.children.append(child)
     self.t = widget.tabWidget
     self.t.removeTab(0)
Example #18
0
    def testBug909(self):
        fileName = QFile(adjust_filename('bug_909.ui', __file__))
        loader = QUiLoader()
        main_win = loader.load(fileName)
        self.assertEqual(sys.getrefcount(main_win), 2)
        fileName.close()

        tw = QTabWidget(main_win)
        main_win.setCentralWidget(tw)
        main_win.show()
Example #19
0
    def testBug909(self):
        fileName = QFile(adjust_filename('bug_909.ui', __file__))
        loader = QUiLoader()
        main_win = loader.load(fileName)
        self.assertEqual(sys.getrefcount(main_win), 2)
        fileName.close()

        tw = QTabWidget(main_win)
        main_win.setCentralWidget(tw)
        main_win.show()
Example #20
0
    def test_qml_type(self):
        qmlRegisterType(TestClass, "JavaScriptExceptions", 1, 0, "JavaScriptExceptions")

        view = QQuickView()
        qml_url = QUrl.fromLocalFile(adjust_filename("javascript_exceptions.qml", __file__))

        view.setSource(qml_url)

        self.assertTrue(test_1)
        self.assertTrue(test_2)
    def testQDeclarativeNetworkFactory(self):
        view = QDeclarativeView()

        url = QUrl.fromLocalFile(adjust_filename('hw.qml', __file__))

        view.setSource(url)
        view.show()

        self.assertEqual(view.status(), QDeclarativeView.Ready)

        self.app.exec_()
    def testQDeclarativeNetworkFactory(self):
        view = QDeclarativeView()

        url = QUrl.fromLocalFile(adjust_filename('hw.qml', __file__))

        view.setSource(url)
        view.show()

        self.assertEqual(view.status(), QDeclarativeView.Ready)

        self.app.exec_()
Example #23
0
    def testIt(self):
        global paintCalled
        app = QApplication([])
        qmlRegisterType(Bug825, 'bugs', 1, 0, 'Bug825')
        self.assertRaises(TypeError, qmlRegisterType, A, 'bugs', 1, 0, 'A')

        view = QDeclarativeView()
        view.setSource(QUrl.fromLocalFile(adjust_filename('bug_825.qml', __file__)))
        view.show()
        QTimer.singleShot(250, view.close)
        app.exec_()
        self.assertTrue(paintCalled)
Example #24
0
    def testModelExport(self):
        view = QQuickView()
        dataList = [MyObject("Item 1"), MyObject("Item 2"), MyObject("Item 3"), MyObject("Item 4")]

        ctxt = view.rootContext()
        ctxt.setContextProperty("myModel", dataList)

        url = QUrl.fromLocalFile(adjust_filename('viewmodel.qml', __file__))
        view.setSource(url)
        view.show()

        self.assertEqual(view.status(), QQuickView.Ready)
    def testModelExport(self):
        view = QDeclarativeView()
        dataList = [MyObject("Item 1"), MyObject("Item 2"), MyObject("Item 3"), MyObject("Item 4")]

        ctxt = view.rootContext()
        ctxt.setContextProperty("myModel", dataList)

        url = QUrl.fromLocalFile(adjust_filename("viewmodel.qml", __file__))
        view.setSource(url)
        view.show()

        self.assertEqual(view.status(), QDeclarativeView.Ready)
Example #26
0
    def testIt(self):
        global paintCalled
        app = QGuiApplication([])
        qmlRegisterType(Bug825, 'bugs', 1, 0, 'Bug825')
        self.assertRaises(TypeError, qmlRegisterType, A, 'bugs', 1, 0, 'A')

        view = QQuickView()
        view.setSource(QUrl.fromLocalFile(adjust_filename('bug_825.qml', __file__)))
        view.show()
        QTimer.singleShot(250, view.close)
        app.exec_()
        self.assertTrue(paintCalled)
Example #27
0
    def testImage(self):
        #Test loading of sample.png resource
        f = open(adjust_filename('sample.png', __file__), "rb")
        orig = f.read()
        f.close()

        f = QFile(':/sample.png')
        f.open(QIODevice.ReadOnly)
        copy = f.readAll()
        f.close()
        self.assertEqual(len(orig), len(copy))
        self.assertEqual(orig, copy)
Example #28
0
    def testPhrase(self):
        #Test loading of quote.txt resource
        f = open(adjust_filename('quoteEnUS.txt', __file__), "r")
        orig = f.read()
        f.close()

        f = QFile(':/quote.txt')
        f.open(QIODevice.ReadOnly) #|QIODevice.Text)
        print("Error:", f.errorString())
        copy = f.readAll()
        f.close()
        self.assertEqual(orig, copy)
Example #29
0
    def testSlotRetur(self):
        view = QtQuick.QQuickView()
        proxy = ProxyObject()

        context = view.rootContext()
        context.setContextProperty("proxy", proxy)
        view.setSource(QtCore.QUrl.fromLocalFile(adjust_filename('bug_726.qml', __file__)))
        root = view.rootObject()
        button = root.findChild(QtCore.QObject, "buttonMouseArea")
        view.show()
        button.entered.emit()
        self.assertEqual(proxy._receivedName, "PySideObject")
Example #30
0
    def test_qml_type(self):
        qmlRegisterType(TestClass, 'JavaScriptExceptions', 1, 0,
                        'JavaScriptExceptions')

        view = QQuickView()
        qml_url = QUrl.fromLocalFile(
            adjust_filename('javascript_exceptions.qml', __file__))

        view.setSource(qml_url)

        self.assertTrue(test_1)
        self.assertTrue(test_2)
Example #31
0
    def testQDeclarativeViewList(self):
        view = QDeclarativeView()

        dataList = ["Item 1", "Item 2", "Item 3", "Item 4"]

        ctxt = view.rootContext()
        ctxt.setContextProperty("myModel", dataList)

        url = QUrl.fromLocalFile(adjust_filename('view.qml', __file__))
        view.setSource(url)
        view.show()

        self.assertEqual(view.status(), QDeclarativeView.Ready)
 def testFailConnection(self):
     self.buttonClicked = False
     self.buttonFailClicked = False
     view = QtQuick.QQuickView()
     view.setSource(QtCore.QUrl.fromLocalFile(adjust_filename('connect_python_qml.qml', __file__)))
     root = view.rootObject()
     button = root.findChild(QtCore.QObject, "buttonMouseArea")
     self.assertRaises(TypeError, QtCore.QObject.connect, [button,QtCore.SIGNAL('entered()'), self.onButtonFailClicked])
     button.entered.connect(self.onButtonClicked)
     button.entered.emit()
     view.show()
     self.app.exec_()
     self.assertTrue(self.buttonClicked)
Example #33
0
    def testIt(self):
        app = QApplication([])

        qmlRegisterType(PieChart, 'Charts', 1, 0, 'PieChart');
        qmlRegisterType(PieSlice, "Charts", 1, 0, "PieSlice");

        view = QDeclarativeView()
        view.setSource(QUrl.fromLocalFile(helper.adjust_filename('registertype.qml', __file__)))
        view.show()
        QTimer.singleShot(250, view.close)
        app.exec_()
        self.assertTrue(appendCalled)
        self.assertTrue(paintCalled)
Example #34
0
    def testIt(self):
        app = QGuiApplication([])

        qmlRegisterType(PieChart, 'Charts', 1, 0, 'PieChart');
        qmlRegisterType(PieSlice, "Charts", 1, 0, "PieSlice");

        view = QQuickView()
        view.setSource(QUrl.fromLocalFile(helper.adjust_filename('registertype.qml', __file__)))
        view.show()
        QTimer.singleShot(250, view.close)
        app.exec_()
        self.assertTrue(appendCalled)
        self.assertTrue(paintCalled)
Example #35
0
 def testFailConnection(self):
     self.buttonClicked = False
     self.buttonFailClicked = False
     view = QtDeclarative.QDeclarativeView()
     view.setSource(QtCore.QUrl.fromLocalFile(adjust_filename('connect_python_qml.qml', __file__)))
     root = view.rootObject()
     button = root.findChild(QtCore.QObject, "buttonMouseArea")
     self.assertRaises(TypeError, QtCore.QObject.connect, [button,QtCore.SIGNAL('entered()'), self.onButtonFailClicked])
     button.entered.connect(self.onButtonClicked)
     button.entered.emit()
     view.show()
     self.app.exec_()
     self.assert_(self.buttonClicked)
Example #36
0
    def testQQuickNetworkFactory(self):
        view = QQuickView()
        self.factory = CustomFactory()
        view.engine().setNetworkAccessManagerFactory(self.factory)

        url = QUrl.fromLocalFile(adjust_filename('hw.qml', __file__))

        view.setSource(url)
        view.show()

        self.assertEqual(view.status(), QQuickView.Ready)

        self.app.exec_()
    def testQDeclarativeViewList(self):
        view = QDeclarativeView()

        dataList = ["Item 1", "Item 2", "Item 3", "Item 4"]

        ctxt = view.rootContext()
        ctxt.setContextProperty("myModel", dataList)

        url = QUrl.fromLocalFile(adjust_filename('view.qml', __file__))
        view.setSource(url)
        view.show()

        self.assertEqual(view.status(), QDeclarativeView.Ready)
Example #38
0
    def testQMLFunctionCall(self):
        ownerData = QtQml.QQmlPropertyMap()
        ownerData.insert("name", "John Smith")
        ownerData.insert("phone", "555-5555")
        ownerData.insert("newValue", "")

        view = QtQuick.QQuickView()
        ctxt = view.rootContext()
        ctxt.setContextProperty("owner", ownerData)
        view.setSource(QtCore.QUrl.fromLocalFile(adjust_filename("bug_997.qml", __file__)))
        view.show()
        QtCore.QTimer.singleShot(1000, self.app.quit)
        self.app.exec_()
        self.assertEqual(ownerData.value("newName"), ownerData.value("name"))
Example #39
0
    def testQMLFunctionCall(self):
        ownerData = QtDeclarative.QDeclarativePropertyMap()
        ownerData.insert('name', 'John Smith')
        ownerData.insert('phone', '555-5555')
        ownerData.insert('newValue', '')

        view = QtDeclarative.QDeclarativeView()
        ctxt = view.rootContext()
        ctxt.setContextProperty('owner', ownerData)
        view.setSource(QtCore.QUrl.fromLocalFile(adjust_filename('bug_997.qml', __file__)))
        view.show()
        QtCore.QTimer.singleShot(1000, self.app.quit)
        self.app.exec_()
        self.assertEqual(ownerData.value('newName'), ownerData.value('name'))
Example #40
0
    def testQMLFunctionCall(self):
        ownerData = QtDeclarative.QDeclarativePropertyMap()
        ownerData.insert('name', 'John Smith')
        ownerData.insert('phone', '555-5555')
        ownerData.insert('newValue', '')

        view = QtDeclarative.QDeclarativeView()
        ctxt = view.rootContext()
        ctxt.setContextProperty('owner', ownerData)
        view.setSource(QtCore.QUrl.fromLocalFile(adjust_filename('bug_997.qml', __file__)))
        view.show()
        QtCore.QTimer.singleShot(1000, self.app.quit)
        self.app.exec_()
        self.assertEqual(ownerData.value('newName'), ownerData.value('name'))
Example #41
0
    def testSlotRetur(self):
        view = QtQuick.QQuickView()
        proxy = ProxyObject()

        context = view.rootContext()
        context.setContextProperty("proxy", proxy)
        view.setSource(
            QtCore.QUrl.fromLocalFile(adjust_filename('bug_726.qml',
                                                      __file__)))
        root = view.rootObject()
        button = root.findChild(QtCore.QObject, "buttonMouseArea")
        view.show()
        button.entered.emit()
        self.assertEqual(proxy._receivedName, "PySideObject")
Example #42
0
    def testPythonSlot(self):
        self._sucess = False
        view = View()

        # Connect first, then set the property.
        view.called.connect(self.done)
        view.setSource(QUrl.fromLocalFile(adjust_filename('bug_847.qml', __file__)))
        view.rootObject().setProperty('pythonObject', view)

        view.show()
        # Essentially a timeout in case method invocation fails.
        QTimer.singleShot(2000, QCoreApplication.instance().quit)
        self.app.exec_()
        self.assertTrue(self._sucess)
    def testSignalArguments(self):
        view = QQuickView()
        obj = Obj()

        context = view.rootContext()
        context.setContextProperty("o", obj)
        view.setSource(
            QUrl.fromLocalFile(
                adjust_filename('signal_arguments.qml', __file__)))
        root = view.rootObject()
        self.assertTrue(root)
        button = root.findChild(QObject, "button")
        view.show()
        button.clicked.emit()
        self.assertEqual(obj.value, 42)
Example #44
0
    def testConversions(self):
        file_path = adjust_filename('qsettings_test.ini', __file__)
        settings = QSettings(file_path, QSettings.IniFormat)

        r = settings.value('var1')
        self.assertEqual(type(r), list)

        r = settings.value('var2')
        if py3k.IS_PY3K:
            self.assertEqual(type(r), str)
        else:
            self.assertEqual(type(r), unicode)

        r = settings.value('var2', type=list)
        self.assertEqual(type(r), list)
Example #45
0
    def testSlotRetur(self):
        view = QtQuick.QQuickView()
        rotatevalue = RotateValue()

        timer = QtCore.QTimer()
        timer.start(2000)

        context = view.rootContext()
        context.setContextProperty("rotatevalue", rotatevalue)
        view.setSource(QtCore.QUrl.fromLocalFile(adjust_filename('bug_456.qml', __file__)))
        root = view.rootObject()
        button = root.findChild(QtCore.QObject, "buttonMouseArea")
        view.show()
        button.entered.emit()
        self.assertEqual(rotatevalue.rotation, 100)
Example #46
0
    def testQImageStringBuffer(self):
        '''Test if the QImage signatures receiving string buffers exist.'''
        img0 = QImage(adjust_filename('sample.png', __file__))

        # btw let's test the bits() method
        img1 = QImage(img0.bits(), img0.width(), img0.height(), img0.format())
        self.assertEqual(img0, img1)
        img2 = QImage(img0.bits(), img0.width(), img0.height(), img0.bytesPerLine(), img0.format())
        self.assertEqual(img0, img2)

        ## test scanLine method
        data1 = img0.scanLine(0)
        data2 = img1.scanLine(0)
        self.assertEqual(data1, data2)
        self.assertEqual(data1, py3k.buffer(img0.bits()[:img0.bytesPerLine()]))
        self.assertEqual(data2, py3k.buffer(img0.bits()[:img0.bytesPerLine()]))
    def testQQuickViewList(self):
        view = QQuickView()

        dataList = ["Item 1", "Item 2", "Item 3", "Item 4"]

        ctxt = view.rootContext()
        ctxt.setContextProperty("myModel", dataList)

        url = QUrl.fromLocalFile(adjust_filename('view.qml', __file__))
        view.setSource(url)
        view.show()

        self.assertEqual(view.status(), QQuickView.Ready)
        rootObject = view.rootObject()
        self.assertTrue(rootObject)
        self.assertTrue(QtQml.qmlEngine(rootObject))
        self.assertTrue(QtQml.qmlContext(rootObject))
Example #48
0
    def testSlotRetur(self):
        view = QtDeclarative.QDeclarativeView()
        rotatevalue = RotateValue()

        timer = QtCore.QTimer()
        timer.start(2000)

        context = view.rootContext()
        context.setContextProperty("rotatevalue", rotatevalue)
        view.setSource(
            QtCore.QUrl.fromLocalFile(adjust_filename('bug_456.qml',
                                                      __file__)))
        root = view.rootObject()
        button = root.findChild(QtCore.QObject, "buttonMouseArea")
        view.show()
        button.entered.emit()
        self.assertEqual(rotatevalue.rotation, 100)
Example #49
0
    def testQImageStringBuffer(self):
        '''Test if the QImage signatures receiving string buffers exist.'''
        img0 = QImage(adjust_filename('sample.png', __file__))

        # btw let's test the bits() method
        img1 = QImage(img0.bits(), img0.width(), img0.height(), img0.format())
        self.assertEqual(img0, img1)
        img2 = QImage(img0.bits(), img0.width(), img0.height(), img0.bytesPerLine(), img0.format())
        self.assertEqual(img0, img2)

        ## test scanLine method
        data1 = img0.scanLine(0)
        data2 = img1.scanLine(0)
        self.assertEqual(data1, data2)

        # PySide python 3.x does not support slice yet
        if not py3k.IS_PY3K:
            buff = py3k.buffer(img0.bits()[:img0.bytesPerLine()])
            self.assertEqual(data1, buff)
            self.assertEqual(data2, buff)
Example #50
0
    def testQQuickItemGrabToImageSharedPointer(self):
        view = QtQuick.QQuickView()
        view.setSource(
            QtCore.QUrl.fromLocalFile(
                adjust_filename('qquickitem_grabToImage.qml', __file__)))
        view.show()

        # Get the QQuickItem objects for the blue Rectangle and the Image item.
        root = view.rootObject()
        blueRectangle = root.findChild(QtQuick.QQuickItem, "blueRectangle")
        imageContainer = root.findChild(QtQuick.QQuickItem, "imageContainer")

        # Start the image grabbing.
        grabResultSharedPtr = blueRectangle.grabToImage()

        # Implicit call of operator bool() of the smart pointer, to check that it holds
        # a valid pointer.
        self.assertTrue(grabResultSharedPtr)

        self.grabbedColor = None

        def onGrabReady():
            # Signal early exit.
            QtCore.QTimer.singleShot(0, self.app.quit)

            # Show the grabbed image in the QML Image item.
            imageContainer.setProperty("source", grabResultSharedPtr.url())

        # Wait for signal when grabbing is complete.
        grabResultSharedPtr.ready.connect(onGrabReady)
        self.app.exec_()

        # Get the first pixel color of the grabbed image.
        self.image = grabResultSharedPtr.image()
        self.assertTrue(self.image)
        self.grabbedColor = self.image.pixelColor(0, 0)
        self.assertTrue(self.grabbedColor.isValid())

        # Compare the grabbed color with the one we set in the rectangle.
        blueColor = QtGui.QColor("blue")
        self.assertEqual(self.grabbedColor, blueColor)
Example #51
0
    def testQMLFunctionCall(self):
        app = QtGui.QApplication(sys.argv)
        view = QtDeclarative.QDeclarativeView()

        obj = PythonObject()
        context = view.rootContext()
        context.setContextProperty("python", obj)
        view.setSource(QtCore.QUrl.fromLocalFile(adjust_filename("bug_451.qml", __file__)))
        root = view.rootObject()
        root.simpleFunction()
        self.assertEqual(obj.called, "simpleFunction")

        root.oneArgFunction(42)
        self.assertEqual(obj.called, "oneArgFunction")
        self.assertEqual(obj.arg1, 42)

        root.twoArgFunction(10, app)
        self.assertEqual(obj.called, "twoArgFunction")
        self.assertEqual(obj.arg1, 10)
        self.assertEqual(obj.arg2, app)

        rvalue = root.returnFunction()
        self.assertEqual(obj.called, "returnFunction")
        self.assertEqual(rvalue, 42)
Example #52
0
 def __init__(self):
     QQuickView.__init__(self)
     self.setSource(QUrl.fromLocalFile(adjust_filename('bug_847.qml', __file__)))
     self.rootObject().setProperty('pythonObject', self)
Example #53
0
import sys
from PySide import QtCore, QtGui, QtDeclarative
import helper

class TestModel(QtCore.QAbstractListModel):
    def __init__(self, parent=None):
        super(TestModel, self).__init__(parent)
        self._data = ["one", "two", "three"]
        # this _must_ crash without the fix
        obj = QtCore.QObject()

    def rowCount(self, parent=QtCore.QModelIndex()):
        return len(self._data)

    def data(self, index, role):
        return self._data[index.row()]

if __name__ == "__main__":
    QtDeclarative.qmlRegisterType(TestModel, "Test", 1,0,
                                  "TestModel")

    app = QtGui.QApplication(sys.argv)
    view = QtDeclarative.QDeclarativeView()
    url = QtCore.QUrl.fromLocalFile(helper.adjust_filename("bug_1113.qml",
                                                           __file__))
    view.setSource(url)
    QtCore.QTimer.singleShot(70, app.quit)
    view.show()
    sys.exit(app.exec_())
Example #54
0
''' unit test for BUG #1060 '''

from PySide2.QtWidgets import QApplication
from PySide2.QtUiTools import QUiLoader
from helper import adjust_filename

class MyQUiLoader(QUiLoader):
    def __init__(self):
        super(MyQUiLoader, self).__init__()

    def createWidget(self, *args):
        return super(MyQUiLoader, self).createWidget(*args)

if __name__ == "__main__":
    app = QApplication([])

    ui = MyQUiLoader().load(adjust_filename("bug_1060.ui", __file__))
    ui.show()
Example #55
0
from PySide import QtUiTools
from PySide import QtCore
from PySide import QtGui
from helper import adjust_filename

app = QtGui.QApplication([])
loader = QtUiTools.QUiLoader()
file = QtCore.QFile(adjust_filename('bug_552.ui', __file__))
w = QtGui.QWidget()
# An exception can't be thrown
mainWindow = loader.load(file, w)
Example #56
0
from PySide.QtGui import *
from PySide.QtDeclarative import *
from helper import adjust_filename, UsesQApplication

app = QApplication([])
view = QDeclarativeView(adjust_filename('bug_995.qml', __file__))
view.show()
view.resize(200, 200)
item = view.itemAt(100, 100)

# it CAN NOT crash here
print(item)

Example #57
0
    def testLoadFinishedFromFile(self):
        url = QUrl.fromLocalFile(adjust_filename('fox.html', __file__))
        self.view.setUrl(url)
        self.app.exec_()

        self.assert_(self.called)