summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/corelib/animation/qsequentialanimationgroup/tst_qsequentialanimationgroup.cpp2
-rw-r--r--tests/auto/corelib/global/qglobal/tst_qglobal.cpp31
-rw-r--r--tests/auto/corelib/io/qdebug/tst_qdebug.cpp54
-rw-r--r--tests/auto/corelib/io/qprocess/tst_qprocess.cpp1
-rw-r--r--tests/auto/corelib/io/qurl/tst_qurl.cpp21
-rw-r--r--tests/auto/corelib/itemmodels/qabstractitemmodel/tst_qabstractitemmodel.cpp5
-rw-r--r--tests/auto/corelib/itemmodels/qabstractproxymodel/tst_qabstractproxymodel.cpp2
-rw-r--r--tests/auto/corelib/itemmodels/qsortfilterproxymodel/tst_qsortfilterproxymodel.cpp12
-rw-r--r--tests/auto/corelib/tools/qchar/tst_qchar.cpp68
-rw-r--r--tests/auto/corelib/tools/qmargins/tst_qmargins.cpp44
-rw-r--r--tests/auto/corelib/tools/qmessageauthenticationcode/.gitignore1
-rw-r--r--tests/auto/corelib/tools/qmessageauthenticationcode/qmessageauthenticationcode.pro7
-rw-r--r--tests/auto/corelib/tools/qmessageauthenticationcode/tst_qmessageauthenticationcode.cpp151
-rw-r--r--tests/auto/corelib/tools/qrect/tst_qrect.cpp21
-rw-r--r--tests/auto/corelib/tools/qregularexpression/tst_qregularexpression.cpp104
-rw-r--r--tests/auto/corelib/tools/qregularexpression/tst_qregularexpression.h1
-rw-r--r--tests/auto/corelib/tools/qsharedpointer/tst_qsharedpointer.cpp120
-rw-r--r--tests/auto/corelib/tools/qstring/tst_qstring.cpp49
-rw-r--r--tests/auto/corelib/tools/tools.pro1
-rw-r--r--tests/auto/dbus/qdbuspendingreply/tst_qdbuspendingreply.cpp7
-rw-r--r--tests/auto/gui/image/qpixmap/tst_qpixmap.cpp23
-rw-r--r--tests/auto/gui/text/qfontmetrics/tst_qfontmetrics.cpp2
-rw-r--r--tests/auto/gui/util/qregularexpressionvalidator/.gitignore1
-rw-r--r--tests/auto/gui/util/qregularexpressionvalidator/qregularexpressionvalidator.pro4
-rw-r--r--tests/auto/gui/util/qregularexpressionvalidator/tst_qregularexpressionvalidator.cpp120
-rw-r--r--tests/auto/gui/util/util.pro1
-rw-r--r--tests/auto/other/qaccessibility/tst_qaccessibility.cpp70
-rw-r--r--tests/auto/tools/moc/tst_moc.cpp36
-rw-r--r--tests/auto/widgets/graphicsview/qgraphicsitem/tst_qgraphicsitem.cpp68
-rw-r--r--tests/auto/widgets/graphicsview/qgraphicsscene/tst_qgraphicsscene.cpp118
-rw-r--r--tests/auto/widgets/graphicsview/qgraphicswidget/tst_qgraphicswidget.cpp99
-rw-r--r--tests/auto/widgets/itemviews/qabstractitemview/tst_qabstractitemview.cpp43
-rw-r--r--tests/auto/widgets/widgets/qdatetimeedit/tst_qdatetimeedit.cpp1
-rw-r--r--tests/auto/widgets/widgets/qdialogbuttonbox/tst_qdialogbuttonbox.cpp8
-rw-r--r--tests/auto/widgets/widgets/qmenubar/tst_qmenubar.cpp1
-rw-r--r--tests/manual/widgets/itemviews/qheaderview/qheaderviewtest1.cpp3
-rw-r--r--tests/manual/windowflags/controls.cpp4
37 files changed, 1209 insertions, 95 deletions
diff --git a/tests/auto/corelib/animation/qsequentialanimationgroup/tst_qsequentialanimationgroup.cpp b/tests/auto/corelib/animation/qsequentialanimationgroup/tst_qsequentialanimationgroup.cpp
index 970d6a995b..1876184e7e 100644
--- a/tests/auto/corelib/animation/qsequentialanimationgroup/tst_qsequentialanimationgroup.cpp
+++ b/tests/auto/corelib/animation/qsequentialanimationgroup/tst_qsequentialanimationgroup.cpp
@@ -44,7 +44,6 @@
#include <QtCore/qsequentialanimationgroup.h>
Q_DECLARE_METATYPE(QAbstractAnimation::State)
-Q_DECLARE_METATYPE(QAbstractAnimation*)
class tst_QSequentialAnimationGroup : public QObject
{
@@ -84,7 +83,6 @@ private slots:
void tst_QSequentialAnimationGroup::initTestCase()
{
qRegisterMetaType<QAbstractAnimation::State>("QAbstractAnimation::State");
- qRegisterMetaType<QAbstractAnimation*>("QAbstractAnimation*");
}
void tst_QSequentialAnimationGroup::construction()
diff --git a/tests/auto/corelib/global/qglobal/tst_qglobal.cpp b/tests/auto/corelib/global/qglobal/tst_qglobal.cpp
index 72a2863fdd..47add61b05 100644
--- a/tests/auto/corelib/global/qglobal/tst_qglobal.cpp
+++ b/tests/auto/corelib/global/qglobal/tst_qglobal.cpp
@@ -55,6 +55,8 @@ private slots:
void checkptr();
void qstaticassert();
void qConstructorFunction();
+ void qCoreAppStartupFunction();
+ void qCoreAppStartupFunctionRestart();
void isEnum();
void qAlignOf();
};
@@ -303,6 +305,33 @@ void tst_QGlobal::qConstructorFunction()
QCOMPARE(qConstructorFunctionValue, 123);
}
+static int qStartupFunctionValue;
+static void myStartupFunc()
+{
+ Q_ASSERT(QCoreApplication::instance());
+ if (QCoreApplication::instance())
+ qStartupFunctionValue += 124;
+}
+
+Q_COREAPP_STARTUP_FUNCTION(myStartupFunc)
+
+void tst_QGlobal::qCoreAppStartupFunction()
+{
+ QCOMPARE(qStartupFunctionValue, 0);
+ int argc = 1;
+ char *argv[] = { const_cast<char*>("tst_qglobal") };
+ QCoreApplication app(argc, argv);
+ QCOMPARE(qStartupFunctionValue, 124);
+}
+
+void tst_QGlobal::qCoreAppStartupFunctionRestart()
+{
+ qStartupFunctionValue = 0;
+ qCoreAppStartupFunction();
+ qStartupFunctionValue = 0;
+ qCoreAppStartupFunction();
+}
+
struct isEnum_A {
int n_;
};
@@ -532,5 +561,5 @@ void tst_QGlobal::qAlignOf()
#undef TEST_AlignOf_RValueRef
#undef TEST_AlignOf_impl
-QTEST_MAIN(tst_QGlobal)
+QTEST_APPLESS_MAIN(tst_QGlobal)
#include "tst_qglobal.moc"
diff --git a/tests/auto/corelib/io/qdebug/tst_qdebug.cpp b/tests/auto/corelib/io/qdebug/tst_qdebug.cpp
index 407b5d00f3..c7a41657ac 100644
--- a/tests/auto/corelib/io/qdebug/tst_qdebug.cpp
+++ b/tests/auto/corelib/io/qdebug/tst_qdebug.cpp
@@ -52,7 +52,8 @@ private slots:
void warningWithoutDebug() const;
void criticalWithoutDebug() const;
void debugWithBool() const;
- void debugNoSpaces() const;
+ void debugSpaceHandling() const;
+ void stateSaver() const;
void veryLongWarningMessage() const;
void qDebugQStringRef() const;
void qDebugQLatin1String() const;
@@ -150,7 +151,36 @@ void tst_QDebug::debugWithBool() const
QCOMPARE(QString::fromLatin1(s_function), function);
}
-void tst_QDebug::debugNoSpaces() const
+class MyPoint
+{
+public:
+ MyPoint(int val1, int val2)
+ : v1(val1), v2(val2) {}
+ int v1;
+ int v2;
+};
+QDebug operator<< (QDebug s, const MyPoint& point)
+{
+ const QDebugStateSaver saver(s);
+ return s.nospace() << "MyPoint(" << point.v1 << ", " << point.v2 << ")";
+}
+
+class MyLine
+{
+public:
+ MyLine(const MyPoint& point1, const MyPoint& point2)
+ : p1(point1), p2(point2) {}
+ MyPoint p1;
+ MyPoint p2;
+};
+QDebug operator<< (QDebug s, const MyLine& line)
+{
+ const QDebugStateSaver saver(s);
+ s.nospace() << "MyLine(" << line.p1 << ", " << line.p2 << ")";
+ return s;
+}
+
+void tst_QDebug::debugSpaceHandling() const
{
MessageHandlerSetter mhs(myMessageHandler);
{
@@ -166,8 +196,26 @@ void tst_QDebug::debugNoSpaces() const
d << "key=" << "value";
d.space();
d << 1 << 2;
+ MyLine line(MyPoint(10, 11), MyPoint (12, 13));
+ d << line;
+ // With the old implementation of MyPoint doing dbg.nospace() << ...; dbg.space() we ended up with
+ // MyLine(MyPoint(10, 11) , MyPoint(12, 13) )
+ }
+ QCOMPARE(s_msg, QString::fromLatin1(" foo key=value 1 2 MyLine(MyPoint(10, 11), MyPoint(12, 13))"));
+}
+
+void tst_QDebug::stateSaver() const
+{
+ MessageHandlerSetter mhs(myMessageHandler);
+ {
+ QDebug d = qDebug();
+ {
+ QDebugStateSaver saver(d);
+ d.nospace() << hex << right << qSetFieldWidth(3) << qSetPadChar('0') << 42;
+ }
+ d.space() << 42;
}
- QCOMPARE(s_msg, QString::fromLatin1(" foo key=value 1 2 "));
+ QCOMPARE(s_msg, QString::fromLatin1("02a 42 "));
}
void tst_QDebug::veryLongWarningMessage() const
diff --git a/tests/auto/corelib/io/qprocess/tst_qprocess.cpp b/tests/auto/corelib/io/qprocess/tst_qprocess.cpp
index 98c12b01c1..070e78437f 100644
--- a/tests/auto/corelib/io/qprocess/tst_qprocess.cpp
+++ b/tests/auto/corelib/io/qprocess/tst_qprocess.cpp
@@ -1256,7 +1256,6 @@ void tst_QProcess::waitForBytesWrittenInABytesWrittenSlot()
process->start("testProcessEcho/testProcessEcho");
QVERIFY(process->waitForStarted(5000));
- qRegisterMetaType<qint64>("qint64");
QSignalSpy spy(process, SIGNAL(bytesWritten(qint64)));
QVERIFY(spy.isValid());
process->write("f");
diff --git a/tests/auto/corelib/io/qurl/tst_qurl.cpp b/tests/auto/corelib/io/qurl/tst_qurl.cpp
index ec402dd986..1b2c8da565 100644
--- a/tests/auto/corelib/io/qurl/tst_qurl.cpp
+++ b/tests/auto/corelib/io/qurl/tst_qurl.cpp
@@ -79,6 +79,8 @@ private slots:
void toString();
void toString_constructed_data();
void toString_constructed();
+ void toAndFromStringList_data();
+ void toAndFromStringList();
void isParentOf_data();
void isParentOf();
void toLocalFile_data();
@@ -941,6 +943,25 @@ void tst_QUrl::toString()
QCOMPARE(url.toString(QUrl::FormattingOptions(options)), string);
}
+void tst_QUrl::toAndFromStringList_data()
+{
+ QTest::addColumn<QStringList>("strings");
+
+ QTest::newRow("empty") << QStringList();
+ QTest::newRow("local") << (QStringList() << "file:///tmp" << "file:///");
+ QTest::newRow("remote") << (QStringList() << "http://qt-project.org");
+}
+
+void tst_QUrl::toAndFromStringList()
+{
+ QFETCH(QStringList, strings);
+
+ const QList<QUrl> urls = QUrl::fromStringList(strings);
+ QCOMPARE(urls.count(), strings.count());
+ const QStringList converted = QUrl::toStringList(urls);
+ QCOMPARE(converted, strings);
+}
+
//### more tests ... what do we expect ...
void tst_QUrl::isParentOf_data()
{
diff --git a/tests/auto/corelib/itemmodels/qabstractitemmodel/tst_qabstractitemmodel.cpp b/tests/auto/corelib/itemmodels/qabstractitemmodel/tst_qabstractitemmodel.cpp
index b987fb6835..368c5240e7 100644
--- a/tests/auto/corelib/itemmodels/qabstractitemmodel/tst_qabstractitemmodel.cpp
+++ b/tests/auto/corelib/itemmodels/qabstractitemmodel/tst_qabstractitemmodel.cpp
@@ -467,9 +467,6 @@ typedef QPair<int, int> Position;
typedef QVector<QPair<int, int> > Selection;
typedef QVector<QVector<QString> > StringTable;
typedef QVector<QString> StringTableRow;
-Q_DECLARE_METATYPE(Position)
-Q_DECLARE_METATYPE(Selection)
-Q_DECLARE_METATYPE(StringTable)
static StringTableRow qStringTableRow(const QString &s1, const QString &s2, const QString &s3)
{
@@ -1922,8 +1919,6 @@ public:
void tst_QAbstractItemModel::testDataChanged()
{
- qRegisterMetaType<QVector<int> >();
-
CustomRoleModel model;
QSignalSpy withRoles(&model, SIGNAL(dataChanged(QModelIndex,QModelIndex,QVector<int>)));
diff --git a/tests/auto/corelib/itemmodels/qabstractproxymodel/tst_qabstractproxymodel.cpp b/tests/auto/corelib/itemmodels/qabstractproxymodel/tst_qabstractproxymodel.cpp
index 30beffe467..8138ad939b 100644
--- a/tests/auto/corelib/itemmodels/qabstractproxymodel/tst_qabstractproxymodel.cpp
+++ b/tests/auto/corelib/itemmodels/qabstractproxymodel/tst_qabstractproxymodel.cpp
@@ -281,8 +281,6 @@ void tst_QAbstractProxyModel::revert()
// public void setSourceModel(QAbstractItemModel* sourceModel)
void tst_QAbstractProxyModel::setSourceModel()
{
- qRegisterMetaType<QAbstractItemModel*>();
-
SubQAbstractProxyModel model;
QCOMPARE(model.property("sourceModel"), QVariant::fromValue<QAbstractItemModel*>(0));
diff --git a/tests/auto/corelib/itemmodels/qsortfilterproxymodel/tst_qsortfilterproxymodel.cpp b/tests/auto/corelib/itemmodels/qsortfilterproxymodel/tst_qsortfilterproxymodel.cpp
index 576ef7747c..0894847572 100644
--- a/tests/auto/corelib/itemmodels/qsortfilterproxymodel/tst_qsortfilterproxymodel.cpp
+++ b/tests/auto/corelib/itemmodels/qsortfilterproxymodel/tst_qsortfilterproxymodel.cpp
@@ -54,6 +54,8 @@ typedef QList<int> IntList;
typedef QPair<int, int> IntPair;
typedef QList<IntPair> IntPairList;
+Q_DECLARE_METATYPE(QList<QPersistentModelIndex>)
+
class tst_QSortFilterProxyModel : public QObject
{
Q_OBJECT
@@ -174,9 +176,7 @@ tst_QSortFilterProxyModel::tst_QSortFilterProxyModel()
void tst_QSortFilterProxyModel::initTestCase()
{
- qRegisterMetaType<IntList>("IntList");
- qRegisterMetaType<IntPair>("IntPair");
- qRegisterMetaType<IntPairList>("IntPairList");
+ qRegisterMetaType<QList<QPersistentModelIndex> >();
m_model = new QStandardItemModel(0, 1);
m_proxy = new QSortFilterProxyModel();
m_proxy->setSourceModel(m_model);
@@ -3242,8 +3242,6 @@ void tst_QSortFilterProxyModel::resetInvalidate()
QCOMPARE(ok, works);
}
-Q_DECLARE_METATYPE(QList<QPersistentModelIndex>)
-
void tst_QSortFilterProxyModel::testParentLayoutChanged()
{
QStandardItemModel model;
@@ -3276,8 +3274,6 @@ void tst_QSortFilterProxyModel::testParentLayoutChanged()
proxy2.setSourceModel(&proxy);
proxy2.setObjectName("proxy2");
- qRegisterMetaType<QList<QPersistentModelIndex> >();
-
QSignalSpy dataChangedSpy(&model, SIGNAL(dataChanged(QModelIndex,QModelIndex)));
QVERIFY(dataChangedSpy.isValid());
@@ -3411,8 +3407,6 @@ private:
void tst_QSortFilterProxyModel::moveSourceRows()
{
- qRegisterMetaType<QList<QPersistentModelIndex> >();
-
DynamicTreeModel model;
{
diff --git a/tests/auto/corelib/tools/qchar/tst_qchar.cpp b/tests/auto/corelib/tools/qchar/tst_qchar.cpp
index fb49503e0e..2fdd680639 100644
--- a/tests/auto/corelib/tools/qchar/tst_qchar.cpp
+++ b/tests/auto/corelib/tools/qchar/tst_qchar.cpp
@@ -709,40 +709,40 @@ void tst_QChar::lineBreakClass()
void tst_QChar::script()
{
- QVERIFY(QUnicodeTables::script(0x0020u) == QUnicodeTables::Common);
- QVERIFY(QUnicodeTables::script(0x0041u) == QUnicodeTables::Common); // ### Latin
- QVERIFY(QUnicodeTables::script(0x0375u) == QUnicodeTables::Greek);
- QVERIFY(QUnicodeTables::script(0x0400u) == QUnicodeTables::Cyrillic);
- QVERIFY(QUnicodeTables::script(0x0531u) == QUnicodeTables::Armenian);
- QVERIFY(QUnicodeTables::script(0x0591u) == QUnicodeTables::Hebrew);
- QVERIFY(QUnicodeTables::script(0x0600u) == QUnicodeTables::Arabic);
- QVERIFY(QUnicodeTables::script(0x0700u) == QUnicodeTables::Syriac);
- QVERIFY(QUnicodeTables::script(0x0780u) == QUnicodeTables::Thaana);
- QVERIFY(QUnicodeTables::script(0x07c0u) == QUnicodeTables::Nko);
- QVERIFY(QUnicodeTables::script(0x0900u) == QUnicodeTables::Devanagari);
- QVERIFY(QUnicodeTables::script(0x0981u) == QUnicodeTables::Bengali);
- QVERIFY(QUnicodeTables::script(0x0a01u) == QUnicodeTables::Gurmukhi);
- QVERIFY(QUnicodeTables::script(0x0a81u) == QUnicodeTables::Gujarati);
- QVERIFY(QUnicodeTables::script(0x0b01u) == QUnicodeTables::Oriya);
- QVERIFY(QUnicodeTables::script(0x0b82u) == QUnicodeTables::Tamil);
- QVERIFY(QUnicodeTables::script(0x0c01u) == QUnicodeTables::Telugu);
- QVERIFY(QUnicodeTables::script(0x0c82u) == QUnicodeTables::Kannada);
- QVERIFY(QUnicodeTables::script(0x0d02u) == QUnicodeTables::Malayalam);
- QVERIFY(QUnicodeTables::script(0x0d82u) == QUnicodeTables::Sinhala);
- QVERIFY(QUnicodeTables::script(0x0e01u) == QUnicodeTables::Thai);
- QVERIFY(QUnicodeTables::script(0x0e81u) == QUnicodeTables::Lao);
- QVERIFY(QUnicodeTables::script(0x0f00u) == QUnicodeTables::Tibetan);
- QVERIFY(QUnicodeTables::script(0x1000u) == QUnicodeTables::Myanmar);
- QVERIFY(QUnicodeTables::script(0x10a0u) == QUnicodeTables::Georgian);
- QVERIFY(QUnicodeTables::script(0x1100u) == QUnicodeTables::Hangul);
- QVERIFY(QUnicodeTables::script(0x1680u) == QUnicodeTables::Ogham);
- QVERIFY(QUnicodeTables::script(0x16a0u) == QUnicodeTables::Runic);
- QVERIFY(QUnicodeTables::script(0x1780u) == QUnicodeTables::Khmer);
- QVERIFY(QUnicodeTables::script(0x200cu) == QUnicodeTables::Inherited);
- QVERIFY(QUnicodeTables::script(0x200du) == QUnicodeTables::Inherited);
- QVERIFY(QUnicodeTables::script(0x1018au) == QUnicodeTables::Greek);
- QVERIFY(QUnicodeTables::script(0x1f130u) == QUnicodeTables::Common);
- QVERIFY(QUnicodeTables::script(0xe0100u) == QUnicodeTables::Inherited);
+ QVERIFY(QChar::script(0x0020u) == QChar::Script_Common);
+ QVERIFY(QChar::script(0x0041u) == QChar::Script_Latin);
+ QVERIFY(QChar::script(0x0375u) == QChar::Script_Greek);
+ QVERIFY(QChar::script(0x0400u) == QChar::Script_Cyrillic);
+ QVERIFY(QChar::script(0x0531u) == QChar::Script_Armenian);
+ QVERIFY(QChar::script(0x0591u) == QChar::Script_Hebrew);
+ QVERIFY(QChar::script(0x0600u) == QChar::Script_Arabic);
+ QVERIFY(QChar::script(0x0700u) == QChar::Script_Syriac);
+ QVERIFY(QChar::script(0x0780u) == QChar::Script_Thaana);
+ QVERIFY(QChar::script(0x07c0u) == QChar::Script_Nko);
+ QVERIFY(QChar::script(0x0900u) == QChar::Script_Devanagari);
+ QVERIFY(QChar::script(0x0981u) == QChar::Script_Bengali);
+ QVERIFY(QChar::script(0x0a01u) == QChar::Script_Gurmukhi);
+ QVERIFY(QChar::script(0x0a81u) == QChar::Script_Gujarati);
+ QVERIFY(QChar::script(0x0b01u) == QChar::Script_Oriya);
+ QVERIFY(QChar::script(0x0b82u) == QChar::Script_Tamil);
+ QVERIFY(QChar::script(0x0c01u) == QChar::Script_Telugu);
+ QVERIFY(QChar::script(0x0c82u) == QChar::Script_Kannada);
+ QVERIFY(QChar::script(0x0d02u) == QChar::Script_Malayalam);
+ QVERIFY(QChar::script(0x0d82u) == QChar::Script_Sinhala);
+ QVERIFY(QChar::script(0x0e01u) == QChar::Script_Thai);
+ QVERIFY(QChar::script(0x0e81u) == QChar::Script_Lao);
+ QVERIFY(QChar::script(0x0f00u) == QChar::Script_Tibetan);
+ QVERIFY(QChar::script(0x1000u) == QChar::Script_Myanmar);
+ QVERIFY(QChar::script(0x10a0u) == QChar::Script_Georgian);
+ QVERIFY(QChar::script(0x1100u) == QChar::Script_Hangul);
+ QVERIFY(QChar::script(0x1680u) == QChar::Script_Ogham);
+ QVERIFY(QChar::script(0x16a0u) == QChar::Script_Runic);
+ QVERIFY(QChar::script(0x1780u) == QChar::Script_Khmer);
+ QVERIFY(QChar::script(0x200cu) == QChar::Script_Inherited);
+ QVERIFY(QChar::script(0x200du) == QChar::Script_Inherited);
+ QVERIFY(QChar::script(0x1018au) == QChar::Script_Greek);
+ QVERIFY(QChar::script(0x1f130u) == QChar::Script_Common);
+ QVERIFY(QChar::script(0xe0100u) == QChar::Script_Inherited);
}
void tst_QChar::normalization_data()
diff --git a/tests/auto/corelib/tools/qmargins/tst_qmargins.cpp b/tests/auto/corelib/tools/qmargins/tst_qmargins.cpp
index 5e3b3d221e..b74fc53ed0 100644
--- a/tests/auto/corelib/tools/qmargins/tst_qmargins.cpp
+++ b/tests/auto/corelib/tools/qmargins/tst_qmargins.cpp
@@ -50,6 +50,7 @@ class tst_QMargins : public QObject
private slots:
void getSetCheck();
void dataStreamCheck();
+ void operators();
};
// Testing get/set functions
@@ -75,6 +76,49 @@ void tst_QMargins::getSetCheck()
QCOMPARE(margins, QMargins(5, 0, 5, 0));
}
+void tst_QMargins::operators()
+{
+ const QMargins m1(12, 14, 16, 18);
+ const QMargins m2(2, 3, 4, 5);
+
+ const QMargins added = m1 + m2;
+ QCOMPARE(added, QMargins(14, 17, 20, 23));
+ QMargins a = m1;
+ a += m2;
+ QCOMPARE(a, added);
+
+ const QMargins subtracted = m1 - m2;
+ QCOMPARE(subtracted, QMargins(10, 11, 12, 13));
+ a = m1;
+ a -= m2;
+ QCOMPARE(a, subtracted);
+
+ const QMargins doubled = m1 * 2;
+ QCOMPARE(doubled, QMargins(24, 28, 32, 36));
+ QCOMPARE(2 * m1, doubled);
+ QCOMPARE(qreal(2) * m1, doubled);
+ QCOMPARE(m1 * qreal(2), doubled);
+
+ a = m1;
+ a *= 2;
+ QCOMPARE(a, doubled);
+ a = m1;
+ a *= qreal(2);
+ QCOMPARE(a, doubled);
+
+ const QMargins halved = m1 / 2;
+ QCOMPARE(halved, QMargins(6, 7, 8, 9));
+
+ a = m1;
+ a /= 2;
+ QCOMPARE(a, halved);
+ a = m1;
+ a /= qreal(2);
+ QCOMPARE(a, halved);
+
+ QCOMPARE(m1 + (-m1), QMargins());
+}
+
// Testing QDataStream operators
void tst_QMargins::dataStreamCheck()
{
diff --git a/tests/auto/corelib/tools/qmessageauthenticationcode/.gitignore b/tests/auto/corelib/tools/qmessageauthenticationcode/.gitignore
new file mode 100644
index 0000000000..bfd53f437b
--- /dev/null
+++ b/tests/auto/corelib/tools/qmessageauthenticationcode/.gitignore
@@ -0,0 +1 @@
+tst_qmessageauthenticationcode
diff --git a/tests/auto/corelib/tools/qmessageauthenticationcode/qmessageauthenticationcode.pro b/tests/auto/corelib/tools/qmessageauthenticationcode/qmessageauthenticationcode.pro
new file mode 100644
index 0000000000..1ea23915b7
--- /dev/null
+++ b/tests/auto/corelib/tools/qmessageauthenticationcode/qmessageauthenticationcode.pro
@@ -0,0 +1,7 @@
+CONFIG += testcase parallel_test
+TARGET = tst_qmessageauthenticationcode
+QT = core testlib
+SOURCES = tst_qmessageauthenticationcode.cpp
+
+TESTDATA += data/*
+DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0
diff --git a/tests/auto/corelib/tools/qmessageauthenticationcode/tst_qmessageauthenticationcode.cpp b/tests/auto/corelib/tools/qmessageauthenticationcode/tst_qmessageauthenticationcode.cpp
new file mode 100644
index 0000000000..0e243988e2
--- /dev/null
+++ b/tests/auto/corelib/tools/qmessageauthenticationcode/tst_qmessageauthenticationcode.cpp
@@ -0,0 +1,151 @@
+/****************************************************************************
+**
+** Copyright (C) 2013 Ruslan Nigmatullin <euroelessar@yandex.ru>
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+
+#include <QtCore/QCoreApplication>
+#include <QtTest/QtTest>
+
+class tst_QMessageAuthenticationCode : public QObject
+{
+ Q_OBJECT
+private slots:
+ void result_data();
+ void result();
+ void result_incremental_data();
+ void result_incremental();
+};
+
+Q_DECLARE_METATYPE(QCryptographicHash::Algorithm)
+
+void tst_QMessageAuthenticationCode::result_data()
+{
+ QTest::addColumn<QCryptographicHash::Algorithm>("algo");
+ QTest::addColumn<QByteArray>("key");
+ QTest::addColumn<QByteArray>("message");
+ QTest::addColumn<QByteArray>("code");
+
+ // Empty values
+ QTest::newRow("md5-empty") << QCryptographicHash::Md5
+ << QByteArray()
+ << QByteArray()
+ << QByteArray::fromHex("74e6f7298a9c2d168935f58c001bad88");
+ QTest::newRow("sha1-empty") << QCryptographicHash::Sha1
+ << QByteArray()
+ << QByteArray()
+ << QByteArray::fromHex("fbdb1d1b18aa6c08324b7d64b71fb76370690e1d");
+ QTest::newRow("sha256-empty") << QCryptographicHash::Sha256
+ << QByteArray()
+ << QByteArray()
+ << QByteArray::fromHex("b613679a0814d9ec772f95d778c35fc5ff1697c493715653c6c712144292c5ad");
+
+ // Some not-empty
+ QTest::newRow("md5") << QCryptographicHash::Md5
+ << QByteArray("key")
+ << QByteArray("The quick brown fox jumps over the lazy dog")
+ << QByteArray::fromHex("80070713463e7749b90c2dc24911e275");
+ QTest::newRow("sha1") << QCryptographicHash::Sha1
+ << QByteArray("key")
+ << QByteArray("The quick brown fox jumps over the lazy dog")
+ << QByteArray::fromHex("de7c9b85b8b78aa6bc8a7a36f70a90701c9db4d9");
+ QTest::newRow("sha256") << QCryptographicHash::Sha256
+ << QByteArray("key")
+ << QByteArray("The quick brown fox jumps over the lazy dog")
+ << QByteArray::fromHex("f7bc83f430538424b13298e6aa6fb143ef4d59a14946175997479dbc2d1a3cd8");
+
+ // Some from rfc-2104
+ QTest::newRow("rfc-md5-1") << QCryptographicHash::Md5
+ << QByteArray::fromHex("0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b0b")
+ << QByteArray("Hi There")
+ << QByteArray::fromHex("9294727a3638bb1c13f48ef8158bfc9d");
+ QTest::newRow("rfc-md5-2") << QCryptographicHash::Md5
+ << QByteArray("Jefe")
+ << QByteArray("what do ya want for nothing?")
+ << QByteArray::fromHex("750c783e6ab0b503eaa86e310a5db738");
+ QTest::newRow("rfc-md5-3") << QCryptographicHash::Md5
+ << QByteArray::fromHex("AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA")
+ << QByteArray(50, 0xdd)
+ << QByteArray::fromHex("56be34521d144c88dbb8c733f0e8b3f6");
+}
+
+void tst_QMessageAuthenticationCode::result()
+{
+ QFETCH(QCryptographicHash::Algorithm, algo);
+ QFETCH(QByteArray, key);
+ QFETCH(QByteArray, message);
+ QFETCH(QByteArray, code);
+
+ QMessageAuthenticationCode mac(algo);
+ mac.setKey(key);
+ mac.addData(message);
+ QByteArray result = mac.result();
+
+ QCOMPARE(result, code);
+}
+
+void tst_QMessageAuthenticationCode::result_incremental_data()
+{
+ result_data();
+}
+
+void tst_QMessageAuthenticationCode::result_incremental()
+{
+ QFETCH(QCryptographicHash::Algorithm, algo);
+ QFETCH(QByteArray, key);
+ QFETCH(QByteArray, message);
+ QFETCH(QByteArray, code);
+
+ int index = message.length() / 2;
+ QByteArray leftPart(message.mid(0, index));
+ QByteArray rightPart(message.mid(index));
+
+ QCOMPARE(leftPart + rightPart, message);
+
+ QMessageAuthenticationCode mac(algo);
+ mac.setKey(key);
+ mac.addData(leftPart);
+ mac.addData(rightPart);
+ QByteArray result = mac.result();
+
+ QCOMPARE(result, code);
+}
+
+QTEST_MAIN(tst_QMessageAuthenticationCode)
+#include "tst_qmessageauthenticationcode.moc"
diff --git a/tests/auto/corelib/tools/qrect/tst_qrect.cpp b/tests/auto/corelib/tools/qrect/tst_qrect.cpp
index 7772a8aa1e..a5f2fa73da 100644
--- a/tests/auto/corelib/tools/qrect/tst_qrect.cpp
+++ b/tests/auto/corelib/tools/qrect/tst_qrect.cpp
@@ -41,6 +41,7 @@
#include <QtTest/QtTest>
#include <qrect.h>
+#include <qmargins.h>
#include <limits.h>
#include <qdebug.h>
@@ -133,6 +134,7 @@ private slots:
void newMoveTopLeft();
void newMoveBottomRight_data();
void newMoveBottomRight();
+ void margins();
void translate_data();
void translate();
@@ -3484,6 +3486,25 @@ void tst_QRect::newMoveBottomRight()
QCOMPARE(r,nr);
}
+void tst_QRect::margins()
+{
+ const QRect rectangle = QRect(QPoint(10, 10), QSize(50 ,50));
+ const QMargins margins = QMargins(2, 3, 4, 5);
+
+ const QRect added = rectangle + margins;
+ QCOMPARE(added, QRect(QPoint(8, 7), QSize(56, 58)));
+ QCOMPARE(added, margins + rectangle);
+ QCOMPARE(added, rectangle.marginsAdded(margins));
+
+ QRect a = rectangle;
+ a += margins;
+ QCOMPARE(added, a);
+
+ a = rectangle;
+ a -= margins;
+ QCOMPARE(a, QRect(QPoint(12, 13), QSize(44, 42)));
+ QCOMPARE(a, rectangle.marginsRemoved(margins));
+}
void tst_QRect::translate_data()
{
diff --git a/tests/auto/corelib/tools/qregularexpression/tst_qregularexpression.cpp b/tests/auto/corelib/tools/qregularexpression/tst_qregularexpression.cpp
index 7073805db4..139f831b3d 100644
--- a/tests/auto/corelib/tools/qregularexpression/tst_qregularexpression.cpp
+++ b/tests/auto/corelib/tools/qregularexpression/tst_qregularexpression.cpp
@@ -126,8 +126,6 @@ bool operator!=(const Match &m, const QRegularExpressionMatch &rem)
bool operator==(const QRegularExpressionMatchIterator &iterator, const QList<Match> &expectedMatchList)
{
QRegularExpressionMatchIterator i = iterator;
- if (i.isValid() != (!expectedMatchList.isEmpty()))
- return false;
foreach (const Match &expectedMatch, expectedMatchList)
{
@@ -293,6 +291,31 @@ void tst_QRegularExpression::provideRegularExpressions()
| QRegularExpression::InvertedGreedinessOption);
}
+void tst_QRegularExpression::defaultConstructors()
+{
+ QRegularExpression re;
+ QCOMPARE(re.pattern(), QString());
+ QCOMPARE(re.patternOptions(), QRegularExpression::NoPatternOption);
+
+ QRegularExpressionMatch match;
+ QCOMPARE(match.regularExpression(), QRegularExpression());
+ QCOMPARE(match.regularExpression(), re);
+ QCOMPARE(match.matchType(), QRegularExpression::NoMatch);
+ QCOMPARE(match.matchOptions(), QRegularExpression::NoMatchOption);
+ QCOMPARE(match.hasMatch(), false);
+ QCOMPARE(match.hasPartialMatch(), false);
+ QCOMPARE(match.isValid(), true);
+ QCOMPARE(match.lastCapturedIndex(), -1);
+
+ QRegularExpressionMatchIterator iterator;
+ QCOMPARE(iterator.regularExpression(), QRegularExpression());
+ QCOMPARE(iterator.regularExpression(), re);
+ QCOMPARE(iterator.matchType(), QRegularExpression::NoMatch);
+ QCOMPARE(iterator.matchOptions(), QRegularExpression::NoMatchOption);
+ QCOMPARE(iterator.isValid(), true);
+ QCOMPARE(iterator.hasNext(), false);
+}
+
void tst_QRegularExpression::gettersSetters_data()
{
provideRegularExpressions();
@@ -693,12 +716,31 @@ void tst_QRegularExpression::normalMatch()
QFETCH(QRegularExpression::MatchOptions, matchOptions);
QFETCH(Match, match);
- QRegularExpressionMatch m = regexp.match(subject, offset, QRegularExpression::NormalMatch, matchOptions);
- consistencyCheck(m);
- QVERIFY(m == match);
+ {
+ QRegularExpressionMatch m = regexp.match(subject, offset, QRegularExpression::NormalMatch, matchOptions);
+ consistencyCheck(m);
+ QVERIFY(m == match);
+ QCOMPARE(m.regularExpression(), regexp);
+ QCOMPARE(m.matchType(), QRegularExpression::NormalMatch);
+ QCOMPARE(m.matchOptions(), matchOptions);
+ }
+ {
+ // ignore the expected results provided by the match object --
+ // we'll never get any result when testing the NoMatch type.
+ // Just check the validity of the match here.
+ Match realMatch;
+ realMatch.clear();
+ realMatch.isValid = match.isValid;
+
+ QRegularExpressionMatch m = regexp.match(subject, offset, QRegularExpression::NoMatch, matchOptions);
+ consistencyCheck(m);
+ QVERIFY(m == realMatch);
+ QCOMPARE(m.regularExpression(), regexp);
+ QCOMPARE(m.matchType(), QRegularExpression::NoMatch);
+ QCOMPARE(m.matchOptions(), matchOptions);
+ }
}
-
void tst_QRegularExpression::partialMatch_data()
{
QTest::addColumn<QRegularExpression>("regexp");
@@ -952,9 +994,29 @@ void tst_QRegularExpression::partialMatch()
QFETCH(QRegularExpression::MatchOptions, matchOptions);
QFETCH(Match, match);
- QRegularExpressionMatch m = regexp.match(subject, offset, matchType, matchOptions);
- consistencyCheck(m);
- QVERIFY(m == match);
+ {
+ QRegularExpressionMatch m = regexp.match(subject, offset, matchType, matchOptions);
+ consistencyCheck(m);
+ QVERIFY(m == match);
+ QCOMPARE(m.regularExpression(), regexp);
+ QCOMPARE(m.matchType(), matchType);
+ QCOMPARE(m.matchOptions(), matchOptions);
+ }
+ {
+ // ignore the expected results provided by the match object --
+ // we'll never get any result when testing the NoMatch type.
+ // Just check the validity of the match here.
+ Match realMatch;
+ realMatch.clear();
+ realMatch.isValid = match.isValid;
+
+ QRegularExpressionMatch m = regexp.match(subject, offset, QRegularExpression::NoMatch, matchOptions);
+ consistencyCheck(m);
+ QVERIFY(m == realMatch);
+ QCOMPARE(m.regularExpression(), regexp);
+ QCOMPARE(m.matchType(), QRegularExpression::NoMatch);
+ QCOMPARE(m.matchOptions(), matchOptions);
+ }
}
void tst_QRegularExpression::globalMatch_data()
@@ -1223,10 +1285,28 @@ void tst_QRegularExpression::globalMatch()
QFETCH(QRegularExpression::MatchType, matchType);
QFETCH(QRegularExpression::MatchOptions, matchOptions);
QFETCH(QList<Match>, matchList);
+ {
+ QRegularExpressionMatchIterator iterator = regexp.globalMatch(subject, offset, matchType, matchOptions);
+ consistencyCheck(iterator);
+ QVERIFY(iterator == matchList);
+ QCOMPARE(iterator.regularExpression(), regexp);
+ QCOMPARE(iterator.matchType(), matchType);
+ QCOMPARE(iterator.matchOptions(), matchOptions);
+ }
+ {
+ // ignore the expected results provided by the match object --
+ // we'll never get any result when testing the NoMatch type.
+ // Just check the validity of the match here.
+ QList<Match> realMatchList;
+
+ QRegularExpressionMatchIterator iterator = regexp.globalMatch(subject, offset, QRegularExpression::NoMatch, matchOptions);
+ consistencyCheck(iterator);
+ QVERIFY(iterator == realMatchList);
+ QCOMPARE(iterator.regularExpression(), regexp);
+ QCOMPARE(iterator.matchType(), QRegularExpression::NoMatch);
+ QCOMPARE(iterator.matchOptions(), matchOptions);
+ }
- QRegularExpressionMatchIterator iterator = regexp.globalMatch(subject, offset, matchType, matchOptions);
- consistencyCheck(iterator);
- QVERIFY(iterator == matchList);
}
void tst_QRegularExpression::serialize_data()
diff --git a/tests/auto/corelib/tools/qregularexpression/tst_qregularexpression.h b/tests/auto/corelib/tools/qregularexpression/tst_qregularexpression.h
index d6f9312411..6df7b80ac4 100644
--- a/tests/auto/corelib/tools/qregularexpression/tst_qregularexpression.h
+++ b/tests/auto/corelib/tools/qregularexpression/tst_qregularexpression.h
@@ -51,6 +51,7 @@ class tst_QRegularExpression : public QObject
Q_OBJECT
private slots:
+ void defaultConstructors();
void gettersSetters_data();
void gettersSetters();
void escape_data();
diff --git a/tests/auto/corelib/tools/qsharedpointer/tst_qsharedpointer.cpp b/tests/auto/corelib/tools/qsharedpointer/tst_qsharedpointer.cpp
index f9fffaa71c..086f0b49ca 100644
--- a/tests/auto/corelib/tools/qsharedpointer/tst_qsharedpointer.cpp
+++ b/tests/auto/corelib/tools/qsharedpointer/tst_qsharedpointer.cpp
@@ -97,6 +97,7 @@ private slots:
void lambdaCustomDeleter();
#endif
void creating();
+ void creatingVariadic();
void creatingQObject();
void mixTrackingPointerCode();
void reentrancyWhileDestructing();
@@ -176,6 +177,49 @@ public:
int Data::generationCounter = 0;
int Data::destructorCounter = 0;
+struct NoDefaultConstructor1
+{
+ int i;
+ NoDefaultConstructor1(int i) : i(i) {}
+ NoDefaultConstructor1(uint j) : i(j + 42) {}
+};
+
+struct NoDefaultConstructorRef1
+{
+ int &i;
+ NoDefaultConstructorRef1(int &i) : i(i) {}
+};
+
+struct NoDefaultConstructor2
+{
+ void *ptr;
+ int i;
+ NoDefaultConstructor2(void *ptr, int i) : ptr(ptr), i(i) {}
+};
+
+struct NoDefaultConstructorRef2
+{
+ QString str;
+ int i;
+ NoDefaultConstructorRef2(QString &str, int i) : str(str), i(i) {}
+};
+
+struct NoDefaultConstructorConstRef2
+{
+ QString str;
+ int i;
+ NoDefaultConstructorConstRef2(const QString &str, int i) : str(str), i(i) {}
+ NoDefaultConstructorConstRef2(const QByteArray &ba, int i = 42) : str(QString::fromLatin1(ba)), i(i) {}
+};
+
+#ifdef Q_COMPILER_RVALUE_REFS
+struct NoDefaultConstructorRRef1
+{
+ int &i;
+ NoDefaultConstructorRRef1(int &&i) : i(i) {}
+};
+#endif
+
void tst_QSharedPointer::basics_data()
{
QTest::addColumn<bool>("isNull");
@@ -1436,6 +1480,82 @@ void tst_QSharedPointer::creating()
safetyCheck();
}
+void tst_QSharedPointer::creatingVariadic()
+{
+#if !defined(Q_COMPILER_RVALUE_REFS) || !defined(Q_COMPILER_VARIADIC_TEMPLATES)
+ QSKIP("This compiler is not in C++11 mode or it doesn't support rvalue refs and variadic templates");
+#else
+ int i = 42;
+
+ {
+ NoDefaultConstructor1(1); // control check
+ QSharedPointer<NoDefaultConstructor1> ptr = QSharedPointer<NoDefaultConstructor1>::create(1);
+ QCOMPARE(ptr->i, 1);
+
+ NoDefaultConstructor1(0u); // control check
+ ptr = QSharedPointer<NoDefaultConstructor1>::create(0u);
+ QCOMPARE(ptr->i, 42);
+
+ NoDefaultConstructor1 x(i); // control check
+ ptr = QSharedPointer<NoDefaultConstructor1>::create(i);
+ QCOMPARE(ptr->i, i);
+ }
+ {
+ NoDefaultConstructor2((void*)0, 1); // control check
+ QSharedPointer<NoDefaultConstructor2> ptr = QSharedPointer<NoDefaultConstructor2>::create((void*)0, 1);
+ QCOMPARE(ptr->i, 1);
+ QCOMPARE(ptr->ptr, (void*)0);
+
+ int *null = 0;
+ NoDefaultConstructor2(null, 2); // control check
+ ptr = QSharedPointer<NoDefaultConstructor2>::create(null, 2);
+ QCOMPARE(ptr->i, 2);
+ QCOMPARE(ptr->ptr, (void*)0);
+
+#ifdef Q_COMPILER_NULLPTR
+ NoDefaultConstructor2(nullptr, 3); // control check
+ ptr = QSharedPointer<NoDefaultConstructor2>::create(nullptr, 3);
+ QCOMPARE(ptr->i, 3);
+ QCOMPARE(ptr->ptr, (void*)nullptr);
+#endif
+ }
+ {
+ NoDefaultConstructorRef1 x(i); // control check
+ QSharedPointer<NoDefaultConstructorRef1> ptr = QSharedPointer<NoDefaultConstructorRef1>::create(i);
+ QCOMPARE(ptr->i, i);
+ QCOMPARE(&ptr->i, &i);
+ }
+ {
+ NoDefaultConstructorRRef1(1); // control check
+ QSharedPointer<NoDefaultConstructorRRef1> ptr = QSharedPointer<NoDefaultConstructorRRef1>::create(1);
+ QCOMPARE(ptr->i, 1);
+
+ NoDefaultConstructorRRef1(std::move(i)); // control check
+ ptr = QSharedPointer<NoDefaultConstructorRRef1>::create(std::move(i));
+ QCOMPARE(ptr->i, i);
+ }
+ {
+ QString text("Hello, World");
+ NoDefaultConstructorRef2(text, 1); // control check
+ QSharedPointer<NoDefaultConstructorRef2> ptr = QSharedPointer<NoDefaultConstructorRef2>::create(text, 1);
+ QCOMPARE(ptr->str, text);
+ QCOMPARE(ptr->i, 1);
+ }
+ {
+ QSharedPointer<NoDefaultConstructorConstRef2> ptr;
+ NoDefaultConstructorConstRef2(QLatin1String("string"), 1); // control check
+ ptr = QSharedPointer<NoDefaultConstructorConstRef2>::create(QLatin1String("string"), 1);
+ QCOMPARE(ptr->str, QString("string"));
+ QCOMPARE(ptr->i, 1);
+
+ NoDefaultConstructorConstRef2(QByteArray("bytearray")); // control check
+ ptr = QSharedPointer<NoDefaultConstructorConstRef2>::create(QByteArray("bytearray"));
+ QCOMPARE(ptr->str, QString("bytearray"));
+ QCOMPARE(ptr->i, 42);
+ }
+#endif
+}
+
void tst_QSharedPointer::creatingQObject()
{
{
diff --git a/tests/auto/corelib/tools/qstring/tst_qstring.cpp b/tests/auto/corelib/tools/qstring/tst_qstring.cpp
index 740581ceec..24dfac8c01 100644
--- a/tests/auto/corelib/tools/qstring/tst_qstring.cpp
+++ b/tests/auto/corelib/tools/qstring/tst_qstring.cpp
@@ -1425,6 +1425,55 @@ void tst_QString::contains()
QVERIFY(a.contains(QRegularExpression("[FG][HI]")));
QVERIFY(a.contains(QRegularExpression("[G][HE]")));
+ {
+ QRegularExpressionMatch match;
+ QVERIFY(!match.hasMatch());
+
+ QVERIFY(a.contains(QRegularExpression("[FG][HI]"), &match));
+ QVERIFY(match.hasMatch());
+ QCOMPARE(match.capturedStart(), 6);
+ QCOMPARE(match.capturedEnd(), 8);
+ QCOMPARE(match.captured(), QStringLiteral("GH"));
+
+ QVERIFY(a.contains(QRegularExpression("[G][HE]"), &match));
+ QVERIFY(match.hasMatch());
+ QCOMPARE(match.capturedStart(), 6);
+ QCOMPARE(match.capturedEnd(), 8);
+ QCOMPARE(match.captured(), QStringLiteral("GH"));
+
+ QVERIFY(a.contains(QRegularExpression("[f](.*)[FG]"), &match));
+ QVERIFY(match.hasMatch());
+ QCOMPARE(match.capturedStart(), 10);
+ QCOMPARE(match.capturedEnd(), 15);
+ QCOMPARE(match.captured(), QString("fGEFG"));
+ QCOMPARE(match.capturedStart(1), 11);
+ QCOMPARE(match.capturedEnd(1), 14);
+ QCOMPARE(match.captured(1), QStringLiteral("GEF"));
+
+ QVERIFY(a.contains(QRegularExpression("[f](.*)[F]"), &match));
+ QVERIFY(match.hasMatch());
+ QCOMPARE(match.capturedStart(), 10);
+ QCOMPARE(match.capturedEnd(), 14);
+ QCOMPARE(match.captured(), QString("fGEF"));
+ QCOMPARE(match.capturedStart(1), 11);
+ QCOMPARE(match.capturedEnd(1), 13);
+ QCOMPARE(match.captured(1), QStringLiteral("GE"));
+
+ QVERIFY(!a.contains(QRegularExpression("ZZZ"), &match));
+ // doesn't match, but ensure match didn't change
+ QVERIFY(match.hasMatch());
+ QCOMPARE(match.capturedStart(), 10);
+ QCOMPARE(match.capturedEnd(), 14);
+ QCOMPARE(match.captured(), QStringLiteral("fGEF"));
+ QCOMPARE(match.capturedStart(1), 11);
+ QCOMPARE(match.capturedEnd(1), 13);
+ QCOMPARE(match.captured(1), QStringLiteral("GE"));
+
+ // don't crash with a null pointer
+ QVERIFY(a.contains(QRegularExpression("[FG][HI]"), 0));
+ QVERIFY(!a.contains(QRegularExpression("ZZZ"), 0));
+ }
+
CREATE_REF(QLatin1String("FG"));
QVERIFY(a.contains(ref));
QVERIFY(a.contains(ref, Qt::CaseInsensitive));
diff --git a/tests/auto/corelib/tools/tools.pro b/tests/auto/corelib/tools/tools.pro
index 100409e58b..f8b2437d35 100644
--- a/tests/auto/corelib/tools/tools.pro
+++ b/tests/auto/corelib/tools/tools.pro
@@ -22,6 +22,7 @@ SUBDIRS=\
qlocale \
qmap \
qmargins \
+ qmessageauthenticationcode \
qpair \
qpoint \
qpointf \
diff --git a/tests/auto/dbus/qdbuspendingreply/tst_qdbuspendingreply.cpp b/tests/auto/dbus/qdbuspendingreply/tst_qdbuspendingreply.cpp
index e4863574e3..31b7e0dbce 100644
--- a/tests/auto/dbus/qdbuspendingreply/tst_qdbuspendingreply.cpp
+++ b/tests/auto/dbus/qdbuspendingreply/tst_qdbuspendingreply.cpp
@@ -572,6 +572,8 @@ void tst_QDBusPendingReply::errors()
QVERIFY(rint.isError());
error = rint.error();
VERIFY_ERROR(error);
+ int dummyint = rint;
+ QCOMPARE(dummyint, int());
QDBusPendingReply<int,int> rintint(iface->asyncCall("sendError"));
rintint.waitForFinished();
@@ -579,6 +581,9 @@ void tst_QDBusPendingReply::errors()
QVERIFY(rintint.isError());
error = rintint.error();
VERIFY_ERROR(error);
+ dummyint = rintint;
+ QCOMPARE(dummyint, int());
+ QCOMPARE(rintint.argumentAt<1>(), int());
QDBusPendingReply<QString> rstring(iface->asyncCall("sendError"));
rstring.waitForFinished();
@@ -586,6 +591,8 @@ void tst_QDBusPendingReply::errors()
QVERIFY(rstring.isError());
error = rstring.error();
VERIFY_ERROR(error);
+ QString dummystring = rstring;
+ QCOMPARE(dummystring, QString());
}
QTEST_MAIN(tst_QDBusPendingReply)
diff --git a/tests/auto/gui/image/qpixmap/tst_qpixmap.cpp b/tests/auto/gui/image/qpixmap/tst_qpixmap.cpp
index 576519e2ca..e204da059d 100644
--- a/tests/auto/gui/image/qpixmap/tst_qpixmap.cpp
+++ b/tests/auto/gui/image/qpixmap/tst_qpixmap.cpp
@@ -114,6 +114,7 @@ private slots:
void convertFromImageNoDetach();
void convertFromImageDetach();
+ void convertFromImageCacheKey();
#if defined(Q_OS_WIN)
void toWinHBITMAP_data();
@@ -779,6 +780,28 @@ void tst_QPixmap::convertFromImageDetach()
QVERIFY(copy.isDetached());
}
+void tst_QPixmap::convertFromImageCacheKey()
+{
+ QPixmap randomPixmap(10, 10);
+ if (randomPixmap.handle()->classId() != QPlatformPixmap::RasterClass)
+ QSKIP("Test only valid for raster pixmaps");
+
+ //first get the screen format
+ QImage::Format screenFormat = randomPixmap.toImage().format();
+ QVERIFY(screenFormat != QImage::Format_Invalid);
+
+ QImage orig(100,100, screenFormat);
+ orig.fill(0);
+
+ QPixmap pix = QPixmap::fromImage(orig);
+ QImage copy = pix.toImage();
+
+ QVERIFY(copy.format() == screenFormat);
+
+ QCOMPARE(orig.cacheKey(), pix.cacheKey());
+ QCOMPARE(copy.cacheKey(), pix.cacheKey());
+}
+
#if defined(Q_OS_WIN)
QT_BEGIN_NAMESPACE
diff --git a/tests/auto/gui/text/qfontmetrics/tst_qfontmetrics.cpp b/tests/auto/gui/text/qfontmetrics/tst_qfontmetrics.cpp
index b457e17b48..b0da1fdd5a 100644
--- a/tests/auto/gui/text/qfontmetrics/tst_qfontmetrics.cpp
+++ b/tests/auto/gui/text/qfontmetrics/tst_qfontmetrics.cpp
@@ -281,7 +281,7 @@ void tst_QFontMetrics::inFontUcs4()
}
{
- QFontEngine *engine = QFontPrivate::get(font)->engineForScript(QUnicodeTables::Common);
+ QFontEngine *engine = QFontPrivate::get(font)->engineForScript(QChar::Script_Common);
QGlyphLayout glyphs;
glyphs.numGlyphs = 3;
uint buf[3];
diff --git a/tests/auto/gui/util/qregularexpressionvalidator/.gitignore b/tests/auto/gui/util/qregularexpressionvalidator/.gitignore
new file mode 100644
index 0000000000..a4022144d5
--- /dev/null
+++ b/tests/auto/gui/util/qregularexpressionvalidator/.gitignore
@@ -0,0 +1 @@
+tst_qregularexpressionvalidator
diff --git a/tests/auto/gui/util/qregularexpressionvalidator/qregularexpressionvalidator.pro b/tests/auto/gui/util/qregularexpressionvalidator/qregularexpressionvalidator.pro
new file mode 100644
index 0000000000..1e8e50563e
--- /dev/null
+++ b/tests/auto/gui/util/qregularexpressionvalidator/qregularexpressionvalidator.pro
@@ -0,0 +1,4 @@
+CONFIG += testcase parallel_test
+TARGET = tst_qregularexpressionvalidator
+SOURCES += tst_qregularexpressionvalidator.cpp
+QT += testlib
diff --git a/tests/auto/gui/util/qregularexpressionvalidator/tst_qregularexpressionvalidator.cpp b/tests/auto/gui/util/qregularexpressionvalidator/tst_qregularexpressionvalidator.cpp
new file mode 100644
index 0000000000..61d26104bd
--- /dev/null
+++ b/tests/auto/gui/util/qregularexpressionvalidator/tst_qregularexpressionvalidator.cpp
@@ -0,0 +1,120 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
+** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/legal
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and Digia. For licensing terms and
+** conditions see http://qt.digia.com/licensing. For further information
+** use the contact form at http://qt.digia.com/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Digia gives you certain additional
+** rights. These rights are described in the Digia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 3.0 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU General Public License version 3.0 requirements will be
+** met: http://www.gnu.org/copyleft/gpl.html.
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtGui/QRegularExpressionValidator>
+#include <QtTest/QtTest>
+
+class tst_QRegularExpressionValidator : public QObject
+{
+ Q_OBJECT
+
+private slots:
+ void validate_data();
+ void validate();
+};
+
+Q_DECLARE_METATYPE(QValidator::State)
+
+void tst_QRegularExpressionValidator::validate_data()
+{
+ QTest::addColumn<QRegularExpression>("re");
+ QTest::addColumn<QString>("value");
+ QTest::addColumn<QValidator::State>("state");
+
+ QTest::newRow("data0") << QRegularExpression("[1-9]\\d{0,3}") << QString("0") << QValidator::Invalid;
+ QTest::newRow("data1") << QRegularExpression("[1-9]\\d{0,3}") << QString("12345") << QValidator::Invalid;
+ QTest::newRow("data2") << QRegularExpression("[1-9]\\d{0,3}") << QString("1") << QValidator::Acceptable;
+
+ QTest::newRow("data3") << QRegularExpression("\\S+") << QString("myfile.txt") << QValidator::Acceptable;
+ QTest::newRow("data4") << QRegularExpression("\\S+") << QString("my file.txt") << QValidator::Invalid;
+
+ QTest::newRow("data5") << QRegularExpression("[A-C]\\d{5}[W-Z]") << QString("a12345Z") << QValidator::Invalid;
+ QTest::newRow("data6") << QRegularExpression("[A-C]\\d{5}[W-Z]") << QString("A12345Z") << QValidator::Acceptable;
+ QTest::newRow("data7") << QRegularExpression("[A-C]\\d{5}[W-Z]") << QString("B12") << QValidator::Intermediate;
+
+ QTest::newRow("data8") << QRegularExpression("read\\S?me(\\.(txt|asc|1st))?") << QString("readme") << QValidator::Acceptable;
+ QTest::newRow("data9") << QRegularExpression("read\\S?me(\\.(txt|asc|1st))?") << QString("read me.txt") << QValidator::Invalid;
+ QTest::newRow("data10") << QRegularExpression("read\\S?me(\\.(txt|asc|1st))?") << QString("readm") << QValidator::Intermediate;
+
+ QTest::newRow("data11") << QRegularExpression("read\\S?me(\\.(txt|asc|1st))?") << QString("read me.txt") << QValidator::Invalid;
+ QTest::newRow("data12") << QRegularExpression("read\\S?me(\\.(txt|asc|1st))?") << QString("readm") << QValidator::Intermediate;
+
+ QTest::newRow("data13") << QRegularExpression("\\w\\d\\d") << QString("A57") << QValidator::Acceptable;
+ QTest::newRow("data14") << QRegularExpression("\\w\\d\\d") << QString("E5") << QValidator::Intermediate;
+ QTest::newRow("data15") << QRegularExpression("\\w\\d\\d") << QString("+9") << QValidator::Invalid;
+
+ QTest::newRow("empty01") << QRegularExpression() << QString() << QValidator::Acceptable;
+ QTest::newRow("empty02") << QRegularExpression() << QString("test") << QValidator::Acceptable;
+}
+
+void tst_QRegularExpressionValidator::validate()
+{
+ QFETCH(QRegularExpression, re);
+ QFETCH(QString, value);
+
+ QRegularExpressionValidator rv;
+
+ // setting the same regexp won't emit signals
+ const int signalCount = (rv.regularExpression() == re) ? 0 : 1;
+
+ QSignalSpy spy(&rv, SIGNAL(regularExpressionChanged(QRegularExpression)));
+ QSignalSpy changedSpy(&rv, SIGNAL(changed()));
+
+ rv.setRegularExpression(re);
+ QCOMPARE(rv.regularExpression(), re);
+
+ int pos = -1;
+ QValidator::State result = rv.validate(value, pos);
+
+ QTEST(result, "state");
+ if (result == QValidator::Invalid)
+ QCOMPARE(pos, value.length());
+ else
+ QCOMPARE(pos, -1); // ensure pos is not modified if validate returned Acceptable or Intermediate
+
+ QCOMPARE(spy.count(), signalCount);
+ QCOMPARE(changedSpy.count(), signalCount);
+}
+
+QTEST_GUILESS_MAIN(tst_QRegularExpressionValidator)
+
+#include "tst_qregularexpressionvalidator.moc"
diff --git a/tests/auto/gui/util/util.pro b/tests/auto/gui/util/util.pro
index a0963980c9..f2c4515dc2 100644
--- a/tests/auto/gui/util/util.pro
+++ b/tests/auto/gui/util/util.pro
@@ -4,4 +4,5 @@ SUBDIRS= \
qdoublevalidator \
qintvalidator \
qregexpvalidator \
+ qregularexpressionvalidator \
diff --git a/tests/auto/other/qaccessibility/tst_qaccessibility.cpp b/tests/auto/other/qaccessibility/tst_qaccessibility.cpp
index acb072bf6d..da727be3a4 100644
--- a/tests/auto/other/qaccessibility/tst_qaccessibility.cpp
+++ b/tests/auto/other/qaccessibility/tst_qaccessibility.cpp
@@ -2690,6 +2690,76 @@ void tst_QAccessibility::tableTest()
QCOMPARE(table2->rowDescription(1), QString("v2"));
QCOMPARE(table2->rowDescription(2), QString("v3"));
+ tableView->clearSelection();
+ tableView->setSelectionBehavior(QAbstractItemView::SelectItems);
+ tableView->setSelectionMode(QAbstractItemView::SingleSelection);
+ QVERIFY(!table2->selectRow(0));
+ QVERIFY(!table2->isRowSelected(0));
+ tableView->setSelectionBehavior(QAbstractItemView::SelectRows);
+ QVERIFY(table2->selectRow(0));
+ QVERIFY(table2->selectRow(1));
+ QVERIFY(!table2->isRowSelected(0));
+ tableView->setSelectionMode(QAbstractItemView::MultiSelection);
+ QVERIFY(table2->selectRow(0));
+ QVERIFY(table2->isRowSelected(1));
+ QVERIFY(table2->unselectRow(0));
+ QVERIFY(!table2->isRowSelected(0));
+ tableView->setSelectionBehavior(QAbstractItemView::SelectColumns);
+ QVERIFY(!table2->selectRow(0));
+ QVERIFY(!table2->isRowSelected(0));
+ tableView->clearSelection();
+ QCOMPARE(table2->selectedColumnCount(), 0);
+ QCOMPARE(table2->selectedRowCount(), 0);
+ QVERIFY(table2->selectColumn(1));
+ QVERIFY(table2->isColumnSelected(1));
+ tableView->clearSelection();
+ tableView->setSelectionMode(QAbstractItemView::ContiguousSelection);
+ table2->selectColumn(0);
+ table2->selectColumn(2);
+ QVERIFY(!(table2->isColumnSelected(2) && table2->isColumnSelected(0)));
+ tableView->clearSelection();
+ tableView->setSelectionBehavior(QAbstractItemView::SelectItems);
+ tableView->setSelectionMode(QAbstractItemView::MultiSelection);
+ table2->selectColumn(1);
+ table2->selectRow(1);
+ QVERIFY(table2->isColumnSelected(1));
+ QVERIFY(table2->isRowSelected(1));
+
+ QAIPtr cell4(table2->cellAt(2,2));
+ QVERIFY(cell1->actionInterface());
+ QVERIFY(cell1->tableCellInterface());
+
+ tableView->clearSelection();
+ tableView->setSelectionBehavior(QAbstractItemView::SelectRows);
+ tableView->setSelectionMode(QAbstractItemView::SingleSelection);
+ QVERIFY(!cell1->tableCellInterface()->isSelected());
+ QVERIFY(cell1->actionInterface()->actionNames().contains(QAccessibleActionInterface::toggleAction()));
+ cell1->actionInterface()->doAction(QAccessibleActionInterface::toggleAction());
+ QVERIFY(cell2->tableCellInterface()->isSelected());
+
+ tableView->clearSelection();
+ tableView->setSelectionBehavior(QAbstractItemView::SelectColumns);
+ cell3->actionInterface()->doAction(QAccessibleActionInterface::toggleAction());
+ QVERIFY(cell4->tableCellInterface()->isSelected());
+
+ tableView->clearSelection();
+ tableView->setSelectionBehavior(QAbstractItemView::SelectItems);
+ tableView->setSelectionMode(QAbstractItemView::SingleSelection);
+ cell1->actionInterface()->doAction(QAccessibleActionInterface::toggleAction());
+ QVERIFY(cell1->tableCellInterface()->isSelected());
+ cell2->actionInterface()->doAction(QAccessibleActionInterface::toggleAction());
+ QVERIFY(!cell1->tableCellInterface()->isSelected());
+
+ tableView->clearSelection();
+ tableView->setSelectionMode(QAbstractItemView::MultiSelection);
+ cell1->actionInterface()->doAction(QAccessibleActionInterface::toggleAction());
+ cell2->actionInterface()->doAction(QAccessibleActionInterface::toggleAction());
+ QVERIFY(cell1->tableCellInterface()->isSelected());
+ QVERIFY(cell2->tableCellInterface()->isSelected());
+ cell2->actionInterface()->doAction(QAccessibleActionInterface::toggleAction());
+ QVERIFY(cell1->tableCellInterface()->isSelected());
+ QVERIFY(!cell2->tableCellInterface()->isSelected());
+
delete tableView;
QTestAccessibility::clearEvents();
diff --git a/tests/auto/tools/moc/tst_moc.cpp b/tests/auto/tools/moc/tst_moc.cpp
index e3ed473978..76607ccf4e 100644
--- a/tests/auto/tools/moc/tst_moc.cpp
+++ b/tests/auto/tools/moc/tst_moc.cpp
@@ -553,6 +553,7 @@ private slots:
void explicitOverrideControl();
void autoPropertyMetaTypeRegistration();
void autoMethodArgumentMetaTypeRegistration();
+ void autoSignalSpyMetaTypeRegistration();
void parseDefines();
void preprocessorOnly();
@@ -2388,6 +2389,7 @@ struct CustomObject8 {};
struct CustomObject9 {};
struct CustomObject10 {};
struct CustomObject11 {};
+struct CustomObject12 {};
Q_DECLARE_METATYPE(CustomObject3)
Q_DECLARE_METATYPE(CustomObject4)
@@ -2398,6 +2400,7 @@ Q_DECLARE_METATYPE(CustomObject8)
Q_DECLARE_METATYPE(CustomObject9)
Q_DECLARE_METATYPE(CustomObject10)
Q_DECLARE_METATYPE(CustomObject11)
+Q_DECLARE_METATYPE(CustomObject12)
class AutoRegistrationObject : public QObject
{
@@ -2520,6 +2523,9 @@ public slots:
void ref2(QList<int>&) {}
void ref3(CustomQObject2&) {}
void ref4(QSharedPointer<CustomQObject2>&) {}
+
+signals:
+ void someSignal(CustomObject12);
};
void tst_Moc::autoPropertyMetaTypeRegistration()
@@ -2583,6 +2589,16 @@ void tst_Moc::autoMethodArgumentMetaTypeRegistration()
int i = metaObject->methodOffset(); // Start after QObject built-in slots;
+ while (i < metaObject->methodCount()) {
+ // Skip over signals so we start at the first slot.
+ const QMetaMethod method = metaObject->method(i);
+ if (method.methodType() == QMetaMethod::Signal)
+ ++i;
+ else
+ break;
+
+ }
+
#define TYPE_LOOP(TYPE) \
{ \
const QMetaMethod method = metaObject->method(i); \
@@ -2709,6 +2725,26 @@ void tst_Moc::autoMethodArgumentMetaTypeRegistration()
}
+void tst_Moc::autoSignalSpyMetaTypeRegistration()
+{
+ AutoRegistrationObject aro;
+
+ QVector<int> methodArgMetaTypeIds;
+
+ const QMetaObject *metaObject = aro.metaObject();
+
+ int i = metaObject->indexOfSignal(QMetaObject::normalizedSignature("someSignal(CustomObject12)"));
+
+ QVERIFY(i > 0);
+
+ QCOMPARE(QMetaType::type("CustomObject12"), (int)QMetaType::UnknownType);
+
+ QSignalSpy spy(&aro, SIGNAL(someSignal(CustomObject12)));
+
+ QVERIFY(QMetaType::type("CustomObject12") != QMetaType::UnknownType);
+ QCOMPARE(QMetaType::type("CustomObject12"), qMetaTypeId<CustomObject12>());
+}
+
void tst_Moc::parseDefines()
{
const QMetaObject *mo = &PD_NAMESPACE::PD_CLASSNAME::staticMetaObject;
diff --git a/tests/auto/widgets/graphicsview/qgraphicsitem/tst_qgraphicsitem.cpp b/tests/auto/widgets/graphicsview/qgraphicsitem/tst_qgraphicsitem.cpp
index b1411ea618..0d48789a7a 100644
--- a/tests/auto/widgets/graphicsview/qgraphicsitem/tst_qgraphicsitem.cpp
+++ b/tests/auto/widgets/graphicsview/qgraphicsitem/tst_qgraphicsitem.cpp
@@ -424,6 +424,7 @@ private slots:
void activate();
void setActivePanelOnInactiveScene();
void activationOnShowHide();
+ void deactivateInactivePanel();
void moveWhileDeleting();
void ensureDirtySceneTransform();
void focusScope();
@@ -2203,7 +2204,6 @@ void tst_QGraphicsItem::sceneMatrix()
void tst_QGraphicsItem::setMatrix()
{
QGraphicsScene scene;
- qRegisterMetaType<QList<QRectF> >("QList<QRectF>");
QSignalSpy spy(&scene, SIGNAL(changed(QList<QRectF>)));
QRectF unrotatedRect(-12, -34, 56, 78);
QGraphicsRectItem item(unrotatedRect, 0);
@@ -9029,6 +9029,40 @@ public:
}
};
+void tst_QGraphicsItem::deactivateInactivePanel()
+{
+ QGraphicsScene scene;
+ QGraphicsItem *panel1 = scene.addRect(QRectF(0, 0, 10, 10));
+ panel1->setFlag(QGraphicsItem::ItemIsPanel);
+
+ QGraphicsItem *panel2 = scene.addRect(QRectF(0, 0, 10, 10));
+ panel2->setFlag(QGraphicsItem::ItemIsPanel);
+
+ QEvent event(QEvent::WindowActivate);
+ qApp->sendEvent(&scene, &event);
+
+ panel1->setActive(true);
+ QVERIFY(scene.isActive());
+ QVERIFY(panel1->isActive());
+ QVERIFY(!panel2->isActive());
+ QCOMPARE(scene.activePanel(), panel1);
+
+ panel2->setActive(true);
+ QVERIFY(panel2->isActive());
+ QVERIFY(!panel1->isActive());
+ QCOMPARE(scene.activePanel(), panel2);
+
+ panel2->setActive(false);
+ QVERIFY(panel1->isActive());
+ QVERIFY(!panel2->isActive());
+ QCOMPARE(scene.activePanel(), panel1);
+
+ panel2->setActive(false);
+ QVERIFY(panel1->isActive());
+ QVERIFY(!panel2->isActive());
+ QCOMPARE(scene.activePanel(), panel1);
+}
+
void tst_QGraphicsItem::moveWhileDeleting()
{
QGraphicsScene scene;
@@ -10276,23 +10310,24 @@ void tst_QGraphicsItem::modality_clickFocus()
EventSpy2 rect1Spy(&scene, rect1);
EventSpy2 rect2Spy(&scene, rect2);
- // activate rect1, it should not get focus
+ // activate rect1, it should get focus
rect1->setActive(true);
- QCOMPARE(scene.focusItem(), (QGraphicsItem *) 0);
+ QCOMPARE(scene.focusItem(), (QGraphicsItem *) rect1);
- // focus stays unset when rect2 becomes modal
+ // focus stays when rect2 becomes modal
rect2->setPanelModality(QGraphicsItem::SceneModal);
- QCOMPARE(scene.focusItem(), (QGraphicsItem *) 0);
- QCOMPARE(rect1Spy.counts[QEvent::FocusIn], 0);
+ QCOMPARE(scene.focusItem(), (QGraphicsItem *) rect1);
+ QCOMPARE(rect1Spy.counts[QEvent::FocusIn], 1);
QCOMPARE(rect1Spy.counts[QEvent::FocusOut], 0);
QCOMPARE(rect2Spy.counts[QEvent::FocusIn], 0);
QCOMPARE(rect2Spy.counts[QEvent::FocusOut], 0);
// clicking on rect1 should not set it's focus item
+ rect1->clearFocus();
sendMouseClick(&scene, QPointF(-25, -25));
QCOMPARE(rect1->focusItem(), (QGraphicsItem *) 0);
- QCOMPARE(rect1Spy.counts[QEvent::FocusIn], 0);
- QCOMPARE(rect1Spy.counts[QEvent::FocusOut], 0);
+ QCOMPARE(rect1Spy.counts[QEvent::FocusIn], 1);
+ QCOMPARE(rect1Spy.counts[QEvent::FocusOut], 1);
QCOMPARE(rect2Spy.counts[QEvent::FocusIn], 0);
QCOMPARE(rect2Spy.counts[QEvent::FocusOut], 0);
@@ -10300,33 +10335,34 @@ void tst_QGraphicsItem::modality_clickFocus()
rect2->setActive(true);
sendMouseClick(&scene, QPointF(75, 75));
QCOMPARE(scene.focusItem(), (QGraphicsItem *) rect2);
- QCOMPARE(rect1Spy.counts[QEvent::FocusIn], 0);
- QCOMPARE(rect1Spy.counts[QEvent::FocusOut], 0);
+ QCOMPARE(rect1Spy.counts[QEvent::FocusIn], 1);
+ QCOMPARE(rect1Spy.counts[QEvent::FocusOut], 1);
QCOMPARE(rect2Spy.counts[QEvent::FocusIn], 1);
QCOMPARE(rect2Spy.counts[QEvent::FocusOut], 0);
// clicking on rect1 does *not* give it focus
rect1->setActive(true);
+ rect1->clearFocus();
sendMouseClick(&scene, QPointF(-25, -25));
QCOMPARE(scene.focusItem(), (QGraphicsItem *) 0);
- QCOMPARE(rect1Spy.counts[QEvent::FocusIn], 0);
- QCOMPARE(rect1Spy.counts[QEvent::FocusOut], 0);
+ QCOMPARE(rect1Spy.counts[QEvent::FocusIn], 2);
+ QCOMPARE(rect1Spy.counts[QEvent::FocusOut], 2);
QCOMPARE(rect2Spy.counts[QEvent::FocusIn], 1);
QCOMPARE(rect2Spy.counts[QEvent::FocusOut], 1);
// focus doesn't change when leaving modality either
rect2->setPanelModality(QGraphicsItem::NonModal);
QCOMPARE(scene.focusItem(), (QGraphicsItem *) 0);
- QCOMPARE(rect1Spy.counts[QEvent::FocusIn], 0);
- QCOMPARE(rect1Spy.counts[QEvent::FocusOut], 0);
+ QCOMPARE(rect1Spy.counts[QEvent::FocusIn], 2);
+ QCOMPARE(rect1Spy.counts[QEvent::FocusOut], 2);
QCOMPARE(rect2Spy.counts[QEvent::FocusIn], 1);
QCOMPARE(rect2Spy.counts[QEvent::FocusOut], 1);
// click on rect1, it should get focus now
sendMouseClick(&scene, QPointF(-25, -25));
QCOMPARE(scene.focusItem(), (QGraphicsItem *) rect1);
- QCOMPARE(rect1Spy.counts[QEvent::FocusIn], 1);
- QCOMPARE(rect1Spy.counts[QEvent::FocusOut], 0);
+ QCOMPARE(rect1Spy.counts[QEvent::FocusIn], 3);
+ QCOMPARE(rect1Spy.counts[QEvent::FocusOut], 2);
QCOMPARE(rect2Spy.counts[QEvent::FocusIn], 1);
QCOMPARE(rect2Spy.counts[QEvent::FocusOut], 1);
}
diff --git a/tests/auto/widgets/graphicsview/qgraphicsscene/tst_qgraphicsscene.cpp b/tests/auto/widgets/graphicsview/qgraphicsscene/tst_qgraphicsscene.cpp
index af21e88598..4730bada0e 100644
--- a/tests/auto/widgets/graphicsview/qgraphicsscene/tst_qgraphicsscene.cpp
+++ b/tests/auto/widgets/graphicsview/qgraphicsscene/tst_qgraphicsscene.cpp
@@ -266,6 +266,7 @@ private slots:
void siblingIndexAlwaysValid();
void removeFullyTransparentItem();
void zeroScale();
+ void focusItemChangedSignal();
// task specific tests below me
void task139710_bspTreeCrash();
@@ -3883,11 +3884,11 @@ void tst_QGraphicsScene::initialFocus_data()
QTest::addColumn<bool>("shouldHaveFocus");
QTest::newRow("inactive scene, normal item") << false << false << false << false;
- QTest::newRow("inactive scene, panel item") << false << false << true << false;
+ QTest::newRow("inactive scene, panel item") << false << false << true << true;
QTest::newRow("inactive scene, normal item, explicit focus") << false << true << false << true;
QTest::newRow("inactive scene, panel, explicit focus") << false << true << true << true;
QTest::newRow("active scene, normal item") << true << false << false << false;
- QTest::newRow("active scene, panel item") << true << false << true << false;
+ QTest::newRow("active scene, panel item") << true << false << true << true;
QTest::newRow("active scene, normal item, explicit focus") << true << true << false << true;
QTest::newRow("active scene, panel, explicit focus") << true << true << true << true;
}
@@ -4561,6 +4562,119 @@ void tst_QGraphicsScene::zeroScale()
QTRY_COMPARE(cl.changes.count(), 2);
}
+void tst_QGraphicsScene::focusItemChangedSignal()
+{
+ qRegisterMetaType<QGraphicsItem *>("QGraphicsItem *");
+ qRegisterMetaType<Qt::FocusReason>("Qt::FocusReason");
+
+ QGraphicsScene scene;
+ QSignalSpy spy(&scene, SIGNAL(focusItemChanged(QGraphicsItem *, QGraphicsItem *, Qt::FocusReason)));
+ QVERIFY(spy.isValid());
+ QCOMPARE(spy.count(), 0);
+ scene.setFocus();
+ QCOMPARE(spy.count(), 0);
+ QEvent activateEvent(QEvent::WindowActivate);
+ qApp->sendEvent(&scene, &activateEvent);
+ QCOMPARE(spy.count(), 0);
+
+ QGraphicsRectItem *topLevelItem1 = new QGraphicsRectItem;
+ topLevelItem1->setFlag(QGraphicsItem::ItemIsFocusable);
+ scene.addItem(topLevelItem1);
+ QCOMPARE(spy.count(), 0);
+ QVERIFY(!topLevelItem1->hasFocus());
+
+ QGraphicsRectItem *topLevelItem2 = new QGraphicsRectItem;
+ topLevelItem2->setFlag(QGraphicsItem::ItemIsFocusable);
+ topLevelItem2->setFocus();
+ QVERIFY(!topLevelItem2->hasFocus());
+ scene.addItem(topLevelItem2);
+ QCOMPARE(spy.count(), 1);
+ QList<QVariant> arguments = spy.takeFirst();
+ QCOMPARE(arguments.size(), 3);
+ QCOMPARE(qVariantValue<QGraphicsItem *>(arguments.at(0)), (QGraphicsItem *)topLevelItem2);
+ QCOMPARE(qVariantValue<QGraphicsItem *>(arguments.at(1)), (QGraphicsItem *)0);
+ QCOMPARE(qVariantValue<Qt::FocusReason>(arguments.at(2)), Qt::OtherFocusReason);
+ QVERIFY(topLevelItem2->hasFocus());
+
+ scene.clearFocus();
+ QCOMPARE(spy.count(), 1);
+ arguments = spy.takeFirst();
+ QCOMPARE(arguments.size(), 3);
+ QCOMPARE(qVariantValue<QGraphicsItem *>(arguments.at(0)), (QGraphicsItem *)0);
+ QCOMPARE(qVariantValue<QGraphicsItem *>(arguments.at(1)), (QGraphicsItem *)topLevelItem2);
+ QCOMPARE(qVariantValue<Qt::FocusReason>(arguments.at(2)), Qt::OtherFocusReason);
+
+ scene.setFocus(Qt::MenuBarFocusReason);
+ QCOMPARE(spy.count(), 1);
+ arguments = spy.takeFirst();
+ QCOMPARE(arguments.size(), 3);
+ QCOMPARE(qVariantValue<QGraphicsItem *>(arguments.at(0)), (QGraphicsItem *)topLevelItem2);
+ QCOMPARE(qVariantValue<QGraphicsItem *>(arguments.at(1)), (QGraphicsItem *)0);
+ QCOMPARE(qVariantValue<Qt::FocusReason>(arguments.at(2)), Qt::MenuBarFocusReason);
+
+ for (int i = 0; i < 3; ++i) {
+ topLevelItem1->setFocus(Qt::TabFocusReason);
+ arguments = spy.takeFirst();
+ QCOMPARE(arguments.size(), 3);
+ QCOMPARE(qVariantValue<QGraphicsItem *>(arguments.at(0)), (QGraphicsItem *)topLevelItem1);
+ QCOMPARE(qVariantValue<QGraphicsItem *>(arguments.at(1)), (QGraphicsItem *)topLevelItem2);
+ QCOMPARE(qVariantValue<Qt::FocusReason>(arguments.at(2)), Qt::TabFocusReason);
+
+ topLevelItem2->setFocus(Qt::TabFocusReason);
+ arguments = spy.takeFirst();
+ QCOMPARE(arguments.size(), 3);
+ QCOMPARE(qVariantValue<QGraphicsItem *>(arguments.at(0)), (QGraphicsItem *)topLevelItem2);
+ QCOMPARE(qVariantValue<QGraphicsItem *>(arguments.at(1)), (QGraphicsItem *)topLevelItem1);
+ QCOMPARE(qVariantValue<Qt::FocusReason>(arguments.at(2)), Qt::TabFocusReason);
+ }
+
+ // The following two are unexpected, but fixing this (i.e., losing and gaining focus
+ // when the scene activation changes) breaks quite a few tests so leave this fix
+ // for some future release. See QTBUG-28346.
+ QEvent deactivateEvent(QEvent::WindowDeactivate);
+ qApp->sendEvent(&scene, &deactivateEvent);
+ QEXPECT_FAIL("", "QTBUG-28346", Continue);
+ QCOMPARE(spy.count(), 1);
+ qApp->sendEvent(&scene, &activateEvent);
+ QEXPECT_FAIL("", "QTBUG-28346", Continue);
+ QCOMPARE(spy.count(), 1);
+
+ QGraphicsRectItem *panel1 = new QGraphicsRectItem;
+ panel1->setFlags(QGraphicsItem::ItemIsPanel | QGraphicsItem::ItemIsFocusable);
+ panel1->setFocus();
+ scene.addItem(panel1);
+ QCOMPARE(spy.count(), 1);
+ arguments = spy.takeFirst();
+ QCOMPARE(arguments.size(), 3);
+ QCOMPARE(qVariantValue<QGraphicsItem *>(arguments.at(0)), (QGraphicsItem *)panel1);
+ QCOMPARE(qVariantValue<QGraphicsItem *>(arguments.at(1)), (QGraphicsItem *)topLevelItem2);
+ QCOMPARE(qVariantValue<Qt::FocusReason>(arguments.at(2)), Qt::ActiveWindowFocusReason);
+
+ QGraphicsRectItem *panel2 = new QGraphicsRectItem;
+ panel2->setFlags(QGraphicsItem::ItemIsPanel | QGraphicsItem::ItemIsFocusable);
+ scene.addItem(panel2);
+ QCOMPARE(spy.count(), 0);
+
+ for (int i = 0; i < 3; ++i) {
+ scene.setActivePanel(panel2);
+ QCOMPARE(spy.count(), 1);
+ arguments = spy.takeFirst();
+ QCOMPARE(arguments.size(), 3);
+ QCOMPARE(qVariantValue<QGraphicsItem *>(arguments.at(0)), (QGraphicsItem *)panel2);
+ QCOMPARE(qVariantValue<QGraphicsItem *>(arguments.at(1)), (QGraphicsItem *)panel1);
+ QCOMPARE(qVariantValue<Qt::FocusReason>(arguments.at(2)), Qt::ActiveWindowFocusReason);
+
+ scene.setActivePanel(panel1);
+ QCOMPARE(spy.count(), 1);
+ arguments = spy.takeFirst();
+ QCOMPARE(arguments.size(), 3);
+ QCOMPARE(qVariantValue<QGraphicsItem *>(arguments.at(0)), (QGraphicsItem *)panel1);
+ QCOMPARE(qVariantValue<QGraphicsItem *>(arguments.at(1)), (QGraphicsItem *)panel2);
+ QCOMPARE(qVariantValue<Qt::FocusReason>(arguments.at(2)), Qt::ActiveWindowFocusReason);
+ }
+
+}
+
void tst_QGraphicsScene::taskQTBUG_15977_renderWithDeviceCoordinateCache()
{
QGraphicsScene scene;
diff --git a/tests/auto/widgets/graphicsview/qgraphicswidget/tst_qgraphicswidget.cpp b/tests/auto/widgets/graphicsview/qgraphicswidget/tst_qgraphicswidget.cpp
index 841e2e900c..3a23c222f9 100644
--- a/tests/auto/widgets/graphicsview/qgraphicswidget/tst_qgraphicswidget.cpp
+++ b/tests/auto/widgets/graphicsview/qgraphicswidget/tst_qgraphicswidget.cpp
@@ -172,12 +172,12 @@ private slots:
void initialShow2();
void itemChangeEvents();
void itemSendGeometryPosChangesDeactivated();
-
void fontPropagatesResolveToChildren();
void fontPropagatesResolveToGrandChildren();
void fontPropagatesResolveInParentChange();
void fontPropagatesResolveViaNonWidget();
void fontPropagatesResolveFromScene();
+ void tabFocus();
// Task fixes
void task236127_bspTreeIndexFails();
@@ -3302,6 +3302,103 @@ void tst_QGraphicsWidget::itemSendGeometryPosChangesDeactivated()
QCOMPARE(item->geometry(), QRectF(10, 10, 60, 60));
}
+class TabFocusWidget : public QGraphicsWidget
+{
+ Q_OBJECT
+public:
+ TabFocusWidget(const QString &name, QGraphicsItem *parent = 0)
+ : QGraphicsWidget(parent)
+ { setFocusPolicy(Qt::TabFocus); setData(0, name); }
+};
+
+void verifyTabFocus(QGraphicsScene *scene, const QList<QGraphicsWidget *> &chain, bool wrapsAround)
+{
+ QKeyEvent tabEvent(QEvent::KeyPress, Qt::Key_Tab, 0);
+ QKeyEvent backtabEvent(QEvent::KeyPress, Qt::Key_Backtab, 0);
+
+ for (int i = 0; i < chain.size(); ++i)
+ chain.at(i)->clearFocus();
+
+ int n = chain.size() * (wrapsAround ? 3 : 1);
+ for (int i = 0; i < n; ++i)
+ {
+ qApp->sendEvent(scene, &tabEvent);
+ QVERIFY(chain.at(i % chain.size())->hasFocus());
+ QCOMPARE(scene->focusItem(), chain.at(i % chain.size()));
+ }
+ for (int i = n - 2; i >= 0; --i)
+ {
+ qApp->sendEvent(scene, &backtabEvent);
+ QVERIFY(chain.at(i % chain.size())->hasFocus());
+ QCOMPARE(scene->focusItem(), chain.at(i % chain.size()));
+ }
+}
+
+void tst_QGraphicsWidget::tabFocus()
+{
+ QGraphicsScene scene;
+ scene.setFocus();
+
+ QEvent activate(QEvent::WindowActivate);
+ qApp->sendEvent(&scene, &activate);
+
+ TabFocusWidget *widget = new TabFocusWidget("1");
+ scene.addItem(widget);
+ verifyTabFocus(&scene, QList<QGraphicsWidget *>() << widget, false);
+
+ TabFocusWidget *widget2 = new TabFocusWidget("2");
+ scene.addItem(widget2);
+ scene.setFocusItem(0);
+ verifyTabFocus(&scene, QList<QGraphicsWidget *>() << widget << widget2, false);
+
+ TabFocusWidget *widget3 = new TabFocusWidget("3");
+ widget3->setFlag(QGraphicsItem::ItemIsPanel);
+ scene.addItem(widget3);
+ QCOMPARE(scene.activePanel(), (QGraphicsItem *)widget3);
+ scene.setActivePanel(0);
+ scene.setFocusItem(0);
+ verifyTabFocus(&scene, QList<QGraphicsWidget *>() << widget << widget2, false);
+
+ scene.setActivePanel(widget3);
+ QCOMPARE(scene.focusItem(), (QGraphicsItem *)widget3);
+ verifyTabFocus(&scene, QList<QGraphicsWidget *>() << widget3, true);
+
+ TabFocusWidget *widget4 = new TabFocusWidget("4");
+ widget4->setParentItem(widget3);
+ QVERIFY(widget3->hasFocus());
+ widget3->clearFocus();
+ QVERIFY(!widget3->focusItem());
+ QCOMPARE(scene.activePanel(), (QGraphicsItem *)widget3);
+ verifyTabFocus(&scene, QList<QGraphicsWidget *>() << widget3 << widget4, true);
+
+ QGraphicsWidget *widget5 = new QGraphicsWidget; widget5->setData(0, QLatin1String("5"));
+ widget5->setParentItem(widget3);
+ verifyTabFocus(&scene, QList<QGraphicsWidget *>() << widget3 << widget4, true);
+
+ widget5->setFocusPolicy(Qt::TabFocus);
+ verifyTabFocus(&scene, QList<QGraphicsWidget *>() << widget3 << widget4 << widget5, true);
+
+ TabFocusWidget *widget6 = new TabFocusWidget("6");
+ widget6->setParentItem(widget4);
+ verifyTabFocus(&scene, QList<QGraphicsWidget *>() << widget3 << widget4 << widget6 << widget5, true);
+
+ TabFocusWidget *widget7 = new TabFocusWidget("7", widget6);
+ verifyTabFocus(&scene, QList<QGraphicsWidget *>() << widget3 << widget4 << widget6 << widget7 << widget5, true);
+
+ TabFocusWidget *widget8 = new TabFocusWidget("8", widget6);
+ verifyTabFocus(&scene, QList<QGraphicsWidget *>() << widget3 << widget4 << widget6 << widget7 << widget8 << widget5, true);
+ widget6->setFlag(QGraphicsItem::ItemIsPanel);
+ widget6->setActive(true);
+ verifyTabFocus(&scene, QList<QGraphicsWidget *>() << widget6 << widget7 << widget8, true);
+ widget3->setActive(true);
+ verifyTabFocus(&scene, QList<QGraphicsWidget *>() << widget3 << widget4 << widget5, true);
+ widget6->setFlag(QGraphicsItem::ItemIsPanel, false);
+ verifyTabFocus(&scene, QList<QGraphicsWidget *>() << widget3 << widget4 << widget6 << widget7 << widget8 << widget5, true);
+ scene.removeItem(widget6);
+ verifyTabFocus(&scene, QList<QGraphicsWidget *>() << widget3 << widget4 << widget5, true);
+ delete widget6;
+}
+
void tst_QGraphicsWidget::QT_BUG_6544_tabFocusFirstUnsetWhenRemovingItems()
{
QGraphicsScene scene;
diff --git a/tests/auto/widgets/itemviews/qabstractitemview/tst_qabstractitemview.cpp b/tests/auto/widgets/itemviews/qabstractitemview/tst_qabstractitemview.cpp
index 30eecb58ed..e576259d1a 100644
--- a/tests/auto/widgets/itemviews/qabstractitemview/tst_qabstractitemview.cpp
+++ b/tests/auto/widgets/itemviews/qabstractitemview/tst_qabstractitemview.cpp
@@ -235,6 +235,7 @@ private slots:
void testDelegateDestroyEditor();
void testClickedSignal();
void testChangeEditorState();
+ void deselectInSingleSelection();
};
class MyAbstractItemDelegate : public QAbstractItemDelegate
@@ -1599,5 +1600,47 @@ void tst_QAbstractItemView::testChangeEditorState()
// No segfault - the test passes.
}
+void tst_QAbstractItemView::deselectInSingleSelection()
+{
+ QTableView view;
+ QStandardItemModel s;
+ s.setRowCount(10);
+ s.setColumnCount(10);
+ view.setModel(&s);
+ view.show();
+ view.setSelectionMode(QAbstractItemView::SingleSelection);
+ view.setEditTriggers(QAbstractItemView::NoEditTriggers);
+ QApplication::setActiveWindow(&view);
+ QVERIFY(QTest::qWaitForWindowExposed(&view));
+ // mouse
+ QModelIndex index22 = s.index(2, 2);
+ QRect rect22 = view.visualRect(index22);
+ QPoint clickpos = rect22.center();
+ QTest::mouseClick(view.viewport(), Qt::LeftButton, Qt::NoModifier, clickpos);
+ QCOMPARE(view.currentIndex(), index22);
+ QCOMPARE(view.selectionModel()->selectedIndexes().count(), 1);
+ QTest::mouseClick(view.viewport(), Qt::LeftButton, Qt::ControlModifier, clickpos);
+ QCOMPARE(view.currentIndex(), index22);
+ QCOMPARE(view.selectionModel()->selectedIndexes().count(), 0);
+
+ // second click with modifier however does select
+ QTest::mouseClick(view.viewport(), Qt::LeftButton, Qt::ControlModifier, clickpos);
+ QCOMPARE(view.currentIndex(), index22);
+ QCOMPARE(view.selectionModel()->selectedIndexes().count(), 1);
+
+ // keyboard
+ QTest::keyClick(&view, Qt::Key_Space, Qt::NoModifier);
+ QCOMPARE(view.currentIndex(), index22);
+ QCOMPARE(view.selectionModel()->selectedIndexes().count(), 1);
+ QTest::keyClick(&view, Qt::Key_Space, Qt::ControlModifier);
+ QCOMPARE(view.currentIndex(), index22);
+ QCOMPARE(view.selectionModel()->selectedIndexes().count(), 0);
+
+ // second keypress with modifier however does select
+ QTest::keyClick(&view, Qt::Key_Space, Qt::ControlModifier);
+ QCOMPARE(view.currentIndex(), index22);
+ QCOMPARE(view.selectionModel()->selectedIndexes().count(), 1);
+}
+
QTEST_MAIN(tst_QAbstractItemView)
#include "tst_qabstractitemview.moc"
diff --git a/tests/auto/widgets/widgets/qdatetimeedit/tst_qdatetimeedit.cpp b/tests/auto/widgets/widgets/qdatetimeedit/tst_qdatetimeedit.cpp
index 269440e37e..79cded8f9b 100644
--- a/tests/auto/widgets/widgets/qdatetimeedit/tst_qdatetimeedit.cpp
+++ b/tests/auto/widgets/widgets/qdatetimeedit/tst_qdatetimeedit.cpp
@@ -316,7 +316,6 @@ void tst_QDateTimeEdit::getSetCheck()
tst_QDateTimeEdit::tst_QDateTimeEdit()
{
- qRegisterMetaType<QList<int> >("QList<int>");
}
tst_QDateTimeEdit::~tst_QDateTimeEdit()
diff --git a/tests/auto/widgets/widgets/qdialogbuttonbox/tst_qdialogbuttonbox.cpp b/tests/auto/widgets/widgets/qdialogbuttonbox/tst_qdialogbuttonbox.cpp
index e6f5a5aa02..3f3d2cd65b 100644
--- a/tests/auto/widgets/widgets/qdialogbuttonbox/tst_qdialogbuttonbox.cpp
+++ b/tests/auto/widgets/widgets/qdialogbuttonbox/tst_qdialogbuttonbox.cpp
@@ -68,8 +68,8 @@ public slots:
private slots:
void standardButtons();
void testConstructor1();
- void testConstrurtor2();
- void testConstrurtor2_data();
+ void testConstructor2();
+ void testConstructor2_data();
void testConstructor3();
void testConstructor3_data();
void setOrientation_data();
@@ -146,7 +146,7 @@ void tst_QDialogButtonBox::layoutReuse()
delete box;
}
-void tst_QDialogButtonBox::testConstrurtor2_data()
+void tst_QDialogButtonBox::testConstructor2_data()
{
QTest::addColumn<int>("orientation");
@@ -154,7 +154,7 @@ void tst_QDialogButtonBox::testConstrurtor2_data()
QTest::newRow("vertical") << int(Qt::Vertical);
}
-void tst_QDialogButtonBox::testConstrurtor2()
+void tst_QDialogButtonBox::testConstructor2()
{
QFETCH(int, orientation);
Qt::Orientation orient = Qt::Orientation(orientation);
diff --git a/tests/auto/widgets/widgets/qmenubar/tst_qmenubar.cpp b/tests/auto/widgets/widgets/qmenubar/tst_qmenubar.cpp
index 3aefe26b1c..974502ff9d 100644
--- a/tests/auto/widgets/widgets/qmenubar/tst_qmenubar.cpp
+++ b/tests/auto/widgets/widgets/qmenubar/tst_qmenubar.cpp
@@ -1122,7 +1122,6 @@ void tst_QMenuBar::check_menuPosition()
void tst_QMenuBar::task223138_triggered()
{
- qRegisterMetaType<QAction *>("QAction *");
//we create a window with submenus and we check that both menubar and menus get the triggered signal
QMainWindow win;
QMenu *menu = win.menuBar()->addMenu("test");
diff --git a/tests/manual/widgets/itemviews/qheaderview/qheaderviewtest1.cpp b/tests/manual/widgets/itemviews/qheaderview/qheaderviewtest1.cpp
index 7a8c1d159d..b5aeb023f4 100644
--- a/tests/manual/widgets/itemviews/qheaderview/qheaderviewtest1.cpp
+++ b/tests/manual/widgets/itemviews/qheaderview/qheaderviewtest1.cpp
@@ -99,6 +99,9 @@ int main(int argc, char *argv[])
m.setRowCount(500);
m.setColumnCount(250);
tv.setModel(&m);
+ tv.setSelectionMode(QAbstractItemView::SingleSelection);
+ // Comment in the line below to test selection with keyboard (space)
+ // tv.setEditTriggers(QAbstractItemView::NoEditTriggers);
SomeHandler handler(tv.horizontalHeader(), &tv);
tv.horizontalHeader()->setDefaultSectionSize(30);
tv.show();
diff --git a/tests/manual/windowflags/controls.cpp b/tests/manual/windowflags/controls.cpp
index 79a297c45d..cc0abffd67 100644
--- a/tests/manual/windowflags/controls.cpp
+++ b/tests/manual/windowflags/controls.cpp
@@ -123,8 +123,10 @@ Qt::WindowFlags HintControl::hints() const
flags |= Qt::WindowMinimizeButtonHint;
if (windowMaximizeButtonCheckBox->isChecked())
flags |= Qt::WindowMaximizeButtonHint;
+#if QT_VERSION >= 0x050000
if (windowFullscreenButtonCheckBox->isChecked())
flags |= Qt::WindowFullscreenButtonHint;
+#endif
if (windowCloseButtonCheckBox->isChecked())
flags |= Qt::WindowCloseButtonHint;
if (windowContextHelpButtonCheckBox->isChecked())
@@ -153,7 +155,9 @@ void HintControl::setHints(Qt::WindowFlags flags)
windowSystemMenuCheckBox->setChecked(flags & Qt::WindowSystemMenuHint);
windowMinimizeButtonCheckBox->setChecked(flags & Qt::WindowMinimizeButtonHint);
windowMaximizeButtonCheckBox->setChecked(flags & Qt::WindowMaximizeButtonHint);
+#if QT_VERSION >= 0x050000
windowFullscreenButtonCheckBox->setChecked(flags & Qt::WindowFullscreenButtonHint);
+#endif
windowCloseButtonCheckBox->setChecked(flags & Qt::WindowCloseButtonHint);
windowContextHelpButtonCheckBox->setChecked(flags & Qt::WindowContextHelpButtonHint);
windowShadeButtonCheckBox->setChecked(flags & Qt::WindowShadeButtonHint);