summaryrefslogtreecommitdiffstats
path: root/tests/QtDeclarative/qdeclarativeview_test.py
diff options
context:
space:
mode:
authorrenatofilho <renato.filho@openbossa.org>2010-11-10 12:54:23 -0300
committerrenatofilho <renato.filho@openbossa.org>2010-11-10 18:52:47 -0300
commit2ef14fcc12f003620f85a30f6a4b00e8fee654d2 (patch)
tree8bd3f6e09176cf3b3a3761a5fd46ddea0fb71d5c /tests/QtDeclarative/qdeclarativeview_test.py
parenta623a57d0660e4490c370da7167db3a794f5162e (diff)
downloadpyside-2ef14fcc12f003620f85a30f6a4b00e8fee654d2.tar.gz
pyside-2ef14fcc12f003620f85a30f6a4b00e8fee654d2.tar.xz
pyside-2ef14fcc12f003620f85a30f6a4b00e8fee654d2.zip
Created unit test for qvariant conversion for object type.
Reviewer: Marcelo Lira <marcelo.lira@openbossa.org> Luciano Wolf <luciano.wolf@openbossa.org>
Diffstat (limited to 'tests/QtDeclarative/qdeclarativeview_test.py')
-rw-r--r--tests/QtDeclarative/qdeclarativeview_test.py33
1 files changed, 31 insertions, 2 deletions
diff --git a/tests/QtDeclarative/qdeclarativeview_test.py b/tests/QtDeclarative/qdeclarativeview_test.py
index 7a2b657..f8f3a54 100644
--- a/tests/QtDeclarative/qdeclarativeview_test.py
+++ b/tests/QtDeclarative/qdeclarativeview_test.py
@@ -2,11 +2,26 @@
import unittest
-from PySide.QtCore import QUrl
+from PySide.QtCore import QUrl, QObject, Property, Slot
from PySide.QtDeclarative import QDeclarativeView
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):
@@ -24,7 +39,21 @@ class TestQDeclarativeView(TimedQApplication):
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__':
unittest.main()