aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorLuciano Wolf <luciano.wolf@openbossa.org>2010-05-25 14:55:24 -0300
committerLuciano Wolf <luciano.wolf@openbossa.org>2010-05-28 16:00:47 -0300
commit2cb23734c85529a32e720b6f624fa6176a8e0a32 (patch)
tree52a5d0e28931dfc54c39abb4dfc0e8bbeaff07f1 /tests
parent12e6ba386a733bd38105aacfa2d0304ac94ade67 (diff)
Adding test cases to cover QtDeclarative + fix inside typesystem.
Reviewer: Marcelo Lira <marcelo.lira@openbossa.org> Renato Ara├║jo <renato.filho@openbossa.org>
Diffstat (limited to 'tests')
-rw-r--r--tests/qtdeclarative/network.qml47
-rw-r--r--tests/qtdeclarative/qdeclarativenetwork_test.py35
-rw-r--r--tests/qtdeclarative/qdeclarativeview_test.py31
-rw-r--r--tests/qtdeclarative/view.qml55
4 files changed, 168 insertions, 0 deletions
diff --git a/tests/qtdeclarative/network.qml b/tests/qtdeclarative/network.qml
new file mode 100644
index 00000000..4b849e07
--- /dev/null
+++ b/tests/qtdeclarative/network.qml
@@ -0,0 +1,47 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import Qt 4.7
+
+Image {
+ width: 100
+ height: 100
+ source: "http://qt.nokia.com/logo.png"
+}
diff --git a/tests/qtdeclarative/qdeclarativenetwork_test.py b/tests/qtdeclarative/qdeclarativenetwork_test.py
new file mode 100644
index 00000000..a03a484a
--- /dev/null
+++ b/tests/qtdeclarative/qdeclarativenetwork_test.py
@@ -0,0 +1,35 @@
+'''Test cases for QDeclarativeNetwork'''
+
+import unittest
+
+from PySide.QtCore import QUrl
+from PySide.QtDeclarative import QDeclarativeView, QDeclarativeNetworkAccessManagerFactory
+from PySide.QtNetwork import QNetworkAccessManager
+
+from helper import adjust_filename, TimedQApplication
+
+class MyNetworkAccessManagerFactory(QDeclarativeNetworkAccessManagerFactory):
+ def create(self, parent):
+ nam = QNetworkAccessManager(parent)
+ return nam
+
+class TestQDeclarativeNetworkFactory(TimedQApplication):
+
+ def setUp(self):
+ TimedQApplication.setUp(self, timeout=1000)
+
+ def testQDeclarativeNetworkFactory(self):
+ view = QDeclarativeView()
+
+ url = QUrl.fromLocalFile(adjust_filename('network.qml', __file__))
+
+ view.engine().setNetworkAccessManagerFactory(MyNetworkAccessManagerFactory())
+ view.setSource(url)
+ view.show()
+
+ self.assertEqual(view.status(), QDeclarativeView.Ready)
+
+ self.app.exec_()
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/tests/qtdeclarative/qdeclarativeview_test.py b/tests/qtdeclarative/qdeclarativeview_test.py
new file mode 100644
index 00000000..8101c5f0
--- /dev/null
+++ b/tests/qtdeclarative/qdeclarativeview_test.py
@@ -0,0 +1,31 @@
+'''Test cases for QDeclarativeView'''
+
+import unittest
+
+from PySide.QtCore import QUrl, QStringList, QVariant
+from PySide.QtGui import QPushButton
+from PySide.QtDeclarative import QDeclarativeView
+
+from helper import adjust_filename, TimedQApplication
+
+
+class TestQDeclarativeView(TimedQApplication):
+
+ def testQDeclarativeViewList(self):
+ view = QDeclarativeView()
+
+ dataList = QStringList(["Item 1", "Item 2", "Item 3", "Item 4"])
+
+ ctxt = view.rootContext()
+ ctxt.setContextProperty("myModel", dataList)
+
+ url = QUrl.fromLocalFile(adjust_filename('view.qml', __file__))
+ view.setSource(url)
+ view.show()
+
+ self.assertEqual(view.status(), QDeclarativeView.Ready)
+
+ self.app.exec_()
+
+if __name__ == '__main__':
+ unittest.main()
diff --git a/tests/qtdeclarative/view.qml b/tests/qtdeclarative/view.qml
new file mode 100644
index 00000000..ec5597df
--- /dev/null
+++ b/tests/qtdeclarative/view.qml
@@ -0,0 +1,55 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of Nokia Corporation and its Subsidiary(-ies) nor
+** the names of its contributors may be used to endorse or promote
+** products derived from this software without specific prior written
+** permission.
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import Qt 4.7
+
+ListView {
+ width: 100
+ height: 100
+ anchors.fill: parent
+ model: myModel
+ delegate: Component {
+ Rectangle {
+ height: 25
+ width: 100
+ Text { text: modelData }
+ }
+ }
+}