summaryrefslogtreecommitdiffstats
path: root/tests/QtDeclarative/qdeclarativeview_test.py
diff options
context:
space:
mode:
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()