From 442a0ca932a663251deeefb37428b4d8df70a139 Mon Sep 17 00:00:00 2001 From: Renato Filho Date: Mon, 11 Apr 2011 11:36:29 -0300 Subject: Created unit test for bug #814. Reviewer: Luciano Wolf Hugo Parente --- tests/QtDeclarative/CMakeLists.txt | 1 + tests/QtDeclarative/bug_814.py | 39 ++++++++++++++++++++++++++++++++++++++ tests/QtDeclarative/bug_814.qml | 9 +++++++++ 3 files changed, 49 insertions(+) create mode 100644 tests/QtDeclarative/bug_814.py create mode 100644 tests/QtDeclarative/bug_814.qml (limited to 'tests/QtDeclarative') diff --git a/tests/QtDeclarative/CMakeLists.txt b/tests/QtDeclarative/CMakeLists.txt index 01a417262..7cad2d7ff 100644 --- a/tests/QtDeclarative/CMakeLists.txt +++ b/tests/QtDeclarative/CMakeLists.txt @@ -2,6 +2,7 @@ PYSIDE_TEST(bug_451.py) PYSIDE_TEST(bug_456.py) PYSIDE_TEST(bug_557.py) PYSIDE_TEST(bug_726.py) +PYSIDE_TEST(bug_814.py) PYSIDE_TEST(qdeclarativenetwork_test.py) PYSIDE_TEST(qdeclarativeview_test.py) PYSIDE_TEST(connect_python_qml.py) diff --git a/tests/QtDeclarative/bug_814.py b/tests/QtDeclarative/bug_814.py new file mode 100644 index 000000000..43fcc5f61 --- /dev/null +++ b/tests/QtDeclarative/bug_814.py @@ -0,0 +1,39 @@ +#!/usr/bin/python +# -*- coding: utf-8 -*- + +# Test case for PySide bug 814 +# http://bugs.pyside.org/show_bug.cgi?id=814 +# 2011-04-08 Thomas Perl +# Released under the same terms as PySide itself + +from PySide.QtCore import QUrl, QAbstractListModel, QModelIndex +from PySide.QtDeclarative import QDeclarativeView + +from helper import adjust_filename, TimedQApplication +import unittest + +class ListModel(QAbstractListModel): + def __init__(self): + QAbstractListModel.__init__(self) + self.setRoleNames({0: 'modelData'}) + + def rowCount(self, parent=QModelIndex()): + return 3 + + def data(self, index, role): + if index.isValid() and role == 0: + return 'blubb' + return None + +class TestBug814(TimedQApplication): + 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() + +if __name__ == '__main__': + unittest.main() + diff --git a/tests/QtDeclarative/bug_814.qml b/tests/QtDeclarative/bug_814.qml new file mode 100644 index 000000000..f772c3a84 --- /dev/null +++ b/tests/QtDeclarative/bug_814.qml @@ -0,0 +1,9 @@ + +import Qt 4.7 + +ListView { + width: 300; height: 300 + delegate: Text { text: modelData } + model: 3 +} + -- cgit v1.2.3