Created unit test for qvariant conversion for object type.
Reviewer: Marcelo Lira <marcelo.lira@openbossa.org>
Luciano Wolf <luciano.wolf@openbossa.org>
This commit is contained in:
parent
a623a57d06
commit
2ef14fcc12
3 changed files with 50 additions and 7 deletions
|
|
@ -1,5 +1,5 @@
|
||||||
PYSIDE_TEST(bug_451.py FALSE)
|
PYSIDE_TEST(bug_451.py)
|
||||||
PYSIDE_TEST(bug_456.py FALSE)
|
PYSIDE_TEST(bug_456.py)
|
||||||
PYSIDE_TEST(qdeclarativenetwork_test.py FALSE)
|
PYSIDE_TEST(qdeclarativenetwork_test.py)
|
||||||
PYSIDE_TEST(qdeclarativeview_test.py FALSE)
|
PYSIDE_TEST(qdeclarativeview_test.py)
|
||||||
PYSIDE_TEST(connect_python_qml.py FALSE)
|
PYSIDE_TEST(connect_python_qml.py)
|
||||||
|
|
|
||||||
|
|
@ -2,11 +2,26 @@
|
||||||
|
|
||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
from PySide.QtCore import QUrl
|
from PySide.QtCore import QUrl, QObject, Property, Slot
|
||||||
from PySide.QtDeclarative import QDeclarativeView
|
from PySide.QtDeclarative import QDeclarativeView
|
||||||
|
|
||||||
from helper import adjust_filename, TimedQApplication
|
from helper import adjust_filename, TimedQApplication
|
||||||
|
|
||||||
|
class MyObject(QObject):
|
||||||
|
def __init__(self, text, parent=None):
|
||||||
|
QObject.__init__(self, parent)
|
||||||
|
self._text = text
|
||||||
|
|
||||||
|
def getText(self):
|
||||||
|
return self._text
|
||||||
|
|
||||||
|
|
||||||
|
@Slot(str)
|
||||||
|
def qmlText(self, text):
|
||||||
|
self._qmlText = text
|
||||||
|
|
||||||
|
title = Property(str, getText)
|
||||||
|
|
||||||
|
|
||||||
class TestQDeclarativeView(TimedQApplication):
|
class TestQDeclarativeView(TimedQApplication):
|
||||||
|
|
||||||
|
|
@ -24,7 +39,21 @@ class TestQDeclarativeView(TimedQApplication):
|
||||||
|
|
||||||
self.assertEqual(view.status(), QDeclarativeView.Ready)
|
self.assertEqual(view.status(), QDeclarativeView.Ready)
|
||||||
|
|
||||||
self.app.exec_()
|
|
||||||
|
def testModelExport(self):
|
||||||
|
print "TEST"
|
||||||
|
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)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
unittest.main()
|
unittest.main()
|
||||||
|
|
|
||||||
14
tests/QtDeclarative/viewmodel.qml
Normal file
14
tests/QtDeclarative/viewmodel.qml
Normal file
|
|
@ -0,0 +1,14 @@
|
||||||
|
import Qt 4.7
|
||||||
|
|
||||||
|
ListView {
|
||||||
|
width: 100; height: 100
|
||||||
|
anchors.fill: parent
|
||||||
|
|
||||||
|
model: myModel
|
||||||
|
delegate: Rectangle {
|
||||||
|
height: 25
|
||||||
|
width: 100
|
||||||
|
Text { text: title }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue