aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorSimon Hausmann <simon.hausmann@digia.com>2014-06-13 23:10:03 +0200
committerSimon Hausmann <simon.hausmann@digia.com>2014-06-13 23:10:03 +0200
commit9932617582470d717c97f8161a65133293c185c5 (patch)
tree1df48d67c6e5ca4aa8b7810fc9e717083b4199e3 /tests
parent7fde8a8d20da7fa00d974286fa903b3fee76d466 (diff)
parent17ee404f2678684674b9c5c0c523602953146e37 (diff)
Merge remote-tracking branch 'origin/5.3' into dev
Conflicts: src/quickwidgets/qquickwidget.cpp Change-Id: Id4b080aea713df68608847bb82570231e37ce536
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/qml/debugger/qqmlprofilerservice/tst_qqmlprofilerservice.cpp98
-rw-r--r--tests/auto/qml/qjsengine/tst_qjsengine.cpp49
-rw-r--r--tests/auto/quick/qquickgridview/data/negativeDisplayMargin.qml116
-rw-r--r--tests/auto/quick/qquickgridview/tst_qquickgridview.cpp44
-rw-r--r--tests/auto/quick/qquickitem2/data/keysforward.qml6
-rw-r--r--tests/auto/quick/qquicklistview/data/negativeDisplayMargin.qml115
-rw-r--r--tests/auto/quick/qquicklistview/tst_qquicklistview.cpp44
-rw-r--r--tests/auto/quick/scenegraph/data/render_OpacityThroughBatchRoot.qml90
-rw-r--r--tests/auto/quick/scenegraph/tst_scenegraph.cpp9
9 files changed, 520 insertions, 51 deletions
diff --git a/tests/auto/qml/debugger/qqmlprofilerservice/tst_qqmlprofilerservice.cpp b/tests/auto/qml/debugger/qqmlprofilerservice/tst_qqmlprofilerservice.cpp
index 2b1b7ce6ec..cebe9cb1ba 100644
--- a/tests/auto/qml/debugger/qqmlprofilerservice/tst_qqmlprofilerservice.cpp
+++ b/tests/auto/qml/debugger/qqmlprofilerservice/tst_qqmlprofilerservice.cpp
@@ -143,7 +143,8 @@ public:
{
}
- QList<QQmlProfilerData> synchronousMessages;
+ QList<QQmlProfilerData> qmlMessages;
+ QList<QQmlProfilerData> javascriptMessages;
QList<QQmlProfilerData> asynchronousMessages;
QList<QQmlProfilerData> pixmapMessages;
@@ -324,14 +325,12 @@ void QQmlProfilerClient::messageReceived(const QByteArray &message)
if (data.messageType == QQmlProfilerClient::PixmapCacheEvent)
pixmapMessages.append(data);
else if (data.messageType == QQmlProfilerClient::SceneGraphFrame ||
- (data.messageType == QQmlProfilerClient::Event &&
- (data.detailType == QQmlProfilerClient::FramePaint ||
- data.detailType == QQmlProfilerClient::AnimationFrame ||
- data.detailType == QQmlProfilerClient::Mouse ||
- data.detailType == QQmlProfilerClient::Key)))
+ data.messageType == QQmlProfilerClient::Event)
asynchronousMessages.append(data);
+ else if (data.detailType == QQmlProfilerClient::Javascript)
+ javascriptMessages.append(data);
else
- synchronousMessages.append(data);
+ qmlMessages.append(data);
}
void tst_QQmlProfilerService::connect(bool block, const QString &testFile)
@@ -360,23 +359,30 @@ void tst_QQmlProfilerService::connect(bool block, const QString &testFile)
void tst_QQmlProfilerService::checkTraceReceived()
{
QVERIFY2(QQmlDebugTest::waitForSignal(m_client, SIGNAL(complete())), "No trace received in time.");
- QVERIFY(m_client->synchronousMessages.count());
+ QVERIFY(m_client->asynchronousMessages.count());
// must start with "StartTrace"
- QCOMPARE(m_client->synchronousMessages.first().messageType, (int)QQmlProfilerClient::Event);
- QCOMPARE(m_client->synchronousMessages.first().detailType, (int)QQmlProfilerClient::StartTrace);
+ QCOMPARE(m_client->asynchronousMessages.first().messageType, (int)QQmlProfilerClient::Event);
+ QCOMPARE(m_client->asynchronousMessages.first().detailType, (int)QQmlProfilerClient::StartTrace);
// must end with "EndTrace"
- QCOMPARE(m_client->synchronousMessages.last().messageType, (int)QQmlProfilerClient::Event);
- QCOMPARE(m_client->synchronousMessages.last().detailType, (int)QQmlProfilerClient::EndTrace);
+ QCOMPARE(m_client->asynchronousMessages.last().messageType, (int)QQmlProfilerClient::Event);
+ QCOMPARE(m_client->asynchronousMessages.last().detailType, (int)QQmlProfilerClient::EndTrace);
}
void tst_QQmlProfilerService::cleanup()
{
if (QTest::currentTestFailed()) {
- qDebug() << "Synchronous Messages:" << m_client->synchronousMessages.count();
+ qDebug() << "QML Messages:" << m_client->qmlMessages.count();
int i = 0;
- foreach (const QQmlProfilerData &data, m_client->synchronousMessages) {
+ foreach (const QQmlProfilerData &data, m_client->qmlMessages) {
+ qDebug() << i++ << data.time << data.messageType << data.detailType << data.detailData
+ << data.line << data.column;
+ }
+ qDebug() << " ";
+ qDebug() << "JavaScript Messages:" << m_client->javascriptMessages.count();
+ i = 0;
+ foreach (const QQmlProfilerData &data, m_client->javascriptMessages) {
qDebug() << i++ << data.time << data.messageType << data.detailType << data.detailData
<< data.line << data.column;
}
@@ -547,22 +553,22 @@ void tst_QQmlProfilerService::signalSourceLocation()
m_client->setTraceState(false);
checkTraceReceived();
- QVERIFY2(m_client->synchronousMessages.count() >= 20,
- QString::number(m_client->synchronousMessages.count()).toUtf8().constData());
-
- QCOMPARE(m_client->synchronousMessages[14].messageType, (int)QQmlProfilerClient::RangeLocation);
- QCOMPARE(m_client->synchronousMessages[14].detailType, (int)QQmlProfilerClient::HandlingSignal);
- QVERIFY2(m_client->synchronousMessages[14].detailData.endsWith("signalSourceLocation.qml"),
- m_client->synchronousMessages[14].detailData.toUtf8().constData());
- QCOMPARE(m_client->synchronousMessages[14].line, 8);
- QCOMPARE(m_client->synchronousMessages[14].column, 28);
-
- QCOMPARE(m_client->synchronousMessages[19].messageType, (int)QQmlProfilerClient::RangeLocation);
- QCOMPARE(m_client->synchronousMessages[19].detailType, (int)QQmlProfilerClient::HandlingSignal);
- QVERIFY2(m_client->synchronousMessages[19].detailData.endsWith("signalSourceLocation.qml"),
- m_client->synchronousMessages[19].detailData.toUtf8().constData());
- QCOMPARE(m_client->synchronousMessages[19].line, 7);
- QCOMPARE(m_client->synchronousMessages[19].column, 21);
+ QVERIFY2(m_client->qmlMessages.count() >= 16,
+ QString::number(m_client->qmlMessages.count()).toUtf8().constData());
+
+ QCOMPARE(m_client->qmlMessages[13].messageType, (int)QQmlProfilerClient::RangeLocation);
+ QCOMPARE(m_client->qmlMessages[13].detailType, (int)QQmlProfilerClient::HandlingSignal);
+ QVERIFY2(m_client->qmlMessages[13].detailData.endsWith("signalSourceLocation.qml"),
+ m_client->qmlMessages[13].detailData.toUtf8().constData());
+ QCOMPARE(m_client->qmlMessages[13].line, 8);
+ QCOMPARE(m_client->qmlMessages[13].column, 28);
+
+ QCOMPARE(m_client->qmlMessages[15].messageType, (int)QQmlProfilerClient::RangeLocation);
+ QCOMPARE(m_client->qmlMessages[15].detailType, (int)QQmlProfilerClient::HandlingSignal);
+ QVERIFY2(m_client->qmlMessages[15].detailData.endsWith("signalSourceLocation.qml"),
+ m_client->qmlMessages[15].detailData.toUtf8().constData());
+ QCOMPARE(m_client->qmlMessages[15].line, 7);
+ QCOMPARE(m_client->qmlMessages[15].column, 21);
}
void tst_QQmlProfilerService::javascript()
@@ -577,26 +583,26 @@ void tst_QQmlProfilerService::javascript()
m_client->setTraceState(false);
checkTraceReceived();
- QVERIFY2(m_client->synchronousMessages.count() >= 36,
- QString::number(m_client->synchronousMessages.count()).toUtf8().constData());
+ QVERIFY2(m_client->javascriptMessages.count() >= 22,
+ QString::number(m_client->javascriptMessages.count()).toUtf8().constData());
- QCOMPARE(m_client->synchronousMessages[32].messageType, (int)QQmlProfilerClient::RangeStart);
- QCOMPARE(m_client->synchronousMessages[32].detailType, (int)QQmlProfilerClient::Javascript);
+ QCOMPARE(m_client->javascriptMessages[6].messageType, (int)QQmlProfilerClient::RangeStart);
+ QCOMPARE(m_client->javascriptMessages[6].detailType, (int)QQmlProfilerClient::Javascript);
- QCOMPARE(m_client->synchronousMessages[33].messageType, (int)QQmlProfilerClient::RangeLocation);
- QCOMPARE(m_client->synchronousMessages[33].detailType, (int)QQmlProfilerClient::Javascript);
- QVERIFY2(m_client->synchronousMessages[33].detailData.endsWith("javascript.qml"),
- m_client->synchronousMessages[33].detailData.toUtf8().constData());
- QCOMPARE(m_client->synchronousMessages[33].line, 4);
- QCOMPARE(m_client->synchronousMessages[33].column, 5);
+ QCOMPARE(m_client->javascriptMessages[7].messageType, (int)QQmlProfilerClient::RangeLocation);
+ QCOMPARE(m_client->javascriptMessages[7].detailType, (int)QQmlProfilerClient::Javascript);
+ QVERIFY2(m_client->javascriptMessages[7].detailData.endsWith("javascript.qml"),
+ m_client->javascriptMessages[7].detailData.toUtf8().constData());
+ QCOMPARE(m_client->javascriptMessages[7].line, 4);
+ QCOMPARE(m_client->javascriptMessages[7].column, 5);
- QCOMPARE(m_client->synchronousMessages[34].messageType, (int)QQmlProfilerClient::RangeData);
- QCOMPARE(m_client->synchronousMessages[34].detailType, (int)QQmlProfilerClient::Javascript);
- QVERIFY2(m_client->synchronousMessages[34].detailData == "something",
- m_client->synchronousMessages[34].detailData.toUtf8().constData());
+ QCOMPARE(m_client->javascriptMessages[8].messageType, (int)QQmlProfilerClient::RangeData);
+ QCOMPARE(m_client->javascriptMessages[8].detailType, (int)QQmlProfilerClient::Javascript);
+ QVERIFY2(m_client->javascriptMessages[8].detailData == "something",
+ m_client->javascriptMessages[8].detailData.toUtf8().constData());
- QCOMPARE(m_client->synchronousMessages[35].messageType, (int)QQmlProfilerClient::RangeEnd);
- QCOMPARE(m_client->synchronousMessages[35].detailType, (int)QQmlProfilerClient::Javascript);
+ QCOMPARE(m_client->javascriptMessages[21].messageType, (int)QQmlProfilerClient::RangeEnd);
+ QCOMPARE(m_client->javascriptMessages[21].detailType, (int)QQmlProfilerClient::Javascript);
}
QTEST_MAIN(tst_QQmlProfilerService)
diff --git a/tests/auto/qml/qjsengine/tst_qjsengine.cpp b/tests/auto/qml/qjsengine/tst_qjsengine.cpp
index 9183c37df1..feef9d27f8 100644
--- a/tests/auto/qml/qjsengine/tst_qjsengine.cpp
+++ b/tests/auto/qml/qjsengine/tst_qjsengine.cpp
@@ -206,6 +206,7 @@ signals:
void slotWithSingleArgCalled(const QString &arg);
void slotWithArgumentsCalled(const QString &arg1, const QString &arg2, const QString &arg3);
void slotWithOverloadedArgumentsCalled(const QString &arg, Qt::KeyboardModifier modifier, Qt::KeyboardModifiers moreModifiers);
+ void slotWithTwoOverloadedArgumentsCalled(const QString &arg, Qt::KeyboardModifiers moreModifiers, Qt::KeyboardModifier modifier);
public slots:
void slotToCall() { emit slotWithoutArgCalled(); }
@@ -218,6 +219,10 @@ public slots:
{
emit slotWithOverloadedArgumentsCalled(arg, modifier, blah);
}
+ void slotToCallTwoDefault(const QString &arg, Qt::KeyboardModifiers modifiers = Qt::ShiftModifier | Qt::ControlModifier, Qt::KeyboardModifier modifier = Qt::AltModifier)
+ {
+ emit slotWithTwoOverloadedArgumentsCalled(arg, modifiers, modifier);
+ }
};
void tst_QJSEngine::callQObjectSlot()
@@ -275,6 +280,50 @@ void tst_QJSEngine::callQObjectSlot()
QCOMPARE(int(qvariant_cast<Qt::KeyboardModifiers>(arguments.at(2))), int(Qt::ShiftModifier));
}
+
+ {
+ QSignalSpy spy(&dummy, SIGNAL(slotWithTwoOverloadedArgumentsCalled(QString, Qt::KeyboardModifiers, Qt::KeyboardModifier)));
+ QJSValue v = eng.evaluate(QStringLiteral("dummy.slotToCallTwoDefault('arg', %1);").arg(QString::number(Qt::MetaModifier | Qt::KeypadModifier)));
+ QCOMPARE(spy.count(), 1);
+
+ const QList<QVariant> arguments = spy.first();
+ QCOMPARE(arguments.at(0).toString(), QString("arg"));
+ QCOMPARE(int(qvariant_cast<Qt::KeyboardModifiers>(arguments.at(1))), int(Qt::MetaModifier | Qt::KeypadModifier));
+ QCOMPARE(int(qvariant_cast<Qt::KeyboardModifier>(arguments.at(2))), int(Qt::AltModifier));
+ }
+
+ QJSValue jsArray = eng.newArray();
+ jsArray.setProperty(QStringLiteral("MetaModifier"), QJSValue(Qt::MetaModifier));
+ jsArray.setProperty(QStringLiteral("ShiftModifier"), QJSValue(Qt::ShiftModifier));
+ jsArray.setProperty(QStringLiteral("ControlModifier"), QJSValue(Qt::ControlModifier));
+ jsArray.setProperty(QStringLiteral("KeypadModifier"), QJSValue(Qt::KeypadModifier));
+
+ QJSValue value = eng.newQObject(new QObject);
+ value.setPrototype(jsArray);
+ eng.globalObject().setProperty(QStringLiteral("Qt"), value);
+
+ {
+ QSignalSpy spy(&dummy, SIGNAL(slotWithOverloadedArgumentsCalled(QString, Qt::KeyboardModifier, Qt::KeyboardModifiers)));
+ QJSValue v = eng.evaluate(QStringLiteral("dummy.slotToCall('arg', Qt.ControlModifier);"));
+ QCOMPARE(spy.count(), 1);
+
+ const QList<QVariant> arguments = spy.first();
+ QCOMPARE(arguments.at(0).toString(), QString("arg"));
+ QCOMPARE(arguments.at(1).toInt(), int(Qt::ControlModifier));
+ QCOMPARE(int(qvariant_cast<Qt::KeyboardModifiers>(arguments.at(2))), int(Qt::ShiftModifier));
+ }
+
+ {
+ QSignalSpy spy(&dummy, SIGNAL(slotWithTwoOverloadedArgumentsCalled(QString, Qt::KeyboardModifiers, Qt::KeyboardModifier)));
+ QJSValue v = eng.evaluate(QStringLiteral("dummy.slotToCallTwoDefault('arg', Qt.MetaModifier | Qt.KeypadModifier);"));
+ QCOMPARE(spy.count(), 1);
+
+ const QList<QVariant> arguments = spy.first();
+ QCOMPARE(arguments.at(0).toString(), QString("arg"));
+ QCOMPARE(int(qvariant_cast<Qt::KeyboardModifiers>(arguments.at(1))), int(Qt::MetaModifier | Qt::KeypadModifier));
+ QCOMPARE(int(qvariant_cast<Qt::KeyboardModifier>(arguments.at(2))), int(Qt::AltModifier));
+ }
+
}
void tst_QJSEngine::constructWithParent()
diff --git a/tests/auto/quick/qquickgridview/data/negativeDisplayMargin.qml b/tests/auto/quick/qquickgridview/data/negativeDisplayMargin.qml
new file mode 100644
index 0000000000..96063e32cf
--- /dev/null
+++ b/tests/auto/quick/qquickgridview/data/negativeDisplayMargin.qml
@@ -0,0 +1,116 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Canonical Limited and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.3
+
+ListView {
+ id: list
+ width: 400
+ height: 600
+ model: ListModel {
+ ListElement { kind: "Bought" }
+ ListElement { kind: "Available To Buy" }
+ }
+
+ delegate: GridView {
+ id: grid
+ objectName: "grid"
+ height: Math.ceil(count / (width / cellWidth)) * cellHeight / 1
+ width: list.width
+ interactive: false
+ property int count: 50
+ cellHeight: 200
+ cellWidth: cellHeight
+ model: count
+ property int createdItems: 0
+ property int destroyedItems: 0
+
+ delegate: Item {
+ objectName: "delegate"
+ width: cellWidth
+ height: cellHeight
+ Rectangle {
+ width: parent.width - 20
+ height: parent.height - 20
+ anchors.centerIn: parent
+ color: Math.random() * 2 > 1 ? "green" : "yellow";
+ Text {
+ text: index
+ }
+ Component.onCompleted: createdItems++
+ Component.onDestruction: destroyedItems++
+ }
+ }
+
+ displayMarginBeginning: 0
+ displayMarginEnd: -height
+
+ function updatedDelegateCreationRange() {
+ if (list.contentY + list.height <= grid.y) {
+ // Not visible
+ grid.displayMarginBeginning = 0
+ grid.displayMarginEnd = -grid.height
+ } else if (grid.y + grid.height <= list.contentY) {
+ // Not visible
+ grid.displayMarginBeginning = -grid.height
+ grid.displayMarginEnd = 0
+ } else {
+ grid.displayMarginBeginning = -Math.max(list.contentY - grid.y, 0)
+ grid.displayMarginEnd = -Math.max(grid.height - list.height - list.contentY + grid.y, 0)
+ }
+ }
+
+ Component.onCompleted: updatedDelegateCreationRange();
+ onHeightChanged: updatedDelegateCreationRange();
+ Connections {
+ target: list
+ onContentYChanged: updatedDelegateCreationRange();
+ onHeightChanged: updatedDelegateCreationRange();
+ }
+ }
+
+ section.property: "kind"
+ section.delegate: Text {
+ height: 40
+ font.pixelSize: 30
+ text: section
+ }
+}
diff --git a/tests/auto/quick/qquickgridview/tst_qquickgridview.cpp b/tests/auto/quick/qquickgridview/tst_qquickgridview.cpp
index 890174e2a8..863fb69b84 100644
--- a/tests/auto/quick/qquickgridview/tst_qquickgridview.cpp
+++ b/tests/auto/quick/qquickgridview/tst_qquickgridview.cpp
@@ -210,6 +210,7 @@ private slots:
void moved_topToBottom_RtL_BtT_data();
void displayMargin();
+ void negativeDisplayMargin();
private:
QList<int> toIntList(const QVariantList &list);
@@ -6393,6 +6394,49 @@ void tst_QQuickGridView::displayMargin()
delete window;
}
+void tst_QQuickGridView::negativeDisplayMargin()
+{
+ QQuickItem *item;
+ QQuickView *window = createView();
+ window->setSource(testFileUrl("negativeDisplayMargin.qml"));
+ window->show();
+ QVERIFY(QTest::qWaitForWindowExposed(window));
+
+ QQuickItem *listview = window->rootObject();
+ QQuickGridView *gridview = findItem<QQuickGridView>(window->rootObject(), "grid");
+ QVERIFY(gridview != 0);
+
+ QTRY_COMPARE(gridview->property("createdItems").toInt(), 11);
+ QCOMPARE(gridview->property("destroyedItem").toInt(), 0);
+
+ QQuickItem *content = gridview->contentItem();
+ QVERIFY(content != 0);
+
+ QVERIFY(item = findItem<QQuickItem>(content, "delegate", 0));
+ QCOMPARE(delegateVisible(item), true);
+
+ QVERIFY(item = findItem<QQuickItem>(content, "delegate", 7));
+ QCOMPARE(delegateVisible(item), true);
+
+ QVERIFY(item = findItem<QQuickItem>(content, "delegate", 8));
+ QCOMPARE(delegateVisible(item), false);
+
+ // Flick until contentY means that delegate8 should be visible
+ listview->setProperty("contentY", 500);
+ QVERIFY(item = findItem<QQuickItem>(content, "delegate", 8));
+ QTRY_COMPARE(delegateVisible(item), true);
+
+ listview->setProperty("contentY", 1000);
+ QTRY_VERIFY(item = findItem<QQuickItem>(content, "delegate", 14));
+ QTRY_COMPARE(delegateVisible(item), true);
+
+ listview->setProperty("contentY", 0);
+ QVERIFY(item = findItem<QQuickItem>(content, "delegate", 4));
+ QTRY_COMPARE(delegateVisible(item), true);
+
+ delete window;
+}
+
QTEST_MAIN(tst_QQuickGridView)
#include "tst_qquickgridview.moc"
diff --git a/tests/auto/quick/qquickitem2/data/keysforward.qml b/tests/auto/quick/qquickitem2/data/keysforward.qml
index f0cb4d9508..5677aa62f1 100644
--- a/tests/auto/quick/qquickitem2/data/keysforward.qml
+++ b/tests/auto/quick/qquickitem2/data/keysforward.qml
@@ -58,7 +58,7 @@ Item {
objectName: "primary"
property var pressedKeys: []
property var releasedKeys: []
- Keys.forwardTo: secondaryTarget
+ Keys.forwardTo: [ secondaryTarget, extraTarget ]
Keys.onPressed: { event.accepted = event.key === Qt.Key_P; var keys = pressedKeys; keys.push(event.key); pressedKeys = keys }
Keys.onReleased: { event.accepted = event.key === Qt.Key_P; var keys = releasedKeys; keys.push(event.key); releasedKeys = keys }
@@ -81,4 +81,8 @@ Item {
Keys.onPressed: { event.accepted = event.key === Qt.Key_S; var keys = pressedKeys; keys.push(event.key); pressedKeys = keys }
Keys.onReleased: { event.accepted = event.key === Qt.Key_S; var keys = releasedKeys; keys.push(event.key); releasedKeys = keys }
}
+
+ Item {
+ id: extraTarget
+ }
}
diff --git a/tests/auto/quick/qquicklistview/data/negativeDisplayMargin.qml b/tests/auto/quick/qquicklistview/data/negativeDisplayMargin.qml
new file mode 100644
index 0000000000..64d9ce1956
--- /dev/null
+++ b/tests/auto/quick/qquicklistview/data/negativeDisplayMargin.qml
@@ -0,0 +1,115 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Canonical Limited and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.3
+
+ListView {
+ id: list
+ width: 400
+ height: 600
+ model: ListModel {
+ ListElement { kind: "Bought" }
+ ListElement { kind: "Available To Buy" }
+ }
+
+ delegate: ListView {
+ id: innerList
+ objectName: "innerList"
+ height: count * lineHeight
+ width: list.width
+ interactive: false
+ property int count: 50
+ model: count
+ property int createdItems: 0
+ property int destroyedItems: 0
+ property int lineHeight: 85
+
+ delegate: Item {
+ objectName: "delegate"
+ width: innerList.width
+ height: innerList.lineHeight
+ Rectangle {
+ width: parent.width - 20
+ height: parent.height - 20
+ anchors.centerIn: parent
+ color: Math.random() * 2 > 1 ? "green" : "yellow";
+ Text {
+ text: index
+ }
+ Component.onCompleted: createdItems++
+ Component.onDestruction: destroyedItems++
+ }
+ }
+
+ displayMarginBeginning: 0
+ displayMarginEnd: -height
+
+ function updatedDelegateCreationRange() {
+ if (list.contentY + list.height <= innerList.y) {
+ // Not visible
+ innerList.displayMarginBeginning = 0
+ innerList.displayMarginEnd = -innerList.height
+ } else if (innerList.y + innerList.height <= list.contentY) {
+ // Not visible
+ innerList.displayMarginBeginning = -innerList.height
+ innerList.displayMarginEnd = 0
+ } else {
+ innerList.displayMarginBeginning = -Math.max(list.contentY - innerList.y, 0)
+ innerList.displayMarginEnd = -Math.max(innerList.height - list.height - list.contentY + innerList.y, 0)
+ }
+ }
+
+ Component.onCompleted: updatedDelegateCreationRange();
+ onHeightChanged: updatedDelegateCreationRange();
+ Connections {
+ target: list
+ onContentYChanged: updatedDelegateCreationRange();
+ onHeightChanged: updatedDelegateCreationRange();
+ }
+ }
+
+ section.property: "kind"
+ section.delegate: Text {
+ height: 40
+ font.pixelSize: 30
+ text: section
+ }
+}
diff --git a/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp b/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp
index c05434166d..b909d14301 100644
--- a/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp
+++ b/tests/auto/quick/qquicklistview/tst_qquicklistview.cpp
@@ -221,6 +221,7 @@ private slots:
void typedModel();
void displayMargin();
+ void negativeDisplayMargin();
void highlightItemGeometryChanges();
@@ -7203,6 +7204,49 @@ void tst_QQuickListView::displayMargin()
delete window;
}
+void tst_QQuickListView::negativeDisplayMargin()
+{
+ QQuickItem *item;
+ QQuickView *window = createView();
+ window->setSource(testFileUrl("negativeDisplayMargin.qml"));
+ window->show();
+ QVERIFY(QTest::qWaitForWindowExposed(window));
+
+ QQuickItem *listview = window->rootObject();
+ QQuickListView *innerList = findItem<QQuickListView>(window->rootObject(), "innerList");
+ QVERIFY(innerList != 0);
+
+ QTRY_COMPARE(innerList->property("createdItems").toInt(), 11);
+ QCOMPARE(innerList->property("destroyedItem").toInt(), 0);
+
+ QQuickItem *content = innerList->contentItem();
+ QVERIFY(content != 0);
+
+ QVERIFY(item = findItem<QQuickItem>(content, "delegate", 0));
+ QCOMPARE(delegateVisible(item), true);
+
+ QVERIFY(item = findItem<QQuickItem>(content, "delegate", 7));
+ QCOMPARE(delegateVisible(item), true);
+
+ QVERIFY(item = findItem<QQuickItem>(content, "delegate", 8));
+ QCOMPARE(delegateVisible(item), false);
+
+ // Flick until contentY means that delegate8 should be visible
+ listview->setProperty("contentY", 500);
+ QVERIFY(item = findItem<QQuickItem>(content, "delegate", 8));
+ QTRY_COMPARE(delegateVisible(item), true);
+
+ listview->setProperty("contentY", 1000);
+ QTRY_VERIFY(item = findItem<QQuickItem>(content, "delegate", 14));
+ QTRY_COMPARE(delegateVisible(item), true);
+
+ listview->setProperty("contentY", 0);
+ QTRY_VERIFY(item = findItem<QQuickItem>(content, "delegate", 4));
+ QTRY_COMPARE(delegateVisible(item), true);
+
+ delete window;
+}
+
void tst_QQuickListView::highlightItemGeometryChanges()
{
QScopedPointer<QQuickView> window(createView());
diff --git a/tests/auto/quick/scenegraph/data/render_OpacityThroughBatchRoot.qml b/tests/auto/quick/scenegraph/data/render_OpacityThroughBatchRoot.qml
new file mode 100644
index 0000000000..ed55a98979
--- /dev/null
+++ b/tests/auto/quick/scenegraph/data/render_OpacityThroughBatchRoot.qml
@@ -0,0 +1,90 @@
+/****************************************************************************
+**
+** Copyright (C) 2014 Jolla Ltd, author: <gunnar.sletta@jollamobile.com>
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.2
+
+/*
+ This test verifies that when we have an update to opacity above
+ a batch root, the opacity of the batch root's children is rendered
+ correctly. The Text element has 1000 glyphs in it, which is needed
+ for contentRoot to become a batch root when the scale changes.
+
+ #samples: 2
+ PixelPos R G B Error-tolerance
+ #base: 50 50 0.0 0.0 1.0 0.0
+ #final: 50 50 0.5 0.5 1.0 0.05
+*/
+
+RenderTestBase {
+ id: root
+
+ Item {
+ id: failRoot;
+ property alias itemScale: contentItem.scale
+
+ Item {
+ id: contentItem
+ width: 100
+ height: 100
+ Rectangle {
+ width: 100
+ height: 100
+ color: "blue"
+ Text {
+ id: input
+ color: "black"
+ Component.onCompleted: { for (var i = 0; i<1000; ++i) input.text += 'x' }
+ }
+ }
+ }
+ }
+
+ SequentialAnimation {
+ id: unifiedAnimation;
+ NumberAnimation { properties: "opacity,itemScale"; duration: 256; from: 1; to: 0.5; target: failRoot }
+ ScriptAction { script: root.finalStageComplete = true; }
+ }
+
+ onEnterFinalStage: {
+ unifiedAnimation.running = true;
+ }
+
+}
diff --git a/tests/auto/quick/scenegraph/tst_scenegraph.cpp b/tests/auto/quick/scenegraph/tst_scenegraph.cpp
index ac4938e8bc..d510fdcda8 100644
--- a/tests/auto/quick/scenegraph/tst_scenegraph.cpp
+++ b/tests/auto/quick/scenegraph/tst_scenegraph.cpp
@@ -43,7 +43,7 @@
#include <QtQuick>
-#include <private/qsgcontext_p.h>
+#include <private/qopenglcontext_p.h>
#include <QtQml>
@@ -168,7 +168,7 @@ void tst_SceneGraph::manyWindows_data()
struct ShareContextResetter {
public:
- ~ShareContextResetter() { QSGContext::setSharedOpenGLContext(0); }
+ ~ShareContextResetter() { QOpenGLContextPrivate::setGlobalShareContext(0); }
};
void tst_SceneGraph::manyWindows()
@@ -181,7 +181,7 @@ void tst_SceneGraph::manyWindows()
ShareContextResetter cleanup; // To avoid dangling pointer in case of test-failure.
if (shared) {
sharedGLContext.create();
- QSGContext::setSharedOpenGLContext(&sharedGLContext);
+ QOpenGLContextPrivate::setGlobalShareContext(&sharedGLContext);
}
QScopedPointer<QWindow> parent;
@@ -328,7 +328,8 @@ void tst_SceneGraph::render_data()
<< "data/render_StackingOrder.qml"
<< "data/render_Mipmap.qml"
<< "data/render_ImageFiltering.qml"
- << "data/render_bug37555.qml"
+ << "data/render_bug37422.qml"
+ << "data/render_OpacityThroughBatchRoot.qml"
;
QRegExp sampleCount("#samples: *(\\d+)");