summaryrefslogtreecommitdiffstats
path: root/tests/auto
diff options
context:
space:
mode:
authorKent Hansen <khansen@trolltech.com>2009-08-05 14:10:47 (GMT)
committerKent Hansen <khansen@trolltech.com>2009-08-05 14:10:47 (GMT)
commit1d7d5436eea09a232187836e59d2a937a752dee4 (patch)
tree6bd9ae61abb1467aceddc5a828fc2e65d93b2534 /tests/auto
parent791bddfcd5cc7540219835ef5d91486acd833c4b (diff)
parentfb8bb148affec842e8fa1a70616c64c7d3066ee8 (diff)
downloadQt-1d7d5436eea09a232187836e59d2a937a752dee4.zip
Qt-1d7d5436eea09a232187836e59d2a937a752dee4.tar.gz
Qt-1d7d5436eea09a232187836e59d2a937a752dee4.tar.bz2
Merge branch 'master' of git@scm.dev.nokia.troll.no:qt/qt into qtscript-jsc-backend
Conflicts: src/script/qscriptextqobject.cpp
Diffstat (limited to 'tests/auto')
-rw-r--r--tests/auto/auto.pro7
-rw-r--r--tests/auto/math3d/qmatrixnxn/tst_qmatrixnxn.cpp47
-rw-r--r--tests/auto/math3d/qquaternion/tst_qquaternion.cpp52
-rw-r--r--tests/auto/math3d/qvectornd/tst_qvectornd.cpp96
-rw-r--r--tests/auto/moc/os9-newlines.h2
-rw-r--r--tests/auto/moc/tst_moc.cpp7
-rw-r--r--tests/auto/q3socket/tst_qsocket.cpp14
-rw-r--r--tests/auto/q3sqlcursor/tst_q3sqlcursor.cpp6
-rw-r--r--tests/auto/q3urloperator/tst_q3urloperator.cpp12
-rw-r--r--tests/auto/qaudiodeviceid/qaudiodeviceid.pro7
-rw-r--r--tests/auto/qaudiodeviceid/tst_qaudiodeviceid.cpp98
-rw-r--r--tests/auto/qaudiodeviceinfo/qaudiodeviceinfo.pro7
-rw-r--r--tests/auto/qaudiodeviceinfo/tst_qaudiodeviceinfo.cpp159
-rw-r--r--tests/auto/qaudioformat/qaudioformat.pro7
-rw-r--r--tests/auto/qaudioformat/tst_qaudioformat.cpp180
-rw-r--r--tests/auto/qaudioinput/qaudioinput.pro7
-rw-r--r--tests/auto/qaudioinput/tst_qaudioinput.cpp120
-rw-r--r--tests/auto/qaudiooutput/4.wavbin0 -> 5538 bytes
-rw-r--r--tests/auto/qaudiooutput/qaudiooutput.pro12
-rw-r--r--tests/auto/qaudiooutput/tst_qaudiooutput.cpp156
-rw-r--r--tests/auto/qcompleter/tst_qcompleter.cpp27
-rw-r--r--tests/auto/qdom/tst_qdom.cpp8
-rw-r--r--tests/auto/qfiledialog/tst_qfiledialog.cpp43
-rw-r--r--tests/auto/qformlayout/tst_qformlayout.cpp30
-rw-r--r--tests/auto/qgl/tst_qgl.cpp330
-rw-r--r--tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp29
-rw-r--r--tests/auto/qguard/qguard.pro2
-rw-r--r--tests/auto/qguard/tst_qguard.cpp350
-rw-r--r--tests/auto/qhelpenginecore/data/collection.qhcbin10240 -> 10240 bytes
-rw-r--r--tests/auto/qhelpenginecore/data/collection1.qhcbin10240 -> 10240 bytes
-rw-r--r--tests/auto/qhelpenginecore/data/linguist-3.3.8.qchbin131072 -> 131072 bytes
-rw-r--r--tests/auto/qhelpenginecore/data/qmake-3.3.8.qchbin61440 -> 61440 bytes
-rw-r--r--tests/auto/qhelpenginecore/data/qmake-4.3.0.qchbin93184 -> 93184 bytes
-rw-r--r--tests/auto/qhelpenginecore/data/test.qchbin22528 -> 22528 bytes
-rw-r--r--tests/auto/qhelpenginecore/tst_qhelpenginecore.cpp40
-rw-r--r--tests/auto/qhelpindexmodel/data/collection.qhcbin10240 -> 10240 bytes
-rw-r--r--tests/auto/qhelpindexmodel/data/collection1.qhcbin10240 -> 10240 bytes
-rw-r--r--tests/auto/qhelpindexmodel/data/linguist-3.3.8.qchbin131072 -> 131072 bytes
-rw-r--r--tests/auto/qhelpindexmodel/data/qmake-3.3.8.qchbin61440 -> 61440 bytes
-rw-r--r--tests/auto/qhelpindexmodel/data/qmake-4.3.0.qchbin93184 -> 93184 bytes
-rw-r--r--tests/auto/qhelpindexmodel/data/test.qchbin22528 -> 22528 bytes
-rw-r--r--tests/auto/qhelpindexmodel/tst_qhelpindexmodel.cpp6
-rw-r--r--tests/auto/qitemdelegate/tst_qitemdelegate.cpp33
-rw-r--r--tests/auto/qitemselectionmodel/tst_qitemselectionmodel.cpp2
-rw-r--r--tests/auto/qlocale/tst_qlocale.cpp16
-rw-r--r--tests/auto/qmake/testdata/simple_app_build/README1
-rw-r--r--tests/auto/qmenu/tst_qmenu.cpp48
-rw-r--r--tests/auto/qmetaobject/tst_qmetaobject.cpp34
-rw-r--r--tests/auto/qnetworkreply/tst_qnetworkreply.cpp265
-rw-r--r--tests/auto/qobject/tst_qobject.cpp11
-rw-r--r--tests/auto/qparallelanimationgroup/tst_qparallelanimationgroup.cpp33
-rw-r--r--tests/auto/qplaintextedit/tst_qplaintextedit.cpp7
-rw-r--r--tests/auto/qscriptcontext/tst_qscriptcontext.cpp30
-rw-r--r--tests/auto/qscriptengine/tst_qscriptengine.cpp29
-rw-r--r--tests/auto/qsequentialanimationgroup/tst_qsequentialanimationgroup.cpp36
-rw-r--r--tests/auto/qsharedpointer/qsharedpointer.pro11
-rw-r--r--tests/auto/qsharedpointer/tst_qsharedpointer.cpp438
-rw-r--r--tests/auto/qsharedpointer/wrapper.cpp60
-rw-r--r--tests/auto/qsharedpointer/wrapper.h55
-rw-r--r--tests/auto/qsharedpointer_and_qwidget/qsharedpointer_and_qwidget.pro3
-rw-r--r--tests/auto/qsharedpointer_and_qwidget/tst_qsharedpointer_and_qwidget.cpp150
-rw-r--r--tests/auto/qsqldatabase/tst_databases.h12
-rw-r--r--tests/auto/qsqldatabase/tst_qsqldatabase.cpp14
-rw-r--r--tests/auto/qsqlrelationaltablemodel/tst_qsqlrelationaltablemodel.cpp8
-rw-r--r--tests/auto/qstate/tst_qstate.cpp5
-rw-r--r--tests/auto/qstatemachine/tst_qstatemachine.cpp71
-rw-r--r--tests/auto/selftests/expected_longstring.txt16
-rw-r--r--tests/auto/selftests/longstring/longstring.pro10
-rw-r--r--tests/auto/selftests/longstring/tst_longstring.cpp72
-rw-r--r--tests/auto/selftests/selftests.pro2
-rw-r--r--tests/auto/selftests/selftests.qrc1
-rw-r--r--tests/auto/selftests/tst_selftests.cpp8
-rw-r--r--tests/auto/tests.xml8
-rw-r--r--tests/auto/uic3/uic3.pro3
-rw-r--r--tests/auto/uiloader/baseline/css_task259226_spinboxes.ui83
75 files changed, 3126 insertions, 310 deletions
diff --git a/tests/auto/auto.pro b/tests/auto/auto.pro
index b4a6600..c923dee 100644
--- a/tests/auto/auto.pro
+++ b/tests/auto/auto.pro
@@ -270,7 +270,8 @@ SUBDIRS += _networkselftest \
qscriptenginedebugger \
qscrollarea \
qsemaphore \
- qsharedpointer \
+ qsharedpointer \
+ qsharedpointer_and_qwidget \
qsequentialanimationgroup \
qset \
qsettings \
@@ -284,6 +285,10 @@ SUBDIRS += _networkselftest \
qsocks5socketengine \
qsortfilterproxymodel \
qsound \
+ qaudiodeviceid \
+ qaudioformat \
+ qaudiooutput \
+ qaudioinput \
qspinbox \
qsplitter \
qsql \
diff --git a/tests/auto/math3d/qmatrixnxn/tst_qmatrixnxn.cpp b/tests/auto/math3d/qmatrixnxn/tst_qmatrixnxn.cpp
index d799c1b..fe1d0db 100644
--- a/tests/auto/math3d/qmatrixnxn/tst_qmatrixnxn.cpp
+++ b/tests/auto/math3d/qmatrixnxn/tst_qmatrixnxn.cpp
@@ -170,6 +170,9 @@ private slots:
void mapRect_data();
void mapRect();
+ void properties();
+ void metaTypes();
+
private:
static void setMatrix(QMatrix2x2& m, const qreal *values);
static void setMatrixDirect(QMatrix2x2& m, const qreal *values);
@@ -3331,6 +3334,50 @@ void tst_QMatrix::mapRect()
QVERIFY(mri == tri);
}
+class tst_QMatrix4x4Properties : public QObject
+{
+ Q_OBJECT
+ Q_PROPERTY(QMatrix4x4 matrix READ matrix WRITE setMatrix)
+public:
+ tst_QMatrix4x4Properties(QObject *parent = 0) : QObject(parent) {}
+
+ QMatrix4x4 matrix() const { return m; }
+ void setMatrix(const QMatrix4x4& value) { m = value; }
+
+private:
+ QMatrix4x4 m;
+};
+
+// Test getting and setting matrix properties via the metaobject system.
+void tst_QMatrix::properties()
+{
+ tst_QMatrix4x4Properties obj;
+
+ QMatrix4x4 m1(uniqueValues4);
+ obj.setMatrix(m1);
+
+ QMatrix4x4 m2 = qVariantValue<QMatrix4x4>(obj.property("matrix"));
+ QVERIFY(isSame(m2, uniqueValues4));
+
+ QMatrix4x4 m3(transposedValues4);
+ obj.setProperty("matrix", qVariantFromValue(m3));
+
+ m2 = qVariantValue<QMatrix4x4>(obj.property("matrix"));
+ QVERIFY(isSame(m2, transposedValues4));
+}
+
+void tst_QMatrix::metaTypes()
+{
+ QVERIFY(QMetaType::type("QMatrix4x4") == QMetaType::QMatrix4x4);
+
+ QCOMPARE(QByteArray(QMetaType::typeName(QMetaType::QMatrix4x4)),
+ QByteArray("QMatrix4x4"));
+
+ QVERIFY(QMetaType::isRegistered(QMetaType::QMatrix4x4));
+
+ QVERIFY(qMetaTypeId<QMatrix4x4>() == QMetaType::QMatrix4x4);
+}
+
QTEST_APPLESS_MAIN(tst_QMatrix)
#include "tst_qmatrixnxn.moc"
diff --git a/tests/auto/math3d/qquaternion/tst_qquaternion.cpp b/tests/auto/math3d/qquaternion/tst_qquaternion.cpp
index 16b87a1..369f5ac 100644
--- a/tests/auto/math3d/qquaternion/tst_qquaternion.cpp
+++ b/tests/auto/math3d/qquaternion/tst_qquaternion.cpp
@@ -93,6 +93,9 @@ private slots:
void nlerp_data();
void nlerp();
+
+ void properties();
+ void metaTypes();
};
// qFuzzyCompare isn't always "fuzzy" enough to handle conversion
@@ -825,6 +828,55 @@ void tst_QQuaternion::nlerp()
QVERIFY(fuzzyCompare(result.scalar(), q3.scalar()));
}
+class tst_QQuaternionProperties : public QObject
+{
+ Q_OBJECT
+ Q_PROPERTY(QQuaternion quaternion READ quaternion WRITE setQuaternion)
+public:
+ tst_QQuaternionProperties(QObject *parent = 0) : QObject(parent) {}
+
+ QQuaternion quaternion() const { return q; }
+ void setQuaternion(const QQuaternion& value) { q = value; }
+
+private:
+ QQuaternion q;
+};
+
+// Test getting and setting quaternion properties via the metaobject system.
+void tst_QQuaternion::properties()
+{
+ tst_QQuaternionProperties obj;
+
+ obj.setQuaternion(QQuaternion(6.0f, 7.0f, 8.0f, 9.0f));
+
+ QQuaternion q = qVariantValue<QQuaternion>(obj.property("quaternion"));
+ QCOMPARE(q.scalar(), (qreal)6.0f);
+ QCOMPARE(q.x(), (qreal)7.0f);
+ QCOMPARE(q.y(), (qreal)8.0f);
+ QCOMPARE(q.z(), (qreal)9.0f);
+
+ obj.setProperty("quaternion",
+ qVariantFromValue(QQuaternion(-6.0f, -7.0f, -8.0f, -9.0f)));
+
+ q = qVariantValue<QQuaternion>(obj.property("quaternion"));
+ QCOMPARE(q.scalar(), (qreal)-6.0f);
+ QCOMPARE(q.x(), (qreal)-7.0f);
+ QCOMPARE(q.y(), (qreal)-8.0f);
+ QCOMPARE(q.z(), (qreal)-9.0f);
+}
+
+void tst_QQuaternion::metaTypes()
+{
+ QVERIFY(QMetaType::type("QQuaternion") == QMetaType::QQuaternion);
+
+ QCOMPARE(QByteArray(QMetaType::typeName(QMetaType::QQuaternion)),
+ QByteArray("QQuaternion"));
+
+ QVERIFY(QMetaType::isRegistered(QMetaType::QQuaternion));
+
+ QVERIFY(qMetaTypeId<QQuaternion>() == QMetaType::QQuaternion);
+}
+
QTEST_APPLESS_MAIN(tst_QQuaternion)
#include "tst_qquaternion.moc"
diff --git a/tests/auto/math3d/qvectornd/tst_qvectornd.cpp b/tests/auto/math3d/qvectornd/tst_qvectornd.cpp
index 9c1ea83..6368874 100644
--- a/tests/auto/math3d/qvectornd/tst_qvectornd.cpp
+++ b/tests/auto/math3d/qvectornd/tst_qvectornd.cpp
@@ -137,6 +137,9 @@ private slots:
void dotProduct3();
void dotProduct4_data();
void dotProduct4();
+
+ void properties();
+ void metaTypes();
};
// qFuzzyCompare isn't always "fuzzy" enough to handle conversion
@@ -2040,6 +2043,99 @@ void tst_QVector::dotProduct4()
QCOMPARE(QVector4D::dotProduct(v1, v2), d);
}
+class tst_QVectorProperties : public QObject
+{
+ Q_OBJECT
+ Q_PROPERTY(QVector2D vector2D READ vector2D WRITE setVector2D)
+ Q_PROPERTY(QVector3D vector3D READ vector3D WRITE setVector3D)
+ Q_PROPERTY(QVector4D vector4D READ vector4D WRITE setVector4D)
+public:
+ tst_QVectorProperties(QObject *parent = 0) : QObject(parent) {}
+
+ QVector2D vector2D() const { return v2; }
+ void setVector2D(const QVector2D& value) { v2 = value; }
+
+ QVector3D vector3D() const { return v3; }
+ void setVector3D(const QVector3D& value) { v3 = value; }
+
+ QVector4D vector4D() const { return v4; }
+ void setVector4D(const QVector4D& value) { v4 = value; }
+
+private:
+ QVector2D v2;
+ QVector3D v3;
+ QVector4D v4;
+};
+
+// Test getting and setting vector properties via the metaobject system.
+void tst_QVector::properties()
+{
+ tst_QVectorProperties obj;
+
+ obj.setVector2D(QVector2D(1.0f, 2.0f));
+ obj.setVector3D(QVector3D(3.0f, 4.0f, 5.0f));
+ obj.setVector4D(QVector4D(6.0f, 7.0f, 8.0f, 9.0f));
+
+ QVector2D v2 = qVariantValue<QVector2D>(obj.property("vector2D"));
+ QCOMPARE(v2.x(), (qreal)1.0f);
+ QCOMPARE(v2.y(), (qreal)2.0f);
+
+ QVector3D v3 = qVariantValue<QVector3D>(obj.property("vector3D"));
+ QCOMPARE(v3.x(), (qreal)3.0f);
+ QCOMPARE(v3.y(), (qreal)4.0f);
+ QCOMPARE(v3.z(), (qreal)5.0f);
+
+ QVector4D v4 = qVariantValue<QVector4D>(obj.property("vector4D"));
+ QCOMPARE(v4.x(), (qreal)6.0f);
+ QCOMPARE(v4.y(), (qreal)7.0f);
+ QCOMPARE(v4.z(), (qreal)8.0f);
+ QCOMPARE(v4.w(), (qreal)9.0f);
+
+ obj.setProperty("vector2D",
+ qVariantFromValue(QVector2D(-1.0f, -2.0f)));
+ obj.setProperty("vector3D",
+ qVariantFromValue(QVector3D(-3.0f, -4.0f, -5.0f)));
+ obj.setProperty("vector4D",
+ qVariantFromValue(QVector4D(-6.0f, -7.0f, -8.0f, -9.0f)));
+
+ v2 = qVariantValue<QVector2D>(obj.property("vector2D"));
+ QCOMPARE(v2.x(), (qreal)-1.0f);
+ QCOMPARE(v2.y(), (qreal)-2.0f);
+
+ v3 = qVariantValue<QVector3D>(obj.property("vector3D"));
+ QCOMPARE(v3.x(), (qreal)-3.0f);
+ QCOMPARE(v3.y(), (qreal)-4.0f);
+ QCOMPARE(v3.z(), (qreal)-5.0f);
+
+ v4 = qVariantValue<QVector4D>(obj.property("vector4D"));
+ QCOMPARE(v4.x(), (qreal)-6.0f);
+ QCOMPARE(v4.y(), (qreal)-7.0f);
+ QCOMPARE(v4.z(), (qreal)-8.0f);
+ QCOMPARE(v4.w(), (qreal)-9.0f);
+}
+
+void tst_QVector::metaTypes()
+{
+ QVERIFY(QMetaType::type("QVector2D") == QMetaType::QVector2D);
+ QVERIFY(QMetaType::type("QVector3D") == QMetaType::QVector3D);
+ QVERIFY(QMetaType::type("QVector4D") == QMetaType::QVector4D);
+
+ QCOMPARE(QByteArray(QMetaType::typeName(QMetaType::QVector2D)),
+ QByteArray("QVector2D"));
+ QCOMPARE(QByteArray(QMetaType::typeName(QMetaType::QVector3D)),
+ QByteArray("QVector3D"));
+ QCOMPARE(QByteArray(QMetaType::typeName(QMetaType::QVector4D)),
+ QByteArray("QVector4D"));
+
+ QVERIFY(QMetaType::isRegistered(QMetaType::QVector2D));
+ QVERIFY(QMetaType::isRegistered(QMetaType::QVector3D));
+ QVERIFY(QMetaType::isRegistered(QMetaType::QVector4D));
+
+ QVERIFY(qMetaTypeId<QVector2D>() == QMetaType::QVector2D);
+ QVERIFY(qMetaTypeId<QVector3D>() == QMetaType::QVector3D);
+ QVERIFY(qMetaTypeId<QVector4D>() == QMetaType::QVector4D);
+}
+
QTEST_APPLESS_MAIN(tst_QVector)
#include "tst_qvectornd.moc"
diff --git a/tests/auto/moc/os9-newlines.h b/tests/auto/moc/os9-newlines.h
index fb9bbe4..85fa671 100644
--- a/tests/auto/moc/os9-newlines.h
+++ b/tests/auto/moc/os9-newlines.h
@@ -1 +1 @@
-/**************************************************************************** ** ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). ** 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 either Technology Preview License Agreement or the ** Beta Release License Agreement. ** ** 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.0, 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. ** ** If you are unsure which license is appropriate for your use, please ** contact the sales department at http://www.qtsoftware.com/contact. ** $QT_END_LICENSE$ ** ****************************************************************************/ #include <QObject> class Os9Newlines : public QObject { Q_OBJECT public Q_SLOTS: inline void testSlot() {} };
+/**************************************************************************** ** ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). ** 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 either Technology Preview License Agreement or the ** Beta Release License Agreement. ** ** 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.0, 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. ** ** If you are unsure which license is appropriate for your use, please ** contact the sales department at http://www.qtsoftware.com/contact. ** $QT_END_LICENSE$ ** ****************************************************************************/ #include <QObject> class Os9Newlines : public QObject { Q_OBJECT public Q_SLOTS: inline void testSlot() {} }; \ No newline at end of file
diff --git a/tests/auto/moc/tst_moc.cpp b/tests/auto/moc/tst_moc.cpp
index d66791f..488f068 100644
--- a/tests/auto/moc/tst_moc.cpp
+++ b/tests/auto/moc/tst_moc.cpp
@@ -1157,6 +1157,13 @@ void tst_Moc::constructors()
QObject *o3 = mo->newInstance(Q_ARG(QString, str));
QVERIFY(o3 != 0);
QCOMPARE(qobject_cast<CtorTestClass*>(o3)->m_str, str);
+
+ {
+ //explicit constructor
+ QObject *o = QObject::staticMetaObject.newInstance();
+ QVERIFY(o);
+ delete o;
+ }
}
#include "task234909.h"
diff --git a/tests/auto/q3socket/tst_qsocket.cpp b/tests/auto/q3socket/tst_qsocket.cpp
index b07fa2f..854cc75 100644
--- a/tests/auto/q3socket/tst_qsocket.cpp
+++ b/tests/auto/q3socket/tst_qsocket.cpp
@@ -124,8 +124,10 @@ void tst_Q3Socket::peerAddress_data()
QTest::addColumn<bool>("peerClosesConnection");
QTest::addColumn<QString>("peerAddr");
- QTest::newRow( "echo" ) << QString("qt-test-server.troll.no") << (uint)7 << false << QString("10.3.3.69");
- QTest::newRow( "daytime" ) << QString("qt-test-server.troll.no") << (uint)13 << true << QString("10.3.3.69");
+ QTest::newRow( "echo" ) << QtNetworkSettings::serverLocalName() << (uint)7 << false
+ << QtNetworkSettings::serverIP().toString();
+ QTest::newRow( "daytime" ) << QtNetworkSettings::serverLocalName() << (uint)13 << true
+ << QtNetworkSettings::serverIP().toString();
}
void tst_Q3Socket::peerAddress()
@@ -191,7 +193,7 @@ void tst_Q3Socket::emitConnectionRefused()
{
Q3Socket sock;
connect( &sock, SIGNAL(error(int)), SLOT(emitConnectionRefused_error(int)) );
- sock.connectToHost( "ares.troll.no", 12331 );
+ sock.connectToHost( QtNetworkSettings::serverLocalName(), 12331 );
emitConnectionRefused_errorReceived = false;
QTestEventLoop::instance().enterLoop( 30 );
@@ -225,8 +227,8 @@ void tst_Q3Socket::connectionAttempts_data()
QTest::addColumn<int>("port");
QTest::addColumn<bool>("expectedResult");
- QTest::newRow("fluke port 80") << QString("qt-test-server.troll.no") << 80 << true;
- QTest::newRow("fluke port 79") << QString("qt-test-server.troll.no") << 79 << false;
+ QTest::newRow("fluke port 80") << QtNetworkSettings::serverLocalName() << 80 << true;
+ QTest::newRow("fluke port 79") << QtNetworkSettings::serverLocalName() << 79 << false;
}
void tst_Q3Socket::connectionAttempts()
@@ -266,7 +268,7 @@ void tst_Q3Socket::canReadLine()
connect(&socket, SIGNAL(connected()), &loop, SLOT(quit()));
// timeout error will fail in #238
connect(&socket, SIGNAL(error(int)), &loop, SLOT(quit()));
- socket.connectToHost("qt-test-server.troll.no", 143);
+ socket.connectToHost(QtNetworkSettings::serverLocalName(), 143);
loop.exec();
diff --git a/tests/auto/q3sqlcursor/tst_q3sqlcursor.cpp b/tests/auto/q3sqlcursor/tst_q3sqlcursor.cpp
index e4b1a55..e5a9b01 100644
--- a/tests/auto/q3sqlcursor/tst_q3sqlcursor.cpp
+++ b/tests/auto/q3sqlcursor/tst_q3sqlcursor.cpp
@@ -548,7 +548,7 @@ void tst_Q3SqlCursor::unicode()
else
QFAIL( QString( "Strings differ at position %1: orig: %2, db: %3" ).arg( i ).arg( utf8str[ i ].unicode(), 0, 16 ).arg( res[ i ].unicode(), 0, 16 ) );
}
- if(db.driverName().startsWith("QMYSQL") || db.driverName().startsWith("QDB2"))
+ if((db.driverName().startsWith("QMYSQL") || db.driverName().startsWith("QDB2")) && res != utf8str)
QEXPECT_FAIL("", "See above message", Continue);
QVERIFY( res == utf8str );
}
@@ -721,7 +721,9 @@ void tst_Q3SqlCursor::updateNoPK()
// Sqlite returns 2, don't ask why.
QVERIFY(cur.update() != 0);
QString expect = "update " + qTableName("qtestPK") +
- " set id = 1 , name = NULL , num = NULL where " + qTableName("qtestPK") + ".id"
+ " set "+db.driver()->escapeIdentifier("id", QSqlDriver::FieldName)+" = 1 , "
+ +db.driver()->escapeIdentifier("name", QSqlDriver::FieldName)+" = NULL , "
+ +db.driver()->escapeIdentifier("num", QSqlDriver::FieldName)+" = NULL where " + qTableName("qtestPK") + ".id"
" IS NULL and " + qTableName("qtestPK") + ".name IS NULL and " +
qTableName("qtestPK") + ".num IS NULL";
if (!db.driver()->hasFeature(QSqlDriver::PreparedQueries)) {
diff --git a/tests/auto/q3urloperator/tst_q3urloperator.cpp b/tests/auto/q3urloperator/tst_q3urloperator.cpp
index f1e1059..a9e5096 100644
--- a/tests/auto/q3urloperator/tst_q3urloperator.cpp
+++ b/tests/auto/q3urloperator/tst_q3urloperator.cpp
@@ -55,6 +55,8 @@
#include <q3valuelist.h>
#include <qlist.h>
+#include "../network-settings.h"
+
//TESTED_CLASS=
//TESTED_FILES=
@@ -150,7 +152,7 @@ void tst_Q3UrlOperator::initTestCase()
// prepare: make sure that there is a unique directory for FTP upload
// testing (to avoid parallel executed tests interfere with each other)
- ftpQtestUpload = "ftp://qt-test-server.troll.no/";
+ ftpQtestUpload = QString("ftp://%1/").arg(QtNetworkSettings::serverLocalName());
QString dir = QString( "qtest/upload/%1" ).arg( (ulong)this );
Q3UrlOperator opMkdir( ftpQtestUpload );
@@ -218,8 +220,8 @@ void tst_Q3UrlOperator::cleanup()
void tst_Q3UrlOperator::copy_data()
{
- const QString ftpQtest( "ftp://qt-test-server.troll.no/qtest" );
- const QString httpQtest( "http://qt-test-server.troll.no/qtest" );
+ const QString ftpQtest( QString("ftp://%1/qtest").arg(QtNetworkSettings::serverLocalName()) );
+ const QString httpQtest( QString("http://%1/qtest").arg(QtNetworkSettings::serverLocalName()) );
// argument for the constructor
QTest::addColumn<QString>("url");
@@ -339,8 +341,8 @@ void tst_Q3UrlOperator::slotFinished_copy( Q3NetworkOperation *op )
void tst_Q3UrlOperator::put_data()
{
- const QString httpQtest( "http://qt-test-server.troll.no/qtest/cgi-bin" );
- const QString httpQtestGet( "http://qt-test-server.troll.no/qtest/cgi-bin/retrieve_testfile.cgi" );
+ const QString httpQtest( QString("http://%1/qtest/cgi-bin").arg(QtNetworkSettings::serverLocalName()) );
+ const QString httpQtestGet( QString("http://%1/qtest/cgi-bin/retrieve_testfile.cgi").arg(QtNetworkSettings::serverLocalName()) );
QByteArray putData_1( 5 );
putData_1[0] = 'a';
diff --git a/tests/auto/qaudiodeviceid/qaudiodeviceid.pro b/tests/auto/qaudiodeviceid/qaudiodeviceid.pro
new file mode 100644
index 0000000..e0c7d4d
--- /dev/null
+++ b/tests/auto/qaudiodeviceid/qaudiodeviceid.pro
@@ -0,0 +1,7 @@
+load(qttest_p4)
+
+DEFINES += SRCDIR=\\\"$$PWD/\\\"
+
+SOURCES += tst_qaudiodeviceid.cpp
+
+QT = core multimedia
diff --git a/tests/auto/qaudiodeviceid/tst_qaudiodeviceid.cpp b/tests/auto/qaudiodeviceid/tst_qaudiodeviceid.cpp
new file mode 100644
index 0000000..d40118b
--- /dev/null
+++ b/tests/auto/qaudiodeviceid/tst_qaudiodeviceid.cpp
@@ -0,0 +1,98 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** 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 either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** 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.0, 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.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtTest/QtTest>
+#include <QtCore/qlocale.h>
+#include <qaudiodeviceid.h>
+#include <qaudiodeviceinfo.h>
+
+#include <QStringList>
+#include <QList>
+
+
+class tst_QAudioDeviceId : public QObject
+{
+ Q_OBJECT
+
+public:
+ tst_QAudioDeviceId(QObject* parent=0) : QObject(parent) {}
+
+private slots:
+ void checkNull();
+ void checkEquality();
+};
+
+void tst_QAudioDeviceId::checkNull()
+{
+ // Default constructed is null.
+ QAudioDeviceId deviceId0;
+ QVERIFY(deviceId0.isNull());
+
+ // Null is transferred
+ QAudioDeviceId deviceId1(deviceId0);
+ QVERIFY(deviceId1.isNull());
+}
+
+void tst_QAudioDeviceId::checkEquality()
+{
+ QAudioDeviceId deviceId0;
+ QAudioDeviceId deviceId1;
+
+ // Null ids are equivalent
+ QVERIFY(deviceId0 == deviceId1);
+ QVERIFY(!(deviceId0 != deviceId1));
+
+ deviceId1 = QAudioDeviceInfo::defaultOutputDevice();
+
+ // Different
+ QVERIFY(deviceId0 != deviceId1);
+ QVERIFY(!(deviceId0 == deviceId1));
+
+ // Same
+ deviceId0 = deviceId1;
+
+ QVERIFY(deviceId0 == deviceId1);
+ QVERIFY(!(deviceId0 != deviceId1));
+}
+
+QTEST_MAIN(tst_QAudioDeviceId)
+
+#include "tst_qaudiodeviceid.moc"
diff --git a/tests/auto/qaudiodeviceinfo/qaudiodeviceinfo.pro b/tests/auto/qaudiodeviceinfo/qaudiodeviceinfo.pro
new file mode 100644
index 0000000..695987c
--- /dev/null
+++ b/tests/auto/qaudiodeviceinfo/qaudiodeviceinfo.pro
@@ -0,0 +1,7 @@
+load(qttest_p4)
+
+DEFINES += SRCDIR=\\\"$$PWD/\\\"
+
+SOURCES += tst_qaudiodeviceinfo.cpp
+
+QT = core multimedia
diff --git a/tests/auto/qaudiodeviceinfo/tst_qaudiodeviceinfo.cpp b/tests/auto/qaudiodeviceinfo/tst_qaudiodeviceinfo.cpp
new file mode 100644
index 0000000..c2cd97e
--- /dev/null
+++ b/tests/auto/qaudiodeviceinfo/tst_qaudiodeviceinfo.cpp
@@ -0,0 +1,159 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** 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 either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** 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.0, 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.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+
+#include <QtTest/QtTest>
+#include <QtCore/qlocale.h>
+#include <qaudiodeviceinfo.h>
+
+#include <QStringList>
+#include <QList>
+
+
+class tst_QAudioDeviceInfo : public QObject
+{
+ Q_OBJECT
+public:
+ tst_QAudioDeviceInfo(QObject* parent=0) : QObject(parent) {}
+
+private slots:
+ void checkAvailableDefaultInput();
+ void checkAvailableDefaultOutput();
+ void outputList();
+ void codecs();
+ void channels();
+ void sampleSizes();
+ void byteOrders();
+ void sampleTypes();
+ void frequencies();
+ void isformat();
+ void preferred();
+ void nearest();
+
+private:
+ QAudioDeviceInfo* device;
+};
+
+void tst_QAudioDeviceInfo::checkAvailableDefaultInput()
+{
+ QVERIFY(!QAudioDeviceInfo::defaultInputDevice().isNull());
+}
+
+void tst_QAudioDeviceInfo::checkAvailableDefaultOutput()
+{
+ QVERIFY(!QAudioDeviceInfo::defaultOutputDevice().isNull());
+}
+
+void tst_QAudioDeviceInfo::outputList()
+{
+ QList<QAudioDeviceId> devices = QAudioDeviceInfo::deviceList(QAudio::AudioOutput);
+ QVERIFY(devices.size() > 0);
+ device = new QAudioDeviceInfo(devices.at(0), this);
+}
+
+void tst_QAudioDeviceInfo::codecs()
+{
+ QStringList avail = device->supportedCodecs();
+ QVERIFY(avail.size() > 0);
+}
+
+void tst_QAudioDeviceInfo::channels()
+{
+ QList<int> avail = device->supportedChannels();
+ QVERIFY(avail.size() > 0);
+}
+
+void tst_QAudioDeviceInfo::sampleSizes()
+{
+ QList<int> avail = device->supportedSampleSizes();
+ QVERIFY(avail.size() > 0);
+}
+
+void tst_QAudioDeviceInfo::byteOrders()
+{
+ QList<QAudioFormat::Endian> avail = device->supportedByteOrders();
+ QVERIFY(avail.size() > 0);
+}
+
+void tst_QAudioDeviceInfo::sampleTypes()
+{
+ QList<QAudioFormat::SampleType> avail = device->supportedSampleTypes();
+ QVERIFY(avail.size() > 0);
+}
+
+void tst_QAudioDeviceInfo::frequencies()
+{
+ QList<int> avail = device->supportedFrequencies();
+ QVERIFY(avail.size() > 0);
+}
+
+void tst_QAudioDeviceInfo::isformat()
+{
+ QAudioFormat format;
+ format.setFrequency(44100);
+ format.setChannels(2);
+ format.setSampleType(QAudioFormat::SignedInt);
+ format.setByteOrder(QAudioFormat::LittleEndian);
+ format.setSampleSize(16);
+ format.setCodec("audio/pcm");
+
+ // Should always be true for these format
+ QVERIFY(device->isFormatSupported(format));
+}
+
+void tst_QAudioDeviceInfo::preferred()
+{
+ QAudioFormat format = device->preferredFormat();
+ QVERIFY(format.frequency() == 44100);
+ QVERIFY(format.channels() == 2);
+}
+
+void tst_QAudioDeviceInfo::nearest()
+{
+ QAudioFormat format1, format2;
+ format1.setFrequency(8000);
+ format2 = device->nearestFormat(format1);
+ QVERIFY(format2.frequency() == 44100);
+}
+
+QTEST_MAIN(tst_QAudioDeviceInfo)
+
+#include "tst_qaudiodeviceinfo.moc"
diff --git a/tests/auto/qaudioformat/qaudioformat.pro b/tests/auto/qaudioformat/qaudioformat.pro
new file mode 100644
index 0000000..78962d7
--- /dev/null
+++ b/tests/auto/qaudioformat/qaudioformat.pro
@@ -0,0 +1,7 @@
+load(qttest_p4)
+
+DEFINES += SRCDIR=\\\"$$PWD/\\\"
+
+SOURCES += tst_qaudioformat.cpp
+
+QT = core multimedia
diff --git a/tests/auto/qaudioformat/tst_qaudioformat.cpp b/tests/auto/qaudioformat/tst_qaudioformat.cpp
new file mode 100644
index 0000000..bcfc78f
--- /dev/null
+++ b/tests/auto/qaudioformat/tst_qaudioformat.cpp
@@ -0,0 +1,180 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** 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 either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** 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.0, 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.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+
+#include <QtTest/QtTest>
+#include <QtCore/qlocale.h>
+#include <qaudioformat.h>
+
+#include <QStringList>
+#include <QList>
+
+
+class tst_QAudioFormat : public QObject
+{
+ Q_OBJECT
+
+public:
+ tst_QAudioFormat(QObject* parent=0) : QObject(parent) {}
+
+private slots:
+ void checkNull();
+ void checkFrequency();
+ void checkChannels();
+ void checkSampleSize();
+ void checkCodec();
+ void checkByteOrder();
+ void checkSampleType();
+ void checkEquality();
+ void checkAssignment();
+};
+
+void tst_QAudioFormat::checkNull()
+{
+ // Default constructed QAudioFormat is null.
+ QAudioFormat audioFormat0;
+ QVERIFY(audioFormat0.isNull());
+
+ // Null is transferred
+ QAudioFormat audioFormat1(audioFormat0);
+ QVERIFY(audioFormat1.isNull());
+
+ // Null is voided on activity
+ audioFormat0.setFrequency(44100);
+ QVERIFY(!audioFormat0.isNull());
+}
+
+void tst_QAudioFormat::checkFrequency()
+{
+ QAudioFormat audioFormat;
+ audioFormat.setFrequency(44100);
+ QVERIFY(audioFormat.frequency() == 44100);
+}
+
+void tst_QAudioFormat::checkChannels()
+{
+ QAudioFormat audioFormat;
+ audioFormat.setChannels(2);
+ QVERIFY(audioFormat.channels() == 2);
+}
+
+void tst_QAudioFormat::checkSampleSize()
+{
+ QAudioFormat audioFormat;
+ audioFormat.setSampleSize(16);
+ QVERIFY(audioFormat.sampleSize() == 16);
+}
+
+void tst_QAudioFormat::checkCodec()
+{
+ QAudioFormat audioFormat;
+ audioFormat.setCodec(QString::fromLatin1("audio/pcm"));
+ QVERIFY(audioFormat.codec() == QString::fromLatin1("audio/pcm"));
+}
+
+void tst_QAudioFormat::checkByteOrder()
+{
+ QAudioFormat audioFormat;
+ audioFormat.setByteOrder(QAudioFormat::LittleEndian);
+ QVERIFY(audioFormat.byteOrder() == QAudioFormat::LittleEndian);
+}
+
+void tst_QAudioFormat::checkSampleType()
+{
+ QAudioFormat audioFormat;
+ audioFormat.setSampleType(QAudioFormat::SignedInt);
+ QVERIFY(audioFormat.sampleType() == QAudioFormat::SignedInt);
+}
+
+void tst_QAudioFormat::checkEquality()
+{
+ QAudioFormat audioFormat0;
+ QAudioFormat audioFormat1;
+
+ // Null formats are equivalent
+ QVERIFY(audioFormat0 == audioFormat1);
+ QVERIFY(!(audioFormat0 != audioFormat1));
+
+ // on filled formats
+ audioFormat0.setFrequency(8000);
+ audioFormat0.setChannels(1);
+ audioFormat0.setSampleSize(8);
+ audioFormat0.setCodec("audio/pcm");
+ audioFormat0.setByteOrder(QAudioFormat::LittleEndian);
+ audioFormat0.setSampleType(QAudioFormat::UnSignedInt);
+
+ audioFormat1.setFrequency(8000);
+ audioFormat1.setChannels(1);
+ audioFormat1.setSampleSize(8);
+ audioFormat1.setCodec("audio/pcm");
+ audioFormat1.setByteOrder(QAudioFormat::LittleEndian);
+ audioFormat1.setSampleType(QAudioFormat::UnSignedInt);
+
+ QVERIFY(audioFormat0 == audioFormat1);
+ QVERIFY(!(audioFormat0 != audioFormat1));
+
+ audioFormat0.setFrequency(44100);
+ QVERIFY(audioFormat0 != audioFormat1);
+ QVERIFY(!(audioFormat0 == audioFormat1));
+}
+
+void tst_QAudioFormat::checkAssignment()
+{
+ QAudioFormat audioFormat0;
+ QAudioFormat audioFormat1;
+
+ audioFormat0.setFrequency(8000);
+ audioFormat0.setChannels(1);
+ audioFormat0.setSampleSize(8);
+ audioFormat0.setCodec("audio/pcm");
+ audioFormat0.setByteOrder(QAudioFormat::LittleEndian);
+ audioFormat0.setSampleType(QAudioFormat::UnSignedInt);
+
+ audioFormat1 = audioFormat0;
+ QVERIFY(audioFormat1 == audioFormat0);
+
+ QAudioFormat audioFormat2(audioFormat0);
+ QVERIFY(audioFormat2 == audioFormat0);
+}
+
+QTEST_MAIN(tst_QAudioFormat)
+
+#include "tst_qaudioformat.moc"
diff --git a/tests/auto/qaudioinput/qaudioinput.pro b/tests/auto/qaudioinput/qaudioinput.pro
new file mode 100644
index 0000000..8a03749
--- /dev/null
+++ b/tests/auto/qaudioinput/qaudioinput.pro
@@ -0,0 +1,7 @@
+load(qttest_p4)
+
+DEFINES += SRCDIR=\\\"$$PWD/\\\"
+
+SOURCES += tst_qaudioinput.cpp
+
+QT = core multimedia
diff --git a/tests/auto/qaudioinput/tst_qaudioinput.cpp b/tests/auto/qaudioinput/tst_qaudioinput.cpp
new file mode 100644
index 0000000..6e16320
--- /dev/null
+++ b/tests/auto/qaudioinput/tst_qaudioinput.cpp
@@ -0,0 +1,120 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** 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 either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** 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.0, 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.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtTest/QtTest>
+#include <QtCore/qlocale.h>
+#include <qaudioinput.h>
+#include <qaudiodeviceinfo.h>
+#include <qaudio.h>
+#include <qaudioformat.h>
+
+
+class tst_QAudioInput : public QObject
+{
+ Q_OBJECT
+public:
+ tst_QAudioInput(QObject* parent=0) : QObject(parent) {}
+
+private slots:
+ void initTestCase();
+ void settings();
+ void notifyInterval();
+ void pullFile();
+
+private:
+ QAudioFormat format;
+ QAudioInput* audio;
+};
+
+void tst_QAudioInput::initTestCase()
+{
+ format.setFrequency(8000);
+ format.setChannels(1);
+ format.setSampleSize(8);
+ format.setCodec("audio/pcm");
+ format.setByteOrder(QAudioFormat::LittleEndian);
+ format.setSampleType(QAudioFormat::UnSignedInt);
+
+ audio = new QAudioInput(format, this);
+}
+
+void tst_QAudioInput::settings()
+{
+ QAudioFormat f = audio->format();
+
+ QVERIFY(format.channels() == f.channels());
+ QVERIFY(format.frequency() == f.frequency());
+ QVERIFY(format.sampleSize() == f.sampleSize());
+ QVERIFY(format.codec() == f.codec());
+ QVERIFY(format.byteOrder() == f.byteOrder());
+ QVERIFY(format.sampleType() == f.sampleType());
+}
+
+void tst_QAudioInput::notifyInterval()
+{
+ QVERIFY(audio->notifyInterval() == 1000); // Default
+
+ audio->setNotifyInterval(500);
+ QVERIFY(audio->notifyInterval() == 500); // Custom
+
+ audio->setNotifyInterval(1000); // reset
+}
+
+void tst_QAudioInput::pullFile()
+{
+ QFile filename(SRCDIR "test.raw");
+ filename.open( QIODevice::WriteOnly | QIODevice::Truncate );
+
+ QSignalSpy readSignal(audio, SIGNAL(notify()));
+ audio->start(&filename);
+
+ QTest::qWait(5000);
+
+ QVERIFY(readSignal.count() > 0);
+ QVERIFY(audio->totalTime() > 0);
+
+ audio->stop();
+ filename.close();
+}
+
+QTEST_MAIN(tst_QAudioInput)
+
+#include "tst_qaudioinput.moc"
diff --git a/tests/auto/qaudiooutput/4.wav b/tests/auto/qaudiooutput/4.wav
new file mode 100644
index 0000000..e31b0609
--- /dev/null
+++ b/tests/auto/qaudiooutput/4.wav
Binary files differ
diff --git a/tests/auto/qaudiooutput/qaudiooutput.pro b/tests/auto/qaudiooutput/qaudiooutput.pro
new file mode 100644
index 0000000..6c07c64
--- /dev/null
+++ b/tests/auto/qaudiooutput/qaudiooutput.pro
@@ -0,0 +1,12 @@
+load(qttest_p4)
+
+DEFINES += SRCDIR=\\\"$$PWD/\\\"
+
+SOURCES += tst_qaudiooutput.cpp
+
+QT = core multimedia
+
+wince*: {
+ deploy.sources += 4.wav
+ DEPLOYMENT = deploy
+}
diff --git a/tests/auto/qaudiooutput/tst_qaudiooutput.cpp b/tests/auto/qaudiooutput/tst_qaudiooutput.cpp
new file mode 100644
index 0000000..0f94faa
--- /dev/null
+++ b/tests/auto/qaudiooutput/tst_qaudiooutput.cpp
@@ -0,0 +1,156 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** 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 either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** 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.0, 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.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+
+
+#include <QtTest/QtTest>
+#include <QtCore/qlocale.h>
+#include <qaudiooutput.h>
+#include <qaudiodeviceinfo.h>
+#include <qaudio.h>
+#include <qaudioformat.h>
+
+
+class tst_QAudioOutput : public QObject
+{
+ Q_OBJECT
+public:
+ tst_QAudioOutput(QObject* parent=0) : QObject(parent) {}
+
+private slots:
+ void initTestCase();
+ void settings();
+ void notifyInterval();
+ void pullFile();
+ void pushFile();
+
+private:
+ QAudioFormat format;
+ QAudioOutput* audio;
+};
+
+void tst_QAudioOutput::initTestCase()
+{
+ format.setFrequency(8000);
+ format.setChannels(1);
+ format.setSampleSize(8);
+ format.setCodec("audio/pcm");
+ format.setByteOrder(QAudioFormat::LittleEndian);
+ format.setSampleType(QAudioFormat::UnSignedInt);
+
+ audio = new QAudioOutput(format, this);
+}
+
+void tst_QAudioOutput::settings()
+{
+ QAudioFormat f = audio->format();
+
+ QVERIFY(format.channels() == f.channels());
+ QVERIFY(format.frequency() == f.frequency());
+ QVERIFY(format.sampleSize() == f.sampleSize());
+ QVERIFY(format.codec() == f.codec());
+ QVERIFY(format.byteOrder() == f.byteOrder());
+ QVERIFY(format.sampleType() == f.sampleType());
+}
+
+void tst_QAudioOutput::notifyInterval()
+{
+ QVERIFY(audio->notifyInterval() == 1000); // Default
+
+ audio->setNotifyInterval(500);
+ QVERIFY(audio->notifyInterval() == 500); // Custom
+
+ audio->setNotifyInterval(1000); // reset
+}
+
+void tst_QAudioOutput::pullFile()
+{
+ QFile filename(SRCDIR "4.wav");
+ QVERIFY(filename.exists());
+ filename.open(QIODevice::ReadOnly);
+
+ QSignalSpy readSignal(audio, SIGNAL(notify()));
+ audio->setNotifyInterval(100);
+ audio->start(&filename);
+
+ QTestEventLoop::instance().enterLoop(1);
+ // 4.wav is a little less than 700ms, so notify should fire 6 times!
+ QVERIFY(readSignal.count() >= 6);
+ QVERIFY(audio->totalTime() == 692250);
+
+ audio->stop();
+ filename.close();
+}
+
+void tst_QAudioOutput::pushFile()
+{
+ QFile filename(SRCDIR "4.wav");
+ QVERIFY(filename.exists());
+ filename.open(QIODevice::ReadOnly);
+
+ const qint64 fileSize = filename.size();
+
+ QIODevice* feed = audio->start(0);
+
+ char* buffer = new char[fileSize];
+ filename.read(buffer, fileSize);
+
+ qint64 counter=0;
+ qint64 written=0;
+ while(written < fileSize) {
+ written+=feed->write(buffer+written,fileSize-written);
+ QTest::qWait(20);
+ counter++;
+ }
+ QTestEventLoop::instance().enterLoop(1);
+
+ QVERIFY(written == fileSize);
+ QVERIFY(audio->totalTime() == 692250);
+
+ audio->stop();
+ filename.close();
+ delete [] buffer;
+ delete audio;
+}
+
+QTEST_MAIN(tst_QAudioOutput)
+
+#include "tst_qaudiooutput.moc"
diff --git a/tests/auto/qcompleter/tst_qcompleter.cpp b/tests/auto/qcompleter/tst_qcompleter.cpp
index 0a9c16a..a65490d 100644
--- a/tests/auto/qcompleter/tst_qcompleter.cpp
+++ b/tests/auto/qcompleter/tst_qcompleter.cpp
@@ -138,6 +138,7 @@ private slots:
void setters();
void dynamicSortOrder();
+ void disabledItems();
// task-specific tests below me
void task178797_activatedOnReturn();
@@ -147,7 +148,6 @@ private slots:
void task253125_lineEditCompletion_data();
void task253125_lineEditCompletion();
-
void task247560_keyboardNavigation();
private:
@@ -1106,6 +1106,31 @@ void tst_QCompleter::dynamicSortOrder()
QCOMPARE(completer.completionCount(), 12);
}
+void tst_QCompleter::disabledItems()
+{
+ QLineEdit lineEdit;
+ QStandardItemModel *model = new QStandardItemModel(&lineEdit);
+ QStandardItem *suggestions = new QStandardItem("suggestions");
+ suggestions->setEnabled(false);
+ model->appendRow(suggestions);
+ model->appendRow(new QStandardItem("suggestions Enabled"));
+ QCompleter *completer = new QCompleter(model, &lineEdit);
+ QSignalSpy spy(completer, SIGNAL(activated(const QString &)));
+ lineEdit.setCompleter(completer);
+ lineEdit.show();
+
+ QTest::keyPress(&lineEdit, Qt::Key_S);
+ QTest::keyPress(&lineEdit, Qt::Key_U);
+ QAbstractItemView *view = lineEdit.completer()->popup();
+ QVERIFY(view->isVisible());
+ QTest::mouseClick(view->viewport(), Qt::LeftButton, 0, view->visualRect(view->model()->index(0, 0)).center());
+ QCOMPARE(spy.count(), 0);
+ QVERIFY(view->isVisible());
+ QTest::mouseClick(view->viewport(), Qt::LeftButton, 0, view->visualRect(view->model()->index(1, 0)).center());
+ QCOMPARE(spy.count(), 1);
+ QVERIFY(!view->isVisible());
+}
+
void tst_QCompleter::task178797_activatedOnReturn()
{
QStringList words;
diff --git a/tests/auto/qdom/tst_qdom.cpp b/tests/auto/qdom/tst_qdom.cpp
index ea3b64e..5b4787f 100644
--- a/tests/auto/qdom/tst_qdom.cpp
+++ b/tests/auto/qdom/tst_qdom.cpp
@@ -1386,7 +1386,7 @@ void tst_QDom::roundTripAttributes() const
doc.save(stream, 0);
stream.flush();
- const QByteArray expected("<localName xmlns=\"\" attr=\" &#xd;&#xa;&#x9; \" />\n");
+ const QByteArray expected("<localName xmlns=\"\" attr=\" &#xd;&#xa;&#x9; \"/>\n");
QCOMPARE(QString::fromLatin1(serialized.constData()), QString::fromLatin1(expected.constData()));
}
@@ -1671,7 +1671,7 @@ void tst_QDom::appendDocumentNode() const
doc.appendChild(elem);
Q_ASSERT(!xml.isNull());
- const QString expected(QLatin1String("<document>\n<test_elem name=\"value\" />\n</document>\n"));
+ const QString expected(QLatin1String("<document>\n<test_elem name=\"value\"/>\n</document>\n"));
elem.appendChild(xml);
QCOMPARE(doc.childNodes().count(), 1);
@@ -1788,8 +1788,8 @@ void tst_QDom::doubleNamespaceDeclarations() const
QXmlInputSource source(&file);
QVERIFY(doc.setContent(&source, &reader));
- QVERIFY(doc.toString(0) == QString::fromLatin1("<a>\n<b p:c=\"\" xmlns:p=\"NS\" p:d=\"\" />\n</a>\n") ||
- doc.toString(0) == QString::fromLatin1("<a>\n<b p:c=\"\" p:d=\"\" xmlns:p=\"NS\" />\n</a>\n"));
+ QVERIFY(doc.toString(0) == QString::fromLatin1("<a>\n<b p:c=\"\" xmlns:p=\"NS\" p:d=\"\"/>\n</a>\n") ||
+ doc.toString(0) == QString::fromLatin1("<a>\n<b p:c=\"\" p:d=\"\" xmlns:p=\"NS\"/>\n</a>\n"));
}
void tst_QDom::setContentQXmlReaderOverload() const
diff --git a/tests/auto/qfiledialog/tst_qfiledialog.cpp b/tests/auto/qfiledialog/tst_qfiledialog.cpp
index c31ecf2..0f307dc 100644
--- a/tests/auto/qfiledialog/tst_qfiledialog.cpp
+++ b/tests/auto/qfiledialog/tst_qfiledialog.cpp
@@ -161,6 +161,7 @@ private slots:
void task251341_sideBarRemoveEntries();
void task254490_selectFileMultipleTimes();
void task257579_sideBarWithNonCleanUrls();
+ void task259105_filtersCornerCases();
private:
QByteArray userSettings;
@@ -2057,6 +2058,48 @@ void tst_QFiledialog::task257579_sideBarWithNonCleanUrls()
#endif
}
+void tst_QFiledialog::task259105_filtersCornerCases()
+{
+ QNonNativeFileDialog fd(0, "TestFileDialog");
+ fd.setNameFilter(QLatin1String("All Files! (*);;Text Files (*.txt)"));
+ fd.setOption(QFileDialog::HideNameFilterDetails, true);
+ fd.show();
+ QTest::qWait(250);
+
+ //Extensions are hidden
+ QComboBox *filters = qFindChild<QComboBox*>(&fd, "fileTypeCombo");
+ QVERIFY(filters);
+ QCOMPARE(filters->currentText(), QLatin1String("All Files!"));
+ filters->setCurrentIndex(1);
+ QCOMPARE(filters->currentText(), QLatin1String("Text Files"));
+
+ //We should have the full names
+ fd.setOption(QFileDialog::HideNameFilterDetails, false);
+ QTest::qWait(250);
+ filters->setCurrentIndex(0);
+ QCOMPARE(filters->currentText(), QLatin1String("All Files! (*)"));
+ filters->setCurrentIndex(1);
+ QCOMPARE(filters->currentText(), QLatin1String("Text Files (*.txt)"));
+
+ //Corner case undocumented of the task
+ fd.setNameFilter(QLatin1String("\352 (I like cheese) All Files! (*);;Text Files (*.txt)"));
+ QCOMPARE(filters->currentText(), QLatin1String("\352 (I like cheese) All Files! (*)"));
+ filters->setCurrentIndex(1);
+ QCOMPARE(filters->currentText(), QLatin1String("Text Files (*.txt)"));
+
+ fd.setOption(QFileDialog::HideNameFilterDetails, true);
+ filters->setCurrentIndex(0);
+ QTest::qWait(500);
+ QCOMPARE(filters->currentText(), QLatin1String("\352 (I like cheese) All Files!"));
+ filters->setCurrentIndex(1);
+ QCOMPARE(filters->currentText(), QLatin1String("Text Files"));
+ fd.setOption(QFileDialog::HideNameFilterDetails, true);
+ filters->setCurrentIndex(0);
+ QTest::qWait(500);
+ QCOMPARE(filters->currentText(), QLatin1String("\352 (I like cheese) All Files!"));
+ filters->setCurrentIndex(1);
+ QCOMPARE(filters->currentText(), QLatin1String("Text Files"));
+}
QTEST_MAIN(tst_QFiledialog)
#include "tst_qfiledialog.moc"
diff --git a/tests/auto/qformlayout/tst_qformlayout.cpp b/tests/auto/qformlayout/tst_qformlayout.cpp
index 74384a9..9806557 100644
--- a/tests/auto/qformlayout/tst_qformlayout.cpp
+++ b/tests/auto/qformlayout/tst_qformlayout.cpp
@@ -125,7 +125,6 @@ private slots:
Qt::Orientations expandingDirections() const;
*/
- void fieldMinimumSize();
};
tst_QFormLayout::tst_QFormLayout()
@@ -906,35 +905,6 @@ void tst_QFormLayout::layoutAlone()
QTest::qWait(500);
}
-
-void tst_QFormLayout::fieldMinimumSize()
-{
- //check that the field with is bigger than its minimumSizeHint for any size of the widget
- // even if the label with is not fixed
- QWidget w;
- QFormLayout layout;
- layout.setFieldGrowthPolicy(QFormLayout::AllNonFixedFieldsGrow);
- w.setLayout(&layout);
- QLabel label1("Here is a strange test case");
- label1.setWordWrap(true);
- QLabel label2("Here is another label");
- label2.setWordWrap(true);
- QLabel shortLabel("short");
- QLabel longLabel("Quite long label");
- layout.addRow(&label1, &shortLabel);
- layout.addRow(&label2, &longLabel);
- w.show();
- int width = w.size().width() + 9;
-
- do {
- w.resize(width, w.size().height());
- layout.activate();
- QVERIFY(shortLabel.size().width() >= shortLabel.minimumSizeHint().width());
- QVERIFY(longLabel.size().width() >= longLabel.minimumSizeHint().width());
- width -= 3;
- } while(width >= w.minimumSizeHint().width());
-}
-
QTEST_MAIN(tst_QFormLayout)
#include "tst_qformlayout.moc"
diff --git a/tests/auto/qgl/tst_qgl.cpp b/tests/auto/qgl/tst_qgl.cpp
index 96f5ddd..31c4a3c 100644
--- a/tests/auto/qgl/tst_qgl.cpp
+++ b/tests/auto/qgl/tst_qgl.cpp
@@ -45,6 +45,7 @@
#include <qcoreapplication.h>
#include <qdebug.h>
#include <qgl.h>
+#include <qglcolormap.h>
#include <QGraphicsView>
#include <QGraphicsProxyWidget>
@@ -66,6 +67,7 @@ private slots:
void graphicsViewClipping();
void partialGLWidgetUpdates_data();
void partialGLWidgetUpdates();
+ void colormap();
};
tst_QGL::tst_QGL()
@@ -94,6 +96,11 @@ public:
void setAutoBufferSwap(bool on) { QGLWidget::setAutoBufferSwap(on); }
};
+// Using INT_MIN and INT_MAX will cause failures on systems
+// where "int" is 64-bit, so use the explicit values instead.
+#define TEST_INT_MIN (-2147483647 - 1)
+#define TEST_INT_MAX 2147483647
+
// Testing get/set functions
void tst_QGL::getSetCheck()
{
@@ -103,120 +110,286 @@ void tst_QGL::getSetCheck()
QGLFormat obj1;
// int QGLFormat::depthBufferSize()
// void QGLFormat::setDepthBufferSize(int)
+ QCOMPARE(-1, obj1.depthBufferSize());
obj1.setDepthBufferSize(0);
QCOMPARE(0, obj1.depthBufferSize());
- obj1.setDepthBufferSize(INT_MIN);
+ QTest::ignoreMessage(QtWarningMsg, "QGLFormat::setDepthBufferSize: Cannot set negative depth buffer size -2147483648");
+ obj1.setDepthBufferSize(TEST_INT_MIN);
QCOMPARE(0, obj1.depthBufferSize()); // Makes no sense with a negative buffer size
- obj1.setDepthBufferSize(INT_MAX);
- QCOMPARE(INT_MAX, obj1.depthBufferSize());
+ obj1.setDepthBufferSize(3);
+ QTest::ignoreMessage(QtWarningMsg, "QGLFormat::setDepthBufferSize: Cannot set negative depth buffer size -1");
+ obj1.setDepthBufferSize(-1);
+ QCOMPARE(3, obj1.depthBufferSize());
+ obj1.setDepthBufferSize(TEST_INT_MAX);
+ QCOMPARE(TEST_INT_MAX, obj1.depthBufferSize());
// int QGLFormat::accumBufferSize()
// void QGLFormat::setAccumBufferSize(int)
+ QCOMPARE(-1, obj1.accumBufferSize());
obj1.setAccumBufferSize(0);
QCOMPARE(0, obj1.accumBufferSize());
- obj1.setAccumBufferSize(INT_MIN);
+ QTest::ignoreMessage(QtWarningMsg, "QGLFormat::setAccumBufferSize: Cannot set negative accumulate buffer size -2147483648");
+ obj1.setAccumBufferSize(TEST_INT_MIN);
QCOMPARE(0, obj1.accumBufferSize()); // Makes no sense with a negative buffer size
- obj1.setAccumBufferSize(INT_MAX);
- QCOMPARE(INT_MAX, obj1.accumBufferSize());
+ obj1.setAccumBufferSize(3);
+ QTest::ignoreMessage(QtWarningMsg, "QGLFormat::setAccumBufferSize: Cannot set negative accumulate buffer size -1");
+ obj1.setAccumBufferSize(-1);
+ QCOMPARE(3, obj1.accumBufferSize());
+ obj1.setAccumBufferSize(TEST_INT_MAX);
+ QCOMPARE(TEST_INT_MAX, obj1.accumBufferSize());
+
+ // int QGLFormat::redBufferSize()
+ // void QGLFormat::setRedBufferSize(int)
+ QCOMPARE(-1, obj1.redBufferSize());
+ obj1.setRedBufferSize(0);
+ QCOMPARE(0, obj1.redBufferSize());
+ QTest::ignoreMessage(QtWarningMsg, "QGLFormat::setRedBufferSize: Cannot set negative red buffer size -2147483648");
+ obj1.setRedBufferSize(TEST_INT_MIN);
+ QCOMPARE(0, obj1.redBufferSize()); // Makes no sense with a negative buffer size
+ obj1.setRedBufferSize(3);
+ QTest::ignoreMessage(QtWarningMsg, "QGLFormat::setRedBufferSize: Cannot set negative red buffer size -1");
+ obj1.setRedBufferSize(-1);
+ QCOMPARE(3, obj1.redBufferSize());
+ obj1.setRedBufferSize(TEST_INT_MAX);
+ QCOMPARE(TEST_INT_MAX, obj1.redBufferSize());
+
+ // int QGLFormat::greenBufferSize()
+ // void QGLFormat::setGreenBufferSize(int)
+ QCOMPARE(-1, obj1.greenBufferSize());
+ obj1.setGreenBufferSize(0);
+ QCOMPARE(0, obj1.greenBufferSize());
+ QTest::ignoreMessage(QtWarningMsg, "QGLFormat::setGreenBufferSize: Cannot set negative green buffer size -2147483648");
+ obj1.setGreenBufferSize(TEST_INT_MIN);
+ QCOMPARE(0, obj1.greenBufferSize()); // Makes no sense with a negative buffer size
+ obj1.setGreenBufferSize(3);
+ QTest::ignoreMessage(QtWarningMsg, "QGLFormat::setGreenBufferSize: Cannot set negative green buffer size -1");
+ obj1.setGreenBufferSize(-1);
+ QCOMPARE(3, obj1.greenBufferSize());
+ obj1.setGreenBufferSize(TEST_INT_MAX);
+ QCOMPARE(TEST_INT_MAX, obj1.greenBufferSize());
+
+ // int QGLFormat::blueBufferSize()
+ // void QGLFormat::setBlueBufferSize(int)
+ QCOMPARE(-1, obj1.blueBufferSize());
+ obj1.setBlueBufferSize(0);
+ QCOMPARE(0, obj1.blueBufferSize());
+ QTest::ignoreMessage(QtWarningMsg, "QGLFormat::setBlueBufferSize: Cannot set negative blue buffer size -2147483648");
+ obj1.setBlueBufferSize(TEST_INT_MIN);
+ QCOMPARE(0, obj1.blueBufferSize()); // Makes no sense with a negative buffer size
+ obj1.setBlueBufferSize(3);
+ QTest::ignoreMessage(QtWarningMsg, "QGLFormat::setBlueBufferSize: Cannot set negative blue buffer size -1");
+ obj1.setBlueBufferSize(-1);
+ QCOMPARE(3, obj1.blueBufferSize());
+ obj1.setBlueBufferSize(TEST_INT_MAX);
+ QCOMPARE(TEST_INT_MAX, obj1.blueBufferSize());
// int QGLFormat::alphaBufferSize()
// void QGLFormat::setAlphaBufferSize(int)
+ QCOMPARE(-1, obj1.alphaBufferSize());
+ QCOMPARE(false, obj1.alpha());
+ QVERIFY(!obj1.testOption(QGL::AlphaChannel));
+ QVERIFY(obj1.testOption(QGL::NoAlphaChannel));
obj1.setAlphaBufferSize(0);
+ QCOMPARE(true, obj1.alpha()); // setAlphaBufferSize() enables alpha.
QCOMPARE(0, obj1.alphaBufferSize());
- obj1.setAlphaBufferSize(INT_MIN);
+ QTest::ignoreMessage(QtWarningMsg, "QGLFormat::setAlphaBufferSize: Cannot set negative alpha buffer size -2147483648");
+ obj1.setAlphaBufferSize(TEST_INT_MIN);
QCOMPARE(0, obj1.alphaBufferSize()); // Makes no sense with a negative buffer size
- obj1.setAlphaBufferSize(INT_MAX);
- QCOMPARE(INT_MAX, obj1.alphaBufferSize());
+ obj1.setAlphaBufferSize(3);
+ QTest::ignoreMessage(QtWarningMsg, "QGLFormat::setAlphaBufferSize: Cannot set negative alpha buffer size -1");
+ obj1.setAlphaBufferSize(-1);
+ QCOMPARE(3, obj1.alphaBufferSize());
+ obj1.setAlphaBufferSize(TEST_INT_MAX);
+ QCOMPARE(TEST_INT_MAX, obj1.alphaBufferSize());
// int QGLFormat::stencilBufferSize()
// void QGLFormat::setStencilBufferSize(int)
+ QCOMPARE(-1, obj1.stencilBufferSize());
obj1.setStencilBufferSize(0);
QCOMPARE(0, obj1.stencilBufferSize());
- obj1.setStencilBufferSize(INT_MIN);
+ QTest::ignoreMessage(QtWarningMsg, "QGLFormat::setStencilBufferSize: Cannot set negative stencil buffer size -2147483648");
+ obj1.setStencilBufferSize(TEST_INT_MIN);
QCOMPARE(0, obj1.stencilBufferSize()); // Makes no sense with a negative buffer size
- obj1.setStencilBufferSize(INT_MAX);
- QCOMPARE(INT_MAX, obj1.stencilBufferSize());
+ obj1.setStencilBufferSize(3);
+ QTest::ignoreMessage(QtWarningMsg, "QGLFormat::setStencilBufferSize: Cannot set negative stencil buffer size -1");
+ obj1.setStencilBufferSize(-1);
+ QCOMPARE(3, obj1.stencilBufferSize());
+ obj1.setStencilBufferSize(TEST_INT_MAX);
+ QCOMPARE(TEST_INT_MAX, obj1.stencilBufferSize());
// bool QGLFormat::sampleBuffers()
// void QGLFormat::setSampleBuffers(bool)
+ QCOMPARE(false, obj1.sampleBuffers());
+ QVERIFY(!obj1.testOption(QGL::SampleBuffers));
+ QVERIFY(obj1.testOption(QGL::NoSampleBuffers));
obj1.setSampleBuffers(false);
QCOMPARE(false, obj1.sampleBuffers());
+ QVERIFY(obj1.testOption(QGL::NoSampleBuffers));
obj1.setSampleBuffers(true);
QCOMPARE(true, obj1.sampleBuffers());
+ QVERIFY(obj1.testOption(QGL::SampleBuffers));
// int QGLFormat::samples()
// void QGLFormat::setSamples(int)
+ QCOMPARE(-1, obj1.samples());
obj1.setSamples(0);
QCOMPARE(0, obj1.samples());
- obj1.setSamples(INT_MIN);
+ QTest::ignoreMessage(QtWarningMsg, "QGLFormat::setSamples: Cannot have negative number of samples per pixel -2147483648");
+ obj1.setSamples(TEST_INT_MIN);
QCOMPARE(0, obj1.samples()); // Makes no sense with a negative sample size
- obj1.setSamples(INT_MAX);
- QCOMPARE(INT_MAX, obj1.samples());
+ obj1.setSamples(3);
+ QTest::ignoreMessage(QtWarningMsg, "QGLFormat::setSamples: Cannot have negative number of samples per pixel -1");
+ obj1.setSamples(-1);
+ QCOMPARE(3, obj1.samples());
+ obj1.setSamples(TEST_INT_MAX);
+ QCOMPARE(TEST_INT_MAX, obj1.samples());
+
+ // int QGLFormat::swapInterval()
+ // void QGLFormat::setSwapInterval(int)
+ QCOMPARE(-1, obj1.swapInterval());
+ obj1.setSwapInterval(0);
+ QCOMPARE(0, obj1.swapInterval());
+ obj1.setSwapInterval(TEST_INT_MIN);
+ QCOMPARE(TEST_INT_MIN, obj1.swapInterval());
+ obj1.setSwapInterval(-1);
+ QCOMPARE(-1, obj1.swapInterval());
+ obj1.setSwapInterval(TEST_INT_MAX);
+ QCOMPARE(TEST_INT_MAX, obj1.swapInterval());
// bool QGLFormat::doubleBuffer()
// void QGLFormat::setDoubleBuffer(bool)
+ QCOMPARE(true, obj1.doubleBuffer());
+ QVERIFY(obj1.testOption(QGL::DoubleBuffer));
+ QVERIFY(!obj1.testOption(QGL::SingleBuffer));
obj1.setDoubleBuffer(false);
QCOMPARE(false, obj1.doubleBuffer());
+ QVERIFY(!obj1.testOption(QGL::DoubleBuffer));
+ QVERIFY(obj1.testOption(QGL::SingleBuffer));
obj1.setDoubleBuffer(true);
QCOMPARE(true, obj1.doubleBuffer());
+ QVERIFY(obj1.testOption(QGL::DoubleBuffer));
+ QVERIFY(!obj1.testOption(QGL::SingleBuffer));
// bool QGLFormat::depth()
// void QGLFormat::setDepth(bool)
+ QCOMPARE(true, obj1.depth());
+ QVERIFY(obj1.testOption(QGL::DepthBuffer));
+ QVERIFY(!obj1.testOption(QGL::NoDepthBuffer));
obj1.setDepth(false);
QCOMPARE(false, obj1.depth());
+ QVERIFY(!obj1.testOption(QGL::DepthBuffer));
+ QVERIFY(obj1.testOption(QGL::NoDepthBuffer));
obj1.setDepth(true);
QCOMPARE(true, obj1.depth());
+ QVERIFY(obj1.testOption(QGL::DepthBuffer));
+ QVERIFY(!obj1.testOption(QGL::NoDepthBuffer));
// bool QGLFormat::rgba()
// void QGLFormat::setRgba(bool)
+ QCOMPARE(true, obj1.rgba());
+ QVERIFY(obj1.testOption(QGL::Rgba));
+ QVERIFY(!obj1.testOption(QGL::ColorIndex));
obj1.setRgba(false);
QCOMPARE(false, obj1.rgba());
+ QVERIFY(!obj1.testOption(QGL::Rgba));
+ QVERIFY(obj1.testOption(QGL::ColorIndex));
obj1.setRgba(true);
QCOMPARE(true, obj1.rgba());
+ QVERIFY(obj1.testOption(QGL::Rgba));
+ QVERIFY(!obj1.testOption(QGL::ColorIndex));
// bool QGLFormat::alpha()
// void QGLFormat::setAlpha(bool)
+ QVERIFY(obj1.testOption(QGL::AlphaChannel));
+ QVERIFY(!obj1.testOption(QGL::NoAlphaChannel));
obj1.setAlpha(false);
QCOMPARE(false, obj1.alpha());
+ QVERIFY(!obj1.testOption(QGL::AlphaChannel));
+ QVERIFY(obj1.testOption(QGL::NoAlphaChannel));
obj1.setAlpha(true);
QCOMPARE(true, obj1.alpha());
+ QVERIFY(obj1.testOption(QGL::AlphaChannel));
+ QVERIFY(!obj1.testOption(QGL::NoAlphaChannel));
// bool QGLFormat::accum()
// void QGLFormat::setAccum(bool)
+ QCOMPARE(false, obj1.accum());
+ QVERIFY(!obj1.testOption(QGL::AccumBuffer));
+ QVERIFY(obj1.testOption(QGL::NoAccumBuffer));
obj1.setAccum(false);
QCOMPARE(false, obj1.accum());
+ QVERIFY(!obj1.testOption(QGL::AccumBuffer));
+ QVERIFY(obj1.testOption(QGL::NoAccumBuffer));
obj1.setAccum(true);
QCOMPARE(true, obj1.accum());
+ QVERIFY(obj1.testOption(QGL::AccumBuffer));
+ QVERIFY(!obj1.testOption(QGL::NoAccumBuffer));
// bool QGLFormat::stencil()
// void QGLFormat::setStencil(bool)
+ QCOMPARE(true, obj1.stencil());
+ QVERIFY(obj1.testOption(QGL::StencilBuffer));
+ QVERIFY(!obj1.testOption(QGL::NoStencilBuffer));
obj1.setStencil(false);
QCOMPARE(false, obj1.stencil());
+ QVERIFY(!obj1.testOption(QGL::StencilBuffer));
+ QVERIFY(obj1.testOption(QGL::NoStencilBuffer));
obj1.setStencil(true);
QCOMPARE(true, obj1.stencil());
+ QVERIFY(obj1.testOption(QGL::StencilBuffer));
+ QVERIFY(!obj1.testOption(QGL::NoStencilBuffer));
// bool QGLFormat::stereo()
// void QGLFormat::setStereo(bool)
+ QCOMPARE(false, obj1.stereo());
+ QVERIFY(!obj1.testOption(QGL::StereoBuffers));
+ QVERIFY(obj1.testOption(QGL::NoStereoBuffers));
obj1.setStereo(false);
QCOMPARE(false, obj1.stereo());
+ QVERIFY(!obj1.testOption(QGL::StereoBuffers));
+ QVERIFY(obj1.testOption(QGL::NoStereoBuffers));
obj1.setStereo(true);
QCOMPARE(true, obj1.stereo());
+ QVERIFY(obj1.testOption(QGL::StereoBuffers));
+ QVERIFY(!obj1.testOption(QGL::NoStereoBuffers));
// bool QGLFormat::directRendering()
// void QGLFormat::setDirectRendering(bool)
+ QCOMPARE(true, obj1.directRendering());
+ QVERIFY(obj1.testOption(QGL::DirectRendering));
+ QVERIFY(!obj1.testOption(QGL::IndirectRendering));
obj1.setDirectRendering(false);
QCOMPARE(false, obj1.directRendering());
+ QVERIFY(!obj1.testOption(QGL::DirectRendering));
+ QVERIFY(obj1.testOption(QGL::IndirectRendering));
obj1.setDirectRendering(true);
QCOMPARE(true, obj1.directRendering());
+ QVERIFY(obj1.testOption(QGL::DirectRendering));
+ QVERIFY(!obj1.testOption(QGL::IndirectRendering));
+
+ // bool QGLFormat::overlay()
+ // void QGLFormat::setOverlay(bool)
+ QCOMPARE(false, obj1.hasOverlay());
+ QVERIFY(!obj1.testOption(QGL::HasOverlay));
+ QVERIFY(obj1.testOption(QGL::NoOverlay));
+ obj1.setOverlay(false);
+ QCOMPARE(false, obj1.hasOverlay());
+ QVERIFY(!obj1.testOption(QGL::HasOverlay));
+ QVERIFY(obj1.testOption(QGL::NoOverlay));
+ obj1.setOverlay(true);
+ QCOMPARE(true, obj1.hasOverlay());
+ QVERIFY(obj1.testOption(QGL::HasOverlay));
+ QVERIFY(!obj1.testOption(QGL::NoOverlay));
// int QGLFormat::plane()
// void QGLFormat::setPlane(int)
+ QCOMPARE(0, obj1.plane());
obj1.setPlane(0);
QCOMPARE(0, obj1.plane());
- obj1.setPlane(INT_MIN);
- QCOMPARE(INT_MIN, obj1.plane());
- obj1.setPlane(INT_MAX);
- QCOMPARE(INT_MAX, obj1.plane());
+ obj1.setPlane(TEST_INT_MIN);
+ QCOMPARE(TEST_INT_MIN, obj1.plane());
+ obj1.setPlane(TEST_INT_MAX);
+ QCOMPARE(TEST_INT_MAX, obj1.plane());
MyGLContext obj2(obj1);
// bool QGLContext::windowCreated()
@@ -452,5 +625,124 @@ void tst_QGL::partialGLWidgetUpdates()
QCOMPARE(widget.paintEventRegion, QRegion(widget.rect()));
}
+class ColormapExtended : public QGLColormap
+{
+public:
+ ColormapExtended() {}
+
+ Qt::HANDLE handle() { return QGLColormap::handle(); }
+ void setHandle(Qt::HANDLE handle) { QGLColormap::setHandle(handle); }
+};
+
+void tst_QGL::colormap()
+{
+ // Check the properties of the default empty colormap.
+ QGLColormap cmap1;
+ QVERIFY(cmap1.isEmpty());
+ QCOMPARE(cmap1.size(), 0);
+ QVERIFY(cmap1.entryRgb(0) == 0);
+ QVERIFY(cmap1.entryRgb(-1) == 0);
+ QVERIFY(cmap1.entryRgb(100) == 0);
+ QVERIFY(!cmap1.entryColor(0).isValid());
+ QVERIFY(!cmap1.entryColor(-1).isValid());
+ QVERIFY(!cmap1.entryColor(100).isValid());
+ QCOMPARE(cmap1.find(qRgb(255, 0, 0)), -1);
+ QCOMPARE(cmap1.findNearest(qRgb(255, 0, 0)), -1);
+
+ // Set an entry and re-test.
+ cmap1.setEntry(56, qRgb(255, 0, 0));
+ // The colormap is still considered "empty" even though it
+ // has entries in it now. The isEmpty() method is used to
+ // detect when the colormap is in use by a GL widget,
+ // not to detect when it is empty!
+ QVERIFY(cmap1.isEmpty());
+ QCOMPARE(cmap1.size(), 256);
+ QVERIFY(cmap1.entryRgb(0) == 0);
+ QVERIFY(cmap1.entryColor(0) == QColor(0, 0, 0, 255));
+ QVERIFY(cmap1.entryRgb(56) == qRgb(255, 0, 0));
+ QVERIFY(cmap1.entryColor(56) == QColor(255, 0, 0, 255));
+ QCOMPARE(cmap1.find(qRgb(255, 0, 0)), 56);
+ QCOMPARE(cmap1.findNearest(qRgb(255, 0, 0)), 56);
+
+ // Set some more entries.
+ static QRgb const colors[] = {
+ qRgb(255, 0, 0),
+ qRgb(0, 255, 0),
+ qRgb(255, 255, 255),
+ qRgb(0, 0, 255),
+ qRgb(0, 0, 0)
+ };
+ cmap1.setEntry(57, QColor(0, 255, 0));
+ cmap1.setEntries(3, colors + 2, 58);
+ cmap1.setEntries(5, colors, 251);
+ int idx;
+ for (idx = 0; idx < 5; ++idx) {
+ QVERIFY(cmap1.entryRgb(56 + idx) == colors[idx]);
+ QVERIFY(cmap1.entryColor(56 + idx) == QColor(colors[idx]));
+ QVERIFY(cmap1.entryRgb(251 + idx) == colors[idx]);
+ QVERIFY(cmap1.entryColor(251 + idx) == QColor(colors[idx]));
+ }
+ QCOMPARE(cmap1.size(), 256);
+
+ // Perform color lookups.
+ QCOMPARE(cmap1.find(qRgb(255, 0, 0)), 56);
+ QCOMPARE(cmap1.find(qRgb(0, 0, 0)), 60); // Actually finds 0, 0, 0, 255.
+ QCOMPARE(cmap1.find(qRgba(0, 0, 0, 0)), 0);
+ QCOMPARE(cmap1.find(qRgb(0, 255, 0)), 57);
+ QCOMPARE(cmap1.find(qRgb(255, 255, 255)), 58);
+ QCOMPARE(cmap1.find(qRgb(0, 0, 255)), 59);
+ QCOMPARE(cmap1.find(qRgb(140, 0, 0)), -1);
+ QCOMPARE(cmap1.find(qRgb(0, 140, 0)), -1);
+ QCOMPARE(cmap1.find(qRgb(0, 0, 140)), -1);
+ QCOMPARE(cmap1.find(qRgb(64, 0, 0)), -1);
+ QCOMPARE(cmap1.find(qRgb(0, 64, 0)), -1);
+ QCOMPARE(cmap1.find(qRgb(0, 0, 64)), -1);
+ QCOMPARE(cmap1.findNearest(qRgb(255, 0, 0)), 56);
+ QCOMPARE(cmap1.findNearest(qRgb(0, 0, 0)), 60);
+ QCOMPARE(cmap1.findNearest(qRgba(0, 0, 0, 0)), 0);
+ QCOMPARE(cmap1.findNearest(qRgb(0, 255, 0)), 57);
+ QCOMPARE(cmap1.findNearest(qRgb(255, 255, 255)), 58);
+ QCOMPARE(cmap1.findNearest(qRgb(0, 0, 255)), 59);
+ QCOMPARE(cmap1.findNearest(qRgb(140, 0, 0)), 56);
+ QCOMPARE(cmap1.findNearest(qRgb(0, 140, 0)), 57);
+ QCOMPARE(cmap1.findNearest(qRgb(0, 0, 140)), 59);
+ QCOMPARE(cmap1.findNearest(qRgb(64, 0, 0)), 0);
+ QCOMPARE(cmap1.findNearest(qRgb(0, 64, 0)), 0);
+ QCOMPARE(cmap1.findNearest(qRgb(0, 0, 64)), 0);
+
+ // Make some copies of the colormap and check that they are the same.
+ QGLColormap cmap2(cmap1);
+ QGLColormap cmap3;
+ cmap3 = cmap1;
+ QVERIFY(cmap2.isEmpty());
+ QVERIFY(cmap3.isEmpty());
+ QCOMPARE(cmap2.size(), 256);
+ QCOMPARE(cmap3.size(), 256);
+ for (idx = 0; idx < 256; ++idx) {
+ QCOMPARE(cmap1.entryRgb(idx), cmap2.entryRgb(idx));
+ QCOMPARE(cmap1.entryRgb(idx), cmap3.entryRgb(idx));
+ }
+
+ // Modify an entry in one of the copies and recheck the original.
+ cmap2.setEntry(45, qRgb(255, 0, 0));
+ for (idx = 0; idx < 256; ++idx) {
+ if (idx != 45)
+ QCOMPARE(cmap1.entryRgb(idx), cmap2.entryRgb(idx));
+ else
+ QCOMPARE(cmap2.entryRgb(45), qRgb(255, 0, 0));
+ QCOMPARE(cmap1.entryRgb(idx), cmap3.entryRgb(idx));
+ }
+
+ // Check that setting the handle will cause isEmpty() to work right.
+ ColormapExtended cmap4;
+ cmap4.setEntry(56, qRgb(255, 0, 0));
+ QVERIFY(cmap4.isEmpty());
+ QCOMPARE(cmap4.size(), 256);
+ cmap4.setHandle(Qt::HANDLE(42));
+ QVERIFY(cmap4.handle() == Qt::HANDLE(42));
+ QVERIFY(!cmap4.isEmpty());
+ QCOMPARE(cmap4.size(), 256);
+}
+
QTEST_MAIN(tst_QGL)
#include "tst_qgl.moc"
diff --git a/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp b/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp
index 7f6f322..789bb27 100644
--- a/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp
+++ b/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp
@@ -169,6 +169,7 @@ private slots:
void setParentItem();
void children();
void flags();
+ void inputMethodHints();
void toolTip();
void visible();
void explicitlyVisible();
@@ -760,6 +761,34 @@ void tst_QGraphicsItem::flags()
QApplication::sendEvent(&scene, &event5);
QCOMPARE(item->pos(), QPointF(10, 10));
}
+ {
+ QGraphicsItem* clippingParent = new QGraphicsRectItem;
+ clippingParent->setFlag(QGraphicsItem::ItemClipsChildrenToShape, true);
+
+ QGraphicsItem* nonClippingParent = new QGraphicsRectItem;
+ nonClippingParent->setFlag(QGraphicsItem::ItemClipsChildrenToShape, false);
+
+ QGraphicsItem* child = new QGraphicsRectItem(nonClippingParent);
+ QVERIFY(!child->isClipped());
+
+ child->setParentItem(clippingParent);
+ QVERIFY(child->isClipped());
+
+ child->setParentItem(nonClippingParent);
+ QVERIFY(!child->isClipped());
+ }
+}
+
+class ImhTester : public QGraphicsItem
+{
+ QRectF boundingRect() const { return QRectF(); }
+ void paint(QPainter *, const QStyleOptionGraphicsItem *, QWidget *) {}
+};
+
+void tst_QGraphicsItem::inputMethodHints()
+{
+ ImhTester item;
+ QCOMPARE(item.inputMethodHints(), Qt::ImhNone);
}
void tst_QGraphicsItem::toolTip()
diff --git a/tests/auto/qguard/qguard.pro b/tests/auto/qguard/qguard.pro
new file mode 100644
index 0000000..f249dde
--- /dev/null
+++ b/tests/auto/qguard/qguard.pro
@@ -0,0 +1,2 @@
+load(qttest_p4)
+SOURCES += tst_qguard.cpp
diff --git a/tests/auto/qguard/tst_qguard.cpp b/tests/auto/qguard/tst_qguard.cpp
new file mode 100644
index 0000000..96d1b60
--- /dev/null
+++ b/tests/auto/qguard/tst_qguard.cpp
@@ -0,0 +1,350 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** 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 either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** 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.0, 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.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+// NOTE: This is identical to the QPointer autotest
+
+#include <QtTest/QtTest>
+
+#include <QApplication>
+#include <QDebug>
+#include <QWidget>
+#include <private/qguard_p.h>
+
+class tst_QGuard : public QObject
+{
+ Q_OBJECT
+public:
+ tst_QGuard();
+ ~tst_QGuard();
+
+ inline tst_QGuard *me() const
+ { return const_cast<tst_QGuard *>(this); }
+
+public slots:
+ void initTestCase();
+ void cleanupTestCase();
+ void init();
+ void cleanup();
+private slots:
+ void constructors();
+ void destructor();
+ void assignment_operators();
+ void equality_operators();
+ void isNull();
+ void dereference_operators();
+ void disconnect();
+ void castDuringDestruction();
+ void data() const;
+ void dataSignature() const;
+};
+
+tst_QGuard::tst_QGuard()
+{ }
+
+tst_QGuard::~tst_QGuard()
+{ }
+
+void tst_QGuard::initTestCase()
+{ }
+
+void tst_QGuard::cleanupTestCase()
+{ }
+
+void tst_QGuard::init()
+{ }
+
+void tst_QGuard::cleanup()
+{ }
+
+void tst_QGuard::constructors()
+{
+ QGuard<QObject> p1;
+ QGuard<QObject> p2(this);
+ QGuard<QObject> p3(p2);
+ QCOMPARE(p1, QGuard<QObject>(0));
+ QCOMPARE(p2, QGuard<QObject>(this));
+ QCOMPARE(p3, QGuard<QObject>(this));
+}
+
+void tst_QGuard::destructor()
+{
+ QObject *object = new QObject;
+ QGuard<QObject> p = object;
+ QCOMPARE(p, QGuard<QObject>(object));
+ delete object;
+ QCOMPARE(p, QGuard<QObject>(0));
+}
+
+void tst_QGuard::assignment_operators()
+{
+ QGuard<QObject> p1;
+ QGuard<QObject> p2;
+
+ p1 = this;
+ p2 = p1;
+
+ QCOMPARE(p1, QGuard<QObject>(this));
+ QCOMPARE(p2, QGuard<QObject>(this));
+ QCOMPARE(p1, QGuard<QObject>(p2));
+
+ p1 = 0;
+ p2 = p1;
+ QCOMPARE(p1, QGuard<QObject>(0));
+ QCOMPARE(p2, QGuard<QObject>(0));
+ QCOMPARE(p1, QGuard<QObject>(p2));
+
+ QObject *object = new QObject;
+
+ p1 = object;
+ p2 = p1;
+ QCOMPARE(p1, QGuard<QObject>(object));
+ QCOMPARE(p2, QGuard<QObject>(object));
+ QCOMPARE(p1, QGuard<QObject>(p2));
+
+ delete object;
+ QCOMPARE(p1, QGuard<QObject>(0));
+ QCOMPARE(p2, QGuard<QObject>(0));
+ QCOMPARE(p1, QGuard<QObject>(p2));
+}
+
+void tst_QGuard::equality_operators()
+{
+ QGuard<QObject> p1;
+ QGuard<QObject> p2;
+
+ QVERIFY(p1 == p2);
+
+ QObject *object = 0;
+ QWidget *widget = 0;
+
+ p1 = object;
+ QVERIFY(p1 == p2);
+ QVERIFY(p1 == object);
+ p2 = object;
+ QVERIFY(p2 == p1);
+ QVERIFY(p2 == object);
+
+ p1 = this;
+ QVERIFY(p1 != p2);
+ p2 = p1;
+ QVERIFY(p1 == p2);
+
+ // compare to zero
+ p1 = 0;
+ QVERIFY(p1 == 0);
+ QVERIFY(0 == p1);
+ QVERIFY(p2 != 0);
+ QVERIFY(0 != p2);
+ QVERIFY(p1 == object);
+ QVERIFY(object == p1);
+ QVERIFY(p2 != object);
+ QVERIFY(object != p2);
+ QVERIFY(p1 == widget);
+ QVERIFY(widget == p1);
+ QVERIFY(p2 != widget);
+ QVERIFY(widget != p2);
+}
+
+void tst_QGuard::isNull()
+{
+ QGuard<QObject> p1;
+ QVERIFY(p1.isNull());
+ p1 = this;
+ QVERIFY(!p1.isNull());
+ p1 = 0;
+ QVERIFY(p1.isNull());
+}
+
+void tst_QGuard::dereference_operators()
+{
+ QGuard<tst_QGuard> p1 = this;
+
+ QObject *object = p1->me();
+ QVERIFY(object == this);
+
+ QObject &ref = *p1;
+ QVERIFY(&ref == this);
+
+ object = static_cast<QObject *>(p1);
+ QVERIFY(object == this);
+}
+
+void tst_QGuard::disconnect()
+{
+ QGuard<QObject> p1 = new QObject;
+ QVERIFY(!p1.isNull());
+ p1->disconnect();
+ QVERIFY(!p1.isNull());
+ delete static_cast<QObject *>(p1);
+ QVERIFY(p1.isNull());
+}
+
+class ChildObject : public QObject
+{
+ QGuard<QObject> guardedPointer;
+
+public:
+ ChildObject(QObject *parent)
+ : QObject(parent), guardedPointer(parent)
+ { }
+ ~ChildObject();
+};
+
+ChildObject::~ChildObject()
+{
+ QCOMPARE(static_cast<QObject *>(guardedPointer), static_cast<QObject *>(0));
+ QCOMPARE(qobject_cast<QObject *>(guardedPointer), static_cast<QObject *>(0));
+}
+
+class ChildWidget : public QWidget
+{
+ QGuard<QWidget> guardedPointer;
+
+public:
+ ChildWidget(QWidget *parent)
+ : QWidget(parent), guardedPointer(parent)
+ { }
+ ~ChildWidget();
+};
+
+ChildWidget::~ChildWidget()
+{
+ QCOMPARE(static_cast<QWidget *>(guardedPointer), static_cast<QWidget *>(0));
+ QCOMPARE(qobject_cast<QWidget *>(guardedPointer), static_cast<QWidget *>(0));
+}
+
+class DerivedChild;
+
+class DerivedParent : public QObject
+{
+ Q_OBJECT
+
+ DerivedChild *derivedChild;
+
+public:
+ DerivedParent();
+ ~DerivedParent();
+};
+
+class DerivedChild : public QObject
+{
+ Q_OBJECT
+
+ DerivedParent *parentPointer;
+ QGuard<DerivedParent> guardedParentPointer;
+
+public:
+ DerivedChild(DerivedParent *parent)
+ : QObject(parent), parentPointer(parent), guardedParentPointer(parent)
+ { }
+ ~DerivedChild();
+};
+
+DerivedParent::DerivedParent()
+ : QObject()
+{
+ derivedChild = new DerivedChild(this);
+}
+
+DerivedParent::~DerivedParent()
+{
+ delete derivedChild;
+}
+
+DerivedChild::~DerivedChild()
+{
+ QCOMPARE(static_cast<DerivedParent *>(guardedParentPointer), parentPointer);
+ QCOMPARE(qobject_cast<DerivedParent *>(guardedParentPointer), parentPointer);
+}
+
+void tst_QGuard::castDuringDestruction()
+{
+ {
+ QObject *parentObject = new QObject();
+ (void) new ChildObject(parentObject);
+ delete parentObject;
+ }
+
+ {
+ QWidget *parentWidget = new QWidget();
+ (void) new ChildWidget(parentWidget);
+ delete parentWidget;
+ }
+
+ {
+ delete new DerivedParent();
+ }
+}
+
+void tst_QGuard::data() const
+{
+ /* Check value of a default constructed object. */
+ {
+ QGuard<QObject> p;
+ QCOMPARE(p.data(), static_cast<QObject *>(0));
+ }
+
+ /* Check value of a default constructed object. */
+ {
+ QObject *const object = new QObject();
+ QGuard<QObject> p(object);
+ QCOMPARE(p.data(), object);
+ }
+}
+
+void tst_QGuard::dataSignature() const
+{
+ /* data() should be const. */
+ {
+ const QGuard<QObject> p;
+ p.data();
+ }
+
+ /* The return type should be T. */
+ {
+ const QGuard<QWidget> p;
+ /* If the types differs, the QCOMPARE will fail to instansiate. */
+ QCOMPARE(p.data(), static_cast<QWidget *>(0));
+ }
+}
+
+QTEST_MAIN(tst_QGuard)
+#include "tst_qguard.moc"
diff --git a/tests/auto/qhelpenginecore/data/collection.qhc b/tests/auto/qhelpenginecore/data/collection.qhc
index 6fb8abb..bd2f37c 100644
--- a/tests/auto/qhelpenginecore/data/collection.qhc
+++ b/tests/auto/qhelpenginecore/data/collection.qhc
Binary files differ
diff --git a/tests/auto/qhelpenginecore/data/collection1.qhc b/tests/auto/qhelpenginecore/data/collection1.qhc
index 45acf33..de310ea 100644
--- a/tests/auto/qhelpenginecore/data/collection1.qhc
+++ b/tests/auto/qhelpenginecore/data/collection1.qhc
Binary files differ
diff --git a/tests/auto/qhelpenginecore/data/linguist-3.3.8.qch b/tests/auto/qhelpenginecore/data/linguist-3.3.8.qch
index 0b53cd8..ed9a89c 100644
--- a/tests/auto/qhelpenginecore/data/linguist-3.3.8.qch
+++ b/tests/auto/qhelpenginecore/data/linguist-3.3.8.qch
Binary files differ
diff --git a/tests/auto/qhelpenginecore/data/qmake-3.3.8.qch b/tests/auto/qhelpenginecore/data/qmake-3.3.8.qch
index a3ca18a..0e95c14 100644
--- a/tests/auto/qhelpenginecore/data/qmake-3.3.8.qch
+++ b/tests/auto/qhelpenginecore/data/qmake-3.3.8.qch
Binary files differ
diff --git a/tests/auto/qhelpenginecore/data/qmake-4.3.0.qch b/tests/auto/qhelpenginecore/data/qmake-4.3.0.qch
index 8f76134..337d7a1 100644
--- a/tests/auto/qhelpenginecore/data/qmake-4.3.0.qch
+++ b/tests/auto/qhelpenginecore/data/qmake-4.3.0.qch
Binary files differ
diff --git a/tests/auto/qhelpenginecore/data/test.qch b/tests/auto/qhelpenginecore/data/test.qch
index 8a8f7a1..06b789a 100644
--- a/tests/auto/qhelpenginecore/data/test.qch
+++ b/tests/auto/qhelpenginecore/data/test.qch
Binary files differ
diff --git a/tests/auto/qhelpenginecore/tst_qhelpenginecore.cpp b/tests/auto/qhelpenginecore/tst_qhelpenginecore.cpp
index d62c8e5..f9aa653 100644
--- a/tests/auto/qhelpenginecore/tst_qhelpenginecore.cpp
+++ b/tests/auto/qhelpenginecore/tst_qhelpenginecore.cpp
@@ -130,7 +130,7 @@ void tst_QHelpEngineCore::setCollectionFile()
QStringList docs = help.registeredDocumentations();
QCOMPARE(docs.count(), 1);
- QCOMPARE(docs.first(), QLatin1String("trolltech.com.1_0_0.test"));
+ QCOMPARE(docs.first(), QLatin1String("trolltech.com.1-0-0.test"));
}
void tst_QHelpEngineCore::copyCollectionFile()
@@ -177,7 +177,7 @@ void tst_QHelpEngineCore::copyCollectionFile()
i = 0;
while (m_query->next()) {
if (i == 0) {
- QCOMPARE(m_query->value(0).toString(), QString("trolltech.com.3_3_8.qmake"));
+ QCOMPARE(m_query->value(0).toString(), QString("trolltech.com.3-3-8.qmake"));
QCOMPARE(m_query->value(1).toString(), QString("data/qmake-3.3.8.qch"));
}
++i;
@@ -193,9 +193,9 @@ void tst_QHelpEngineCore::copyCollectionFile()
void tst_QHelpEngineCore::namespaceName()
{
QCOMPARE(QHelpEngineCore::namespaceName(m_path + "/data/qmake-3.3.8.qch"),
- QString("trolltech.com.3_3_8.qmake"));
+ QString("trolltech.com.3-3-8.qmake"));
QCOMPARE(QHelpEngineCore::namespaceName(m_path + "/data/linguist-3.3.8.qch"),
- QString("trolltech.com.3_3_8.linguist"));
+ QString("trolltech.com.3-3-8.linguist"));
}
void tst_QHelpEngineCore::registeredDocumentations()
@@ -205,8 +205,8 @@ void tst_QHelpEngineCore::registeredDocumentations()
QStringList docs = help.registeredDocumentations();
QCOMPARE(docs.count(), 3);
QStringList lst;
- lst << "trolltech.com.3_3_8.qmake" << "trolltech.com.4_3_0.qmake"
- << "trolltech.com.1_0_0.test";
+ lst << "trolltech.com.3-3-8.qmake" << "trolltech.com.4-3-0.qmake"
+ << "trolltech.com.1-0-0.test";
foreach (QString s, docs)
lst.removeAll(s);
QCOMPARE(lst.isEmpty(), true);
@@ -236,7 +236,7 @@ void tst_QHelpEngineCore::registerDocumentation()
}
QSqlQuery query(db);
query.exec("SELECT FilePath FROM NamespaceTable WHERE "
- "Name=\'trolltech.com.3_3_8.linguist\'");
+ "Name=\'trolltech.com.3-3-8.linguist\'");
if (query.next())
QCOMPARE(query.value(0).toString(),
QString("linguist-3.3.8.qch"));
@@ -251,7 +251,7 @@ void tst_QHelpEngineCore::unregisterDocumentation()
QHelpEngineCore c(m_colFile);
QCOMPARE(c.setupData(), true);
QCOMPARE(c.registeredDocumentations().count(), 3);
- c.unregisterDocumentation("trolltech.com.3_3_8.qmake");
+ c.unregisterDocumentation("trolltech.com.3-3-8.qmake");
QCOMPARE(c.registeredDocumentations().count(), 2);
QCOMPARE(c.unregisterDocumentation("noexisting"), false);
}
@@ -260,9 +260,9 @@ void tst_QHelpEngineCore::documentationFileName()
{
QHelpEngineCore c(m_colFile);
QCOMPARE(c.setupData(), true);
- QCOMPARE(c.documentationFileName(QLatin1String("trolltech.com.3_3_8.qmake")),
+ QCOMPARE(c.documentationFileName(QLatin1String("trolltech.com.3-3-8.qmake")),
QString(m_path + "/data/qmake-3.3.8.qch"));
- QCOMPARE(c.documentationFileName(QLatin1String("trolltech.com.1_0_0.test")),
+ QCOMPARE(c.documentationFileName(QLatin1String("trolltech.com.1-0-0.test")),
QString(m_path + "/data/test.qch"));
QCOMPARE(c.documentationFileName(QLatin1String("trolltech.com.empty")),
QString());
@@ -337,7 +337,7 @@ void tst_QHelpEngineCore::filterAttributeSets()
{
QHelpEngineCore help(m_colFile, 0);
QCOMPARE(help.setupData(), true);
- QList<QStringList> lst = help.filterAttributeSets("trolltech.com.1_0_0.test");
+ QList<QStringList> lst = help.filterAttributeSets("trolltech.com.1-0-0.test");
QCOMPARE(lst.count(), 2);
QCOMPARE(lst.first().count(), 2);
QCOMPARE((bool)lst.first().contains("filter1"), true);
@@ -348,22 +348,22 @@ void tst_QHelpEngineCore::files()
{
QHelpEngineCore help(m_colFile, 0);
QCOMPARE(help.setupData(), true);
- QList<QUrl> lst = help.files("trolltech.com.4_3_0.qmake",
+ QList<QUrl> lst = help.files("trolltech.com.4-3-0.qmake",
QStringList());
QCOMPARE(lst.count(), 16);
- lst = help.files("trolltech.com.4_3_0.qmake",
+ lst = help.files("trolltech.com.4-3-0.qmake",
QStringList(), "png");
QCOMPARE(lst.count(), 2);
- lst = help.files("trolltech.com.4_3_0.qmake",
+ lst = help.files("trolltech.com.4-3-0.qmake",
QStringList() << "qt", "html");
QCOMPARE(lst.count(), 13);
- lst = help.files("trolltech.com.4_3_0.qmake",
+ lst = help.files("trolltech.com.4-3-0.qmake",
QStringList() << "qt" << "qmake", "html");
QCOMPARE(lst.count(), 13);
- lst = help.files("trolltech.com.4_3_0.qmake",
+ lst = help.files("trolltech.com.4-3-0.qmake",
QStringList() << "qt" << "qmake" << "bla", "html");
QCOMPARE(lst.count(), 0);
- lst = help.files("trolltech.com.4_3_0.qmake",
+ lst = help.files("trolltech.com.4-3-0.qmake",
QStringList() << "qt" << "qmake", "foo");
QCOMPARE(lst.count(), 0);
@@ -378,7 +378,7 @@ void tst_QHelpEngineCore::fileData()
QCOMPARE(help.setupData(), true);
QByteArray ba = help.fileData(QUrl("NotExisting"));
QCOMPARE(ba.size(), 0);
- ba = help.fileData(QUrl("qthelp://trolltech.com.1_0_0.test/testFolder/test.html"));
+ ba = help.fileData(QUrl("qthelp://trolltech.com.1-0-0.test/testFolder/test.html"));
QTextStream s(ba, QIODevice::ReadOnly|QIODevice::Text);
QFile f(m_path + "/data/test.html");
if (!f.open(QIODevice::ReadOnly|QIODevice::Text))
@@ -396,7 +396,7 @@ void tst_QHelpEngineCore::linksForIdentifier()
QCOMPARE(map.contains("Test Manual"), true);
QCOMPARE(map.count(), 1);
QCOMPARE(map.value("Test Manual"),
- QUrl("qthelp://trolltech.com.1_0_0.test/testFolder/test.html#foo"));
+ QUrl("qthelp://trolltech.com.1-0-0.test/testFolder/test.html#foo"));
help.setCurrentFilter("Custom Filter 2");
map = help.linksForIdentifier("People::newton");
@@ -405,7 +405,7 @@ void tst_QHelpEngineCore::linksForIdentifier()
QCOMPARE(map.contains("Fancy"), true);
QCOMPARE(map.count(), 1);
QCOMPARE(map.value("Fancy"),
- QUrl("qthelp://trolltech.com.1_0_0.test/testFolder/fancy.html#foobar"));
+ QUrl("qthelp://trolltech.com.1-0-0.test/testFolder/fancy.html#foobar"));
}
void tst_QHelpEngineCore::customValue()
diff --git a/tests/auto/qhelpindexmodel/data/collection.qhc b/tests/auto/qhelpindexmodel/data/collection.qhc
index 6fb8abb..bd2f37c 100644
--- a/tests/auto/qhelpindexmodel/data/collection.qhc
+++ b/tests/auto/qhelpindexmodel/data/collection.qhc
Binary files differ
diff --git a/tests/auto/qhelpindexmodel/data/collection1.qhc b/tests/auto/qhelpindexmodel/data/collection1.qhc
index 45acf33..de310ea 100644
--- a/tests/auto/qhelpindexmodel/data/collection1.qhc
+++ b/tests/auto/qhelpindexmodel/data/collection1.qhc
Binary files differ
diff --git a/tests/auto/qhelpindexmodel/data/linguist-3.3.8.qch b/tests/auto/qhelpindexmodel/data/linguist-3.3.8.qch
index 0b53cd8..ed9a89c 100644
--- a/tests/auto/qhelpindexmodel/data/linguist-3.3.8.qch
+++ b/tests/auto/qhelpindexmodel/data/linguist-3.3.8.qch
Binary files differ
diff --git a/tests/auto/qhelpindexmodel/data/qmake-3.3.8.qch b/tests/auto/qhelpindexmodel/data/qmake-3.3.8.qch
index a3ca18a..0e95c14 100644
--- a/tests/auto/qhelpindexmodel/data/qmake-3.3.8.qch
+++ b/tests/auto/qhelpindexmodel/data/qmake-3.3.8.qch
Binary files differ
diff --git a/tests/auto/qhelpindexmodel/data/qmake-4.3.0.qch b/tests/auto/qhelpindexmodel/data/qmake-4.3.0.qch
index 8f76134..337d7a1 100644
--- a/tests/auto/qhelpindexmodel/data/qmake-4.3.0.qch
+++ b/tests/auto/qhelpindexmodel/data/qmake-4.3.0.qch
Binary files differ
diff --git a/tests/auto/qhelpindexmodel/data/test.qch b/tests/auto/qhelpindexmodel/data/test.qch
index 1d6c1a8..4ea9847 100644
--- a/tests/auto/qhelpindexmodel/data/test.qch
+++ b/tests/auto/qhelpindexmodel/data/test.qch
Binary files differ
diff --git a/tests/auto/qhelpindexmodel/tst_qhelpindexmodel.cpp b/tests/auto/qhelpindexmodel/tst_qhelpindexmodel.cpp
index 9482def..3adb894 100644
--- a/tests/auto/qhelpindexmodel/tst_qhelpindexmodel.cpp
+++ b/tests/auto/qhelpindexmodel/tst_qhelpindexmodel.cpp
@@ -185,11 +185,11 @@ void tst_QHelpIndexModel::linksForIndex()
QCOMPARE(map.count(), 2);
QCOMPARE(map.contains("Test Manual"), true);
QCOMPARE(map.value("Test Manual"),
- QUrl("qthelp://trolltech.com.1_0_0.test/testFolder/test.html#foo"));
+ QUrl("qthelp://trolltech.com.1-0-0.test/testFolder/test.html#foo"));
QCOMPARE(map.contains("Fancy"), true);
QCOMPARE(map.value("Fancy"),
- QUrl("qthelp://trolltech.com.1_0_0.test/testFolder/fancy.html#foo"));
+ QUrl("qthelp://trolltech.com.1-0-0.test/testFolder/fancy.html#foo"));
map = m->linksForKeyword("foobar");
QCOMPARE(map.count(), 1);
@@ -208,7 +208,7 @@ void tst_QHelpIndexModel::linksForIndex()
QCOMPARE(map.count(), 1);
QCOMPARE(map.contains("Test Manual"), true);
QCOMPARE(map.value("Test Manual"),
- QUrl("qthelp://trolltech.com.1_0_0.test/testFolder/test.html#foo"));
+ QUrl("qthelp://trolltech.com.1-0-0.test/testFolder/test.html#foo"));
}
QTEST_MAIN(tst_QHelpIndexModel)
diff --git a/tests/auto/qitemdelegate/tst_qitemdelegate.cpp b/tests/auto/qitemdelegate/tst_qitemdelegate.cpp
index 65dd86f..6714de3 100644
--- a/tests/auto/qitemdelegate/tst_qitemdelegate.cpp
+++ b/tests/auto/qitemdelegate/tst_qitemdelegate.cpp
@@ -61,6 +61,7 @@
#include <QAbstractItemDelegate>
#include <QTextEdit>
#include <QPlainTextEdit>
+#include <QDialog>
Q_DECLARE_METATYPE(QAbstractItemDelegate::EndEditHint)
@@ -230,6 +231,8 @@ private slots:
void editorEvent();
void enterKey_data();
void enterKey();
+
+ void task257859_finalizeEdit();
};
@@ -1124,6 +1127,36 @@ void tst_QItemDelegate::enterKey()
QCOMPARE(editor && editor->hasFocus(), expectedFocus);
}
+void tst_QItemDelegate::task257859_finalizeEdit()
+{
+ QStandardItemModel model;
+ model.appendRow(new QStandardItem());
+
+ QListView view;
+ view.setModel(&model);
+ view.show();
+ QApplication::setActiveWindow(&view);
+ view.setFocus();
+ QTest::qWait(30);
+
+ QModelIndex index = model.index(0, 0);
+ view.edit(index);
+ QTest::qWait(30);
+
+ QList<QWidget*> lineEditors = qFindChildren<QWidget *>(view.viewport());
+ QCOMPARE(lineEditors.count(), 1);
+
+ QPointer<QWidget> editor = lineEditors.at(0);
+ QCOMPARE(editor->hasFocus(), true);
+
+ QDialog dialog;
+ QTimer::singleShot(100, &dialog, SLOT(close()));
+ dialog.exec();
+
+ QTest::qWait(10);
+
+ QVERIFY(!editor);
+}
// ### _not_ covered:
diff --git a/tests/auto/qitemselectionmodel/tst_qitemselectionmodel.cpp b/tests/auto/qitemselectionmodel/tst_qitemselectionmodel.cpp
index ae64e51..0541b46 100644
--- a/tests/auto/qitemselectionmodel/tst_qitemselectionmodel.cpp
+++ b/tests/auto/qitemselectionmodel/tst_qitemselectionmodel.cpp
@@ -1547,7 +1547,7 @@ void tst_QItemSelectionModel::resetModel()
model.reset();
QVERIFY(view.selectionModel()->selection().isEmpty());
- QVERIFY(view.selectionModel()->hasSelection());
+ QVERIFY(view.selectionModel()->hasSelection() == false);
view.selectionModel()->select(QItemSelection(model.index(0, 0), model.index(5, 5)), QItemSelectionModel::Select);
diff --git a/tests/auto/qlocale/tst_qlocale.cpp b/tests/auto/qlocale/tst_qlocale.cpp
index 9ef7f1d..9a5c549 100644
--- a/tests/auto/qlocale/tst_qlocale.cpp
+++ b/tests/auto/qlocale/tst_qlocale.cpp
@@ -327,9 +327,8 @@ void tst_QLocale::emptyCtor()
{ \
/* Test constructor without arguments. Needs separate process */ \
/* because of caching of the system locale. */ \
- QString oldEnv = QString::fromLocal8Bit(qgetenv("LANG")); \
- qputenv("LANG", QString(req_lc).toLocal8Bit()); \
QProcess process; \
+ process.setEnvironment(QStringList(env) << QString("LANG=%1").arg(req_lc)); \
process.start("syslocaleapp/syslocaleapp"); \
process.waitForReadyRead(); \
QString ret = QString(process.readAll()); \
@@ -337,18 +336,23 @@ void tst_QLocale::emptyCtor()
QVERIFY2(!ret.isEmpty(), "Cannot launch external process"); \
QVERIFY2(QString(exp_str) == ret, QString("Expected: " + QString(exp_str) + ", got: " \
+ ret + ". Requested: " + QString(req_lc)).toLatin1().constData()); \
- qputenv("LANG", oldEnv.toLocal8Bit()); \
+ }
+
+ // Get an environment free of any locale-related variables
+ QStringList env;
+ foreach (QString const& entry, QProcess::systemEnvironment()) {
+ if (entry.startsWith("LANG=") || entry.startsWith("LC_"))
+ continue;
+ env << entry;
}
// Get default locale.
- QString old = QString::fromLocal8Bit(qgetenv("LANG"));
- qputenv("LANG", "");
QProcess p;
+ p.setEnvironment(env);
p.start("syslocaleapp/syslocaleapp");
p.waitForReadyRead();
QString defaultLoc = QString(p.readAll());
p.waitForFinished();
- qputenv("LANG", old.toLocal8Bit());
TEST_CTOR("C", "C")
TEST_CTOR("bla", "C")
diff --git a/tests/auto/qmake/testdata/simple_app_build/README b/tests/auto/qmake/testdata/simple_app_build/README
new file mode 100644
index 0000000..81dc596
--- /dev/null
+++ b/tests/auto/qmake/testdata/simple_app_build/README
@@ -0,0 +1 @@
+Placeholder file to ensure this directory exists
diff --git a/tests/auto/qmenu/tst_qmenu.cpp b/tests/auto/qmenu/tst_qmenu.cpp
index 1d19ffa..6ba6466 100644
--- a/tests/auto/qmenu/tst_qmenu.cpp
+++ b/tests/auto/qmenu/tst_qmenu.cpp
@@ -95,6 +95,8 @@ private slots:
void task250673_activeMultiColumnSubMenuPosition();
void task256918_setFont();
void menuSizeHint();
+ void task258920_mouseBorder();
+ void setFixedWidth();
protected slots:
void onActivated(QAction*);
void onHighlighted(QAction*);
@@ -763,5 +765,51 @@ void tst_QMenu::menuSizeHint()
QCOMPARE(resSize, menu.sizeHint());
}
+class Menu258920 : public QMenu
+{
+ Q_OBJECT
+public slots:
+ void paintEvent(QPaintEvent *e)
+ {
+ QMenu::paintEvent(e);
+ painted = true;
+ }
+
+public:
+ bool painted;
+};
+
+void tst_QMenu::task258920_mouseBorder()
+{
+ Menu258920 menu;
+ QAction *action = menu.addAction("test");
+
+ menu.popup(QPoint());
+ QTest::qWait(100);
+ QRect actionRect = menu.actionGeometry(action);
+ QTest::mouseMove(&menu, actionRect.center());
+ QTest::qWait(30);
+ QTest::mouseMove(&menu, actionRect.center() + QPoint(10, 0));
+ QTest::qWait(30);
+ QCOMPARE(action, menu.activeAction());
+ menu.painted = false;
+ QTest::mouseMove(&menu, QPoint(actionRect.center().x(), actionRect.bottom() + 1));
+ QTest::qWait(30);
+ QCOMPARE(static_cast<QAction*>(0), menu.activeAction());
+ QVERIFY(menu.painted);
+}
+
+void tst_QMenu::setFixedWidth()
+{
+ QMenu menu;
+ menu.addAction("action");
+ menu.setFixedWidth(300);
+ //the sizehint should reflect the minimumwidth because the action will try to
+ //get as much space as possible
+ QCOMPARE(menu.sizeHint().width(), menu.minimumWidth());
+}
+
+
+
QTEST_MAIN(tst_QMenu)
#include "tst_qmenu.moc"
diff --git a/tests/auto/qmetaobject/tst_qmetaobject.cpp b/tests/auto/qmetaobject/tst_qmetaobject.cpp
index dea0ffb..ac2858c 100644
--- a/tests/auto/qmetaobject/tst_qmetaobject.cpp
+++ b/tests/auto/qmetaobject/tst_qmetaobject.cpp
@@ -108,6 +108,8 @@ class tst_QMetaObject : public QObject
Q_PROPERTY(int value6 READ value6 NOTIFY value6Changed)
Q_PROPERTY(MyStruct value7 READ value7 WRITE setVal7 NOTIFY value7Changed)
Q_PROPERTY(int value8 READ value8 NOTIFY value8Changed)
+ Q_PROPERTY(int value9 READ value9 CONSTANT)
+ Q_PROPERTY(int value10 READ value10 FINAL)
public:
enum EnumType { EnumType1 };
@@ -137,6 +139,10 @@ public:
int value8() const { return 1; }
+ int value9() const { return 1; }
+
+ int value10() const { return 1; }
+
QList<QVariant> value4;
QVariantList value5;
@@ -159,6 +165,8 @@ private slots:
void customPropertyType();
void checkScope();
void propertyNotify();
+ void propertyConstant();
+ void propertyFinal();
void stdSet();
void classInfo();
@@ -785,6 +793,32 @@ void tst_QMetaObject::propertyNotify()
QCOMPARE(signal.signature(), (const char *)0);
}
+void tst_QMetaObject::propertyConstant()
+{
+ const QMetaObject *mo = metaObject();
+
+ QMetaProperty prop = mo->property(mo->indexOfProperty("value8"));
+ QVERIFY(prop.isValid());
+ QVERIFY(!prop.isConstant());
+
+ prop = mo->property(mo->indexOfProperty("value9"));
+ QVERIFY(prop.isValid());
+ QVERIFY(prop.isConstant());
+}
+
+void tst_QMetaObject::propertyFinal()
+{
+ const QMetaObject *mo = metaObject();
+
+ QMetaProperty prop = mo->property(mo->indexOfProperty("value10"));
+ QVERIFY(prop.isValid());
+ QVERIFY(prop.isFinal());
+
+ prop = mo->property(mo->indexOfProperty("value9"));
+ QVERIFY(prop.isValid());
+ QVERIFY(!prop.isFinal());
+}
+
class ClassInfoTestObjectA : public QObject
{
Q_OBJECT
diff --git a/tests/auto/qnetworkreply/tst_qnetworkreply.cpp b/tests/auto/qnetworkreply/tst_qnetworkreply.cpp
index 03b1474..cfd3dd0 100644
--- a/tests/auto/qnetworkreply/tst_qnetworkreply.cpp
+++ b/tests/auto/qnetworkreply/tst_qnetworkreply.cpp
@@ -223,8 +223,10 @@ private Q_SLOTS:
void rateControl();
void downloadPerformance();
void uploadPerformance();
- void httpUploadPerformance();
void performanceControlRate();
+ void httpUploadPerformance();
+ void httpDownloadPerformance_data();
+ void httpDownloadPerformance();
void downloadProgress_data();
void downloadProgress();
@@ -248,8 +250,6 @@ private Q_SLOTS:
void authorizationError();
void httpConnectionCount();
- void httpDownloadPerformance_data();
- void httpDownloadPerformance();
#ifndef QT_NO_OPENSSL
void ignoreSslErrorsList_data();
@@ -513,10 +513,10 @@ public:
QTcpSocket *active = new QTcpSocket(this);
active->connectToHost("127.0.0.1", server.serverPort());
- if (!active->waitForConnected(10))
+ if (!active->waitForConnected(100))
return false;
- if (!server.waitForNewConnection(10))
+ if (!server.waitForNewConnection(100))
return false;
QTcpSocket *passive = server.nextPendingConnection();
passive->setParent(this);
@@ -836,6 +836,92 @@ protected:
}
};
+class HttpDownloadPerformanceClient : QObject {
+ Q_OBJECT;
+ QIODevice *device;
+ public:
+ HttpDownloadPerformanceClient (QIODevice *dev) : device(dev){
+ connect(dev, SIGNAL(readyRead()), this, SLOT(readyReadSlot()));
+ }
+
+ public slots:
+ void readyReadSlot() {
+ device->readAll();
+ }
+
+};
+
+class HttpDownloadPerformanceServer : QObject {
+ Q_OBJECT;
+ qint64 dataSize;
+ qint64 dataSent;
+ QTcpServer server;
+ QTcpSocket *client;
+ bool serverSendsContentLength;
+ bool chunkedEncoding;
+
+public:
+ HttpDownloadPerformanceServer (qint64 ds, bool sscl, bool ce) : dataSize(ds), dataSent(0),
+ client(0), serverSendsContentLength(sscl), chunkedEncoding(ce) {
+ server.listen();
+ connect(&server, SIGNAL(newConnection()), this, SLOT(newConnectionSlot()));
+ }
+
+ int serverPort() {
+ return server.serverPort();
+ }
+
+public slots:
+
+ void newConnectionSlot() {
+ client = server.nextPendingConnection();
+ client->setParent(this);
+ connect(client, SIGNAL(readyRead()), this, SLOT(readyReadSlot()));
+ connect(client, SIGNAL(bytesWritten(qint64)), this, SLOT(bytesWrittenSlot(qint64)));
+ }
+
+ void readyReadSlot() {
+ client->readAll();
+ client->write("HTTP/1.0 200 OK\n");
+ if (serverSendsContentLength)
+ client->write(QString("Content-Length: " + QString::number(dataSize) + "\n").toAscii());
+ if (chunkedEncoding)
+ client->write(QString("Transfer-Encoding: chunked\n").toAscii());
+ client->write("Connection: close\n\n");
+ }
+
+ void bytesWrittenSlot(qint64 amount) {
+ Q_UNUSED(amount);
+ if (dataSent == dataSize && client) {
+ // close eventually
+
+ // chunked encoding: we have to send a last "empty" chunk
+ if (chunkedEncoding)
+ client->write(QString("0\r\n\r\n").toAscii());
+
+ client->disconnectFromHost();
+ server.close();
+ client = 0;
+ return;
+ }
+
+ // send data
+ if (client && client->bytesToWrite() < 100*1024 && dataSent < dataSize) {
+ qint64 amount = qMin(qint64(16*1024), dataSize - dataSent);
+ QByteArray data(amount, '@');
+
+ if (chunkedEncoding) {
+ client->write(QString(QString("%1").arg(amount,0,16).toUpper() + "\r\n").toAscii());
+ client->write(data.constData(), amount);
+ client->write(QString("\r\n").toAscii());
+ } else {
+ client->write(data.constData(), amount);
+ }
+
+ dataSent += amount;
+ }
+ }
+};
tst_QNetworkReply::tst_QNetworkReply()
@@ -2642,8 +2728,6 @@ void tst_QNetworkReply::ioPutToFileFromProcess()
QCOMPARE(file.size(), qint64(data.size()));
QByteArray contents = file.readAll();
QCOMPARE(contents, data);
-
- delete reply;
#endif
}
@@ -3183,7 +3267,7 @@ void tst_QNetworkReply::uploadPerformance()
void tst_QNetworkReply::httpUploadPerformance()
{
- enum {UploadSize = 1000*1024*1024}; // 1000 MB
+ enum {UploadSize = 128*1024*1024}; // 128 MB
ThreadedDataReaderHttpServer reader;
FixedSizeDataGenerator generator(UploadSize);
@@ -3205,7 +3289,7 @@ void tst_QNetworkReply::httpUploadPerformance()
<< ((UploadSize/1024.0)/(elapsed/1000.0)) << " kB/sec";
reader.exit();
- reader.wait(3000);
+ reader.wait();
}
@@ -3233,6 +3317,41 @@ void tst_QNetworkReply::performanceControlRate()
<< elapsedTime << "ms";
}
+void tst_QNetworkReply::httpDownloadPerformance_data()
+{
+ QTest::addColumn<bool>("serverSendsContentLength");
+ QTest::addColumn<bool>("chunkedEncoding");
+
+ QTest::newRow("Server sends no Content-Length") << false << false;
+ QTest::newRow("Server sends Content-Length") << true << false;
+ QTest::newRow("Server uses chunked encoding") << false << true;
+
+}
+
+void tst_QNetworkReply::httpDownloadPerformance()
+{
+ QFETCH(bool, serverSendsContentLength);
+ QFETCH(bool, chunkedEncoding);
+
+ enum {UploadSize = 128*1024*1024}; // 128 MB
+ HttpDownloadPerformanceServer server(UploadSize, serverSendsContentLength, chunkedEncoding);
+
+ QNetworkRequest request(QUrl("http://127.0.0.1:" + QString::number(server.serverPort()) + "/?bare=1"));
+ QNetworkReplyPtr reply = manager.get(request);
+
+ connect(reply, SIGNAL(finished()), &QTestEventLoop::instance(), SLOT(exitLoop()), Qt::QueuedConnection);
+ HttpDownloadPerformanceClient client(reply);
+
+ QTime time;
+ time.start();
+ QTestEventLoop::instance().enterLoop(40);
+ QVERIFY(!QTestEventLoop::instance().timeout());
+
+ qint64 elapsed = time.elapsed();
+ qDebug() << "tst_QNetworkReply::httpDownloadPerformance" << elapsed << "msec, "
+ << ((UploadSize/1024.0)/(elapsed/1000.0)) << " kB/sec";
+}
+
void tst_QNetworkReply::downloadProgress_data()
{
QTest::addColumn<int>("loopCount");
@@ -3720,130 +3839,6 @@ void tst_QNetworkReply::httpConnectionCount()
QCOMPARE(pendingConnectionCount, 6);
}
-class HttpDownloadPerformanceClient : QObject {
- Q_OBJECT;
- QIODevice *device;
- public:
- HttpDownloadPerformanceClient (QIODevice *dev) : device(dev){
- connect(dev, SIGNAL(readyRead()), this, SLOT(readyReadSlot()));
- }
-
- public slots:
- void readyReadSlot() {
- device->readAll();
- }
-
-};
-
-class HttpDownloadPerformanceServer : QObject {
- Q_OBJECT;
- qint64 dataSize;
- qint64 dataSent;
- QTcpServer server;
- QTcpSocket *client;
- bool serverSendsContentLength;
- bool chunkedEncoding;
-
-public:
- HttpDownloadPerformanceServer (qint64 ds, bool sscl, bool ce) : dataSize(ds), dataSent(0),
- client(0), serverSendsContentLength(sscl), chunkedEncoding(ce) {
- server.listen();
- connect(&server, SIGNAL(newConnection()), this, SLOT(newConnectionSlot()));
- }
-
- int serverPort() {
- return server.serverPort();
- }
-
-public slots:
-
- void newConnectionSlot() {
- client = server.nextPendingConnection();
- client->setParent(this);
- connect(client, SIGNAL(readyRead()), this, SLOT(readyReadSlot()));
- connect(client, SIGNAL(bytesWritten(qint64)), this, SLOT(bytesWrittenSlot(qint64)));
- }
-
- void readyReadSlot() {
- client->readAll();
- client->write("HTTP/1.0 200 OK\n");
- if (serverSendsContentLength)
- client->write(QString("Content-Length: " + QString::number(dataSize) + "\n").toAscii());
- if (chunkedEncoding)
- client->write(QString("Transfer-Encoding: chunked\n").toAscii());
- client->write("Connection: close\n\n");
- }
-
- void bytesWrittenSlot(qint64 amount) {
- Q_UNUSED(amount);
- if (dataSent == dataSize && client) {
- // close eventually
-
- // chunked encoding: we have to send a last "empty" chunk
- if (chunkedEncoding)
- client->write(QString("0\r\n\r\n").toAscii());
-
- client->disconnectFromHost();
- server.close();
- client = 0;
- return;
- }
-
- // send data
- if (client && client->bytesToWrite() < 100*1024 && dataSent < dataSize) {
- qint64 amount = qMin(qint64(16*1024), dataSize - dataSent);
- QByteArray data(amount, '@');
-
- if (chunkedEncoding) {
- client->write(QString(QString("%1").arg(amount,0,16).toUpper() + "\r\n").toAscii());
- client->write(data.constData(), amount);
- client->write(QString("\r\n").toAscii());
- } else {
- client->write(data.constData(), amount);
- }
-
- dataSent += amount;
- }
- }
-};
-
-void tst_QNetworkReply::httpDownloadPerformance_data()
-{
- QTest::addColumn<bool>("serverSendsContentLength");
- QTest::addColumn<bool>("chunkedEncoding");
-
- QTest::newRow("Server sends no Content-Length") << false << false;
- QTest::newRow("Server sends Content-Length") << true << false;
- QTest::newRow("Server uses chunked encoding") << false << true;
-
-}
-
-void tst_QNetworkReply::httpDownloadPerformance()
-{
- QFETCH(bool, serverSendsContentLength);
- QFETCH(bool, chunkedEncoding);
-
- enum {UploadSize = 1000*1024*1024}; // 1000 MB
- HttpDownloadPerformanceServer server(UploadSize, serverSendsContentLength, chunkedEncoding);
-
- QNetworkRequest request(QUrl("http://127.0.0.1:" + QString::number(server.serverPort()) + "/?bare=1"));
- QNetworkReply* reply = manager.get(request);
-
- connect(reply, SIGNAL(finished()), &QTestEventLoop::instance(), SLOT(exitLoop()), Qt::QueuedConnection);
- HttpDownloadPerformanceClient client(reply);
-
- QTime time;
- time.start();
- QTestEventLoop::instance().enterLoop(40);
- QVERIFY(!QTestEventLoop::instance().timeout());
-
- qint64 elapsed = time.elapsed();
- qDebug() << "tst_QNetworkReply::httpDownloadPerformance" << elapsed << "msec, "
- << ((UploadSize/1024.0)/(elapsed/1000.0)) << " kB/sec";
-
- delete reply;
-}
-
#ifndef QT_NO_OPENSSL
void tst_QNetworkReply::ignoreSslErrorsList_data()
{
@@ -3872,7 +3867,7 @@ void tst_QNetworkReply::ignoreSslErrorsList()
{
QFETCH(QString, url);
QNetworkRequest request(url);
- QNetworkReply *reply = manager.get(request);
+ QNetworkReplyPtr reply = manager.get(request);
QFETCH(QList<QSslError>, expectedSslErrors);
reply->ignoreSslErrors(expectedSslErrors);
@@ -3901,7 +3896,7 @@ void tst_QNetworkReply::ignoreSslErrorsListWithSlot()
{
QFETCH(QString, url);
QNetworkRequest request(url);
- QNetworkReply *reply = manager.get(request);
+ QNetworkReplyPtr reply = manager.get(request);
QFETCH(QList<QSslError>, expectedSslErrors);
// store the errors to ignore them later in the slot connected below
diff --git a/tests/auto/qobject/tst_qobject.cpp b/tests/auto/qobject/tst_qobject.cpp
index 4f25af6..3df83d7 100644
--- a/tests/auto/qobject/tst_qobject.cpp
+++ b/tests/auto/qobject/tst_qobject.cpp
@@ -118,6 +118,7 @@ private slots:
void connectToSender();
void qobjectConstCast();
void uniqConnection();
+ void interfaceIid();
protected:
};
@@ -2887,5 +2888,15 @@ void tst_QObject::uniqConnection()
delete r2;
}
+void tst_QObject::interfaceIid()
+{
+ QCOMPARE(QByteArray(qobject_interface_iid<Foo::Bleh *>()),
+ QByteArray(Bleh_iid));
+ QCOMPARE(QByteArray(qobject_interface_iid<Foo::Bar *>()),
+ QByteArray("com.qtest.foobar"));
+ QCOMPARE(QByteArray(qobject_interface_iid<FooObject *>()),
+ QByteArray());
+}
+
QTEST_MAIN(tst_QObject)
#include "tst_qobject.moc"
diff --git a/tests/auto/qparallelanimationgroup/tst_qparallelanimationgroup.cpp b/tests/auto/qparallelanimationgroup/tst_qparallelanimationgroup.cpp
index d7d6b88..16c58b0 100644
--- a/tests/auto/qparallelanimationgroup/tst_qparallelanimationgroup.cpp
+++ b/tests/auto/qparallelanimationgroup/tst_qparallelanimationgroup.cpp
@@ -74,6 +74,7 @@ private slots:
void loopCount_data();
void loopCount();
void autoAdd();
+ void pauseResume();
};
tst_QParallelAnimationGroup::tst_QParallelAnimationGroup()
@@ -828,5 +829,37 @@ void tst_QParallelAnimationGroup::autoAdd()
QCOMPARE(group.duration(), 0);
}
+void tst_QParallelAnimationGroup::pauseResume()
+{
+ QParallelAnimationGroup group;
+ TestAnimation2 *anim = new TestAnimation2(250, &group); // 0, duration = 250;
+ QSignalSpy spy(anim, SIGNAL(stateChanged(QAbstractAnimation::State, QAbstractAnimation::State)));
+ QCOMPARE(group.duration(), 250);
+ group.start();
+ QTest::qWait(100);
+ QCOMPARE(group.state(), QAnimationGroup::Running);
+ QCOMPARE(anim->state(), QAnimationGroup::Running);
+ QCOMPARE(spy.count(), 1);
+ spy.clear();
+ const int currentTime = group.currentTime();
+ QCOMPARE(anim->currentTime(), currentTime);
+
+ group.pause();
+ QCOMPARE(group.state(), QAnimationGroup::Paused);
+ QCOMPARE(group.currentTime(), currentTime);
+ QCOMPARE(anim->state(), QAnimationGroup::Paused);
+ QCOMPARE(anim->currentTime(), currentTime);
+ QCOMPARE(spy.count(), 1);
+ spy.clear();
+
+ group.resume();
+ QCOMPARE(group.state(), QAnimationGroup::Running);
+ QCOMPARE(group.currentTime(), currentTime);
+ QCOMPARE(anim->state(), QAnimationGroup::Running);
+ QCOMPARE(anim->currentTime(), currentTime);
+ QCOMPARE(spy.count(), 1);
+}
+
+
QTEST_MAIN(tst_QParallelAnimationGroup)
#include "tst_qparallelanimationgroup.moc"
diff --git a/tests/auto/qplaintextedit/tst_qplaintextedit.cpp b/tests/auto/qplaintextedit/tst_qplaintextedit.cpp
index 40ad539..e8350e3 100644
--- a/tests/auto/qplaintextedit/tst_qplaintextedit.cpp
+++ b/tests/auto/qplaintextedit/tst_qplaintextedit.cpp
@@ -856,7 +856,12 @@ void tst_QPlainTextEdit::lineWrapModes()
ed->setLineWrapMode(QPlainTextEdit::NoWrap);
QCOMPARE(lineCount(), 1);
ed->setLineWrapMode(QPlainTextEdit::WidgetWidth);
- ed->resize(1, 1000);
+
+ // QPlainTextEdit does lazy line layout on resize, only for the visible blocks.
+ // We thus need to make it wide enough to show something visible.
+ int minimumWidth = 2 * ed->document()->documentMargin();
+ minimumWidth += ed->fontMetrics().width(QLatin1Char('a'));
+ ed->resize(minimumWidth, 1000);
QCOMPARE(lineCount(), 26);
ed->setParent(0);
delete window;
diff --git a/tests/auto/qscriptcontext/tst_qscriptcontext.cpp b/tests/auto/qscriptcontext/tst_qscriptcontext.cpp
index 87db0ad..c9a553a 100644
--- a/tests/auto/qscriptcontext/tst_qscriptcontext.cpp
+++ b/tests/auto/qscriptcontext/tst_qscriptcontext.cpp
@@ -72,6 +72,7 @@ private slots:
void scopeChain();
void pushAndPopScope();
void getSetActivationObject();
+ void inheritActivationAndThisObject();
void toString();
void calledAsConstructor();
void argumentsObjectInNative();
@@ -731,6 +732,35 @@ void tst_QScriptContext::getSetActivationObject()
}
}
+static QScriptValue myEval(QScriptContext *ctx, QScriptEngine *eng)
+{
+ QString code = ctx->argument(0).toString();
+ ctx->setActivationObject(ctx->parentContext()->activationObject());
+ ctx->setThisObject(ctx->parentContext()->thisObject());
+ return eng->evaluate(code);
+}
+
+void tst_QScriptContext::inheritActivationAndThisObject()
+{
+ QScriptEngine eng;
+ eng.globalObject().setProperty("myEval", eng.newFunction(myEval));
+ {
+ QScriptValue ret = eng.evaluate("var a = 123; myEval('a')");
+ QVERIFY(ret.isNumber());
+ QCOMPARE(ret.toInt32(), 123);
+ }
+ {
+ QScriptValue ret = eng.evaluate("(function() { return myEval('this'); }).call(Number)");
+ QVERIFY(ret.isFunction());
+ QVERIFY(ret.equals(eng.globalObject().property("Number")));
+ }
+ {
+ QScriptValue ret = eng.evaluate("(function(a) { return myEval('a'); })(123)");
+ QVERIFY(ret.isNumber());
+ QCOMPARE(ret.toInt32(), 123);
+ }
+}
+
static QScriptValue parentContextToString(QScriptContext *ctx, QScriptEngine *)
{
return ctx->parentContext()->toString();
diff --git a/tests/auto/qscriptengine/tst_qscriptengine.cpp b/tests/auto/qscriptengine/tst_qscriptengine.cpp
index 06be924..25e84dc 100644
--- a/tests/auto/qscriptengine/tst_qscriptengine.cpp
+++ b/tests/auto/qscriptengine/tst_qscriptengine.cpp
@@ -914,6 +914,35 @@ void tst_QScriptEngine::getSetGlobalObject()
QVERIFY(eng.globalObject().strictlyEquals(obj));
QVERIFY(eng.currentContext()->thisObject().strictlyEquals(obj));
QVERIFY(eng.currentContext()->activationObject().strictlyEquals(obj));
+
+ QVERIFY(!obj.property("foo").isValid());
+ eng.evaluate("var foo = 123");
+ {
+ QScriptValue ret = obj.property("foo");
+ QVERIFY(ret.isNumber());
+ QCOMPARE(ret.toInt32(), 123);
+ }
+
+ QVERIFY(!obj.property("bar").isValid());
+ eng.evaluate("bar = 456");
+ {
+ QScriptValue ret = obj.property("bar");
+ QVERIFY(ret.isNumber());
+ QCOMPARE(ret.toInt32(), 456);
+ }
+
+ QVERIFY(!obj.property("baz").isValid());
+ eng.evaluate("this['baz'] = 789");
+ {
+ QScriptValue ret = obj.property("baz");
+ QVERIFY(ret.isNumber());
+ QCOMPARE(ret.toInt32(), 789);
+ }
+
+ {
+ QScriptValue ret = eng.evaluate("(function() { return this; })()");
+ QVERIFY(ret.strictlyEquals(obj));
+ }
}
void tst_QScriptEngine::globalObjectProperties()
diff --git a/tests/auto/qsequentialanimationgroup/tst_qsequentialanimationgroup.cpp b/tests/auto/qsequentialanimationgroup/tst_qsequentialanimationgroup.cpp
index 97ff04b..744ba52 100644
--- a/tests/auto/qsequentialanimationgroup/tst_qsequentialanimationgroup.cpp
+++ b/tests/auto/qsequentialanimationgroup/tst_qsequentialanimationgroup.cpp
@@ -88,6 +88,7 @@ private slots:
void currentAnimationWithZeroDuration();
void insertAnimation();
void clearAnimations();
+ void pauseResume();
};
tst_QSequentialAnimationGroup::tst_QSequentialAnimationGroup()
@@ -1644,5 +1645,40 @@ void tst_QSequentialAnimationGroup::clearAnimations()
QCOMPARE(group.state(), QAbstractAnimation::Running);
}
+void tst_QSequentialAnimationGroup::pauseResume()
+{
+ QObject dummy;
+ dummy.setProperty("foo", 0);
+ QParallelAnimationGroup group;
+ QPropertyAnimation *anim = new QPropertyAnimation(&dummy, "foo", &group);
+ anim->setDuration(250);
+ anim->setEndValue(250);
+ QSignalSpy spy(anim, SIGNAL(stateChanged(QAbstractAnimation::State, QAbstractAnimation::State)));
+ QCOMPARE(group.duration(), 250);
+ group.start();
+ QTest::qWait(100);
+ QCOMPARE(group.state(), QAnimationGroup::Running);
+ QCOMPARE(anim->state(), QAnimationGroup::Running);
+ QCOMPARE(spy.count(), 1);
+ spy.clear();
+ const int currentTime = group.currentTime();
+ QCOMPARE(anim->currentTime(), currentTime);
+
+ group.pause();
+ QCOMPARE(group.state(), QAnimationGroup::Paused);
+ QCOMPARE(group.currentTime(), currentTime);
+ QCOMPARE(anim->state(), QAnimationGroup::Paused);
+ QCOMPARE(anim->currentTime(), currentTime);
+ QCOMPARE(spy.count(), 1);
+ spy.clear();
+
+ group.resume();
+ QCOMPARE(group.state(), QAnimationGroup::Running);
+ QCOMPARE(group.currentTime(), currentTime);
+ QCOMPARE(anim->state(), QAnimationGroup::Running);
+ QCOMPARE(anim->currentTime(), currentTime);
+ QCOMPARE(spy.count(), 1);
+}
+
QTEST_MAIN(tst_QSequentialAnimationGroup)
#include "tst_qsequentialanimationgroup.moc"
diff --git a/tests/auto/qsharedpointer/qsharedpointer.pro b/tests/auto/qsharedpointer/qsharedpointer.pro
index 90fde06..1759323 100644
--- a/tests/auto/qsharedpointer/qsharedpointer.pro
+++ b/tests/auto/qsharedpointer/qsharedpointer.pro
@@ -1,9 +1,14 @@
load(qttest_p4)
+
SOURCES += tst_qsharedpointer.cpp \
forwarddeclaration.cpp \
- forwarddeclared.cpp
+ forwarddeclared.cpp \
+ wrapper.cpp
+
+HEADERS += forwarddeclared.h \
+ wrapper.h
+
QT = core
DEFINES += SRCDIR=\\\"$$PWD/\\\"
-requires(contains(QT_CONFIG,private_tests))
+
include(externaltests.pri)
-HEADERS += forwarddeclared.h
diff --git a/tests/auto/qsharedpointer/tst_qsharedpointer.cpp b/tests/auto/qsharedpointer/tst_qsharedpointer.cpp
index ae5155e..5214edb 100644
--- a/tests/auto/qsharedpointer/tst_qsharedpointer.cpp
+++ b/tests/auto/qsharedpointer/tst_qsharedpointer.cpp
@@ -41,8 +41,19 @@
#define QT_SHAREDPOINTER_TRACK_POINTERS
#include "qsharedpointer.h"
-#include "externaltests.h"
#include <QtTest/QtTest>
+#include <QtCore/QThread>
+#include <QtCore/QVector>
+
+#include "externaltests.h"
+#include "wrapper.h"
+
+#include <stdlib.h>
+#include <time.h>
+
+namespace QtSharedPointer {
+ Q_CORE_EXPORT void internalSafetyCheckCleanCheck();
+}
class tst_QSharedPointer: public QObject
{
@@ -56,6 +67,9 @@ private slots:
void memoryManagement();
void downCast();
void upCast();
+ void qobjectWeakManagement();
+ void noSharedPointerFromWeakQObject();
+ void weakQObjectFromSharedPointer();
void objectCast();
void differentPointers();
void virtualBaseDifferentPointers();
@@ -68,10 +82,35 @@ private slots:
void constCorrectness();
void customDeleter();
void creating();
+ void creatingQObject();
+ void mixTrackingPointerCode();
+ void threadStressTest_data();
+ void threadStressTest();
void validConstructs();
void invalidConstructs_data();
void invalidConstructs();
+
+public slots:
+ void cleanup() { check(); }
+
+public:
+ inline void check()
+ {
+#ifdef QT_BUILD_INTERNAL
+ QtSharedPointer::internalSafetyCheckCleanCheck();
+#endif
+ }
+};
+
+template <typename Base>
+class RefCountHack: public Base
+{
+public:
+ using Base::d;
};
+template<typename Base> static inline
+QtSharedPointer::ExternalRefCountData *refCountData(const Base &b)
+{ return static_cast<const RefCountHack<Base> *>(&b)->d; }
class Data
{
@@ -156,8 +195,8 @@ void tst_QSharedPointer::basics()
QVERIFY(! (ptr == otherData));
QVERIFY(! (otherData == ptr));
}
- QVERIFY(!ptr.d || ptr.d->weakref == 1);
- QVERIFY(!ptr.d || ptr.d->strongref == 1);
+ QVERIFY(!refCountData(ptr) || refCountData(ptr)->weakref == 1);
+ QVERIFY(!refCountData(ptr) || refCountData(ptr)->strongref == 1);
{
// create another object:
@@ -169,8 +208,8 @@ void tst_QSharedPointer::basics()
// otherData is deleted here
}
- QVERIFY(!ptr.d || ptr.d->weakref == 1);
- QVERIFY(!ptr.d || ptr.d->strongref == 1);
+ QVERIFY(!refCountData(ptr) || refCountData(ptr)->weakref == 1);
+ QVERIFY(!refCountData(ptr) || refCountData(ptr)->strongref == 1);
{
// create a copy:
@@ -186,8 +225,8 @@ void tst_QSharedPointer::basics()
QCOMPARE(copy.data(), aData);
QVERIFY(copy == aData);
}
- QVERIFY(!ptr.d || ptr.d->weakref == 1);
- QVERIFY(!ptr.d || ptr.d->strongref == 1);
+ QVERIFY(!refCountData(ptr) || refCountData(ptr)->weakref == 1);
+ QVERIFY(!refCountData(ptr) || refCountData(ptr)->strongref == 1);
{
// create a weak reference:
@@ -218,8 +257,8 @@ void tst_QSharedPointer::basics()
QVERIFY(strong == ptr);
QCOMPARE(strong.data(), aData);
}
- QVERIFY(!ptr.d || ptr.d->weakref == 1);
- QVERIFY(!ptr.d || ptr.d->strongref == 1);
+ QVERIFY(!refCountData(ptr) || refCountData(ptr)->weakref == 1);
+ QVERIFY(!refCountData(ptr) || refCountData(ptr)->strongref == 1);
// aData is deleted here
}
@@ -435,15 +474,15 @@ void tst_QSharedPointer::upCast()
QVERIFY(baseptr == derivedptr);
QCOMPARE(static_cast<Data *>(derivedptr.data()), baseptr.data());
}
- QCOMPARE(int(baseptr.d->weakref), 1);
- QCOMPARE(int(baseptr.d->strongref), 1);
+ QCOMPARE(int(refCountData(baseptr)->weakref), 1);
+ QCOMPARE(int(refCountData(baseptr)->strongref), 1);
{
QWeakPointer<DerivedData> derivedptr = qWeakPointerCast<DerivedData>(baseptr);
QVERIFY(baseptr == derivedptr);
}
- QCOMPARE(int(baseptr.d->weakref), 1);
- QCOMPARE(int(baseptr.d->strongref), 1);
+ QCOMPARE(int(refCountData(baseptr)->weakref), 1);
+ QCOMPARE(int(refCountData(baseptr)->strongref), 1);
{
QWeakPointer<Data> weakptr = baseptr;
@@ -451,16 +490,16 @@ void tst_QSharedPointer::upCast()
QVERIFY(baseptr == derivedptr);
QCOMPARE(static_cast<Data *>(derivedptr.data()), baseptr.data());
}
- QCOMPARE(int(baseptr.d->weakref), 1);
- QCOMPARE(int(baseptr.d->strongref), 1);
+ QCOMPARE(int(refCountData(baseptr)->weakref), 1);
+ QCOMPARE(int(refCountData(baseptr)->strongref), 1);
{
QSharedPointer<DerivedData> derivedptr = baseptr.staticCast<DerivedData>();
QVERIFY(baseptr == derivedptr);
QCOMPARE(static_cast<Data *>(derivedptr.data()), baseptr.data());
}
- QCOMPARE(int(baseptr.d->weakref), 1);
- QCOMPARE(int(baseptr.d->strongref), 1);
+ QCOMPARE(int(refCountData(baseptr)->weakref), 1);
+ QCOMPARE(int(refCountData(baseptr)->strongref), 1);
}
class OtherObject: public QObject
@@ -468,6 +507,122 @@ class OtherObject: public QObject
Q_OBJECT
};
+void tst_QSharedPointer::qobjectWeakManagement()
+{
+ {
+ QObject *obj = new QObject;
+ QWeakPointer<QObject> weak(obj);
+ QVERIFY(!weak.isNull());
+ QVERIFY(weak.data() == obj);
+
+ // now delete
+ delete obj;
+ QVERIFY(weak.isNull());
+ }
+ check();
+
+ {
+ // same, bit with operator=
+ QObject *obj = new QObject;
+ QWeakPointer<QObject> weak;
+ weak = obj;
+ QVERIFY(!weak.isNull());
+ QVERIFY(weak.data() == obj);
+
+ // now delete
+ delete obj;
+ QVERIFY(weak.isNull());
+ }
+ check();
+
+ {
+ // delete triggered by parent
+ QObject *obj, *parent;
+ parent = new QObject;
+ obj = new QObject(parent);
+ QWeakPointer<QObject> weak(obj);
+
+ // now delete the parent
+ delete parent;
+ QVERIFY(weak.isNull());
+ }
+ check();
+
+ {
+ // same as above, but set the parent after QWeakPointer is created
+ QObject *obj, *parent;
+ obj = new QObject;
+ QWeakPointer<QObject> weak(obj);
+
+ parent = new QObject;
+ obj->setParent(parent);
+
+ // now delete the parent
+ delete parent;
+ QVERIFY(weak.isNull());
+ }
+ check();
+
+ {
+ // with two QWeakPointers
+ QObject *obj = new QObject;
+ QWeakPointer<QObject> weak(obj);
+
+ {
+ QWeakPointer<QObject> weak2(obj);
+ QVERIFY(!weak2.isNull());
+ QVERIFY(weak == weak2);
+ }
+ QVERIFY(!weak.isNull());
+
+ delete obj;
+ QVERIFY(weak.isNull());
+ }
+ check();
+
+ {
+ // same, but delete the pointer while two QWeakPointers exist
+ QObject *obj = new QObject;
+ QWeakPointer<QObject> weak(obj);
+
+ {
+ QWeakPointer<QObject> weak2(obj);
+ QVERIFY(!weak2.isNull());
+
+ delete obj;
+ QVERIFY(weak.isNull());
+ QVERIFY(weak2.isNull());
+ }
+ QVERIFY(weak.isNull());
+ }
+ check();
+}
+
+void tst_QSharedPointer::noSharedPointerFromWeakQObject()
+{
+ // you're not allowed to create a QSharedPointer from an unmanaged QObject
+ QObject obj;
+ QWeakPointer<QObject> weak(&obj);
+
+ QSharedPointer<QObject> strong = weak.toStrongRef();
+ QVERIFY(strong.isNull());
+
+ // is something went wrong, we'll probably crash here
+}
+
+void tst_QSharedPointer::weakQObjectFromSharedPointer()
+{
+ // this is the inverse of the above: you're allowed to create a QWeakPointer
+ // from a managed QObject
+ QSharedPointer<QObject> shared(new QObject);
+ QWeakPointer<QObject> weak = shared.data();
+ QVERIFY(!weak.isNull());
+
+ // delete:
+ shared.clear();
+ QVERIFY(weak.isNull());
+}
+
void tst_QSharedPointer::objectCast()
{
{
@@ -496,6 +651,7 @@ void tst_QSharedPointer::objectCast()
QVERIFY(ptr == data);
#endif
}
+ check();
{
const OtherObject *data = new OtherObject;
@@ -523,6 +679,7 @@ void tst_QSharedPointer::objectCast()
QVERIFY(ptr == data);
#endif
}
+ check();
{
OtherObject *data = new OtherObject;
@@ -564,6 +721,7 @@ void tst_QSharedPointer::objectCast()
QVERIFY(otherptr.isNull());
#endif
}
+ check();
}
void tst_QSharedPointer::differentPointers()
@@ -583,6 +741,7 @@ void tst_QSharedPointer::differentPointers()
QVERIFY(baseptr == aData);
QVERIFY(baseptr == aBase);
}
+ check();
{
DiffPtrDerivedData *aData = new DiffPtrDerivedData;
@@ -597,6 +756,7 @@ void tst_QSharedPointer::differentPointers()
QVERIFY(ptr == aBase);
QVERIFY(baseptr == aData);
}
+ check();
{
DiffPtrDerivedData *aData = new DiffPtrDerivedData;
@@ -613,6 +773,7 @@ void tst_QSharedPointer::differentPointers()
QVERIFY(baseptr == aData);
QVERIFY(baseptr == aBase);
}
+ check();
}
void tst_QSharedPointer::virtualBaseDifferentPointers()
@@ -632,6 +793,7 @@ void tst_QSharedPointer::virtualBaseDifferentPointers()
QVERIFY(baseptr == aData);
QVERIFY(baseptr == aBase);
}
+ check();
{
VirtualDerived *aData = new VirtualDerived;
@@ -648,6 +810,7 @@ void tst_QSharedPointer::virtualBaseDifferentPointers()
QVERIFY(baseptr == aData);
QVERIFY(baseptr == aBase);
}
+ check();
}
#ifndef QTEST_NO_RTTI
@@ -662,8 +825,8 @@ void tst_QSharedPointer::dynamicCast()
QCOMPARE(derivedptr.data(), aData);
QCOMPARE(static_cast<Data *>(derivedptr.data()), baseptr.data());
}
- QCOMPARE(int(baseptr.d->weakref), 1);
- QCOMPARE(int(baseptr.d->strongref), 1);
+ QCOMPARE(int(refCountData(baseptr)->weakref), 1);
+ QCOMPARE(int(refCountData(baseptr)->strongref), 1);
{
QWeakPointer<Data> weakptr = baseptr;
@@ -672,8 +835,8 @@ void tst_QSharedPointer::dynamicCast()
QCOMPARE(derivedptr.data(), aData);
QCOMPARE(static_cast<Data *>(derivedptr.data()), baseptr.data());
}
- QCOMPARE(int(baseptr.d->weakref), 1);
- QCOMPARE(int(baseptr.d->strongref), 1);
+ QCOMPARE(int(refCountData(baseptr)->weakref), 1);
+ QCOMPARE(int(refCountData(baseptr)->strongref), 1);
{
QSharedPointer<DerivedData> derivedptr = baseptr.dynamicCast<DerivedData>();
@@ -681,8 +844,8 @@ void tst_QSharedPointer::dynamicCast()
QCOMPARE(derivedptr.data(), aData);
QCOMPARE(static_cast<Data *>(derivedptr.data()), baseptr.data());
}
- QCOMPARE(int(baseptr.d->weakref), 1);
- QCOMPARE(int(baseptr.d->strongref), 1);
+ QCOMPARE(int(refCountData(baseptr)->weakref), 1);
+ QCOMPARE(int(refCountData(baseptr)->strongref), 1);
}
void tst_QSharedPointer::dynamicCastDifferentPointers()
@@ -697,8 +860,8 @@ void tst_QSharedPointer::dynamicCastDifferentPointers()
QCOMPARE(derivedptr.data(), aData);
QCOMPARE(static_cast<Data *>(derivedptr.data()), baseptr.data());
}
- QCOMPARE(int(baseptr.d->weakref), 1);
- QCOMPARE(int(baseptr.d->strongref), 1);
+ QCOMPARE(int(refCountData(baseptr)->weakref), 1);
+ QCOMPARE(int(refCountData(baseptr)->strongref), 1);
{
QWeakPointer<Data> weakptr = baseptr;
@@ -707,8 +870,8 @@ void tst_QSharedPointer::dynamicCastDifferentPointers()
QCOMPARE(derivedptr.data(), aData);
QCOMPARE(static_cast<Data *>(derivedptr.data()), baseptr.data());
}
- QCOMPARE(int(baseptr.d->weakref), 1);
- QCOMPARE(int(baseptr.d->strongref), 1);
+ QCOMPARE(int(refCountData(baseptr)->weakref), 1);
+ QCOMPARE(int(refCountData(baseptr)->strongref), 1);
{
QSharedPointer<DiffPtrDerivedData> derivedptr = baseptr.dynamicCast<DiffPtrDerivedData>();
@@ -716,8 +879,8 @@ void tst_QSharedPointer::dynamicCastDifferentPointers()
QCOMPARE(derivedptr.data(), aData);
QCOMPARE(static_cast<Data *>(derivedptr.data()), baseptr.data());
}
- QCOMPARE(int(baseptr.d->weakref), 1);
- QCOMPARE(int(baseptr.d->strongref), 1);
+ QCOMPARE(int(refCountData(baseptr)->weakref), 1);
+ QCOMPARE(int(refCountData(baseptr)->strongref), 1);
{
Stuffing *nakedptr = dynamic_cast<Stuffing *>(baseptr.data());
@@ -742,8 +905,8 @@ void tst_QSharedPointer::dynamicCastVirtualBase()
QCOMPARE(derivedptr.data(), aData);
QCOMPARE(static_cast<Data *>(derivedptr.data()), baseptr.data());
}
- QCOMPARE(int(baseptr.d->weakref), 1);
- QCOMPARE(int(baseptr.d->strongref), 1);
+ QCOMPARE(int(refCountData(baseptr)->weakref), 1);
+ QCOMPARE(int(refCountData(baseptr)->strongref), 1);
{
QWeakPointer<Data> weakptr = baseptr;
@@ -752,8 +915,8 @@ void tst_QSharedPointer::dynamicCastVirtualBase()
QCOMPARE(derivedptr.data(), aData);
QCOMPARE(static_cast<Data *>(derivedptr.data()), baseptr.data());
}
- QCOMPARE(int(baseptr.d->weakref), 1);
- QCOMPARE(int(baseptr.d->strongref), 1);
+ QCOMPARE(int(refCountData(baseptr)->weakref), 1);
+ QCOMPARE(int(refCountData(baseptr)->strongref), 1);
{
QSharedPointer<VirtualDerived> derivedptr = baseptr.dynamicCast<VirtualDerived>();
@@ -761,8 +924,8 @@ void tst_QSharedPointer::dynamicCastVirtualBase()
QCOMPARE(derivedptr.data(), aData);
QCOMPARE(static_cast<Data *>(derivedptr.data()), baseptr.data());
}
- QCOMPARE(int(baseptr.d->weakref), 1);
- QCOMPARE(int(baseptr.d->strongref), 1);
+ QCOMPARE(int(refCountData(baseptr)->weakref), 1);
+ QCOMPARE(int(refCountData(baseptr)->strongref), 1);
}
void tst_QSharedPointer::dynamicCastFailure()
@@ -774,15 +937,15 @@ void tst_QSharedPointer::dynamicCastFailure()
QSharedPointer<DerivedData> derivedptr = qSharedPointerDynamicCast<DerivedData>(baseptr);
QVERIFY(derivedptr.isNull());
}
- QCOMPARE(int(baseptr.d->weakref), 1);
- QCOMPARE(int(baseptr.d->strongref), 1);
+ QCOMPARE(int(refCountData(baseptr)->weakref), 1);
+ QCOMPARE(int(refCountData(baseptr)->strongref), 1);
{
QSharedPointer<DerivedData> derivedptr = baseptr.dynamicCast<DerivedData>();
QVERIFY(derivedptr.isNull());
}
- QCOMPARE(int(baseptr.d->weakref), 1);
- QCOMPARE(int(baseptr.d->strongref), 1);
+ QCOMPARE(int(refCountData(baseptr)->weakref), 1);
+ QCOMPARE(int(refCountData(baseptr)->strongref), 1);
}
#endif
@@ -814,6 +977,7 @@ void tst_QSharedPointer::constCorrectness()
ptr = cvptr.constCast<Data>();
#endif
}
+ check();
{
Data *aData = new Data;
@@ -827,6 +991,7 @@ void tst_QSharedPointer::constCorrectness()
QCOMPARE(cptr.data(), aData);
QCOMPARE(cptr.operator->(), aData);
}
+ check();
}
static int customDeleterFnCallCount;
@@ -836,9 +1001,14 @@ void customDeleterFn(Data *ptr)
delete ptr;
}
+static int refcount;
+
template <typename T>
struct CustomDeleter
{
+ CustomDeleter() { ++refcount; }
+ CustomDeleter(const CustomDeleter &) { ++refcount; }
+ ~CustomDeleter() { --refcount; }
inline void operator()(T *ptr)
{
delete ptr;
@@ -855,11 +1025,13 @@ void tst_QSharedPointer::customDeleter()
QSharedPointer<Data> ptr2(new Data, &Data::alsoDelete);
QSharedPointer<Data> ptr3(new Data, &Data::virtualDelete);
}
+ check();
{
QSharedPointer<DerivedData> ptr(new DerivedData, &Data::doDelete);
QSharedPointer<DerivedData> ptr2(new DerivedData, &Data::alsoDelete);
QSharedPointer<DerivedData> ptr3(new DerivedData, &Data::virtualDelete);
}
+ check();
customDeleterFnCallCount = 0;
{
@@ -868,6 +1040,7 @@ void tst_QSharedPointer::customDeleter()
QCOMPARE(customDeleterFnCallCount, 0);
}
QCOMPARE(customDeleterFnCallCount, 1);
+ check();
customDeleterFnCallCount = 0;
{
@@ -877,6 +1050,7 @@ void tst_QSharedPointer::customDeleter()
QCOMPARE(customDeleterFnCallCount, 1);
}
QCOMPARE(customDeleterFnCallCount, 1);
+ check();
customDeleterFnCallCount = 0;
{
@@ -886,6 +1060,7 @@ void tst_QSharedPointer::customDeleter()
QCOMPARE(customDeleterFnCallCount, 1);
}
QCOMPARE(customDeleterFnCallCount, 1);
+ check();
customDeleterFnCallCount = 0;
{
@@ -894,6 +1069,7 @@ void tst_QSharedPointer::customDeleter()
QCOMPARE(customDeleterFnCallCount, 0);
}
QCOMPARE(customDeleterFnCallCount, 1);
+ check();
customDeleterFnCallCount = 0;
{
@@ -902,6 +1078,7 @@ void tst_QSharedPointer::customDeleter()
QCOMPARE(customDeleterFnCallCount, 0);
}
QCOMPARE(customDeleterFnCallCount, 1);
+ check();
customDeleterFnCallCount = 0;
{
@@ -914,6 +1091,7 @@ void tst_QSharedPointer::customDeleter()
QCOMPARE(customDeleterFnCallCount, 0);
}
QCOMPARE(customDeleterFnCallCount, 1);
+ check();
customDeleterFnCallCount = 0;
{
@@ -926,7 +1104,9 @@ void tst_QSharedPointer::customDeleter()
QCOMPARE(customDeleterFnCallCount, 0);
}
QCOMPARE(customDeleterFnCallCount, 1);
+ check();
+ refcount = 0;
CustomDeleter<Data> dataDeleter;
dataDeleter.callCount = 0;
{
@@ -935,6 +1115,8 @@ void tst_QSharedPointer::customDeleter()
QCOMPARE(dataDeleter.callCount, 0);
}
QCOMPARE(dataDeleter.callCount, 1);
+ QCOMPARE(refcount, 1);
+ check();
dataDeleter.callCount = 0;
{
@@ -944,6 +1126,8 @@ void tst_QSharedPointer::customDeleter()
QCOMPARE(dataDeleter.callCount, 0);
}
QCOMPARE(dataDeleter.callCount, 1);
+ QCOMPARE(refcount, 1);
+ check();
dataDeleter.callCount = 0;
{
@@ -956,6 +1140,8 @@ void tst_QSharedPointer::customDeleter()
QCOMPARE(dataDeleter.callCount, 0);
}
QCOMPARE(dataDeleter.callCount, 1);
+ QCOMPARE(refcount, 1);
+ check();
dataDeleter.callCount = 0;
{
@@ -964,6 +1150,8 @@ void tst_QSharedPointer::customDeleter()
QCOMPARE(dataDeleter.callCount, 0);
}
QCOMPARE(dataDeleter.callCount, 1);
+ QCOMPARE(refcount, 1);
+ check();
CustomDeleter<DerivedData> derivedDataDeleter;
derivedDataDeleter.callCount = 0;
@@ -976,6 +1164,8 @@ void tst_QSharedPointer::customDeleter()
}
QCOMPARE(dataDeleter.callCount, 0);
QCOMPARE(derivedDataDeleter.callCount, 1);
+ QCOMPARE(refcount, 2);
+ check();
derivedDataDeleter.callCount = 0;
dataDeleter.callCount = 0;
@@ -992,6 +1182,8 @@ void tst_QSharedPointer::customDeleter()
}
QCOMPARE(dataDeleter.callCount, 1);
QCOMPARE(derivedDataDeleter.callCount, 0);
+ QCOMPARE(refcount, 2);
+ check();
derivedDataDeleter.callCount = 0;
dataDeleter.callCount = 0;
@@ -1008,6 +1200,14 @@ void tst_QSharedPointer::customDeleter()
}
QCOMPARE(dataDeleter.callCount, 0);
QCOMPARE(derivedDataDeleter.callCount, 1);
+ QCOMPARE(refcount, 2);
+ check();
+}
+
+void customQObjectDeleterFn(QObject *obj)
+{
+ ++customDeleterFnCallCount;
+ delete obj;
}
void tst_QSharedPointer::creating()
@@ -1025,12 +1225,13 @@ void tst_QSharedPointer::creating()
ptr.clear();
QCOMPARE(Data::destructorCounter, 1);
}
+ check();
Data::generationCounter = Data::destructorCounter = 0;
{
QSharedPointer<Data> ptr = QSharedPointer<Data>::create();
QWeakPointer<Data> weakptr = ptr;
- QtSharedPointer::ExternalRefCountData *d = ptr.d;
+ QtSharedPointer::ExternalRefCountData *d = refCountData(ptr);
ptr.clear();
QVERIFY(ptr.isNull());
@@ -1040,6 +1241,7 @@ void tst_QSharedPointer::creating()
QVERIFY(d->weakref == 1);
QVERIFY(d->strongref == 0);
}
+ check();
Data::generationCounter = Data::destructorCounter = 0;
DerivedData::derivedDestructorCounter = 0;
@@ -1052,6 +1254,7 @@ void tst_QSharedPointer::creating()
QCOMPARE(Data::destructorCounter, 1);
QCOMPARE(DerivedData::derivedDestructorCounter, 1);
}
+ check();
{
QSharedPointer<Data> ptr = QSharedPointer<DiffPtrDerivedData>::create();
@@ -1060,6 +1263,7 @@ void tst_QSharedPointer::creating()
QCOMPARE(ptr.staticCast<DiffPtrDerivedData>()->buffer[3]+0, 16-3);
QCOMPARE(ptr.staticCast<DiffPtrDerivedData>()->buffer[0]+0, 16);
}
+ check();
{
QSharedPointer<VirtualDerived> ptr = QSharedPointer<VirtualDerived>::create();
@@ -1069,7 +1273,11 @@ void tst_QSharedPointer::creating()
QSharedPointer<Data> baseptr = ptr;
QCOMPARE(baseptr->classLevel(), 4);
}
+ check();
+}
+void tst_QSharedPointer::creatingQObject()
+{
{
QSharedPointer<QObject> ptr = QSharedPointer<QObject>::create();
QCOMPARE(ptr->metaObject(), &QObject::staticMetaObject);
@@ -1079,11 +1287,148 @@ void tst_QSharedPointer::creating()
QVERIFY(qptr.isNull());
}
+ check();
{
QSharedPointer<QObject> ptr = QSharedPointer<OtherObject>::create();
QCOMPARE(ptr->metaObject(), &OtherObject::staticMetaObject);
}
+ check();
+}
+
+void tst_QSharedPointer::mixTrackingPointerCode()
+{
+ {
+ // pointer created with tracking
+ // deleted in code without tracking
+ QSharedPointer<int> ptr = QSharedPointer<int>(new int(42));
+ Wrapper w(ptr);
+ ptr.clear();
+ }
+ check();
+
+ {
+ // pointer created without tracking
+ // deleted in code with tracking
+ Wrapper w = Wrapper::create();
+ w.ptr.clear();
+ }
+}
+
+class ThreadData
+{
+ QAtomicInt * volatile ptr;
+public:
+ ThreadData(QAtomicInt *p) : ptr(p) { }
+ ~ThreadData() { ++ptr; }
+ void ref()
+ {
+ // if we're called after the destructor, we'll crash
+ ptr->ref();
+ }
+};
+
+class StrongThread: public QThread
+{
+protected:
+ void run()
+ {
+ usleep(rand() % 2000);
+ ptr->ref();
+ ptr.clear();
+ }
+public:
+ QSharedPointer<ThreadData> ptr;
+};
+
+class WeakThread: public QThread
+{
+protected:
+ void run()
+ {
+ usleep(rand() % 2000);
+ QSharedPointer<ThreadData> ptr = weak;
+ if (ptr)
+ ptr->ref();
+ ptr.clear();
+ }
+public:
+ QWeakPointer<ThreadData> weak;
+};
+
+void tst_QSharedPointer::threadStressTest_data()
+{
+ QTest::addColumn<int>("strongThreadCount");
+ QTest::addColumn<int>("weakThreadCount");
+
+ QTest::newRow("0+0") << 0 << 0;
+ QTest::newRow("1+0") << 1 << 0;
+ QTest::newRow("2+0") << 2 << 0;
+ QTest::newRow("10+0") << 10 << 0;
+
+ QTest::newRow("0+1") << 0 << 1;
+ QTest::newRow("1+1") << 1 << 1;
+
+ QTest::newRow("2+10") << 2 << 10;
+ QTest::newRow("5+10") << 5 << 10;
+ QTest::newRow("5+30") << 5 << 30;
+
+ QTest::newRow("100+100") << 100 << 100;
+}
+
+void tst_QSharedPointer::threadStressTest()
+{
+ QFETCH(int, strongThreadCount);
+ QFETCH(int, weakThreadCount);
+
+ int guard1[128];
+ QAtomicInt counter;
+ int guard2[128];
+
+ memset(guard1, 0, sizeof guard1);
+ memset(guard2, 0, sizeof guard2);
+
+ for (int r = 0; r < 5; ++r) {
+ QVector<QThread*> allThreads(6 * qMax(strongThreadCount, weakThreadCount) + 3, 0);
+ QSharedPointer<ThreadData> base = QSharedPointer<ThreadData>(new ThreadData(&counter));
+ counter = 0;
+
+ // set the pointers
+ for (int i = 0; i < strongThreadCount; ++i) {
+ StrongThread *t = new StrongThread;
+ t->ptr = base;
+ allThreads[2 * i] = t;
+ }
+ for (int i = 0; i < weakThreadCount; ++i) {
+ WeakThread *t = new WeakThread;
+ t->weak = base;
+ allThreads[6 * i + 3] = t;
+ }
+
+ base.clear();
+
+ srand(time(NULL));
+ // start threads
+ for (int i = 0; i < allThreads.count(); ++i)
+ if (allThreads[i]) allThreads[i]->start();
+
+ // wait for them to finish
+ for (int i = 0; i < allThreads.count(); ++i)
+ if (allThreads[i]) allThreads[i]->wait();
+ qDeleteAll(allThreads);
+
+ // ensure the guards aren't touched
+ for (uint i = 0; i < sizeof guard1 / sizeof guard1[0]; ++i)
+ QVERIFY(!guard1[i]);
+ for (uint i = 0; i < sizeof guard2 / sizeof guard2[0]; ++i)
+ QVERIFY(!guard2[i]);
+
+ // verify that the count is the right range
+ int minValue = strongThreadCount;
+ int maxValue = strongThreadCount + weakThreadCount;
+ QVERIFY(counter >= minValue);
+ QVERIFY(counter <= maxValue);
+ }
}
void tst_QSharedPointer::validConstructs()
@@ -1195,6 +1540,7 @@ void tst_QSharedPointer::invalidConstructs_data()
"QSharedPointer<Data> b;\n"
"if (a + b) return;";
+#if QT_VERSION >= 0x040600
// two objects with the same pointer
QTest::newRow("same-pointer")
<< &QTest::QExternalTest::tryRunFail
@@ -1208,6 +1554,7 @@ void tst_QSharedPointer::invalidConstructs_data()
<< "Data *aData = new Data;\n"
"QSharedPointer<Data> ptr1 = QSharedPointer<Data>(aData);"
"ptr1 = QSharedPointer<Data>(aData);";
+#endif
// any type of cast for unrelated types:
// (we have no reinterpret_cast)
@@ -1229,6 +1576,17 @@ void tst_QSharedPointer::invalidConstructs_data()
<< &QTest::QExternalTest::tryCompileFail
<< "QSharedPointer<Data> ptr1;\n"
"QSharedPointer<int> ptr2 = qSharedPointerObjectCast<int>(ptr1);";
+
+ QTest::newRow("weak-pointer-from-regular-pointer")
+ << &QTest::QExternalTest::tryCompileFail
+ << "Data *ptr = 0;\n"
+ "QWeakPointer<Data> weakptr(ptr);\n";
+
+ QTest::newRow("shared-pointer-from-unmanaged-qobject")
+ << &QTest::QExternalTest::tryRunFail
+ << "QObject *ptr = new QObject;\n"
+ "QWeakPointer<QObject> weak = ptr;\n" // this makes the object unmanaged
+ "QSharedPointer<QObject> shared(ptr);\n";
}
void tst_QSharedPointer::invalidConstructs()
diff --git a/tests/auto/qsharedpointer/wrapper.cpp b/tests/auto/qsharedpointer/wrapper.cpp
new file mode 100644
index 0000000..7640e68
--- /dev/null
+++ b/tests/auto/qsharedpointer/wrapper.cpp
@@ -0,0 +1,60 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** 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 either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** 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.0, 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.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifdef QT_SHAREDPOINTER_TRACK_POINTERS
+# undef QT_SHAREDPOINTER_TRACK_POINTERS
+#endif
+#include <QtCore/qsharedpointer.h>
+#include "wrapper.h"
+
+Wrapper::Wrapper(const QSharedPointer<int> &value)
+ : ptr(value)
+{
+}
+
+Wrapper::~Wrapper()
+{
+}
+
+Wrapper Wrapper::create()
+{
+ return Wrapper(QSharedPointer<int>(new int(-47)));
+}
diff --git a/tests/auto/qsharedpointer/wrapper.h b/tests/auto/qsharedpointer/wrapper.h
new file mode 100644
index 0000000..a888063
--- /dev/null
+++ b/tests/auto/qsharedpointer/wrapper.h
@@ -0,0 +1,55 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** 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 either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** 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.0, 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.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#ifndef WRAPPER_H
+#define WRAPPER_H
+
+template <class T> class QSharedPointer;
+class Wrapper
+{
+public:
+ QSharedPointer<int> ptr;
+ Wrapper(const QSharedPointer<int> &);
+ ~Wrapper();
+
+ static Wrapper create();
+};
+
+#endif // WRAPPER_H
diff --git a/tests/auto/qsharedpointer_and_qwidget/qsharedpointer_and_qwidget.pro b/tests/auto/qsharedpointer_and_qwidget/qsharedpointer_and_qwidget.pro
new file mode 100644
index 0000000..db647a5
--- /dev/null
+++ b/tests/auto/qsharedpointer_and_qwidget/qsharedpointer_and_qwidget.pro
@@ -0,0 +1,3 @@
+load(qttest_p4)
+SOURCES += tst_qsharedpointer_and_qwidget.cpp
+DEFINES += SRCDIR=\\\"$$PWD/\\\"
diff --git a/tests/auto/qsharedpointer_and_qwidget/tst_qsharedpointer_and_qwidget.cpp b/tests/auto/qsharedpointer_and_qwidget/tst_qsharedpointer_and_qwidget.cpp
new file mode 100644
index 0000000..66727c2
--- /dev/null
+++ b/tests/auto/qsharedpointer_and_qwidget/tst_qsharedpointer_and_qwidget.cpp
@@ -0,0 +1,150 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** 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 either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** 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.0, 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.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtGui/QWidget>
+#include <QtGui/QPushButton>
+#include <QtTest/QtTest>
+
+namespace QtSharedPointer {
+ Q_CORE_EXPORT void internalSafetyCheckCleanCheck();
+}
+
+class tst_QSharedPointer_and_QWidget: public QObject
+{
+ Q_OBJECT
+private slots:
+ void weak_externalDelete();
+ void weak_parentDelete();
+ void weak_parentDelete_setParent();
+
+ void strong_weak();
+
+ void strong_sharedptrDelete();
+
+public slots:
+ void cleanup() { check(); }
+
+public:
+ inline void check()
+ {
+#ifdef QT_BUILD_INTERNAL
+ QtSharedPointer::internalSafetyCheckCleanCheck();
+#endif
+ }
+};
+
+void tst_QSharedPointer_and_QWidget::weak_externalDelete()
+{
+ QWidget *w = new QWidget;
+ QWeakPointer<QWidget> ptr = w;
+
+ QVERIFY(!ptr.isNull());
+
+ delete w;
+ QVERIFY(ptr.isNull());
+}
+
+void tst_QSharedPointer_and_QWidget::weak_parentDelete()
+{
+ QWidget *parent = new QWidget;
+ QWidget *w = new QWidget(parent);
+ QWeakPointer<QWidget> ptr = w;
+
+ QVERIFY(!ptr.isNull());
+
+ delete parent;
+ QVERIFY(ptr.isNull());
+}
+
+void tst_QSharedPointer_and_QWidget::weak_parentDelete_setParent()
+{
+ QWidget *parent = new QWidget;
+ QWidget *w = new QWidget;
+ QWeakPointer<QWidget> ptr = w;
+ w->setParent(parent);
+
+ QVERIFY(!ptr.isNull());
+
+ delete parent;
+ QVERIFY(ptr.isNull());
+}
+
+// -- mixed --
+
+void tst_QSharedPointer_and_QWidget::strong_weak()
+{
+ QSharedPointer<QWidget> ptr(new QWidget);
+ QWeakPointer<QWidget> weak = ptr.data();
+ QWeakPointer<QWidget> weak2 = ptr;
+
+ QVERIFY(!weak.isNull());
+ QVERIFY(!weak2.isNull());
+
+ ptr.clear(); // deletes
+
+ QVERIFY(weak.isNull());
+ QVERIFY(weak2.isNull());
+}
+
+
+// ---- strong management ----
+
+void tst_QSharedPointer_and_QWidget::strong_sharedptrDelete()
+{
+ QWidget *parent = new QWidget;
+ QSharedPointer<QWidget> ptr(new QWidget(parent));
+ QWeakPointer<QWidget> weak = ptr;
+ QPointer<QWidget> check = ptr.data();
+
+ QVERIFY(!check.isNull());
+ QVERIFY(!weak.isNull());
+
+ ptr.clear(); // deletes
+
+ QVERIFY(check.isNull());
+ QVERIFY(weak.isNull());
+
+ delete parent; // mustn't crash
+}
+
+QTEST_MAIN(tst_QSharedPointer_and_QWidget)
+
+#include "tst_qsharedpointer_and_qwidget.moc"
diff --git a/tests/auto/qsqldatabase/tst_databases.h b/tests/auto/qsqldatabase/tst_databases.h
index 8253541..f1e9d28 100644
--- a/tests/auto/qsqldatabase/tst_databases.h
+++ b/tests/auto/qsqldatabase/tst_databases.h
@@ -219,7 +219,7 @@ public:
// addDb( "QMYSQL3", "testdb", "troll", "trond", "horsehead.nokia.troll.no", 3307 );
// addDb( "QMYSQL3", "testdb", "troll", "trond", "horsehead.nokia.troll.no", 3308, "CLIENT_COMPRESS=1;CLIENT_SSL=1" ); // MySQL 4.1.1
// addDb( "QMYSQL3", "testdb", "troll", "trond", "horsehead.nokia.troll.no", 3309, "CLIENT_COMPRESS=1;CLIENT_SSL=1" ); // MySQL 5.0.18 Linux
-// addDb( "QMYSQL3", "testdb", "troll", "trond", "iceblink.nokia.troll.no" ); // MySQL 5.0.13 Windows
+// addDb( "QMYSQL3", "testdb", "troll", "trond", "silence.nokia.troll.no" ); // MySQL 5.1.36 Windows
// addDb( "QMYSQL3", "testdb", "testuser", "Ee4Gabf6_", "mysql4-nokia.trolltech.com.au" ); // MySQL 4.1.22-2.el4 linux
// addDb( "QMYSQL3", "testdb", "testuser", "Ee4Gabf6_", "mysql5-nokia.trolltech.com.au" ); // MySQL 5.0.45-7.el5 linux
@@ -518,6 +518,16 @@ public:
return QString();
}
+ static QString getPSQLVersion( const QSqlDatabase &db )
+ {
+ QSqlQuery q(db);
+ q.exec( "select version()" );
+ if(q.next())
+ return q.value( 0 ).toString();
+ else
+ return QString();
+ }
+
QStringList dbNames;
int counter;
};
diff --git a/tests/auto/qsqldatabase/tst_qsqldatabase.cpp b/tests/auto/qsqldatabase/tst_qsqldatabase.cpp
index e1f1d3c..fe4c86e 100644
--- a/tests/auto/qsqldatabase/tst_qsqldatabase.cpp
+++ b/tests/auto/qsqldatabase/tst_qsqldatabase.cpp
@@ -1054,6 +1054,7 @@ void tst_QSqlDatabase::recordMySQL()
int major = tst_Databases::getMySqlVersion( db ).section( QChar('.'), 0, 0 ).toInt();
int minor = tst_Databases::getMySqlVersion( db ).section( QChar('.'), 1, 1 ).toInt();
int revision = tst_Databases::getMySqlVersion( db ).section( QChar('.'), 2, 2 ).toInt();
+ int vernum = (major << 16) + (minor << 8) + revision;
#ifdef QT3_SUPPORT
/* The below is broken in mysql below 5.0.15
@@ -1061,7 +1062,7 @@ void tst_QSqlDatabase::recordMySQL()
specifically: Before MySQL 5.0.15, the pad value is space. Values are right-padded
with space on insert, and trailing spaces are removed on select.
*/
- if ( major >5 || ( major == 5 && minor > 0) || ( major == 5 && minor == 0 && revision >= 15) ) {
+ if( vernum >= ((5 << 16) + 15) ) {
bin10 = FieldDef("binary(10)", QVariant::ByteArray, QByteArray(Q3CString("123abc ")));
varbin10 = FieldDef("varbinary(10)", QVariant::ByteArray, QByteArray(Q3CString("123abcv ")));
}
@@ -1591,6 +1592,11 @@ void tst_QSqlDatabase::bug_249059()
QSqlDatabase db = QSqlDatabase::database(dbName);
CHECK_DATABASE(db);
+ QString version=tst_Databases::getPSQLVersion( db );
+ double ver=version.section(QChar::fromLatin1('.'),0,1).toDouble();
+ if (ver < 7.3)
+ QSKIP("Test requires PostgreSQL >= 7.3", SkipSingle);
+
QSqlQuery q(db);
QString tableName = qTableName("bug_249059");
QVERIFY_SQL(q, exec(QString("CREATE TABLE %1 (dt timestamp, t time)").arg(tableName)));
@@ -2025,11 +2031,9 @@ void tst_QSqlDatabase::mysql_multiselect()
CHECK_DATABASE(db);
QSqlQuery q(db);
- QVERIFY_SQL(q, exec("select version()"));
- QVERIFY_SQL(q, next());
QString version=tst_Databases::getMySqlVersion( db );
- int ver=version.section(QChar::fromLatin1('.'),0,1).toDouble();
- if (ver >= 4.1)
+ double ver=version.section(QChar::fromLatin1('.'),0,1).toDouble();
+ if (ver < 4.1)
QSKIP("Test requires MySQL >= 4.1", SkipSingle);
QVERIFY_SQL(q, exec("SELECT * FROM " + qTableName("qtest") + "; SELECT * FROM " + qTableName("qtest")));
diff --git a/tests/auto/qsqlrelationaltablemodel/tst_qsqlrelationaltablemodel.cpp b/tests/auto/qsqlrelationaltablemodel/tst_qsqlrelationaltablemodel.cpp
index 1e23d3d..d836486 100644
--- a/tests/auto/qsqlrelationaltablemodel/tst_qsqlrelationaltablemodel.cpp
+++ b/tests/auto/qsqlrelationaltablemodel/tst_qsqlrelationaltablemodel.cpp
@@ -930,13 +930,15 @@ void tst_QSqlRelationalTableModel::casing()
QSqlQuery q(db);
QVERIFY_SQL( q, exec("create table " + qTableName("CASETEST1", db.driver()).toUpper() +
" (id int not null primary key, name varchar(20), title_key int, another_title_key int)"));
+
+ if( !q.exec("create table " + qTableName("casetest1", db.driver()) +
+ " (ident int not null primary key, name varchar(20), title_key int)"))
+ QSKIP("The casing test for this database is irrelevant since this database does not treat different cases as separate entities", SkipAll);
+
QVERIFY_SQL( q, exec("insert into " + qTableName("CASETEST1", db.driver()).toUpper() + " values(1, 'harry', 1, 2)"));
QVERIFY_SQL( q, exec("insert into " + qTableName("CASETEST1", db.driver()).toUpper() + " values(2, 'trond', 2, 1)"));
QVERIFY_SQL( q, exec("insert into " + qTableName("CASETEST1", db.driver()).toUpper() + " values(3, 'vohi', 1, 2)"));
QVERIFY_SQL( q, exec("insert into " + qTableName("CASETEST1", db.driver()).toUpper() + " values(4, 'boris', 2, 2)"));
-
- QVERIFY_SQL( q, exec("create table " + qTableName("casetest1", db.driver()) +
- " (ident int not null primary key, name varchar(20), title_key int)"));
QVERIFY_SQL( q, exec("insert into " + qTableName("casetest1", db.driver()) + " values(1, 'jerry', 1)"));
QVERIFY_SQL( q, exec("insert into " + qTableName("casetest1", db.driver()) + " values(2, 'george', 2)"));
QVERIFY_SQL( q, exec("insert into " + qTableName("casetest1", db.driver()) + " values(4, 'kramer', 2)"));
diff --git a/tests/auto/qstate/tst_qstate.cpp b/tests/auto/qstate/tst_qstate.cpp
index 78b9853..43ea7fe 100644
--- a/tests/auto/qstate/tst_qstate.cpp
+++ b/tests/auto/qstate/tst_qstate.cpp
@@ -250,8 +250,9 @@ class EventTestTransition: public QAbstractTransition
{
public:
EventTestTransition(QEvent::Type type, QState *targetState)
- : QAbstractTransition(QList<QAbstractState*>() << targetState), m_type(type)
- {
+ : QAbstractTransition(), m_type(type)
+ {
+ setTargetState(targetState);
}
protected:
diff --git a/tests/auto/qstatemachine/tst_qstatemachine.cpp b/tests/auto/qstatemachine/tst_qstatemachine.cpp
index 7f4d9f5..97115bb 100644
--- a/tests/auto/qstatemachine/tst_qstatemachine.cpp
+++ b/tests/auto/qstatemachine/tst_qstatemachine.cpp
@@ -192,6 +192,7 @@ private slots:
// void overrideDefaultTargetAnimationWithSource();
void nestedStateMachines();
+ void goToState();
};
tst_QStateMachine::tst_QStateMachine()
@@ -225,7 +226,8 @@ class TestTransition : public QAbstractTransition
{
public:
TestTransition(QAbstractState *target)
- : QAbstractTransition(QList<QAbstractState*>() << target) {}
+ : QAbstractTransition()
+ { setTargetState(target); }
QList<int> triggers;
protected:
virtual bool eventTest(QEvent *) {
@@ -248,7 +250,8 @@ class EventTransition : public QAbstractTransition
{
public:
EventTransition(QEvent::Type type, QAbstractState *target, QState *parent = 0)
- : QAbstractTransition(QList<QAbstractState*>() << target, parent), m_type(type) {}
+ : QAbstractTransition(parent), m_type(type)
+ { setTargetState(target); }
protected:
virtual bool eventTest(QEvent *e) {
return (e->type() == m_type);
@@ -1513,7 +1516,8 @@ class StringTransition : public QAbstractTransition
{
public:
StringTransition(const QString &value, QAbstractState *target)
- : QAbstractTransition(QList<QAbstractState*>() << target), m_value(value) {}
+ : QAbstractTransition(), m_value(value)
+ { setTargetState(target); }
protected:
virtual bool eventTest(QEvent *e)
@@ -1736,7 +1740,8 @@ public:
: QSignalTransition(sourceState) {}
TestSignalTransition(QObject *sender, const char *signal,
QAbstractState *target)
- : QSignalTransition(sender, signal, QList<QAbstractState*>() << target) {}
+ : QSignalTransition(sender, signal)
+ { setTargetState(target); }
QVariantList argumentsReceived() const {
return m_args;
}
@@ -2021,20 +2026,15 @@ void tst_QStateMachine::signalTransitions()
void tst_QStateMachine::eventTransitions()
{
QPushButton button;
- for (int x = 0; x < 2; ++x) {
+ {
QStateMachine machine;
QState *s0 = new QState(&machine);
QFinalState *s1 = new QFinalState(&machine);
QMouseEventTransition *trans;
- if (x == 0) {
- trans = new QMouseEventTransition(&button, QEvent::MouseButtonPress, Qt::LeftButton);
- QCOMPARE(trans->targetState(), (QAbstractState*)0);
- trans->setTargetState(s1);
- } else {
- trans = new QMouseEventTransition(&button, QEvent::MouseButtonPress,
- Qt::LeftButton, QList<QAbstractState*>() << s1);
- }
+ trans = new QMouseEventTransition(&button, QEvent::MouseButtonPress, Qt::LeftButton);
+ QCOMPARE(trans->targetState(), (QAbstractState*)0);
+ trans->setTargetState(s1);
QCOMPARE(trans->eventType(), QEvent::MouseButtonPress);
QCOMPARE(trans->button(), Qt::LeftButton);
QCOMPARE(trans->targetState(), (QAbstractState*)s1);
@@ -2070,7 +2070,7 @@ void tst_QStateMachine::eventTransitions()
QTest::mousePress(&button2, Qt::LeftButton);
QTRY_COMPARE(finishedSpy.count(), 4);
}
- for (int x = 0; x < 3; ++x) {
+ for (int x = 0; x < 2; ++x) {
QStateMachine machine;
QState *s0 = new QState(&machine);
QFinalState *s1 = new QFinalState(&machine);
@@ -2086,9 +2086,6 @@ void tst_QStateMachine::eventTransitions()
} else if (x == 1) {
trans = new QEventTransition(&button, QEvent::MouseButtonPress);
trans->setTargetState(s1);
- } else {
- trans = new QEventTransition(&button, QEvent::MouseButtonPress,
- QList<QAbstractState*>() << s1);
}
QCOMPARE(trans->eventObject(), (QObject*)&button);
QCOMPARE(trans->eventType(), QEvent::MouseButtonPress);
@@ -3900,5 +3897,45 @@ void tst_QStateMachine::nestedStateMachines()
QTRY_COMPARE(finishedSpy.count(), 1);
}
+void tst_QStateMachine::goToState()
+{
+ QStateMachine machine;
+ QState *s1 = new QState(&machine);
+ QState *s2 = new QState(&machine);
+ machine.setInitialState(s1);
+ QSignalSpy startedSpy(&machine, SIGNAL(started()));
+ machine.start();
+ QTRY_COMPARE(startedSpy.count(), 1);
+
+ QStateMachinePrivate::get(&machine)->goToState(s2);
+ QCoreApplication::processEvents();
+ QCOMPARE(machine.configuration().size(), 1);
+ QVERIFY(machine.configuration().contains(s2));
+
+ QStateMachinePrivate::get(&machine)->goToState(s2);
+ QCoreApplication::processEvents();
+ QCOMPARE(machine.configuration().size(), 1);
+ QVERIFY(machine.configuration().contains(s2));
+
+ QStateMachinePrivate::get(&machine)->goToState(s1);
+ QStateMachinePrivate::get(&machine)->goToState(s2);
+ QStateMachinePrivate::get(&machine)->goToState(s1);
+ QCOMPARE(machine.configuration().size(), 1);
+ QVERIFY(machine.configuration().contains(s2));
+
+ QCoreApplication::processEvents();
+ QCOMPARE(machine.configuration().size(), 1);
+ QVERIFY(machine.configuration().contains(s1));
+
+ // go to state in group
+ QState *s2_1 = new QState(s2);
+ s2->setInitialState(s2_1);
+ QStateMachinePrivate::get(&machine)->goToState(s2_1);
+ QCoreApplication::processEvents();
+ QCOMPARE(machine.configuration().size(), 2);
+ QVERIFY(machine.configuration().contains(s2));
+ QVERIFY(machine.configuration().contains(s2_1));
+}
+
QTEST_MAIN(tst_QStateMachine)
#include "tst_qstatemachine.moc"
diff --git a/tests/auto/selftests/expected_longstring.txt b/tests/auto/selftests/expected_longstring.txt
new file mode 100644
index 0000000..4abdb23
--- /dev/null
+++ b/tests/auto/selftests/expected_longstring.txt
@@ -0,0 +1,16 @@
+********* Start testing of tst_LongString *********
+Config: Using QTest library 4.6.0, Qt 4.6.0
+PASS : tst_LongString::initTestCase()
+FAIL! : tst_LongString::failWithLongString() Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo ligula eget dolor. Aenean massa. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Donec quam felis, ultricies nec, pellentesque eu, pretium quis, sem. Nulla consequat massa quis enim. Donec pede justo, fringilla vel, aliquet nec, vulputate eget, arcu. In enim justo, rhoncus ut, imperdiet a, venenatis vitae, justo. Nullam dictum felis eu pede mollis pretium. Integer tincidunt. Cras dapibus. Vivamus elementum semper nisi. Aenean vulputate eleifend tellus. Aenean leo ligula, porttitor eu, consequat vitae, eleifend ac, enim. Aliquam lorem ante, dapibus in, viverra quis, feugiat a, tellus. Phasellus viverra nulla ut metus varius laoreet. Quisque rutrum. Aenean imperdiet. Etiam ultricies nisi vel augue. Curabitur ullamcorper ultricies nisi. Nam eget dui.
+
+Etiam rhoncus. Maecenas tempus, tellus eget condimentum rhoncus, sem quam semper libero, sit amet adipiscing sem neque sed ipsum. Nam quam nunc, blandit vel, luctus pulvinar, hendrerit id, lorem. Maecenas nec odio et ante tincidunt tempus. Donec vitae sapien ut libero venenatis faucibus. Nullam quis ante. Etiam sit amet orci eget eros faucibus tincidunt. Duis leo. Sed fringilla mauris sit amet nibh. Donec sodales sagittis magna. Sed consequat, leo eget bibendum sodales, augue velit cursus nunc, quis gravida magna mi a libero. Fusce vulputate eleifend sapien. Vestibulum purus quam, scelerisque ut, mollis sed, nonummy id, metus. Nullam accumsan lorem in dui. Cras ultricies mi eu turpis hendrerit fringilla. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; In ac dui quis mi consectetuer lacinia.
+
+Nam pretium turpis et arcu. Duis arcu tortor, suscipit eget, imperdiet nec, imperdiet iaculis, ipsum. Sed aliquam ultrices mauris. Integer ante arcu, accumsan a, consectetuer eget, posuere ut, mauris. Praesent adipiscing. Phasellus ullamcorper ipsum rutrum nunc. Nunc nonummy metus. Vestibulum volutpat pretium libero. Cras id dui. Aenean ut eros et nisl sagittis vestibulum. Nullam nulla eros, ultricies sit amet, nonummy id, imperdiet feugiat, pede. Sed lectus. Donec mollis hendrerit risus. Phasellus nec sem in justo pellentesque facilisis. Etiam imperdiet imperdiet orci. Nunc nec neque. Phasellus leo dolor, tempus non, auctor et, hendrerit quis, nisi.
+
+Curabitur ligula sapien, tincidunt non, euismod vitae, posuere imperdiet, leo. Maecenas malesuada. Praesent congue erat at massa. Sed cursus turpis vitae tortor. Donec posuere vulputate arcu. Phasellus accumsan cursus velit. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Sed aliquam, nisi quis porttitor congue, elit erat euismod orci, ac placerat dolor lectus quis orci. Phasellus consectetuer vestibulum elit. Aenean tellus metus, bibendum sed, posuere ac, mattis non, nunc. Vestibulum fringilla pede sit amet augue. In turpis. Pellentesque posuere. Praesent turpis.
+
+Aenean posuere, tortor sed cursus feugiat, nunc augue blandit nunc, eu sollicitudin urna dolor sagittis lacus. Donec elit libero, sodales nec, volutpat a, suscipit non, turpis. Nullam sagittis. Suspendisse pulvinar, augue ac venenatis condimentum, sem libero volutpat nibh, nec pellentesque velit pede quis nunc. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Fusce id purus. Ut varius tincidunt libero. Phasellus dolor. Maecenas vestibulum mollis diam. Pellentesque ut neque. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas.
+ Loc: [/home/rmcgover/depot/qt/master/tests/auto/selftests/longstring/tst_longstring.cpp(67)]
+PASS : tst_LongString::cleanupTestCase()
+Totals: 2 passed, 1 failed, 0 skipped
+********* Finished testing of tst_LongString *********
diff --git a/tests/auto/selftests/longstring/longstring.pro b/tests/auto/selftests/longstring/longstring.pro
new file mode 100644
index 0000000..b917481
--- /dev/null
+++ b/tests/auto/selftests/longstring/longstring.pro
@@ -0,0 +1,10 @@
+load(qttest_p4)
+SOURCES += tst_longstring.cpp
+QT = core
+
+mac:CONFIG -= app_bundle
+CONFIG -= debug_and_release_target
+
+
+TARGET = longstring
+
diff --git a/tests/auto/selftests/longstring/tst_longstring.cpp b/tests/auto/selftests/longstring/tst_longstring.cpp
new file mode 100644
index 0000000..a708fa7
--- /dev/null
+++ b/tests/auto/selftests/longstring/tst_longstring.cpp
@@ -0,0 +1,72 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** 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 either Technology Preview License Agreement or the
+** Beta Release License Agreement.
+**
+** 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.0, 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.
+**
+** If you are unsure which license is appropriate for your use, please
+** contact the sales department at http://www.qtsoftware.com/contact.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+
+#include <QtCore>
+#include <QtTest/QtTest>
+
+char const lipsum[] =
+"Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Aenean commodo ligula eget dolor. Aenean massa. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Donec quam felis, ultricies nec, pellentesque eu, pretium quis, sem. Nulla consequat massa quis enim. Donec pede justo, fringilla vel, aliquet nec, vulputate eget, arcu. In enim justo, rhoncus ut, imperdiet a, venenatis vitae, justo. Nullam dictum felis eu pede mollis pretium. Integer tincidunt. Cras dapibus. Vivamus elementum semper nisi. Aenean vulputate eleifend tellus. Aenean leo ligula, porttitor eu, consequat vitae, eleifend ac, enim. Aliquam lorem ante, dapibus in, viverra quis, feugiat a, tellus. Phasellus viverra nulla ut metus varius laoreet. Quisque rutrum. Aenean imperdiet. Etiam ultricies nisi vel augue. Curabitur ullamcorper ultricies nisi. Nam eget dui.\n\n"
+"Etiam rhoncus. Maecenas tempus, tellus eget condimentum rhoncus, sem quam semper libero, sit amet adipiscing sem neque sed ipsum. Nam quam nunc, blandit vel, luctus pulvinar, hendrerit id, lorem. Maecenas nec odio et ante tincidunt tempus. Donec vitae sapien ut libero venenatis faucibus. Nullam quis ante. Etiam sit amet orci eget eros faucibus tincidunt. Duis leo. Sed fringilla mauris sit amet nibh. Donec sodales sagittis magna. Sed consequat, leo eget bibendum sodales, augue velit cursus nunc, quis gravida magna mi a libero. Fusce vulputate eleifend sapien. Vestibulum purus quam, scelerisque ut, mollis sed, nonummy id, metus. Nullam accumsan lorem in dui. Cras ultricies mi eu turpis hendrerit fringilla. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; In ac dui quis mi consectetuer lacinia.\n\n"
+"Nam pretium turpis et arcu. Duis arcu tortor, suscipit eget, imperdiet nec, imperdiet iaculis, ipsum. Sed aliquam ultrices mauris. Integer ante arcu, accumsan a, consectetuer eget, posuere ut, mauris. Praesent adipiscing. Phasellus ullamcorper ipsum rutrum nunc. Nunc nonummy metus. Vestibulum volutpat pretium libero. Cras id dui. Aenean ut eros et nisl sagittis vestibulum. Nullam nulla eros, ultricies sit amet, nonummy id, imperdiet feugiat, pede. Sed lectus. Donec mollis hendrerit risus. Phasellus nec sem in justo pellentesque facilisis. Etiam imperdiet imperdiet orci. Nunc nec neque. Phasellus leo dolor, tempus non, auctor et, hendrerit quis, nisi.\n\n"
+"Curabitur ligula sapien, tincidunt non, euismod vitae, posuere imperdiet, leo. Maecenas malesuada. Praesent congue erat at massa. Sed cursus turpis vitae tortor. Donec posuere vulputate arcu. Phasellus accumsan cursus velit. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Sed aliquam, nisi quis porttitor congue, elit erat euismod orci, ac placerat dolor lectus quis orci. Phasellus consectetuer vestibulum elit. Aenean tellus metus, bibendum sed, posuere ac, mattis non, nunc. Vestibulum fringilla pede sit amet augue. In turpis. Pellentesque posuere. Praesent turpis.\n\n"
+"Aenean posuere, tortor sed cursus feugiat, nunc augue blandit nunc, eu sollicitudin urna dolor sagittis lacus. Donec elit libero, sodales nec, volutpat a, suscipit non, turpis. Nullam sagittis. Suspendisse pulvinar, augue ac venenatis condimentum, sem libero volutpat nibh, nec pellentesque velit pede quis nunc. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Fusce id purus. Ut varius tincidunt libero. Phasellus dolor. Maecenas vestibulum mollis diam. Pellentesque ut neque. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas."
+;
+
+/*!
+ \internal
+ */
+class tst_LongString: public QObject
+{
+ Q_OBJECT
+
+private slots:
+ void failWithLongString() const;
+};
+
+void tst_LongString::failWithLongString() const
+{
+ QFAIL(lipsum);
+}
+
+QTEST_MAIN(tst_LongString)
+
+#include "tst_longstring.moc"
diff --git a/tests/auto/selftests/selftests.pro b/tests/auto/selftests/selftests.pro
index 45de658..d854b5e 100644
--- a/tests/auto/selftests/selftests.pro
+++ b/tests/auto/selftests/selftests.pro
@@ -5,7 +5,7 @@ SUBDIRS = subtest test warnings maxwarnings cmptest globaldata skipglobal skip \
skipinit skipinitdata datetime singleskip assert waitwithoutgui differentexec \
exceptionthrow qexecstringlist datatable commandlinedata\
benchlibwalltime benchlibcallgrind benchlibeventcounter benchlibtickcounter \
- benchliboptions xunit badxml
+ benchliboptions xunit badxml longstring
INSTALLS =
diff --git a/tests/auto/selftests/selftests.qrc b/tests/auto/selftests/selftests.qrc
index 3d78bf5..4b75405 100644
--- a/tests/auto/selftests/selftests.qrc
+++ b/tests/auto/selftests/selftests.qrc
@@ -36,5 +36,6 @@
<file>expected_benchliboptions.txt</file>
<file>expected_benchlibtickcounter.txt</file>
<file>expected_xunit.txt</file>
+ <file>expected_longstring.txt</file>
</qresource>
</RCC>
diff --git a/tests/auto/selftests/tst_selftests.cpp b/tests/auto/selftests/tst_selftests.cpp
index 8eb7fe1..76a005b 100644
--- a/tests/auto/selftests/tst_selftests.cpp
+++ b/tests/auto/selftests/tst_selftests.cpp
@@ -184,13 +184,15 @@ void tst_Selftests::runSubTest_data()
QTest::newRow("benchliboptions") << "benchliboptions" << QStringList("-eventcounter");
QTest::newRow("benchlibwalltime") << "benchlibwalltime" << QStringList();
- //### QWS tests are currently run on a virtual machine, where ticks are not
- //### monotonously increasing
-#if defined(HAVE_TICK_COUNTER) && !defined(Q_WS_QWS)
+ //### This test is affected by the speed of the CPU and whether the tick counter is
+ //### monotonically increasing. It won't work on some machines so leave it off by default.
+ //### Feel free to uncomment for your own testing.
+#if 0
QTest::newRow("benchlibtickcounter") << "benchlibtickcounter" << QStringList("-tickcounter");
#endif
QTest::newRow("xunit") << "xunit" << QStringList("-xunitxml");
+ QTest::newRow("longstring") << "longstring" << QStringList();
}
diff --git a/tests/auto/tests.xml b/tests/auto/tests.xml
index a5386b2..ccfc380 100644
--- a/tests/auto/tests.xml
+++ b/tests/auto/tests.xml
@@ -271,6 +271,10 @@
<Test name="qsocks5socketengine" location="tests/auto/qsocks5socketengine/tst_qsocks5socketengine" />
<Test name="qsortfilterproxymodel" location="tests/auto/qsortfilterproxymodel/tst_qsortfilterproxymodel" />
<Test name="qsound" location="tests/auto/qsound/tst_qsound" />
+ <Test name="qaudiodeviceid" location="tests/auto/qaudiodeviceid/tst_qaudiodeviceid" />
+ <Test name="qaudioformat" location="tests/auto/qaudioformat/tst_qaudioformat" />
+ <Test name="qaudiooutput" location="tests/auto/qaudiooutput/tst_qaudiooutput" />
+ <Test name="qaudioinput" location="tests/auto/qaudioinput/tst_qaudioinput" />
<Test name="qsourcelocation" location="tests/auto/qsourcelocation/tst_qsourcelocation" />
<Test name="qspinbox" location="tests/auto/qspinbox/tst_qspinbox" />
<Test name="qsplitter" location="tests/auto/qsplitter/tst_qsplitter" />
@@ -676,6 +680,10 @@
<Test id="qsocks5socketengine" />
<Test id="qsortfilterproxymodel" />
<Test id="qsound" />
+ <Test id="qaudiodeviceid" />
+ <Test id="qaudioformat" />
+ <Test id="qaudiooutput" />
+ <Test id="qaudioinput" />
<Test id="qsourcelocation" />
<Test id="qspinbox" />
<Test id="qsplitter" />
diff --git a/tests/auto/uic3/uic3.pro b/tests/auto/uic3/uic3.pro
index 520f95a..72a1304 100644
--- a/tests/auto/uic3/uic3.pro
+++ b/tests/auto/uic3/uic3.pro
@@ -6,3 +6,6 @@ TARGET = tst_uic3
# This test is not run on wince (I think)
DEFINES += SRCDIR=\\\"$$PWD\\\"
+
+requires(contains(QT_CONFIG,qt3support))
+
diff --git a/tests/auto/uiloader/baseline/css_task259226_spinboxes.ui b/tests/auto/uiloader/baseline/css_task259226_spinboxes.ui
new file mode 100644
index 0000000..eb9ade3
--- /dev/null
+++ b/tests/auto/uiloader/baseline/css_task259226_spinboxes.ui
@@ -0,0 +1,83 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>Form</class>
+ <widget class="QWidget" name="Form">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>320</width>
+ <height>116</height>
+ </rect>
+ </property>
+ <property name="windowTitle">
+ <string>Form</string>
+ </property>
+ <property name="styleSheet">
+ <string notr="true">#spinbox1::up-button{
+ subcontrol-origin: border;
+ subcontrol-position: top left;
+ }
+#spinbox1::down-button {
+ subcontrol-origin: border;
+ subcontrol-position: bottom left;
+ }
+
+
+#spinbox2::up-button{
+ subcontrol-origin: border;
+ subcontrol-position: center left;
+ left: 0px;
+ height: 100%;
+ top: 0px;
+ }
+#spinbox2::down-button {
+ subcontrol-origin: border;
+ subcontrol-position: center right;
+ right: 0px;
+ height: 100%;
+ top: 0px;
+ }
+
+
+
+#spinbox3::up-button{
+ subcontrol-origin: border;
+ subcontrol-position: top left;
+ }
+
+
+#spinbox4 { padding: 20px 1px; }
+#spinbox4::up-button{
+ subcontrol-origin: border;
+ subcontrol-position: top center;
+ width:100%;
+ height: 20px;
+ }
+#spinbox4::down-button {
+ subcontrol-origin: border;
+ subcontrol-position: bottom center;
+ width:100%;
+ height: 20px;
+ }
+
+</string>
+ </property>
+ <layout class="QGridLayout" name="gridLayout">
+ <item row="0" column="0">
+ <widget class="QSpinBox" name="spinbox1"/>
+ </item>
+ <item row="0" column="1">
+ <widget class="QSpinBox" name="spinbox2"/>
+ </item>
+ <item row="1" column="0">
+ <widget class="QSpinBox" name="spinbox3"/>
+ </item>
+ <item row="1" column="1">
+ <widget class="QSpinBox" name="spinbox4"/>
+ </item>
+ </layout>
+ </widget>
+ <resources/>
+ <connections/>
+</ui>