Adding test cases to cover QtDeclarative + fix inside typesystem.
Reviewer: Marcelo Lira <marcelo.lira@openbossa.org>
Renato Araújo <renato.filho@openbossa.org>
This commit is contained in:
parent
12e6ba386a
commit
2cb23734c8
5 changed files with 175 additions and 1 deletions
|
|
@ -7,7 +7,13 @@
|
||||||
<object-type name="QDeclarativeComponent" />
|
<object-type name="QDeclarativeComponent" />
|
||||||
<enum-type name="QDeclarativeComponent::Status" />
|
<enum-type name="QDeclarativeComponent::Status" />
|
||||||
<object-type name="QDeclarativeContext" />
|
<object-type name="QDeclarativeContext" />
|
||||||
<object-type name="QDeclarativeEngine" />
|
<object-type name="QDeclarativeEngine">
|
||||||
|
<modify-function signature="setNetworkAccessManagerFactory(QDeclarativeNetworkAccessManagerFactory*)">
|
||||||
|
<modify-argument index="1">
|
||||||
|
<parent index="this" action="add" />
|
||||||
|
</modify-argument>
|
||||||
|
</modify-function>
|
||||||
|
</object-type>
|
||||||
<enum-type name="QDeclarativeEngine::ObjectOwnership" />
|
<enum-type name="QDeclarativeEngine::ObjectOwnership" />
|
||||||
<value-type name="QDeclarativeError" />
|
<value-type name="QDeclarativeError" />
|
||||||
<object-type name="QDeclarativeExpression" />
|
<object-type name="QDeclarativeExpression" />
|
||||||
|
|
|
||||||
47
tests/qtdeclarative/network.qml
Normal file
47
tests/qtdeclarative/network.qml
Normal file
|
|
@ -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"
|
||||||
|
}
|
||||||
35
tests/qtdeclarative/qdeclarativenetwork_test.py
Normal file
35
tests/qtdeclarative/qdeclarativenetwork_test.py
Normal file
|
|
@ -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()
|
||||||
31
tests/qtdeclarative/qdeclarativeview_test.py
Normal file
31
tests/qtdeclarative/qdeclarativeview_test.py
Normal file
|
|
@ -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()
|
||||||
55
tests/qtdeclarative/view.qml
Normal file
55
tests/qtdeclarative/view.qml
Normal file
|
|
@ -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 }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue