summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorOlivier Goffart <olivier.goffart@nokia.com>2010-09-28 11:14:23 (GMT)
committerOlivier Goffart <olivier.goffart@nokia.com>2010-09-28 11:14:23 (GMT)
commit38d7fb497eec5491e2d845e7eb5522dafc6ab42b (patch)
tree9b51ec779b10296ce1cc8ebae29d069c1d2edd55 /tests
parent2868302626b8a31f44df1068514485a89ec27171 (diff)
parent7b796b4dcdebfba55c4754d241edb334217fc550 (diff)
downloadQt-38d7fb497eec5491e2d845e7eb5522dafc6ab42b.zip
Qt-38d7fb497eec5491e2d845e7eb5522dafc6ab42b.tar.gz
Qt-38d7fb497eec5491e2d845e7eb5522dafc6ab42b.tar.bz2
Merge remote branch 'origin/4.7' into qt-master-from-4.7
Conflicts: src/gui/painting/qrasterizer.cpp src/network/access/qnetworkaccessmanager.cpp tests/auto/qpainter/tst_qpainter.cpp tools/assistant/tools/assistant/mainwindow.cpp
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/declarative/qdeclarativeconnection/data/error-object.qml7
-rw-r--r--tests/auto/declarative/qdeclarativeconnection/data/error-property.qml5
-rw-r--r--tests/auto/declarative/qdeclarativeconnection/data/error-property2.qml5
-rw-r--r--tests/auto/declarative/qdeclarativeconnection/data/error-syntax.qml9
-rw-r--r--tests/auto/declarative/qdeclarativeconnection/tst_qdeclarativeconnection.cpp31
-rw-r--r--tests/auto/declarative/qdeclarativedebughelper/private_headers/qdeclarativedebughelper_p.h67
-rw-r--r--tests/auto/declarative/qdeclarativedebughelper/qdeclarativedebughelper.pro5
-rw-r--r--tests/auto/declarative/qdeclarativedebughelper/tst_qdeclarativedebughelper.cpp115
-rw-r--r--tests/auto/declarative/qdeclarativedom/tst_qdeclarativedom.cpp13
-rw-r--r--tests/auto/declarative/qdeclarativeinfo/tst_qdeclarativeinfo.cpp64
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/notAvailable.errors.txt1
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/data/notAvailable.qml4
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/testtypes.cpp2
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/testtypes.h6
-rw-r--r--tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp1
-rw-r--r--tests/auto/declarative/qdeclarativelistmodel/data/multipleroles.qml25
-rw-r--r--tests/auto/declarative/qdeclarativelistmodel/tst_qdeclarativelistmodel.cpp34
-rw-r--r--tests/auto/declarative/qdeclarativemoduleplugin/tst_qdeclarativemoduleplugin.cpp1
-rw-r--r--tests/auto/declarative/qdeclarativeqt/data/quit.qml5
-rw-r--r--tests/auto/declarative/qdeclarativeqt/tst_qdeclarativeqt.cpp14
-rw-r--r--tests/auto/declarative/qdeclarativeview/data/error1.qml5
-rw-r--r--tests/auto/declarative/qdeclarativeview/tst_qdeclarativeview.cpp17
-rw-r--r--tests/auto/qapplication/test/test.pro2
-rw-r--r--tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp188
-rw-r--r--tests/auto/qgraphicsview/tst_qgraphicsview.cpp48
-rw-r--r--tests/auto/qpainter/tst_qpainter.cpp23
-rw-r--r--tests/auto/qsettings/qsettings.pro1
-rw-r--r--tests/auto/qthread/tst_qthread.cpp41
-rw-r--r--tests/auto/qtimer/tst_qtimer.cpp27
-rw-r--r--tests/auto/qtreeview/tst_qtreeview.cpp22
-rw-r--r--tests/auto/qwidget/tst_qwidget.cpp33
31 files changed, 812 insertions, 9 deletions
diff --git a/tests/auto/declarative/qdeclarativeconnection/data/error-object.qml b/tests/auto/declarative/qdeclarativeconnection/data/error-object.qml
new file mode 100644
index 0000000..a8127a4
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativeconnection/data/error-object.qml
@@ -0,0 +1,7 @@
+import Qt 4.7
+
+Item {
+ Connections {
+ onClicked: Item {}
+ }
+}
diff --git a/tests/auto/declarative/qdeclarativeconnection/data/error-property.qml b/tests/auto/declarative/qdeclarativeconnection/data/error-property.qml
new file mode 100644
index 0000000..2791f56
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativeconnection/data/error-property.qml
@@ -0,0 +1,5 @@
+import Qt 4.7
+
+Item {
+ Connections { fakeProperty: {} }
+}
diff --git a/tests/auto/declarative/qdeclarativeconnection/data/error-property2.qml b/tests/auto/declarative/qdeclarativeconnection/data/error-property2.qml
new file mode 100644
index 0000000..0205c0a
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativeconnection/data/error-property2.qml
@@ -0,0 +1,5 @@
+import Qt 4.7
+
+Item {
+ Connections { onfakeProperty: {} }
+}
diff --git a/tests/auto/declarative/qdeclarativeconnection/data/error-syntax.qml b/tests/auto/declarative/qdeclarativeconnection/data/error-syntax.qml
new file mode 100644
index 0000000..867e4e2
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativeconnection/data/error-syntax.qml
@@ -0,0 +1,9 @@
+import Qt 4.7
+
+Item {
+ Connections {
+ onClicked {
+ onPressed: {}
+ }
+ }
+}
diff --git a/tests/auto/declarative/qdeclarativeconnection/tst_qdeclarativeconnection.cpp b/tests/auto/declarative/qdeclarativeconnection/tst_qdeclarativeconnection.cpp
index d384372..a623e96 100644
--- a/tests/auto/declarative/qdeclarativeconnection/tst_qdeclarativeconnection.cpp
+++ b/tests/auto/declarative/qdeclarativeconnection/tst_qdeclarativeconnection.cpp
@@ -66,6 +66,8 @@ private slots:
void targetChanged();
void unknownSignals_data();
void unknownSignals();
+ void errors_data();
+ void errors();
private:
QDeclarativeEngine engine;
@@ -195,9 +197,38 @@ void tst_qdeclarativeconnection::unknownSignals()
QDeclarativeConnections *connections = item->findChild<QDeclarativeConnections*>("connections");
QVERIFY(connections);
+ if (file == "connection-unknownsignals-ignored.qml")
+ QVERIFY(connections->ignoreUnknownSignals());
+
delete item;
}
+void tst_qdeclarativeconnection::errors_data()
+{
+ QTest::addColumn<QString>("file");
+ QTest::addColumn<QString>("error");
+
+ QTest::newRow("no \"on\"") << "error-property.qml" << "Cannot assign to non-existent property \"fakeProperty\"";
+ QTest::newRow("3rd letter lowercase") << "error-property2.qml" << "Cannot assign to non-existent property \"onfakeProperty\"";
+ QTest::newRow("child object") << "error-object.qml" << "Connections: nested objects not allowed";
+ QTest::newRow("grouped object") << "error-syntax.qml" << "Connections: syntax error";
+}
+
+void tst_qdeclarativeconnection::errors()
+{
+ QFETCH(QString, file);
+ QFETCH(QString, error);
+
+ QUrl url = QUrl::fromLocalFile(SRCDIR "/data/" + file);
+
+ QDeclarativeEngine engine;
+ QDeclarativeComponent c(&engine, url);
+ QVERIFY(c.isError() == true);
+ QList<QDeclarativeError> errors = c.errors();
+ QVERIFY(errors.count() == 1);
+ QCOMPARE(errors.at(0).description(), error);
+}
+
QTEST_MAIN(tst_qdeclarativeconnection)
#include "tst_qdeclarativeconnection.moc"
diff --git a/tests/auto/declarative/qdeclarativedebughelper/private_headers/qdeclarativedebughelper_p.h b/tests/auto/declarative/qdeclarativedebughelper/private_headers/qdeclarativedebughelper_p.h
new file mode 100644
index 0000000..c9cb839
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativedebughelper/private_headers/qdeclarativedebughelper_p.h
@@ -0,0 +1,67 @@
+/****************************************************************************
+**
+** 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:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** 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, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QDECLARATIVEDEBUGHELPER_P_H
+#define QDECLARATIVEDEBUGHELPER_P_H
+
+#include <QtCore/qglobal.h>
+
+QT_BEGIN_HEADER
+
+QT_BEGIN_NAMESPACE
+
+class QScriptEngine;
+class QDeclarativeEngine;
+
+// Helper methods to access private API through a stable interface
+// This is used in the qmljsdebugger library of QtCreator.
+class Q_DECLARATIVE_EXPORT QDeclarativeDebugHelper
+{
+public:
+ static QScriptEngine *getScriptEngine(QDeclarativeEngine *engine);
+ static void setAnimationSlowDownFactor(qreal factor);
+};
+
+QT_END_NAMESPACE
+
+QT_END_HEADER
+
+#endif // QDECLARATIVEDEBUGHELPER_P_H
diff --git a/tests/auto/declarative/qdeclarativedebughelper/qdeclarativedebughelper.pro b/tests/auto/declarative/qdeclarativedebughelper/qdeclarativedebughelper.pro
new file mode 100644
index 0000000..c52c652
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativedebughelper/qdeclarativedebughelper.pro
@@ -0,0 +1,5 @@
+load(qttest_p4)
+contains(QT_CONFIG,declarative): QT += network declarative script
+macx:CONFIG -= app_bundle
+
+SOURCES += tst_qdeclarativedebughelper.cpp
diff --git a/tests/auto/declarative/qdeclarativedebughelper/tst_qdeclarativedebughelper.cpp b/tests/auto/declarative/qdeclarativedebughelper/tst_qdeclarativedebughelper.cpp
new file mode 100644
index 0000000..36f2222
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativedebughelper/tst_qdeclarativedebughelper.cpp
@@ -0,0 +1,115 @@
+/****************************************************************************
+**
+** 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 test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** 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, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include <qtest.h>
+
+#include <QDeclarativeEngine>
+#include <private/qdeclarativeengine_p.h>
+#include <QAbstractAnimation>
+#include <private/qabstractanimation_p.h>
+
+// We have copied the header which is used in the qmljsdebugger (part of QtCreator)
+// to catch BC changes. Don't update it unless you know what you are doing!
+#include "private_headers/qdeclarativedebughelper_p.h"
+
+class tst_qdeclarativedebughelper : public QObject {
+ Q_OBJECT
+private slots:
+ void getScriptEngine();
+ void setAnimationSlowDownFactor();
+};
+
+class TestAnimation : public QAbstractAnimation {
+public:
+ int updateCalled;
+
+ TestAnimation() : updateCalled(0) {}
+
+ virtual void updateCurrentTime(int /*currentTime*/) {
+ updateCalled++;
+ }
+ virtual int duration() const {
+ return 100;
+ }
+};
+
+void tst_qdeclarativedebughelper::getScriptEngine()
+{
+ QDeclarativeEngine engine;
+
+ QScriptEngine *scriptEngine = QDeclarativeDebugHelper::getScriptEngine(&engine);
+ QVERIFY(scriptEngine);
+ QCOMPARE(scriptEngine, QDeclarativeEnginePrivate::getScriptEngine(&engine));
+}
+
+void tst_qdeclarativedebughelper::setAnimationSlowDownFactor()
+{
+ TestAnimation animation;
+
+ // first check whether setup works
+ QCOMPARE(animation.updateCalled, 0);
+ animation.start();
+ QTest::qWait(animation.totalDuration() + 50);
+#ifdef Q_OS_WIN
+ if (animation.state() != QAbstractAnimation::Stopped)
+ QEXPECT_FAIL("", "On windows, consistent timing is not working properly due to bad timer resolution", Abort);
+#endif
+ QCOMPARE(animation.state(), QAbstractAnimation::Stopped);
+ QVERIFY(animation.updateCalled > 1);
+
+ // check if we can pause all animations
+ animation.updateCalled = 0;
+ QDeclarativeDebugHelper::setAnimationSlowDownFactor(0.0);
+ animation.start();
+ QTest::qWait(animation.totalDuration() + 50);
+ QVERIFY(animation.updateCalled <= 1); // updateCurrentTime seems to be called at least once
+
+ // now run them again
+ animation.updateCalled = 0;
+ QDeclarativeDebugHelper::setAnimationSlowDownFactor(2.0);
+ animation.start();
+ QTest::qWait(animation.totalDuration() + 50);
+ QVERIFY(animation.updateCalled > 1);
+}
+
+QTEST_MAIN(tst_qdeclarativedebughelper)
+
+#include "tst_qdeclarativedebughelper.moc"
+
diff --git a/tests/auto/declarative/qdeclarativedom/tst_qdeclarativedom.cpp b/tests/auto/declarative/qdeclarativedom/tst_qdeclarativedom.cpp
index dca5205..e1b4c1c 100644
--- a/tests/auto/declarative/qdeclarativedom/tst_qdeclarativedom.cpp
+++ b/tests/auto/declarative/qdeclarativedom/tst_qdeclarativedom.cpp
@@ -493,9 +493,11 @@ void tst_qdeclarativedom::loadDynamicProperty()
{
QByteArray qml = "import Qt 4.7\n"
"Item {\n"
+ " id: item\n"
" property int a: 12\n"
" property int b: a + 6\n"
" default property QtObject c\n"
+ " property alias d: item.a\n"
"}\n";
QDeclarativeDomDocument document;
@@ -504,11 +506,12 @@ void tst_qdeclarativedom::loadDynamicProperty()
QDeclarativeDomObject rootObject = document.rootObject();
QVERIFY(rootObject.isValid());
- QCOMPARE(rootObject.dynamicProperties().count(), 3);
+ QCOMPARE(rootObject.dynamicProperties().count(), 4);
{
QDeclarativeDomDynamicProperty d = rootObject.dynamicProperties().at(0);
QVERIFY(d.isDefaultProperty() == false);
+ QVERIFY(d.isAlias() == false);
QVERIFY(d.defaultValue().isValid());
QVERIFY(d.defaultValue().propertyName() == "a");
QVERIFY(d.defaultValue().value().isLiteral());
@@ -517,6 +520,7 @@ void tst_qdeclarativedom::loadDynamicProperty()
{
QDeclarativeDomDynamicProperty d = rootObject.dynamicProperties().at(1);
QVERIFY(d.isDefaultProperty() == false);
+ QVERIFY(d.isAlias() == false);
QVERIFY(d.defaultValue().isValid());
QVERIFY(d.defaultValue().propertyName() == "b");
QVERIFY(d.defaultValue().value().isBinding());
@@ -525,8 +529,15 @@ void tst_qdeclarativedom::loadDynamicProperty()
{
QDeclarativeDomDynamicProperty d = rootObject.dynamicProperties().at(2);
QVERIFY(d.isDefaultProperty() == true);
+ QVERIFY(d.isAlias() == false);
QVERIFY(d.defaultValue().isValid() == false);
}
+
+ {
+ QDeclarativeDomDynamicProperty d = rootObject.dynamicProperties().at(3);
+ QVERIFY(d.isDefaultProperty() == false);
+ QVERIFY(d.isAlias() == true);
+ }
}
}
diff --git a/tests/auto/declarative/qdeclarativeinfo/tst_qdeclarativeinfo.cpp b/tests/auto/declarative/qdeclarativeinfo/tst_qdeclarativeinfo.cpp
index 03df71f..7fd6279 100644
--- a/tests/auto/declarative/qdeclarativeinfo/tst_qdeclarativeinfo.cpp
+++ b/tests/auto/declarative/qdeclarativeinfo/tst_qdeclarativeinfo.cpp
@@ -63,6 +63,8 @@ private slots:
void nonQmlObject();
void nullObject();
void nonQmlContextedObject();
+ void types();
+ void chaining();
private:
QDeclarativeEngine engine;
@@ -139,6 +141,68 @@ void tst_qdeclarativeinfo::nonQmlContextedObject()
qmlInfo(&object) << "Test Message";
}
+void tst_qdeclarativeinfo::types()
+{
+ QTest::ignoreMessage(QtWarningMsg, "<Unknown File>: false");
+ qmlInfo(0) << false;
+
+ QTest::ignoreMessage(QtWarningMsg, "<Unknown File>: 1.1");
+ qmlInfo(0) << 1.1;
+
+ QTest::ignoreMessage(QtWarningMsg, "<Unknown File>: 1.2");
+ qmlInfo(0) << 1.2f;
+
+ QTest::ignoreMessage(QtWarningMsg, "<Unknown File>: 15");
+ qmlInfo(0) << 15;
+
+ QTest::ignoreMessage(QtWarningMsg, "<Unknown File>: 'b'");
+ qmlInfo(0) << QChar('b');
+
+ QTest::ignoreMessage(QtWarningMsg, "<Unknown File>: \"Qt\"");
+ qmlInfo(0) << QByteArray("Qt");
+
+ QTest::ignoreMessage(QtWarningMsg, "<Unknown File>: true");
+ qmlInfo(0) << QBool(true);
+
+ //### do we actually want QUrl to show up in the output?
+ //### why the extra space at the end?
+ QTest::ignoreMessage(QtWarningMsg, "<Unknown File>: QUrl(\"http://qt.nokia.com\") ");
+ qmlInfo(0) << QUrl("http://qt.nokia.com");
+
+ //### should this be quoted?
+ QTest::ignoreMessage(QtWarningMsg, "<Unknown File>: hello");
+ qmlInfo(0) << QLatin1String("hello");
+
+ //### should this be quoted?
+ QTest::ignoreMessage(QtWarningMsg, "<Unknown File>: World");
+ QString str("Hello World");
+ QStringRef ref(&str, 6, 5);
+ qmlInfo(0) << ref;
+
+ //### should this be quoted?
+ QTest::ignoreMessage(QtWarningMsg, "<Unknown File>: Quick");
+ qmlInfo(0) << QString ("Quick");
+}
+
+void tst_qdeclarativeinfo::chaining()
+{
+ //### should more of these be automatically inserting spaces?
+ QString str("Hello World");
+ QStringRef ref(&str, 6, 5);
+ QTest::ignoreMessage(QtWarningMsg, "<Unknown File>: false 1.1 1.2 15 hello 'b' QUrl(\"http://qt.nokia.com\") World \"Qt\" true Quick ");
+ qmlInfo(0) << false << ' '
+ << 1.1 << ' '
+ << 1.2f << ' '
+ << 15 << ' '
+ << QLatin1String("hello") << ' '
+ << QChar('b') << ' '
+ << QUrl("http://qt.nokia.com")
+ << ref
+ << QByteArray("Qt")
+ << QBool(true)
+ << QString ("Quick");
+}
+
QTEST_MAIN(tst_qdeclarativeinfo)
#include "tst_qdeclarativeinfo.moc"
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/notAvailable.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/notAvailable.errors.txt
new file mode 100644
index 0000000..af95a53
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativelanguage/data/notAvailable.errors.txt
@@ -0,0 +1 @@
+3:1:UnavailableType is unavailable for testing
diff --git a/tests/auto/declarative/qdeclarativelanguage/data/notAvailable.qml b/tests/auto/declarative/qdeclarativelanguage/data/notAvailable.qml
new file mode 100644
index 0000000..7c3c7ee
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativelanguage/data/notAvailable.qml
@@ -0,0 +1,4 @@
+import Test 1.0
+
+UnavailableType {
+}
diff --git a/tests/auto/declarative/qdeclarativelanguage/testtypes.cpp b/tests/auto/declarative/qdeclarativelanguage/testtypes.cpp
index 20cd976..e697aeb 100644
--- a/tests/auto/declarative/qdeclarativelanguage/testtypes.cpp
+++ b/tests/auto/declarative/qdeclarativelanguage/testtypes.cpp
@@ -54,6 +54,8 @@ void registerTypes()
qmlRegisterType<MyGroupedObject>();
qmlRegisterCustomType<MyCustomParserType>("Test", 1, 0, "MyCustomParserType", new MyCustomParserTypeParser);
+
+ qmlRegisterTypeNotAvailable("Test",1,0,"UnavailableType", "UnavailableType is unavailable for testing");
}
QVariant myCustomVariantTypeConverter(const QString &data)
diff --git a/tests/auto/declarative/qdeclarativelanguage/testtypes.h b/tests/auto/declarative/qdeclarativelanguage/testtypes.h
index ac55bae..2b23a49 100644
--- a/tests/auto/declarative/qdeclarativelanguage/testtypes.h
+++ b/tests/auto/declarative/qdeclarativelanguage/testtypes.h
@@ -508,6 +508,12 @@ public:
}
};
+class UnavailableType : public QObject
+{
+ Q_OBJECT
+public:
+ UnavailableType() {}
+};
class MyDotPropertyObject : public QObject
{
diff --git a/tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp b/tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp
index 1825991..37e074b 100644
--- a/tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp
+++ b/tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp
@@ -376,6 +376,7 @@ void tst_qdeclarativelanguage::errors_data()
QTest::newRow("invalidOn") << "invalidOn.qml" << "invalidOn.errors.txt" << false;
QTest::newRow("invalidProperty") << "invalidProperty.qml" << "invalidProperty.errors.txt" << false;
QTest::newRow("nonScriptableProperty") << "nonScriptableProperty.qml" << "nonScriptableProperty.errors.txt" << false;
+ QTest::newRow("notAvailable") << "notAvailable.qml" << "notAvailable.errors.txt" << false;
}
diff --git a/tests/auto/declarative/qdeclarativelistmodel/data/multipleroles.qml b/tests/auto/declarative/qdeclarativelistmodel/data/multipleroles.qml
new file mode 100644
index 0000000..b8f2f32
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativelistmodel/data/multipleroles.qml
@@ -0,0 +1,25 @@
+import Qt 4.7
+ListView {
+ width: 100
+ height: 250
+ delegate: Rectangle {
+ width: 100
+ height: 50
+ color: black ? "black": "white"
+ }
+ model: ListModel {
+ objectName: "listModel"
+ ListElement {
+ black: false
+ rounded: false
+ }
+ ListElement {
+ black: true
+ rounded: false
+ }
+ ListElement {
+ black: true
+ rounded: false
+ }
+ }
+} \ No newline at end of file
diff --git a/tests/auto/declarative/qdeclarativelistmodel/tst_qdeclarativelistmodel.cpp b/tests/auto/declarative/qdeclarativelistmodel/tst_qdeclarativelistmodel.cpp
index f456778..f8d2411 100644
--- a/tests/auto/declarative/qdeclarativelistmodel/tst_qdeclarativelistmodel.cpp
+++ b/tests/auto/declarative/qdeclarativelistmodel/tst_qdeclarativelistmodel.cpp
@@ -91,6 +91,7 @@ private slots:
void enumerate();
void error_data();
void error();
+ void syncError();
void set();
void get();
void get_data();
@@ -98,6 +99,7 @@ private slots:
void get_worker_data();
void get_nested();
void get_nested_data();
+ void crash_model_with_multiple_roles();
};
int tst_qdeclarativelistmodel::roleFromName(const QDeclarativeListModel *model, const QString &roleName)
{
@@ -259,7 +261,7 @@ void tst_qdeclarativelistmodel::dynamic_data()
QTest::newRow("set2") << "{append({'foo':123});set(0,{'foo':456});get(0).foo}" << 456 << "";
QTest::newRow("set3a") << "{append({'foo':123,'bar':456});set(0,{'foo':999});get(0).foo}" << 999 << "";
QTest::newRow("set3b") << "{append({'foo':123,'bar':456});set(0,{'foo':999});get(0).bar}" << 456 << "";
- QTest::newRow("set4a") << "{set(0,{'foo':456})}" << 0 << "<Unknown File>: QML ListModel: set: index 0 out of range";
+ QTest::newRow("set4a") << "{set(0,{'foo':456});count}" << 1 << "";
QTest::newRow("set4c") << "{set(-1,{'foo':456})}" << 0 << "<Unknown File>: QML ListModel: set: index -1 out of range";
QTest::newRow("set5a") << "{append({'foo':123,'bar':456});set(0,123);count}" << 1 << "<Unknown File>: QML ListModel: set: value is not an object";
QTest::newRow("set5b") << "{append({'foo':123,'bar':456});set(0,[1,2,3]);count}" << 1 << "<Unknown File>: QML ListModel: set: value is not an object";
@@ -660,6 +662,21 @@ void tst_qdeclarativelistmodel::error()
}
}
+void tst_qdeclarativelistmodel::syncError()
+{
+ QString qml = "import Qt 4.7\nListModel { id: lm; Component.onCompleted: lm.sync() }";
+ QString error = "file:dummy.qml:2:1: QML ListModel: List sync() can only be called from a WorkerScript";
+
+ QDeclarativeEngine engine;
+ QDeclarativeComponent component(&engine);
+ component.setData(qml.toUtf8(),
+ QUrl::fromLocalFile(QString("dummy.qml")));
+ QTest::ignoreMessage(QtWarningMsg,error.toUtf8());
+ QObject *obj = component.create();
+ QVERIFY(obj);
+ delete obj;
+}
+
/*
Test model changes from set() are available to the view
*/
@@ -886,6 +903,21 @@ void tst_qdeclarativelistmodel::get_nested_data()
get_data();
}
+//QTBUG-13754
+void tst_qdeclarativelistmodel::crash_model_with_multiple_roles()
+{
+ QDeclarativeEngine eng;
+ QDeclarativeComponent component(&eng, QUrl::fromLocalFile(SRCDIR "/data/multipleroles.qml"));
+ QObject *rootItem = component.create();
+ QVERIFY(component.errorString().isEmpty());
+ QVERIFY(rootItem != 0);
+ QDeclarativeListModel *model = rootItem->findChild<QDeclarativeListModel*>("listModel");
+ QVERIFY(model != 0);
+
+ // used to cause a crash in QDeclarativeVisualDataModel
+ model->setProperty(0, "black", true);
+}
+
QTEST_MAIN(tst_qdeclarativelistmodel)
#include "tst_qdeclarativelistmodel.moc"
diff --git a/tests/auto/declarative/qdeclarativemoduleplugin/tst_qdeclarativemoduleplugin.cpp b/tests/auto/declarative/qdeclarativemoduleplugin/tst_qdeclarativemoduleplugin.cpp
index 2081f0e..e1022e0 100644
--- a/tests/auto/declarative/qdeclarativemoduleplugin/tst_qdeclarativemoduleplugin.cpp
+++ b/tests/auto/declarative/qdeclarativemoduleplugin/tst_qdeclarativemoduleplugin.cpp
@@ -117,6 +117,7 @@ void tst_qdeclarativemoduleplugin::importsPlugin()
QObject *object = component.create();
QVERIFY(object != 0);
QCOMPARE(object->property("value").toInt(),123);
+ delete object;
}
QTEST_MAIN(tst_qdeclarativemoduleplugin)
diff --git a/tests/auto/declarative/qdeclarativeqt/data/quit.qml b/tests/auto/declarative/qdeclarativeqt/data/quit.qml
new file mode 100644
index 0000000..f4c8441
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativeqt/data/quit.qml
@@ -0,0 +1,5 @@
+import Qt 4.7
+
+QtObject {
+ Component.onCompleted: Qt.quit()
+}
diff --git a/tests/auto/declarative/qdeclarativeqt/tst_qdeclarativeqt.cpp b/tests/auto/declarative/qdeclarativeqt/tst_qdeclarativeqt.cpp
index 895ee6c..739b10a 100644
--- a/tests/auto/declarative/qdeclarativeqt/tst_qdeclarativeqt.cpp
+++ b/tests/auto/declarative/qdeclarativeqt/tst_qdeclarativeqt.cpp
@@ -50,6 +50,7 @@
#include <QVector3D>
#include <QCryptographicHash>
#include <QDeclarativeItem>
+#include <QSignalSpy>
#ifdef Q_OS_SYMBIAN
// In Symbian OS test data is located in applications private dir
@@ -84,6 +85,7 @@ private slots:
void btoa();
void atob();
void fontFamilies();
+ void quit();
private:
QDeclarativeEngine engine;
@@ -518,6 +520,18 @@ void tst_qdeclarativeqt::fontFamilies()
delete object;
}
+void tst_qdeclarativeqt::quit()
+{
+ QDeclarativeComponent component(&engine, TEST_FILE("quit.qml"));
+
+ QSignalSpy spy(&engine, SIGNAL(quit()));
+ QObject *object = component.create();
+ QVERIFY(object != 0);
+ QCOMPARE(spy.count(), 1);
+
+ delete object;
+}
+
QTEST_MAIN(tst_qdeclarativeqt)
#include "tst_qdeclarativeqt.moc"
diff --git a/tests/auto/declarative/qdeclarativeview/data/error1.qml b/tests/auto/declarative/qdeclarativeview/data/error1.qml
new file mode 100644
index 0000000..c154716
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativeview/data/error1.qml
@@ -0,0 +1,5 @@
+import Qt 4.7
+
+Rectangle {
+ nonExistentProperty: 5
+}
diff --git a/tests/auto/declarative/qdeclarativeview/tst_qdeclarativeview.cpp b/tests/auto/declarative/qdeclarativeview/tst_qdeclarativeview.cpp
index 6450e38..9ac79e4 100644
--- a/tests/auto/declarative/qdeclarativeview/tst_qdeclarativeview.cpp
+++ b/tests/auto/declarative/qdeclarativeview/tst_qdeclarativeview.cpp
@@ -62,6 +62,7 @@ public:
private slots:
void resizemodedeclarativeitem();
void resizemodegraphicswidget();
+ void errors();
private:
template<typename T>
@@ -255,6 +256,22 @@ void tst_QDeclarativeView::resizemodegraphicswidget()
delete canvas;
}
+static void silentErrorsMsgHandler(QtMsgType, const char *)
+{
+}
+
+void tst_QDeclarativeView::errors()
+{
+ QDeclarativeView *canvas = new QDeclarativeView;
+ QVERIFY(canvas);
+ QtMsgHandler old = qInstallMsgHandler(silentErrorsMsgHandler);
+ canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/error1.qml"));
+ qInstallMsgHandler(old);
+ QVERIFY(canvas->status() == QDeclarativeView::Error);
+ QVERIFY(canvas->errors().count() == 1);
+ delete canvas;
+}
+
template<typename T>
T *tst_QDeclarativeView::findItem(QGraphicsObject *parent, const QString &objectName)
{
diff --git a/tests/auto/qapplication/test/test.pro b/tests/auto/qapplication/test/test.pro
index 30eb751..2c54c37 100644
--- a/tests/auto/qapplication/test/test.pro
+++ b/tests/auto/qapplication/test/test.pro
@@ -12,7 +12,7 @@ wince* {
}
symbian: {
- additional.sources = ../desktopsettingsaware/desktopsettingsaware.exe
+ additional.sources = $$OUT_PWD/../desktopsettingsaware/desktopsettingsaware.exe
additional.path = desktopsettingsaware
someTest.sources = test.pro
someTest.path = test
diff --git a/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp b/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp
index 4476084..25ec040 100644
--- a/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp
+++ b/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp
@@ -377,6 +377,7 @@ private slots:
void itemClipsChildrenToShape2();
void itemClipsChildrenToShape3();
void itemClipsChildrenToShape4();
+ void itemClipsChildrenToShape5();
void itemClipsTextChildToShape();
void itemClippingDiscovery();
void ancestorFlags();
@@ -5464,6 +5465,193 @@ void tst_QGraphicsItem::itemClipsChildrenToShape4()
QTRY_COMPARE(innerWidget->painted, true);
}
+//#define DEBUG_ITEM_CLIPS_CHILDREN_TO_SHAPE_5
+static inline void renderSceneToImage(QGraphicsScene *scene, QImage *image, const QString &filename)
+{
+ image->fill(0);
+ QPainter painter(image);
+ scene->render(&painter);
+ painter.end();
+#ifdef DEBUG_ITEM_CLIPS_CHILDREN_TO_SHAPE_5
+ image->save(filename);
+#else
+ Q_UNUSED(filename);
+#endif
+}
+
+void tst_QGraphicsItem::itemClipsChildrenToShape5()
+{
+ class ParentItem : public QGraphicsRectItem
+ {
+ public:
+ ParentItem(qreal x, qreal y, qreal width, qreal height)
+ : QGraphicsRectItem(x, y, width, height) {}
+
+ QPainterPath shape() const
+ {
+ QPainterPath path;
+ path.addRect(50, 50, 200, 200);
+ return path;
+ }
+ };
+
+ ParentItem *parent = new ParentItem(0, 0, 300, 300);
+ parent->setBrush(Qt::blue);
+ parent->setOpacity(0.5);
+
+ const QRegion parentRegion(0, 0, 300, 300);
+ const QRegion clippedParentRegion = parentRegion & QRect(50, 50, 200, 200);
+ QRegion childRegion;
+ QRegion grandChildRegion;
+
+ QGraphicsRectItem *topLeftChild = new QGraphicsRectItem(0, 0, 100, 100);
+ topLeftChild->setBrush(Qt::red);
+ topLeftChild->setParentItem(parent);
+ childRegion += QRect(0, 0, 100, 100);
+
+ QGraphicsRectItem *topRightChild = new QGraphicsRectItem(0, 0, 100, 100);
+ topRightChild->setBrush(Qt::red);
+ topRightChild->setParentItem(parent);
+ topRightChild->setFlag(QGraphicsItem::ItemClipsChildrenToShape);
+ topRightChild->setPos(200, 0);
+ childRegion += QRect(200, 0, 100, 100);
+
+ QGraphicsRectItem *topRightGrandChild = new QGraphicsRectItem(0, 0, 100, 100);
+ topRightGrandChild->setBrush(Qt::green);
+ topRightGrandChild->setParentItem(topRightChild);
+ topRightGrandChild->setPos(-40, 40);
+ grandChildRegion += QRect(200 - 40, 0 + 40, 100, 100) & QRect(200, 0, 100, 100);
+
+ QGraphicsRectItem *bottomLeftChild = new QGraphicsRectItem(0, 0, 100, 100);
+ bottomLeftChild->setBrush(Qt::red);
+ bottomLeftChild->setParentItem(parent);
+ bottomLeftChild->setFlag(QGraphicsItem::ItemClipsToShape);
+ bottomLeftChild->setPos(0, 200);
+ childRegion += QRect(0, 200, 100, 100);
+
+ QGraphicsRectItem *bottomLeftGrandChild = new QGraphicsRectItem(0, 0, 160, 160);
+ bottomLeftGrandChild->setBrush(Qt::green);
+ bottomLeftGrandChild->setParentItem(bottomLeftChild);
+ bottomLeftGrandChild->setFlag(QGraphicsItem::ItemClipsToShape);
+ bottomLeftGrandChild->setPos(0, -60);
+ grandChildRegion += QRect(0, 200 - 60, 160, 160);
+
+ QGraphicsRectItem *bottomRightChild = new QGraphicsRectItem(0, 0, 100, 100);
+ bottomRightChild->setBrush(Qt::red);
+ bottomRightChild->setParentItem(parent);
+ bottomRightChild->setPos(200, 200);
+ childRegion += QRect(200, 200, 100, 100);
+
+ QPoint controlPoints[17] = {
+ QPoint(5, 5) , QPoint(95, 5) , QPoint(205, 5) , QPoint(295, 5) ,
+ QPoint(5, 95) , QPoint(95, 95) , QPoint(205, 95) , QPoint(295, 95) ,
+ QPoint(150, 150),
+ QPoint(5, 205), QPoint(95, 205), QPoint(205, 205), QPoint(295, 205),
+ QPoint(5, 295), QPoint(95, 295), QPoint(205, 295), QPoint(295, 295),
+ };
+
+ const QRegion clippedChildRegion = childRegion & QRect(50, 50, 200, 200);
+ const QRegion clippedGrandChildRegion = grandChildRegion & QRect(50, 50, 200, 200);
+
+ QGraphicsScene scene;
+ scene.addItem(parent);
+ QImage sceneImage(300, 300, QImage::Format_ARGB32);
+
+#define VERIFY_CONTROL_POINTS(pRegion, cRegion, gRegion) \
+ for (int i = 0; i < 17; ++i) { \
+ QPoint controlPoint = controlPoints[i]; \
+ QRgb pixel = sceneImage.pixel(controlPoint.x(), controlPoint.y()); \
+ if (pRegion.contains(controlPoint)) \
+ QVERIFY(qBlue(pixel) != 0); \
+ else \
+ QVERIFY(qBlue(pixel) == 0); \
+ if (cRegion.contains(controlPoint)) \
+ QVERIFY(qRed(pixel) != 0); \
+ else \
+ QVERIFY(qRed(pixel) == 0); \
+ if (gRegion.contains(controlPoint)) \
+ QVERIFY(qGreen(pixel) != 0); \
+ else \
+ QVERIFY(qGreen(pixel) == 0); \
+ }
+
+ const QList<QGraphicsItem *> children = parent->childItems();
+ const int childrenCount = children.count();
+
+ for (int i = 0; i < 5; ++i) {
+ QString clipString;
+ QString childString;
+ switch (i) {
+ case 0:
+ // All children stacked in front.
+ childString = QLatin1String("ChildrenInFront.png");
+ foreach (QGraphicsItem *child, children)
+ child->setFlag(QGraphicsItem::ItemStacksBehindParent, false);
+ break;
+ case 1:
+ // All children stacked behind.
+ childString = QLatin1String("ChildrenBehind.png");
+ foreach (QGraphicsItem *child, children)
+ child->setFlag(QGraphicsItem::ItemStacksBehindParent, true);
+ break;
+ case 2:
+ // First half of the children behind, second half in front.
+ childString = QLatin1String("FirstHalfBehind_SecondHalfInFront.png");
+ for (int j = 0; j < childrenCount; ++j) {
+ QGraphicsItem *child = children.at(j);
+ child->setFlag(QGraphicsItem::ItemStacksBehindParent, (j < childrenCount / 2));
+ }
+ break;
+ case 3:
+ // First half of the children in front, second half behind.
+ childString = QLatin1String("FirstHalfInFront_SecondHalfBehind.png");
+ for (int j = 0; j < childrenCount; ++j) {
+ QGraphicsItem *child = children.at(j);
+ child->setFlag(QGraphicsItem::ItemStacksBehindParent, (j >= childrenCount / 2));
+ }
+ break;
+ case 4:
+ // Child2 and child4 behind, rest in front.
+ childString = QLatin1String("Child2And4Behind_RestInFront.png");
+ for (int j = 0; j < childrenCount; ++j) {
+ QGraphicsItem *child = children.at(j);
+ if (j == 1 || j == 3)
+ child->setFlag(QGraphicsItem::ItemStacksBehindParent, true);
+ else
+ child->setFlag(QGraphicsItem::ItemStacksBehindParent, false);
+ }
+ break;
+ default:
+ qFatal("internal error");
+ }
+
+ // Nothing is clipped.
+ parent->setFlag(QGraphicsItem::ItemClipsChildrenToShape, false);
+ parent->setFlag(QGraphicsItem::ItemClipsToShape, false);
+ clipString = QLatin1String("nothingClipped_");
+ renderSceneToImage(&scene, &sceneImage, clipString + childString);
+ VERIFY_CONTROL_POINTS(parentRegion, childRegion, grandChildRegion);
+
+ // Parent clips children to shape.
+ parent->setFlag(QGraphicsItem::ItemClipsChildrenToShape);
+ clipString = QLatin1String("parentClipsChildrenToShape_");
+ renderSceneToImage(&scene, &sceneImage, clipString + childString);
+ VERIFY_CONTROL_POINTS(parentRegion, clippedChildRegion, clippedGrandChildRegion);
+
+ // Parent clips itself and children to shape.
+ parent->setFlag(QGraphicsItem::ItemClipsToShape);
+ clipString = QLatin1String("parentClipsItselfAndChildrenToShape_");
+ renderSceneToImage(&scene, &sceneImage, clipString + childString);
+ VERIFY_CONTROL_POINTS(clippedParentRegion, clippedChildRegion, clippedGrandChildRegion);
+
+ // Parent clips itself to shape.
+ parent->setFlag(QGraphicsItem::ItemClipsChildrenToShape, false);
+ clipString = QLatin1String("parentClipsItselfToShape_");
+ renderSceneToImage(&scene, &sceneImage, clipString + childString);
+ VERIFY_CONTROL_POINTS(clippedParentRegion, childRegion, grandChildRegion);
+ }
+}
+
void tst_QGraphicsItem::itemClipsTextChildToShape()
{
// Construct a scene with a rect that clips its children, with one text
diff --git a/tests/auto/qgraphicsview/tst_qgraphicsview.cpp b/tests/auto/qgraphicsview/tst_qgraphicsview.cpp
index 7b5ac7a..af02c55 100644
--- a/tests/auto/qgraphicsview/tst_qgraphicsview.cpp
+++ b/tests/auto/qgraphicsview/tst_qgraphicsview.cpp
@@ -2492,25 +2492,31 @@ void tst_QGraphicsView::optimizationFlags_dontSavePainterState()
void tst_QGraphicsView::optimizationFlags_dontSavePainterState2_data()
{
QTest::addColumn<bool>("savePainter");
- QTest::newRow("With painter state protection") << true;
- QTest::newRow("Without painter state protection") << false;
+ QTest::addColumn<bool>("indirectPainting");
+ QTest::newRow("With painter state protection, without indirect painting") << true << false;
+ QTest::newRow("Without painter state protection, without indirect painting") << false << false;
+ QTest::newRow("With painter state protectionm, with indirect painting") << true << true;
+ QTest::newRow("Without painter state protection, with indirect painting") << false << true;
}
void tst_QGraphicsView::optimizationFlags_dontSavePainterState2()
{
QFETCH(bool, savePainter);
+ QFETCH(bool, indirectPainting);
class MyScene : public QGraphicsScene
{
public:
void drawBackground(QPainter *p, const QRectF &)
- { transformInDrawBackground = p->worldTransform(); }
+ { transformInDrawBackground = p->worldTransform(); opacityInDrawBackground = p->opacity(); }
void drawForeground(QPainter *p, const QRectF &)
- { transformInDrawForeground = p->worldTransform(); }
+ { transformInDrawForeground = p->worldTransform(); opacityInDrawForeground = p->opacity(); }
QTransform transformInDrawBackground;
QTransform transformInDrawForeground;
+ qreal opacityInDrawBackground;
+ qreal opacityInDrawForeground;
};
MyScene scene;
@@ -2518,9 +2524,13 @@ void tst_QGraphicsView::optimizationFlags_dontSavePainterState2()
scene.addRect(0, 0, 20, 20)->setTransform(QTransform::fromScale(2, 2));
scene.addRect(50, 50, 20, 20)->setTransform(QTransform::fromTranslate(200, 200));
+ foreach (QGraphicsItem *item, scene.items())
+ item->setOpacity(0.6);
+
CustomView view(&scene);
if (!savePainter)
view.setOptimizationFlag(QGraphicsView::DontSavePainterState);
+ view.setOptimizationFlag(QGraphicsView::IndirectPainting, indirectPainting);
view.rotate(45);
view.scale(1.5, 1.5);
view.show();
@@ -2534,10 +2544,38 @@ void tst_QGraphicsView::optimizationFlags_dontSavePainterState2()
QVERIFY(view.painted);
// Make sure the painter's world transform is preserved after drawItems.
- const QTransform expectedTransform = view.viewportTransform();
+ QTransform expectedTransform = view.viewportTransform();
QVERIFY(!expectedTransform.isIdentity());
QCOMPARE(scene.transformInDrawForeground, expectedTransform);
QCOMPARE(scene.transformInDrawBackground, expectedTransform);
+
+ qreal expectedOpacity = 1.0;
+ QCOMPARE(scene.opacityInDrawBackground, expectedOpacity);
+ QCOMPARE(scene.opacityInDrawForeground, expectedOpacity);
+
+ // Trigger more painting, this time from QGraphicsScene::render.
+ QImage image(scene.sceneRect().size().toSize(), QImage::Format_RGB32);
+ QPainter painter(&image);
+ scene.render(&painter);
+ painter.end();
+
+ expectedTransform = QTransform();
+ QCOMPARE(scene.transformInDrawForeground, expectedTransform);
+ QCOMPARE(scene.transformInDrawBackground, expectedTransform);
+ QCOMPARE(scene.opacityInDrawBackground, expectedOpacity);
+ QCOMPARE(scene.opacityInDrawForeground, expectedOpacity);
+
+ // Trigger more painting with another opacity on the painter.
+ painter.begin(&image);
+ painter.setOpacity(0.4);
+ expectedOpacity = 0.4;
+ scene.render(&painter);
+ painter.end();
+
+ QCOMPARE(scene.transformInDrawForeground, expectedTransform);
+ QCOMPARE(scene.transformInDrawBackground, expectedTransform);
+ QCOMPARE(scene.opacityInDrawBackground, expectedOpacity);
+ QCOMPARE(scene.opacityInDrawForeground, expectedOpacity);
}
class LodItem : public QGraphicsRectItem
diff --git a/tests/auto/qpainter/tst_qpainter.cpp b/tests/auto/qpainter/tst_qpainter.cpp
index ae97285..f7db6b3 100644
--- a/tests/auto/qpainter/tst_qpainter.cpp
+++ b/tests/auto/qpainter/tst_qpainter.cpp
@@ -256,6 +256,8 @@ private slots:
void QTBUG5939_attachPainterPrivate();
+ void drawPointScaled();
+
private:
void fillData();
void setPenColor(QPainter& p);
@@ -3174,7 +3176,6 @@ void fpe_steepSlopes()
p.setRenderHint(QPainter::Antialiasing, antialiased);
p.setTransform(transform);
- QEXPECT_FAIL("steep line 3 aa", "needs to be fixed", Continue);
p.drawLine(line);
}
@@ -4631,6 +4632,26 @@ void tst_QPainter::drawText_subPixelPositionsInRaster_qtbug5053()
QVERIFY(foundDifferentRasterization);
}
+void tst_QPainter::drawPointScaled()
+{
+ QImage image(32, 32, QImage::Format_RGB32);
+ image.fill(0xffffffff);
+
+ QPainter p(&image);
+
+ p.scale(0.1, 0.1);
+
+ QPen pen;
+ pen.setWidth(1000);
+ pen.setColor(Qt::red);
+
+ p.setPen(pen);
+ p.drawPoint(0, 0);
+ p.end();
+
+ QCOMPARE(image.pixel(16, 16), 0xffff0000);
+}
+
QTEST_MAIN(tst_QPainter)
#include "tst_qpainter.moc"
diff --git a/tests/auto/qsettings/qsettings.pro b/tests/auto/qsettings/qsettings.pro
index 115fb13..19513b3 100644
--- a/tests/auto/qsettings/qsettings.pro
+++ b/tests/auto/qsettings/qsettings.pro
@@ -5,3 +5,4 @@ RESOURCES += qsettings.qrc
contains(QT_CONFIG, qt3support):QT += qt3support
CONFIG -= debug
CONFIG += release
+win32-msvc*:LIBS += advapi32.lib
diff --git a/tests/auto/qthread/tst_qthread.cpp b/tests/auto/qthread/tst_qthread.cpp
index 7a5b053..843749a 100644
--- a/tests/auto/qthread/tst_qthread.cpp
+++ b/tests/auto/qthread/tst_qthread.cpp
@@ -49,6 +49,7 @@
#include <qtimer.h>
#include <qwaitcondition.h>
#include <qdebug.h>
+#include <qmetaobject.h>
#ifdef Q_OS_UNIX
#include <pthread.h>
@@ -104,6 +105,8 @@ private slots:
void adoptedThreadFinished();
void adoptMultipleThreads();
+ void QTBUG13810_exitAndStart();
+
void stressTest();
};
@@ -934,6 +937,44 @@ void tst_QThread::stressTest()
}
}
+class Syncronizer : public QObject
+{ Q_OBJECT
+public slots:
+ void setProp(int p) {
+ if(m_prop != p) {
+ m_prop = p;
+ emit propChanged(p);
+ }
+ }
+signals:
+ void propChanged(int);
+public:
+ Syncronizer() : m_prop(42) {}
+ int m_prop;
+};
+
+void tst_QThread::QTBUG13810_exitAndStart()
+{
+ QThread thread;
+ thread.exit(555); //should do nothing
+
+ thread.start();
+
+ //test that the thread is running by executing queued connected signal there
+ Syncronizer sync1;
+ sync1.moveToThread(&thread);
+ Syncronizer sync2;
+ sync2.moveToThread(&thread);
+ connect(&sync2, SIGNAL(propChanged(int)), &sync1, SLOT(setProp(int)), Qt::QueuedConnection);
+ connect(&sync1, SIGNAL(propChanged(int)), &thread, SLOT(quit()), Qt::QueuedConnection);
+ QMetaObject::invokeMethod(&sync2, "setProp", Qt::QueuedConnection , Q_ARG(int, 89));
+ QTest::qWait(50);
+ while(!thread.wait(10))
+ QTest::qWait(10);
+ QCOMPARE(sync2.m_prop, 89);
+ QCOMPARE(sync1.m_prop, 89);
+}
+
QTEST_MAIN(tst_QThread)
#include "tst_qthread.moc"
diff --git a/tests/auto/qtimer/tst_qtimer.cpp b/tests/auto/qtimer/tst_qtimer.cpp
index f23d065..102308e 100644
--- a/tests/auto/qtimer/tst_qtimer.cpp
+++ b/tests/auto/qtimer/tst_qtimer.cpp
@@ -89,6 +89,7 @@ private slots:
void recurseOnTimeoutAndStopTimer();
void QTBUG13633_dontBlockEvents();
+ void postedEventsShouldNotStarveTimers();
};
class TimerHelper : public QObject
@@ -723,5 +724,31 @@ void tst_QTimer::QTBUG13633_dontBlockEvents()
QVERIFY(t.total > 2);
}
+class SlotRepeater : public QObject {
+ Q_OBJECT
+public:
+ SlotRepeater() {}
+
+public slots:
+ void repeatThisSlot()
+ {
+ QMetaObject::invokeMethod(this, "repeatThisSlot", Qt::QueuedConnection);
+ }
+};
+
+void tst_QTimer::postedEventsShouldNotStarveTimers()
+{
+ TimerHelper timerHelper;
+ QTimer timer;
+ connect(&timer, SIGNAL(timeout()), &timerHelper, SLOT(timeout()));
+ timer.setInterval(0);
+ timer.setSingleShot(false);
+ timer.start();
+ SlotRepeater slotRepeater;
+ slotRepeater.repeatThisSlot();
+ QTest::qWait(100);
+ QVERIFY(timerHelper.count > 5);
+}
+
QTEST_MAIN(tst_QTimer)
#include "tst_qtimer.moc"
diff --git a/tests/auto/qtreeview/tst_qtreeview.cpp b/tests/auto/qtreeview/tst_qtreeview.cpp
index 7e2e800..c7b53e9 100644
--- a/tests/auto/qtreeview/tst_qtreeview.cpp
+++ b/tests/auto/qtreeview/tst_qtreeview.cpp
@@ -240,6 +240,7 @@ private slots:
void taskQTBUG_6450_selectAllWith1stColumnHidden();
void taskQTBUG_9216_setSizeAndUniformRowHeightsWrongRepaint();
void taskQTBUG_11466_keyboardNavigationRegression();
+ void taskQTBUG_13567_removeLastItemRegression();
};
class QtTestModel: public QAbstractItemModel
@@ -3910,5 +3911,26 @@ void tst_QTreeView::taskQTBUG_11466_keyboardNavigationRegression()
QTRY_COMPARE(treeView.currentIndex(), treeView.selectionModel()->selection().indexes().first());
}
+void tst_QTreeView::taskQTBUG_13567_removeLastItemRegression()
+{
+ QtTestModel model(200, 1);
+
+ QTreeView view;
+ view.setSelectionMode(QAbstractItemView::ExtendedSelection);
+ view.setModel(&model);
+ view.show();
+ QTest::qWaitForWindowShown(&view);
+
+ view.scrollToBottom();
+ QTest::qWait(10);
+ CHECK_VISIBLE(199, 0);
+
+ view.setCurrentIndex(model.index(199, 0));
+ model.removeLastRow();
+ QTest::qWait(10);
+ QCOMPARE(view.currentIndex(), model.index(198, 0));
+ CHECK_VISIBLE(198, 0);
+}
+
QTEST_MAIN(tst_QTreeView)
#include "tst_qtreeview.moc"
diff --git a/tests/auto/qwidget/tst_qwidget.cpp b/tests/auto/qwidget/tst_qwidget.cpp
index 902c8ff..a2b8d5b 100644
--- a/tests/auto/qwidget/tst_qwidget.cpp
+++ b/tests/auto/qwidget/tst_qwidget.cpp
@@ -70,6 +70,7 @@
#include <qtoolbar.h>
#include <QtGui/qpaintengine.h>
#include <private/qbackingstore_p.h>
+#include <qmenubar.h>
#include <QtGui/QGraphicsView>
#include <QtGui/QGraphicsProxyWidget>
@@ -81,8 +82,14 @@
#include <avkon.hrh> // EEikStatusPaneUidTitle
#include <akntitle.h> // CAknTitlePane
#include <akncontext.h> // CAknContextPane
+#endif
+
+#ifdef Q_OS_SYMBIAN
#include <eikspane.h> // CEikStatusPane
#include <eikbtgpc.h> // CEikButtonGroupContainer
+#include <eikenv.h> // CEikonEnv
+#include <eikaufty.h> // MEikAppUiFactory
+#include <eikmenub.h> // CEikMenuBar
#endif
#ifdef Q_WS_QWS
@@ -387,6 +394,7 @@ private slots:
void maximizedWindowModeTransitions();
void minimizedWindowModeTransitions();
void normalWindowModeTransitions();
+ void focusSwitchClosesPopupMenu();
#endif
void focusProxyAndInputMethods();
@@ -10227,6 +10235,31 @@ void tst_QWidget::normalWindowModeTransitions()
QVERIFY(!buttonGroup->IsVisible());
QVERIFY(!statusPane->IsVisible());
}
+
+void tst_QWidget::focusSwitchClosesPopupMenu()
+{
+ QMainWindow mainWindow;
+ QAction action("Test action", &mainWindow);
+ mainWindow.menuBar()->addAction(&action);
+
+ mainWindow.show();
+ QT_TRAP_THROWING(CEikonEnv::Static()->AppUiFactory()->MenuBar()->TryDisplayMenuBarL());
+ QVERIFY(CEikonEnv::Static()->AppUiFactory()->MenuBar()->IsDisplayed());
+
+ // Close the popup by opening a new window.
+ QMainWindow mainWindow2;
+ QAction action2("Test action", &mainWindow2);
+ mainWindow2.menuBar()->addAction(&action2);
+ mainWindow2.show();
+ QVERIFY(!CEikonEnv::Static()->AppUiFactory()->MenuBar()->IsDisplayed());
+
+ QT_TRAP_THROWING(CEikonEnv::Static()->AppUiFactory()->MenuBar()->TryDisplayMenuBarL());
+ QVERIFY(CEikonEnv::Static()->AppUiFactory()->MenuBar()->IsDisplayed());
+
+ // Close the popup by switching focus.
+ mainWindow.activateWindow();
+ QVERIFY(!CEikonEnv::Static()->AppUiFactory()->MenuBar()->IsDisplayed());
+}
#endif
class InputContextTester : public QInputContext