diff options
author | renatofilho <renato.filho@openbossa.org> | 2010-11-10 12:54:23 -0300 |
---|---|---|
committer | renatofilho <renato.filho@openbossa.org> | 2010-11-10 18:52:47 -0300 |
commit | 2ef14fcc12f003620f85a30f6a4b00e8fee654d2 (patch) | |
tree | 8bd3f6e09176cf3b3a3761a5fd46ddea0fb71d5c /tests | |
parent | a623a57d0660e4490c370da7167db3a794f5162e (diff) |
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')
-rw-r--r-- | tests/QtDeclarative/CMakeLists.txt | 10 | ||||
-rw-r--r-- | tests/QtDeclarative/qdeclarativeview_test.py | 33 | ||||
-rw-r--r-- | tests/QtDeclarative/viewmodel.qml | 14 |
3 files changed, 50 insertions, 7 deletions
diff --git a/tests/QtDeclarative/CMakeLists.txt b/tests/QtDeclarative/CMakeLists.txt index 277384987..5ceba4224 100644 --- a/tests/QtDeclarative/CMakeLists.txt +++ b/tests/QtDeclarative/CMakeLists.txt @@ -1,5 +1,5 @@ -PYSIDE_TEST(bug_451.py FALSE) -PYSIDE_TEST(bug_456.py FALSE) -PYSIDE_TEST(qdeclarativenetwork_test.py FALSE) -PYSIDE_TEST(qdeclarativeview_test.py FALSE) -PYSIDE_TEST(connect_python_qml.py FALSE) +PYSIDE_TEST(bug_451.py) +PYSIDE_TEST(bug_456.py) +PYSIDE_TEST(qdeclarativenetwork_test.py) +PYSIDE_TEST(qdeclarativeview_test.py) +PYSIDE_TEST(connect_python_qml.py) diff --git a/tests/QtDeclarative/qdeclarativeview_test.py b/tests/QtDeclarative/qdeclarativeview_test.py index 7a2b657e1..f8f3a549b 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() diff --git a/tests/QtDeclarative/viewmodel.qml b/tests/QtDeclarative/viewmodel.qml new file mode 100644 index 000000000..badce7de2 --- /dev/null +++ b/tests/QtDeclarative/viewmodel.qml @@ -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 } + } +} + |