diff options
Diffstat (limited to 'tests')
219 files changed, 5031 insertions, 766 deletions
diff --git a/tests/auto/corelib/animation/qanimationgroup/tst_qanimationgroup.cpp b/tests/auto/corelib/animation/qanimationgroup/tst_qanimationgroup.cpp index f6d9d2c14f..c0a3ae6114 100644 --- a/tests/auto/corelib/animation/qanimationgroup/tst_qanimationgroup.cpp +++ b/tests/auto/corelib/animation/qanimationgroup/tst_qanimationgroup.cpp @@ -137,7 +137,7 @@ private: void tst_QAnimationGroup::emptyGroup() { QSequentialAnimationGroup group; - QSignalSpy groupStateChangedSpy(&group, SIGNAL(stateChanged(QAbstractAnimation::State,QAbstractAnimation::State))); + QSignalSpy groupStateChangedSpy(&group, &QSequentialAnimationGroup::stateChanged); QVERIFY(groupStateChangedSpy.isValid()); QCOMPARE(group.state(), QAnimationGroup::Stopped); diff --git a/tests/auto/corelib/animation/qparallelanimationgroup/tst_qparallelanimationgroup.cpp b/tests/auto/corelib/animation/qparallelanimationgroup/tst_qparallelanimationgroup.cpp index 2021eefd8f..bbe9e1a816 100644 --- a/tests/auto/corelib/animation/qparallelanimationgroup/tst_qparallelanimationgroup.cpp +++ b/tests/auto/corelib/animation/qparallelanimationgroup/tst_qparallelanimationgroup.cpp @@ -256,10 +256,10 @@ void tst_QParallelAnimationGroup::stateChanged() group.addAnimation(anim3); group.addAnimation(anim4); - QSignalSpy spy1(anim1, SIGNAL(stateChanged(QAbstractAnimation::State,QAbstractAnimation::State))); - QSignalSpy spy2(anim2, SIGNAL(stateChanged(QAbstractAnimation::State,QAbstractAnimation::State))); - QSignalSpy spy3(anim3, SIGNAL(stateChanged(QAbstractAnimation::State,QAbstractAnimation::State))); - QSignalSpy spy4(anim4, SIGNAL(stateChanged(QAbstractAnimation::State,QAbstractAnimation::State))); + QSignalSpy spy1(anim1, &TestAnimation::stateChanged); + QSignalSpy spy2(anim2, &TestAnimation::stateChanged); + QSignalSpy spy3(anim3, &TestAnimation::stateChanged); + QSignalSpy spy4(anim4, &TestAnimation::stateChanged); QVERIFY(spy1.isValid()); QVERIFY(spy2.isValid()); @@ -434,8 +434,8 @@ void tst_QParallelAnimationGroup::updateChildrenWithRunningGroup() anim.setEndValue(100); anim.setDuration(200); - QSignalSpy groupStateChangedSpy(&group, SIGNAL(stateChanged(QAbstractAnimation::State,QAbstractAnimation::State))); - QSignalSpy childStateChangedSpy(&anim, SIGNAL(stateChanged(QAbstractAnimation::State,QAbstractAnimation::State))); + QSignalSpy groupStateChangedSpy(&group, &QParallelAnimationGroup::stateChanged); + QSignalSpy childStateChangedSpy(&anim, &TestAnimation::stateChanged); QVERIFY(groupStateChangedSpy.isValid()); QVERIFY(childStateChangedSpy.isValid()); @@ -601,8 +601,8 @@ void tst_QParallelAnimationGroup::startGroupWithRunningChild() anim2.setEndValue(100); anim2.setDuration(200); - QSignalSpy stateChangedSpy1(&anim1, SIGNAL(stateChanged(QAbstractAnimation::State,QAbstractAnimation::State))); - QSignalSpy stateChangedSpy2(&anim2, SIGNAL(stateChanged(QAbstractAnimation::State,QAbstractAnimation::State))); + QSignalSpy stateChangedSpy1(&anim1, &TestAnimation::stateChanged); + QSignalSpy stateChangedSpy2(&anim2, &TestAnimation::stateChanged); QVERIFY(stateChangedSpy1.isValid()); QVERIFY(stateChangedSpy2.isValid()); @@ -669,20 +669,20 @@ void tst_QParallelAnimationGroup::zeroDurationAnimation() anim3.setEndValue(100); anim3.setDuration(10); - QSignalSpy stateChangedSpy1(&anim1, SIGNAL(stateChanged(QAbstractAnimation::State,QAbstractAnimation::State))); - QSignalSpy finishedSpy1(&anim1, SIGNAL(finished())); + QSignalSpy stateChangedSpy1(&anim1, &TestAnimation::stateChanged); + QSignalSpy finishedSpy1(&anim1, &TestAnimation::finished); QVERIFY(stateChangedSpy1.isValid()); QVERIFY(finishedSpy1.isValid()); - QSignalSpy stateChangedSpy2(&anim2, SIGNAL(stateChanged(QAbstractAnimation::State,QAbstractAnimation::State))); - QSignalSpy finishedSpy2(&anim2, SIGNAL(finished())); + QSignalSpy stateChangedSpy2(&anim2, &TestAnimation::stateChanged); + QSignalSpy finishedSpy2(&anim2, &TestAnimation::finished); QVERIFY(stateChangedSpy2.isValid()); QVERIFY(finishedSpy2.isValid()); - QSignalSpy stateChangedSpy3(&anim3, SIGNAL(stateChanged(QAbstractAnimation::State,QAbstractAnimation::State))); - QSignalSpy finishedSpy3(&anim3, SIGNAL(finished())); + QSignalSpy stateChangedSpy3(&anim3, &TestAnimation::stateChanged); + QSignalSpy finishedSpy3(&anim3, &TestAnimation::finished); QVERIFY(stateChangedSpy3.isValid()); QVERIFY(finishedSpy3.isValid()); @@ -760,7 +760,7 @@ void tst_QParallelAnimationGroup::stopUncontrolledAnimations() loopsForever.setDuration(100); loopsForever.setLoopCount(-1); - QSignalSpy stateChangedSpy(&anim1, SIGNAL(stateChanged(QAbstractAnimation::State,QAbstractAnimation::State))); + QSignalSpy stateChangedSpy(&anim1, &TestAnimation::stateChanged); QVERIFY(stateChangedSpy.isValid()); group.addAnimation(&anim1); @@ -968,7 +968,7 @@ void tst_QParallelAnimationGroup::pauseResume() { QParallelAnimationGroup group; TestAnimation2 *anim = new TestAnimation2(250, &group); // 0, duration = 250; - QSignalSpy spy(anim, SIGNAL(stateChanged(QAbstractAnimation::State,QAbstractAnimation::State))); + QSignalSpy spy(anim, &TestAnimation::stateChanged); QVERIFY(spy.isValid()); QCOMPARE(group.duration(), 250); group.start(); diff --git a/tests/auto/corelib/animation/qpropertyanimation/tst_qpropertyanimation.cpp b/tests/auto/corelib/animation/qpropertyanimation/tst_qpropertyanimation.cpp index dc731ee765..0dab56a9cc 100644 --- a/tests/auto/corelib/animation/qpropertyanimation/tst_qpropertyanimation.cpp +++ b/tests/auto/corelib/animation/qpropertyanimation/tst_qpropertyanimation.cpp @@ -230,9 +230,9 @@ void tst_QPropertyAnimation::statesAndSignals() anim = new DummyPropertyAnimation; anim->setDuration(100); - QSignalSpy finishedSpy(anim, SIGNAL(finished())); - QSignalSpy runningSpy(anim, SIGNAL(stateChanged(QAbstractAnimation::State,QAbstractAnimation::State))); - QSignalSpy currentLoopSpy(anim, SIGNAL(currentLoopChanged(int))); + QSignalSpy finishedSpy(anim, &QPropertyAnimation::finished); + QSignalSpy runningSpy(anim, &QPropertyAnimation::stateChanged); + QSignalSpy currentLoopSpy(anim, &QPropertyAnimation::currentLoopChanged); QVERIFY(finishedSpy.isValid()); QVERIFY(runningSpy.isValid()); @@ -311,8 +311,8 @@ void tst_QPropertyAnimation::deletion1() QPointer<QPropertyAnimation> anim = new QPropertyAnimation(object, "minimumWidth"); //test that the animation is deleted correctly depending of the deletion flag passed in start() - QSignalSpy runningSpy(anim, SIGNAL(stateChanged(QAbstractAnimation::State,QAbstractAnimation::State))); - QSignalSpy finishedSpy(anim, SIGNAL(finished())); + QSignalSpy runningSpy(anim.data(), &QPropertyAnimation::stateChanged); + QSignalSpy finishedSpy(anim.data(), &QPropertyAnimation::finished); QVERIFY(runningSpy.isValid()); QVERIFY(finishedSpy.isValid()); anim->setStartValue(10); @@ -355,8 +355,8 @@ void tst_QPropertyAnimation::deletion2() anim->setEndValue(20); anim->setDuration(200); - QSignalSpy runningSpy(anim, SIGNAL(stateChanged(QAbstractAnimation::State,QAbstractAnimation::State))); - QSignalSpy finishedSpy(anim, SIGNAL(finished())); + QSignalSpy runningSpy(anim.data(), &QPropertyAnimation::stateChanged); + QSignalSpy finishedSpy(anim.data(), &QPropertyAnimation::finished); QVERIFY(runningSpy.isValid()); QVERIFY(finishedSpy.isValid()); @@ -389,8 +389,8 @@ void tst_QPropertyAnimation::deletion3() anim->setEndValue(20); anim->setDuration(200); - QSignalSpy runningSpy(anim, SIGNAL(stateChanged(QAbstractAnimation::State,QAbstractAnimation::State))); - QSignalSpy finishedSpy(anim, SIGNAL(finished())); + QSignalSpy runningSpy(anim, &QPropertyAnimation::stateChanged); + QSignalSpy finishedSpy(anim, &QPropertyAnimation::finished); QVERIFY(runningSpy.isValid()); QVERIFY(finishedSpy.isValid()); @@ -490,7 +490,7 @@ void tst_QPropertyAnimation::startWhenAnotherIsRunning() //normal case: the animation finishes and is deleted QPointer<QVariantAnimation> anim = new QPropertyAnimation(&o, "ole"); anim->setEndValue(100); - QSignalSpy runningSpy(anim, SIGNAL(stateChanged(QAbstractAnimation::State,QAbstractAnimation::State))); + QSignalSpy runningSpy(anim.data(), &QVariantAnimation::stateChanged); QVERIFY(runningSpy.isValid()); anim->start(QVariantAnimation::DeleteWhenStopped); QTest::qWait(anim->duration() + 100); @@ -501,7 +501,7 @@ void tst_QPropertyAnimation::startWhenAnotherIsRunning() { QPointer<QVariantAnimation> anim = new QPropertyAnimation(&o, "ole"); anim->setEndValue(100); - QSignalSpy runningSpy(anim, SIGNAL(stateChanged(QAbstractAnimation::State,QAbstractAnimation::State))); + QSignalSpy runningSpy(anim.data(), &QVariantAnimation::stateChanged); QVERIFY(runningSpy.isValid()); anim->start(QVariantAnimation::DeleteWhenStopped); QTest::qWait(anim->duration()/2); @@ -850,7 +850,7 @@ void tst_QPropertyAnimation::setStartEndValues() void tst_QPropertyAnimation::zeroDurationStart() { DummyPropertyAnimation anim; - QSignalSpy spy(&anim, SIGNAL(stateChanged(QAbstractAnimation::State,QAbstractAnimation::State))); + QSignalSpy spy(&anim, &DummyPropertyAnimation::stateChanged); QVERIFY(spy.isValid()); anim.setDuration(0); QCOMPARE(anim.state(), QAbstractAnimation::Stopped); @@ -972,7 +972,7 @@ void tst_QPropertyAnimation::operationsInStates() o.setProperty("ole", 42); QPropertyAnimation anim(&o, "ole"); anim.setEndValue(100); - QSignalSpy spy(&anim, SIGNAL(stateChanged(QAbstractAnimation::State,QAbstractAnimation::State))); + QSignalSpy spy(&anim, &QPropertyAnimation::stateChanged); QVERIFY(spy.isValid()); anim.stop(); @@ -1132,7 +1132,7 @@ void tst_QPropertyAnimation::valueChanged() QPropertyAnimation anim(&o, "ole"); anim.setEndValue(5); anim.setDuration(1000); - QSignalSpy spy(&anim, SIGNAL(valueChanged(QVariant))); + QSignalSpy spy(&anim, &QPropertyAnimation::valueChanged); QVERIFY(spy.isValid()); anim.start(); @@ -1263,8 +1263,8 @@ void tst_QPropertyAnimation::zeroLoopCount() anim->setDuration(20); anim->setLoopCount(0); - QSignalSpy runningSpy(anim, SIGNAL(stateChanged(QAbstractAnimation::State,QAbstractAnimation::State))); - QSignalSpy finishedSpy(anim, SIGNAL(finished())); + QSignalSpy runningSpy(anim, &QPropertyAnimation::stateChanged); + QSignalSpy finishedSpy(anim, &QPropertyAnimation::finished); QVERIFY(runningSpy.isValid()); QVERIFY(finishedSpy.isValid()); diff --git a/tests/auto/corelib/animation/qsequentialanimationgroup/tst_qsequentialanimationgroup.cpp b/tests/auto/corelib/animation/qsequentialanimationgroup/tst_qsequentialanimationgroup.cpp index 51f07993cd..cbd484c016 100644 --- a/tests/auto/corelib/animation/qsequentialanimationgroup/tst_qsequentialanimationgroup.cpp +++ b/tests/auto/corelib/animation/qsequentialanimationgroup/tst_qsequentialanimationgroup.cpp @@ -637,8 +637,8 @@ void tst_QSequentialAnimationGroup::pauseAndResume() sequence->addAnimation(a3_s_o1); sequence->setLoopCount(2); - QSignalSpy a1StateChangedSpy(a1_s_o1, SIGNAL(stateChanged(QAbstractAnimation::State,QAbstractAnimation::State))); - QSignalSpy seqStateChangedSpy(sequence, SIGNAL(stateChanged(QAbstractAnimation::State,QAbstractAnimation::State))); + QSignalSpy a1StateChangedSpy(a1_s_o1, &QVariantAnimation::stateChanged); + QSignalSpy seqStateChangedSpy(sequence, &QAnimationGroup::stateChanged); QVERIFY(a1StateChangedSpy.isValid()); QVERIFY(seqStateChangedSpy.isValid()); @@ -744,8 +744,8 @@ void tst_QSequentialAnimationGroup::restart() { // sequence operating on same object/property QAnimationGroup *sequence = new QSequentialAnimationGroup(); - QSignalSpy seqCurrentAnimChangedSpy(sequence, SIGNAL(currentAnimationChanged(QAbstractAnimation*))); - QSignalSpy seqStateChangedSpy(sequence, SIGNAL(stateChanged(QAbstractAnimation::State,QAbstractAnimation::State))); + QSignalSpy seqCurrentAnimChangedSpy(static_cast<QSequentialAnimationGroup*>(sequence), &QSequentialAnimationGroup::currentAnimationChanged); + QSignalSpy seqStateChangedSpy(sequence, &QAnimationGroup::stateChanged); QVERIFY(seqCurrentAnimChangedSpy.isValid()); QVERIFY(seqStateChangedSpy.isValid()); @@ -756,7 +756,7 @@ void tst_QSequentialAnimationGroup::restart() for (int i = 0; i < 3; i++) { anims[i] = new DummyPropertyAnimation; anims[i]->setDuration(100); - animsStateChanged[i] = new QSignalSpy(anims[i], SIGNAL(stateChanged(QAbstractAnimation::State,QAbstractAnimation::State))); + animsStateChanged[i] = new QSignalSpy(anims[i], &QVariantAnimation::stateChanged); QVERIFY(animsStateChanged[i]->isValid()); } @@ -816,10 +816,10 @@ void tst_QSequentialAnimationGroup::looping() QAbstractAnimation *a2_s_o1 = new DummyPropertyAnimation; QAbstractAnimation *a3_s_o1 = new DummyPropertyAnimation; - QSignalSpy a1Spy(a1_s_o1, SIGNAL(stateChanged(QAbstractAnimation::State,QAbstractAnimation::State))); - QSignalSpy a2Spy(a2_s_o1, SIGNAL(stateChanged(QAbstractAnimation::State,QAbstractAnimation::State))); - QSignalSpy a3Spy(a3_s_o1, SIGNAL(stateChanged(QAbstractAnimation::State,QAbstractAnimation::State))); - QSignalSpy seqSpy(sequence, SIGNAL(stateChanged(QAbstractAnimation::State,QAbstractAnimation::State))); + QSignalSpy a1Spy(a1_s_o1, &QAbstractAnimation::stateChanged); + QSignalSpy a2Spy(a2_s_o1, &QAbstractAnimation::stateChanged); + QSignalSpy a3Spy(a3_s_o1, &QAbstractAnimation::stateChanged); + QSignalSpy seqSpy(sequence, &QSequentialAnimationGroup::stateChanged); QVERIFY(a1Spy.isValid()); QVERIFY(a2Spy.isValid()); @@ -833,7 +833,7 @@ void tst_QSequentialAnimationGroup::looping() sequence->setLoopCount(2); QSequentialAnimationGroup group; - QSignalSpy groupSpy(&group, SIGNAL(stateChanged(QAbstractAnimation::State,QAbstractAnimation::State))); + QSignalSpy groupSpy(&group, &QSequentialAnimationGroup::stateChanged); QVERIFY(groupSpy.isValid()); group.addAnimation(sequence); @@ -1101,8 +1101,8 @@ void tst_QSequentialAnimationGroup::updateChildrenWithRunningGroup() anim.setEndValue(100); anim.setDuration(200); - QSignalSpy groupStateChangedSpy(&group, SIGNAL(stateChanged(QAbstractAnimation::State,QAbstractAnimation::State))); - QSignalSpy childStateChangedSpy(&anim, SIGNAL(stateChanged(QAbstractAnimation::State,QAbstractAnimation::State))); + QSignalSpy groupStateChangedSpy(&group, &QSequentialAnimationGroup::stateChanged); + QSignalSpy childStateChangedSpy(&anim, &TestAnimation::stateChanged); QVERIFY(groupStateChangedSpy.isValid()); QVERIFY(childStateChangedSpy.isValid()); @@ -1268,8 +1268,8 @@ void tst_QSequentialAnimationGroup::startGroupWithRunningChild() anim2->setEndValue(100); anim2->setDuration(200); - QSignalSpy stateChangedSpy1(anim1, SIGNAL(stateChanged(QAbstractAnimation::State,QAbstractAnimation::State))); - QSignalSpy stateChangedSpy2(anim2, SIGNAL(stateChanged(QAbstractAnimation::State,QAbstractAnimation::State))); + QSignalSpy stateChangedSpy1(anim1, &TestAnimation::stateChanged); + QSignalSpy stateChangedSpy2(anim2, &TestAnimation::stateChanged); QVERIFY(stateChangedSpy1.isValid()); QVERIFY(stateChangedSpy2.isValid()); @@ -1345,7 +1345,7 @@ void tst_QSequentialAnimationGroup::zeroDurationAnimation() anim3->setEndValue(100); anim3->setDuration(0); - QSignalSpy stateChangedSpy(anim1, SIGNAL(stateChanged(QAbstractAnimation::State,QAbstractAnimation::State))); + QSignalSpy stateChangedSpy(anim1, &TestAnimation::stateChanged); QVERIFY(stateChangedSpy.isValid()); group.addAnimation(anim1); @@ -1417,7 +1417,7 @@ void tst_QSequentialAnimationGroup::finishWithUncontrolledAnimation() //first we test a group with one uncontrolled animation QSequentialAnimationGroup group; UncontrolledAnimation notTimeDriven(&o1, &group); - QSignalSpy spy(&group, SIGNAL(finished())); + QSignalSpy spy(&group, &QSequentialAnimationGroup::finished); QVERIFY(spy.isValid()); group.start(); @@ -1437,7 +1437,7 @@ void tst_QSequentialAnimationGroup::finishWithUncontrolledAnimation() // lets make sure the seeking will work again spy.clear(); DummyPropertyAnimation anim(&group); - QSignalSpy animStateChangedSpy(&anim, SIGNAL(stateChanged(QAbstractAnimation::State,QAbstractAnimation::State))); + QSignalSpy animStateChangedSpy(&anim, &DummyPropertyAnimation::stateChanged); QVERIFY(animStateChangedSpy.isValid()); group.setCurrentTime(300); @@ -1639,7 +1639,7 @@ void tst_QSequentialAnimationGroup::pauseResume() QPropertyAnimation *anim = new QPropertyAnimation(&dummy, "foo", &group); anim->setDuration(250); anim->setEndValue(250); - QSignalSpy spy(anim, SIGNAL(stateChanged(QAbstractAnimation::State,QAbstractAnimation::State))); + QSignalSpy spy(anim, &QPropertyAnimation::stateChanged); QVERIFY(spy.isValid()); QCOMPARE(group.duration(), 250); group.start(); diff --git a/tests/auto/corelib/global/global.pro b/tests/auto/corelib/global/global.pro index c05905bd15..219e9de818 100644 --- a/tests/auto/corelib/global/global.pro +++ b/tests/auto/corelib/global/global.pro @@ -9,4 +9,4 @@ SUBDIRS=\ qlogging \ qtendian \ qglobalstatic \ - + qhooks diff --git a/tests/auto/corelib/global/qglobal/tst_qglobal.cpp b/tests/auto/corelib/global/qglobal/tst_qglobal.cpp index 4eb3e4fc98..0389ae7976 100644 --- a/tests/auto/corelib/global/qglobal/tst_qglobal.cpp +++ b/tests/auto/corelib/global/qglobal/tst_qglobal.cpp @@ -43,6 +43,9 @@ #include <QtTest/QtTest> #include <QtCore/qtypetraits.h> +#include <QPair> +#include <QTextCodec> + class tst_QGlobal: public QObject { Q_OBJECT @@ -60,6 +63,8 @@ private slots: void isEnum(); void qAlignOf(); void integerForSize(); + void qprintable(); + void qprintable_data(); }; void tst_QGlobal::qIsNull() @@ -588,5 +593,64 @@ void tst_QGlobal::integerForSize() Q_STATIC_ASSERT(sizeof(QIntegerForSize<8>::Unsigned) == 8); } +typedef QPair<const char *, const char *> stringpair; +Q_DECLARE_METATYPE(stringpair) + +void tst_QGlobal::qprintable() +{ + QFETCH(QList<stringpair>, localestrings); + QFETCH(int, utf8index); + + QVERIFY(utf8index >= 0 && utf8index < localestrings.count()); + if (utf8index < 0 || utf8index >= localestrings.count()) + return; + + const char *const utf8string = localestrings.at(utf8index).second; + + QString string = QString::fromUtf8(utf8string); + + foreach (const stringpair &pair, localestrings) { + QTextCodec *codec = QTextCodec::codecForName(pair.first); + if (!codec) + continue; + QTextCodec::setCodecForLocale(codec); + // test qPrintable() + QVERIFY(qstrcmp(qPrintable(string), pair.second) == 0); + foreach (const stringpair &pair2, localestrings) { + if (pair2.second == pair.second) + continue; + QVERIFY(qstrcmp(qPrintable(string), pair2.second) != 0); + } + // test qUtf8Printable() + QVERIFY(qstrcmp(qUtf8Printable(string), utf8string) == 0); + foreach (const stringpair &pair2, localestrings) { + if (qstrcmp(pair2.second, utf8string) == 0) + continue; + QVERIFY(qstrcmp(qUtf8Printable(string), pair2.second) != 0); + } + } + + QTextCodec::setCodecForLocale(0); +} + +void tst_QGlobal::qprintable_data() +{ + QTest::addColumn<QList<stringpair> >("localestrings"); + QTest::addColumn<int>("utf8index"); // index of utf8 string + + // Unicode: HIRAGANA LETTER A, I, U, E, O (U+3442, U+3444, U+3446, U+3448, U+344a) + static const char *const utf8string = "\xe3\x81\x82\xe3\x81\x84\xe3\x81\x86\xe3\x81\x88\xe3\x81\x8a"; + static const char *const eucjpstring = "\xa4\xa2\xa4\xa4\xa4\xa6\xa4\xa8\xa4\xaa"; + static const char *const sjisstring = "\x82\xa0\x82\xa2\x82\xa4\x82\xa6\x82\xa8"; + + QList<stringpair> japanesestrings; + japanesestrings << stringpair("UTF-8", utf8string) + << stringpair("EUC-JP", eucjpstring) + << stringpair("Shift_JIS", sjisstring); + + QTest::newRow("Japanese") << japanesestrings << 0; + +} + QTEST_APPLESS_MAIN(tst_QGlobal) #include "tst_qglobal.moc" diff --git a/tests/auto/corelib/global/qhooks/qhooks.pro b/tests/auto/corelib/global/qhooks/qhooks.pro new file mode 100644 index 0000000000..f886e7d49a --- /dev/null +++ b/tests/auto/corelib/global/qhooks/qhooks.pro @@ -0,0 +1,4 @@ +CONFIG += testcase parallel_test +TARGET = tst_qhooks +QT = core-private testlib +SOURCES = tst_qhooks.cpp diff --git a/tests/auto/corelib/global/qhooks/tst_qhooks.cpp b/tests/auto/corelib/global/qhooks/tst_qhooks.cpp new file mode 100644 index 0000000000..817c0b8173 --- /dev/null +++ b/tests/auto/corelib/global/qhooks/tst_qhooks.cpp @@ -0,0 +1,90 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Volker Krause <volker.krause@kdab.com> +** Contact: http://www.qt-project.org/legal +** +** This file is part of the QtCore module 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 <QtTest/QtTest> +#include <QtCore/private/qhooks_p.h> + +class tst_QHooks: public QObject +{ + Q_OBJECT + +private slots: + void testVersion(); + void testAddRemoveObject(); +}; + +void tst_QHooks::testVersion() +{ + QVERIFY(qtHookData[QHooks::HookDataVersion] >= 1); + QCOMPARE(qtHookData[QHooks::HookDataSize], (quintptr)QHooks::LastHookIndex); + QCOMPARE(qtHookData[QHooks::QtVersion], (quintptr)QT_VERSION); +} + +static int objectCount = 0; + +static void objectAddHook(QObject*) +{ + ++objectCount; +} + +static void objectRemoveHook(QObject*) +{ + --objectCount; +} + +void tst_QHooks::testAddRemoveObject() +{ + QCOMPARE(qtHookData[QHooks::AddQObject], (quintptr)0); + QCOMPARE(qtHookData[QHooks::RemoveQObject], (quintptr)0); + + qtHookData[QHooks::AddQObject] = (quintptr)&objectAddHook; + qtHookData[QHooks::RemoveQObject] = (quintptr)&objectRemoveHook; + + QCOMPARE(objectCount, 0); + QObject *obj = new QObject; + QVERIFY(objectCount > 0); + delete obj; + QCOMPARE(objectCount, 0); +} + +QTEST_APPLESS_MAIN(tst_QHooks) +#include "tst_qhooks.moc" diff --git a/tests/auto/corelib/io/qdatastream/tst_qdatastream.cpp b/tests/auto/corelib/io/qdatastream/tst_qdatastream.cpp index a6d76ea7b6..a477d6bc6c 100644 --- a/tests/auto/corelib/io/qdatastream/tst_qdatastream.cpp +++ b/tests/auto/corelib/io/qdatastream/tst_qdatastream.cpp @@ -270,7 +270,9 @@ static int NColorRoles[] = { QPalette::ToolTipText + 1, // Qt_5_0 QPalette::ToolTipText + 1, // Qt_5_1 QPalette::ToolTipText + 1, // Qt_5_2 - 0 // add the correct value for Qt_5_3 here later + QPalette::ToolTipText + 1, // Qt_5_3 + QPalette::ToolTipText + 1, // Qt_5_4 + 0 // add the correct value for Qt_5_5 here later }; // Testing get/set functions diff --git a/tests/auto/corelib/io/qdebug/tst_qdebug.cpp b/tests/auto/corelib/io/qdebug/tst_qdebug.cpp index 8fd830a839..3f53ab5f0a 100644 --- a/tests/auto/corelib/io/qdebug/tst_qdebug.cpp +++ b/tests/auto/corelib/io/qdebug/tst_qdebug.cpp @@ -167,7 +167,8 @@ public: QDebug operator<< (QDebug s, const MyPoint& point) { const QDebugStateSaver saver(s); - return s.nospace() << "MyPoint(" << point.v1 << ", " << point.v2 << ")"; + s.nospace() << "MyPoint(" << point.v1 << ", " << point.v2 << ")"; + return s; } class MyLine @@ -203,10 +204,19 @@ void tst_QDebug::debugSpaceHandling() const d << 1 << 2; MyLine line(MyPoint(10, 11), MyPoint (12, 13)); d << line; + d << "bar"; // 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))")); + QCOMPARE(s_msg, QString::fromLatin1(" foo key=value 1 2 MyLine(MyPoint(10, 11), MyPoint(12, 13)) bar")); + + QVERIFY(qDebug().autoInsertSpaces()); + qDebug() << QPoint(21, 22) << QRect(23, 24, 25, 26) << QLine(27, 28, 29, 30); + QCOMPARE(s_msg, QString::fromLatin1("QPoint(21,22) QRect(23,24 25x26) QLine(QPoint(27,28),QPoint(29,30))")); + qDebug() << QPointF(21, 22) << QRectF(23, 24, 25, 26) << QLineF(27, 28, 29, 30); + QCOMPARE(s_msg, QString::fromLatin1("QPointF(21,22) QRectF(23,24 25x26) QLineF(QPointF(27,28),QPointF(29,30))")); + qDebug() << QMimeType() << QMimeDatabase().mimeTypeForName("application/pdf") << "foo"; + QCOMPARE(s_msg, QString::fromLatin1("QMimeType(invalid) QMimeType(\"application/pdf\") foo")); } void tst_QDebug::stateSaver() const @@ -218,7 +228,7 @@ void tst_QDebug::stateSaver() const QDebugStateSaver saver(d); d.nospace() << hex << right << qSetFieldWidth(3) << qSetPadChar('0') << 42; } - d.space() << 42; + d << 42; } QCOMPARE(s_msg, QString::fromLatin1("02a 42")); } diff --git a/tests/auto/corelib/io/qfilesystemwatcher/tst_qfilesystemwatcher.cpp b/tests/auto/corelib/io/qfilesystemwatcher/tst_qfilesystemwatcher.cpp index e06af5a799..7e04fa5957 100644 --- a/tests/auto/corelib/io/qfilesystemwatcher/tst_qfilesystemwatcher.cpp +++ b/tests/auto/corelib/io/qfilesystemwatcher/tst_qfilesystemwatcher.cpp @@ -140,7 +140,7 @@ void tst_QFileSystemWatcher::basicTest() watcher.setObjectName(QLatin1String("_qt_autotest_force_engine_") + backend); QVERIFY(watcher.addPath(testFile.fileName())); - QSignalSpy changedSpy(&watcher, SIGNAL(fileChanged(QString))); + QSignalSpy changedSpy(&watcher, &QFileSystemWatcher::fileChanged); QVERIFY(changedSpy.isValid()); QEventLoop eventLoop; QTimer timer; @@ -278,7 +278,7 @@ void tst_QFileSystemWatcher::watchDirectory() watcher.setObjectName(QLatin1String("_qt_autotest_force_engine_") + backend); QVERIFY(watcher.addPath(testDir.absolutePath())); - QSignalSpy changedSpy(&watcher, SIGNAL(directoryChanged(QString))); + QSignalSpy changedSpy(&watcher, &QFileSystemWatcher::directoryChanged); QVERIFY(changedSpy.isValid()); QEventLoop eventLoop; QTimer timer; @@ -441,8 +441,8 @@ void tst_QFileSystemWatcher::watchFileAndItsDirectory() QVERIFY(watcher.addPath(testDir.absolutePath())); QVERIFY(watcher.addPath(testFileName)); - QSignalSpy fileChangedSpy(&watcher, SIGNAL(fileChanged(QString))); - QSignalSpy dirChangedSpy(&watcher, SIGNAL(directoryChanged(QString))); + QSignalSpy fileChangedSpy(&watcher, &QFileSystemWatcher::fileChanged); + QSignalSpy dirChangedSpy(&watcher, &QFileSystemWatcher::directoryChanged); QVERIFY(fileChangedSpy.isValid()); QVERIFY(dirChangedSpy.isValid()); QEventLoop eventLoop; @@ -601,7 +601,7 @@ void tst_QFileSystemWatcher::QTBUG2331() QVERIFY(watcher.addPath(temporaryDirectory.path())); // watch signal - QSignalSpy changedSpy(&watcher, SIGNAL(directoryChanged(QString))); + QSignalSpy changedSpy(&watcher, &QFileSystemWatcher::directoryChanged); QVERIFY(changedSpy.isValid()); // remove directory, we should get one change signal, and we should no longer @@ -680,7 +680,7 @@ void tst_QFileSystemWatcher::signalsEmittedAfterFileMoved() connect(&watcher, SIGNAL(fileChanged(QString)), &signalReceiver, SLOT(fileChanged(QString))); // watch signals - QSignalSpy changedSpy(&watcher, SIGNAL(fileChanged(QString))); + QSignalSpy changedSpy(&watcher, &QFileSystemWatcher::fileChanged); QVERIFY(changedSpy.isValid()); // move files to second directory diff --git a/tests/auto/corelib/io/qprocess/tst_qprocess.cpp b/tests/auto/corelib/io/qprocess/tst_qprocess.cpp index 82a0f3f832..1d6418cbc0 100644 --- a/tests/auto/corelib/io/qprocess/tst_qprocess.cpp +++ b/tests/auto/corelib/io/qprocess/tst_qprocess.cpp @@ -259,7 +259,7 @@ void tst_QProcess::simpleStart() qRegisterMetaType<QProcess::ProcessState>("QProcess::ProcessState"); process = new QProcess; - QSignalSpy spy(process, SIGNAL(stateChanged(QProcess::ProcessState))); + QSignalSpy spy(process, &QProcess::stateChanged); QVERIFY(spy.isValid()); connect(process, SIGNAL(readyRead()), this, SLOT(readFromProcess())); @@ -351,7 +351,7 @@ void tst_QProcess::crashTest() { qRegisterMetaType<QProcess::ProcessState>("QProcess::ProcessState"); process = new QProcess; - QSignalSpy stateSpy(process, SIGNAL(stateChanged(QProcess::ProcessState))); + QSignalSpy stateSpy(process, &QProcess::stateChanged); QVERIFY(stateSpy.isValid()); process->start("testProcessCrash/testProcessCrash"); QVERIFY(process->waitForStarted(5000)); @@ -359,8 +359,8 @@ void tst_QProcess::crashTest() qRegisterMetaType<QProcess::ProcessError>("QProcess::ProcessError"); qRegisterMetaType<QProcess::ExitStatus>("QProcess::ExitStatus"); - QSignalSpy spy(process, SIGNAL(error(QProcess::ProcessError))); - QSignalSpy spy2(process, SIGNAL(finished(int,QProcess::ExitStatus))); + QSignalSpy spy(process, static_cast<void (QProcess::*)(QProcess::ProcessError)>(&QProcess::error)); + QSignalSpy spy2(process, static_cast<void (QProcess::*)(int, QProcess::ExitStatus)>(&QProcess::finished)); QVERIFY(spy.isValid()); QVERIFY(spy2.isValid()); @@ -394,8 +394,8 @@ void tst_QProcess::crashTest2() qRegisterMetaType<QProcess::ProcessError>("QProcess::ProcessError"); qRegisterMetaType<QProcess::ExitStatus>("QProcess::ExitStatus"); - QSignalSpy spy(process, SIGNAL(error(QProcess::ProcessError))); - QSignalSpy spy2(process, SIGNAL(finished(int,QProcess::ExitStatus))); + QSignalSpy spy(process, static_cast<void (QProcess::*)(QProcess::ProcessError)>(&QProcess::error)); + QSignalSpy spy2(process, static_cast<void (QProcess::*)(int, QProcess::ExitStatus)>(&QProcess::finished)); QVERIFY(spy.isValid()); QVERIFY(spy2.isValid()); @@ -503,8 +503,8 @@ void tst_QProcess::echoTest2() QCOMPARE(process->error(), QProcess::Timedout); process->write("Hello"); - QSignalSpy spy1(process, SIGNAL(readyReadStandardOutput())); - QSignalSpy spy2(process, SIGNAL(readyReadStandardError())); + QSignalSpy spy1(process, &QProcess::readyReadStandardOutput); + QSignalSpy spy2(process, &QProcess::readyReadStandardError); QVERIFY(spy1.isValid()); QVERIFY(spy2.isValid()); @@ -685,7 +685,7 @@ void tst_QProcess::readTimeoutAndThenCrash() QCOMPARE(process->error(), QProcess::Timedout); qRegisterMetaType<QProcess::ProcessError>("QProcess::ProcessError"); - QSignalSpy spy(process, SIGNAL(error(QProcess::ProcessError))); + QSignalSpy spy(process, static_cast<void (QProcess::*)(QProcess::ProcessError)>(&QProcess::error)); QVERIFY(spy.isValid()); process->kill(); @@ -887,7 +887,7 @@ void tst_QProcess::emitReadyReadOnlyWhenNewDataArrives() QProcess proc; connect(&proc, SIGNAL(readyRead()), this, SLOT(exitLoopSlot())); - QSignalSpy spy(&proc, SIGNAL(readyRead())); + QSignalSpy spy(&proc, &QProcess::readyRead); QVERIFY(spy.isValid()); proc.start("testProcessEcho/testProcessEcho"); @@ -1283,7 +1283,7 @@ void tst_QProcess::waitForReadyReadInAReadyReadSlot() process->start("testProcessEcho/testProcessEcho"); QVERIFY(process->waitForStarted(5000)); - QSignalSpy spy(process, SIGNAL(readyRead())); + QSignalSpy spy(process, &QProcess::readyRead); QVERIFY(spy.isValid()); process->write("foo"); QTestEventLoop::instance().enterLoop(30); @@ -1323,7 +1323,7 @@ void tst_QProcess::waitForBytesWrittenInABytesWrittenSlot() process->start("testProcessEcho/testProcessEcho"); QVERIFY(process->waitForStarted(5000)); - QSignalSpy spy(process, SIGNAL(bytesWritten(qint64))); + QSignalSpy spy(process, &QProcess::bytesWritten); QVERIFY(spy.isValid()); process->write("f"); QTestEventLoop::instance().enterLoop(30); @@ -1538,10 +1538,10 @@ void tst_QProcess::failToStart() qRegisterMetaType<QProcess::ProcessState>("QProcess::ProcessState"); QProcess process; - QSignalSpy stateSpy(&process, SIGNAL(stateChanged(QProcess::ProcessState))); - QSignalSpy errorSpy(&process, SIGNAL(error(QProcess::ProcessError))); - QSignalSpy finishedSpy(&process, SIGNAL(finished(int))); - QSignalSpy finishedSpy2(&process, SIGNAL(finished(int,QProcess::ExitStatus))); + QSignalSpy stateSpy(&process, &QProcess::stateChanged); + QSignalSpy errorSpy(&process, static_cast<void (QProcess::*)(QProcess::ProcessError)>(&QProcess::error)); + QSignalSpy finishedSpy(&process, static_cast<void (QProcess::*)(int)>(&QProcess::finished)); + QSignalSpy finishedSpy2(&process, static_cast<void (QProcess::*)(int, QProcess::ExitStatus)>(&QProcess::finished)); QVERIFY(stateSpy.isValid()); QVERIFY(errorSpy.isValid()); @@ -1605,9 +1605,9 @@ void tst_QProcess::failToStartWithWait() QProcess process; QEventLoop loop; - QSignalSpy errorSpy(&process, SIGNAL(error(QProcess::ProcessError))); - QSignalSpy finishedSpy(&process, SIGNAL(finished(int))); - QSignalSpy finishedSpy2(&process, SIGNAL(finished(int,QProcess::ExitStatus))); + QSignalSpy errorSpy(&process, static_cast<void (QProcess::*)(QProcess::ProcessError)>(&QProcess::error)); + QSignalSpy finishedSpy(&process, static_cast<void (QProcess::*)(int)>(&QProcess::finished)); + QSignalSpy finishedSpy2(&process, static_cast<void (QProcess::*)(int, QProcess::ExitStatus)>(&QProcess::finished)); QVERIFY(errorSpy.isValid()); QVERIFY(finishedSpy.isValid()); @@ -1632,9 +1632,9 @@ void tst_QProcess::failToStartWithEventLoop() QProcess process; QEventLoop loop; - QSignalSpy errorSpy(&process, SIGNAL(error(QProcess::ProcessError))); - QSignalSpy finishedSpy(&process, SIGNAL(finished(int))); - QSignalSpy finishedSpy2(&process, SIGNAL(finished(int,QProcess::ExitStatus))); + QSignalSpy errorSpy(&process, static_cast<void (QProcess::*)(QProcess::ProcessError)>(&QProcess::error)); + QSignalSpy finishedSpy(&process, static_cast<void (QProcess::*)(int)>(&QProcess::finished)); + QSignalSpy finishedSpy2(&process, static_cast<void (QProcess::*)(int, QProcess::ExitStatus)>(&QProcess::finished)); QVERIFY(errorSpy.isValid()); QVERIFY(finishedSpy.isValid()); @@ -1864,9 +1864,9 @@ void tst_QProcess::waitForReadyReadForNonexistantProcess() qRegisterMetaType<QProcess::ExitStatus>("QProcess::ExitStatus"); QProcess process; - QSignalSpy errorSpy(&process, SIGNAL(error(QProcess::ProcessError))); - QSignalSpy finishedSpy1(&process, SIGNAL(finished(int))); - QSignalSpy finishedSpy2(&process, SIGNAL(finished(int,QProcess::ExitStatus))); + QSignalSpy errorSpy(&process, static_cast<void (QProcess::*)(QProcess::ProcessError)>(&QProcess::error)); + QSignalSpy finishedSpy1(&process, static_cast<void (QProcess::*)(int)>(&QProcess::finished)); + QSignalSpy finishedSpy2(&process, static_cast<void (QProcess::*)(int, QProcess::ExitStatus)>(&QProcess::finished)); QVERIFY(errorSpy.isValid()); QVERIFY(finishedSpy1.isValid()); @@ -2202,7 +2202,7 @@ void tst_QProcess::invalidProgramString() QProcess process; qRegisterMetaType<QProcess::ProcessError>("QProcess::ProcessError"); - QSignalSpy spy(&process, SIGNAL(error(QProcess::ProcessError))); + QSignalSpy spy(&process, static_cast<void (QProcess::*)(QProcess::ProcessError)>(&QProcess::error)); QVERIFY(spy.isValid()); process.start(programString); @@ -2218,8 +2218,8 @@ void tst_QProcess::onlyOneStartedSignal() qRegisterMetaType<QProcess::ExitStatus>("QProcess::ExitStatus"); QProcess process; - QSignalSpy spyStarted(&process, SIGNAL(started())); - QSignalSpy spyFinished(&process, SIGNAL(finished(int,QProcess::ExitStatus))); + QSignalSpy spyStarted(&process, &QProcess::started); + QSignalSpy spyFinished(&process, static_cast<void (QProcess::*)(int, QProcess::ExitStatus)>(&QProcess::finished)); QVERIFY(spyStarted.isValid()); QVERIFY(spyFinished.isValid()); diff --git a/tests/auto/corelib/io/qsavefile/tst_qsavefile.cpp b/tests/auto/corelib/io/qsavefile/tst_qsavefile.cpp index 87bcfe572d..08b943ba72 100644 --- a/tests/auto/corelib/io/qsavefile/tst_qsavefile.cpp +++ b/tests/auto/corelib/io/qsavefile/tst_qsavefile.cpp @@ -93,6 +93,8 @@ private slots: void transactionalWriteNoPermissionsOnFile(); void transactionalWriteCanceled(); void transactionalWriteErrorRenaming(); + void symlink(); + void directory(); }; static inline QByteArray msgCannotOpen(const QFileDevice &f) @@ -340,5 +342,142 @@ void tst_QSaveFile::transactionalWriteErrorRenaming() QCOMPARE(file.error(), QFile::RenameError); } +void tst_QSaveFile::symlink() +{ +#ifdef Q_OS_UNIX + QByteArray someData = "some data"; + QTemporaryDir dir; + QVERIFY(dir.isValid()); + + const QString targetFile = dir.path() + QLatin1String("/outfile"); + const QString linkFile = dir.path() + QLatin1String("/linkfile"); + { + QFile file(targetFile); + QVERIFY2(file.open(QIODevice::WriteOnly), msgCannotOpen(file).constData()); + QCOMPARE(file.write("Hello"), Q_INT64_C(5)); + file.close(); + } + + QVERIFY(QFile::link(targetFile, linkFile)); + + QString canonical = QFileInfo(linkFile).canonicalFilePath(); + QCOMPARE(canonical, QFileInfo(targetFile).canonicalFilePath()); + + // Try saving into it + { + QSaveFile saveFile(linkFile); + QVERIFY(saveFile.open(QIODevice::WriteOnly)); + QCOMPARE(saveFile.write(someData), someData.size()); + saveFile.commit(); + + //Check that the linkFile is still a link and still has the same canonical path + QFileInfo info(linkFile); + QVERIFY(info.isSymLink()); + QCOMPARE(QFileInfo(linkFile).canonicalFilePath(), canonical); + + QFile file(targetFile); + QVERIFY2(file.open(QIODevice::ReadOnly), msgCannotOpen(file).constData()); + QCOMPARE(file.readAll(), someData); + file.remove(); + } + + // Save into a symbolic link that point to a removed file + someData = "more stuff"; + { + QSaveFile saveFile(linkFile); + QVERIFY(saveFile.open(QIODevice::WriteOnly)); + QCOMPARE(saveFile.write(someData), someData.size()); + saveFile.commit(); + + QFileInfo info(linkFile); + QVERIFY(info.isSymLink()); + QCOMPARE(QFileInfo(linkFile).canonicalFilePath(), canonical); + + QFile file(targetFile); + QVERIFY2(file.open(QIODevice::ReadOnly), msgCannotOpen(file).constData()); + QCOMPARE(file.readAll(), someData); + } + + // link to a link in another directory + QTemporaryDir dir2; + QVERIFY(dir2.isValid()); + + const QString linkFile2 = dir2.path() + QLatin1String("/linkfile"); + QVERIFY(QFile::link(linkFile, linkFile2)); + QCOMPARE(QFileInfo(linkFile2).canonicalFilePath(), canonical); + + + someData = "hello everyone"; + + { + QSaveFile saveFile(linkFile2); + QVERIFY(saveFile.open(QIODevice::WriteOnly)); + QCOMPARE(saveFile.write(someData), someData.size()); + saveFile.commit(); + + QFile file(targetFile); + QVERIFY2(file.open(QIODevice::ReadOnly), msgCannotOpen(file).constData()); + QCOMPARE(file.readAll(), someData); + } + + //cyclic link + const QString cyclicLink = dir.path() + QLatin1String("/cyclic"); + QVERIFY(QFile::link(cyclicLink, cyclicLink)); + { + QSaveFile saveFile(cyclicLink); + QVERIFY(saveFile.open(QIODevice::WriteOnly)); + QCOMPARE(saveFile.write(someData), someData.size()); + saveFile.commit(); + + QFile file(cyclicLink); + QVERIFY2(file.open(QIODevice::ReadOnly), msgCannotOpen(file).constData()); + QCOMPARE(file.readAll(), someData); + } + + //cyclic link2 + QVERIFY(QFile::link(cyclicLink + QLatin1Char('1'), cyclicLink + QLatin1Char('2'))); + QVERIFY(QFile::link(cyclicLink + QLatin1Char('2'), cyclicLink + QLatin1Char('1'))); + + { + QSaveFile saveFile(cyclicLink + QLatin1Char('1')); + QVERIFY(saveFile.open(QIODevice::WriteOnly)); + QCOMPARE(saveFile.write(someData), someData.size()); + saveFile.commit(); + + // the explicit file becomes a file instead of a link + QVERIFY(!QFileInfo(cyclicLink + QLatin1Char('1')).isSymLink()); + QVERIFY(QFileInfo(cyclicLink + QLatin1Char('2')).isSymLink()); + + QFile file(cyclicLink + QLatin1Char('1')); + QVERIFY2(file.open(QIODevice::ReadOnly), msgCannotOpen(file).constData()); + QCOMPARE(file.readAll(), someData); + } +#endif +} + +void tst_QSaveFile::directory() +{ + QTemporaryDir dir; + QVERIFY(dir.isValid()); + + const QString subdir = dir.path() + QLatin1String("/subdir"); + QVERIFY(QDir(dir.path()).mkdir(QStringLiteral("subdir"))); + { + QFile sf(subdir); + QVERIFY(!sf.open(QIODevice::WriteOnly)); + } + +#ifdef Q_OS_UNIX + //link to a directory + const QString linkToDir = dir.path() + QLatin1String("/linkToDir"); + QVERIFY(QFile::link(subdir, linkToDir)); + + { + QFile sf(linkToDir); + QVERIFY(!sf.open(QIODevice::WriteOnly)); + } +#endif +} + QTEST_MAIN(tst_QSaveFile) #include "tst_qsavefile.moc" diff --git a/tests/auto/corelib/io/qstandardpaths/tst_qstandardpaths.cpp b/tests/auto/corelib/io/qstandardpaths/tst_qstandardpaths.cpp index 7247b02498..c373e80408 100644 --- a/tests/auto/corelib/io/qstandardpaths/tst_qstandardpaths.cpp +++ b/tests/auto/corelib/io/qstandardpaths/tst_qstandardpaths.cpp @@ -56,7 +56,7 @@ #define Q_XDG_PLATFORM #endif -static const int MaxStandardLocation = QStandardPaths::GenericConfigLocation; +static const int MaxStandardLocation = QStandardPaths::AppDataLocation; class tst_qstandardpaths : public QObject { @@ -129,7 +129,8 @@ static const char * const enumNames[MaxStandardLocation + 1 - int(QStandardPaths "ConfigLocation", "DownloadLocation", "GenericCacheLocation", - "GenericConfigLocation" + "GenericConfigLocation", + "AppDataLocation" }; void tst_qstandardpaths::dump() @@ -238,7 +239,8 @@ void tst_qstandardpaths::enableTestMode() // Check this for locations where test programs typically write. Not desktop, download, music etc... typedef QHash<QStandardPaths::StandardLocation, QString> LocationHash; LocationHash testLocations; - testLocations.insert(QStandardPaths::DataLocation, QStandardPaths::writableLocation(QStandardPaths::DataLocation)); + testLocations.insert(QStandardPaths::AppDataLocation, QStandardPaths::writableLocation(QStandardPaths::AppDataLocation)); + testLocations.insert(QStandardPaths::AppLocalDataLocation, QStandardPaths::writableLocation(QStandardPaths::AppLocalDataLocation)); testLocations.insert(QStandardPaths::GenericDataLocation, QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation)); testLocations.insert(QStandardPaths::ConfigLocation, QStandardPaths::writableLocation(QStandardPaths::ConfigLocation)); testLocations.insert(QStandardPaths::GenericConfigLocation, QStandardPaths::writableLocation(QStandardPaths::GenericConfigLocation)); @@ -294,18 +296,18 @@ void tst_qstandardpaths::testDataLocation() // applications are sandboxed. #if !defined(Q_OS_BLACKBERRY) && !defined(Q_OS_ANDROID) && !defined(Q_OS_WINRT) const QString base = QStandardPaths::writableLocation(QStandardPaths::GenericDataLocation); - QCOMPARE(QStandardPaths::writableLocation(QStandardPaths::DataLocation), base + "/tst_qstandardpaths"); + QCOMPARE(QStandardPaths::writableLocation(QStandardPaths::AppLocalDataLocation), base + "/tst_qstandardpaths"); QCoreApplication::instance()->setOrganizationName("Qt"); - QCOMPARE(QStandardPaths::writableLocation(QStandardPaths::DataLocation), base + "/Qt/tst_qstandardpaths"); + QCOMPARE(QStandardPaths::writableLocation(QStandardPaths::AppLocalDataLocation), base + "/Qt/tst_qstandardpaths"); QCoreApplication::instance()->setApplicationName("QtTest"); - QCOMPARE(QStandardPaths::writableLocation(QStandardPaths::DataLocation), base + "/Qt/QtTest"); + QCOMPARE(QStandardPaths::writableLocation(QStandardPaths::AppLocalDataLocation), base + "/Qt/QtTest"); #endif #ifdef Q_XDG_PLATFORM setDefaultLocations(); const QString expectedAppDataDir = QDir::homePath() + QString::fromLatin1("/.local/share/Qt/QtTest"); - QCOMPARE(QStandardPaths::writableLocation(QStandardPaths::DataLocation), expectedAppDataDir); - const QStringList appDataDirs = QStandardPaths::standardLocations(QStandardPaths::DataLocation); + QCOMPARE(QStandardPaths::writableLocation(QStandardPaths::AppLocalDataLocation), expectedAppDataDir); + const QStringList appDataDirs = QStandardPaths::standardLocations(QStandardPaths::AppLocalDataLocation); QCOMPARE(appDataDirs.count(), 3); QCOMPARE(appDataDirs.at(0), expectedAppDataDir); QCOMPARE(appDataDirs.at(1), QString::fromLatin1("/usr/local/share/Qt/QtTest")); @@ -463,7 +465,7 @@ void tst_qstandardpaths::testAllWritableLocations_data() QTest::newRow("PicturesLocation") << QStandardPaths::PicturesLocation; QTest::newRow("TempLocation") << QStandardPaths::TempLocation; QTest::newRow("HomeLocation") << QStandardPaths::HomeLocation; - QTest::newRow("DataLocation") << QStandardPaths::DataLocation; + QTest::newRow("AppLocalDataLocation") << QStandardPaths::AppLocalDataLocation; QTest::newRow("DownloadLocation") << QStandardPaths::DownloadLocation; } diff --git a/tests/auto/corelib/io/qurl/tst_qurl.cpp b/tests/auto/corelib/io/qurl/tst_qurl.cpp index 92dbb96817..df090c3de9 100644 --- a/tests/auto/corelib/io/qurl/tst_qurl.cpp +++ b/tests/auto/corelib/io/qurl/tst_qurl.cpp @@ -165,6 +165,8 @@ private slots: void binaryData(); void fromUserInput_data(); void fromUserInput(); + void fromUserInputWithCwd_data(); + void fromUserInputWithCwd(); void fileName_data(); void fileName(); void isEmptyForEncodedUrl(); @@ -2913,6 +2915,52 @@ void tst_QUrl::fromUserInput() QCOMPARE(url, guessUrlFromString); } +void tst_QUrl::fromUserInputWithCwd_data() +{ + QTest::addColumn<QString>("string"); + QTest::addColumn<QString>("directory"); + QTest::addColumn<QUrl>("guessedUrlDefault"); + QTest::addColumn<QUrl>("guessedUrlAssumeLocalFile"); + + // Null + QTest::newRow("null") << QString() << QString() << QUrl() << QUrl(); + + // Existing file + QDirIterator it(QDir::currentPath(), QDir::NoDotDot | QDir::AllEntries); + int c = 0; + while (it.hasNext()) { + it.next(); + QUrl url = QUrl::fromLocalFile(it.filePath()); + QTest::newRow(QString("file-%1").arg(c++).toLatin1()) << it.fileName() << QDir::currentPath() << url << url; + } + QDir parent = QDir::current(); + QVERIFY(parent.cdUp()); + QUrl parentUrl = QUrl::fromLocalFile(parent.path()); + QTest::newRow("dotdot") << ".." << QDir::currentPath() << parentUrl << parentUrl; + + QTest::newRow("nonexisting") << "nonexisting" << QDir::currentPath() << QUrl("http://nonexisting") << QUrl::fromLocalFile(QDir::currentPath() + "/nonexisting"); + QTest::newRow("short-url") << "example.org" << QDir::currentPath() << QUrl("http://example.org") << QUrl::fromLocalFile(QDir::currentPath() + "/example.org"); + QTest::newRow("full-url") << "http://example.org" << QDir::currentPath() << QUrl("http://example.org") << QUrl("http://example.org"); + QTest::newRow("absolute") << "/doesnotexist.txt" << QDir::currentPath() << QUrl("file:///doesnotexist.txt") << QUrl("file:///doesnotexist.txt"); +#ifdef Q_OS_WIN + QTest::newRow("windows-absolute") << "c:/doesnotexist.txt" << QDir::currentPath() << QUrl("file:///c:/doesnotexist.txt") << QUrl("file:///c:/doesnotexist.txt"); +#endif +} + +void tst_QUrl::fromUserInputWithCwd() +{ + QFETCH(QString, string); + QFETCH(QString, directory); + QFETCH(QUrl, guessedUrlDefault); + QFETCH(QUrl, guessedUrlAssumeLocalFile); + + QUrl url = QUrl::fromUserInput(string, directory); + QCOMPARE(url, guessedUrlDefault); + + url = QUrl::fromUserInput(string, directory, QUrl::AssumeLocalFile); + QCOMPARE(url, guessedUrlAssumeLocalFile); +} + void tst_QUrl::fileName_data() { QTest::addColumn<QString>("urlStr"); diff --git a/tests/auto/corelib/io/qwinoverlappedionotifier/tst_qwinoverlappedionotifier.cpp b/tests/auto/corelib/io/qwinoverlappedionotifier/tst_qwinoverlappedionotifier.cpp index 8321f76bec..16f94e7c5d 100644 --- a/tests/auto/corelib/io/qwinoverlappedionotifier/tst_qwinoverlappedionotifier.cpp +++ b/tests/auto/corelib/io/qwinoverlappedionotifier/tst_qwinoverlappedionotifier.cpp @@ -58,6 +58,7 @@ private slots: void readFile(); void waitForNotified_data(); void waitForNotified(); + void waitForAnyNotified(); void brokenPipe(); void multipleOperations(); @@ -195,6 +196,45 @@ void tst_QWinOverlappedIoNotifier::waitForNotified() QCOMPARE(notifier.waitForNotified(100, &overlapped), false); } +void tst_QWinOverlappedIoNotifier::waitForAnyNotified() +{ + const QString fileName = QDir::toNativeSeparators(sourceFileInfo.absoluteFilePath()); + const int readBufferSize = sourceFileInfo.size(); + + QWinOverlappedIoNotifier notifier; + HANDLE hFile = CreateFile(reinterpret_cast<const wchar_t*>(fileName.utf16()), + GENERIC_READ, FILE_SHARE_READ, + NULL, OPEN_EXISTING, FILE_FLAG_OVERLAPPED, NULL); + notifier.setHandle(hFile); + notifier.setEnabled(true); + QVERIFY(notifier.waitForAnyNotified(100) == 0); + + OVERLAPPED overlapped1; + ZeroMemory(&overlapped1, sizeof(OVERLAPPED)); + QByteArray buffer1(readBufferSize, 0); + BOOL readSuccess = ReadFile(hFile, buffer1.data(), buffer1.size(), NULL, &overlapped1); + QVERIFY(readSuccess || GetLastError() == ERROR_IO_PENDING); + + OVERLAPPED overlapped2; + ZeroMemory(&overlapped2, sizeof(OVERLAPPED)); + QByteArray buffer2(readBufferSize, 0); + readSuccess = ReadFile(hFile, buffer2.data(), buffer2.size(), NULL, &overlapped2); + QVERIFY(readSuccess || GetLastError() == ERROR_IO_PENDING); + + QSet<OVERLAPPED *> overlappedObjects; + overlappedObjects << &overlapped1 << &overlapped2; + + for (int i = 1; i <= 2; ++i) { + OVERLAPPED *notifiedOverlapped = notifier.waitForAnyNotified(3000); + QVERIFY(overlappedObjects.contains(notifiedOverlapped)); + overlappedObjects.remove(notifiedOverlapped); + } + + CloseHandle(hFile); + QVERIFY(overlappedObjects.isEmpty()); + QVERIFY(notifier.waitForAnyNotified(100) == 0); +} + void tst_QWinOverlappedIoNotifier::brokenPipe() { QWinOverlappedIoNotifier notifier; diff --git a/tests/auto/corelib/itemmodels/qabstractitemmodel/tst_qabstractitemmodel.cpp b/tests/auto/corelib/itemmodels/qabstractitemmodel/tst_qabstractitemmodel.cpp index 2d2ae14fb8..0503371714 100644 --- a/tests/auto/corelib/itemmodels/qabstractitemmodel/tst_qabstractitemmodel.cpp +++ b/tests/auto/corelib/itemmodels/qabstractitemmodel/tst_qabstractitemmodel.cpp @@ -158,6 +158,8 @@ public: QVector<QVector<QString> > table; }; +Q_DECLARE_METATYPE(QAbstractItemModel::LayoutChangeHint); + QtTestModel::QtTestModel(int rows, int columns, QObject *parent) : QAbstractItemModel(parent), cCount(columns), rCount(rows), wrongIndex(false) { @@ -353,6 +355,8 @@ void tst_QAbstractItemModel::init() insertCommand->setStartRow(0); insertCommand->setEndRow(9); insertCommand->doCommand(); + + qRegisterMetaType<QAbstractItemModel::LayoutChangeHint>(); } void tst_QAbstractItemModel::cleanup() @@ -807,8 +811,8 @@ void tst_QAbstractItemModel::removeRows() { QtTestModel model(10, 10); - QSignalSpy rowsAboutToBeRemovedSpy(&model, SIGNAL(rowsAboutToBeRemoved(QModelIndex,int,int))); - QSignalSpy rowsRemovedSpy(&model, SIGNAL(rowsRemoved(QModelIndex,int,int))); + QSignalSpy rowsAboutToBeRemovedSpy(&model, &QtTestModel::rowsAboutToBeRemoved); + QSignalSpy rowsRemovedSpy(&model, &QtTestModel::rowsRemoved); QVERIFY(rowsAboutToBeRemovedSpy.isValid()); QVERIFY(rowsRemovedSpy.isValid()); @@ -822,8 +826,8 @@ void tst_QAbstractItemModel::removeColumns() { QtTestModel model(10, 10); - QSignalSpy columnsAboutToBeRemovedSpy(&model, SIGNAL(columnsAboutToBeRemoved(QModelIndex,int,int))); - QSignalSpy columnsRemovedSpy(&model, SIGNAL(columnsRemoved(QModelIndex,int,int))); + QSignalSpy columnsAboutToBeRemovedSpy(&model, &QtTestModel::columnsAboutToBeRemoved); + QSignalSpy columnsRemovedSpy(&model, &QtTestModel::columnsRemoved); QVERIFY(columnsAboutToBeRemovedSpy.isValid()); QVERIFY(columnsRemovedSpy.isValid()); @@ -837,8 +841,8 @@ void tst_QAbstractItemModel::insertRows() { QtTestModel model(10, 10); - QSignalSpy rowsAboutToBeInsertedSpy(&model, SIGNAL(rowsAboutToBeInserted(QModelIndex,int,int))); - QSignalSpy rowsInsertedSpy(&model, SIGNAL(rowsInserted(QModelIndex,int,int))); + QSignalSpy rowsAboutToBeInsertedSpy(&model, &QtTestModel::rowsAboutToBeInserted); + QSignalSpy rowsInsertedSpy(&model, &QtTestModel::rowsInserted); QVERIFY(rowsAboutToBeInsertedSpy.isValid()); QVERIFY(rowsInsertedSpy.isValid()); @@ -852,8 +856,8 @@ void tst_QAbstractItemModel::insertColumns() { QtTestModel model(10, 10); - QSignalSpy columnsAboutToBeInsertedSpy(&model, SIGNAL(columnsAboutToBeInserted(QModelIndex,int,int))); - QSignalSpy columnsInsertedSpy(&model, SIGNAL(columnsInserted(QModelIndex,int,int))); + QSignalSpy columnsAboutToBeInsertedSpy(&model, &QtTestModel::columnsAboutToBeInserted); + QSignalSpy columnsInsertedSpy(&model, &QtTestModel::columnsInserted); QVERIFY(columnsAboutToBeInsertedSpy.isValid()); QVERIFY(columnsInsertedSpy.isValid()); @@ -867,8 +871,8 @@ void tst_QAbstractItemModel::moveRows() { QtTestModel model(10, 10); - QSignalSpy rowsAboutToBeMovedSpy(&model, SIGNAL(rowsAboutToBeMoved(QModelIndex,int,int,QModelIndex,int))); - QSignalSpy rowsMovedSpy(&model, SIGNAL(rowsMoved(QModelIndex,int,int,QModelIndex,int))); + QSignalSpy rowsAboutToBeMovedSpy(&model, &QtTestModel::rowsAboutToBeMoved); + QSignalSpy rowsMovedSpy(&model, &QtTestModel::rowsMoved); QVERIFY(rowsAboutToBeMovedSpy.isValid()); QVERIFY(rowsMovedSpy.isValid()); @@ -882,8 +886,8 @@ void tst_QAbstractItemModel::moveColumns() { QtTestModel model(10, 10); - QSignalSpy columnsAboutToBeMovedSpy(&model, SIGNAL(columnsAboutToBeMoved(QModelIndex,int,int,QModelIndex,int))); - QSignalSpy columnsMovedSpy(&model, SIGNAL(columnsMoved(QModelIndex,int,int,QModelIndex,int))); + QSignalSpy columnsAboutToBeMovedSpy(&model, &QtTestModel::columnsAboutToBeMoved); + QSignalSpy columnsMovedSpy(&model, &QtTestModel::columnsMoved); QVERIFY(columnsAboutToBeMovedSpy.isValid()); QVERIFY(columnsMovedSpy.isValid()); @@ -901,7 +905,7 @@ void tst_QAbstractItemModel::reset() { QtTestModel model(10, 10); - QSignalSpy resetSpy(&model, SIGNAL(modelReset())); + QSignalSpy resetSpy(&model, &QtTestModel::modelReset); QVERIFY(resetSpy.isValid()); model.reset(); QCOMPARE(resetSpy.count(), 1); @@ -1023,8 +1027,8 @@ void tst_QAbstractItemModel::testMoveSameParentDown() } } - QSignalSpy beforeSpy(m_model, SIGNAL(rowsAboutToBeMoved(QModelIndex,int,int,QModelIndex,int))); - QSignalSpy afterSpy(m_model, SIGNAL(rowsMoved(QModelIndex,int,int,QModelIndex,int))); + QSignalSpy beforeSpy(m_model, &DynamicTreeModel::rowsAboutToBeMoved); + QSignalSpy afterSpy(m_model, &DynamicTreeModel::rowsMoved); QVERIFY(beforeSpy.isValid()); QVERIFY(afterSpy.isValid()); @@ -1138,8 +1142,8 @@ void tst_QAbstractItemModel::testMoveSameParentUp() } } - QSignalSpy beforeSpy(m_model, SIGNAL(rowsAboutToBeMoved(QModelIndex,int,int,QModelIndex,int))); - QSignalSpy afterSpy(m_model, SIGNAL(rowsMoved(QModelIndex,int,int,QModelIndex,int))); + QSignalSpy beforeSpy(m_model, &DynamicTreeModel::rowsAboutToBeMoved); + QSignalSpy afterSpy(m_model, &DynamicTreeModel::rowsMoved); QVERIFY(beforeSpy.isValid()); QVERIFY(afterSpy.isValid()); @@ -1287,8 +1291,8 @@ void tst_QAbstractItemModel::testMoveToGrandParent() } } - QSignalSpy beforeSpy(m_model, SIGNAL(rowsAboutToBeMoved(QModelIndex,int,int,QModelIndex,int))); - QSignalSpy afterSpy(m_model, SIGNAL(rowsMoved(QModelIndex,int,int,QModelIndex,int))); + QSignalSpy beforeSpy(m_model, &DynamicTreeModel::rowsAboutToBeMoved); + QSignalSpy afterSpy(m_model, &DynamicTreeModel::rowsMoved); QVERIFY(beforeSpy.isValid()); QVERIFY(afterSpy.isValid()); @@ -1427,8 +1431,8 @@ void tst_QAbstractItemModel::testMoveToSibling() persistentList << QPersistentModelIndex(idx); } - QSignalSpy beforeSpy(m_model, SIGNAL(rowsAboutToBeMoved(QModelIndex,int,int,QModelIndex,int))); - QSignalSpy afterSpy(m_model, SIGNAL(rowsMoved(QModelIndex,int,int,QModelIndex,int))); + QSignalSpy beforeSpy(m_model, &DynamicTreeModel::rowsAboutToBeMoved); + QSignalSpy afterSpy(m_model, &DynamicTreeModel::rowsMoved); QVERIFY(beforeSpy.isValid()); QVERIFY(afterSpy.isValid()); @@ -1577,8 +1581,8 @@ void tst_QAbstractItemModel::testMoveToUncle() persistentList << QPersistentModelIndex(idx); } - QSignalSpy beforeSpy(m_model, SIGNAL(rowsAboutToBeMoved(QModelIndex,int,int,QModelIndex,int))); - QSignalSpy afterSpy(m_model, SIGNAL(rowsMoved(QModelIndex,int,int,QModelIndex,int))); + QSignalSpy beforeSpy(m_model, &DynamicTreeModel::rowsAboutToBeMoved); + QSignalSpy afterSpy(m_model, &DynamicTreeModel::rowsMoved); QVERIFY(beforeSpy.isValid()); QVERIFY(afterSpy.isValid()); @@ -1684,8 +1688,8 @@ void tst_QAbstractItemModel::testMoveToDescendants() persistentList << QPersistentModelIndex(idx); } - QSignalSpy beforeSpy(m_model, SIGNAL(rowsAboutToBeMoved(QModelIndex,int,int,QModelIndex,int))); - QSignalSpy afterSpy(m_model, SIGNAL(rowsMoved(QModelIndex,int,int,QModelIndex,int))); + QSignalSpy beforeSpy(m_model, &DynamicTreeModel::rowsAboutToBeMoved); + QSignalSpy afterSpy(m_model, &DynamicTreeModel::rowsMoved); QVERIFY(beforeSpy.isValid()); QVERIFY(afterSpy.isValid()); @@ -1748,8 +1752,8 @@ void tst_QAbstractItemModel::testMoveWithinOwnRange() QFETCH(int, endRow); QFETCH(int, destRow); - QSignalSpy beforeSpy(m_model, SIGNAL(rowsAboutToBeMoved(QModelIndex,int,int,QModelIndex,int))); - QSignalSpy afterSpy(m_model, SIGNAL(rowsMoved(QModelIndex,int,int,QModelIndex,int))); + QSignalSpy beforeSpy(m_model, &DynamicTreeModel::rowsAboutToBeMoved); + QSignalSpy afterSpy(m_model, &DynamicTreeModel::rowsMoved); QVERIFY(beforeSpy.isValid()); QVERIFY(afterSpy.isValid()); @@ -1841,8 +1845,8 @@ void ListenerObject::slotReset() void tst_QAbstractItemModel::testReset() { - QSignalSpy beforeResetSpy(m_model, SIGNAL(modelAboutToBeReset())); - QSignalSpy afterResetSpy(m_model, SIGNAL(modelReset())); + QSignalSpy beforeResetSpy(m_model, &DynamicTreeModel::modelAboutToBeReset); + QSignalSpy afterResetSpy(m_model, &DynamicTreeModel::modelReset); QVERIFY(beforeResetSpy.isValid()); QVERIFY(afterResetSpy.isValid()); @@ -1874,8 +1878,8 @@ void tst_QAbstractItemModel::testReset() // Delete it because its slots test things which are not true after this point. delete listener; - QSignalSpy proxyBeforeResetSpy(nullProxy, SIGNAL(modelAboutToBeReset())); - QSignalSpy proxyAfterResetSpy(nullProxy, SIGNAL(modelReset())); + QSignalSpy proxyBeforeResetSpy(nullProxy, &QSortFilterProxyModel::modelAboutToBeReset); + QSignalSpy proxyAfterResetSpy(nullProxy, &QSortFilterProxyModel::modelReset); // Before setting it, it does not have custom roles. QCOMPARE(nullProxy->roleNames().value(Qt::UserRole + 1), QByteArray()); @@ -1925,8 +1929,8 @@ void tst_QAbstractItemModel::testDataChanged() { CustomRoleModel model; - QSignalSpy withRoles(&model, SIGNAL(dataChanged(QModelIndex,QModelIndex,QVector<int>))); - QSignalSpy withoutRoles(&model, SIGNAL(dataChanged(QModelIndex,QModelIndex))); + QSignalSpy withRoles(&model, &CustomRoleModel::dataChanged); + QSignalSpy withoutRoles(&model, &CustomRoleModel::dataChanged); QVERIFY(withRoles.isValid()); QVERIFY(withoutRoles.isValid()); @@ -2027,8 +2031,8 @@ void tst_QAbstractItemModel::testChildrenLayoutsChanged() QCOMPARE(model.rowCount(p1), 10); QCOMPARE(model.rowCount(p2), 10); - QSignalSpy beforeSpy(&model, SIGNAL(layoutAboutToBeChanged(QList<QPersistentModelIndex>))); - QSignalSpy afterSpy(&model, SIGNAL(layoutChanged(QList<QPersistentModelIndex>))); + QSignalSpy beforeSpy(&model, &DynamicTreeModel::layoutAboutToBeChanged); + QSignalSpy afterSpy(&model, &DynamicTreeModel::layoutChanged); QVERIFY(beforeSpy.isValid()); QVERIFY(afterSpy.isValid()); @@ -2043,8 +2047,8 @@ void tst_QAbstractItemModel::testChildrenLayoutsChanged() const QVariantList beforeSignal = beforeSpy.first(); const QVariantList afterSignal = afterSpy.first(); - QCOMPARE(beforeSignal.size(), 1); - QCOMPARE(afterSignal.size(), 1); + QCOMPARE(beforeSignal.size(), 2); + QCOMPARE(afterSignal.size(), 2); const QList<QPersistentModelIndex> beforeParents = beforeSignal.first().value<QList<QPersistentModelIndex> >(); QCOMPARE(beforeParents.size(), 2); @@ -2093,8 +2097,8 @@ void tst_QAbstractItemModel::testChildrenLayoutsChanged() const QPersistentModelIndex p2FirstPersistent = model.index(0, 0, p2); const QPersistentModelIndex p2LastPersistent = model.index(9, 0, p2); - QSignalSpy beforeSpy(&model, SIGNAL(layoutAboutToBeChanged(QList<QPersistentModelIndex>))); - QSignalSpy afterSpy(&model, SIGNAL(layoutChanged(QList<QPersistentModelIndex>))); + QSignalSpy beforeSpy(&model, &DynamicTreeModel::layoutAboutToBeChanged); + QSignalSpy afterSpy(&model, &DynamicTreeModel::layoutChanged); QVERIFY(beforeSpy.isValid()); QVERIFY(afterSpy.isValid()); @@ -2116,8 +2120,8 @@ void tst_QAbstractItemModel::testChildrenLayoutsChanged() const QVariantList beforeSignal = beforeSpy.first(); const QVariantList afterSignal = afterSpy.first(); - QCOMPARE(beforeSignal.size(), 1); - QCOMPARE(afterSignal.size(), 1); + QCOMPARE(beforeSignal.size(), 2); + QCOMPARE(afterSignal.size(), 2); QVERIFY(p1FirstPersistent.row() == 1); QVERIFY(p1LastPersistent.row() == 0); diff --git a/tests/auto/corelib/itemmodels/qidentityproxymodel/tst_qidentityproxymodel.cpp b/tests/auto/corelib/itemmodels/qidentityproxymodel/tst_qidentityproxymodel.cpp index ea0a14c18c..5d21509c86 100644 --- a/tests/auto/corelib/itemmodels/qidentityproxymodel/tst_qidentityproxymodel.cpp +++ b/tests/auto/corelib/itemmodels/qidentityproxymodel/tst_qidentityproxymodel.cpp @@ -163,10 +163,10 @@ void tst_QIdentityProxyModel::insertRows() verifyIdentity(m_model); - QSignalSpy modelBeforeSpy(m_model, SIGNAL(rowsAboutToBeInserted(QModelIndex,int,int))); - QSignalSpy modelAfterSpy(m_model, SIGNAL(rowsInserted(QModelIndex,int,int))); - QSignalSpy proxyBeforeSpy(m_proxy, SIGNAL(rowsAboutToBeInserted(QModelIndex,int,int))); - QSignalSpy proxyAfterSpy(m_proxy, SIGNAL(rowsInserted(QModelIndex,int,int))); + QSignalSpy modelBeforeSpy(m_model, &QStandardItemModel::rowsAboutToBeInserted); + QSignalSpy modelAfterSpy(m_model, &QStandardItemModel::rowsInserted); + QSignalSpy proxyBeforeSpy(m_proxy, &QStandardItemModel::rowsAboutToBeInserted); + QSignalSpy proxyAfterSpy(m_proxy, &QStandardItemModel::rowsInserted); QVERIFY(modelBeforeSpy.isValid()); QVERIFY(modelAfterSpy.isValid()); @@ -203,10 +203,10 @@ void tst_QIdentityProxyModel::removeRows() verifyIdentity(m_model); - QSignalSpy modelBeforeSpy(m_model, SIGNAL(rowsAboutToBeRemoved(QModelIndex,int,int))); - QSignalSpy modelAfterSpy(m_model, SIGNAL(rowsRemoved(QModelIndex,int,int))); - QSignalSpy proxyBeforeSpy(m_proxy, SIGNAL(rowsAboutToBeRemoved(QModelIndex,int,int))); - QSignalSpy proxyAfterSpy(m_proxy, SIGNAL(rowsRemoved(QModelIndex,int,int))); + QSignalSpy modelBeforeSpy(m_model, &QStandardItemModel::rowsAboutToBeRemoved); + QSignalSpy modelAfterSpy(m_model, &QStandardItemModel::rowsRemoved); + QSignalSpy proxyBeforeSpy(m_proxy, &QStandardItemModel::rowsAboutToBeRemoved); + QSignalSpy proxyAfterSpy(m_proxy, &QStandardItemModel::rowsRemoved); QVERIFY(modelBeforeSpy.isValid()); QVERIFY(modelAfterSpy.isValid()); @@ -257,10 +257,10 @@ void tst_QIdentityProxyModel::moveRows() verifyIdentity(&model); - QSignalSpy modelBeforeSpy(&model, SIGNAL(rowsAboutToBeMoved(QModelIndex,int,int,QModelIndex,int))); - QSignalSpy modelAfterSpy(&model, SIGNAL(rowsMoved(QModelIndex,int,int,QModelIndex,int))); - QSignalSpy proxyBeforeSpy(m_proxy, SIGNAL(rowsAboutToBeMoved(QModelIndex,int,int,QModelIndex,int))); - QSignalSpy proxyAfterSpy(m_proxy, SIGNAL(rowsMoved(QModelIndex,int,int,QModelIndex,int))); + QSignalSpy modelBeforeSpy(&model, &DynamicTreeModel::rowsAboutToBeMoved); + QSignalSpy modelAfterSpy(&model, &DynamicTreeModel::rowsMoved); + QSignalSpy proxyBeforeSpy(m_proxy, &QIdentityProxyModel::rowsAboutToBeMoved); + QSignalSpy proxyAfterSpy(m_proxy, &QIdentityProxyModel::rowsMoved); QVERIFY(modelBeforeSpy.isValid()); QVERIFY(modelAfterSpy.isValid()); @@ -318,10 +318,10 @@ void tst_QIdentityProxyModel::reset() verifyIdentity(&model); - QSignalSpy modelBeforeSpy(&model, SIGNAL(modelAboutToBeReset())); - QSignalSpy modelAfterSpy(&model, SIGNAL(modelReset())); - QSignalSpy proxyBeforeSpy(m_proxy, SIGNAL(modelAboutToBeReset())); - QSignalSpy proxyAfterSpy(m_proxy, SIGNAL(modelReset())); + QSignalSpy modelBeforeSpy(&model, &DynamicTreeModel::modelAboutToBeReset); + QSignalSpy modelAfterSpy(&model, &DynamicTreeModel::modelReset); + QSignalSpy proxyBeforeSpy(m_proxy, &QIdentityProxyModel::modelAboutToBeReset); + QSignalSpy proxyAfterSpy(m_proxy, &QIdentityProxyModel::modelReset); QVERIFY(modelBeforeSpy.isValid()); QVERIFY(modelAfterSpy.isValid()); @@ -351,8 +351,8 @@ void tst_QIdentityProxyModel::dataChanged() verifyIdentity(&model); - QSignalSpy modelSpy(&model, SIGNAL(dataChanged(QModelIndex,QModelIndex,QVector<int>))); - QSignalSpy proxySpy(m_proxy, SIGNAL(dataChanged(QModelIndex,QModelIndex,QVector<int>))); + QSignalSpy modelSpy(&model, &DataChangedModel::dataChanged); + QSignalSpy proxySpy(m_proxy, &QIdentityProxyModel::dataChanged); QVERIFY(modelSpy.isValid()); QVERIFY(proxySpy.isValid()); diff --git a/tests/auto/corelib/itemmodels/qitemmodel/tst_qitemmodel.cpp b/tests/auto/corelib/itemmodels/qitemmodel/tst_qitemmodel.cpp index 30434bfd56..df4d8d0916 100644 --- a/tests/auto/corelib/itemmodels/qitemmodel/tst_qitemmodel.cpp +++ b/tests/auto/corelib/itemmodels/qitemmodel/tst_qitemmodel.cpp @@ -608,7 +608,7 @@ void tst_QItemModel::setData() QFETCH(QString, modelType); currentModel = testModels->createModel(modelType); QVERIFY(currentModel); - QSignalSpy spy(currentModel, SIGNAL(dataChanged(QModelIndex,QModelIndex))); + QSignalSpy spy(currentModel, &QAbstractItemModel::dataChanged); QVERIFY(spy.isValid()); QCOMPARE(currentModel->setData(QModelIndex(), QVariant()), false); QCOMPARE(spy.count(), 0); @@ -670,7 +670,7 @@ void tst_QItemModel::setHeaderData() QVERIFY(index.isValid()); qRegisterMetaType<Qt::Orientation>("Qt::Orientation"); - QSignalSpy spy(currentModel, SIGNAL(headerDataChanged(Qt::Orientation,int,int))); + QSignalSpy spy(currentModel, &QAbstractItemModel::headerDataChanged); QVERIFY(spy.isValid()); QString text = "Index private pointers should always be the same"; @@ -711,7 +711,7 @@ void tst_QItemModel::sort() QVERIFY(currentModel->hasChildren(topIndex)); QModelIndex index = currentModel->index(0, 0, topIndex); QVERIFY(index.isValid()); - QSignalSpy spy(currentModel, SIGNAL(layoutChanged())); + QSignalSpy spy(currentModel, &QAbstractItemModel::layoutChanged); QVERIFY(spy.isValid()); for (int i=-1; i < 10; ++i){ currentModel->sort(i); @@ -849,12 +849,12 @@ void tst_QItemModel::remove() // When a row or column is removed there should be two signals. // Watch to make sure they are emitted and get the row/column count when they do get emitted by connecting them to a slot - QSignalSpy columnsAboutToBeRemovedSpy(currentModel, SIGNAL(columnsAboutToBeRemoved(QModelIndex,int,int))); - QSignalSpy rowsAboutToBeRemovedSpy(currentModel, SIGNAL(rowsAboutToBeRemoved(QModelIndex,int,int))); - QSignalSpy columnsRemovedSpy(currentModel, SIGNAL(columnsRemoved(QModelIndex,int,int))); - QSignalSpy rowsRemovedSpy(currentModel, SIGNAL(rowsRemoved(QModelIndex,int,int))); - QSignalSpy modelResetSpy(currentModel, SIGNAL(modelReset())); - QSignalSpy modelLayoutChangedSpy(currentModel, SIGNAL(layoutChanged())); + QSignalSpy columnsAboutToBeRemovedSpy(currentModel, &QAbstractItemModel::columnsAboutToBeRemoved); + QSignalSpy rowsAboutToBeRemovedSpy(currentModel, &QAbstractItemModel::rowsAboutToBeRemoved); + QSignalSpy columnsRemovedSpy(currentModel, &QAbstractItemModel::columnsRemoved); + QSignalSpy rowsRemovedSpy(currentModel, &QAbstractItemModel::rowsRemoved); + QSignalSpy modelResetSpy(currentModel, &QAbstractItemModel::modelReset); + QSignalSpy modelLayoutChangedSpy(currentModel, &QAbstractItemModel::layoutChanged); QVERIFY(columnsAboutToBeRemovedSpy.isValid()); QVERIFY(rowsAboutToBeRemovedSpy.isValid()); @@ -1191,12 +1191,12 @@ void tst_QItemModel::insert() // When a row or column is inserted there should be two signals. // Watch to make sure they are emitted and get the row/column count when they do get emitted by connecting them to a slot - QSignalSpy columnsAboutToBeInsertedSpy(currentModel, SIGNAL(columnsAboutToBeInserted(QModelIndex,int,int))); - QSignalSpy rowsAboutToBeInsertedSpy(currentModel, SIGNAL(rowsAboutToBeInserted(QModelIndex,int,int))); - QSignalSpy columnsInsertedSpy(currentModel, SIGNAL(columnsInserted(QModelIndex,int,int))); - QSignalSpy rowsInsertedSpy(currentModel, SIGNAL(rowsInserted(QModelIndex,int,int))); - QSignalSpy modelResetSpy(currentModel, SIGNAL(modelReset())); - QSignalSpy modelLayoutChangedSpy(currentModel, SIGNAL(layoutChanged())); + QSignalSpy columnsAboutToBeInsertedSpy(currentModel, &QAbstractItemModel::columnsAboutToBeInserted); + QSignalSpy rowsAboutToBeInsertedSpy(currentModel, &QAbstractItemModel::rowsAboutToBeInserted); + QSignalSpy columnsInsertedSpy(currentModel, &QAbstractItemModel::columnsInserted); + QSignalSpy rowsInsertedSpy(currentModel, &QAbstractItemModel::rowsInserted); + QSignalSpy modelResetSpy(currentModel, &QAbstractItemModel::modelReset); + QSignalSpy modelLayoutChangedSpy(currentModel, &QAbstractItemModel::layoutChanged); QVERIFY(columnsAboutToBeInsertedSpy.isValid()); QVERIFY(rowsAboutToBeInsertedSpy.isValid()); diff --git a/tests/auto/corelib/itemmodels/qitemselectionmodel/tst_qitemselectionmodel.cpp b/tests/auto/corelib/itemmodels/qitemselectionmodel/tst_qitemselectionmodel.cpp index 9e3457a25a..a4e219a040 100644 --- a/tests/auto/corelib/itemmodels/qitemselectionmodel/tst_qitemselectionmodel.cpp +++ b/tests/auto/corelib/itemmodels/qitemselectionmodel/tst_qitemselectionmodel.cpp @@ -1529,7 +1529,7 @@ void tst_QItemSelectionModel::resetModel() MyStandardItemModel model(20, 20); QItemSelectionModel *selectionModel = new QItemSelectionModel(&model); - QSignalSpy spy(selectionModel, SIGNAL(selectionChanged(QItemSelection,QItemSelection))); + QSignalSpy spy(selectionModel, &QItemSelectionModel::selectionChanged); QVERIFY(spy.isValid()); selectionModel->select(QItemSelection(model.index(0, 0), model.index(5, 5)), QItemSelectionModel::Select); @@ -1592,7 +1592,7 @@ void tst_QItemSelectionModel::removeRows() MyStandardItemModel model(rowCount, columnCount); QItemSelectionModel selections(&model); - QSignalSpy spy(&selections, SIGNAL(selectionChanged(QItemSelection,QItemSelection))); + QSignalSpy spy(&selections, &QItemSelectionModel::selectionChanged); QVERIFY(spy.isValid()); QModelIndex tl = model.index(selectTop, selectLeft); @@ -1655,7 +1655,7 @@ void tst_QItemSelectionModel::removeColumns() MyStandardItemModel model(rowCount, columnCount); QItemSelectionModel selections(&model); - QSignalSpy spy(&selections, SIGNAL(selectionChanged(QItemSelection,QItemSelection))); + QSignalSpy spy(&selections, &QItemSelectionModel::selectionChanged); QVERIFY(spy.isValid()); QModelIndex tl = model.index(selectTop, selectLeft); @@ -1914,12 +1914,9 @@ void tst_QItemSelectionModel::setCurrentIndex() treemodel->index(0, 0, treemodel->index(0, 0)), QItemSelectionModel::SelectCurrent); - QSignalSpy currentSpy(&selectionModel, - SIGNAL(currentChanged(QModelIndex,QModelIndex))); - QSignalSpy rowSpy(&selectionModel, - SIGNAL(currentRowChanged(QModelIndex,QModelIndex))); - QSignalSpy columnSpy(&selectionModel, - SIGNAL(currentColumnChanged(QModelIndex,QModelIndex))); + QSignalSpy currentSpy(&selectionModel, &QItemSelectionModel::currentChanged); + QSignalSpy rowSpy(&selectionModel, &QItemSelectionModel::currentRowChanged); + QSignalSpy columnSpy(&selectionModel, &QItemSelectionModel::currentColumnChanged); QVERIFY(currentSpy.isValid()); QVERIFY(rowSpy.isValid()); @@ -2223,7 +2220,7 @@ void tst_QItemSelectionModel::childrenDeselectionSignal() QItemSelectionModel selectionModel(&model); selectionModel.select(sel, QItemSelectionModel::SelectCurrent); - QSignalSpy deselectSpy(&selectionModel, SIGNAL(selectionChanged(QItemSelection,QItemSelection))); + QSignalSpy deselectSpy(&selectionModel, &QItemSelectionModel::selectionChanged); QVERIFY(deselectSpy.isValid()); model.removeRows(0, 1, root); QVERIFY(deselectSpy.count() == 1); @@ -2406,7 +2403,7 @@ void tst_QItemSelectionModel::deselectRemovedMiddleRange() RemovalObserver ro(&selModel); - QSignalSpy spy(&selModel, SIGNAL(selectionChanged(QItemSelection,QItemSelection))); + QSignalSpy spy(&selModel, &QItemSelectionModel::selectionChanged); QVERIFY(spy.isValid()); bool ok = model.removeRows(4, 2); @@ -2738,7 +2735,7 @@ void tst_QItemSelectionModel::testClearCurrentIndex() QItemSelectionModel selectionModel(&model, 0); - QSignalSpy currentIndexSpy(&selectionModel, SIGNAL(currentChanged(QModelIndex,QModelIndex))); + QSignalSpy currentIndexSpy(&selectionModel, &QItemSelectionModel::currentChanged); QVERIFY(currentIndexSpy.isValid()); QModelIndex firstIndex = model.index(0, 0); diff --git a/tests/auto/corelib/itemmodels/qsortfilterproxymodel/tst_qsortfilterproxymodel.cpp b/tests/auto/corelib/itemmodels/qsortfilterproxymodel/tst_qsortfilterproxymodel.cpp index 0f72b419a0..471e5e6655 100644 --- a/tests/auto/corelib/itemmodels/qsortfilterproxymodel/tst_qsortfilterproxymodel.cpp +++ b/tests/auto/corelib/itemmodels/qsortfilterproxymodel/tst_qsortfilterproxymodel.cpp @@ -150,6 +150,8 @@ private slots: void chainedProxyModelRoleNames(); void noMapAfterSourceDelete(); + void forwardDropApi(); + protected: void buildHierarchy(const QStringList &data, QAbstractItemModel *model); void checkHierarchy(const QStringList &data, const QAbstractItemModel *model); @@ -159,6 +161,8 @@ private: QSortFilterProxyModel *m_proxy; }; +Q_DECLARE_METATYPE(QAbstractItemModel::LayoutChangeHint) + // Testing get/set functions void tst_QSortFilterProxyModel::getSetCheck() { @@ -177,6 +181,7 @@ void tst_QSortFilterProxyModel::getSetCheck() tst_QSortFilterProxyModel::tst_QSortFilterProxyModel() : m_model(0), m_proxy(0) { + qRegisterMetaType<QAbstractItemModel::LayoutChangeHint>(); } void tst_QSortFilterProxyModel::initTestCase() @@ -1472,7 +1477,7 @@ void tst_QSortFilterProxyModel::filterCurrent() view.show(); view.setModel(&proxy); - QSignalSpy spy(view.selectionModel(), SIGNAL(currentChanged(QModelIndex,QModelIndex))); + QSignalSpy spy(view.selectionModel(), &QItemSelectionModel::currentChanged); QVERIFY(spy.isValid()); view.setCurrentIndex(proxy.index(0, 0)); @@ -1620,10 +1625,10 @@ void tst_QSortFilterProxyModel::removeSourceRows() proxy.sort(0, static_cast<Qt::SortOrder>(sortOrder)); (void)proxy.rowCount(QModelIndex()); // force mapping - QSignalSpy removeSpy(&proxy, SIGNAL(rowsRemoved(QModelIndex,int,int))); - QSignalSpy insertSpy(&proxy, SIGNAL(rowsInserted(QModelIndex,int,int))); - QSignalSpy aboutToRemoveSpy(&proxy, SIGNAL(rowsAboutToBeRemoved(QModelIndex,int,int))); - QSignalSpy aboutToInsertSpy(&proxy, SIGNAL(rowsAboutToBeInserted(QModelIndex,int,int))); + QSignalSpy removeSpy(&proxy, &QSortFilterProxyModel::rowsRemoved); + QSignalSpy insertSpy(&proxy, &QSortFilterProxyModel::rowsInserted); + QSignalSpy aboutToRemoveSpy(&proxy, &QSortFilterProxyModel::rowsAboutToBeRemoved); + QSignalSpy aboutToInsertSpy(&proxy, &QSortFilterProxyModel::rowsAboutToBeInserted); QVERIFY(removeSpy.isValid()); QVERIFY(insertSpy.isValid()); @@ -1801,8 +1806,8 @@ void tst_QSortFilterProxyModel::changeFilter() proxy.sort(0, static_cast<Qt::SortOrder>(sortOrder)); (void)proxy.rowCount(QModelIndex()); // force mapping - QSignalSpy initialRemoveSpy(&proxy, SIGNAL(rowsRemoved(QModelIndex,int,int))); - QSignalSpy initialInsertSpy(&proxy, SIGNAL(rowsInserted(QModelIndex,int,int))); + QSignalSpy initialRemoveSpy(&proxy, &QSortFilterProxyModel::rowsRemoved); + QSignalSpy initialInsertSpy(&proxy, &QSortFilterProxyModel::rowsInserted); QVERIFY(initialRemoveSpy.isValid()); QVERIFY(initialInsertSpy.isValid()); @@ -1825,8 +1830,8 @@ void tst_QSortFilterProxyModel::changeFilter() QCOMPARE(proxy.data(index, Qt::DisplayRole).toString(), initialProxyItems.at(i)); } - QSignalSpy finalRemoveSpy(&proxy, SIGNAL(rowsRemoved(QModelIndex,int,int))); - QSignalSpy finalInsertSpy(&proxy, SIGNAL(rowsInserted(QModelIndex,int,int))); + QSignalSpy finalRemoveSpy(&proxy, &QSortFilterProxyModel::rowsRemoved); + QSignalSpy finalInsertSpy(&proxy, &QSortFilterProxyModel::rowsInserted); QVERIFY(finalRemoveSpy.isValid()); QVERIFY(finalInsertSpy.isValid()); @@ -1976,8 +1981,8 @@ void tst_QSortFilterProxyModel::changeSourceData() proxy.setFilterRegExp(filter); - QSignalSpy removeSpy(&proxy, SIGNAL(rowsRemoved(QModelIndex,int,int))); - QSignalSpy insertSpy(&proxy, SIGNAL(rowsInserted(QModelIndex,int,int))); + QSignalSpy removeSpy(&proxy, &QSortFilterProxyModel::rowsRemoved); + QSignalSpy insertSpy(&proxy, &QSortFilterProxyModel::rowsInserted); QVERIFY(removeSpy.isValid()); QVERIFY(insertSpy.isValid()); @@ -2075,7 +2080,7 @@ void tst_QSortFilterProxyModel::selectionFilteredOut() view.show(); view.setModel(&proxy); - QSignalSpy spy(view.selectionModel(), SIGNAL(currentChanged(QModelIndex,QModelIndex))); + QSignalSpy spy(view.selectionModel(), &QItemSelectionModel::currentChanged); QVERIFY(spy.isValid()); view.setCurrentIndex(proxy.index(0, 0)); @@ -2190,8 +2195,8 @@ void tst_QSortFilterProxyModel::insertIntoChildrenlessItem() QSortFilterProxyModel proxy; proxy.setSourceModel(&model); - QSignalSpy colsInsertedSpy(&proxy, SIGNAL(columnsInserted(QModelIndex,int,int))); - QSignalSpy rowsInsertedSpy(&proxy, SIGNAL(rowsInserted(QModelIndex,int,int))); + QSignalSpy colsInsertedSpy(&proxy, &QSortFilterProxyModel::columnsInserted); + QSignalSpy rowsInsertedSpy(&proxy, &QSortFilterProxyModel::rowsInserted); QVERIFY(colsInsertedSpy.isValid()); QVERIFY(rowsInsertedSpy.isValid()); @@ -2270,7 +2275,7 @@ void tst_QSortFilterProxyModel::insertRowIntoFilteredParent() EvenOddFilterModel proxy; proxy.setSourceModel(&model); - QSignalSpy spy(&proxy, SIGNAL(rowsInserted(QModelIndex,int,int))); + QSignalSpy spy(&proxy, &EvenOddFilterModel::rowsInserted); QVERIFY(spy.isValid()); QStandardItem *itemA = new QStandardItem(); @@ -2299,8 +2304,8 @@ void tst_QSortFilterProxyModel::filterOutParentAndFilterInChild() QStandardItem *itemC = new QStandardItem("C"); itemA->appendRow(itemC); // filtered - QSignalSpy removedSpy(&proxy, SIGNAL(rowsRemoved(QModelIndex,int,int))); - QSignalSpy insertedSpy(&proxy, SIGNAL(rowsInserted(QModelIndex,int,int))); + QSignalSpy removedSpy(&proxy, &QSortFilterProxyModel::rowsRemoved); + QSignalSpy insertedSpy(&proxy, &QSortFilterProxyModel::rowsInserted); QVERIFY(removedSpy.isValid()); QVERIFY(insertedSpy.isValid()); @@ -2903,8 +2908,8 @@ void tst_QSortFilterProxyModel::appearsAndSort() QCOMPARE(sourceModel.rowCount(), 3); QCOMPARE(proxyModel.rowCount(), 0); //all rows are hidden at first; - QSignalSpy spyAbout1(&proxyModel, SIGNAL(layoutAboutToBeChanged())); - QSignalSpy spyChanged1(&proxyModel, SIGNAL(layoutChanged())); + QSignalSpy spyAbout1(&proxyModel, &PModel::layoutAboutToBeChanged); + QSignalSpy spyChanged1(&proxyModel, &PModel::layoutChanged); QVERIFY(spyAbout1.isValid()); QVERIFY(spyChanged1.isValid()); @@ -2915,8 +2920,8 @@ void tst_QSortFilterProxyModel::appearsAndSort() secondProxyModel.setDynamicSortFilter(true); secondProxyModel.sort(0, Qt::DescendingOrder); QCOMPARE(secondProxyModel.rowCount(), 0); //all rows are hidden at first; - QSignalSpy spyAbout2(&secondProxyModel, SIGNAL(layoutAboutToBeChanged())); - QSignalSpy spyChanged2(&secondProxyModel, SIGNAL(layoutChanged())); + QSignalSpy spyAbout2(&secondProxyModel, &QSortFilterProxyModel::layoutAboutToBeChanged); + QSignalSpy spyChanged2(&secondProxyModel, &QSortFilterProxyModel::layoutChanged); QVERIFY(spyAbout2.isValid()); QVERIFY(spyChanged2.isValid()); @@ -3443,25 +3448,25 @@ void tst_QSortFilterProxyModel::testParentLayoutChanged() proxy2.setSourceModel(&proxy); proxy2.setObjectName("proxy2"); - QSignalSpy dataChangedSpy(&model, SIGNAL(dataChanged(QModelIndex,QModelIndex))); + QSignalSpy dataChangedSpy(&model, &QSortFilterProxyModel::dataChanged); QVERIFY(dataChangedSpy.isValid()); // Verify that the no-arg signal is still emitted. - QSignalSpy layoutAboutToBeChangedSpy(&proxy, SIGNAL(layoutAboutToBeChanged())); - QSignalSpy layoutChangedSpy(&proxy, SIGNAL(layoutChanged())); + QSignalSpy layoutAboutToBeChangedSpy(&proxy, &QSortFilterProxyModel::layoutAboutToBeChanged); + QSignalSpy layoutChangedSpy(&proxy, &QSortFilterProxyModel::layoutChanged); QVERIFY(layoutAboutToBeChangedSpy.isValid()); QVERIFY(layoutChangedSpy.isValid()); - QSignalSpy parentsAboutToBeChangedSpy(&proxy, SIGNAL(layoutAboutToBeChanged(QList<QPersistentModelIndex>))); - QSignalSpy parentsChangedSpy(&proxy, SIGNAL(layoutChanged(QList<QPersistentModelIndex>))); + QSignalSpy parentsAboutToBeChangedSpy(&proxy, &QSortFilterProxyModel::layoutAboutToBeChanged); + QSignalSpy parentsChangedSpy(&proxy, &QSortFilterProxyModel::layoutChanged); QVERIFY(parentsAboutToBeChangedSpy.isValid()); QVERIFY(parentsChangedSpy.isValid()); - QSignalSpy proxy2ParentsAboutToBeChangedSpy(&proxy2, SIGNAL(layoutAboutToBeChanged(QList<QPersistentModelIndex>))); - QSignalSpy proxy2ParentsChangedSpy(&proxy2, SIGNAL(layoutChanged(QList<QPersistentModelIndex>))); + QSignalSpy proxy2ParentsAboutToBeChangedSpy(&proxy2, &QSortFilterProxyModel::layoutAboutToBeChanged); + QSignalSpy proxy2ParentsChangedSpy(&proxy2, &QSortFilterProxyModel::layoutChanged); QVERIFY(proxy2ParentsAboutToBeChangedSpy.isValid()); QVERIFY(proxy2ParentsChangedSpy.isValid()); @@ -3484,8 +3489,8 @@ void tst_QSortFilterProxyModel::testParentLayoutChanged() QVariantList beforeSignal = parentsAboutToBeChangedSpy.first(); QVariantList afterSignal = parentsChangedSpy.first(); - QCOMPARE(beforeSignal.size(), 1); - QCOMPARE(afterSignal.size(), 1); + QCOMPARE(beforeSignal.size(), 2); + QCOMPARE(afterSignal.size(), 2); QList<QPersistentModelIndex> beforeParents = beforeSignal.first().value<QList<QPersistentModelIndex> >(); QList<QPersistentModelIndex> afterParents = afterSignal.first().value<QList<QPersistentModelIndex> >(); @@ -3620,16 +3625,16 @@ void tst_QSortFilterProxyModel::moveSourceRows() filterBothProxy.setSourceModel(&proxy); filterBothProxy.setFilterRegExp("5"); // The parents are 6 and 3. This filters both out. - QSignalSpy modelBeforeSpy(&model, SIGNAL(rowsAboutToBeMoved(QModelIndex,int,int,QModelIndex,int))); - QSignalSpy modelAfterSpy(&model, SIGNAL(rowsMoved(QModelIndex,int,int,QModelIndex,int))); - QSignalSpy proxyBeforeMoveSpy(m_proxy, SIGNAL(rowsAboutToBeMoved(QModelIndex,int,int,QModelIndex,int))); - QSignalSpy proxyAfterMoveSpy(m_proxy, SIGNAL(rowsMoved(QModelIndex,int,int,QModelIndex,int))); - QSignalSpy proxyBeforeParentLayoutSpy(&proxy, SIGNAL(layoutAboutToBeChanged(QList<QPersistentModelIndex>))); - QSignalSpy proxyAfterParentLayoutSpy(&proxy, SIGNAL(layoutChanged(QList<QPersistentModelIndex>))); - QSignalSpy filterBeforeParentLayoutSpy(&filterProxy, SIGNAL(layoutAboutToBeChanged(QList<QPersistentModelIndex>))); - QSignalSpy filterAfterParentLayoutSpy(&filterProxy, SIGNAL(layoutChanged(QList<QPersistentModelIndex>))); - QSignalSpy filterBothBeforeParentLayoutSpy(&filterBothProxy, SIGNAL(layoutAboutToBeChanged(QList<QPersistentModelIndex>))); - QSignalSpy filterBothAfterParentLayoutSpy(&filterBothProxy, SIGNAL(layoutChanged(QList<QPersistentModelIndex>))); + QSignalSpy modelBeforeSpy(&model, &DynamicTreeModel::rowsAboutToBeMoved); + QSignalSpy modelAfterSpy(&model, &DynamicTreeModel::rowsMoved); + QSignalSpy proxyBeforeMoveSpy(m_proxy, &QSortFilterProxyModel::rowsAboutToBeMoved); + QSignalSpy proxyAfterMoveSpy(m_proxy, &QSortFilterProxyModel::rowsMoved); + QSignalSpy proxyBeforeParentLayoutSpy(&proxy, &QSortFilterProxyModel::layoutAboutToBeChanged); + QSignalSpy proxyAfterParentLayoutSpy(&proxy, &QSortFilterProxyModel::layoutChanged); + QSignalSpy filterBeforeParentLayoutSpy(&filterProxy, &QSortFilterProxyModel::layoutAboutToBeChanged); + QSignalSpy filterAfterParentLayoutSpy(&filterProxy, &QSortFilterProxyModel::layoutChanged); + QSignalSpy filterBothBeforeParentLayoutSpy(&filterBothProxy, &QSortFilterProxyModel::layoutAboutToBeChanged); + QSignalSpy filterBothAfterParentLayoutSpy(&filterBothProxy, &QSortFilterProxyModel::layoutChanged); QVERIFY(modelBeforeSpy.isValid()); QVERIFY(modelAfterSpy.isValid()); @@ -3872,5 +3877,35 @@ void tst_QSortFilterProxyModel::noMapAfterSourceDelete() QVERIFY(!persistent.isValid()); } +// QTBUG-39549, test whether canDropMimeData(), dropMimeData() are proxied as well +// by invoking them on a QSortFilterProxyModel proxying a QStandardItemModel that allows drops +// on row #1, filtering for that row. +class DropTestModel : public QStandardItemModel { +public: + explicit DropTestModel(QObject *parent = 0) : QStandardItemModel(0, 1, parent) + { + appendRow(new QStandardItem(QStringLiteral("Row0"))); + appendRow(new QStandardItem(QStringLiteral("Row1"))); + } + + bool canDropMimeData(const QMimeData *, Qt::DropAction, + int row, int /* column */, const QModelIndex & /* parent */) const Q_DECL_OVERRIDE + { return row == 1; } + + bool dropMimeData(const QMimeData *, Qt::DropAction, + int row, int /* column */, const QModelIndex & /* parent */) Q_DECL_OVERRIDE + { return row == 1; } +}; + +void tst_QSortFilterProxyModel::forwardDropApi() +{ + QSortFilterProxyModel model; + model.setSourceModel(new DropTestModel(&model)); + model.setFilterFixedString(QStringLiteral("Row1")); + QCOMPARE(model.rowCount(), 1); + QVERIFY(model.canDropMimeData(0, Qt::CopyAction, 0, 0, QModelIndex())); + QVERIFY(model.dropMimeData(0, Qt::CopyAction, 0, 0, QModelIndex())); +} + QTEST_MAIN(tst_QSortFilterProxyModel) #include "tst_qsortfilterproxymodel.moc" diff --git a/tests/auto/corelib/json/tst_qtjson.cpp b/tests/auto/corelib/json/tst_qtjson.cpp index a17fe7561a..8d8a3d7e0e 100644 --- a/tests/auto/corelib/json/tst_qtjson.cpp +++ b/tests/auto/corelib/json/tst_qtjson.cpp @@ -132,6 +132,7 @@ private Q_SLOTS: void testTrailingComma(); void testDetachBug(); + void testJsonValueRefDefault(); void valueEquals(); @@ -2425,5 +2426,22 @@ void tst_QtJson::longStrings() } } +void tst_QtJson::testJsonValueRefDefault() +{ + QJsonObject empty; + + QCOMPARE(empty["n/a"].toString(), QString()); + QCOMPARE(empty["n/a"].toString("default"), QStringLiteral("default")); + + QCOMPARE(empty["n/a"].toBool(), false); + QCOMPARE(empty["n/a"].toBool(true), true); + + QCOMPARE(empty["n/a"].toInt(), 0); + QCOMPARE(empty["n/a"].toInt(42), 42); + + QCOMPARE(empty["n/a"].toDouble(), 0.0); + QCOMPARE(empty["n/a"].toDouble(42.0), 42.0); +} + QTEST_MAIN(tst_QtJson) #include "tst_qtjson.moc" diff --git a/tests/auto/corelib/kernel/qeventloop/tst_qeventloop.cpp b/tests/auto/corelib/kernel/qeventloop/tst_qeventloop.cpp index a7833aa835..ce9577e0ed 100644 --- a/tests/auto/corelib/kernel/qeventloop/tst_qeventloop.cpp +++ b/tests/auto/corelib/kernel/qeventloop/tst_qeventloop.cpp @@ -195,8 +195,8 @@ protected: void tst_QEventLoop::processEvents() { - QSignalSpy aboutToBlockSpy(QAbstractEventDispatcher::instance(), SIGNAL(aboutToBlock())); - QSignalSpy awakeSpy(QAbstractEventDispatcher::instance(), SIGNAL(awake())); + QSignalSpy aboutToBlockSpy(QAbstractEventDispatcher::instance(), &QAbstractEventDispatcher::aboutToBlock); + QSignalSpy awakeSpy(QAbstractEventDispatcher::instance(), &QAbstractEventDispatcher::awake); QVERIFY(aboutToBlockSpy.isValid()); QVERIFY(awakeSpy.isValid()); @@ -282,7 +282,7 @@ void tst_QEventLoop::exec() thread.cond.wait(&thread.mutex); // make sure the eventloop runs - QSignalSpy spy(QAbstractEventDispatcher::instance(&thread), SIGNAL(awake())); + QSignalSpy spy(QAbstractEventDispatcher::instance(&thread), &QAbstractEventDispatcher::awake); QVERIFY(spy.isValid()); thread.cond.wakeOne(); thread.cond.wait(&thread.mutex); @@ -345,7 +345,7 @@ void tst_QEventLoop::wakeUp() thread.start(); (void) eventLoop.exec(); - QSignalSpy spy(QAbstractEventDispatcher::instance(&thread), SIGNAL(awake())); + QSignalSpy spy(QAbstractEventDispatcher::instance(&thread), &QAbstractEventDispatcher::awake); QVERIFY(spy.isValid()); thread.eventLoop->wakeUp(); @@ -633,7 +633,7 @@ void tst_QEventLoop::testQuitLock() QTimer timer; timer.setInterval(100); - QSignalSpy timerSpy(&timer, SIGNAL(timeout())); + QSignalSpy timerSpy(&timer, &QTimer::timeout); timer.start(); QEventLoopPrivate* privateClass = static_cast<QEventLoopPrivate*>(QObjectPrivate::get(&eventLoop)); diff --git a/tests/auto/corelib/kernel/qmath/tst_qmath.cpp b/tests/auto/corelib/kernel/qmath/tst_qmath.cpp index 24934ac138..8d6964cbcd 100644 --- a/tests/auto/corelib/kernel/qmath/tst_qmath.cpp +++ b/tests/auto/corelib/kernel/qmath/tst_qmath.cpp @@ -54,6 +54,14 @@ private slots: void degreesToRadians(); void radiansToDegrees_data(); void radiansToDegrees(); + void qNextPowerOfTwo32S_data(); + void qNextPowerOfTwo32S(); + void qNextPowerOfTwo64S_data(); + void qNextPowerOfTwo64S(); + void qNextPowerOfTwo32U_data(); + void qNextPowerOfTwo32U(); + void qNextPowerOfTwo64U_data(); + void qNextPowerOfTwo64U(); }; void tst_QMath::fastSinCos() @@ -137,6 +145,117 @@ void tst_QMath::radiansToDegrees() QCOMPARE(qRadiansToDegrees(radiansDouble), degreesDouble); } + +void tst_QMath::qNextPowerOfTwo32S_data() +{ + QTest::addColumn<qint32>("input"); + QTest::addColumn<quint32>("output"); + + QTest::newRow("0") << 0 << 1U; + QTest::newRow("1") << 1 << 2U; + QTest::newRow("2") << 2 << 4U; + QTest::newRow("17") << 17 << 32U; + QTest::newRow("128") << 128 << 256U; + QTest::newRow("65535") << 65535 << 65536U; + QTest::newRow("65536") << 65536 << 131072U; + QTest::newRow("2^30") << (1 << 30) << (1U << 31); + QTest::newRow("2^30 + 1") << (1 << 30) + 1 << (1U << 31); + QTest::newRow("2^31 - 1") << 0x7FFFFFFF << (1U<<31); + QTest::newRow("-1") << -1 << 0U; + QTest::newRow("-128") << -128 << 0U; + QTest::newRow("-(2^31)") << int(0x80000000) << 0U; +} + +void tst_QMath::qNextPowerOfTwo32S() +{ + QFETCH(qint32, input); + QFETCH(quint32, output); + + QCOMPARE(qNextPowerOfTwo(input), output); +} + +void tst_QMath::qNextPowerOfTwo32U_data() +{ + QTest::addColumn<quint32>("input"); + QTest::addColumn<quint32>("output"); + + QTest::newRow("0") << 0U << 1U; + QTest::newRow("1") << 1U << 2U; + QTest::newRow("2") << 2U << 4U; + QTest::newRow("17") << 17U << 32U; + QTest::newRow("128") << 128U << 256U; + QTest::newRow("65535") << 65535U << 65536U; + QTest::newRow("65536") << 65536U << 131072U; + QTest::newRow("2^30") << (1U << 30) << (1U << 31); + QTest::newRow("2^30 + 1") << (1U << 30) + 1 << (1U << 31); + QTest::newRow("2^31 - 1") << 2147483647U << 2147483648U; + QTest::newRow("2^31") << 2147483648U << 0U; + QTest::newRow("2^31 + 1") << 2147483649U << 0U; +} + +void tst_QMath::qNextPowerOfTwo32U() +{ + QFETCH(quint32, input); + QFETCH(quint32, output); + + QCOMPARE(qNextPowerOfTwo(input), output); +} + +void tst_QMath::qNextPowerOfTwo64S_data() +{ + QTest::addColumn<qint64>("input"); + QTest::addColumn<quint64>("output"); + + QTest::newRow("0") << Q_INT64_C(0) << Q_UINT64_C(1); + QTest::newRow("1") << Q_INT64_C(1) << Q_UINT64_C(2); + QTest::newRow("2") << Q_INT64_C(2) << Q_UINT64_C(4); + QTest::newRow("17") << Q_INT64_C(17) << Q_UINT64_C(32); + QTest::newRow("128") << Q_INT64_C(128) << Q_UINT64_C(256); + QTest::newRow("65535") << Q_INT64_C(65535) << Q_UINT64_C(65536); + QTest::newRow("65536") << Q_INT64_C(65536) << Q_UINT64_C(131072); + QTest::newRow("2^31 - 1") << Q_INT64_C(2147483647) << Q_UINT64_C(0x80000000); + QTest::newRow("2^31") << Q_INT64_C(2147483648) << Q_UINT64_C(0x100000000); + QTest::newRow("2^31 + 1") << Q_INT64_C(2147483649) << Q_UINT64_C(0x100000000); + QTest::newRow("2^63 - 1") << Q_INT64_C(0x7FFFFFFFFFFFFFFF) << Q_UINT64_C(0x8000000000000000); + QTest::newRow("-1") << Q_INT64_C(-1) << Q_UINT64_C(0); + QTest::newRow("-128") << Q_INT64_C(-128) << Q_UINT64_C(0); + QTest::newRow("-(2^31)") << -Q_INT64_C(0x80000000) << Q_UINT64_C(0); + QTest::newRow("-(2^63)") << (qint64)Q_INT64_C(0x8000000000000000) << Q_UINT64_C(0); +} + +void tst_QMath::qNextPowerOfTwo64S() +{ + QFETCH(qint64, input); + QFETCH(quint64, output); + + QCOMPARE(qNextPowerOfTwo(input), output); +} + +void tst_QMath::qNextPowerOfTwo64U_data() +{ + QTest::addColumn<quint64>("input"); + QTest::addColumn<quint64>("output"); + + QTest::newRow("0") << Q_UINT64_C(0) << Q_UINT64_C(1); + QTest::newRow("1") << Q_UINT64_C(1) << Q_UINT64_C(2); + QTest::newRow("2") << Q_UINT64_C(2) << Q_UINT64_C(4); + QTest::newRow("17") << Q_UINT64_C(17) << Q_UINT64_C(32); + QTest::newRow("128") << Q_UINT64_C(128) << Q_UINT64_C(256); + QTest::newRow("65535") << Q_UINT64_C(65535) << Q_UINT64_C(65536); + QTest::newRow("65536") << Q_UINT64_C(65536) << Q_UINT64_C(131072); + QTest::newRow("2^63 - 1") << Q_UINT64_C(0x7FFFFFFFFFFFFFFF) << Q_UINT64_C(0x8000000000000000); + QTest::newRow("2^63") << Q_UINT64_C(0x8000000000000000) << Q_UINT64_C(0); + QTest::newRow("2^63 + 1") << Q_UINT64_C(0x8000000000000001) << Q_UINT64_C(0); +} + +void tst_QMath::qNextPowerOfTwo64U() +{ + QFETCH(quint64, input); + QFETCH(quint64, output); + + QCOMPARE(qNextPowerOfTwo(input), output); +} + QTEST_APPLESS_MAIN(tst_QMath) #include "tst_qmath.moc" diff --git a/tests/auto/corelib/kernel/qmetaobject/tst_qmetaobject.cpp b/tests/auto/corelib/kernel/qmetaobject/tst_qmetaobject.cpp index 3afc2bc574..a920ea7a01 100644 --- a/tests/auto/corelib/kernel/qmetaobject/tst_qmetaobject.cpp +++ b/tests/auto/corelib/kernel/qmetaobject/tst_qmetaobject.cpp @@ -561,9 +561,11 @@ void tst_QMetaObject::invokeMetaMember() QVERIFY(!QMetaObject::invokeMethod(&obj, "doesNotExist")); QTest::ignoreMessage(QtWarningMsg, "QMetaObject::invokeMethod: No such method QtTestObject::sl1(QString)(QString)"); QVERIFY(!QMetaObject::invokeMethod(&obj, "sl1(QString)", Q_ARG(QString, "arg"))); - QTest::ignoreMessage(QtWarningMsg, "QMetaObject::invokeMethod: No such method QtTestObject::sl3(QString)"); + QTest::ignoreMessage(QtWarningMsg, "QMetaObject::invokeMethod: No such method QtTestObject::sl3(QString)\n" + "Candidates are:\n sl3(QString,QString,QString)"); QVERIFY(!QMetaObject::invokeMethod(&obj, "sl3", Q_ARG(QString, "arg"))); - QTest::ignoreMessage(QtWarningMsg, "QMetaObject::invokeMethod: No such method QtTestObject::sl1(QString,QString,QString)"); + QTest::ignoreMessage(QtWarningMsg, "QMetaObject::invokeMethod: No such method QtTestObject::sl1(QString,QString,QString)\n" + "Candidates are:\n sl1(QString)"); QVERIFY(!QMetaObject::invokeMethod(&obj, "sl1", Q_ARG(QString, "arg"), Q_ARG(QString, "arg"), Q_ARG(QString, "arg"))); //should not have changed since last test. @@ -747,9 +749,11 @@ void tst_QMetaObject::invokeBlockingQueuedMetaMember() QVERIFY(!QMetaObject::invokeMethod(&obj, "doesNotExist", Qt::BlockingQueuedConnection)); QTest::ignoreMessage(QtWarningMsg, "QMetaObject::invokeMethod: No such method QtTestObject::sl1(QString)(QString)"); QVERIFY(!QMetaObject::invokeMethod(&obj, "sl1(QString)", Qt::BlockingQueuedConnection, Q_ARG(QString, "arg"))); - QTest::ignoreMessage(QtWarningMsg, "QMetaObject::invokeMethod: No such method QtTestObject::sl3(QString)"); + QTest::ignoreMessage(QtWarningMsg, "QMetaObject::invokeMethod: No such method QtTestObject::sl3(QString)\n" + "Candidates are:\n sl3(QString,QString,QString)"); QVERIFY(!QMetaObject::invokeMethod(&obj, "sl3", Qt::BlockingQueuedConnection, Q_ARG(QString, "arg"))); - QTest::ignoreMessage(QtWarningMsg, "QMetaObject::invokeMethod: No such method QtTestObject::sl1(QString,QString,QString)"); + QTest::ignoreMessage(QtWarningMsg, "QMetaObject::invokeMethod: No such method QtTestObject::sl1(QString,QString,QString)\n" + "Candidates are:\n sl1(QString)"); QVERIFY(!QMetaObject::invokeMethod(&obj, "sl1", Qt::BlockingQueuedConnection, Q_ARG(QString, "arg"), Q_ARG(QString, "arg"), Q_ARG(QString, "arg"))); //should not have changed since last test. @@ -857,7 +861,7 @@ void tst_QMetaObject::invokeTypedefTypes() { qRegisterMetaType<CustomString>("CustomString"); QtTestCustomObject obj; - QSignalSpy spy(&obj, SIGNAL(sig_custom(CustomString))); + QSignalSpy spy(&obj, &QtTestCustomObject::sig_custom); QVERIFY(spy.isValid()); QCOMPARE(spy.count(), 0); diff --git a/tests/auto/corelib/kernel/qmetaobjectbuilder/tst_qmetaobjectbuilder.cpp b/tests/auto/corelib/kernel/qmetaobjectbuilder/tst_qmetaobjectbuilder.cpp index 0e7005799e..62e41a96c5 100644 --- a/tests/auto/corelib/kernel/qmetaobjectbuilder/tst_qmetaobjectbuilder.cpp +++ b/tests/auto/corelib/kernel/qmetaobjectbuilder/tst_qmetaobjectbuilder.cpp @@ -1593,7 +1593,7 @@ void tst_QMetaObjectBuilder::usage_signal() { QScopedPointer<TestObject> testObject(new TestObject); - QSignalSpy propChangedSpy(testObject.data(), SIGNAL(intPropChanged(int))); + QSignalSpy propChangedSpy(testObject.data(), &TestObject::intPropChanged); testObject->emitIntPropChanged(); QCOMPARE(propChangedSpy.count(), 1); QCOMPARE(propChangedSpy.at(0).count(), 1); @@ -1608,7 +1608,7 @@ void tst_QMetaObjectBuilder::usage_property() QCOMPARE(prop.type(), QVariant::Int); QCOMPARE(prop.toInt(), testObject->intProp()); - QSignalSpy propChangedSpy(testObject.data(), SIGNAL(intPropChanged(int))); + QSignalSpy propChangedSpy(testObject.data(), &TestObject::intPropChanged); QVERIFY(testObject->intProp() != 123); testObject->setProperty("intProp", 123); QCOMPARE(propChangedSpy.count(), 1); diff --git a/tests/auto/corelib/kernel/qmetatype/tst_qmetatype.cpp b/tests/auto/corelib/kernel/qmetatype/tst_qmetatype.cpp index 959c79ed60..9a86dc03e5 100644 --- a/tests/auto/corelib/kernel/qmetatype/tst_qmetatype.cpp +++ b/tests/auto/corelib/kernel/qmetatype/tst_qmetatype.cpp @@ -1341,6 +1341,8 @@ static QByteArray createTypeName(const char *begin, const char *va) } #endif +Q_DECLARE_METATYPE(const void*) + void tst_QMetaType::automaticTemplateRegistration() { #define TEST_SEQUENTIAL_CONTAINER(CONTAINER, VALUE_TYPE) \ @@ -1358,6 +1360,17 @@ void tst_QMetaType::automaticTemplateRegistration() TEST_SEQUENTIAL_CONTAINER(std::list, int) { + std::vector<bool> vecbool; + vecbool.push_back(true); + vecbool.push_back(false); + vecbool.push_back(true); + QVERIFY(QVariant::fromValue(vecbool).value<std::vector<bool> >().front() == true); + QVector<std::vector<bool> > vectorList; + vectorList << vecbool; + QVERIFY(QVariant::fromValue(vectorList).value<QVector<std::vector<bool> > >().first().front() == true); + } + + { QList<QByteArray> bytearrayList; bytearrayList << QByteArray("foo"); QVERIFY(QVariant::fromValue(bytearrayList).value<QList<QByteArray> >().first() == QByteArray("foo")); @@ -1577,6 +1590,12 @@ void tst_QMetaType::automaticTemplateRegistration() ) CREATE_AND_VERIFY_CONTAINER(QList, QList<QMap<int, QHash<char, QVariantList> > >) + CREATE_AND_VERIFY_CONTAINER(QVector, void*) + CREATE_AND_VERIFY_CONTAINER(QVector, const void*) + CREATE_AND_VERIFY_CONTAINER(QList, void*) + CREATE_AND_VERIFY_CONTAINER(QPair, void*, void*) + CREATE_AND_VERIFY_CONTAINER(QHash, void*, void*) + CREATE_AND_VERIFY_CONTAINER(QHash, const void*, const void*) #endif // Q_COMPILER_VARIADIC_MACROS diff --git a/tests/auto/corelib/kernel/qsocketnotifier/tst_qsocketnotifier.cpp b/tests/auto/corelib/kernel/qsocketnotifier/tst_qsocketnotifier.cpp index 5632bcacc4..c650041e1e 100644 --- a/tests/auto/corelib/kernel/qsocketnotifier/tst_qsocketnotifier.cpp +++ b/tests/auto/corelib/kernel/qsocketnotifier/tst_qsocketnotifier.cpp @@ -267,12 +267,12 @@ void tst_QSocketNotifier::posixSockets() { QSocketNotifier rn(posixSocket, QSocketNotifier::Read); connect(&rn, SIGNAL(activated(int)), &QTestEventLoop::instance(), SLOT(exitLoop())); - QSignalSpy readSpy(&rn, SIGNAL(activated(int))); + QSignalSpy readSpy(&rn, &QSocketNotifier::activated); QVERIFY(readSpy.isValid()); // No write notifier, some systems trigger write notification on socket creation, but not all QSocketNotifier en(posixSocket, QSocketNotifier::Exception); connect(&en, SIGNAL(activated(int)), &QTestEventLoop::instance(), SLOT(exitLoop())); - QSignalSpy errorSpy(&en, SIGNAL(activated(int))); + QSignalSpy errorSpy(&en, &QSocketNotifier::activated); QVERIFY(errorSpy.isValid()); passive->write("hello",6); @@ -289,7 +289,7 @@ void tst_QSocketNotifier::posixSockets() QSocketNotifier wn(posixSocket, QSocketNotifier::Write); connect(&wn, SIGNAL(activated(int)), &QTestEventLoop::instance(), SLOT(exitLoop())); - QSignalSpy writeSpy(&wn, SIGNAL(activated(int))); + QSignalSpy writeSpy(&wn, &QSocketNotifier::activated); QVERIFY(writeSpy.isValid()); qt_safe_write(posixSocket, "goodbye", 8); diff --git a/tests/auto/corelib/kernel/qtimer/tst_qtimer.cpp b/tests/auto/corelib/kernel/qtimer/tst_qtimer.cpp index 27ea3faf81..31c627afcb 100644 --- a/tests/auto/corelib/kernel/qtimer/tst_qtimer.cpp +++ b/tests/auto/corelib/kernel/qtimer/tst_qtimer.cpp @@ -77,6 +77,7 @@ private slots: void cancelLongTimer(); void singleShotStaticFunctionZeroTimeout(); void recurseOnTimeoutAndStopTimer(); + void singleShotToFunctors(); void dontBlockEvents(); void postedEventsShouldNotStarveTimers(); @@ -586,6 +587,14 @@ void tst_QTimer::singleShotStaticFunctionZeroTimeout() QCOMPARE(helper.count, 1); QTest::qWait(500); QCOMPARE(helper.count, 1); + + TimerHelper nhelper; + + QTimer::singleShot(0, &nhelper, &TimerHelper::timeout); + QCoreApplication::processEvents(); + QCOMPARE(nhelper.count, 1); + QCoreApplication::processEvents(); + QCOMPARE(nhelper.count, 1); } class RecursOnTimeoutAndStopTimerTimer : public QObject @@ -631,6 +640,96 @@ void tst_QTimer::recurseOnTimeoutAndStopTimer() QVERIFY(!t.two->isActive()); } +struct CountedStruct +{ + CountedStruct(int *count, QThread *t = Q_NULLPTR) : count(count), thread(t) { } + ~CountedStruct() { } + void operator()() const { ++(*count); if (thread) QCOMPARE(QThread::currentThread(), thread); } + + int *count; + QThread *thread; +}; + +static QEventLoop _e; +static QThread *_t = Q_NULLPTR; + +class StaticEventLoop +{ +public: + static void quitEventLoop() { _e.quit(); if (_t) QCOMPARE(QThread::currentThread(), _t); } +}; + +void tst_QTimer::singleShotToFunctors() +{ + int count = 0; + QEventLoop e; + + QTimer::singleShot(0, CountedStruct(&count)); + QCoreApplication::processEvents(); + QCOMPARE(count, 1); + + QTimer::singleShot(0, &StaticEventLoop::quitEventLoop); + QCOMPARE(_e.exec(), 0); + + QThread t1; + QObject c1; + c1.moveToThread(&t1); + + QObject::connect(&t1, SIGNAL(started()), &e, SLOT(quit())); + t1.start(); + QCOMPARE(e.exec(), 0); + + QTimer::singleShot(0, &c1, CountedStruct(&count, &t1)); + QTest::qWait(500); + QCOMPARE(count, 2); + + t1.quit(); + t1.wait(); + + _t = new QThread; + QObject c2; + c2.moveToThread(_t); + + QObject::connect(_t, SIGNAL(started()), &e, SLOT(quit())); + _t->start(); + QCOMPARE(e.exec(), 0); + + QTimer::singleShot(0, &c2, &StaticEventLoop::quitEventLoop); + QCOMPARE(_e.exec(), 0); + + _t->quit(); + _t->wait(); + _t->deleteLater(); + _t = Q_NULLPTR; + + { + QObject c3; + QTimer::singleShot(500, &c3, CountedStruct(&count)); + } + QTest::qWait(800); + QCOMPARE(count, 2); + +#if defined(Q_COMPILER_LAMBDA) + QTimer::singleShot(0, [&count] { ++count; }); + QCoreApplication::processEvents(); + QCOMPARE(count, 3); + + QObject context; + QThread thread; + + context.moveToThread(&thread); + QObject::connect(&thread, SIGNAL(started()), &e, SLOT(quit())); + thread.start(); + QCOMPARE(e.exec(), 0); + + QTimer::singleShot(0, &context, [&count, &thread] { ++count; QCOMPARE(QThread::currentThread(), &thread); }); + QTest::qWait(500); + QCOMPARE(count, 4); + + thread.quit(); + thread.wait(); +#endif +} class DontBlockEvents : public QObject diff --git a/tests/auto/corelib/plugin/qpluginloader/tst_qpluginloader.cpp b/tests/auto/corelib/plugin/qpluginloader/tst_qpluginloader.cpp index 351e3a23e0..4447eb7a0b 100644 --- a/tests/auto/corelib/plugin/qpluginloader/tst_qpluginloader.cpp +++ b/tests/auto/corelib/plugin/qpluginloader/tst_qpluginloader.cpp @@ -264,8 +264,8 @@ void tst_QPluginLoader::deleteinstanceOnUnload() PluginInterface *instance2 = qobject_cast<PluginInterface*>(loader2.instance()); QCOMPARE(instance2->pluginName(), QLatin1String("Plugin ok")); - QSignalSpy spy1(loader1.instance(), SIGNAL(destroyed())); - QSignalSpy spy2(loader2.instance(), SIGNAL(destroyed())); + QSignalSpy spy1(loader1.instance(), &QObject::destroyed); + QSignalSpy spy2(loader2.instance(), &QObject::destroyed); QVERIFY(spy1.isValid()); QVERIFY(spy2.isValid()); if (pass == 0) { @@ -423,7 +423,7 @@ void tst_QPluginLoader::reloadPlugin() QVERIFY(instance); QCOMPARE(instance->pluginName(), QLatin1String("Plugin ok")); - QSignalSpy spy(loader.instance(), SIGNAL(destroyed())); + QSignalSpy spy(loader.instance(), &QObject::destroyed); QVERIFY(spy.isValid()); QVERIFY(loader.unload()); // refcount reached 0, did really unload QCOMPARE(spy.count(), 1); diff --git a/tests/auto/corelib/statemachine/qstatemachine/tst_qstatemachine.cpp b/tests/auto/corelib/statemachine/qstatemachine/tst_qstatemachine.cpp index 2d7beaa7c8..e8d4fe51a8 100644 --- a/tests/auto/corelib/statemachine/qstatemachine/tst_qstatemachine.cpp +++ b/tests/auto/corelib/statemachine/qstatemachine/tst_qstatemachine.cpp @@ -71,6 +71,27 @@ static int globalTick; QCoreApplication::exec(); \ } +#define TEST_RUNNING_CHANGED(RUNNING) \ +{ \ + QTRY_COMPARE(runningSpy.count(), 1); \ + QList<QVariant> runningArgs = runningSpy.takeFirst(); \ + QVERIFY(runningArgs.at(0).type() == QVariant::Bool); \ + QVERIFY(runningArgs.at(0).toBool() == RUNNING); \ + QCOMPARE(machine.isRunning(), runningArgs.at(0).toBool()); \ +} + +#define TEST_RUNNING_CHANGED_STARTED_STOPPED \ +{ \ + QTRY_COMPARE(runningSpy.count(), 2); \ + QList<QVariant> runningArgs = runningSpy.takeFirst(); \ + QVERIFY(runningArgs.at(0).type() == QVariant::Bool); \ + QVERIFY(runningArgs.at(0).toBool() == true); \ + runningArgs = runningSpy.takeFirst(); \ + QVERIFY(runningArgs.at(0).type() == QVariant::Bool); \ + QVERIFY(runningArgs.at(0).toBool() == false); \ + QCOMPARE(machine.isRunning(), runningArgs.at(0).toBool()); \ +} + class SignalEmitter : public QObject { Q_OBJECT @@ -120,6 +141,7 @@ private slots: #endif void historyStates(); void startAndStop(); + void setRunning(); void targetStateWithNoParent(); void targetStateDeleted(); void transitionToRootState(); @@ -916,10 +938,13 @@ void tst_QStateMachine::historyStateAfterRestart() s2->addTransition(new EventTransition(QEvent::User, s1)); for (int x = 0; x < 2; ++x) { - QSignalSpy startedSpy(&machine, SIGNAL(started())); + QSignalSpy runningSpy(&machine, &QStateMachine::runningChanged); + QVERIFY(runningSpy.isValid()); + QSignalSpy startedSpy(&machine, &QStateMachine::started); QVERIFY(startedSpy.isValid()); machine.start(); QTRY_COMPARE(startedSpy.count(), 1); + TEST_RUNNING_CHANGED(true); QCOMPARE(machine.configuration().count(), 1); QVERIFY(machine.configuration().contains(s1)); @@ -952,10 +977,11 @@ void tst_QStateMachine::historyStateAfterRestart() QVERIFY(machine.configuration().contains(s2)); QVERIFY(machine.configuration().contains(s22)); - QSignalSpy stoppedSpy(&machine, SIGNAL(stopped())); + QSignalSpy stoppedSpy(&machine, &QStateMachine::stopped); QVERIFY(stoppedSpy.isValid()); machine.stop(); QTRY_COMPARE(stoppedSpy.count(), 1); + TEST_RUNNING_CHANGED(false); } } @@ -1232,13 +1258,15 @@ void tst_QStateMachine::stateEntryAndExit() QCOMPARE(trans->sourceState(), (QState*)s2); } - QSignalSpy startedSpy(&machine, SIGNAL(started())); - QSignalSpy stoppedSpy(&machine, SIGNAL(stopped())); - QSignalSpy finishedSpy(&machine, SIGNAL(finished())); + QSignalSpy startedSpy(&machine, &QStateMachine::started); + QSignalSpy stoppedSpy(&machine, &QStateMachine::stopped); + QSignalSpy finishedSpy(&machine, &QStateMachine::finished); + QSignalSpy runningSpy(&machine, &QStateMachine::runningChanged); QVERIFY(startedSpy.isValid()); QVERIFY(stoppedSpy.isValid()); QVERIFY(finishedSpy.isValid()); + QVERIFY(runningSpy.isValid()); machine.setInitialState(s1); QCOMPARE(machine.initialState(), (QAbstractState*)s1); @@ -1252,11 +1280,11 @@ void tst_QStateMachine::stateEntryAndExit() QVERIFY(machine.configuration().isEmpty()); globalTick = 0; QVERIFY(!machine.isRunning()); - QSignalSpy s1EnteredSpy(s1, SIGNAL(entered())); - QSignalSpy s1ExitedSpy(s1, SIGNAL(exited())); - QSignalSpy tTriggeredSpy(t, SIGNAL(triggered())); - QSignalSpy s2EnteredSpy(s2, SIGNAL(entered())); - QSignalSpy s2ExitedSpy(s2, SIGNAL(exited())); + QSignalSpy s1EnteredSpy(s1, &TestState::entered); + QSignalSpy s1ExitedSpy(s1, &TestState::exited); + QSignalSpy tTriggeredSpy(t, &TestTransition::triggered); + QSignalSpy s2EnteredSpy(s2, &TestState::entered); + QSignalSpy s2ExitedSpy(s2, &TestState::exited); QVERIFY(s1EnteredSpy.isValid()); QVERIFY(s1ExitedSpy.isValid()); @@ -1269,6 +1297,7 @@ void tst_QStateMachine::stateEntryAndExit() QTRY_COMPARE(startedSpy.count(), 1); QTRY_COMPARE(finishedSpy.count(), 1); QTRY_COMPARE(stoppedSpy.count(), 0); + TEST_RUNNING_CHANGED_STARTED_STOPPED; QCOMPARE(machine.configuration().count(), 1); QVERIFY(machine.configuration().contains(s3)); @@ -1312,16 +1341,19 @@ void tst_QStateMachine::stateEntryAndExit() s12->addTransition(t2); s2->addTransition(s3); - QSignalSpy startedSpy(&machine, SIGNAL(started())); - QSignalSpy finishedSpy(&machine, SIGNAL(finished())); + QSignalSpy startedSpy(&machine, &QStateMachine::started); + QSignalSpy finishedSpy(&machine, &QStateMachine::finished); + QSignalSpy runningSpy(&machine, &QStateMachine::runningChanged); QVERIFY(startedSpy.isValid()); QVERIFY(finishedSpy.isValid()); + QVERIFY(runningSpy.isValid()); machine.setInitialState(s1); globalTick = 0; machine.start(); QTRY_COMPARE(startedSpy.count(), 1); QTRY_COMPARE(finishedSpy.count(), 1); + TEST_RUNNING_CHANGED_STARTED_STOPPED; QCOMPARE(machine.configuration().count(), 1); QVERIFY(machine.configuration().contains(s3)); @@ -1388,7 +1420,7 @@ void tst_QStateMachine::assignProperty() QCOMPARE(s1->objectName(), QString::fromLatin1("foo")); { - QSignalSpy propertiesAssignedSpy(s1, SIGNAL(propertiesAssigned())); + QSignalSpy propertiesAssignedSpy(s1, &QState::propertiesAssigned); QVERIFY(propertiesAssignedSpy.isValid()); machine.start(); QTRY_COMPARE(propertiesAssignedSpy.count(), 1); @@ -1444,10 +1476,13 @@ void tst_QStateMachine::assignPropertyWithAnimation() s2->addTransition(s2, SIGNAL(propertiesAssigned()), s3); machine.setInitialState(s1); - QSignalSpy finishedSpy(&machine, SIGNAL(finished())); + QSignalSpy runningSpy(&machine, &QStateMachine::runningChanged); + QVERIFY(runningSpy.isValid()); + QSignalSpy finishedSpy(&machine, &QStateMachine::finished); QVERIFY(finishedSpy.isValid()); machine.start(); QTRY_COMPARE(finishedSpy.count(), 1); + TEST_RUNNING_CHANGED_STARTED_STOPPED; QCOMPARE(obj.property("foo").toInt(), 456); QCOMPARE(obj.property("bar").toInt(), 789); } @@ -1473,10 +1508,13 @@ void tst_QStateMachine::assignPropertyWithAnimation() s2->addTransition(s2, SIGNAL(propertiesAssigned()), s3); machine.setInitialState(s1); - QSignalSpy finishedSpy(&machine, SIGNAL(finished())); + QSignalSpy finishedSpy(&machine, &QStateMachine::finished); + QSignalSpy runningSpy(&machine, &QStateMachine::runningChanged); QVERIFY(finishedSpy.isValid()); + QVERIFY(runningSpy.isValid()); machine.start(); QTRY_COMPARE(finishedSpy.count(), 1); + TEST_RUNNING_CHANGED_STARTED_STOPPED; QCOMPARE(obj.property("foo").toInt(), 456); QCOMPARE(obj.property("bar").toInt(), 789); } @@ -1502,10 +1540,13 @@ void tst_QStateMachine::assignPropertyWithAnimation() s2->addTransition(s2, SIGNAL(propertiesAssigned()), s3); machine.setInitialState(s1); - QSignalSpy finishedSpy(&machine, SIGNAL(finished())); + QSignalSpy finishedSpy(&machine, &QStateMachine::finished); + QSignalSpy runningSpy(&machine, &QStateMachine::runningChanged); QVERIFY(finishedSpy.isValid()); + QVERIFY(runningSpy.isValid()); machine.start(); QTRY_COMPARE(finishedSpy.count(), 1); + TEST_RUNNING_CHANGED_STARTED_STOPPED; QCOMPARE(obj.property("foo").toInt(), 456); QCOMPARE(obj.property("bar").toInt(), 654); QCOMPARE(obj.property("baz").toInt(), 789); @@ -1552,10 +1593,13 @@ void tst_QStateMachine::assignPropertyWithAnimation() s22->addTransition(s2, SIGNAL(propertiesAssigned()), s3); machine.setInitialState(s1); - QSignalSpy finishedSpy(&machine, SIGNAL(finished())); + QSignalSpy finishedSpy(&machine, &QStateMachine::finished); + QSignalSpy runningSpy(&machine, &QStateMachine::runningChanged); QVERIFY(finishedSpy.isValid()); + QVERIFY(runningSpy.isValid()); machine.start(); QTRY_COMPARE(finishedSpy.count(), 1); + TEST_RUNNING_CHANGED_STARTED_STOPPED; QCOMPARE(obj.property("foo").toInt(), 321); QCOMPARE(obj.property("bar").toInt(), 789); } @@ -1587,7 +1631,7 @@ void tst_QStateMachine::assignPropertyWithAnimation() machine.setInitialState(group); machine.start(); QTRY_COMPARE(machine.configuration().contains(s1), true); - QSignalSpy propertiesAssignedSpy(s2, SIGNAL(propertiesAssigned())); + QSignalSpy propertiesAssignedSpy(s2, &QState::propertiesAssigned); QVERIFY(propertiesAssignedSpy.isValid()); emitter.emitSignalWithNoArg(); QTRY_COMPARE(machine.configuration().contains(s2), true); @@ -1675,10 +1719,13 @@ void tst_QStateMachine::postEvent() machine.addState(s1); machine.addState(s2); machine.setInitialState(s1); - QSignalSpy finishedSpy(&machine, SIGNAL(finished())); + QSignalSpy finishedSpy(&machine, &QStateMachine::finished); + QSignalSpy runningSpy(&machine, &QStateMachine::runningChanged); QVERIFY(finishedSpy.isValid()); + QVERIFY(runningSpy.isValid()); machine.start(); QTRY_COMPARE(finishedSpy.count(), 1); + TEST_RUNNING_CHANGED_STARTED_STOPPED; QCOMPARE(machine.configuration().size(), 1); QVERIFY(machine.configuration().contains(s2)); @@ -1705,10 +1752,13 @@ void tst_QStateMachine::cancelDelayedEvent() s1->addTransition(new StringTransition("a", s2)); machine.setInitialState(s1); - QSignalSpy startedSpy(&machine, SIGNAL(started())); + QSignalSpy startedSpy(&machine, &QStateMachine::started); + QSignalSpy runningSpy(&machine, &QStateMachine::runningChanged); QVERIFY(startedSpy.isValid()); + QVERIFY(runningSpy.isValid()); machine.start(); QTRY_COMPARE(startedSpy.count(), 1); + TEST_RUNNING_CHANGED(true); QCOMPARE(machine.configuration().size(), 1); QVERIFY(machine.configuration().contains(s1)); @@ -1725,9 +1775,10 @@ void tst_QStateMachine::cancelDelayedEvent() QVERIFY(machine.cancelDelayedEvent(id2)); QVERIFY(!machine.cancelDelayedEvent(id2)); - QSignalSpy finishedSpy(&machine, SIGNAL(finished())); + QSignalSpy finishedSpy(&machine, &QStateMachine::finished); QVERIFY(finishedSpy.isValid()); QTRY_COMPARE(finishedSpy.count(), 1); + TEST_RUNNING_CHANGED(false); QCOMPARE(machine.configuration().size(), 1); QVERIFY(machine.configuration().contains(s2)); } @@ -1740,24 +1791,29 @@ void tst_QStateMachine::postDelayedEventAndStop() s1->addTransition(new StringTransition("a", s2)); machine.setInitialState(s1); - QSignalSpy startedSpy(&machine, SIGNAL(started())); + QSignalSpy runningSpy(&machine, &QStateMachine::runningChanged); + QVERIFY(runningSpy.isValid()); + QSignalSpy startedSpy(&machine, &QStateMachine::started); QVERIFY(startedSpy.isValid()); machine.start(); QTRY_COMPARE(startedSpy.count(), 1); + TEST_RUNNING_CHANGED(true); QCOMPARE(machine.configuration().size(), 1); QVERIFY(machine.configuration().contains(s1)); int id1 = machine.postDelayedEvent(new StringEvent("a"), 0); QVERIFY(id1 != -1); - QSignalSpy stoppedSpy(&machine, SIGNAL(stopped())); + QSignalSpy stoppedSpy(&machine, &QStateMachine::stopped); QVERIFY(stoppedSpy.isValid()); machine.stop(); QTRY_COMPARE(stoppedSpy.count(), 1); + TEST_RUNNING_CHANGED(false); QCOMPARE(machine.configuration().size(), 1); QVERIFY(machine.configuration().contains(s1)); machine.start(); QTRY_COMPARE(startedSpy.count(), 2); + TEST_RUNNING_CHANGED(true); QCOMPARE(machine.configuration().size(), 1); QVERIFY(machine.configuration().contains(s1)); @@ -1765,8 +1821,10 @@ void tst_QStateMachine::postDelayedEventAndStop() QVERIFY(id2 != -1); machine.stop(); QTRY_COMPARE(stoppedSpy.count(), 2); + TEST_RUNNING_CHANGED(false); machine.start(); QTRY_COMPARE(startedSpy.count(), 3); + TEST_RUNNING_CHANGED(true); QTestEventLoop::instance().enterLoop(2); QCOMPARE(machine.configuration().size(), 1); QVERIFY(machine.configuration().contains(s1)); @@ -1813,11 +1871,13 @@ void tst_QStateMachine::postDelayedEventFromThread() DelayedEventPosterThread poster(&machine); poster.start(); - QSignalSpy finishedSpy(&machine, SIGNAL(finished())); + QSignalSpy runningSpy(&machine, &QStateMachine::runningChanged); + QVERIFY(runningSpy.isValid()); + QSignalSpy finishedSpy(&machine, &QStateMachine::finished); QVERIFY(finishedSpy.isValid()); machine.start(); QTRY_COMPARE(finishedSpy.count(), 1); - + TEST_RUNNING_CHANGED_STARTED_STOPPED; QVERIFY(poster.firstEventWasCancelled); } @@ -1826,16 +1886,20 @@ void tst_QStateMachine::stopAndPostEvent() QStateMachine machine; QState *s1 = new QState(&machine); machine.setInitialState(s1); - QSignalSpy startedSpy(&machine, SIGNAL(started())); + QSignalSpy runningSpy(&machine, &QStateMachine::runningChanged); + QVERIFY(runningSpy.isValid()); + QSignalSpy startedSpy(&machine, &QStateMachine::started); QVERIFY(startedSpy.isValid()); machine.start(); QTRY_COMPARE(startedSpy.count(), 1); - QSignalSpy stoppedSpy(&machine, SIGNAL(stopped())); + TEST_RUNNING_CHANGED(true); + QSignalSpy stoppedSpy(&machine, &QStateMachine::stopped); QVERIFY(stoppedSpy.isValid()); machine.stop(); QCOMPARE(stoppedSpy.count(), 0); machine.postEvent(new QEvent(QEvent::User)); QTRY_COMPARE(stoppedSpy.count(), 1); + TEST_RUNNING_CHANGED(false); QCoreApplication::processEvents(); } @@ -1850,10 +1914,13 @@ void tst_QStateMachine::stateFinished() QFinalState *s2 = new QFinalState(&machine); s1->addTransition(s1, SIGNAL(finished()), s2); machine.setInitialState(s1); - QSignalSpy finishedSpy(&machine, SIGNAL(finished())); + QSignalSpy runningSpy(&machine, &QStateMachine::runningChanged); + QVERIFY(runningSpy.isValid()); + QSignalSpy finishedSpy(&machine, &QStateMachine::finished); QVERIFY(finishedSpy.isValid()); machine.start(); QTRY_COMPARE(finishedSpy.count(), 1); + TEST_RUNNING_CHANGED_STARTED_STOPPED; QCOMPARE(machine.configuration().size(), 1); QVERIFY(machine.configuration().contains(s2)); } @@ -1888,11 +1955,14 @@ void tst_QStateMachine::parallelStates() s1->addTransition(s1, SIGNAL(finished()), s2); machine.setInitialState(s1); - QSignalSpy finishedSpy(&machine, SIGNAL(finished())); + QSignalSpy runningSpy(&machine, &QStateMachine::runningChanged); + QVERIFY(runningSpy.isValid()); + QSignalSpy finishedSpy(&machine, &QStateMachine::finished); QVERIFY(finishedSpy.isValid()); globalTick = 0; machine.start(); QTRY_COMPARE(finishedSpy.count(), 1); + TEST_RUNNING_CHANGED_STARTED_STOPPED; QCOMPARE(machine.configuration().size(), 1); QVERIFY(machine.configuration().contains(s2)); @@ -1933,9 +2003,11 @@ void tst_QStateMachine::parallelRootState() QFinalState *s2_f = new QFinalState(s2); s2->setInitialState(s2_f); - QSignalSpy startedSpy(&machine, SIGNAL(started())); + QSignalSpy runningSpy(&machine, &QStateMachine::runningChanged); + QVERIFY(runningSpy.isValid()); + QSignalSpy startedSpy(&machine, &QStateMachine::started); QVERIFY(startedSpy.isValid()); - QSignalSpy finishedSpy(&machine, SIGNAL(finished())); + QSignalSpy finishedSpy(&machine, &QStateMachine::finished); QVERIFY(finishedSpy.isValid()); machine.start(); QTRY_COMPARE(startedSpy.count(), 1); @@ -1945,6 +2017,7 @@ void tst_QStateMachine::parallelRootState() QVERIFY(machine.configuration().contains(s2)); QVERIFY(machine.configuration().contains(s2_f)); QTRY_COMPARE(finishedSpy.count(), 1); + TEST_RUNNING_CHANGED_STARTED_STOPPED; } void tst_QStateMachine::allSourceToTargetConfigurations() @@ -1984,7 +2057,9 @@ void tst_QStateMachine::allSourceToTargetConfigurations() s2->addTransition(new StringTransition("f", s11)); s0->addTransition(new StringTransition("e", s211)); - QSignalSpy finishedSpy(&machine, SIGNAL(finished())); + QSignalSpy runningSpy(&machine, &QStateMachine::runningChanged); + QVERIFY(runningSpy.isValid()); + QSignalSpy finishedSpy(&machine, &QStateMachine::finished); QVERIFY(finishedSpy.isValid()); machine.setInitialState(s0); machine.start(); @@ -2008,6 +2083,7 @@ void tst_QStateMachine::allSourceToTargetConfigurations() QCoreApplication::processEvents(); QTRY_COMPARE(finishedSpy.count(), 1); + TEST_RUNNING_CHANGED_STARTED_STOPPED; } class TestSignalTransition : public QSignalTransition @@ -2094,7 +2170,9 @@ void tst_QStateMachine::signalTransitions() QCOMPARE(trans->senderObject(), (QObject*)&emitter); QCOMPARE(trans->signal(), QByteArray(SIGNAL(signalWithNoArg()))); - QSignalSpy finishedSpy(&machine, SIGNAL(finished())); + QSignalSpy runningSpy(&machine, &QStateMachine::runningChanged); + QVERIFY(runningSpy.isValid()); + QSignalSpy finishedSpy(&machine, &QStateMachine::finished); QVERIFY(finishedSpy.isValid()); machine.setInitialState(s0); machine.start(); @@ -2103,6 +2181,7 @@ void tst_QStateMachine::signalTransitions() emitter.emitSignalWithNoArg(); QTRY_COMPARE(finishedSpy.count(), 1); + TEST_RUNNING_CHANGED_STARTED_STOPPED; emitter.emitSignalWithNoArg(); @@ -2112,6 +2191,7 @@ void tst_QStateMachine::signalTransitions() QCoreApplication::processEvents(); emitter.emitSignalWithIntArg(123); QTRY_COMPARE(finishedSpy.count(), 2); + TEST_RUNNING_CHANGED_STARTED_STOPPED; machine.start(); QCoreApplication::processEvents(); @@ -2119,6 +2199,7 @@ void tst_QStateMachine::signalTransitions() QCOMPARE(trans->signal(), QByteArray(SIGNAL(signalWithNoArg()))); emitter.emitSignalWithNoArg(); QTRY_COMPARE(finishedSpy.count(), 3); + TEST_RUNNING_CHANGED_STARTED_STOPPED; SignalEmitter emitter2; machine.start(); @@ -2126,12 +2207,14 @@ void tst_QStateMachine::signalTransitions() trans->setSenderObject(&emitter2); emitter2.emitSignalWithNoArg(); QTRY_COMPARE(finishedSpy.count(), 4); + TEST_RUNNING_CHANGED_STARTED_STOPPED; machine.start(); QCoreApplication::processEvents(); QTest::ignoreMessage(QtWarningMsg, "QSignalTransition: no such signal: SignalEmitter::noSuchSignal()"); trans->setSignal(SIGNAL(noSuchSignal())); QCOMPARE(trans->signal(), QByteArray(SIGNAL(noSuchSignal()))); + TEST_RUNNING_CHANGED(true); } { QStateMachine machine; @@ -2145,7 +2228,9 @@ void tst_QStateMachine::signalTransitions() QCOMPARE(trans->senderObject(), (QObject*)&emitter); QCOMPARE(trans->signal(), QByteArray("signalWithNoArg()")); - QSignalSpy finishedSpy(&machine, SIGNAL(finished())); + QSignalSpy runningSpy(&machine, &QStateMachine::runningChanged); + QVERIFY(runningSpy.isValid()); + QSignalSpy finishedSpy(&machine, &QStateMachine::finished); QVERIFY(finishedSpy.isValid()); machine.setInitialState(s0); machine.start(); @@ -2154,6 +2239,7 @@ void tst_QStateMachine::signalTransitions() emitter.emitSignalWithNoArg(); QTRY_COMPARE(finishedSpy.count(), 1); + TEST_RUNNING_CHANGED_STARTED_STOPPED; trans->setSignal("signalWithIntArg(int)"); QCOMPARE(trans->signal(), QByteArray("signalWithIntArg(int)")); @@ -2161,6 +2247,7 @@ void tst_QStateMachine::signalTransitions() QCoreApplication::processEvents(); emitter.emitSignalWithIntArg(123); QTRY_COMPARE(finishedSpy.count(), 2); + TEST_RUNNING_CHANGED_STARTED_STOPPED; } { QStateMachine machine; @@ -2170,7 +2257,9 @@ void tst_QStateMachine::signalTransitions() TestSignalTransition *trans = new TestSignalTransition(&emitter, SIGNAL(signalWithIntArg(int)), s1); s0->addTransition(trans); - QSignalSpy finishedSpy(&machine, SIGNAL(finished())); + QSignalSpy runningSpy(&machine, &QStateMachine::runningChanged); + QVERIFY(runningSpy.isValid()); + QSignalSpy finishedSpy(&machine, &QStateMachine::finished); QVERIFY(finishedSpy.isValid()); machine.setInitialState(s0); machine.start(); @@ -2179,6 +2268,7 @@ void tst_QStateMachine::signalTransitions() emitter.emitSignalWithIntArg(123); QTRY_COMPARE(finishedSpy.count(), 1); + TEST_RUNNING_CHANGED_STARTED_STOPPED; QCOMPARE(trans->eventTestSenderReceived(), (QObject*)&emitter); QCOMPARE(trans->eventTestSignalIndexReceived(), emitter.metaObject()->indexOfSignal("signalWithIntArg(int)")); QCOMPARE(trans->eventTestArgumentsReceived().size(), 1); @@ -2196,7 +2286,9 @@ void tst_QStateMachine::signalTransitions() TestSignalTransition *trans = new TestSignalTransition(&emitter, SIGNAL(signalWithStringArg(QString)), s1); s0->addTransition(trans); - QSignalSpy finishedSpy(&machine, SIGNAL(finished())); + QSignalSpy runningSpy(&machine, &QStateMachine::runningChanged); + QVERIFY(runningSpy.isValid()); + QSignalSpy finishedSpy(&machine, &QStateMachine::finished); QVERIFY(finishedSpy.isValid()); machine.setInitialState(s0); machine.start(); @@ -2206,6 +2298,7 @@ void tst_QStateMachine::signalTransitions() emitter.emitSignalWithStringArg(testString); QTRY_COMPARE(finishedSpy.count(), 1); + TEST_RUNNING_CHANGED_STARTED_STOPPED; QCOMPARE(trans->eventTestSenderReceived(), (QObject*)&emitter); QCOMPARE(trans->eventTestSignalIndexReceived(), emitter.metaObject()->indexOfSignal("signalWithStringArg(QString)")); QCOMPARE(trans->eventTestArgumentsReceived().size(), 1); @@ -2232,7 +2325,9 @@ void tst_QStateMachine::signalTransitions() trans->setTargetState(s1); s0->addTransition(trans); - QSignalSpy finishedSpy(&machine, SIGNAL(finished())); + QSignalSpy runningSpy(&machine, &QStateMachine::runningChanged); + QVERIFY(runningSpy.isValid()); + QSignalSpy finishedSpy(&machine, &QStateMachine::finished); QVERIFY(finishedSpy.isValid()); machine.setInitialState(s0); machine.start(); @@ -2241,6 +2336,7 @@ void tst_QStateMachine::signalTransitions() emitter.emitSignalWithNoArg(); QTRY_COMPARE(finishedSpy.count(), 1); + TEST_RUNNING_CHANGED_STARTED_STOPPED; } // Multiple transitions for same (object,signal) { @@ -2251,7 +2347,7 @@ void tst_QStateMachine::signalTransitions() QSignalTransition *t0 = s0->addTransition(&emitter, SIGNAL(signalWithNoArg()), s1); QSignalTransition *t1 = s1->addTransition(&emitter, SIGNAL(signalWithNoArg()), s0); - QSignalSpy finishedSpy(&machine, SIGNAL(finished())); + QSignalSpy finishedSpy(&machine, &QStateMachine::finished); QVERIFY(finishedSpy.isValid()); machine.setInitialState(s0); machine.start(); @@ -2300,30 +2396,38 @@ void tst_QStateMachine::signalTransitions() QFinalState *s3 = new QFinalState(&machine); s0->addTransition(&emitter, SIGNAL(signalWithStringArg(QString)), s3); - QSignalSpy startedSpy(&machine, SIGNAL(started())); - QSignalSpy finishedSpy(&machine, SIGNAL(finished())); + QSignalSpy startedSpy(&machine, &QStateMachine::started); + QSignalSpy finishedSpy(&machine, &QStateMachine::finished); + QSignalSpy runningSpy(&machine, &QStateMachine::runningChanged); QVERIFY(startedSpy.isValid()); QVERIFY(finishedSpy.isValid()); + QVERIFY(runningSpy.isValid()); machine.setInitialState(s0); machine.start(); QTRY_COMPARE(startedSpy.count(), 1); + TEST_RUNNING_CHANGED(true); emitter.emitSignalWithNoArg(); QTRY_COMPARE(finishedSpy.count(), 1); + TEST_RUNNING_CHANGED(false); QCOMPARE(machine.configuration().size(), 1); QVERIFY(machine.configuration().contains(s1)); machine.start(); QTRY_COMPARE(startedSpy.count(), 2); + TEST_RUNNING_CHANGED(true); emitter.emitSignalWithIntArg(123); QTRY_COMPARE(finishedSpy.count(), 2); + TEST_RUNNING_CHANGED(false); QCOMPARE(machine.configuration().size(), 1); QVERIFY(machine.configuration().contains(s2)); machine.start(); QTRY_COMPARE(startedSpy.count(), 3); + TEST_RUNNING_CHANGED(true); emitter.emitSignalWithStringArg("hello"); QTRY_COMPARE(finishedSpy.count(), 3); + TEST_RUNNING_CHANGED(false); QCOMPARE(machine.configuration().size(), 1); QVERIFY(machine.configuration().contains(s3)); } @@ -2341,18 +2445,22 @@ void tst_QStateMachine::signalTransitions() QVERIFY(t1 != 0); QCOMPARE(t1->signal(), QByteArray(SIGNAL(signalWithStringArg(QString)))); - QSignalSpy startedSpy(&machine, SIGNAL(started())); - QSignalSpy finishedSpy(&machine, SIGNAL(finished())); + QSignalSpy startedSpy(&machine, &QStateMachine::started); + QSignalSpy finishedSpy(&machine, &QStateMachine::finished); + QSignalSpy runningSpy(&machine, &QStateMachine::runningChanged); QVERIFY(startedSpy.isValid()); QVERIFY(finishedSpy.isValid()); + QVERIFY(runningSpy.isValid()); machine.setInitialState(s0); machine.start(); QTRY_COMPARE(startedSpy.count(), 1); QCOMPARE(finishedSpy.count(), 0); + TEST_RUNNING_CHANGED(true); emitter.emitSignalWithNoArg(); QTRY_COMPARE(finishedSpy.count(), 1); + TEST_RUNNING_CHANGED(false); } } @@ -2406,7 +2514,9 @@ void tst_QStateMachine::eventTransitions() QCOMPARE(trans->targetState(), (QAbstractState*)s1); s0->addTransition(trans); - QSignalSpy finishedSpy(&machine, SIGNAL(finished())); + QSignalSpy runningSpy(&machine, &QStateMachine::runningChanged); + QVERIFY(runningSpy.isValid()); + QSignalSpy finishedSpy(&machine, &QStateMachine::finished); QVERIFY(finishedSpy.isValid()); machine.setInitialState(s0); machine.start(); @@ -2414,6 +2524,7 @@ void tst_QStateMachine::eventTransitions() QTest::mousePress(&button, Qt::LeftButton); QTRY_COMPARE(finishedSpy.count(), 1); + TEST_RUNNING_CHANGED_STARTED_STOPPED; QTest::mousePress(&button, Qt::LeftButton); @@ -2423,12 +2534,14 @@ void tst_QStateMachine::eventTransitions() QCoreApplication::processEvents(); QTest::mouseRelease(&button, Qt::LeftButton); QTRY_COMPARE(finishedSpy.count(), 2); + TEST_RUNNING_CHANGED_STARTED_STOPPED; machine.start(); QCoreApplication::processEvents(); trans->setEventType(QEvent::MouseButtonPress); QTest::mousePress(&button, Qt::LeftButton); QTRY_COMPARE(finishedSpy.count(), 3); + TEST_RUNNING_CHANGED_STARTED_STOPPED; QPushButton button2; machine.start(); @@ -2436,6 +2549,7 @@ void tst_QStateMachine::eventTransitions() trans->setEventSource(&button2); QTest::mousePress(&button2, Qt::LeftButton); QTRY_COMPARE(finishedSpy.count(), 4); + TEST_RUNNING_CHANGED_STARTED_STOPPED; } for (int x = 0; x < 2; ++x) { QStateMachine machine; @@ -2459,7 +2573,9 @@ void tst_QStateMachine::eventTransitions() QCOMPARE(trans->targetState(), (QAbstractState*)s1); s0->addTransition(trans); - QSignalSpy finishedSpy(&machine, SIGNAL(finished())); + QSignalSpy runningSpy(&machine, &QStateMachine::runningChanged); + QVERIFY(runningSpy.isValid()); + QSignalSpy finishedSpy(&machine, &QStateMachine::finished); QVERIFY(finishedSpy.isValid()); machine.setInitialState(s0); machine.start(); @@ -2469,6 +2585,7 @@ void tst_QStateMachine::eventTransitions() QCoreApplication::processEvents(); QTRY_COMPARE(finishedSpy.count(), 1); + TEST_RUNNING_CHANGED_STARTED_STOPPED; } { QStateMachine machine; @@ -2485,16 +2602,19 @@ void tst_QStateMachine::eventTransitions() trans->setTargetState(s1); s0->addTransition(trans); - QSignalSpy finishedSpy(&machine, SIGNAL(finished())); + QSignalSpy runningSpy(&machine, &QStateMachine::runningChanged); + QVERIFY(runningSpy.isValid()); + QSignalSpy finishedSpy(&machine, &QStateMachine::finished); QVERIFY(finishedSpy.isValid()); machine.setInitialState(s0); machine.start(); QCoreApplication::processEvents(); - + TEST_RUNNING_CHANGED(true); QTest::mousePress(&button, Qt::LeftButton); QCoreApplication::processEvents(); QTRY_COMPARE(finishedSpy.count(), 1); + TEST_RUNNING_CHANGED(false); } { @@ -2508,16 +2628,20 @@ void tst_QStateMachine::eventTransitions() trans->setTargetState(s1); s0->addTransition(trans); - QSignalSpy finishedSpy(&machine, SIGNAL(finished())); + QSignalSpy runningSpy(&machine, &QStateMachine::runningChanged); + QVERIFY(runningSpy.isValid()); + QSignalSpy finishedSpy(&machine, &QStateMachine::finished); QVERIFY(finishedSpy.isValid()); machine.setInitialState(s0); machine.start(); QCoreApplication::processEvents(); + TEST_RUNNING_CHANGED(true); QTest::keyPress(&button, Qt::Key_A); QCoreApplication::processEvents(); QTRY_COMPARE(finishedSpy.count(), 1); + TEST_RUNNING_CHANGED(false); } { QStateMachine machine; @@ -2534,16 +2658,20 @@ void tst_QStateMachine::eventTransitions() trans->setTargetState(s1); s0->addTransition(trans); - QSignalSpy finishedSpy(&machine, SIGNAL(finished())); + QSignalSpy runningSpy(&machine, &QStateMachine::runningChanged); + QVERIFY(runningSpy.isValid()); + QSignalSpy finishedSpy(&machine, &QStateMachine::finished); QVERIFY(finishedSpy.isValid()); machine.setInitialState(s0); machine.start(); QCoreApplication::processEvents(); + TEST_RUNNING_CHANGED(true); QTest::keyPress(&button, Qt::Key_A); QCoreApplication::processEvents(); QTRY_COMPARE(finishedSpy.count(), 1); + TEST_RUNNING_CHANGED(false); } // Multiple transitions for same (object,event) { @@ -2557,7 +2685,7 @@ void tst_QStateMachine::eventTransitions() t1->setTargetState(s0); s1->addTransition(t1); - QSignalSpy finishedSpy(&machine, SIGNAL(finished())); + QSignalSpy finishedSpy(&machine, &QStateMachine::finished); QVERIFY(finishedSpy.isValid()); machine.setInitialState(s0); machine.start(); @@ -2607,23 +2735,29 @@ void tst_QStateMachine::eventTransitions() t1->setTargetState(s2); s0->addTransition(t1); - QSignalSpy startedSpy(&machine, SIGNAL(started())); - QSignalSpy finishedSpy(&machine, SIGNAL(finished())); + QSignalSpy startedSpy(&machine, &QStateMachine::started); + QSignalSpy finishedSpy(&machine, &QStateMachine::finished); + QSignalSpy runningSpy(&machine, &QStateMachine::runningChanged); QVERIFY(startedSpy.isValid()); QVERIFY(finishedSpy.isValid()); + QVERIFY(runningSpy.isValid()); machine.setInitialState(s0); machine.start(); QTRY_COMPARE(startedSpy.count(), 1); + TEST_RUNNING_CHANGED(true); QTest::mousePress(&button, Qt::LeftButton); QTRY_COMPARE(finishedSpy.count(), 1); + TEST_RUNNING_CHANGED(false); QCOMPARE(machine.configuration().size(), 1); QVERIFY(machine.configuration().contains(s1)); machine.start(); QTRY_COMPARE(startedSpy.count(), 2); + TEST_RUNNING_CHANGED(true); QTest::mouseRelease(&button, Qt::LeftButton); QTRY_COMPARE(finishedSpy.count(), 2); + TEST_RUNNING_CHANGED(false); QCOMPARE(machine.configuration().size(), 1); QVERIFY(machine.configuration().contains(s2)); } @@ -2637,12 +2771,15 @@ void tst_QStateMachine::eventTransitions() trans->setTargetState(s1); s0->addTransition(trans); - QSignalSpy startedSpy(&machine, SIGNAL(started())); + QSignalSpy runningSpy(&machine, &QStateMachine::runningChanged); + QVERIFY(runningSpy.isValid()); + QSignalSpy startedSpy(&machine, &QStateMachine::started); QVERIFY(startedSpy.isValid()); machine.setInitialState(s0); machine.start(); QTest::ignoreMessage(QtWarningMsg, "QObject event transitions are not supported for custom types"); QTRY_COMPARE(startedSpy.count(), 1); + TEST_RUNNING_CHANGED(true); } // custom transition { @@ -2655,16 +2792,20 @@ void tst_QStateMachine::eventTransitions() QCOMPARE(trans->eventSourceReceived(), (QObject*)0); QCOMPARE(trans->eventTypeReceived(), QEvent::None); - QSignalSpy finishedSpy(&machine, SIGNAL(finished())); + QSignalSpy runningSpy(&machine, &QStateMachine::runningChanged); + QVERIFY(runningSpy.isValid()); + QSignalSpy finishedSpy(&machine, &QStateMachine::finished); QVERIFY(finishedSpy.isValid()); machine.setInitialState(s0); machine.start(); QCoreApplication::processEvents(); + TEST_RUNNING_CHANGED(true); QTest::mousePress(&button, Qt::LeftButton); QCoreApplication::processEvents(); QTRY_COMPARE(finishedSpy.count(), 1); + TEST_RUNNING_CHANGED(false); QCOMPARE(trans->eventSourceReceived(), (QObject*)&button); QCOMPARE(trans->eventTypeReceived(), QEvent::MouseButtonPress); @@ -2684,16 +2825,20 @@ void tst_QStateMachine::graphicsSceneEventTransitions() s1->addTransition(t); machine.setInitialState(s1); - QSignalSpy startedSpy(&machine, SIGNAL(started())); - QSignalSpy finishedSpy(&machine, SIGNAL(finished())); + QSignalSpy startedSpy(&machine, &QStateMachine::started); + QSignalSpy finishedSpy(&machine, &QStateMachine::finished); + QSignalSpy runningSpy(&machine, &QStateMachine::runningChanged); QVERIFY(startedSpy.isValid()); QVERIFY(finishedSpy.isValid()); + QVERIFY(runningSpy.isValid()); machine.start(); QTRY_COMPARE(startedSpy.count(), 1); QVERIFY(finishedSpy.count() == 0); + TEST_RUNNING_CHANGED(true); QGraphicsSceneMouseEvent mouseEvent(QEvent::GraphicsSceneMouseMove); scene.sendEvent(textItem, &mouseEvent); QTRY_COMPARE(finishedSpy.count(), 1); + TEST_RUNNING_CHANGED(false); } #endif @@ -2734,7 +2879,9 @@ void tst_QStateMachine::historyStates() root->setInitialState(s0); s0->setInitialState(s00); - QSignalSpy finishedSpy(&machine, SIGNAL(finished())); + QSignalSpy runningSpy(&machine, &QStateMachine::runningChanged); + QVERIFY(runningSpy.isValid()); + QSignalSpy finishedSpy(&machine, &QStateMachine::finished); QVERIFY(finishedSpy.isValid()); machine.start(); QCoreApplication::processEvents(); @@ -2765,19 +2912,22 @@ void tst_QStateMachine::historyStates() QVERIFY(machine.configuration().contains(s2)); QTRY_COMPARE(finishedSpy.count(), 1); + TEST_RUNNING_CHANGED_STARTED_STOPPED; } } void tst_QStateMachine::startAndStop() { QStateMachine machine; - QSignalSpy startedSpy(&machine, SIGNAL(started())); - QSignalSpy stoppedSpy(&machine, SIGNAL(stopped())); - QSignalSpy finishedSpy(&machine, SIGNAL(finished())); + QSignalSpy startedSpy(&machine, &QStateMachine::started); + QSignalSpy stoppedSpy(&machine, &QStateMachine::stopped); + QSignalSpy finishedSpy(&machine, &QStateMachine::finished); + QSignalSpy runningSpy(&machine, &QStateMachine::runningChanged); QVERIFY(startedSpy.isValid()); QVERIFY(stoppedSpy.isValid()); QVERIFY(finishedSpy.isValid()); + QVERIFY(runningSpy.isValid()); QVERIFY(!machine.isRunning()); QTest::ignoreMessage(QtWarningMsg, "QStateMachine::start: No initial state set for machine. Refusing to start."); @@ -2785,11 +2935,13 @@ void tst_QStateMachine::startAndStop() QCOMPARE(startedSpy.count(), 0); QCOMPARE(stoppedSpy.count(), 0); QCOMPARE(finishedSpy.count(), 0); + QCOMPARE(runningSpy.count(), 0); QVERIFY(!machine.isRunning()); machine.stop(); QCOMPARE(startedSpy.count(), 0); QCOMPARE(stoppedSpy.count(), 0); QCOMPARE(finishedSpy.count(), 0); + QCOMPARE(runningSpy.count(), 0); QState *s1 = new QState(&machine); machine.setInitialState(s1); @@ -2798,17 +2950,20 @@ void tst_QStateMachine::startAndStop() QTRY_COMPARE(startedSpy.count(), 1); QCOMPARE(stoppedSpy.count(), 0); QCOMPARE(finishedSpy.count(), 0); + TEST_RUNNING_CHANGED(true); QCOMPARE(machine.configuration().count(), 1); QVERIFY(machine.configuration().contains(s1)); QTest::ignoreMessage(QtWarningMsg, "QStateMachine::start(): already running"); machine.start(); + QCOMPARE(runningSpy.count(), 0); machine.stop(); QTRY_COMPARE(machine.isRunning(), false); QTRY_COMPARE(stoppedSpy.count(), 1); QCOMPARE(startedSpy.count(), 1); QCOMPARE(finishedSpy.count(), 0); + TEST_RUNNING_CHANGED(false); QCOMPARE(machine.configuration().count(), 1); QVERIFY(machine.configuration().contains(s1)); @@ -2817,6 +2972,81 @@ void tst_QStateMachine::startAndStop() machine.stop(); QTRY_COMPARE(startedSpy.count(), 2); QCOMPARE(stoppedSpy.count(), 2); + TEST_RUNNING_CHANGED_STARTED_STOPPED; +} + +void tst_QStateMachine::setRunning() +{ + QStateMachine machine; + QSignalSpy startedSpy(&machine, &QStateMachine::started); + QSignalSpy stoppedSpy(&machine, &QStateMachine::stopped); + QSignalSpy finishedSpy(&machine, &QStateMachine::finished); + QSignalSpy runningSpy(&machine, &QStateMachine::runningChanged); + + QVERIFY(startedSpy.isValid()); + QVERIFY(stoppedSpy.isValid()); + QVERIFY(finishedSpy.isValid()); + QVERIFY(runningSpy.isValid()); + + QVERIFY(!machine.isRunning()); + QTest::ignoreMessage(QtWarningMsg, "QStateMachine::start: No initial state set for machine. Refusing to start."); + machine.setRunning(true); + QCOMPARE(startedSpy.count(), 0); + QCOMPARE(stoppedSpy.count(), 0); + QCOMPARE(finishedSpy.count(), 0); + QCOMPARE(runningSpy.count(), 0); + QVERIFY(!machine.isRunning()); + machine.setRunning(false); + QCOMPARE(startedSpy.count(), 0); + QCOMPARE(stoppedSpy.count(), 0); + QCOMPARE(finishedSpy.count(), 0); + QCOMPARE(runningSpy.count(), 0); + + QState *s1 = new QState(&machine); + machine.setInitialState(s1); + machine.setRunning(true); + QTRY_COMPARE(machine.isRunning(), true); + QTRY_COMPARE(startedSpy.count(), 1); + QCOMPARE(stoppedSpy.count(), 0); + QCOMPARE(finishedSpy.count(), 0); + TEST_RUNNING_CHANGED(true); + QCOMPARE(machine.configuration().count(), 1); + QVERIFY(machine.configuration().contains(s1)); + + QTest::ignoreMessage(QtWarningMsg, "QStateMachine::start(): already running"); + machine.setRunning(true); + QCOMPARE(runningSpy.count(), 0); + + machine.setRunning(false); + QTRY_COMPARE(machine.isRunning(), false); + QTRY_COMPARE(stoppedSpy.count(), 1); + QCOMPARE(startedSpy.count(), 1); + QCOMPARE(finishedSpy.count(), 0); + TEST_RUNNING_CHANGED(false); + QCOMPARE(machine.configuration().count(), 1); + QVERIFY(machine.configuration().contains(s1)); + + machine.setRunning(false); + QCOMPARE(runningSpy.count(), 0); + + machine.start(); + machine.setRunning(false); + QTRY_COMPARE(startedSpy.count(), 2); + QCOMPARE(stoppedSpy.count(), 2); + TEST_RUNNING_CHANGED_STARTED_STOPPED; + QState *s1_1 = new QState(s1); + QFinalState *s1_2 = new QFinalState(s1); + s1_1->addTransition(s1_2); + s1->setInitialState(s1_1); + QFinalState *s2 = new QFinalState(&machine); + s1->addTransition(s1, SIGNAL(finished()), s2); + machine.setRunning(false); + QCOMPARE(runningSpy.count(), 0); + machine.setRunning(true); + TEST_RUNNING_CHANGED_STARTED_STOPPED; + QTRY_COMPARE(startedSpy.count(), 3); + QCOMPARE(stoppedSpy.count(), 2); + QCOMPARE(finishedSpy.count(), 1); } void tst_QStateMachine::targetStateWithNoParent() @@ -2827,13 +3057,15 @@ void tst_QStateMachine::targetStateWithNoParent() QState s2; s1->addTransition(&s2); machine.setInitialState(s1); - QSignalSpy startedSpy(&machine, SIGNAL(started())); - QSignalSpy stoppedSpy(&machine, SIGNAL(stopped())); - QSignalSpy finishedSpy(&machine, SIGNAL(finished())); + QSignalSpy startedSpy(&machine, &QStateMachine::started); + QSignalSpy stoppedSpy(&machine, &QStateMachine::stopped); + QSignalSpy finishedSpy(&machine, &QStateMachine::finished); + QSignalSpy runningSpy(&machine, &QStateMachine::runningChanged); QVERIFY(startedSpy.isValid()); QVERIFY(stoppedSpy.isValid()); QVERIFY(finishedSpy.isValid()); + QVERIFY(runningSpy.isValid()); machine.start(); QTest::ignoreMessage(QtWarningMsg, "Unrecoverable error detected in running state machine: No common ancestor for targets and source of transition from state 's1'"); @@ -2841,6 +3073,7 @@ void tst_QStateMachine::targetStateWithNoParent() QCOMPARE(machine.isRunning(), false); QCOMPARE(stoppedSpy.count(), 1); QCOMPARE(finishedSpy.count(), 0); + TEST_RUNNING_CHANGED_STARTED_STOPPED; QCOMPARE(machine.error(), QStateMachine::NoCommonAncestorForTransitionError); } @@ -3263,17 +3496,20 @@ void tst_QStateMachine::propertiesAssignedSignalTransitionsReuseAnimationGroup() QParallelAnimationGroup animationGroup; animationGroup.addAnimation(new QPropertyAnimation(object, "foo")); - QSignalSpy animationFinishedSpy(&animationGroup, SIGNAL(finished())); + QSignalSpy animationFinishedSpy(&animationGroup, &QParallelAnimationGroup::finished); QVERIFY(animationFinishedSpy.isValid()); s1->addTransition(s1, SIGNAL(propertiesAssigned()), s2)->addAnimation(&animationGroup); s2->addTransition(s2, SIGNAL(propertiesAssigned()), s3)->addAnimation(&animationGroup); s3->addTransition(s3, SIGNAL(propertiesAssigned()), s4); machine.setInitialState(s1); - QSignalSpy machineFinishedSpy(&machine, SIGNAL(finished())); + QSignalSpy runningSpy(&machine, &QStateMachine::runningChanged); + QVERIFY(runningSpy.isValid()); + QSignalSpy machineFinishedSpy(&machine, &QStateMachine::finished); QVERIFY(machineFinishedSpy.isValid()); machine.start(); QTRY_COMPARE(machineFinishedSpy.count(), 1); + TEST_RUNNING_CHANGED_STARTED_STOPPED; QCOMPARE(machine.configuration().size(), 1); QVERIFY(machine.configuration().contains(s4)); QCOMPARE(object->property("foo").toInt(), 789); @@ -3770,12 +4006,15 @@ void tst_QStateMachine::nestedStateMachines() group->addTransition(group, SIGNAL(finished()), final); machine.setInitialState(group); - QSignalSpy startedSpy(&machine, SIGNAL(started())); - QSignalSpy finishedSpy(&machine, SIGNAL(finished())); + QSignalSpy startedSpy(&machine, &QStateMachine::started); + QSignalSpy finishedSpy(&machine, &QStateMachine::finished); + QSignalSpy runningSpy(&machine, &QStateMachine::runningChanged); QVERIFY(startedSpy.isValid()); QVERIFY(finishedSpy.isValid()); + QVERIFY(runningSpy.isValid()); machine.start(); QTRY_COMPARE(startedSpy.count(), 1); + TEST_RUNNING_CHANGED(true); QTRY_COMPARE(machine.configuration().count(), 1+2*3); QVERIFY(machine.configuration().contains(group)); for (int i = 0; i < 3; ++i) @@ -3787,6 +4026,7 @@ void tst_QStateMachine::nestedStateMachines() subMachines[i]->postEvent(new QEvent(QEvent::User)); QTRY_COMPARE(finishedSpy.count(), 1); + TEST_RUNNING_CHANGED(false); } void tst_QStateMachine::goToState() @@ -3795,10 +4035,13 @@ void tst_QStateMachine::goToState() QState *s1 = new QState(&machine); QState *s2 = new QState(&machine); machine.setInitialState(s1); - QSignalSpy startedSpy(&machine, SIGNAL(started())); + QSignalSpy startedSpy(&machine, &QStateMachine::started); QVERIFY(startedSpy.isValid()); + QSignalSpy runningSpy(&machine, &QStateMachine::runningChanged); + QVERIFY(runningSpy.isValid()); machine.start(); QTRY_COMPARE(startedSpy.count(), 1); + TEST_RUNNING_CHANGED(true); QStateMachinePrivate::get(&machine)->goToState(s2); QCoreApplication::processEvents(); @@ -3838,10 +4081,13 @@ void tst_QStateMachine::goToStateFromSourceWithTransition() s1->addTransition(new QSignalTransition); QState *s2 = new QState(&machine); machine.setInitialState(s1); - QSignalSpy startedSpy(&machine, SIGNAL(started())); + QSignalSpy runningSpy(&machine, &QStateMachine::runningChanged); + QVERIFY(runningSpy.isValid()); + QSignalSpy startedSpy(&machine, &QStateMachine::started); QVERIFY(startedSpy.isValid()); machine.start(); QTRY_COMPARE(startedSpy.count(), 1); + TEST_RUNNING_CHANGED(true); QStateMachinePrivate::get(&machine)->goToState(s2); QCoreApplication::processEvents(); @@ -3928,10 +4174,13 @@ void tst_QStateMachine::postEventFromOtherThread() poster.start(); - QSignalSpy finishedSpy(&machine, SIGNAL(finished())); + QSignalSpy runningSpy(&machine, &QStateMachine::runningChanged); + QVERIFY(runningSpy.isValid()); + QSignalSpy finishedSpy(&machine, &QStateMachine::finished); QVERIFY(finishedSpy.isValid()); machine.start(); QTRY_COMPARE(finishedSpy.count(), 1); + TEST_RUNNING_CHANGED_STARTED_STOPPED; } #ifndef QT_NO_WIDGETS @@ -3984,18 +4233,21 @@ void tst_QStateMachine::stopInTransitionToFinalState() machine.setInitialState(s1); QObject::connect(t1, SIGNAL(triggered()), &machine, SLOT(stop())); - QSignalSpy stoppedSpy(&machine, SIGNAL(stopped())); - QSignalSpy finishedSpy(&machine, SIGNAL(finished())); - QSignalSpy s2EnteredSpy(s2, SIGNAL(entered())); + QSignalSpy stoppedSpy(&machine, &QStateMachine::stopped); + QSignalSpy finishedSpy(&machine, &QStateMachine::finished); + QSignalSpy s2EnteredSpy(s2, &QFinalState::entered); + QSignalSpy runningSpy(&machine, &QStateMachine::runningChanged); QVERIFY(stoppedSpy.isValid()); QVERIFY(finishedSpy.isValid()); QVERIFY(s2EnteredSpy.isValid()); + QVERIFY(runningSpy.isValid()); machine.start(); // Stopping should take precedence over finished. QTRY_COMPARE(stoppedSpy.count(), 1); QCOMPARE(finishedSpy.count(), 0); QCOMPARE(s2EnteredSpy.count(), 1); + TEST_RUNNING_CHANGED_STARTED_STOPPED; QCOMPARE(machine.configuration().size(), 1); QVERIFY(machine.configuration().contains(s2)); } @@ -4029,19 +4281,23 @@ void tst_QStateMachine::stopInEventTest() s1->addTransition(new StopInEventTestTransition()); machine.setInitialState(s1); - QSignalSpy startedSpy(&machine, SIGNAL(started())); + QSignalSpy runningSpy(&machine, &QStateMachine::runningChanged); + QVERIFY(runningSpy.isValid()); + QSignalSpy startedSpy(&machine, &QStateMachine::started); QVERIFY(startedSpy.isValid()); machine.start(); QTRY_COMPARE(startedSpy.count(), 1); + TEST_RUNNING_CHANGED(true); - QSignalSpy stoppedSpy(&machine, SIGNAL(stopped())); - QSignalSpy finishedSpy(&machine, SIGNAL(finished())); + QSignalSpy stoppedSpy(&machine, &QStateMachine::stopped); + QSignalSpy finishedSpy(&machine, &QStateMachine::finished); QVERIFY(stoppedSpy.isValid()); QVERIFY(finishedSpy.isValid()); machine.postEvent(new QEvent(QEvent::User), QStateMachine::EventPriority(eventPriority)); QTRY_COMPARE(stoppedSpy.count(), 1); QCOMPARE(finishedSpy.count(), 0); + TEST_RUNNING_CHANGED(false); QCOMPARE(machine.configuration().size(), 1); QVERIFY(machine.configuration().contains(s1)); } @@ -4070,12 +4326,16 @@ void tst_QStateMachine::testIncrementReceivers() IncrementReceiversTest testObject; s1->addTransition(&testObject, SIGNAL(mySignal()), s2); - QSignalSpy finishedSpy(&machine, SIGNAL(finished())); + QSignalSpy runningSpy(&machine, &QStateMachine::runningChanged); + QVERIFY(runningSpy.isValid()); + QSignalSpy finishedSpy(&machine, &QStateMachine::finished); machine.start(); + TEST_RUNNING_CHANGED(true); QMetaObject::invokeMethod(&testObject, "mySignal", Qt::QueuedConnection); QTRY_COMPARE(finishedSpy.count(), 1); + TEST_RUNNING_CHANGED(false); QCOMPARE(testObject.signalList.size(), 1); QCOMPARE(testObject.signalList.at(0), QMetaMethod::fromSignal(&IncrementReceiversTest::mySignal)); } @@ -4091,9 +4351,12 @@ void tst_QStateMachine::initialStateIsEnteredBeforeStartedEmitted() // transition should trigger. s1->addTransition(&machine, SIGNAL(started()), s2); - QSignalSpy finishedSpy(&machine, SIGNAL(finished())); + QSignalSpy runningSpy(&machine, &QStateMachine::runningChanged); + QVERIFY(runningSpy.isValid()); + QSignalSpy finishedSpy(&machine, &QStateMachine::finished); machine.start(); QTRY_COMPARE(finishedSpy.count(), 1); + TEST_RUNNING_CHANGED_STARTED_STOPPED; } void tst_QStateMachine::deletePropertyAssignmentObjectBeforeEntry() @@ -4226,9 +4489,9 @@ void tst_QStateMachine::transitionWithNoTarget() EventTransition *t1 = new EventTransition(QEvent::User, /*target=*/0); s1->addTransition(t1); - QSignalSpy s1EnteredSpy(s1, SIGNAL(entered())); - QSignalSpy s1ExitedSpy(s1, SIGNAL(exited())); - QSignalSpy t1TriggeredSpy(t1, SIGNAL(triggered())); + QSignalSpy s1EnteredSpy(s1, &QState::entered); + QSignalSpy s1ExitedSpy(s1, &QState::exited); + QSignalSpy t1TriggeredSpy(t1, &EventTransition::triggered); machine.start(); QTRY_VERIFY(machine.configuration().contains(s1)); @@ -4261,10 +4524,13 @@ void tst_QStateMachine::initialStateIsFinal() QStateMachine machine; QFinalState *f = new QFinalState(&machine); machine.setInitialState(f); - QSignalSpy finishedSpy(&machine, SIGNAL(finished())); + QSignalSpy runningSpy(&machine, &QStateMachine::runningChanged); + QVERIFY(runningSpy.isValid()); + QSignalSpy finishedSpy(&machine, &QStateMachine::finished); machine.start(); QTRY_VERIFY(machine.configuration().contains(f)); QTRY_COMPARE(finishedSpy.count(), 1); + TEST_RUNNING_CHANGED_STARTED_STOPPED; } class PropertyObject : public QObject @@ -4921,15 +5187,19 @@ void tst_QStateMachine::signalTransitionSenderInDifferentThread2() thread.start(); QTRY_VERIFY(thread.isRunning()); - QSignalSpy startedSpy(&machine, SIGNAL(started())); - QSignalSpy finishedSpy(&machine, SIGNAL(finished())); + QSignalSpy runningSpy(&machine, &QStateMachine::runningChanged); + QVERIFY(runningSpy.isValid()); + QSignalSpy startedSpy(&machine, &QStateMachine::started); + QSignalSpy finishedSpy(&machine, &QStateMachine::finished); machine.start(); QTRY_COMPARE(startedSpy.count(), 1); + TEST_RUNNING_CHANGED(true); emitter.emitSignalWithNoArg(); // The second emission should not get "lost". emitter.emitSignalWithDefaultArg(); QTRY_COMPARE(finishedSpy.count(), 1); + TEST_RUNNING_CHANGED(false); thread.quit(); QTRY_VERIFY(thread.wait()); diff --git a/tests/auto/corelib/thread/qfuturewatcher/tst_qfuturewatcher.cpp b/tests/auto/corelib/thread/qfuturewatcher/tst_qfuturewatcher.cpp index b2b0eace34..5c9f26b70e 100644 --- a/tests/auto/corelib/thread/qfuturewatcher/tst_qfuturewatcher.cpp +++ b/tests/auto/corelib/thread/qfuturewatcher/tst_qfuturewatcher.cpp @@ -87,8 +87,8 @@ void tst_QFutureWatcher::startFinish() { QFutureWatcher<void> futureWatcher; - QSignalSpy startedSpy(&futureWatcher, SIGNAL(started())); - QSignalSpy finishedSpy(&futureWatcher, SIGNAL(finished())); + QSignalSpy startedSpy(&futureWatcher, &QFutureWatcher<void>::started); + QSignalSpy finishedSpy(&futureWatcher, &QFutureWatcher<void>::finished); QVERIFY(startedSpy.isValid()); QVERIFY(finishedSpy.isValid()); @@ -322,7 +322,7 @@ void tst_QFutureWatcher::futureSignals() a.reportStarted(); f.setFuture(a.future()); - QSignalSpy progressSpy(&f, SIGNAL(progressValueChanged(int))); + QSignalSpy progressSpy(&f, &QFutureWatcher<void>::progressValueChanged); QVERIFY(progressSpy.isValid()); const int progress = 1; a.setProgressValue(progress); @@ -331,8 +331,8 @@ void tst_QFutureWatcher::futureSignals() QCOMPARE(progressSpy.takeFirst().at(0).toInt(), 0); QCOMPARE(progressSpy.takeFirst().at(0).toInt(), 1); - QSignalSpy finishedSpy(&f, SIGNAL(finished())); - QSignalSpy resultReadySpy(&f, SIGNAL(resultReadyAt(int))); + QSignalSpy finishedSpy(&f, &QFutureWatcher<void>::finished); + QSignalSpy resultReadySpy(&f, &QFutureWatcher<void>::resultReadyAt); QVERIFY(finishedSpy.isValid()); QVERIFY(resultReadySpy.isValid()); @@ -374,10 +374,10 @@ void tst_QFutureWatcher::watchFinishedFuture() #endif connect(&watcher, SIGNAL(resultReadyAt(int)), &object, SLOT(resultReadyAt(int))); - QSignalSpy startedSpy(&watcher, SIGNAL(started())); - QSignalSpy finishedSpy(&watcher, SIGNAL(finished())); - QSignalSpy resultReadySpy(&watcher, SIGNAL(resultReadyAt(int))); - QSignalSpy canceledSpy(&watcher, SIGNAL(canceled())); + QSignalSpy startedSpy(&watcher, &QFutureWatcher<int>::started); + QSignalSpy finishedSpy(&watcher, &QFutureWatcher<int>::finished); + QSignalSpy resultReadySpy(&watcher, &QFutureWatcher<int>::resultReadyAt); + QSignalSpy canceledSpy(&watcher, &QFutureWatcher<int>::canceled); QVERIFY(startedSpy.isValid()); QVERIFY(finishedSpy.isValid()); @@ -408,10 +408,10 @@ void tst_QFutureWatcher::watchCanceledFuture() #endif connect(&watcher, SIGNAL(resultReadyAt(int)), &object, SLOT(resultReadyAt(int))); - QSignalSpy startedSpy(&watcher, SIGNAL(started())); - QSignalSpy finishedSpy(&watcher, SIGNAL(finished())); - QSignalSpy resultReadySpy(&watcher, SIGNAL(resultReadyAt(int))); - QSignalSpy canceledSpy(&watcher, SIGNAL(canceled())); + QSignalSpy startedSpy(&watcher, &QFutureWatcher<int>::started); + QSignalSpy finishedSpy(&watcher, &QFutureWatcher<int>::finished); + QSignalSpy resultReadySpy(&watcher, &QFutureWatcher<int>::resultReadyAt); + QSignalSpy canceledSpy(&watcher, &QFutureWatcher<int>::canceled); QVERIFY(startedSpy.isValid()); QVERIFY(finishedSpy.isValid()); @@ -439,8 +439,8 @@ void tst_QFutureWatcher::disconnectRunningFuture() SignalSlotObject object; connect(watcher, SIGNAL(resultReadyAt(int)), &object, SLOT(resultReadyAt(int))); - QSignalSpy finishedSpy(watcher, SIGNAL(finished())); - QSignalSpy resultReadySpy(watcher, SIGNAL(resultReadyAt(int))); + QSignalSpy finishedSpy(watcher, &QFutureWatcher<int>::finished); + QSignalSpy resultReadySpy(watcher, &QFutureWatcher<int>::resultReadyAt); QVERIFY(finishedSpy.isValid()); QVERIFY(resultReadySpy.isValid()); @@ -634,7 +634,7 @@ void tst_QFutureWatcher::changeFuture() SignalSlotObject object; connect(&watcher, SIGNAL(resultReadyAt(int)), &object, SLOT(resultReadyAt(int))); - QSignalSpy resultReadySpy(&watcher, SIGNAL(resultReadyAt(int))); + QSignalSpy resultReadySpy(&watcher, &QFutureWatcher<int>::resultReadyAt); QVERIFY(resultReadySpy.isValid()); watcher.setFuture(a); // Watch 'a' which will genere a resultReady event. @@ -666,7 +666,7 @@ void tst_QFutureWatcher::cancelEvents() SignalSlotObject object; connect(&watcher, SIGNAL(resultReadyAt(int)), &object, SLOT(resultReadyAt(int))); - QSignalSpy resultReadySpy(&watcher, SIGNAL(resultReadyAt(int))); + QSignalSpy resultReadySpy(&watcher, &QFutureWatcher<int>::resultReadyAt); QVERIFY(resultReadySpy.isValid()); watcher.setFuture(a); @@ -694,7 +694,7 @@ void tst_QFutureWatcher::pauseEvents() SignalSlotObject object; connect(&watcher, SIGNAL(resultReadyAt(int)), &object, SLOT(resultReadyAt(int))); - QSignalSpy resultReadySpy(&watcher, SIGNAL(resultReadyAt(int))); + QSignalSpy resultReadySpy(&watcher, &QFutureWatcher<int>::resultReadyAt); QVERIFY(resultReadySpy.isValid()); watcher.setFuture(a); @@ -720,7 +720,7 @@ void tst_QFutureWatcher::pauseEvents() SignalSlotObject object; connect(&watcher, SIGNAL(resultReadyAt(int)), &object, SLOT(resultReadyAt(int))); - QSignalSpy resultReadySpy(&watcher, SIGNAL(resultReadyAt(int))); + QSignalSpy resultReadySpy(&watcher, &QFutureWatcher<int>::resultReadyAt); QVERIFY(resultReadySpy.isValid()); watcher.setFuture(a); diff --git a/tests/auto/corelib/thread/qthread/tst_qthread.cpp b/tests/auto/corelib/thread/qthread/tst_qthread.cpp index 0e53139414..a8c052119c 100644 --- a/tests/auto/corelib/thread/qthread/tst_qthread.cpp +++ b/tests/auto/corelib/thread/qthread/tst_qthread.cpp @@ -53,13 +53,11 @@ #ifdef Q_OS_UNIX #include <pthread.h> #endif -#if defined(Q_OS_WINCE) +#if defined(Q_OS_WIN) #include <windows.h> -#elif defined(Q_OS_WINRT) -#include <thread> -#elif defined(Q_OS_WIN) +#if defined(Q_OS_WIN32) #include <process.h> -#include <windows.h> +#endif #endif class tst_QThread : public QObject @@ -328,9 +326,6 @@ void tst_QThread::isRunning() void tst_QThread::setPriority() { -#if defined(Q_OS_WINRT) - QSKIP("Thread priority is not supported on WinRT"); -#endif Simple_Thread thread; // cannot change the priority, since the thread is not running @@ -465,10 +460,6 @@ void tst_QThread::start() QVERIFY(!thread.isFinished()); QVERIFY(!thread.isRunning()); QMutexLocker locker(&thread.mutex); -#ifdef Q_OS_WINRT - if (priorities[i] != QThread::NormalPriority && priorities[i] != QThread::InheritPriority) - QTest::ignoreMessage(QtWarningMsg, "QThread::start: Failed to set thread priority (not implemented)"); -#endif thread.start(priorities[i]); QVERIFY(thread.isRunning()); QVERIFY(!thread.isFinished()); @@ -482,7 +473,7 @@ void tst_QThread::start() void tst_QThread::terminate() { #if defined(Q_OS_WINRT) - QSKIP("Terminate is not supported on WinRT"); + QSKIP("Thread termination is not supported on WinRT."); #endif Terminate_Thread thread; { @@ -548,7 +539,7 @@ void tst_QThread::finished() void tst_QThread::terminated() { #if defined(Q_OS_WINRT) - QSKIP("Terminate is not supported on WinRT"); + QSKIP("Thread termination is not supported on WinRT."); #endif SignalRecorder recorder; Terminate_Thread thread; @@ -645,8 +636,6 @@ void noop(void*) { } #if defined Q_OS_UNIX typedef pthread_t ThreadHandle; -#elif defined Q_OS_WINRT - typedef std::thread ThreadHandle; #elif defined Q_OS_WIN typedef HANDLE ThreadHandle; #endif @@ -689,7 +678,7 @@ void NativeThreadWrapper::start(FunctionPointer functionPointer, void *data) const int state = pthread_create(&nativeThreadHandle, 0, NativeThreadWrapper::runUnix, this); Q_UNUSED(state); #elif defined(Q_OS_WINRT) - nativeThreadHandle = std::thread(NativeThreadWrapper::runWin, this); + // creating a new worker from within the GUI thread is not supported #elif defined(Q_OS_WINCE) nativeThreadHandle = CreateThread(NULL, 0 , (LPTHREAD_START_ROUTINE)NativeThreadWrapper::runWin , this, 0, NULL); #elif defined Q_OS_WIN @@ -710,7 +699,7 @@ void NativeThreadWrapper::join() #if defined Q_OS_UNIX pthread_join(nativeThreadHandle, 0); #elif defined Q_OS_WINRT - nativeThreadHandle.join(); + // not supported #elif defined Q_OS_WIN WaitForSingleObject(nativeThreadHandle, INFINITE); CloseHandle(nativeThreadHandle); @@ -766,6 +755,9 @@ void testNativeThreadAdoption(void *) } void tst_QThread::nativeThreadAdoption() { +#ifdef Q_OS_WINRT + QSKIP("Native thread adoption is not supported on WinRT."); +#endif threadAdoptedOk = false; mainThread = QThread::currentThread(); NativeThreadWrapper nativeThread; @@ -789,6 +781,9 @@ void adoptedThreadAffinityFunction(void *arg) void tst_QThread::adoptedThreadAffinity() { +#ifdef Q_OS_WINRT + QSKIP("Native thread adoption is not supported on WinRT."); +#endif QThread *affinity[2] = { 0, 0 }; NativeThreadWrapper thread; @@ -801,10 +796,9 @@ void tst_QThread::adoptedThreadAffinity() void tst_QThread::adoptedThreadSetPriority() { -#if defined(Q_OS_WINRT) - QSKIP("Thread priority is not supported on WinRT"); +#ifdef Q_OS_WINRT + QSKIP("Native thread adoption is not supported on WinRT."); #endif - NativeThreadWrapper nativeThread; nativeThread.setWaitForStop(); nativeThread.startAndWait(); @@ -832,6 +826,9 @@ void tst_QThread::adoptedThreadSetPriority() void tst_QThread::adoptedThreadExit() { +#ifdef Q_OS_WINRT + QSKIP("Native thread adoption is not supported on WinRT."); +#endif NativeThreadWrapper nativeThread; nativeThread.setWaitForStop(); @@ -861,6 +858,9 @@ void adoptedThreadExecFunction(void *) void tst_QThread::adoptedThreadExec() { +#ifdef Q_OS_WINRT + QSKIP("Native thread adoption is not supported on WinRT."); +#endif NativeThreadWrapper nativeThread; nativeThread.start(adoptedThreadExecFunction); nativeThread.join(); @@ -871,6 +871,9 @@ void tst_QThread::adoptedThreadExec() */ void tst_QThread::adoptedThreadFinished() { +#ifdef Q_OS_WINRT + QSKIP("Native thread adoption is not supported on WinRT."); +#endif NativeThreadWrapper nativeThread; nativeThread.setWaitForStop(); nativeThread.startAndWait(); @@ -889,6 +892,9 @@ void tst_QThread::adoptedThreadFinished() void tst_QThread::adoptedThreadExecFinished() { +#ifdef Q_OS_WINRT + QSKIP("Native thread adoption is not supported on WinRT."); +#endif NativeThreadWrapper nativeThread; nativeThread.setWaitForStop(); nativeThread.startAndWait(adoptedThreadExecFunction); @@ -899,14 +905,14 @@ void tst_QThread::adoptedThreadExecFinished() nativeThread.join(); QTestEventLoop::instance().enterLoop(5); -#if defined(Q_OS_WINRT) - QEXPECT_FAIL("", "QTBUG-31397: Known not to work on WinRT", Abort); -#endif QVERIFY(!QTestEventLoop::instance().timeout()); } void tst_QThread::adoptMultipleThreads() { +#ifdef Q_OS_WINRT + QSKIP("Native thread adoption is not supported on WinRT."); +#endif #if defined(Q_OS_WIN) // Windows CE is not capable of handling that many threads. On the emulator it is dead with 26 threads already. # if defined(Q_OS_WINCE) @@ -947,6 +953,9 @@ void tst_QThread::adoptMultipleThreads() void tst_QThread::adoptMultipleThreadsOverlap() { +#ifdef Q_OS_WINRT + QSKIP("Native thread adoption is not supported on WinRT."); +#endif #if defined(Q_OS_WIN) // Windows CE is not capable of handling that many threads. On the emulator it is dead with 26 threads already. # if defined(Q_OS_WINCE) diff --git a/tests/auto/other/collections/.gitignore b/tests/auto/corelib/tools/collections/.gitignore index dcd9d49ec0..dcd9d49ec0 100644 --- a/tests/auto/other/collections/.gitignore +++ b/tests/auto/corelib/tools/collections/.gitignore diff --git a/tests/auto/other/collections/collections.pro b/tests/auto/corelib/tools/collections/collections.pro index 51ea667f58..51ea667f58 100644 --- a/tests/auto/other/collections/collections.pro +++ b/tests/auto/corelib/tools/collections/collections.pro diff --git a/tests/auto/other/collections/tst_collections.cpp b/tests/auto/corelib/tools/collections/tst_collections.cpp index 17ed9c8a45..33aa1c4888 100644 --- a/tests/auto/other/collections/tst_collections.cpp +++ b/tests/auto/corelib/tools/collections/tst_collections.cpp @@ -1238,8 +1238,6 @@ void tst_Collections::byteArray() QVERIFY(hello + "World" == helloWorld); QVERIFY("hello" + World == helloWorld); - - QByteArray l; QVERIFY('h' + ello == hello); QVERIFY(Wor + 'l' + 'd' == "World"); QVERIFY(hello + World == "helloWorld"); @@ -1969,8 +1967,6 @@ void tst_Collections::qstring() QVERIFY(hello + "World" == helloWorld); QVERIFY("hello" + World == helloWorld); - - QString l; QVERIFY('h' + ello == hello); QVERIFY(Wor + 'l' + 'd' == "World"); QVERIFY(hello + World == "helloWorld"); @@ -2441,8 +2437,7 @@ void testContainer() } /* - Verify that the 'sharable' flag is true while no mutable - iterator is active. + Verify that the 'sharable' flag is true in populated containers. */ { Container c1; @@ -2457,95 +2452,6 @@ void testContainer() QVERIFY(!c2.isDetached()); } - /* - Verify that the 'sharable' flag is set to false by the - mutable iterator. - */ - { - Container c1; - populate(c1); - QVERIFY(c1.size() == 4); - QVERIFY(c1.isDetached()); - - ContainerMutableIterator i(c1); - i.next(); - - Container c2 = c1; - QVERIFY(c1.size() == 4); - QVERIFY(c2.size() == 4); - QVERIFY(c1.isDetached()); - QVERIFY(c2.isDetached()); - - i.remove(); - QVERIFY(c1.size() == 3); - QVERIFY(c2.size() == 4); - } - - /* - Verify that the 'sharable' flag is reset to true by the - mutable iterator's destructor. - */ - { - Container c1; - populate(c1); - QVERIFY(c1.size() == 4); - QVERIFY(c1.isDetached()); - - { - ContainerMutableIterator i(c1); - i.next(); - } - - Container c2 = c1; - QVERIFY(c1.size() == 4); - QVERIFY(c2.size() == 4); - QVERIFY(!c1.isDetached()); - QVERIFY(!c2.isDetached()); - } - - /* - Verify that the 'sharable' flag only affects the original - object, not the copies. - */ - { - Container c1; - populate(c1); - QVERIFY(c1.size() == 4); - QVERIFY(c1.isDetached()); - - Container c2 = c1; - QVERIFY(isSharable(c2)); - - ContainerMutableIterator i(c1); - QVERIFY(!isSharable(c1)); - QVERIFY(isSharable(c2)); - - Container c3 = c1; - QVERIFY(!isSharable(c1)); - QVERIFY(isSharable(c2)); - QVERIFY(isSharable(c3)); - QVERIFY(c1.isDetached()); - QVERIFY(c2.isDetached()); - QVERIFY(c3.isDetached()); - - Container c4; - c4 = c1; - QVERIFY(!isSharable(c1)); - QVERIFY(isSharable(c2)); - QVERIFY(isSharable(c4)); - QVERIFY(c1.isDetached()); - QVERIFY(c2.isDetached()); - QVERIFY(c4.isDetached()); - - c3 = c2; - QVERIFY(!isSharable(c1)); - QVERIFY(isSharable(c2)); - QVERIFY(isSharable(c3)); - QVERIFY(c1.isDetached()); - QVERIFY(!c2.isDetached()); - QVERIFY(!c3.isDetached()); - } - /* test that the move operators work properly */ { Container c1 = Container(newInstance<Container>()); @@ -3231,18 +3137,20 @@ void tst_Collections::qtimerList() QFAIL("QList preallocates too much memory"); } +#define QVERIFY_TYPE(Type) QVERIFY(sizeof(Type)) + template <typename Container> void testContainerTypedefs(Container container) { Q_UNUSED(container) - { typedef typename Container::value_type Foo; } - { typedef typename Container::iterator Foo; } - { typedef typename Container::const_iterator Foo; } - { typedef typename Container::reference Foo; } - { typedef typename Container::const_reference Foo; } - { typedef typename Container::pointer Foo; } - { typedef typename Container::difference_type Foo; } - { typedef typename Container::size_type Foo; } + { QVERIFY_TYPE(typename Container::value_type); } + { QVERIFY_TYPE(typename Container::iterator); } + { QVERIFY_TYPE(typename Container::const_iterator); } + { QVERIFY_TYPE(typename Container::reference); } + { QVERIFY_TYPE(typename Container::const_reference); } + { QVERIFY_TYPE(typename Container::pointer); } + { QVERIFY_TYPE(typename Container::difference_type); } + { QVERIFY_TYPE(typename Container::size_type); } } template <typename Container> @@ -3251,34 +3159,34 @@ void testPairAssociativeContainerTypedefs(Container container) Q_UNUSED(container) // TODO: Not sure how to define value_type for our associative containers -// { typedef typename Container::value_type Foo; } -// { typedef typename Container::const_iterator Foo; } -// { typedef typename Container::reference Foo; } -// { typedef typename Container::const_reference Foo; } -// { typedef typename Container::pointer Foo; } - - { typedef typename Container::difference_type Foo; } - { typedef typename Container::size_type Foo; } - { typedef typename Container::iterator Foo; } - { typedef typename Container::key_type Foo; } - { typedef typename Container::mapped_type Foo; } +// { QVERIFY_TYPE(typename Container::value_type); } +// { QVERIFY_TYPE(typename Container::const_iterator); } +// { QVERIFY_TYPE(typename Container::reference); } +// { QVERIFY_TYPE(typename Container::const_reference); } +// { QVERIFY_TYPE(typename Container::pointer); } + + { QVERIFY_TYPE(typename Container::difference_type); } + { QVERIFY_TYPE(typename Container::size_type); } + { QVERIFY_TYPE(typename Container::iterator); } + { QVERIFY_TYPE(typename Container::key_type); } + { QVERIFY_TYPE(typename Container::mapped_type); } // TODO -// { typedef typename Container::key_compare Foo; } -// { typedef typename Container::value_comare Foo; } +// { QVERIFY_TYPE(typename Container::key_compare); } +// { QVERIFY_TYPE(typename Container::value_comare); } } template <typename Container> void testSetContainerTypedefs(Container container) { Q_UNUSED(container) - { typedef typename Container::iterator Foo; } - { typedef typename Container::const_iterator Foo; } - { typedef typename Container::reference Foo; } - { typedef typename Container::const_reference Foo; } - { typedef typename Container::pointer Foo; } - { typedef typename Container::difference_type Foo; } - { typedef typename Container::size_type Foo; } - { typedef typename Container::key_type Foo; } + { QVERIFY_TYPE(typename Container::iterator); } + { QVERIFY_TYPE(typename Container::const_iterator); } + { QVERIFY_TYPE(typename Container::reference); } + { QVERIFY_TYPE(typename Container::const_reference); } + { QVERIFY_TYPE(typename Container::pointer); } + { QVERIFY_TYPE(typename Container::difference_type); } + { QVERIFY_TYPE(typename Container::size_type); } + { QVERIFY_TYPE(typename Container::key_type); } } /* diff --git a/tests/auto/corelib/tools/qbytearray/tst_qbytearray.cpp b/tests/auto/corelib/tools/qbytearray/tst_qbytearray.cpp index cdcbd19ae8..8fac232962 100644 --- a/tests/auto/corelib/tools/qbytearray/tst_qbytearray.cpp +++ b/tests/auto/corelib/tools/qbytearray/tst_qbytearray.cpp @@ -153,6 +153,8 @@ private slots: #endif void macTypes(); + + void stdString(); }; static const struct StaticByteArrays { @@ -2007,6 +2009,23 @@ void tst_QByteArray::macTypes() #endif } +void tst_QByteArray::stdString() +{ + std::string stdstr( "QByteArray" ); + + const QByteArray stlqt = QByteArray::fromStdString(stdstr); + QCOMPARE(stlqt.length(), int(stdstr.length())); + QCOMPARE(stlqt.data(), stdstr.c_str()); + QCOMPARE(stlqt.toStdString(), stdstr); + + std::string utf8str( "Nøt æscii" ); + const QByteArray u8 = QByteArray::fromStdString(utf8str); + const QByteArray l1 = QString::fromUtf8(u8).toLatin1(); + std::string l1str = l1.toStdString(); + QVERIFY(l1str.length() < utf8str.length()); +} + + const char globalChar = '1'; QTEST_MAIN(tst_QByteArray) diff --git a/tests/auto/corelib/tools/qregularexpression/.gitignore b/tests/auto/corelib/tools/qregularexpression/.gitignore index c9249e090e..4650b4454e 100644 --- a/tests/auto/corelib/tools/qregularexpression/.gitignore +++ b/tests/auto/corelib/tools/qregularexpression/.gitignore @@ -1,2 +1,3 @@ tst_qregularexpression_alwaysoptimize tst_qregularexpression_defaultoptimize +tst_qregularexpression_forceoptimize diff --git a/tests/auto/corelib/tools/qregularexpression/forceoptimize/forceoptimize.pro b/tests/auto/corelib/tools/qregularexpression/forceoptimize/forceoptimize.pro new file mode 100644 index 0000000000..d34bc9b93d --- /dev/null +++ b/tests/auto/corelib/tools/qregularexpression/forceoptimize/forceoptimize.pro @@ -0,0 +1,8 @@ +CONFIG += testcase parallel_test +TARGET = tst_qregularexpression_forceoptimize +QT = core testlib +HEADERS = ../tst_qregularexpression.h +SOURCES = \ + tst_qregularexpression_forceoptimize.cpp \ + ../tst_qregularexpression.cpp +DEFINES += forceOptimize=true diff --git a/tests/auto/corelib/tools/qregularexpression/forceoptimize/tst_qregularexpression_forceoptimize.cpp b/tests/auto/corelib/tools/qregularexpression/forceoptimize/tst_qregularexpression_forceoptimize.cpp new file mode 100644 index 0000000000..6244aacedf --- /dev/null +++ b/tests/auto/corelib/tools/qregularexpression/forceoptimize/tst_qregularexpression_forceoptimize.cpp @@ -0,0 +1,52 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Giuseppe D'Angelo <giuseppe.dangelo@kdab.com> +** Contact: http://www.qt-project.org/legal +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include <QtTest/QtTest> +#include "../tst_qregularexpression.h" + +class tst_QRegularExpression_ForceOptimize : public tst_QRegularExpression +{ + Q_OBJECT +}; + +QTEST_APPLESS_MAIN(tst_QRegularExpression_ForceOptimize) + +#include "tst_qregularexpression_forceoptimize.moc" diff --git a/tests/auto/corelib/tools/qregularexpression/qregularexpression.pro b/tests/auto/corelib/tools/qregularexpression/qregularexpression.pro index 0cae10112f..c030f04a27 100644 --- a/tests/auto/corelib/tools/qregularexpression/qregularexpression.pro +++ b/tests/auto/corelib/tools/qregularexpression/qregularexpression.pro @@ -1,3 +1,3 @@ TEMPLATE = subdirs -SUBDIRS = defaultoptimize +SUBDIRS = defaultoptimize forceoptimize contains(QT_CONFIG,private_tests):SUBDIRS += alwaysoptimize diff --git a/tests/auto/corelib/tools/qregularexpression/tst_qregularexpression.cpp b/tests/auto/corelib/tools/qregularexpression/tst_qregularexpression.cpp index 909725f4b8..5fad1bb738 100644 --- a/tests/auto/corelib/tools/qregularexpression/tst_qregularexpression.cpp +++ b/tests/auto/corelib/tools/qregularexpression/tst_qregularexpression.cpp @@ -48,6 +48,10 @@ #include "tst_qregularexpression.h" +#ifndef forceOptimize +#define forceOptimize false +#endif + struct Match { Match() @@ -329,22 +333,30 @@ void tst_QRegularExpression::gettersSetters() { QRegularExpression re; re.setPattern(pattern); + if (forceOptimize) + re.optimize(); QCOMPARE(re.pattern(), pattern); QCOMPARE(re.patternOptions(), QRegularExpression::NoPatternOption); } { QRegularExpression re; re.setPatternOptions(patternOptions); + if (forceOptimize) + re.optimize(); QCOMPARE(re.pattern(), QString()); QCOMPARE(re.patternOptions(), patternOptions); } { QRegularExpression re(pattern); + if (forceOptimize) + re.optimize(); QCOMPARE(re.pattern(), pattern); QCOMPARE(re.patternOptions(), QRegularExpression::NoPatternOption); } { QRegularExpression re(pattern, patternOptions); + if (forceOptimize) + re.optimize(); QCOMPARE(re.pattern(), pattern); QCOMPARE(re.patternOptions(), patternOptions); } @@ -385,6 +397,8 @@ void tst_QRegularExpression::escape() QFETCH(QString, escaped); QCOMPARE(QRegularExpression::escape(string), escaped); QRegularExpression re(escaped); + if (forceOptimize) + re.optimize(); QCOMPARE(re.isValid(), true); } @@ -415,6 +429,8 @@ void tst_QRegularExpression::validity() QFETCH(QString, pattern); QFETCH(bool, validity); QRegularExpression re(pattern); + if (forceOptimize) + re.optimize(); QCOMPARE(re.isValid(), validity); if (!validity) QTest::ignoreMessage(QtWarningMsg, "QRegularExpressionPrivate::doMatch(): called on an invalid QRegularExpression object"); @@ -501,6 +517,9 @@ void tst_QRegularExpression::patternOptions() QFETCH(QString, subject); QFETCH(Match, match); + if (forceOptimize) + regexp.optimize(); + QRegularExpressionMatch m = regexp.match(subject); consistencyCheck(m); QVERIFY(m == match); @@ -717,6 +736,9 @@ void tst_QRegularExpression::normalMatch() QFETCH(QRegularExpression::MatchOptions, matchOptions); QFETCH(Match, match); + if (forceOptimize) + regexp.optimize(); + { QRegularExpressionMatch m = regexp.match(subject, offset, QRegularExpression::NormalMatch, matchOptions); consistencyCheck(m); @@ -995,6 +1017,9 @@ void tst_QRegularExpression::partialMatch() QFETCH(QRegularExpression::MatchOptions, matchOptions); QFETCH(Match, match); + if (forceOptimize) + regexp.optimize(); + { QRegularExpressionMatch m = regexp.match(subject, offset, matchType, matchOptions); consistencyCheck(m); @@ -1286,6 +1311,10 @@ void tst_QRegularExpression::globalMatch() QFETCH(QRegularExpression::MatchType, matchType); QFETCH(QRegularExpression::MatchOptions, matchOptions); QFETCH(QList<Match>, matchList); + + if (forceOptimize) + regexp.optimize(); + { QRegularExpressionMatchIterator iterator = regexp.globalMatch(subject, offset, matchType, matchOptions); consistencyCheck(iterator); @@ -1320,6 +1349,10 @@ void tst_QRegularExpression::serialize() QFETCH(QString, pattern); QFETCH(QRegularExpression::PatternOptions, patternOptions); QRegularExpression outRe(pattern, patternOptions); + + if (forceOptimize) + outRe.optimize(); + QByteArray buffer; { QDataStream out(&buffer, QIODevice::WriteOnly); @@ -1376,16 +1409,34 @@ void tst_QRegularExpression::operatoreq() { QRegularExpression re1(pattern); QRegularExpression re2(pattern); + + if (forceOptimize) + re1.optimize(); + if (forceOptimize) + re2.optimize(); + verifyEquality(re1, re2); } { QRegularExpression re1(QString(), patternOptions); QRegularExpression re2(QString(), patternOptions); + + if (forceOptimize) + re1.optimize(); + if (forceOptimize) + re2.optimize(); + verifyEquality(re1, re2); } { QRegularExpression re1(pattern, patternOptions); QRegularExpression re2(pattern, patternOptions); + + if (forceOptimize) + re1.optimize(); + if (forceOptimize) + re2.optimize(); + verifyEquality(re1, re2); } } @@ -1414,6 +1465,10 @@ void tst_QRegularExpression::captureCount() { QFETCH(QString, pattern); QRegularExpression re(pattern); + + if (forceOptimize) + re.optimize(); + QTEST(re.captureCount(), "captureCount"); if (!re.isValid()) QCOMPARE(re.captureCount(), -1); @@ -1480,7 +1535,11 @@ void tst_QRegularExpression::captureNames() QFETCH(QString, pattern); QFETCH(StringToIntMap, namedCapturesIndexMap); - const QRegularExpression re(pattern); + QRegularExpression re(pattern); + + if (forceOptimize) + re.optimize(); + QStringList namedCaptureGroups = re.namedCaptureGroups(); int namedCaptureGroupsCount = namedCaptureGroups.size(); @@ -1515,6 +1574,10 @@ void tst_QRegularExpression::pcreJitStackUsage() QFETCH(QString, subject); QRegularExpression re(pattern); + + if (forceOptimize) + re.optimize(); + QVERIFY(re.isValid()); QRegularExpressionMatch match = re.match(subject); consistencyCheck(match); @@ -1541,6 +1604,10 @@ void tst_QRegularExpression::regularExpressionMatch() QFETCH(QString, subject); QRegularExpression re(pattern); + + if (forceOptimize) + re.optimize(); + QVERIFY(re.isValid()); QRegularExpressionMatch match = re.match(subject); consistencyCheck(match); @@ -1580,5 +1647,7 @@ void tst_QRegularExpression::JOptionUsage() QRegularExpression re(pattern); if (isValid && JOptionUsed) QTest::ignoreMessage(QtWarningMsg, qPrintable(warningMessage.arg(pattern))); + if (forceOptimize) + re.optimize(); QCOMPARE(re.isValid(), isValid); } diff --git a/tests/auto/corelib/tools/qscopedvaluerollback/tst_qscopedvaluerollback.cpp b/tests/auto/corelib/tools/qscopedvaluerollback/tst_qscopedvaluerollback.cpp index af82897179..86438caed6 100644 --- a/tests/auto/corelib/tools/qscopedvaluerollback/tst_qscopedvaluerollback.cpp +++ b/tests/auto/corelib/tools/qscopedvaluerollback/tst_qscopedvaluerollback.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Copyright (C) 2014 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. @@ -67,14 +67,17 @@ void tst_QScopedValueRollback::leavingScope() { int i = 0; bool b = false; + bool b2 = false; QString s("This is useful"); //test rollback on going out of scope { QScopedValueRollback<int> ri(i); QScopedValueRollback<bool> rb(b); + QScopedValueRollback<bool> rb2(b2, true); QScopedValueRollback<QString> rs(s); QCOMPARE(b, false); + QCOMPARE(b2, true); QCOMPARE(i, 0); QCOMPARE(s, QString("This is useful")); b = true; @@ -85,6 +88,7 @@ void tst_QScopedValueRollback::leavingScope() QCOMPARE(s, QString("Useless")); } QCOMPARE(b, false); + QCOMPARE(b2, false); QCOMPARE(i, 0); QCOMPARE(s, QString("This is useful")); } diff --git a/tests/auto/corelib/tools/qsharedpointer/tst_qsharedpointer.cpp b/tests/auto/corelib/tools/qsharedpointer/tst_qsharedpointer.cpp index 5b1a2cf076..ac37b9af2a 100644 --- a/tests/auto/corelib/tools/qsharedpointer/tst_qsharedpointer.cpp +++ b/tests/auto/corelib/tools/qsharedpointer/tst_qsharedpointer.cpp @@ -74,6 +74,7 @@ private slots: void useOfForwardDeclared(); void memoryManagement(); void dropLastReferenceOfForwardDeclared(); + void lock(); void downCast(); void functionCallDownCast(); void upCast(); @@ -111,6 +112,7 @@ private slots: void invalidConstructs(); void qvariantCast(); + void sharedFromThis(); public slots: void cleanup() { safetyCheck(); } @@ -391,12 +393,56 @@ void tst_QSharedPointer::swap() QVERIFY(p2 != control); QVERIFY(p2.isNull()); QVERIFY(*p1 == 42); + + QWeakPointer<int> w1, w2 = control; + + QVERIFY(w1.isNull()); + QVERIFY(!w2.isNull()); + QVERIFY(w2.lock() == control); + QVERIFY(!w1.lock()); + + w1.swap(w2); + QVERIFY(w2.isNull()); + QVERIFY(!w1.isNull()); + QVERIFY(w1.lock() == control); + QVERIFY(!w2.lock()); + + qSwap(w1, w2); + QVERIFY(w1.isNull()); + QVERIFY(w2.lock() == control); + + p1.reset(); + p2.reset(); + control.reset(); + + QVERIFY(w1.isNull()); + QVERIFY(w2.isNull()); } void tst_QSharedPointer::useOfForwardDeclared() { // this just a compile test: use the forward-declared class QSharedPointer<ForwardDeclared> sp; + + // copying should work, too: + QSharedPointer<ForwardDeclared> sp2 = sp; + + // and assignment: + QSharedPointer<ForwardDeclared> sp3; + sp3 = sp; + + // move assignment: + QSharedPointer<ForwardDeclared> sp4; + sp4 = qMove(sp); + + // and move constuction: + QSharedPointer<ForwardDeclared> sp5 = qMove(sp2); + + // swapping: + sp4.swap(sp3); + qSwap(sp4, sp3); + + // and, of course, destruction } @@ -474,6 +520,22 @@ void tst_QSharedPointer::dropLastReferenceOfForwardDeclared() QCOMPARE(forwardDeclaredDestructorRunCount, 1); } +void tst_QSharedPointer::lock() +{ + QSharedPointer<int> sp = QSharedPointer<int>::create(); + QVERIFY(sp); + QWeakPointer<int> wp = sp; + QVERIFY(sp == wp); + QVERIFY(sp == wp.lock()); + QVERIFY(sp == wp.toStrongRef()); + + sp.reset(); + QVERIFY(!wp); + QVERIFY(sp != wp); // this is why op(shared_ptr, weak_ptr) is a bad idea (apart from MT races)... + QVERIFY(sp == wp.lock()); + QVERIFY(sp == wp.toStrongRef()); +} + class DerivedData: public Data { public: @@ -846,6 +908,7 @@ void tst_QSharedPointer::objectCast() ptr.clear(); QVERIFY(ptr.isNull()); QVERIFY(weakptr.toStrongRef().isNull()); + QVERIFY(weakptr.lock().isNull()); // verify that the object casts fail without crash QSharedPointer<OtherObject> otherptr = qSharedPointerObjectCast<OtherObject>(weakptr); @@ -2079,6 +2142,228 @@ void tst_QSharedPointer::qvariantCast() } } +class SomeClass : public QEnableSharedFromThis<SomeClass> +{ +public: + SomeClass() + { + } + + QSharedPointer<SomeClass> getSharedPtr() + { + return sharedFromThis(); + } + + QSharedPointer<const SomeClass> getSharedPtr() const + { + return sharedFromThis(); + } + + Data data; +}; + +void tst_QSharedPointer::sharedFromThis() +{ + const int generations = Data::generationCounter; + const int destructions = Data::destructorCounter; + + { + SomeClass sc; + QSharedPointer<SomeClass> scp = sc.sharedFromThis(); + QVERIFY(scp.isNull()); + QCOMPARE(Data::generationCounter, generations + 1); + QCOMPARE(Data::destructorCounter, destructions); + + QSharedPointer<const SomeClass> const_scp = sc.sharedFromThis(); + QVERIFY(const_scp.isNull()); + QCOMPARE(Data::generationCounter, generations + 1); + QCOMPARE(Data::destructorCounter, destructions); + } + + QCOMPARE(Data::generationCounter, generations + 1); + QCOMPARE(Data::destructorCounter, destructions + 1); + + { + const SomeClass sc; + QSharedPointer<const SomeClass> const_scp = sc.sharedFromThis(); + QVERIFY(const_scp.isNull()); + QCOMPARE(Data::generationCounter, generations + 2); + QCOMPARE(Data::destructorCounter, destructions + 1); + } + + QCOMPARE(Data::generationCounter, generations + 2); + QCOMPARE(Data::destructorCounter, destructions + 2); + + { + SomeClass *sc = new SomeClass; + QCOMPARE(Data::generationCounter, generations + 3); + QCOMPARE(Data::destructorCounter, destructions + 2); + + QSharedPointer<SomeClass> scp; + QVERIFY(scp.isNull()); + QCOMPARE(Data::generationCounter, generations + 3); + QCOMPARE(Data::destructorCounter, destructions + 2); + + scp = sc->sharedFromThis(); + QVERIFY(scp.isNull()); + QCOMPARE(Data::generationCounter, generations + 3); + QCOMPARE(Data::destructorCounter, destructions + 2); + + scp = QSharedPointer<SomeClass>(sc); + QVERIFY(!scp.isNull()); + QCOMPARE(scp.data(), sc); + QCOMPARE(Data::generationCounter, generations + 3); + QCOMPARE(Data::destructorCounter, destructions + 2); + + QSharedPointer<SomeClass> scp2; + QVERIFY(scp2.isNull()); + QCOMPARE(Data::generationCounter, generations + 3); + QCOMPARE(Data::destructorCounter, destructions + 2); + + scp2 = sc->sharedFromThis(); + QVERIFY(!scp2.isNull()); + QVERIFY(scp == scp2); + QCOMPARE(scp2.data(), sc); + QCOMPARE(Data::generationCounter, generations + 3); + QCOMPARE(Data::destructorCounter, destructions + 2); + + QSharedPointer<const SomeClass> scp3; + QVERIFY(scp3.isNull()); + QCOMPARE(Data::generationCounter, generations + 3); + QCOMPARE(Data::destructorCounter, destructions + 2); + + scp3 = sc->sharedFromThis(); + QVERIFY(!scp3.isNull()); + QVERIFY(scp == scp3); + QVERIFY(scp2 == scp3); + QCOMPARE(scp3.data(), sc); + QCOMPARE(Data::generationCounter, generations + 3); + QCOMPARE(Data::destructorCounter, destructions + 2); + + QSharedPointer<SomeClass> scp4; + QVERIFY(scp4.isNull()); + QCOMPARE(Data::generationCounter, generations + 3); + QCOMPARE(Data::destructorCounter, destructions + 2); + + scp4 = sc->getSharedPtr(); + QVERIFY(!scp4.isNull()); + QVERIFY(scp == scp4); + QVERIFY(scp2 == scp4); + QVERIFY(scp3 == scp4); + QCOMPARE(scp4.data(), sc); + QCOMPARE(Data::generationCounter, generations + 3); + QCOMPARE(Data::destructorCounter, destructions + 2); + + QSharedPointer<const SomeClass> scp5; + QVERIFY(scp5.isNull()); + QCOMPARE(Data::generationCounter, generations + 3); + QCOMPARE(Data::destructorCounter, destructions + 2); + + scp5 = const_cast<const SomeClass *>(sc)->getSharedPtr(); + QVERIFY(!scp4.isNull()); + QVERIFY(scp == scp5); + QVERIFY(scp2 == scp5); + QVERIFY(scp3 == scp5); + QVERIFY(scp4 == scp5); + QCOMPARE(scp5.data(), sc); + QCOMPARE(Data::generationCounter, generations + 3); + QCOMPARE(Data::destructorCounter, destructions + 2); + } + + QCOMPARE(Data::generationCounter, generations + 3); + QCOMPARE(Data::destructorCounter, destructions + 3); + + QSharedPointer<SomeClass> scp; + + QVERIFY(scp.isNull()); + + { + QSharedPointer<SomeClass> scp2(new SomeClass()); + QVERIFY(!scp2.isNull()); + + scp = scp2->sharedFromThis(); + QVERIFY(!scp.isNull()); + + QVERIFY(scp == scp2); + QCOMPARE(Data::generationCounter, generations + 4); + QCOMPARE(Data::destructorCounter, destructions + 3); + } + + + QCOMPARE(Data::generationCounter, generations + 4); + QCOMPARE(Data::destructorCounter, destructions + 3); + QVERIFY(!scp.isNull()); + + { + QSharedPointer<const SomeClass> scp2; + scp2 = scp->sharedFromThis(); + QVERIFY(!scp2.isNull()); + + QVERIFY(scp == scp2); + QCOMPARE(Data::generationCounter, generations + 4); + QCOMPARE(Data::destructorCounter, destructions + 3); + } + + QCOMPARE(Data::generationCounter, generations + 4); + QCOMPARE(Data::destructorCounter, destructions + 3); + QVERIFY(!scp.isNull()); + + { + QSharedPointer<SomeClass> scp2; + scp2 = scp->getSharedPtr(); + QVERIFY(!scp2.isNull()); + + QVERIFY(scp == scp2); + QCOMPARE(Data::generationCounter, generations + 4); + QCOMPARE(Data::destructorCounter, destructions + 3); + } + + QCOMPARE(Data::generationCounter, generations + 4); + QCOMPARE(Data::destructorCounter, destructions + 3); + QVERIFY(!scp.isNull()); + + { + QSharedPointer<const SomeClass> scp2; + scp2 = qSharedPointerConstCast<const SomeClass>(scp)->getSharedPtr(); + QVERIFY(!scp2.isNull()); + + QVERIFY(scp == scp2); + QCOMPARE(Data::generationCounter, generations + 4); + QCOMPARE(Data::destructorCounter, destructions + 3); + } + + QCOMPARE(Data::generationCounter, generations + 4); + QCOMPARE(Data::destructorCounter, destructions + 3); + QVERIFY(!scp.isNull()); + + { + QSharedPointer<SomeClass> scp2; + scp2 = scp->sharedFromThis(); + QVERIFY(!scp2.isNull()); + + QVERIFY(scp == scp2); + QCOMPARE(Data::generationCounter, generations + 4); + QCOMPARE(Data::destructorCounter, destructions + 3); + + scp2.clear(); + + QCOMPARE(Data::generationCounter, generations + 4); + QCOMPARE(Data::destructorCounter, destructions + 3); + QVERIFY(!scp.isNull()); + QVERIFY(scp2.isNull()); + } + + QCOMPARE(Data::generationCounter, generations + 4); + QCOMPARE(Data::destructorCounter, destructions + 3); + QVERIFY(!scp.isNull()); + + scp.clear(); + + QCOMPARE(Data::generationCounter, generations + 4); + QCOMPARE(Data::destructorCounter, destructions + 4); + +} + namespace ReentrancyWhileDestructing { struct IB { diff --git a/tests/auto/corelib/tools/qstringlist/tst_qstringlist.cpp b/tests/auto/corelib/tools/qstringlist/tst_qstringlist.cpp index 246560e47f..91501a0106 100644 --- a/tests/auto/corelib/tools/qstringlist/tst_qstringlist.cpp +++ b/tests/auto/corelib/tools/qstringlist/tst_qstringlist.cpp @@ -66,6 +66,7 @@ private slots: void lastIndexOf_regExp(); void streamingOperator(); + void assignmentOperator(); void join() const; void join_data() const; void joinEmptiness() const; @@ -296,9 +297,11 @@ void tst_QStringList::removeDuplicates_data() QTest::addColumn<QString>("before"); QTest::addColumn<QString>("after"); QTest::addColumn<int>("count"); + QTest::addColumn<bool>("detached"); - QTest::newRow("empty-1") << "Hello,Hello" << "Hello" << 1; - QTest::newRow("empty-2") << "Hello,World" << "Hello,World" << 0; + QTest::newRow("empty-1") << "Hello,Hello" << "Hello" << 1 << true; + QTest::newRow("empty-2") << "Hello,World" << "Hello,World" << 0 << false; + QTest::newRow("middle") << "Hello,World,Hello" << "Hello,World" << 1 << true; } void tst_QStringList::removeDuplicates() @@ -306,13 +309,16 @@ void tst_QStringList::removeDuplicates() QFETCH(QString, before); QFETCH(QString, after); QFETCH(int, count); + QFETCH(bool, detached); QStringList lbefore = before.split(','); + const QStringList oldlbefore = lbefore; QStringList lafter = after.split(','); int removed = lbefore.removeDuplicates(); QCOMPARE(removed, count); QCOMPARE(lbefore, lafter); + QCOMPARE(detached, !oldlbefore.isSharedWith(lbefore)); } void tst_QStringList::streamingOperator() @@ -321,8 +327,13 @@ void tst_QStringList::streamingOperator() list << "hei"; list << list << "hopp" << list; + QList<QString> slist = list; + list << slist; + QCOMPARE(list, QStringList() << "hei" << "hei" << "hopp" + << "hei" << "hei" << "hopp" + << "hei" << "hei" << "hopp" << "hei" << "hei" << "hopp"); QStringList list2; @@ -334,6 +345,21 @@ void tst_QStringList::streamingOperator() QCOMPARE(list2 << list3, QStringList() << "adam" << "eva"); } +void tst_QStringList::assignmentOperator() +{ + // compile-only test + + QStringList adam; + adam << "adam"; + QList<QString> eva; + eva << "eva"; + QStringList result; + QStringList &ref1 = (result = adam); + QStringList &ref2 = (result = eva); + Q_UNUSED(ref1); + Q_UNUSED(ref2); +} + void tst_QStringList::join() const { QFETCH(QStringList, input); diff --git a/tests/auto/corelib/tools/qtimeline/tst_qtimeline.cpp b/tests/auto/corelib/tools/qtimeline/tst_qtimeline.cpp index e6629301f9..6b833681d6 100644 --- a/tests/auto/corelib/tools/qtimeline/tst_qtimeline.cpp +++ b/tests/auto/corelib/tools/qtimeline/tst_qtimeline.cpp @@ -102,7 +102,7 @@ void tst_QTimeLine::range() // Verify that you can change the range in the timeLine timeLine.setFrameRange(10, 20); - QSignalSpy spy(&timeLine, SIGNAL(frameChanged(int))); + QSignalSpy spy(&timeLine, &QTimeLine::frameChanged); QVERIFY(spy.isValid()); timeLine.start(); #ifdef Q_OS_WINCE @@ -131,7 +131,7 @@ void tst_QTimeLine::currentTime() { QTimeLine timeLine(2000); timeLine.setUpdateInterval((timeLine.duration()/2) / 33); - QSignalSpy spy(&timeLine, SIGNAL(valueChanged(qreal))); + QSignalSpy spy(&timeLine, &QTimeLine::valueChanged); QVERIFY(spy.isValid()); timeLine.setFrameRange(10, 20); QCOMPARE(timeLine.currentTime(), 0); @@ -202,7 +202,7 @@ void tst_QTimeLine::frameRate() // Default speed timeLine.setUpdateInterval(1000 / 33); - QSignalSpy spy(&timeLine, SIGNAL(frameChanged(int))); + QSignalSpy spy(&timeLine, &QTimeLine::frameChanged); QVERIFY(spy.isValid()); timeLine.start(); QTest::qWait(timeLine.duration()*2); @@ -225,7 +225,7 @@ void tst_QTimeLine::value() QVERIFY(timeLine.currentValue() == 0.0); // Default speed - QSignalSpy spy(&timeLine, SIGNAL(valueChanged(qreal))); + QSignalSpy spy(&timeLine, &QTimeLine::valueChanged); QVERIFY(spy.isValid()); timeLine.start(); QTest::qWait(timeLine.duration()/3); @@ -256,7 +256,7 @@ void tst_QTimeLine::currentFrame() QCOMPARE(timeLine.currentFrame(), 10); // Default speed - QSignalSpy spy(&timeLine, SIGNAL(frameChanged(int))); + QSignalSpy spy(&timeLine, &QTimeLine::frameChanged); QVERIFY(spy.isValid()); timeLine.start(); QTest::qWait(timeLine.duration()/3); @@ -288,7 +288,7 @@ void tst_QTimeLine::loopCount() QCOMPARE(timeLine.loopCount(), 0); // Default speed infiniti looping - QSignalSpy spy(&timeLine, SIGNAL(frameChanged(int))); + QSignalSpy spy(&timeLine, &QTimeLine::frameChanged); QVERIFY(spy.isValid()); timeLine.start(); QTest::qWait(timeLine.duration()); @@ -306,8 +306,8 @@ void tst_QTimeLine::loopCount() timeLine.setFrameRange(0, 2); timeLine.setLoopCount(4); - QSignalSpy finishedSpy(&timeLine, SIGNAL(finished())); - QSignalSpy frameChangedSpy(&timeLine, SIGNAL(frameChanged(int))); + QSignalSpy finishedSpy(&timeLine, &QTimeLine::finished); + QSignalSpy frameChangedSpy(&timeLine, &QTimeLine::frameChanged); QVERIFY(finishedSpy.isValid()); QVERIFY(frameChangedSpy.isValid()); QEventLoop loop; @@ -461,7 +461,7 @@ void tst_QTimeLine::frameChanged() timeLine.setCurveShape(QTimeLine::LinearCurve); timeLine.setFrameRange(0,9); timeLine.setUpdateInterval(800); - QSignalSpy spy(&timeLine, SIGNAL(frameChanged(int))); + QSignalSpy spy(&timeLine, &QTimeLine::frameChanged); QVERIFY(spy.isValid()); // Test what happens when duration expires before all frames are emitted. @@ -492,7 +492,7 @@ void tst_QTimeLine::stopped() QTimeLine timeLine; timeLine.setFrameRange(0, 9); qRegisterMetaType<QTimeLine::State>("QTimeLine::State"); - QSignalSpy spy(&timeLine, SIGNAL(stateChanged(QTimeLine::State))); + QSignalSpy spy(&timeLine, &QTimeLine::stateChanged); QVERIFY(spy.isValid()); timeLine.start(); QTest::qWait(timeLine.duration()*2); @@ -510,7 +510,7 @@ void tst_QTimeLine::finished() { QTimeLine timeLine; timeLine.setFrameRange(0,9); - QSignalSpy spy(&timeLine, SIGNAL(finished())); + QSignalSpy spy(&timeLine, &QTimeLine::finished); QVERIFY(spy.isValid()); timeLine.start(); QTest::qWait(timeLine.duration()*2); @@ -543,7 +543,7 @@ void tst_QTimeLine::multipleTimeLines() // Stopping a timer shouldn't affect the other timers QTimeLine timeLine(200); timeLine.setFrameRange(0,99); - QSignalSpy spy(&timeLine, SIGNAL(finished())); + QSignalSpy spy(&timeLine, &QTimeLine::finished); QVERIFY(spy.isValid()); QTimeLine timeLineKiller; diff --git a/tests/auto/corelib/tools/qvector/tst_qvector.cpp b/tests/auto/corelib/tools/qvector/tst_qvector.cpp index f1efbf0812..97f370f146 100644 --- a/tests/auto/corelib/tools/qvector/tst_qvector.cpp +++ b/tests/auto/corelib/tools/qvector/tst_qvector.cpp @@ -225,7 +225,9 @@ private slots: void fromListCustom() const; void fromStdVector() const; void indexOf() const; - void insert() const; + void insertInt() const; + void insertMovable() const; + void insertCustom() const; void isEmpty() const; void last() const; void lastIndexOf() const; @@ -296,6 +298,7 @@ private: template<typename T> void eraseReserved() const; template<typename T> void fill() const; template<typename T> void fromList() const; + template<typename T> void insert() const; template<typename T> void prepend() const; template<typename T> void remove() const; template<typename T> void size() const; @@ -1231,32 +1234,87 @@ void tst_QVector::indexOf() const QVERIFY(myvec.indexOf("A", 4) == -1); } +template <typename T> void tst_QVector::insert() const { - QVector<QString> myvec; - myvec << "A" << "B" << "C"; + QVector<T> myvec; + const T + tA = SimpleValue<T>::at(0), + tB = SimpleValue<T>::at(1), + tC = SimpleValue<T>::at(2), + tX = SimpleValue<T>::at(3), + tZ = SimpleValue<T>::at(4), + tT = SimpleValue<T>::at(5), + ti = SimpleValue<T>::at(6); + myvec << tA << tB << tC; + QVector<T> myvec2 = myvec; // first position - QCOMPARE(myvec.at(0), QLatin1String("A")); - myvec.insert(0, QLatin1String("X")); - QCOMPARE(myvec.at(0), QLatin1String("X")); - QCOMPARE(myvec.at(1), QLatin1String("A")); + QCOMPARE(myvec.at(0), tA); + myvec.insert(0, tX); + QCOMPARE(myvec.at(0), tX); + QCOMPARE(myvec.at(1), tA); + + QCOMPARE(myvec2.at(0), tA); + myvec2.insert(myvec2.begin(), tX); + QCOMPARE(myvec2.at(0), tX); + QCOMPARE(myvec2.at(1), tA); // middle - myvec.insert(1, QLatin1String("Z")); - QCOMPARE(myvec.at(0), QLatin1String("X")); - QCOMPARE(myvec.at(1), QLatin1String("Z")); - QCOMPARE(myvec.at(2), QLatin1String("A")); + myvec.insert(1, tZ); + QCOMPARE(myvec.at(0), tX); + QCOMPARE(myvec.at(1), tZ); + QCOMPARE(myvec.at(2), tA); + + myvec2.insert(myvec2.begin() + 1, tZ); + QCOMPARE(myvec2.at(0), tX); + QCOMPARE(myvec2.at(1), tZ); + QCOMPARE(myvec2.at(2), tA); // end - myvec.insert(5, QLatin1String("T")); - QCOMPARE(myvec.at(5), QLatin1String("T")); - QCOMPARE(myvec.at(4), QLatin1String("C")); + myvec.insert(5, tT); + QCOMPARE(myvec.at(5), tT); + QCOMPARE(myvec.at(4), tC); + + myvec2.insert(myvec2.end(), tT); + QCOMPARE(myvec2.at(5), tT); + QCOMPARE(myvec2.at(4), tC); // insert a lot of garbage in the middle - myvec.insert(2, 2, QLatin1String("infinity")); - QCOMPARE(myvec, QVector<QString>() << "X" << "Z" << "infinity" << "infinity" - << "A" << "B" << "C" << "T"); + myvec.insert(2, 2, ti); + QCOMPARE(myvec, QVector<T>() << tX << tZ << ti << ti + << tA << tB << tC << tT); + + myvec2.insert(myvec2.begin() + 2, 2, ti); + QCOMPARE(myvec2, myvec); + + // insert from references to the same container: + myvec.insert(0, 1, myvec[5]); // inserts tB + myvec2.insert(0, 1, myvec2[5]); // inserts tB + QCOMPARE(myvec, QVector<T>() << tB << tX << tZ << ti << ti + << tA << tB << tC << tT); + QCOMPARE(myvec2, myvec); + + myvec.insert(0, 1, const_cast<const QVector<T>&>(myvec)[0]); // inserts tB + myvec2.insert(0, 1, const_cast<const QVector<T>&>(myvec2)[0]); // inserts tB + QCOMPARE(myvec, QVector<T>() << tB << tB << tX << tZ << ti << ti + << tA << tB << tC << tT); + QCOMPARE(myvec2, myvec); +} + +void tst_QVector::insertInt() const +{ + insert<int>(); +} + +void tst_QVector::insertMovable() const +{ + insert<Movable>(); +} + +void tst_QVector::insertCustom() const +{ + insert<Custom>(); } void tst_QVector::isEmpty() const @@ -1321,6 +1379,8 @@ void tst_QVector::mid() const list << "foo" << "bar" << "baz" << "bak" << "buck" << "hello" << "kitty"; QCOMPARE(list.mid(3, 3), QVector<QString>() << "bak" << "buck" << "hello"); + QCOMPARE(list.mid(6, 10), QVector<QString>() << "kitty"); + QCOMPARE(list.mid(-1, 20), list); QCOMPARE(list.mid(4), QVector<QString>() << "buck" << "hello" << "kitty"); } @@ -1386,13 +1446,28 @@ void tst_QVector::remove() const T val1 = SimpleValue<T>::at(1); T val2 = SimpleValue<T>::at(2); T val3 = SimpleValue<T>::at(3); + T val4 = SimpleValue<T>::at(4); + myvec << val1 << val2 << val3; + myvec << val1 << val2 << val3; myvec << val1 << val2 << val3; // remove middle myvec.remove(1); - QCOMPARE(myvec, QVector<T>() << val1 << val3); + QCOMPARE(myvec, QVector<T>() << val1 << val3 << val1 << val2 << val3 << val1 << val2 << val3); + + // removeOne() + QVERIFY(!myvec.removeOne(val4)); + QVERIFY(myvec.removeOne(val2)); + QCOMPARE(myvec, QVector<T>() << val1 << val3 << val1 << val3 << val1 << val2 << val3); + + // removeAll() + QCOMPARE(myvec.removeAll(val4), 0); + QCOMPARE(myvec.removeAll(val1), 3); + QCOMPARE(myvec, QVector<T>() << val3 << val3 << val2 << val3); + QCOMPARE(myvec.removeAll(val2), 1); + QCOMPARE(myvec, QVector<T>() << val3 << val3 << val3); // remove rest - myvec.remove(0, 2); + myvec.remove(0, 3); QCOMPARE(myvec, QVector<T>()); } diff --git a/tests/auto/corelib/tools/tools.pro b/tests/auto/corelib/tools/tools.pro index 1ef8e77071..352cf88d44 100644 --- a/tests/auto/corelib/tools/tools.pro +++ b/tests/auto/corelib/tools/tools.pro @@ -1,5 +1,6 @@ TEMPLATE=subdirs SUBDIRS=\ + collections \ qalgorithms \ qarraydata \ qarraydata_strictiterators \ diff --git a/tests/auto/corelib/xml/qxmlstream/data/009.ref b/tests/auto/corelib/xml/qxmlstream/data/009.ref index 1de530df1c..12b994eac4 100644 --- a/tests/auto/corelib/xml/qxmlstream/data/009.ref +++ b/tests/auto/corelib/xml/qxmlstream/data/009.ref @@ -24,4 +24,4 @@ Invalid( name="bar" qualifiedName="bar" Attribute( name="attr" namespaceUri="http://example.org/~wilbur" qualifiedName="b:attr" prefix="b" value="2" ) ) -ERROR: Attribute redefined. +ERROR: Attribute 'b:attr' redefined. diff --git a/tests/auto/corelib/xml/qxmlstream/data/010.ref b/tests/auto/corelib/xml/qxmlstream/data/010.ref index 217f4963a1..07def503a5 100644 --- a/tests/auto/corelib/xml/qxmlstream/data/010.ref +++ b/tests/auto/corelib/xml/qxmlstream/data/010.ref @@ -24,4 +24,4 @@ Invalid( name="bar" qualifiedName="bar" Attribute( name="attr" namespaceUri="http://example.org/~wilbur" qualifiedName="b:attr" prefix="b" value="2" ) ) -ERROR: Attribute redefined. +ERROR: Attribute 'b:attr' redefined. diff --git a/tests/auto/corelib/xml/qxmlstream/data/011.ref b/tests/auto/corelib/xml/qxmlstream/data/011.ref index e3945324eb..faa6e75429 100644 --- a/tests/auto/corelib/xml/qxmlstream/data/011.ref +++ b/tests/auto/corelib/xml/qxmlstream/data/011.ref @@ -27,4 +27,4 @@ Invalid( name="bar" qualifiedName="bar" Attribute( name="attr" namespaceUri="http://example.org/~wilbur" qualifiedName="b:attr" prefix="b" value="2" ) ) -ERROR: Attribute redefined. +ERROR: Attribute 'b:attr' redefined. diff --git a/tests/auto/corelib/xml/qxmlstream/data/012.ref b/tests/auto/corelib/xml/qxmlstream/data/012.ref index 7a688b103d..834db97ba6 100644 --- a/tests/auto/corelib/xml/qxmlstream/data/012.ref +++ b/tests/auto/corelib/xml/qxmlstream/data/012.ref @@ -24,4 +24,4 @@ Invalid( name="bar" qualifiedName="bar" Attribute( name="attr" namespaceUri="urn:xyzzy" qualifiedName="b:attr" prefix="b" value="2" ) ) -ERROR: Attribute redefined. +ERROR: Attribute 'b:attr' redefined. diff --git a/tests/auto/corelib/xml/qxmlstream/data/035.ref b/tests/auto/corelib/xml/qxmlstream/data/035.ref index e172fc90e1..cab0158a51 100644 --- a/tests/auto/corelib/xml/qxmlstream/data/035.ref +++ b/tests/auto/corelib/xml/qxmlstream/data/035.ref @@ -13,4 +13,4 @@ Invalid( name="bar" qualifiedName="bar" Attribute( name="attr" namespaceUri="http://example.org/~wilbur" qualifiedName="a:attr" prefix="a" value="2" ) ) -ERROR: Attribute redefined. +ERROR: Attribute 'a:attr' redefined. diff --git a/tests/auto/corelib/xml/qxmlstream/data/036.ref b/tests/auto/corelib/xml/qxmlstream/data/036.ref index 158e7361f9..50939ed7e7 100644 --- a/tests/auto/corelib/xml/qxmlstream/data/036.ref +++ b/tests/auto/corelib/xml/qxmlstream/data/036.ref @@ -13,4 +13,4 @@ Invalid( name="bar" qualifiedName="bar" Attribute( name="attr" namespaceUri="http://example.org/~wilbur" qualifiedName="b:attr" prefix="b" value="2" ) ) -ERROR: Attribute redefined. +ERROR: Attribute 'b:attr' redefined. diff --git a/tests/auto/gui/image/qicoimageformat/icons/valid/yellow.cur b/tests/auto/gui/image/qicoimageformat/icons/valid/yellow.cur Binary files differnew file mode 100644 index 0000000000..0a649aa7f7 --- /dev/null +++ b/tests/auto/gui/image/qicoimageformat/icons/valid/yellow.cur diff --git a/tests/auto/gui/image/qicoimageformat/tst_qicoimageformat.cpp b/tests/auto/gui/image/qicoimageformat/tst_qicoimageformat.cpp index cd9d4b448e..71adbabb84 100644 --- a/tests/auto/gui/image/qicoimageformat/tst_qicoimageformat.cpp +++ b/tests/auto/gui/image/qicoimageformat/tst_qicoimageformat.cpp @@ -111,9 +111,17 @@ void tst_QIcoImageFormat::cleanupTestCase() void tst_QIcoImageFormat::format() { - QImageReader reader(m_IconPath + "/valid/35FLOPPY.ICO", "ico"); - QByteArray fmt = reader.format(); - QCOMPARE(const_cast<const char*>(fmt.data()), "ico" ); + { + QImageReader reader(m_IconPath + "/valid/35FLOPPY.ICO", "ico"); + QByteArray fmt = reader.format(); + QCOMPARE(const_cast<const char*>(fmt.data()), "ico" ); + } + + { + QImageReader reader(m_IconPath + "/valid/yellow.cur", "ico"); + QByteArray fmt = reader.format(); + QCOMPARE(const_cast<const char*>(fmt.data()), "ico" ); + } } void tst_QIcoImageFormat::canRead_data() @@ -133,6 +141,7 @@ void tst_QIcoImageFormat::canRead_data() QTest::newRow("103x16px, 24BPP") << "valid/trolltechlogo_tiny.ico" << 1; QTest::newRow("includes 32BPP w/alpha") << "valid/semitransparent.ico" << 1; QTest::newRow("PNG compression") << "valid/Qt.ico" << 1; + QTest::newRow("CUR file") << "valid/yellow.cur" << 1; } void tst_QIcoImageFormat::canRead() @@ -203,7 +212,7 @@ void tst_QIcoImageFormat::imageCount_data() QTest::newRow("invalid floppy (first 8 bytes = 0xff)") << "invalid/35floppy.ico" << 0; QTest::newRow("includes 32BPP w/alpha") << "valid/semitransparent.ico" << 9; QTest::newRow("PNG compression") << "valid/Qt.ico" << 4; - + QTest::newRow("CUR file") << "valid/yellow.cur" << 1; } void tst_QIcoImageFormat::imageCount() @@ -231,6 +240,7 @@ void tst_QIcoImageFormat::jumpToNextImage_data() QTest::newRow("16px16c, 32px32c, 32px256c 2") << "valid/WORLDH.ico" << 3; QTest::newRow("includes 32BPP w/alpha") << "valid/semitransparent.ico" << 9; QTest::newRow("PNG compression") << "valid/Qt.ico" << 4; + QTest::newRow("CUR file") << "valid/yellow.cur" << 1; } void tst_QIcoImageFormat::jumpToNextImage() @@ -281,6 +291,7 @@ void tst_QIcoImageFormat::nextImageDelay_data() QTest::newRow("invalid floppy (first 8 bytes = 0xff)") << "invalid/35floppy.ico" << -1; QTest::newRow("includes 32BPP w/alpha") << "valid/semitransparent.ico" << 9; QTest::newRow("PNG compression") << "valid/Qt.ico" << 4; + QTest::newRow("CUR file") << "valid/yellow.cur" << 1; } void tst_QIcoImageFormat::nextImageDelay() diff --git a/tests/auto/gui/image/qimage/tst_qimage.cpp b/tests/auto/gui/image/qimage/tst_qimage.cpp index 6c496ba6d4..0a4456e22a 100644 --- a/tests/auto/gui/image/qimage/tst_qimage.cpp +++ b/tests/auto/gui/image/qimage/tst_qimage.cpp @@ -173,6 +173,10 @@ private slots: void scaled_QTBUG35972(); + void convertToPixelFormat(); + void convertToImageFormat_data(); + void convertToImageFormat(); + void cleanupFunctions(); }; @@ -2523,6 +2527,46 @@ void tst_QImage::scaled_QTBUG35972() QCOMPARE(pixels[i], 0xffffffff); } +void tst_QImage::convertToPixelFormat() +{ + QPixelFormat rgb565 = QPixelFormatRgb(5,6,5,0,QPixelFormat::IgnoresAlpha, QPixelFormat::AtBeginning, QPixelFormat::NotPremultiplied, QPixelFormat::UnsignedShort); + QPixelFormat rgb565ImageFormat = QImage::toPixelFormat(QImage::Format_RGB16); + QCOMPARE(rgb565, rgb565ImageFormat); +} + +void tst_QImage::convertToImageFormat_data() +{ + QTest::addColumn<QImage::Format>("image_format"); + QTest::newRow("Convert Format_Invalid") << QImage::Format_Invalid; + QTest::newRow("Convert Format_Mono") << QImage::Format_Mono; + //This ends up being a QImage::Format_Mono since we cant specify LSB in QPixelFormat + //QTest::newRow("Convert Format_MonoLSB") << QImage::Format_MonoLSB; + QTest::newRow("Convert Format_Indexed8") << QImage::Format_Indexed8; + QTest::newRow("Convert Format_RGB32") << QImage::Format_RGB32; + QTest::newRow("Convert Format_ARGB32") << QImage::Format_ARGB32; + QTest::newRow("Convert Format_ARGB32_Premultiplied") << QImage::Format_ARGB32_Premultiplied; + QTest::newRow("Convert Format_RGB16") << QImage::Format_RGB16; + QTest::newRow("Convert Format_ARGB8565_Premultiplied") << QImage::Format_ARGB8565_Premultiplied; + QTest::newRow("Convert Format_RGB666") << QImage::Format_RGB666; + QTest::newRow("Convert Format_ARGB6666_Premultiplied") << QImage::Format_ARGB6666_Premultiplied; + QTest::newRow("Convert Format_RGB555") << QImage::Format_RGB555; + QTest::newRow("Convert Format_ARGB8555_Premultiplied") << QImage::Format_ARGB8555_Premultiplied; + QTest::newRow("Convert Format_RGB888") << QImage::Format_RGB888; + QTest::newRow("Convert Format_RGB444") << QImage::Format_RGB444; + QTest::newRow("Convert Format_ARGB4444_Premultiplied") << QImage::Format_ARGB4444_Premultiplied; + QTest::newRow("Convert Format_RGBX8888") << QImage::Format_RGBX8888; + QTest::newRow("Convert Format_RGBA8888") << QImage::Format_RGBA8888; + QTest::newRow("Convert Format_RGBA8888_Premultiplied") << QImage::Format_RGBA8888_Premultiplied; +} +void tst_QImage::convertToImageFormat() +{ + QFETCH(QImage::Format, image_format); + + QPixelFormat pixel_format = QImage::toPixelFormat(image_format); + QImage::Format format = QImage::toImageFormat(pixel_format); + QCOMPARE(format, image_format); +} + static void cleanupFunction(void* info) { bool *called = static_cast<bool*>(info); diff --git a/tests/auto/gui/image/qpicture/tst_qpicture.cpp b/tests/auto/gui/image/qpicture/tst_qpicture.cpp index 2e766c5bf5..986431941f 100644 --- a/tests/auto/gui/image/qpicture/tst_qpicture.cpp +++ b/tests/auto/gui/image/qpicture/tst_qpicture.cpp @@ -45,6 +45,7 @@ #include <qpicture.h> #include <qpainter.h> #include <qimage.h> +#include <qpaintengine.h> #ifndef QT_NO_WIDGETS #include <qdesktopwidget.h> #include <qapplication.h> @@ -64,7 +65,7 @@ private slots: void paintingActive(); void boundingRect(); void swap(); - void operator_lt_lt(); + void serialization(); #ifndef QT_NO_WIDGETS void save_restore(); @@ -169,36 +170,94 @@ void tst_QPicture::swap() QCOMPARE(p2.boundingRect(), QRect(0,0,5,5)); } -// operator<< and operator>> -void tst_QPicture::operator_lt_lt() +Q_DECLARE_METATYPE(QDataStream::Version) +Q_DECLARE_METATYPE(QPicture) + +void ensureSerializesCorrectly(const QPicture &picture, QDataStream::Version version) + { + QDataStream stream; + + QBuffer buffer; + buffer.open(QIODevice::WriteOnly); + stream.setDevice(&buffer); + stream.setVersion(version); + stream << picture; + buffer.close(); + + buffer.open(QIODevice::ReadOnly); + QPicture readpicture; + stream >> readpicture; + QVERIFY2(memcmp(picture.data(), readpicture.data(), picture.size()) == 0, + qPrintable(QString::fromLatin1("Picture data does not compare equal for QDataStream version %1").arg(version))); +} + +class PaintEngine : public QPaintEngine { - // streaming of null pictures - { - QPicture pic1, pic2; - QByteArray ba( 100, 0 ); - QDataStream str1( &ba, QIODevice::WriteOnly ); - str1 << pic1; - QDataStream str2( &ba, QIODevice::ReadOnly ); - str2 >> pic2; - QVERIFY( pic2.isNull() ); +public: + PaintEngine() : QPaintEngine() {} + bool begin(QPaintDevice *) { return true; } + bool end() { return true; } + void updateState(const QPaintEngineState &) {} + void drawPixmap(const QRectF &, const QPixmap &, const QRectF &) {} + Type type() const { return Raster; } + + QFont font() { return state->font(); } +}; + +class Picture : public QPicture +{ +public: + Picture() : QPicture() {} + QPaintEngine *paintEngine() const { return (QPaintEngine*)&mPaintEngine; } +private: + PaintEngine mPaintEngine; +}; + +void tst_QPicture::serialization() +{ + QDataStream stream; + const int thisVersion = stream.version(); + + for (int version = QDataStream::Qt_1_0; version <= thisVersion; ++version) { + const QDataStream::Version versionEnum = static_cast<QDataStream::Version>(version); + + { + // streaming of null pictures + ensureSerializesCorrectly(QPicture(), versionEnum); + } + { + // picture with a simple line, checking bitwise equality + QPicture picture; + QPainter painter(&picture); + painter.drawLine(10, 20, 30, 40); + ensureSerializesCorrectly(picture, versionEnum); + } } - // picture with a simple line, checking bitwise equality { - QPicture pic1, pic2; - QPainter p( &pic1 ); - p.drawLine( 10, 20, 30, 40 ); - p.end(); - QByteArray ba( 10 * pic1.size(), 0 ); - QDataStream str1( &ba, QIODevice::WriteOnly ); - str1 << pic1; - QDataStream str2( &ba, QIODevice::ReadOnly ); - str2 >> pic2; - QCOMPARE( pic1.size(), pic2.size() ); - QVERIFY( memcmp( pic1.data(), pic2.data(), pic1.size() ) == 0 ); + // Test features that were added after Qt 4.5, as that was hard-coded as the major + // version for a while, which was incorrect. In this case, we'll test font hints. + QPicture picture; + QPainter painter; + QFont font; + font.setStyleName("Blah"); + font.setHintingPreference(QFont::PreferFullHinting); + painter.begin(&picture); + painter.setFont(font); + painter.drawText(20, 20, "Hello"); + painter.end(); + + Picture customPicture; + painter.begin(&customPicture); + picture.play(&painter); + const QFont actualFont = ((PaintEngine*)customPicture.paintEngine())->font(); + painter.end(); + QCOMPARE(actualFont.styleName(), QStringLiteral("Blah")); + QCOMPARE(actualFont.hintingPreference(), QFont::PreferFullHinting); } } + #ifndef QT_NO_WIDGETS static QPointF scalePoint(const QPointF &point, QPaintDevice *sourceDevice, QPaintDevice *destDevice) { diff --git a/tests/auto/gui/kernel/kernel.pro b/tests/auto/gui/kernel/kernel.pro index e4d9ce9d27..bbcdd91ea3 100644 --- a/tests/auto/gui/kernel/kernel.pro +++ b/tests/auto/gui/kernel/kernel.pro @@ -20,6 +20,7 @@ SUBDIRS=\ qtouchevent \ qwindow \ qguiapplication \ + qpixelformat \ !qtHaveModule(widgets): SUBDIRS -= \ qmouseevent_modal \ diff --git a/tests/auto/gui/kernel/qclipboard/tst_qclipboard.cpp b/tests/auto/gui/kernel/qclipboard/tst_qclipboard.cpp index cf786c1dca..8a2009a601 100644 --- a/tests/auto/gui/kernel/qclipboard/tst_qclipboard.cpp +++ b/tests/auto/gui/kernel/qclipboard/tst_qclipboard.cpp @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Copyright (C) 2014 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. @@ -134,6 +134,29 @@ void tst_QClipboard::modes() } } +// A predicate to be used with a QSignalSpy / QTRY_VERIFY to ensure all delayed +// notifications are eaten. It waits at least one cycle and returns true when +// no new signals arrive. +class EatSignalSpyNotificationsPredicate +{ +public: + explicit EatSignalSpyNotificationsPredicate(QSignalSpy &spy) : m_spy(spy) { reset(); } + + operator bool() const + { + if (m_timer.elapsed() && !m_spy.count()) + return true; + m_spy.clear(); + return false; + } + + inline void reset() { m_timer.start(); } + +private: + QSignalSpy &m_spy; + QElapsedTimer m_timer; +}; + /* Test that the appropriate signals are emitted when the clipboard contents is changed by calling the qt functions. @@ -149,6 +172,13 @@ void tst_QClipboard::testSignals() QSignalSpy changedSpy(clipboard, SIGNAL(changed(QClipboard::Mode))); QSignalSpy dataChangedSpy(clipboard, SIGNAL(dataChanged())); + // Clipboard notifications are asynchronous with the new AddClipboardFormatListener + // in Windows Vista (5.4). Eat away all signals to ensure they don't interfere + // with the QTRY_COMPARE below. + EatSignalSpyNotificationsPredicate noLeftOverDataChanges(dataChangedSpy); + EatSignalSpyNotificationsPredicate noLeftOverChanges(changedSpy); + QTRY_VERIFY(noLeftOverChanges && noLeftOverDataChanges); + QSignalSpy searchChangedSpy(clipboard, SIGNAL(findBufferChanged())); QSignalSpy selectionChangedSpy(clipboard, SIGNAL(selectionChanged())); @@ -156,7 +186,7 @@ void tst_QClipboard::testSignals() // Test the default mode signal. clipboard->setText(text); - QCOMPARE(dataChangedSpy.count(), 1); + QTRY_COMPARE(dataChangedSpy.count(), 1); QCOMPARE(searchChangedSpy.count(), 0); QCOMPARE(selectionChangedSpy.count(), 0); QCOMPARE(changedSpy.count(), 1); @@ -296,6 +326,11 @@ void tst_QClipboard::setMimeData() QSignalSpy spySelection(QGuiApplication::clipboard(), SIGNAL(selectionChanged())); QSignalSpy spyData(QGuiApplication::clipboard(), SIGNAL(dataChanged())); + // Clipboard notifications are asynchronous with the new AddClipboardFormatListener + // in Windows Vista (5.4). Eat away all signals to ensure they don't interfere + // with the QTRY_COMPARE below. + EatSignalSpyNotificationsPredicate noLeftOverDataChanges(spyData); + QTRY_VERIFY(noLeftOverDataChanges); QSignalSpy spyFindBuffer(QGuiApplication::clipboard(), SIGNAL(findBufferChanged())); QGuiApplication::clipboard()->clear(QClipboard::Clipboard); @@ -312,7 +347,7 @@ void tst_QClipboard::setMimeData() else QCOMPARE(spyFindBuffer.count(), 0); - QCOMPARE(spyData.count(), 1); + QTRY_COMPARE(spyData.count(), 1); // an other crash test data = new QMimeData; @@ -326,7 +361,8 @@ void tst_QClipboard::setMimeData() newData->setText("bar"); spySelection.clear(); - spyData.clear(); + noLeftOverDataChanges.reset(); + QTRY_VERIFY(noLeftOverDataChanges); spyFindBuffer.clear(); QGuiApplication::clipboard()->setMimeData(newData, QClipboard::Clipboard); @@ -343,7 +379,7 @@ void tst_QClipboard::setMimeData() else QCOMPARE(spyFindBuffer.count(), 0); - QCOMPARE(spyData.count(), 1); + QTRY_COMPARE(spyData.count(), 1); } void tst_QClipboard::clearBeforeSetText() diff --git a/tests/auto/gui/kernel/qguiapplication/icons/appicon.png b/tests/auto/gui/kernel/qguiapplication/icons/appicon.png Binary files differnew file mode 100644 index 0000000000..b5d3ecbddf --- /dev/null +++ b/tests/auto/gui/kernel/qguiapplication/icons/appicon.png diff --git a/tests/auto/gui/kernel/qguiapplication/icons/usericon.png b/tests/auto/gui/kernel/qguiapplication/icons/usericon.png Binary files differnew file mode 100644 index 0000000000..8d703640c1 --- /dev/null +++ b/tests/auto/gui/kernel/qguiapplication/icons/usericon.png diff --git a/tests/auto/gui/kernel/qguiapplication/qguiapplication.pro b/tests/auto/gui/kernel/qguiapplication/qguiapplication.pro index cd363bab31..895c2a0307 100644 --- a/tests/auto/gui/kernel/qguiapplication/qguiapplication.pro +++ b/tests/auto/gui/kernel/qguiapplication/qguiapplication.pro @@ -7,3 +7,5 @@ INCLUDEPATH += $$CORE_TEST_PATH TARGET = tst_qguiapplication QT += gui-private SOURCES += tst_qguiapplication.cpp + +RESOURCES = tst_qguiapplication.qrc diff --git a/tests/auto/gui/kernel/qguiapplication/tst_qguiapplication.cpp b/tests/auto/gui/kernel/qguiapplication/tst_qguiapplication.cpp index e551d99959..54b6fc6c44 100644 --- a/tests/auto/gui/kernel/qguiapplication/tst_qguiapplication.cpp +++ b/tests/auto/gui/kernel/qguiapplication/tst_qguiapplication.cpp @@ -65,6 +65,7 @@ class tst_QGuiApplication: public tst_QCoreApplication private slots: void displayName(); void firstWindowTitle(); + void windowIcon(); void focusObject(); void allWindows(); void topLevelWindows(); @@ -74,6 +75,7 @@ private slots: void modalWindow(); void quitOnLastWindowClosed(); void genericPluginsAndWindowSystemEvents(); + void layoutDirection(); }; void tst_QGuiApplication::displayName() @@ -99,6 +101,24 @@ void tst_QGuiApplication::firstWindowTitle() QCOMPARE(window.title(), QString("User Title")); } +void tst_QGuiApplication::windowIcon() +{ + int argc = 3; + char *argv[] = { const_cast<char*>("tst_qguiapplication"), const_cast<char*>("-qwindowicon"), const_cast<char*>(":/icons/usericon.png") }; + QGuiApplication app(argc, argv); + QIcon appIcon(":/icons/appicon.png"); + app.setWindowIcon(appIcon); + + QWindow window; + window.show(); + + QIcon userIcon(":/icons/usericon.png"); + // Comparing icons is hard. cacheKey() differs because the icon was independently loaded. + // So we use availableSizes, after making sure that the app and user icons do have different sizes. + QVERIFY(userIcon.availableSizes() != appIcon.availableSizes()); + QCOMPARE(window.icon().availableSizes(), userIcon.availableSizes()); +} + class DummyWindow : public QWindow { public: @@ -829,4 +849,30 @@ void tst_QGuiApplication::genericPluginsAndWindowSystemEvents() QCOMPARE(testReceiver.customEvents, 1); } +Q_DECLARE_METATYPE(Qt::LayoutDirection) +void tst_QGuiApplication::layoutDirection() +{ + qRegisterMetaType<Qt::LayoutDirection>(); + + Qt::LayoutDirection oldDirection = QGuiApplication::layoutDirection(); + Qt::LayoutDirection newDirection = oldDirection == Qt::LeftToRight ? Qt::RightToLeft : Qt::LeftToRight; + + QGuiApplication::setLayoutDirection(newDirection); + QCOMPARE(QGuiApplication::layoutDirection(), newDirection); + + int argc = 1; + char *argv[] = { const_cast<char*>("tst_qguiapplication") }; + QGuiApplication app(argc, argv); + QSignalSpy signalSpy(&app, SIGNAL(layoutDirectionChanged(Qt::LayoutDirection))); + + QGuiApplication::setLayoutDirection(oldDirection); + QCOMPARE(QGuiApplication::layoutDirection(), oldDirection); + QCOMPARE(signalSpy.count(), 1); + QCOMPARE(signalSpy.at(0).at(0).toInt(), static_cast<int>(oldDirection)); + + QGuiApplication::setLayoutDirection(oldDirection); + QCOMPARE(QGuiApplication::layoutDirection(), oldDirection); + QCOMPARE(signalSpy.count(), 1); +} + QTEST_APPLESS_MAIN(tst_QGuiApplication) diff --git a/tests/auto/gui/kernel/qguiapplication/tst_qguiapplication.qrc b/tests/auto/gui/kernel/qguiapplication/tst_qguiapplication.qrc new file mode 100644 index 0000000000..b26fba37b9 --- /dev/null +++ b/tests/auto/gui/kernel/qguiapplication/tst_qguiapplication.qrc @@ -0,0 +1,6 @@ +<!DOCTYPE RCC><RCC version="1.0"> +<qresource prefix="/"> + <file>icons/usericon.png</file> + <file>icons/appicon.png</file> +</qresource> +</RCC> diff --git a/tests/auto/gui/kernel/qpixelformat/qpixelformat.pro b/tests/auto/gui/kernel/qpixelformat/qpixelformat.pro new file mode 100644 index 0000000000..970e5c7c2d --- /dev/null +++ b/tests/auto/gui/kernel/qpixelformat/qpixelformat.pro @@ -0,0 +1,6 @@ +CONFIG += testcase +TARGET = tst_qpixelformat + +QT += gui testlib + +SOURCES += tst_qpixelformat.cpp diff --git a/tests/auto/gui/kernel/qpixelformat/tst_qpixelformat.cpp b/tests/auto/gui/kernel/qpixelformat/tst_qpixelformat.cpp new file mode 100644 index 0000000000..c3b19a3b44 --- /dev/null +++ b/tests/auto/gui/kernel/qpixelformat/tst_qpixelformat.cpp @@ -0,0 +1,243 @@ +/**************************************************************************** +** +** Copyright (C) 2014 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 <QtTest/QtTest> + +#include <QtGui/qpixelformat.h> + +class tst_QPixelFormat : public QObject +{ + Q_OBJECT + +private slots: + void testOperators(); + void testQVectorOfFormats(); + void testRGB(); + void testCMYK(); + void testHSLandHSV(); + void testYUV_data(); + void testYUV(); + void testEnums(); +}; + +void tst_QPixelFormat::testOperators() +{ + QPixelFormat first = QPixelFormatRgb(8,8,8,8,QPixelFormat::UsesAlpha, QPixelFormat::AtBeginning, QPixelFormat::Premultiplied); + QPixelFormat second = QPixelFormatRgb(8,8,8,8,QPixelFormat::UsesAlpha, QPixelFormat::AtBeginning, QPixelFormat::Premultiplied); + QVERIFY(first == second); + + QPixelFormat third = QPixelFormatRgb(8,8,8,8,QPixelFormat::UsesAlpha, QPixelFormat::AtEnd, QPixelFormat::NotPremultiplied); + QVERIFY(first != third); +} + +void tst_QPixelFormat::testQVectorOfFormats() +{ + QVector<QPixelFormat> reallocedVector; + QVector<QPixelFormat> reservedVector; + reservedVector.reserve(QImage::NImageFormats); + for (int i = 0; i < QImage::NImageFormats; i++) { + if (i == 0 || i == 2) // skip invalid and monolsb + continue; + QImage::Format image_format = static_cast<QImage::Format>(i); + QPixelFormat format = QImage::toPixelFormat(image_format); + reallocedVector.append(format); + reservedVector.append(format); + } + + for (int i = 0; i < reallocedVector.size(); i++) { + QCOMPARE(reallocedVector.at(i), reservedVector.at(i)); + } +} + +void tst_QPixelFormat::testRGB() +{ + QPixelFormat argb8888 = QPixelFormatRgb(8,8,8,8,QPixelFormat::UsesAlpha,QPixelFormat::AtBeginning, QPixelFormat::Premultiplied); + QCOMPARE(argb8888.redSize(), uchar(8)); + QCOMPARE(argb8888.greenSize(), uchar(8)); + QCOMPARE(argb8888.blueSize(), uchar(8)); + QCOMPARE(argb8888.alphaSize(), uchar(8)); + + QPixelFormat rgb565 = QPixelFormatRgb(5,6,5,0,QPixelFormat::IgnoresAlpha,QPixelFormat::AtBeginning, QPixelFormat::NotPremultiplied); + QCOMPARE(rgb565.redSize(), uchar(5)); + QCOMPARE(rgb565.greenSize(), uchar(6)); + QCOMPARE(rgb565.blueSize(), uchar(5)); + QCOMPARE(rgb565.alphaSize(), uchar(0)); + QCOMPARE(rgb565.bitsPerPixel(), uchar(16)); + + QPixelFormat rgba1235 = QPixelFormatRgb(1,2,3,5,QPixelFormat::IgnoresAlpha, QPixelFormat::AtEnd, QPixelFormat::Premultiplied); + QCOMPARE(rgba1235.redSize(), uchar(1)); + QCOMPARE(rgba1235.greenSize(), uchar(2)); + QCOMPARE(rgba1235.blueSize(), uchar(3)); + QCOMPARE(rgba1235.alphaSize(), uchar(5)); + QCOMPARE(rgba1235.bitsPerPixel(), uchar(1 + 2 + 3 + 5)); +} + +void tst_QPixelFormat::testCMYK() +{ + QPixelFormat cmyk6 = QPixelFormatCmyk(6); + QCOMPARE(cmyk6.cyanSize(), uchar(6)); + QCOMPARE(cmyk6.magentaSize(), uchar(6)); + QCOMPARE(cmyk6.yellowSize(), uchar(6)); + QCOMPARE(cmyk6.blackSize(), uchar(6)); + QCOMPARE(cmyk6.bitsPerPixel(), uchar(6*4)); + + QPixelFormat cmykWithAlpha = QPixelFormatCmyk(8,8); + QCOMPARE(cmykWithAlpha.bitsPerPixel(), uchar(8*5)); +} +void tst_QPixelFormat::testHSLandHSV() +{ + QPixelFormat hsl = QPixelFormatHsl(3,5); + + QCOMPARE(hsl.hueSize(), uchar(3)); + QCOMPARE(hsl.saturationSize(), uchar(3)); + QCOMPARE(hsl.lightnessSize(), uchar(3)); + QCOMPARE(hsl.bitsPerPixel(), uchar(3 * 3 + 5)); + + QPixelFormat hsv = QPixelFormatHsv(5,7); + + QCOMPARE(hsv.hueSize(), uchar(5)); + QCOMPARE(hsv.saturationSize(), uchar(5)); + QCOMPARE(hsv.brightnessSize(), uchar(5)); + QCOMPARE(hsv.bitsPerPixel(), uchar(5 * 3 + 7)); +} + +Q_DECLARE_METATYPE(QPixelFormat::YUVLayout) +void tst_QPixelFormat::testYUV_data() +{ + QTest::addColumn<QPixelFormat::YUVLayout>("yuv_layout"); + QTest::newRow("YUV Layout YUV444") << QPixelFormat::YUV444; + QTest::newRow("YUV Layout YUV422") << QPixelFormat::YUV422; + QTest::newRow("YUV Layout YUV411") << QPixelFormat::YUV411; + QTest::newRow("YUV Layout YUV420P") << QPixelFormat::YUV420P; + QTest::newRow("YUV Layout YUV420SP") << QPixelFormat::YUV420SP; + QTest::newRow("YUV Layout YV12") << QPixelFormat::YV12; + QTest::newRow("YUV Layout UYVY") << QPixelFormat::UYVY; + QTest::newRow("YUV Layout YUYV") << QPixelFormat::YUYV; + QTest::newRow("YUV Layout NV12") << QPixelFormat::NV12; + QTest::newRow("YUV Layout NV21") << QPixelFormat::NV21; + QTest::newRow("YUV Layout IMC1") << QPixelFormat::IMC1; + QTest::newRow("YUV Layout IMC2") << QPixelFormat::IMC2; + QTest::newRow("YUV Layout IMC3") << QPixelFormat::IMC3; + QTest::newRow("YUV Layout IMC4") << QPixelFormat::IMC4; + QTest::newRow("YUV Layout Y8") << QPixelFormat::Y8; + QTest::newRow("YUV Layout Y16") << QPixelFormat::Y16; +} + +void tst_QPixelFormat::testYUV() +{ + QFETCH(QPixelFormat::YUVLayout, yuv_layout); + + QPixelFormat format = QPixelFormatYuv(yuv_layout, 0); + + switch (yuv_layout) { + case QPixelFormat::YUV444: + QCOMPARE(format.bitsPerPixel(), uchar(24)); + break; + case QPixelFormat::YUV422: + QCOMPARE(format.bitsPerPixel(), uchar(16)); + break; + case QPixelFormat::YUV411: + case QPixelFormat::YUV420P: + case QPixelFormat::YUV420SP: + case QPixelFormat::YV12: + QCOMPARE(format.bitsPerPixel(), uchar(12)); + break; + case QPixelFormat::UYVY: + case QPixelFormat::YUYV: + QCOMPARE(format.bitsPerPixel(), uchar(16)); + break; + case QPixelFormat::NV12: + case QPixelFormat::NV21: + QCOMPARE(format.bitsPerPixel(), uchar(12)); + break; + case QPixelFormat::IMC1: + case QPixelFormat::IMC2: + case QPixelFormat::IMC3: + case QPixelFormat::IMC4: + QCOMPARE(format.bitsPerPixel(), uchar(12)); + break; + case QPixelFormat::Y8: + QCOMPARE(format.bitsPerPixel(), uchar(8)); + break; + case QPixelFormat::Y16: + QCOMPARE(format.bitsPerPixel(), uchar(16)); + break; + default: + QVERIFY(!"the value stored for the yuvLayout is wrong!"); + } + +} + +void tst_QPixelFormat::testEnums() +{ + QPixelFormat allSet = QPixelFormat(QPixelFormat::BGR,1,2,3,4,5,6, + QPixelFormat::UsesAlpha, + QPixelFormat::AtEnd, + QPixelFormat::Premultiplied, + QPixelFormat::FloatingPoint, + QPixelFormat::BigEndian, + (1 << 6) - 1); + + QCOMPARE(allSet.alphaUsage(), QPixelFormat::UsesAlpha); + QCOMPARE(allSet.alphaPosition(), QPixelFormat::AtEnd); + QCOMPARE(allSet.premultiplied(), QPixelFormat::Premultiplied); + QCOMPARE(allSet.byteOrder(), QPixelFormat::BigEndian); + QCOMPARE(allSet.typeInterpretation(), QPixelFormat::FloatingPoint); + QCOMPARE(allSet.byteOrder(), QPixelFormat::BigEndian); + QCOMPARE(allSet.subEnum(), uchar(63)); + + QPixelFormat nonSet = QPixelFormat(QPixelFormat::RGB,6,5,4,3,2,1, + QPixelFormat::IgnoresAlpha, + QPixelFormat::AtBeginning, + QPixelFormat::NotPremultiplied, + QPixelFormat::UnsignedInteger, + QPixelFormat::LittleEndian); + + QCOMPARE(nonSet.alphaUsage(), QPixelFormat::IgnoresAlpha); + QCOMPARE(nonSet.alphaPosition(), QPixelFormat::AtBeginning); + QCOMPARE(nonSet.premultiplied(), QPixelFormat::NotPremultiplied); + QCOMPARE(nonSet.byteOrder(), QPixelFormat::LittleEndian); + QCOMPARE(nonSet.typeInterpretation(), QPixelFormat::UnsignedInteger); + QCOMPARE(nonSet.byteOrder(), QPixelFormat::LittleEndian); + QCOMPARE(nonSet.subEnum(), uchar(0)); +} + +#include <tst_qpixelformat.moc> +QTEST_MAIN(tst_QPixelFormat); diff --git a/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp b/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp index 868288e36e..9517264e55 100644 --- a/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp +++ b/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp @@ -67,6 +67,7 @@ private slots: void mapGlobal(); void positioning_data(); void positioning(); + void positioningDuringMinimized(); void isExposed(); void isActive(); void testInputEvents(); @@ -306,6 +307,28 @@ void tst_QWindow::positioning() } } +void tst_QWindow::positioningDuringMinimized() +{ + // QTBUG-39544, setting a geometry in minimized state should work as well. + if (QGuiApplication::platformName().compare("windows", Qt::CaseInsensitive)) + QSKIP("Not supported on this platform"); + Window window; + window.setTitle(QStringLiteral("positioningDuringMinimized")); + const QRect initialGeometry(QGuiApplication::primaryScreen()->availableGeometry().topLeft() + QPoint(100, 100), + QSize(200, 200)); + window.setGeometry(initialGeometry); + window.showNormal(); + QVERIFY(QTest::qWaitForWindowExposed(&window)); + QCOMPARE(window.geometry(), initialGeometry); + window.setWindowState(Qt::WindowMinimized); + QCOMPARE(window.geometry(), initialGeometry); + const QRect newGeometry(initialGeometry.topLeft() + QPoint(50, 50), initialGeometry.size() + QSize(50, 50)); + window.setGeometry(newGeometry); + QTRY_COMPARE(window.geometry(), newGeometry); + window.setWindowState(Qt::WindowNoState); + QTRY_COMPARE(window.geometry(), newGeometry); +} + void tst_QWindow::isExposed() { QRect geometry(80, 80, 40, 40); diff --git a/tests/auto/gui/math3d/qmatrixnxn/tst_qmatrixnxn.cpp b/tests/auto/gui/math3d/qmatrixnxn/tst_qmatrixnxn.cpp index 98f1c1c8f9..e492a8f7bf 100644 --- a/tests/auto/gui/math3d/qmatrixnxn/tst_qmatrixnxn.cpp +++ b/tests/auto/gui/math3d/qmatrixnxn/tst_qmatrixnxn.cpp @@ -147,6 +147,7 @@ private slots: void ortho(); void frustum(); void perspective(); + void viewport(); void flipCoordinates(); void convertGeneric(); @@ -2794,6 +2795,40 @@ void tst_QMatrixNxN::perspective() QVERIFY(m5.isIdentity()); } +// Test viewport transformations +void tst_QMatrixNxN::viewport() +{ + // Uses default depth range of 0->1 + QMatrix4x4 m1; + m1.viewport(0.0f, 0.0f, 1024.0f, 768.0f); + + // Lower left + QVector4D p1 = m1 * QVector4D(-1.0f, -1.0f, 0.0f, 1.0f); + QVERIFY(qFuzzyIsNull(p1.x())); + QVERIFY(qFuzzyIsNull(p1.y())); + QVERIFY(qFuzzyCompare(p1.z(), 0.5f)); + + // Lower right + QVector4D p2 = m1 * QVector4D(1.0f, -1.0f, 0.0f, 1.0f); + QVERIFY(qFuzzyCompare(p2.x(), 1024.0f)); + QVERIFY(qFuzzyIsNull(p2.y())); + + // Upper right + QVector4D p3 = m1 * QVector4D(1.0f, 1.0f, 0.0f, 1.0f); + QVERIFY(qFuzzyCompare(p3.x(), 1024.0f)); + QVERIFY(qFuzzyCompare(p3.y(), 768.0f)); + + // Upper left + QVector4D p4 = m1 * QVector4D(-1.0f, 1.0f, 0.0f, 1.0f); + QVERIFY(qFuzzyIsNull(p4.x())); + QVERIFY(qFuzzyCompare(p4.y(), 768.0f)); + + // Center + QVector4D p5 = m1 * QVector4D(0.0f, 0.0f, 0.0f, 1.0f); + QVERIFY(qFuzzyCompare(p5.x(), 1024.0f / 2.0f)); + QVERIFY(qFuzzyCompare(p5.y(), 768.0f / 2.0f)); +} + // Test left-handed vs right-handed coordinate flipping. void tst_QMatrixNxN::flipCoordinates() { diff --git a/tests/auto/gui/painting/qcolor/tst_qcolor.cpp b/tests/auto/gui/painting/qcolor/tst_qcolor.cpp index 1b1f5575b1..2e1d55ced4 100644 --- a/tests/auto/gui/painting/qcolor/tst_qcolor.cpp +++ b/tests/auto/gui/painting/qcolor/tst_qcolor.cpp @@ -530,10 +530,19 @@ static const int rgbTblSize = sizeof(rgbTbl) / sizeof(RGBData); void tst_QColor::setNamedColor() { for (int i = 0; i < rgbTblSize; ++i) { - QColor color; - color.setNamedColor(QLatin1String(rgbTbl[i].name)); QColor expected; expected.setRgba(rgbTbl[i].value); + + QColor color; + color.setNamedColor(QLatin1String(rgbTbl[i].name)); + QCOMPARE(color, expected); + + // name should be case insensitive + color.setNamedColor(QString(rgbTbl[i].name).toUpper()); + QCOMPARE(color, expected); + + // spaces should be ignored + color.setNamedColor(QString(rgbTbl[i].name).insert(1, ' ')); QCOMPARE(color, expected); } } diff --git a/tests/auto/gui/painting/qpainter/tst_qpainter.cpp b/tests/auto/gui/painting/qpainter/tst_qpainter.cpp index e4340451ce..4604f840da 100644 --- a/tests/auto/gui/painting/qpainter/tst_qpainter.cpp +++ b/tests/auto/gui/painting/qpainter/tst_qpainter.cpp @@ -282,6 +282,8 @@ private slots: void QTBUG17053_zeroDashPattern(); + void QTBUG38781_NoBrushAndQBitmap(); + void drawTextOutsideGuiThread(); void drawTextWithComplexBrush(); @@ -4473,6 +4475,26 @@ void tst_QPainter::QTBUG17053_zeroDashPattern() QCOMPARE(image, original); } +void tst_QPainter::QTBUG38781_NoBrushAndQBitmap() +{ + QBitmap bitmap(10, 10); + bitmap.fill(Qt::color0); + QPainter p(&bitmap); + p.setPen(Qt::color1); + p.drawLine(0, 1, 9, 1); // at horizontal line at y=1 + p.setBrush(Qt::NoBrush); + p.drawRect(0, 0, 9, 9); // a rect all around + + QRgb white = qRgb(0xff, 0xff, 0xff); + QRgb black = qRgb(0, 0, 0); + QImage image = bitmap.toImage(); + QCOMPARE(image.pixel(0, 0), black); + QCOMPARE(image.pixel(5, 5), white); + + // Check that the rect didn't overwrite the line + QCOMPARE(image.pixel(5, 1), black); +} + class TextDrawerThread : public QThread { public: diff --git a/tests/auto/gui/painting/qpen/tst_qpen.cpp b/tests/auto/gui/painting/qpen/tst_qpen.cpp index 07c996d026..a373c51710 100644 --- a/tests/auto/gui/painting/qpen/tst_qpen.cpp +++ b/tests/auto/gui/painting/qpen/tst_qpen.cpp @@ -57,6 +57,8 @@ public: private slots: void getSetCheck(); void swap(); + void move(); + void move_assign(); void operator_eq_eq(); void operator_eq_eq_data(); @@ -101,6 +103,57 @@ void tst_QPen::swap() QCOMPARE(p2.color(), QColor(Qt::black)); } +void tst_QPen::move() +{ + QPen p1(Qt::black); + + // check that moving does the right thing: + QPen p2 = qMove(p1); // could be move or copy construction, so don't check p1's state + QCOMPARE(p2.color(), QColor(Qt::black)); + + // this, executed ehre, would crash: + // QVERIFY(p1.style() != Qt::NoPen); + + // check that moved-from QPen p1 can still be safely copied: + const QPen p3 = p1; + + // check that moved-from QPen p1 can still be safely assigned to: + const QPen p4(Qt::yellow); + p1 = p4; + QCOMPARE(p1.color(), QColor(Qt::yellow)); + + // check that moved-from QPens p2, p3 can still be safely destroyed: + QPen p5 = qMove(p2); + + // intentionally no more statements beyond this point +} + +void tst_QPen::move_assign() +{ + QPen p1(Qt::black), p2(Qt::white); + + // check that moving does the right thing: + p2 = qMove(p1); // could be move or copy assignment, so don't check p1's state + QCOMPARE(p2.color(), QColor(Qt::black)); + + // check that move-assigned-from QPen p1 can still be used, albeit + // with undocumented state (it's p2's original state): + QVERIFY(p1.style() != Qt::NoPen); + + // check that moved-from QPen p1 can still be safely copied: + const QPen p3 = p1; + + // check that moved-from QPen p1 can still be safely assigned to: + const QPen p4(Qt::yellow); + p1 = p4; + QCOMPARE(p1.color(), QColor(Qt::yellow)); + + // check that moved-from QPens p2, p3 can still be safely destroyed: + QPen p5; + p5 = qMove(p2); + + // intentionally no more statements beyond this point +} tst_QPen::tst_QPen() diff --git a/tests/auto/gui/qopengl/qopengl.pro b/tests/auto/gui/qopengl/qopengl.pro index 12429bbeed..fcf457fec4 100644 --- a/tests/auto/gui/qopengl/qopengl.pro +++ b/tests/auto/gui/qopengl/qopengl.pro @@ -10,3 +10,5 @@ QT += gui-private core-private testlib SOURCES += tst_qopengl.cpp win32-msvc2010:contains(QT_CONFIG, angle):CONFIG += insignificant_test # QTBUG-31611 + +linux:contains(QT_CONFIG, xcb-glx):contains(QT_CONFIG, xcb-xlib): DEFINES += USE_GLX diff --git a/tests/auto/gui/qopengl/tst_qopengl.cpp b/tests/auto/gui/qopengl/tst_qopengl.cpp index 63fe8b9693..c32edd3f71 100644 --- a/tests/auto/gui/qopengl/tst_qopengl.cpp +++ b/tests/auto/gui/qopengl/tst_qopengl.cpp @@ -51,12 +51,19 @@ #include <QtGui/QGenericMatrix> #include <QtGui/QMatrix4x4> #include <QtGui/private/qopengltextureblitter_p.h> - +#include <QtGui/private/qguiapplication_p.h> +#include <qpa/qplatformintegration.h> +#include <qpa/qplatformnativeinterface.h> #include <QtTest/QtTest> #include <QSignalSpy> +#ifdef USE_GLX +// Must be included last due to the X11 types +#include <QtPlatformHeaders/QGLXNativeContext> +#endif + class tst_QOpenGL : public QObject { Q_OBJECT @@ -85,6 +92,10 @@ private slots: void textureblitterPartOriginTopLeftSourceRectTransform(); void textureblitterFullTargetRectTransform(); void textureblitterPartTargetRectTransform(); + +#ifdef USE_GLX + void glxContextWrap(); +#endif }; struct SharedResourceTracker @@ -448,9 +459,9 @@ void tst_QOpenGL::fboSimpleRendering() QVERIFY(fbo->bind()); - glClearColor(1.0, 0.0, 0.0, 1.0); - glClear(GL_COLOR_BUFFER_BIT); - glFinish(); + ctx.functions()->glClearColor(1.0, 0.0, 0.0, 1.0); + ctx.functions()->glClear(GL_COLOR_BUFFER_BIT); + ctx.functions()->glFinish(); const QImage fb = fbo->toImage().convertToFormat(QImage::Format_RGB32); QCOMPARE(fb.size(), size); @@ -494,9 +505,9 @@ void tst_QOpenGL::fboTextureOwnership() fbo->bind(); QVERIFY(fbo->texture() != 0 && fbo->texture() != texture); - glClearColor(1.0, 0.0, 0.0, 1.0); - glClear(GL_COLOR_BUFFER_BIT); - glFinish(); + ctx.functions()->glClearColor(1.0, 0.0, 0.0, 1.0); + ctx.functions()->glClear(GL_COLOR_BUFFER_BIT); + ctx.functions()->glFinish(); QImage fb = fbo->toImage().convertToFormat(QImage::Format_RGB32); QImage reference(fb.size(), QImage::Format_RGB32); @@ -504,7 +515,7 @@ void tst_QOpenGL::fboTextureOwnership() QFUZZY_COMPARE_IMAGES(fb, reference); - glDeleteTextures(1, &texture); + ctx.functions()->glDeleteTextures(1, &texture); delete fbo; } @@ -970,6 +981,45 @@ void tst_QOpenGL::textureblitterPartTargetRectTransform() QCOMPARE(targetBottomRight, expectedBottomRight); } +#ifdef USE_GLX +void tst_QOpenGL::glxContextWrap() +{ + QWindow *window = new QWindow; + window->setSurfaceType(QWindow::OpenGLSurface); + window->setGeometry(0, 0, 10, 10); + window->show(); + QTest::qWaitForWindowExposed(window); + + QPlatformNativeInterface *nativeIf = QGuiApplicationPrivate::instance()->platformIntegration()->nativeInterface(); + QVERIFY(nativeIf); + + // Fetch a GLXContext. + QOpenGLContext *ctx0 = new QOpenGLContext; + ctx0->setFormat(window->format()); + QVERIFY(ctx0->create()); + QVariant v = ctx0->nativeHandle(); + QVERIFY(!v.isNull()); + QVERIFY(v.canConvert<QGLXNativeContext>()); + GLXContext context = v.value<QGLXNativeContext>().context(); + QVERIFY(context); + + // Then create another QOpenGLContext wrapping it. + QOpenGLContext *ctx = new QOpenGLContext; + ctx->setNativeHandle(QVariant::fromValue<QGLXNativeContext>(QGLXNativeContext(context))); + QVERIFY(ctx->create()); + QVERIFY(ctx->nativeHandle().value<QGLXNativeContext>().context() == context); + QVERIFY(nativeIf->nativeResourceForContext(QByteArrayLiteral("glxcontext"), ctx) == (void *) context); + + QVERIFY(ctx->makeCurrent(window)); + ctx->doneCurrent(); + + delete ctx; + delete ctx0; + + delete window; +} +#endif // USE_GLX + QTEST_MAIN(tst_QOpenGL) #include "tst_qopengl.moc" diff --git a/tests/auto/gui/text/qfont/tst_qfont.cpp b/tests/auto/gui/text/qfont/tst_qfont.cpp index 4c88212c72..6f75a1f8bb 100644 --- a/tests/auto/gui/text/qfont/tst_qfont.cpp +++ b/tests/auto/gui/text/qfont/tst_qfont.cpp @@ -76,7 +76,8 @@ private slots: void isCopyOf(); void italicOblique(); void insertAndRemoveSubstitutions(); - void serializeSpacing(); + void serialize_data(); + void serialize(); void lastResortFont(); void styleName(); void defaultFamily_data(); @@ -534,7 +535,6 @@ void tst_QFont::insertAndRemoveSubstitutions() QVERIFY(QFont::substitutes("bogusfontfamily").isEmpty()); } - static QFont copyFont(const QFont &font1) // copy using a QDataStream { QBuffer buffer; @@ -549,29 +549,115 @@ static QFont copyFont(const QFont &font1) // copy using a QDataStream return font2; } -void tst_QFont::serializeSpacing() +Q_DECLARE_METATYPE(QDataStream::Version) + +void tst_QFont::serialize_data() { - QFont font; - QCOMPARE(font.letterSpacing(), 0.); - QCOMPARE(font.wordSpacing(), 0.); + QTest::addColumn<QFont>("font"); + // The version in which the tested feature was added. + QTest::addColumn<QDataStream::Version>("minimumStreamVersion"); + + QFont basicFont; + // Versions <= Qt 2.1 had broken point size serialization, + // so we set an integer point size. + basicFont.setPointSize(9); + + QFont font = basicFont; + QTest::newRow("defaultConstructed") << font << QDataStream::Qt_1_0; font.setLetterSpacing(QFont::AbsoluteSpacing, 105); - QCOMPARE(font.letterSpacing(), 105.); - QCOMPARE(font.letterSpacingType(), QFont::AbsoluteSpacing); - QCOMPARE(font.wordSpacing(), 0.); - QFont font2 = copyFont(font); - QCOMPARE(font2.letterSpacing(), 105.); - QCOMPARE(font2.letterSpacingType(), QFont::AbsoluteSpacing); - QCOMPARE(font2.wordSpacing(), 0.); + QTest::newRow("letterSpacing") << font << QDataStream::Qt_4_5; + font = basicFont; font.setWordSpacing(50.0); - QCOMPARE(font.letterSpacing(), 105.); - QCOMPARE(font.wordSpacing(), 50.); + QTest::newRow("wordSpacing") << font << QDataStream::Qt_4_5; + + font = basicFont; + font.setPointSize(20); + QTest::newRow("pointSize") << font << QDataStream::Qt_1_0; + + font = basicFont; + font.setPixelSize(32); + QTest::newRow("pixelSize") << font << QDataStream::Qt_3_0; + + font = basicFont; + font.setStyleHint(QFont::Monospace); + QTest::newRow("styleHint") << font << QDataStream::Qt_1_0; + + font = basicFont; + font.setStretch(4000); + QTest::newRow("stretch") << font << QDataStream::Qt_4_3; + + font = basicFont; + font.setWeight(99); + QTest::newRow("weight") << font << QDataStream::Qt_1_0; + + font = basicFont; + font.setUnderline(true); + QTest::newRow("underline") << font << QDataStream::Qt_1_0; + + font = basicFont; + font.setStrikeOut(true); + QTest::newRow("strikeOut") << font << QDataStream::Qt_1_0; + + font = basicFont; + font.setFixedPitch(true); + // This fails for versions less than this, as ignorePitch is set to false + // whenever setFixedPitch() is called, but ignorePitch is considered an + // extended bit, which were apparently not available until 4.4. + QTest::newRow("fixedPitch") << font << QDataStream::Qt_4_4; + + font = basicFont; + font.setLetterSpacing(QFont::AbsoluteSpacing, 10); + // Fails for 4.4 because letterSpacing wasn't read until 4.5. + QTest::newRow("letterSpacing") << font << QDataStream::Qt_4_5; + + font = basicFont; + font.setRawMode(true); + QTest::newRow("rawMode") << font << QDataStream::Qt_1_0; + + font = basicFont; + font.setKerning(false); + QTest::newRow("kerning") << font << QDataStream::Qt_4_0; + + font = basicFont; + font.setStyleStrategy(QFont::NoFontMerging); + // This wasn't read properly until 5.4. + QTest::newRow("styleStrategy") << font << QDataStream::Qt_5_4; + + font = basicFont; + font.setHintingPreference(QFont::PreferFullHinting); + // This wasn't read until 5.4. + QTest::newRow("hintingPreference") << font << QDataStream::Qt_5_4; + + font = basicFont; + font.setStyleName("Regular Black Condensed"); + // This wasn't read until 5.4. + QTest::newRow("styleName") << font << QDataStream::Qt_5_4; +} - QFont font3 = copyFont(font); - QCOMPARE(font3.letterSpacing(), 105.); - QCOMPARE(font3.letterSpacingType(), QFont::AbsoluteSpacing); - QCOMPARE(font3.wordSpacing(), 50.); +void tst_QFont::serialize() +{ + QFETCH(QFont, font); + QFETCH(QDataStream::Version, minimumStreamVersion); + + QDataStream stream; + const int thisVersion = stream.version(); + + for (int version = minimumStreamVersion; version <= thisVersion; ++version) { + QBuffer buffer; + buffer.open(QIODevice::WriteOnly); + stream.setDevice(&buffer); + stream.setVersion(version); + stream << font; + buffer.close(); + + buffer.open(QIODevice::ReadOnly); + QFont readFont; + stream >> readFont; + QVERIFY2(readFont == font, qPrintable(QString::fromLatin1("Fonts do not compare equal for QDataStream version ") + + QString::fromLatin1("%1:\nactual: %2\nexpected: %3").arg(version).arg(readFont.toString()).arg(font.toString()))); + } } // QFont::lastResortFont() may abort with qFatal() on QWS/QPA diff --git a/tests/auto/gui/text/qrawfont/tst_qrawfont.cpp b/tests/auto/gui/text/qrawfont/tst_qrawfont.cpp index a39277b093..a4e1490b01 100644 --- a/tests/auto/gui/text/qrawfont/tst_qrawfont.cpp +++ b/tests/auto/gui/text/qrawfont/tst_qrawfont.cpp @@ -314,16 +314,24 @@ void tst_QRawFont::advances() bool supportsSubPixelPositions = font_d->fontEngine->supportsSubPixelPositions(); QVector<QPointF> advances = font.advancesForGlyphIndexes(glyphIndices); - for (int i=0; i<glyphIndices.size(); ++i) { -#ifdef Q_OS_WIN - // In Windows, freetype engine returns advance of 9 when full hinting is used (default) for - // some of the glyphs. - if (font_d->fontEngine->type() == QFontEngine::Freetype - && (hintingPreference == QFont::PreferFullHinting || hintingPreference == QFont::PreferDefaultHinting) - && (i == 0 || i == 5)) { - QEXPECT_FAIL("", "Advance for some glyphs is not the expected with Windows Freetype engine (9 instead of 8)", Continue); - } + + // On Windows and QNX, freetype engine returns advance of 9 for some of the glyphs + // when full hinting is used (default on Windows). + bool mayFail = false; +#if defined (Q_OS_WIN) + mayFail = font_d->fontEngine->type() == QFontEngine::Freetype + && (hintingPreference == QFont::PreferFullHinting + || hintingPreference == QFont::PreferDefaultHinting); +#elif defined(Q_OS_QNX) + mayFail = font_d->fontEngine->type() == QFontEngine::Freetype + && hintingPreference == QFont::PreferFullHinting; #endif + + for (int i = 0; i < glyphIndices.size(); ++i) { + if (mayFail && (i == 0 || i == 5)) { + QEXPECT_FAIL("", "FreeType engine reports unexpected advance " + "for some glyphs (9 instead of 8)", Continue); + } QVERIFY(qFuzzyCompare(qRound(advances.at(i).x()), 8.0)); if (supportsSubPixelPositions) QVERIFY(advances.at(i).x() > 8.0); @@ -341,16 +349,11 @@ void tst_QRawFont::advances() QVERIFY(font.advancesForGlyphIndexes(glyphIndices.constData(), advances.data(), numGlyphs)); - for (int i=0; i<glyphIndices.size(); ++i) { -#ifdef Q_OS_WIN - // In Windows, freetype engine returns advance of 9 when full hinting is used (default) for - // some of the glyphs. - if (font_d->fontEngine->type() == QFontEngine::Freetype - && (hintingPreference == QFont::PreferFullHinting || hintingPreference == QFont::PreferDefaultHinting) - && (i == 0 || i == 5)) { - QEXPECT_FAIL("", "Advance for some glyphs is not the expected with Windows Freetype engine (9 instead of 8)", Continue); + for (int i = 0; i < glyphIndices.size(); ++i) { + if (mayFail && (i == 0 || i == 5)) { + QEXPECT_FAIL("", "FreeType engine reports unexpected advance " + "for some glyphs (9 instead of 8)", Continue); } -#endif QVERIFY(qFuzzyCompare(qRound(advances.at(i).x()), 8.0)); if (supportsSubPixelPositions) QVERIFY(advances.at(i).x() > 8.0); diff --git a/tests/auto/network/ssl/qsslcertificate/pkcs12/README b/tests/auto/network/ssl/qsslcertificate/pkcs12/README new file mode 100644 index 0000000000..1828d089c1 --- /dev/null +++ b/tests/auto/network/ssl/qsslcertificate/pkcs12/README @@ -0,0 +1,8 @@ +The PKCS#12 bundle was created by running the following on +in the qsslsocket/certs directory: + +openssl pkcs12 -export -in leaf.crt -inkey leaf.key \ + -out leaf.p12 \ + -certfile inter.crt -CAfile ca.crt + +No password was provided. diff --git a/tests/auto/network/ssl/qsslcertificate/pkcs12/inter.crt b/tests/auto/network/ssl/qsslcertificate/pkcs12/inter.crt new file mode 100644 index 0000000000..4e1d67c3e0 --- /dev/null +++ b/tests/auto/network/ssl/qsslcertificate/pkcs12/inter.crt @@ -0,0 +1,22 @@ +-----BEGIN CERTIFICATE----- +MIIDvDCCAnSgAwIBAgIQO+uZxerYC10Ll11PBnVL4TANBgkqhkiG9w0BAQUFADA8 +MQswCQYDVQQGEwJHQjEZMBcGA1UEChMQV2VzdHBvaW50IENBIEtleTESMBAGA1UE +ChMJV2VzdHBvaW50MB4XDTEzMDIxNjE2NTMwOFoXDTIzMDIxNjE2NTMwOFowMjEL +MAkGA1UEBhMCR0IxIzAhBgNVBAoTGldlc3Rwb2ludCBJbnRlcm1lZGlhdGUgS2V5 +MIIBUjANBgkqhkiG9w0BAQEFAAOCAT8AMIIBOgKCATEAsR4tRskg2IFfQFMfGBJ1 +eqlrNejANw0oM6k5HlEB8uFA9qeyAzmflwQUPoJ55KRQ/gVHTOBdWrtgGgPMiekF +1Q36Ry1elwbAl4a+LZ6qsc9ASipvk8HirKpt1v5L9hG+aI4yDxyvjNztFtg5R4P5 +zqsh/WwhCgsYmEVfcSDbhUjqoqxGRLaZxPKO+IMCNFrjZqi0yxc8f6Un4G5SQzHA +4szi/ezcITnAFYWxHG2yaed4hawpxNS1WXabk2rzCi0pWeIcHuIczaCfZ7ElRcqV +VNNXbGTtUDlfIsh6FAVI5kTUDcPV27uf6BmHuFOu/R9Tjni25+vBFvohwQh7ZwCX +5COXnfkJLPkJQQEFVQv8nS27ht/vmyoKjERUeiuMd+hFcN5zl7bS5A2JCgi7erlP +ZQIDAQABo2QwYjAPBgNVHRMBAf8EBTADAQH/MA8GA1UdDwEB/wQFAwMHBgAwHQYD +VR0OBBYEFGn5shQ0SeTcc3x/cNu6TkoV0bPmMB8GA1UdIwQYMBaAFJQnOLW5hBTG +pvc2vfcs4sJpRRPJMA0GCSqGSIb3DQEBBQUAA4IBMQAVDS0enQQ1FL0d92xOFfwx +mjcNPz9oO7jMyEVxAs2eR2QD+xZ3Xj4gAiUEp40aGieDcLv+dg+cmuBFWF61IYSR +UyuoakVm08VDcLAwUzU+xtSvJiSSROb0GsAnVsYZj4TYlvKDplqfapOYaiIkwF+c +iE4n7G0hQW9fzqO+n3FGtBD8YUjghRqLggeRVJ2+8S3Bm8cfx8xPpRIO3ksA6opn +CORRGuzetDHihbks59mkoY3GqKFgBOyrC3kG07nv5wtKjdKDtmD/kS/SAc4fIXKy +Uruq2uXNf/1BUgF5gFGRyj22yB2D0763fJJpl5nqcLrL5RmnVObQKZGhE2VsRTV0 +untj+AmiJivhiAjjkHfw3XDf8tuL7D4pTmEkGgl5xl23fyeTIuygDCLT8fRD3ZqQ +-----END CERTIFICATE----- diff --git a/tests/auto/network/ssl/qsslcertificate/pkcs12/leaf.crt b/tests/auto/network/ssl/qsslcertificate/pkcs12/leaf.crt new file mode 100644 index 0000000000..4a7dc40540 --- /dev/null +++ b/tests/auto/network/ssl/qsslcertificate/pkcs12/leaf.crt @@ -0,0 +1,23 @@ +-----BEGIN CERTIFICATE----- +MIID3zCCApegAwIBAgIQEKCtd1j2bq5Gk6ND+VmKnjANBgkqhkiG9w0BAQUFADAy +MQswCQYDVQQGEwJHQjEjMCEGA1UEChMaV2VzdHBvaW50IEludGVybWVkaWF0ZSBL +ZXkwHhcNMTMwMjE2MTY1MzA4WhcNMjMwMjE2MTY1MzA4WjA1MQswCQYDVQQGEwJH +QjESMBAGA1UEChMJV2VzdHBvaW50MRIwEAYDVQQDEwkxMjcuMC4wLjEwggFSMA0G +CSqGSIb3DQEBAQUAA4IBPwAwggE6AoIBMQC7EIWIzb7XCfmQQ1KFdZ5E9f49eNK/ +KvsXYfq/iV29K1cz2hUyvfdKgyU5F/+BOPQKQ5zdWn1CraZosFv/ibuO3mhRpMfB +SfNn3rfdrE7WtA0wgT2YNIN0L4aCe+C15j2ESdmyMaFLUaUIS47JS66UtaYxp5ia +mJFO1hSNaoI0pGHyPFTTtfOza9z/01qkBbHB4htzauqs/fX5ZrnyCDSrfpVipXke +zkPKg4MkkytEkjRKw6tSXLpWIgF3ee2N/jBdefqlw8YPW08K0wmwF5qGuX6PZ8vB +sOZeWeCfVr136BopkbfP3TkGWw2BrD8xSzOUez9HVc0v4SZ/7pe5w3L4V/mzYQLt +O+1AHevCjX8+M58HYGBaWCAjxYUPGcGKcj0LLtgZgL6wY88N7RtfeOY3AgMBAAGj +gY0wgYowFAYDVR0RBA0wC4IJMTI3LjAuMC4xMAwGA1UdEwEB/wQCMAAwEwYDVR0l +BAwwCgYIKwYBBQUHAwEwDwYDVR0PAQH/BAUDAwcoADAdBgNVHQ4EFgQUKKuyJSrT +Y+dnm1do7l0sVMX96SYwHwYDVR0jBBgwFoAUafmyFDRJ5NxzfH9w27pOShXRs+Yw +DQYJKoZIhvcNAQEFBQADggExAHELijlIFdcncP3B+vxEp0SGKl0arIaCXahivb2F +VxeM3WajN6O+oDRLFltzMeDKA9RVkao7fgITzXQgCGzeNhKv0vc9iDyvR9/67vuS +W8xEEJrYowtw3VK5H1y0ewqZaxJhvKUjm4TBRWe8FGKD3s64lEsfbjOaI5VPidVc +DXmdAlXsj0Hk+v4Ej8mshPQAnVSyJ3D0ZMgTjk8Di28N0qROFIYJaTObK1rCb1nQ +GaCcmbZU6JnkYvVZ+iUe5U0GXFbb+LRNTUT8/fw1zADeHnv/G+WWVrfND+sov5Oc +33fkNE6z+n6ayABVnGLuCYhbzD38sv0dnxeh8vbykNBPzYdzPg6nw3Czv2vlhKpJ +8Yj/maoXuAyTXVf30K1/fAWyU45noq57MjQpU6UxIX1D7qw= +-----END CERTIFICATE----- diff --git a/tests/auto/network/ssl/qsslcertificate/pkcs12/leaf.key b/tests/auto/network/ssl/qsslcertificate/pkcs12/leaf.key new file mode 100644 index 0000000000..54327925d8 --- /dev/null +++ b/tests/auto/network/ssl/qsslcertificate/pkcs12/leaf.key @@ -0,0 +1,32 @@ +-----BEGIN RSA PRIVATE KEY----- +MIIFfAIBAAKCATEAuxCFiM2+1wn5kENShXWeRPX+PXjSvyr7F2H6v4ldvStXM9oV +Mr33SoMlORf/gTj0CkOc3Vp9Qq2maLBb/4m7jt5oUaTHwUnzZ9633axO1rQNMIE9 +mDSDdC+GgnvgteY9hEnZsjGhS1GlCEuOyUuulLWmMaeYmpiRTtYUjWqCNKRh8jxU +07Xzs2vc/9NapAWxweIbc2rqrP31+Wa58gg0q36VYqV5Hs5DyoODJJMrRJI0SsOr +Uly6ViIBd3ntjf4wXXn6pcPGD1tPCtMJsBeahrl+j2fLwbDmXlngn1a9d+gaKZG3 +z905BlsNgaw/MUszlHs/R1XNL+Emf+6XucNy+Ff5s2EC7TvtQB3rwo1/PjOfB2Bg +WlggI8WFDxnBinI9Cy7YGYC+sGPPDe0bX3jmNwIDAQABAoIBMQCczBNyAStGqjjC +oHuKHHWmTh9mPWFBFfDTv6/jXmvxRWPZtaHxH2Qp09Wejqv/D9MWy2ev7spx2oZS +2Ai1ICjTbz83uAwryyW4Wen6aBTJSLCJiLstWk8ZU0DHHLjVH4FO4mwUPh95t5zC +YDr2JXbXdY8xrc5vPxUFZNJjWvR61ZK37bQYpTn5mZ7r3KfsNk2yOylRTDwa9XFo +ZZ+B82NKdrrz0UvGOnXZa5qd1ap7V+67FIAS2Mt8AMzSCG8TW0JXRUk89ISgAd8r +NQTPtX9XCnMZSbBzDKdznXfHS9ZlJcSrpsbQCPcvMVNrdBfCF0eNnsRJffJGdaXI +MsN6PvbcXWD08lXNGyeLjon03RdJnTAamNM3YQEIcjFmu5Y0o0CCJkZSCJPKJGMG +0d/1tN/5AoGZANOcOgQZ9Wiu0ej3YoQ3aSHu3y8ZBJH4B3ViX8i+2x/6UnG7KNaa +4Ygid1upnX6hk4CW5WZcoxGFacrFRpInKh5Ng8lEIHGp0VSzOBVDR0L5sAxutFuX +6N9C0CuH80vD101mOloNnfT5KHZMI5RXqP6sDGUFlwak2XybDL1qOAza3gZAy25H +vS/ll1BneBavikR5j+zxoTztAoGZAOJOJ5RyOrqpNuhiWZylah5LIFT9N1lCF4Hl +ZbFIjUZ4jcApJ7JxkMXNQ4RU/3AiKCC1xr5ib7dd/qyjKXhdMo4SnLoKhapx5R9G +3XOsQMahiCD/Zcymv9tmk8MxxzbLxhZYhEPzIP/NFkua3CHiX+d1e6fkzFLF/EiX +ZGQOgRcFKrlzUeBputRQRXAkKJH+kMClgAWvy28zAoGYKyaMXhG9DV+4xjzMBhIW +iijfsgbz+6AMRU+OIK1qmZa+ARsdNMXYf54noLVxvETOg0ZB+SGizwvZitO3lE4Q +NKWx3fTaeNMcMJ1rLkrN2UZ5M8/PT24muoAxWu8aGbURzmKuO3bTYwT7z0OvbayC +dYw36tG8/knXX6Vub6GdVGG9LKFB2nceiQnUVT0EK/wXwebYBoUvT/ECgZgF9qdG +Wyg/CPyAbS8NWLKOL86fTrjpqjsyWhgu7smCROT/XlZEdoepHrqbvx2oF85U5lVh +aPimrVxrsjUCjfoqEkV9BY/2KOAvzc9CIBTo5xLOQ8yr8uz1XCOiriogwIfsyNJb +dAm3k/D1dxQ79FowoEDs8LONrtfyFcM4e8VdFO7GSkqrDj41IBRkWx+SkVHBMdtI +yxQiTwKBmQCWym2iDCJg1ZZq4/lVwRudMhVmHoD0yoCAwADYHjjAi8QBplM0vfdd +CESKsnBhlcrPGB279BKVJyZHehKZG+/dfnFs+to14l6A3IqU2d6+pu3EyFNX34HS +xo+64QxMeF0akWnSaIPfUJfk36phjCvLBr4eLXN1i4jW3RdGFwF1THXt29VSSGmU +q/hM51H0bsQ13AIVUSdNHA== +-----END RSA PRIVATE KEY----- diff --git a/tests/auto/network/ssl/qsslcertificate/pkcs12/leaf.p12 b/tests/auto/network/ssl/qsslcertificate/pkcs12/leaf.p12 Binary files differnew file mode 100644 index 0000000000..cb89aadb73 --- /dev/null +++ b/tests/auto/network/ssl/qsslcertificate/pkcs12/leaf.p12 diff --git a/tests/auto/network/ssl/qsslcertificate/qsslcertificate.pro b/tests/auto/network/ssl/qsslcertificate/qsslcertificate.pro index 09cb22defe..69cd241f84 100644 --- a/tests/auto/network/ssl/qsslcertificate/qsslcertificate.pro +++ b/tests/auto/network/ssl/qsslcertificate/qsslcertificate.pro @@ -6,5 +6,6 @@ SOURCES += tst_qsslcertificate.cpp QT = core network testlib TARGET = tst_qsslcertificate +DEFINES += SRCDIR=\\\"$$PWD/\\\" -TESTDATA += certificates/* more-certificates/* verify-certs/* +TESTDATA += certificates/* more-certificates/* verify-certs/* pkcs12/* diff --git a/tests/auto/network/ssl/qsslcertificate/tst_qsslcertificate.cpp b/tests/auto/network/ssl/qsslcertificate/tst_qsslcertificate.cpp index 4f62076870..83462568f5 100644 --- a/tests/auto/network/ssl/qsslcertificate/tst_qsslcertificate.cpp +++ b/tests/auto/network/ssl/qsslcertificate/tst_qsslcertificate.cpp @@ -105,6 +105,7 @@ private slots: void largeSerialNumber(); void largeExpirationDate(); void blacklistedCertificates(); + void selfsignedCertificates(); void toText(); void multipleCommonNames(); void subjectAndIssuerAttributes(); @@ -113,6 +114,7 @@ private slots: void threadSafeConstMethods(); void version_data(); void version(); + void pkcs12(); // helper for verbose test failure messages QString toString(const QList<QSslError>&); @@ -890,6 +892,13 @@ void tst_QSslCertificate::blacklistedCertificates() } } +void tst_QSslCertificate::selfsignedCertificates() +{ + QVERIFY(QSslCertificate::fromPath(testDataDir + "/certificates/cert-ss.pem").first().isSelfSigned()); + QVERIFY(!QSslCertificate::fromPath(testDataDir + "/certificates/cert.pem").first().isSelfSigned()); + QVERIFY(!QSslCertificate().isSelfSigned()); +} + void tst_QSslCertificate::toText() { QList<QSslCertificate> certList = @@ -1221,6 +1230,48 @@ void tst_QSslCertificate::version() QCOMPARE(certificate.version(), result); } +void tst_QSslCertificate::pkcs12() +{ + if (!QSslSocket::supportsSsl()) { + qWarning("SSL not supported, skipping test"); + return; + } + + QFile f(QLatin1String(SRCDIR "pkcs12/leaf.p12")); + bool ok = f.open(QIODevice::ReadOnly); + QVERIFY(ok); + + QSslKey key; + QSslCertificate cert; + QList<QSslCertificate> caCerts; + + ok = QSslCertificate::importPKCS12(&f, &key, &cert, &caCerts); + QVERIFY(ok); + f.close(); + + QList<QSslCertificate> leafCert = QSslCertificate::fromPath(QLatin1String( SRCDIR "pkcs12/leaf.crt")); + QVERIFY(!leafCert.isEmpty()); + + QCOMPARE(cert, leafCert.first()); + + QFile f2(QLatin1String(SRCDIR "pkcs12/leaf.key")); + ok = f2.open(QIODevice::ReadOnly); + QVERIFY(ok); + + QSslKey leafKey(&f2, QSsl::Rsa); + f2.close(); + + QVERIFY(!leafKey.isNull()); + QCOMPARE(key, leafKey); + + QList<QSslCertificate> caCert = QSslCertificate::fromPath(QLatin1String(SRCDIR "pkcs12/inter.crt")); + QVERIFY(!caCert.isEmpty()); + + QVERIFY(!caCerts.isEmpty()); + QCOMPARE(caCerts.first(), caCert.first()); + QCOMPARE(caCerts, caCert); +} + #endif // QT_NO_SSL QTEST_MAIN(tst_QSslCertificate) diff --git a/tests/auto/opengl/qgl/tst_qgl.cpp b/tests/auto/opengl/qgl/tst_qgl.cpp index ba2528d3cf..71243339aa 100644 --- a/tests/auto/opengl/qgl/tst_qgl.cpp +++ b/tests/auto/opengl/qgl/tst_qgl.cpp @@ -1090,9 +1090,10 @@ void tst_QGL::glFBOSimpleRendering() fbo->bind(); - glClearColor(1.0, 0.0, 0.0, 1.0); - glClear(GL_COLOR_BUFFER_BIT); - glFinish(); + QOpenGLFunctions *funcs = QOpenGLContext::currentContext()->functions(); + funcs->glClearColor(1.0, 0.0, 0.0, 1.0); + funcs->glClear(GL_COLOR_BUFFER_BIT); + funcs->glFinish(); QImage fb = fbo->toImage().convertToFormat(QImage::Format_RGB32); QImage reference(fb.size(), QImage::Format_RGB32); @@ -1390,11 +1391,11 @@ class RenderPixmapWidget : public QGLWidget protected: void initializeGL() { // Set some gl state: - glClearColor(1.0, 0.0, 0.0, 1.0); + QOpenGLContext::currentContext()->functions()->glClearColor(1.0, 0.0, 0.0, 1.0); } void paintGL() { - glClear(GL_COLOR_BUFFER_BIT); + QOpenGLContext::currentContext()->functions()->glClear(GL_COLOR_BUFFER_BIT); } }; @@ -1683,11 +1684,12 @@ protected: void paintEvent(QPaintEvent*) { // clear the stencil with junk - glStencilMask(0xFFFF); - glClearStencil(0xFFFF); - glDisable(GL_STENCIL_TEST); - glDisable(GL_SCISSOR_TEST); - glClear(GL_STENCIL_BUFFER_BIT); + QOpenGLFunctions *funcs = QOpenGLContext::currentContext()->functions(); + funcs->glStencilMask(0xFFFF); + funcs->glClearStencil(0xFFFF); + funcs->glDisable(GL_STENCIL_TEST); + funcs->glDisable(GL_SCISSOR_TEST); + funcs->glClear(GL_STENCIL_BUFFER_BIT); QPainter painter(this); paint(&painter); @@ -2029,26 +2031,27 @@ void tst_QGL::qglContextDefaultBindTexture() QVERIFY(QImagePixmapCleanupHooks::isImageCached(*boundImage)); QVERIFY(QImagePixmapCleanupHooks::isPixmapCached(*boundPixmap)); + QOpenGLFunctions *funcs = QOpenGLContext::currentContext()->functions(); // Make sure the texture IDs returned are valid: - QCOMPARE((bool)glIsTexture(boundImageTextureId), GL_TRUE); - QCOMPARE((bool)glIsTexture(boundPixmapTextureId), GL_TRUE); + QCOMPARE((bool)funcs->glIsTexture(boundImageTextureId), GL_TRUE); + QCOMPARE((bool)funcs->glIsTexture(boundPixmapTextureId), GL_TRUE); // Make sure the textures are still valid after we delete the image/pixmap: // Also check that although the textures are left intact, the cache entries are removed: delete boundImage; boundImage = 0; - QCOMPARE((bool)glIsTexture(boundImageTextureId), GL_TRUE); + QCOMPARE((bool)funcs->glIsTexture(boundImageTextureId), GL_TRUE); QCOMPARE(QGLTextureCache::instance()->size(), startCacheItemCount+1); delete boundPixmap; boundPixmap = 0; - QCOMPARE((bool)glIsTexture(boundPixmapTextureId), GL_TRUE); + QCOMPARE((bool)funcs->glIsTexture(boundPixmapTextureId), GL_TRUE); QCOMPARE(QGLTextureCache::instance()->size(), startCacheItemCount); // Finally, make sure QGLContext::deleteTexture deletes the texture IDs: ctx->deleteTexture(boundImageTextureId); ctx->deleteTexture(boundPixmapTextureId); - QCOMPARE((bool)glIsTexture(boundImageTextureId), GL_FALSE); - QCOMPARE((bool)glIsTexture(boundPixmapTextureId), GL_FALSE); + QCOMPARE((bool)funcs->glIsTexture(boundImageTextureId), GL_FALSE); + QCOMPARE((bool)funcs->glIsTexture(boundPixmapTextureId), GL_FALSE); } #endif diff --git a/tests/auto/opengl/qglfunctions/tst_qglfunctions.cpp b/tests/auto/opengl/qglfunctions/tst_qglfunctions.cpp index 2f09d84772..a465afef21 100644 --- a/tests/auto/opengl/qglfunctions/tst_qglfunctions.cpp +++ b/tests/auto/opengl/qglfunctions/tst_qglfunctions.cpp @@ -62,7 +62,7 @@ bool tst_QGLFunctions::hasExtension(const char *name) { QString extensions = QString::fromLatin1 - (reinterpret_cast<const char *>(glGetString(GL_EXTENSIONS))); + (reinterpret_cast<const char *>(QOpenGLContext::currentContext()->functions()->glGetString(GL_EXTENSIONS))); return extensions.split(QLatin1Char(' ')).contains (QString::fromLatin1(name)); } @@ -194,46 +194,46 @@ void tst_QGLFunctions::features() // Verify that the multitexture functions appear to resolve and work. void tst_QGLFunctions::multitexture() { - QGLFunctions funcs; + QOpenGLFunctions funcs; QGLWidget glw; if (!glw.isValid()) QSKIP("Could not create a GL context"); glw.makeCurrent(); - funcs.initializeGLFunctions(); + funcs.initializeOpenGLFunctions(); - if (!funcs.hasOpenGLFeature(QGLFunctions::Multitexture)) + if (!funcs.hasOpenGLFeature(QOpenGLFunctions::Multitexture)) QSKIP("Multitexture functions are not supported"); funcs.glActiveTexture(GL_TEXTURE1); GLint active = 0; - glGetIntegerv(GL_ACTIVE_TEXTURE, &active); + funcs.glGetIntegerv(GL_ACTIVE_TEXTURE, &active); QVERIFY(active == GL_TEXTURE1); funcs.glActiveTexture(GL_TEXTURE0); active = 0; - glGetIntegerv(GL_ACTIVE_TEXTURE, &active); + funcs.glGetIntegerv(GL_ACTIVE_TEXTURE, &active); QVERIFY(active == GL_TEXTURE0); } // Verify that the glBlendColor() function appears to resolve and work. void tst_QGLFunctions::blendColor() { - QGLFunctions funcs; + QOpenGLFunctions funcs; QGLWidget glw; if (!glw.isValid()) QSKIP("Could not create a GL context"); glw.makeCurrent(); - funcs.initializeGLFunctions(); + funcs.initializeOpenGLFunctions(); - if (!funcs.hasOpenGLFeature(QGLFunctions::BlendColor)) + if (!funcs.hasOpenGLFeature(QOpenGLFunctions::BlendColor)) QSKIP("glBlendColor() is not supported"); funcs.glBlendColor(0.0f, 1.0f, 0.0f, 1.0f); GLfloat colors[4] = {0.5f, 0.5f, 0.5f, 0.5f}; - glGetFloatv(GL_BLEND_COLOR, colors); + funcs.glGetFloatv(GL_BLEND_COLOR, colors); QCOMPARE(colors[0], 0.0f); QCOMPARE(colors[1], 1.0f); diff --git a/tests/auto/opengl/qglthreads/tst_qglthreads.cpp b/tests/auto/opengl/qglthreads/tst_qglthreads.cpp index 70e3a3b62a..25057ba2a0 100644 --- a/tests/auto/opengl/qglthreads/tst_qglthreads.cpp +++ b/tests/auto/opengl/qglthreads/tst_qglthreads.cpp @@ -48,6 +48,10 @@ #include <QtOpenGL/QtOpenGL> #include "tst_qglthreads.h" +#ifndef QT_OPENGL_ES_2 +#include <QtGui/QOpenGLFunctions_1_0> +#endif + #define RUNNING_TIME 5000 tst_QGLThreads::tst_QGLThreads(QObject *parent) @@ -339,8 +343,9 @@ static inline float qrandom() { return (rand() % 100) / 100.f; } void renderAScene(int w, int h) { + QOpenGLFunctions *funcs = QOpenGLContext::currentContext()->functions(); + if (QOpenGLContext::currentContext()->isOpenGLES()) { - QGLFunctions funcs(QGLContext::currentContext()); Q_UNUSED(w); Q_UNUSED(h); QGLShaderProgram program; @@ -349,7 +354,7 @@ void renderAScene(int w, int h) program.bindAttributeLocation("pos", 0); program.bind(); - funcs.glEnableVertexAttribArray(0); + funcs->glEnableVertexAttribArray(0); for (int i=0; i<1000; ++i) { GLfloat pos[] = { @@ -361,30 +366,33 @@ void renderAScene(int w, int h) (rand() % 100) / 100.f }; - funcs.glVertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE, 0, pos); - glDrawArrays(GL_TRIANGLE_STRIP, 0, 3); + funcs->glVertexAttribPointer(0, 2, GL_FLOAT, GL_FALSE, 0, pos); + funcs->glDrawArrays(GL_TRIANGLE_STRIP, 0, 3); } } else { #ifndef QT_OPENGL_ES_2 - glViewport(0, 0, w, h); + QOpenGLFunctions_1_0 *gl1funcs = QOpenGLContext::currentContext()->versionFunctions<QOpenGLFunctions_1_0>(); + gl1funcs->initializeOpenGLFunctions(); + + gl1funcs->glViewport(0, 0, w, h); - glMatrixMode(GL_PROJECTION); - glLoadIdentity(); - glFrustum(0, w, h, 0, 1, 100); - glTranslated(0, 0, -1); + gl1funcs->glMatrixMode(GL_PROJECTION); + gl1funcs->glLoadIdentity(); + gl1funcs->glFrustum(0, w, h, 0, 1, 100); + gl1funcs->glTranslated(0, 0, -1); - glMatrixMode(GL_MODELVIEW); - glLoadIdentity(); + gl1funcs->glMatrixMode(GL_MODELVIEW); + gl1funcs->glLoadIdentity(); for (int i=0;i<1000; ++i) { - glBegin(GL_TRIANGLES); - glColor3f(qrandom(), qrandom(), qrandom()); - glVertex2f(qrandom() * w, qrandom() * h); - glColor3f(qrandom(), qrandom(), qrandom()); - glVertex2f(qrandom() * w, qrandom() * h); - glColor3f(qrandom(), qrandom(), qrandom()); - glVertex2f(qrandom() * w, qrandom() * h); - glEnd(); + gl1funcs->glBegin(GL_TRIANGLES); + gl1funcs->glColor3f(qrandom(), qrandom(), qrandom()); + gl1funcs->glVertex2f(qrandom() * w, qrandom() * h); + gl1funcs->glColor3f(qrandom(), qrandom(), qrandom()); + gl1funcs->glVertex2f(qrandom() * w, qrandom() * h); + gl1funcs->glColor3f(qrandom(), qrandom(), qrandom()); + gl1funcs->glVertex2f(qrandom() * w, qrandom() * h); + gl1funcs->glEnd(); } #endif } @@ -434,8 +442,9 @@ public: QSize s = m_widget->newSize; m_widget->mutex.unlock(); + QOpenGLFunctions *funcs = QOpenGLContext::currentContext()->functions(); if (s != m_size) { - glViewport(0, 0, s.width(), s.height()); + funcs->glViewport(0, 0, s.width(), s.height()); } if (QGLContext::currentContext() != m_widget->context()) { @@ -443,7 +452,7 @@ public: break; } - glClear(GL_COLOR_BUFFER_BIT); + funcs->glClear(GL_COLOR_BUFFER_BIT); int w = m_widget->width(); int h = m_widget->height(); @@ -451,7 +460,7 @@ public: renderAScene(w, h); int color; - glReadPixels(w / 2, h / 2, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, &color); + funcs->glReadPixels(w / 2, h / 2, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, &color); m_widget->swapBuffers(); } diff --git a/tests/auto/other/compiler/compiler.pro b/tests/auto/other/compiler/compiler.pro index 8ebcf60bc0..213429050f 100644 --- a/tests/auto/other/compiler/compiler.pro +++ b/tests/auto/other/compiler/compiler.pro @@ -1,9 +1,9 @@ CONFIG += testcase TARGET = tst_compiler -SOURCES += tst_compiler.cpp baseclass.cpp derivedclass.cpp +SOURCES += tst_compiler.cpp baseclass.cpp derivedclass.cpp othersource.cpp HEADERS += baseclass.h derivedclass.h QT = core testlib - +contains(QT_CONFIG, c++11): CONFIG += c++14 c++11 DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0 diff --git a/tests/auto/other/compiler/othersource.cpp b/tests/auto/other/compiler/othersource.cpp new file mode 100644 index 0000000000..6ff7c4d8a9 --- /dev/null +++ b/tests/auto/other/compiler/othersource.cpp @@ -0,0 +1,51 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Intel Corporation. +** Contact: http://www.qt-project.org/legal +** +** This file is part of the QtCore module 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 <qglobal.h> + +#ifdef Q_COMPILER_EXTERN_TEMPLATES +template <typename T> T externTemplate(); +template<> int externTemplate<int>() +{ + return 42; +} +#endif + diff --git a/tests/auto/other/compiler/tst_compiler.cpp b/tests/auto/other/compiler/tst_compiler.cpp index a239e2c888..9ed5c64c4f 100644 --- a/tests/auto/other/compiler/tst_compiler.cpp +++ b/tests/auto/other/compiler/tst_compiler.cpp @@ -1,6 +1,7 @@ /**************************************************************************** ** ** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). +** Copyright (C) 2014 Intel Corporation ** Contact: http://www.qt-project.org/legal ** ** This file is part of the test suite of the Qt Toolkit. @@ -48,12 +49,17 @@ #include "baseclass.h" #include "derivedclass.h" +#ifdef Q_COMPILER_ATOMICS +# include <atomic> +#endif + QT_USE_NAMESPACE class tst_Compiler : public QObject { Q_OBJECT private slots: + /* C++98 & C++03 base functionality */ void template_methods(); void template_constructors(); void template_subclasses(); @@ -71,6 +77,57 @@ private slots: void charSignedness() const; void privateStaticTemplateMember() const; void staticConstUnionWithInitializerList() const; + void templateFriends(); + + /* C++11 features */ + void cxx11_alignas(); + void cxx11_alignof(); + void cxx11_alignas_alignof(); + void cxx11_atomics(); + void cxx11_attributes(); + void cxx11_auto_function(); + void cxx11_auto_type(); + void cxx11_class_enum(); + void cxx11_constexpr(); + void cxx11_decltype(); + void cxx11_default_members(); + void cxx11_delete_members(); + void cxx11_delegating_constructors(); + void cxx11_explicit_conversions(); + void cxx11_explicit_overrides(); + void cxx11_extern_templates(); + void cxx11_inheriting_constructors(); + void cxx11_initializer_lists(); + void cxx11_lambda(); + void cxx11_nonstatic_member_init(); + void cxx11_noexcept(); + void cxx11_nullptr(); + void cxx11_range_for(); + void cxx11_raw_strings(); + void cxx11_ref_qualifiers(); + void cxx11_rvalue_refs(); + void cxx11_static_assert(); + void cxx11_template_alias(); + void cxx11_thread_local(); + void cxx11_udl(); + void cxx11_unicode_strings(); + void cxx11_uniform_init(); + void cxx11_unrestricted_unions(); + void cxx11_variadic_macros(); + void cxx11_variadic_templates(); + + /* C++14 compiler features */ + void cxx14_binary_literals(); + void cxx14_init_captures(); + void cxx14_generic_lambdas(); + void cxx14_constexpr(); + void cxx14_decltype_auto(); + void cxx14_return_type_deduction(); + void cxx14_aggregate_nsdmi(); + void cxx14_variable_templates(); + + /* Future / Technical specification compiler features */ + void runtimeArrays(); }; #if defined(Q_CC_HPACC) @@ -556,5 +613,706 @@ void tst_Compiler::staticConstUnionWithInitializerList() const QVERIFY(qIsInf(d)); } +#ifndef Q_NO_TEMPLATE_FRIENDS +template <typename T> class TemplateFriends +{ + T value; +public: + TemplateFriends(T value) : value(value) {} + + template <typename X> void copy(TemplateFriends<X> other) + { value = other.value; } + + template <typename X> friend class TemplateFriends; +}; + +void tst_Compiler::templateFriends() +{ + TemplateFriends<int> ti(42); + TemplateFriends<long> tl(0); + tl.copy(ti); +} +#else +void tst_Compiler::templateFriends() +{ + QSKIP("Compiler does not support template friends"); +} +#endif + +void tst_Compiler::cxx11_alignas() +{ +#ifndef Q_COMPILER_ALIGNAS + QSKIP("Compiler does not support C++11 feature"); +#else + alignas(double) char c; + QVERIFY(Q_ALIGNOF(c) == Q_ALIGNOF(double)); +#endif +} + +void tst_Compiler::cxx11_alignof() +{ +#ifndef Q_COMPILER_ALIGNOF + QSKIP("Compiler does not support C++11 feature"); +#else + size_t alignchar = alignof(char); + size_t aligndouble = alignof(double); + QVERIFY(alignchar >= 1); + QVERIFY(alignchar <= aligndouble); +#endif +} + +void tst_Compiler::cxx11_alignas_alignof() +{ +#if !defined(Q_COMPILER_ALIGNAS) && !defined(Q_COMPILER_ALIGNOF) + QSKIP("Compiler does not support C++11 feature"); +#else + alignas(alignof(double)) char c; + Q_UNUSED(c); +#endif +} + +void tst_Compiler::cxx11_atomics() +{ +#ifndef Q_COMPILER_ATOMICS + QSKIP("Compiler does not support C++11 feature"); +#else + std::atomic<int> i; + i.store(42, std::memory_order_seq_cst); + QCOMPARE(i.load(std::memory_order_acquire), 42); + + std::atomic<short> s; + s.store(42); + QCOMPARE(s.load(), short(42)); + + std::atomic_flag flag; + flag.clear(); + QVERIFY(!flag.test_and_set()); + QVERIFY(flag.test_and_set()); +#endif +} + +void tst_Compiler::cxx11_attributes() +{ +#ifndef Q_COMPILER_ATTRIBUTES + QSKIP("Compiler does not support C++11 feature"); +#else + struct [[deprecated]] C {}; + [[gnu::unused]] struct D {} d; + [[noreturn]] void f(); + struct D e [[gnu::used, gnu::unused]]; + [[gnu::aligned(8)]] int i; + +[[gnu::unused]] end: + ; + + Q_UNUSED(d); + Q_UNUSED(e); + Q_UNUSED(i); +#endif +} + +#ifdef Q_COMPILER_AUTO_FUNCTION +auto autoFunction() -> unsigned +{ + return 1; +} +#endif + +void tst_Compiler::cxx11_auto_function() +{ +#ifndef Q_COMPILER_AUTO_FUNCTION + QSKIP("Compiler does not support C++11 feature"); +#else + QCOMPARE(autoFunction(), 1u); +#endif +} + +void tst_Compiler::cxx11_auto_type() +{ +#ifndef Q_COMPILER_AUTO_TYPE + QSKIP("Compiler does not support C++11 feature"); +#else + auto i = 1; + auto x = qrand(); + auto l = 1L; + auto s = QStringLiteral("Hello World"); + + QCOMPARE(i, 1); + Q_UNUSED(x); + QCOMPARE(l, 1L); + QCOMPARE(s.toLower(), QString("hello world")); +#endif +} + +void tst_Compiler::cxx11_class_enum() +{ +#ifndef Q_COMPILER_CLASS_ENUM + QSKIP("Compiler does not support C++11 feature"); +#else + enum class X { EnumValue }; + X x = X::EnumValue; + QCOMPARE(x, X::EnumValue); + + enum class Y : short { Val = 2 }; + enum Z : long { ValLong = LONG_MAX }; +#endif +} + +#ifdef Q_COMPILER_CONSTEXPR +constexpr int constexprValue() +{ + return 42; +} +#endif + +void tst_Compiler::cxx11_constexpr() +{ +#ifndef Q_COMPILER_CONSTEXPR + QSKIP("Compiler does not support C++11 feature"); +#else + static constexpr QBasicAtomicInt atomic = Q_BASIC_ATOMIC_INITIALIZER(1); + static constexpr int i = constexprValue(); + QCOMPARE(i, constexprValue()); + QCOMPARE(atomic.load(), 1); +#endif +} + +void tst_Compiler::cxx11_decltype() +{ +#ifndef Q_COMPILER_DECLTYPE + QSKIP("Compiler does not support C++11 feature"); +#else + decltype(qrand()) i = 0; + QCOMPARE(i, 0); +#endif +} + +void tst_Compiler::cxx11_default_members() +{ +#ifndef Q_COMPILER_DEFAULT_MEMBERS + QSKIP("Compiler does not support C++11 feature"); +#else + struct DefaultMembers + { + DefaultMembers() = default; + DefaultMembers(int) {} + }; + DefaultMembers dm; + Q_UNUSED(dm); +#endif +} + +void tst_Compiler::cxx11_delete_members() +{ +#ifndef Q_COMPILER_DELETE_MEMBERS + QSKIP("Compiler does not support C++11 feature"); +#else + struct DeleteMembers + { + DeleteMembers() = delete; + DeleteMembers(const DeleteMembers &) = delete; + ~DeleteMembers() = delete; + }; +#endif +} + +void tst_Compiler::cxx11_delegating_constructors() +{ +#ifndef Q_COMPILER_DELEGATING_CONSTRUCTORS + QSKIP("Compiler does not support C++11 feature"); +#else + struct DC { + DC(int i) : i(i) {} + DC() : DC(0) {} + int i; + }; + + DC dc; + QCOMPARE(dc.i, 0); +#endif +} + +void tst_Compiler::cxx11_explicit_conversions() +{ +#ifndef Q_COMPILER_EXPLICIT_CONVERSIONS + QSKIP("Compiler does not support C++11 feature"); +#else + struct EC { + explicit operator int() const { return 0; } + operator long long() const { return 1; } + }; + EC ec; + + int i(ec); + QCOMPARE(i, 0); + + int i2 = ec; + QCOMPARE(i2, 1); +#endif +} + +void tst_Compiler::cxx11_explicit_overrides() +{ +#ifndef Q_COMPILER_EXPLICIT_OVERRIDES + QSKIP("Compiler does not support C++11 feature"); +#else + struct Base { + virtual ~Base() {} + virtual void f() {} + }; + struct Derived final : public Base { + virtual void f() final override {} + }; +#endif +} + +#ifdef Q_COMPILER_EXTERN_TEMPLATES +template <typename T> T externTemplate() { return T(0); } +extern template int externTemplate<int>(); +#endif + +void tst_Compiler::cxx11_extern_templates() +{ +#ifndef Q_COMPILER_EXTERN_TEMPLATES + QSKIP("Compiler does not support C++11 feature"); +#else + QCOMPARE(externTemplate<int>(), 42); +#endif +} + +void tst_Compiler::cxx11_inheriting_constructors() +{ +#ifndef Q_COMPILER_INHERITING_CONSTRUCTORS + QSKIP("Compiler does not support C++11 feature"); +#else + struct Base { + int i; + Base() : i(0) {} + Base(int i) : i(i) {} + }; + struct Derived : public Base { + using Base::Base; + }; + + Derived d(1); + QCOMPARE(d.i, 1); +#endif +} + +void tst_Compiler::cxx11_initializer_lists() +{ +#ifndef Q_COMPILER_INITIALIZER_LISTS + QSKIP("Compiler does not support C++11 feature"); +#else + QList<int> l = { 1, 2, 3, 4, 5 }; + QCOMPARE(l.length(), 5); + QCOMPARE(l.at(0), 1); + QCOMPARE(l.at(4), 5); +#endif +} + +struct CallFunctor +{ + template <typename Functor> static int f(Functor f) + { return f();} +}; + +void tst_Compiler::cxx11_lambda() +{ +#ifndef Q_COMPILER_LAMBDA + QSKIP("Compiler does not support C++11 feature"); +#else + QCOMPARE(CallFunctor::f([]() { return 42; }), 42); +#endif +} + +void tst_Compiler::cxx11_nonstatic_member_init() +{ +#ifndef Q_COMPILER_NONSTATIC_MEMBER_INIT + QSKIP("Compiler does not support C++11 feature"); +#else + struct S { + int i = 42; + long l = 47; + char c; + S() : l(-47), c(0) {} + }; + S s; + + QCOMPARE(s.i, 42); + QCOMPARE(s.l, -47L); + QCOMPARE(s.c, '\0'); +#endif +} + +void tst_Compiler::cxx11_noexcept() +{ +#ifndef Q_COMPILER_NOEXCEPT + QSKIP("Compiler does not support C++11 feature"); +#else + extern void noexcept_f() noexcept; + extern void g() noexcept(noexcept(noexcept_f())); + QCOMPARE(noexcept(cxx11_noexcept()), false); + QCOMPARE(noexcept(noexcept_f), true); + QCOMPARE(noexcept(g), true); +#endif +} + +void tst_Compiler::cxx11_nullptr() +{ +#ifndef Q_COMPILER_NULLPTR + QSKIP("Compiler does not support C++11 feature"); +#else + void *v = nullptr; + char *c = nullptr; + const char *cc = nullptr; + volatile char *vc = nullptr; + std::nullptr_t np = nullptr; + v = np; + + Q_UNUSED(v); + Q_UNUSED(c); + Q_UNUSED(cc); + Q_UNUSED(vc); +#endif +} + +void tst_Compiler::cxx11_range_for() +{ +#ifndef Q_COMPILER_RANGE_FOR + QSKIP("Compiler does not support C++11 feature"); +#else + QList<int> l; + l << 1 << 2 << 3; + for (int i : l) + Q_UNUSED(i); + + l.clear(); + l << 1; + for (int i : l) + QCOMPARE(i, 1); + + QList<long> ll; + l << 2; + for (int i : ll) + QCOMPARE(i, 2); +#endif +} + +void tst_Compiler::cxx11_raw_strings() +{ +#ifndef Q_COMPILER_RAW_STRINGS + QSKIP("Compiler does not support C++11 feature"); +#else + static const char xml[] = R"(<?xml version="1.0" encoding="UTF-8" ?>)"; + static const char raw[] = R"***(*"*)***"; + QCOMPARE(strlen(raw), size_t(3)); + QCOMPARE(raw[1], '"'); + Q_UNUSED(xml); +#endif +} + +void tst_Compiler::cxx11_ref_qualifiers() +{ +#ifndef Q_COMPILER_REF_QUALIFIERS + QSKIP("Compiler does not support C++11 feature"); +#else +# ifndef Q_COMPILER_RVALUE_REFS +# error "Impossible condition: ref qualifiers are supported but not rvalue refs" +# endif + // also applies to function pointers + QByteArray (QString:: *lvalueref)() const & = &QString::toLatin1; + QByteArray (QString:: *rvalueref)() && = &QString::toLatin1; + + QString s("Hello"); + QCOMPARE((s.*lvalueref)(), QByteArray("Hello")); + QCOMPARE((std::move(s).*rvalueref)(), QByteArray("Hello")); + + // tests internal behavior: + QVERIFY(s.isEmpty()); +#endif +} + +void tst_Compiler::cxx11_rvalue_refs() +{ +#ifndef Q_COMPILER_RVALUE_REFS + QSKIP("Compiler does not support C++11 feature"); +#else + int i = 1; + i = std::move(i); + + QString s = "Hello"; + QString t = std::move(s); + QCOMPARE(t, QString("Hello")); + + s = t; + t = std::move(s); + QCOMPARE(t, QString("Hello")); + + QString &&r = std::move(s); + QCOMPARE(r, QString("Hello")); +#endif +} + +void tst_Compiler::cxx11_static_assert() +{ +#ifndef Q_COMPILER_STATIC_ASSERT + QSKIP("Compiler does not support C++11 feature"); +#else + static_assert(true, "Message"); +#endif +} + +#ifdef Q_COMPILER_TEMPLATE_ALIAS +template <typename T> using Map = QMap<QString, T>; +#endif + +void tst_Compiler::cxx11_template_alias() +{ +#ifndef Q_COMPILER_TEMPLATE_ALIAS + QSKIP("Compiler does not support C++11 feature"); +#else + Map<QVariant> m; + m.insert("Hello", "World"); + QCOMPARE(m.value("Hello").toString(), QString("World")); + + using X = int; + X i = 0; + Q_UNUSED(i); +#endif +} + +#ifdef Q_COMPILER_THREAD_LOCAL +static thread_local int stl = 42; +thread_local int gtl = 42; +#endif + +void tst_Compiler::cxx11_thread_local() +{ +#ifndef Q_COMPILER_THREAD_LOCAL + QSKIP("Compiler does not support C++11 feature"); +#else + thread_local int v = 1; + QVERIFY(v); + QVERIFY(stl); + QVERIFY(gtl); + + thread_local QString s = "Hello"; + QVERIFY(!s.isEmpty()); +#endif +} + +#ifdef Q_COMPILER_UDL +QString operator"" _tstqstring(const char *str, size_t len) +{ + return QString::fromUtf8(str, len) + " UDL"; +} +#endif + +void tst_Compiler::cxx11_udl() +{ +#ifndef Q_COMPILER_UDL + QSKIP("Compiler does not support C++11 feature"); +#else + QString s = "Hello World"_tstqstring; + QCOMPARE(s, QString("Hello World UDL")); +#endif +} + +void tst_Compiler::cxx11_unicode_strings() +{ +#ifndef Q_COMPILER_UNICODE_STRINGS + QSKIP("Compiler does not support C++11 feature"); +#else + static const char16_t u[] = u"\u200BHello\u00A0World"; + QCOMPARE(u[0], char16_t(0x200B)); + + static const char32_t U[] = U"\ufffe"; + QCOMPARE(U[0], char32_t(0xfffe)); + + QCOMPARE(u"\U00010000"[0], char16_t(0xD800)); + QCOMPARE(u"\U00010000"[1], char16_t(0xDC00)); +#endif +} + +static void noop(QPair<int, int>) {} +void tst_Compiler::cxx11_uniform_init() +{ +#ifndef Q_COMPILER_UNIFORM_INIT + QSKIP("Compiler does not support C++11 feature"); + noop(QPair<int,int>()); +#else + QString s{"Hello"}; + int i{}; + noop(QPair<int,int>{1,1}); + noop({i,1}); +#endif +} + +void tst_Compiler::cxx11_unrestricted_unions() +{ +#ifndef Q_COMPILER_UNRESTRICTED_UNIONS + QSKIP("Compiler does not support C++11 feature"); +#else + union U { + QString s; + U() {} + U(const QString &s) : s(s) {} + ~U() {} + }; + U u; + std::aligned_storage<sizeof(QString), Q_ALIGNOF(QString)> as; + Q_UNUSED(u); + Q_UNUSED(as); + + U u2("hello"); + u2.s.~QString(); +#endif +} + +void tst_Compiler::cxx11_variadic_macros() +{ +#ifndef Q_COMPILER_VARIADIC_MACROS + QSKIP("Compiler does not support C++11 feature"); +#else +# define TEST_VARARG(x, ...) __VA_ARGS__ + QCOMPARE(TEST_VARARG(0, 1), 1); +#endif +} + +#ifdef Q_COMPILER_VARIADIC_TEMPLATES +template <typename... Args> struct VariadicTemplate {}; +#endif + +void tst_Compiler::cxx11_variadic_templates() +{ +#ifndef Q_COMPILER_VARIADIC_TEMPLATES + QSKIP("Compiler does not support C++11 feature"); +#else + VariadicTemplate<> v0; + VariadicTemplate<int> v1; + VariadicTemplate<int, int, int, int, + int, int, int, int> v8; + Q_UNUSED(v0); + Q_UNUSED(v1); + Q_UNUSED(v8); +#endif +} + +void tst_Compiler::cxx14_binary_literals() +{ +#if __cpp_binary_literals-0 < 201304 + QSKIP("Compiler does not support this C++14 feature"); +#else + int i = 0b11001001; + QCOMPARE(i, 0xC9); +#endif +} + +void tst_Compiler::cxx14_init_captures() +{ +#if __cpp_init_captures-0 < 201304 + QSKIP("Compiler does not support this C++14 feature"); +#else + QCOMPARE([x = 42]() { return x; }(), 42); +#endif +} + +void tst_Compiler::cxx14_generic_lambdas() +{ +#if __cpp_generic_lambdas-0 < 201304 + QSKIP("Compiler does not support this C++14 feature"); +#else + auto identity = [](auto x) { return x; }; + QCOMPARE(identity(42), 42); + QCOMPARE(identity(42U), 42U); + QCOMPARE(identity(42L), 42L); +#endif +} + +#if __cpp_constexpr-0 >= 201304 +constexpr int relaxedConstexpr(int i) +{ + i *= 2; + i += 2; + return i; +} +#endif + +void tst_Compiler::cxx14_constexpr() +{ +#if __cpp_constexpr-0 < 201304 + QSKIP("Compiler does not support this C++14 feature"); +#else + QCOMPARE(relaxedConstexpr(0), 2); + QCOMPARE(relaxedConstexpr(2), 6); +#endif +} + +void tst_Compiler::cxx14_decltype_auto() +{ +#if __cpp_decltype_auto-0 < 201304 + QSKIP("Compiler does not support this C++14 feature"); +#else + QList<int> l; + l << 1; + decltype(auto) value = l[0]; + value = 2; + QCOMPARE(l.at(0), 2); +#endif +} + +#if __cpp_return_type_deduction >= 201304 +auto returnTypeDeduction() +{ + return 1U; +} +#endif + +void tst_Compiler::cxx14_return_type_deduction() +{ +#if __cpp_return_type_deduction-0 < 201304 + QSKIP("Compiler does not support this C++14 feature"); +#else + QCOMPARE(returnTypeDeduction(), 1U); +#endif +} + +void tst_Compiler::cxx14_aggregate_nsdmi() +{ +#if __cpp_aggregate_nsdmi-0 < 201304 + QSKIP("Compiler does not support this C++14 feature"); +#else + struct S { int i, j = i; }; + S s = { 1 }; + QCOMPARE(s.j, 1); +#endif +} + +#if __cpp_variable_templates >= 201304 +template <typename T> constexpr T variableTemplate = T(42); +#endif +void tst_Compiler::cxx14_variable_templates() +{ +#if __cpp_variable_templates-0 < 201304 + QSKIP("Compiler does not support this C++14 feature"); +#else + QCOMPARE(variableTemplate<int>, 42); + QCOMPARE(variableTemplate<long>, 42L); + QCOMPARE(variableTemplate<unsigned>, 42U); + QCOMPARE(variableTemplate<unsigned long long>, 42ULL); +#endif +} + +void tst_Compiler::runtimeArrays() +{ +#if __cpp_runtime_arrays-0 < 201304 + QSKIP("Compiler does not support this C++14 feature"); +#else + int i[qrand() & 0x1f]; + Q_UNUSED(i); +#endif +} + QTEST_MAIN(tst_Compiler) #include "tst_compiler.moc" diff --git a/tests/auto/other/lancelot/scripts/text.qps b/tests/auto/other/lancelot/scripts/text.qps index e7d47448ea..b3d8475411 100644 --- a/tests/auto/other/lancelot/scripts/text.qps +++ b/tests/auto/other/lancelot/scripts/text.qps @@ -11,7 +11,7 @@ save setFont "sansserif" 12 normal drawText 0 40 "sansserif 12pt, normal" - setFont "sansserif" 10 bold + setFont "sansserif" 12 bold drawText 0 60 "sansserif 12pt, bold" setFont "sansserif" 10 bold italic @@ -27,7 +27,7 @@ save setFont "sansserif" 12 normal drawText 0 40 "alpha sansserif 12pt, normal" - setFont "sansserif" 10 bold + setFont "sansserif" 12 bold drawText 0 60 "alpha sansserif 12pt, bold" setFont "sansserif" 10 bold italic @@ -45,7 +45,7 @@ save setFont "sansserif" 12 normal drawText 0 40 "scaled sansserif 12pt, normal" - setFont "sansserif" 10 bold + setFont "sansserif" 12 bold drawText 0 60 "scaled sansserif 12pt, bold" setFont "sansserif" 10 bold italic @@ -63,7 +63,7 @@ save setFont "sansserif" 12 normal drawStaticText 0 40 "flipped sansserif 12pt, normal" - setFont "sansserif" 10 bold + setFont "sansserif" 12 bold drawStaticText 0 60 "flipped sansserif 12pt, bold" setFont "sansserif" 10 bold italic @@ -82,7 +82,7 @@ save setFont "sansserif" 12 normal drawText 0 40 "scaled sansserif 12pt, normal" - setFont "sansserif" 10 bold + setFont "sansserif" 12 bold drawText 0 60 "scaled sansserif 12pt, bold" setFont "sansserif" 10 bold italic @@ -102,7 +102,7 @@ save setFont "sansserif" 12 normal drawText 0 20 "gradient sansserif 12pt, normal" - setFont "sansserif" 10 bold + setFont "sansserif" 12 bold drawText 0 40 "gradient sansserif 12pt, bold" setFont "sansserif" 10 bold italic diff --git a/tests/auto/other/other.pro b/tests/auto/other/other.pro index 407237e519..745c8f2499 100644 --- a/tests/auto/other/other.pro +++ b/tests/auto/other/other.pro @@ -2,7 +2,6 @@ TEMPLATE=subdirs SUBDIRS=\ # atwrapper \ # QTBUG-19452 baselineexample \ - collections \ compiler \ d3dcompiler \ gestures \ diff --git a/tests/auto/other/qaccessibility/tst_qaccessibility.cpp b/tests/auto/other/qaccessibility/tst_qaccessibility.cpp index 8b033efa4a..23b48212ad 100644 --- a/tests/auto/other/qaccessibility/tst_qaccessibility.cpp +++ b/tests/auto/other/qaccessibility/tst_qaccessibility.cpp @@ -243,6 +243,7 @@ private slots: void statesStructTest(); void navigateHierarchy(); void sliderTest(); + void textAttributes_data(); void textAttributes(); void hideShowTest(); @@ -698,58 +699,118 @@ void tst_QAccessibility::accessibleName() QTestAccessibility::clearEvents(); } -void tst_QAccessibility::textAttributes() +// note: color should probably always be part of the attributes +void tst_QAccessibility::textAttributes_data() { - QTextEdit textEdit; - int startOffset; - int endOffset; - QString attributes; - QString text("<html><head></head><body>" + QTest::addColumn<QString>("text"); + QTest::addColumn<int>("offset"); + QTest::addColumn<int>("startOffsetResult"); + QTest::addColumn<int>("endOffsetResult"); + QTest::addColumn<QStringList>("attributeResult"); + + static QStringList defaults = QString("font-style:normal;font-weight:normal;text-align:left;text-position:baseline;text-underline-style:none").split(';'); + static QStringList bold = defaults; + bold[1] = QString::fromLatin1("font-weight:bold"); + + static QStringList italic = defaults; + italic[0] = QString::fromLatin1("font-style:italic"); + + static QStringList boldItalic = defaults; + boldItalic[0] = QString::fromLatin1("font-style:italic"); + boldItalic[1] = QString::fromLatin1("font-weight:bold"); + + static QStringList monospace = defaults; + monospace.append(QLatin1String("font-family:\"monospace\"")); + + static QStringList font8pt = defaults; + font8pt.append(QLatin1String("font-size:8pt")); + + static QStringList color = defaults; + color << QLatin1String("color:rgb(240,241,242)") << QLatin1String("background-color:rgb(20,240,30)"); + + static QStringList rightAlign = defaults; + rightAlign[2] = QStringLiteral("text-align:right"); + + QTest::newRow("defaults 1") << "hello" << 0 << 0 << 5 << defaults; + QTest::newRow("defaults 2") << "hello" << 1 << 0 << 5 << defaults; + QTest::newRow("defaults 3") << "hello" << 4 << 0 << 5 << defaults; + QTest::newRow("defaults 4") << "hello" << 5 << 0 << 5 << defaults; + QTest::newRow("offset -1 length") << "hello" << -1 << 0 << 5 << defaults; + QTest::newRow("offset -2 cursor pos") << "hello" << -2 << 0 << 5 << defaults; + QTest::newRow("offset -3") << "hello" << -3 << -1 << -1 << QStringList(); + QTest::newRow("invalid offset 2") << "hello" << 6 << -1 << -1 << QStringList(); + QTest::newRow("invalid offset 3") << "" << 1 << -1 << -1 << QStringList(); + + QString boldText = QLatin1String("<html><b>bold</b>text"); + QTest::newRow("bold 0") << boldText << 0 << 0 << 4 << bold; + QTest::newRow("bold 2") << boldText << 2 << 0 << 4 << bold; + QTest::newRow("bold 3") << boldText << 3 << 0 << 4 << bold; + QTest::newRow("bold 4") << boldText << 4 << 4 << 8 << defaults; + QTest::newRow("bold 6") << boldText << 6 << 4 << 8 << defaults; + + QString longText = QLatin1String("<html>" "Hello, <b>this</b> is an <i><b>example</b> text</i>." "<span style=\"font-family: monospace\">Multiple fonts are used.</span>" "Multiple <span style=\"font-size: 8pt\">text sizes</span> are used." - "Let's give some color to <span style=\"color:#f0f1f2; background-color:#14f01e\">Qt</span>." - "</body></html>"); + "Let's give some color to <span style=\"color:#f0f1f2; background-color:#14f01e\">Qt</span>."); + + QTest::newRow("default 5") << longText << 6 << 0 << 7 << defaults; + QTest::newRow("default 6") << longText << 7 << 7 << 11 << bold; + QTest::newRow("bold 7") << longText << 10 << 7 << 11 << bold; + QTest::newRow("bold 8") << longText << 10 << 7 << 11 << bold; + QTest::newRow("bold italic") << longText << 18 << 18 << 25 << boldItalic; + QTest::newRow("monospace") << longText << 34 << 31 << 55 << monospace; + QTest::newRow("8pt") << longText << 65 << 64 << 74 << font8pt; + QTest::newRow("color") << longText << 110 << 109 << 111 << color; + + QString rightAligned = QLatin1String("<html><p align=\"right\">right</p>"); + QTest::newRow("right aligned 1") << rightAligned << 0 << 0 << 5 << rightAlign; + QTest::newRow("right aligned 2") << rightAligned << 1 << 0 << 5 << rightAlign; + QTest::newRow("right aligned 3") << rightAligned << 5 << 0 << 5 << rightAlign; + + // left \n right \n left, make sure bold and alignment borders coincide + QString leftRightLeftAligned = QLatin1String("<html><p><b>left</b></p><p align=\"right\">right</p><p><b>left</b></p>"); + QTest::newRow("left right left aligned 1") << leftRightLeftAligned << 1 << 0 << 4 << bold; + QTest::newRow("left right left aligned 3") << leftRightLeftAligned << 3 << 0 << 4 << bold; + QTest::newRow("left right left aligned 4") << leftRightLeftAligned << 4 << 4 << 5 << defaults; + QTest::newRow("left right left aligned 5") << leftRightLeftAligned << 5 << 5 << 10 << rightAlign; + QTest::newRow("left right left aligned 8") << leftRightLeftAligned << 8 << 5 << 10 << rightAlign; + QTest::newRow("left right left aligned 9") << leftRightLeftAligned << 9 << 5 << 10 << rightAlign; + QTest::newRow("left right left aligned 10") << leftRightLeftAligned << 10 << 10 << 11 << rightAlign; + QTest::newRow("left right left aligned 11") << leftRightLeftAligned << 11 << 11 << 15 << bold; + QTest::newRow("left right left aligned 15") << leftRightLeftAligned << 15 << 11 << 15 << bold; +} +void tst_QAccessibility::textAttributes() +{ + { + QFETCH(QString, text); + QFETCH(int, offset); + QFETCH(int, startOffsetResult); + QFETCH(int, endOffsetResult); + QFETCH(QStringList, attributeResult); + + QTextEdit textEdit; textEdit.setText(text); + if (textEdit.document()->characterCount() > 1) + textEdit.textCursor().setPosition(1); QAccessibleInterface *interface = QAccessible::queryAccessibleInterface(&textEdit); - QAccessibleTextInterface *textInterface=interface->textInterface(); - QVERIFY(textInterface); - QCOMPARE(textInterface->characterCount(), 112); + QCOMPARE(textInterface->characterCount(), textEdit.toPlainText().length()); - attributes = textInterface->attributes(10, &startOffset, &endOffset); - QCOMPARE(startOffset, 7); - QCOMPARE(endOffset, 11); - attributes.prepend(';'); - QVERIFY(attributes.contains(QLatin1String(";font-weight:bold;"))); - - attributes = textInterface->attributes(18, &startOffset, &endOffset); - QCOMPARE(startOffset, 18); - QCOMPARE(endOffset, 25); - attributes.prepend(';'); - QVERIFY(attributes.contains(QLatin1String(";font-weight:bold;"))); - QVERIFY(attributes.contains(QLatin1String(";font-style:italic;"))); - - attributes = textInterface->attributes(34, &startOffset, &endOffset); - QCOMPARE(startOffset, 31); - QCOMPARE(endOffset, 55); - attributes.prepend(';'); - QVERIFY(attributes.contains(QLatin1String(";font-family:\"monospace\";"))); - - attributes = textInterface->attributes(65, &startOffset, &endOffset); - QCOMPARE(startOffset, 64); - QCOMPARE(endOffset, 74); - attributes.prepend(';'); - QVERIFY(attributes.contains(QLatin1String(";font-size:8pt;"))); - - attributes = textInterface->attributes(110, &startOffset, &endOffset); - QCOMPARE(startOffset, 109); - QCOMPARE(endOffset, 111); - attributes.prepend(';'); - QVERIFY(attributes.contains(QLatin1String(";background-color:rgb(20,240,30);"))); - QVERIFY(attributes.contains(QLatin1String(";color:rgb(240,241,242);"))); + int startOffset = -1; + int endOffset = -1; + QString attributes = textInterface->attributes(offset, &startOffset, &endOffset); + + QCOMPARE(startOffset, startOffsetResult); + QCOMPARE(endOffset, endOffsetResult); + QStringList attrList = attributes.split(QChar(';'), QString::SkipEmptyParts); + attributeResult.sort(); + attrList.sort(); + QCOMPARE(attrList, attributeResult); + } + QTestAccessibility::clearEvents(); } void tst_QAccessibility::hideShowTest() @@ -1191,8 +1252,11 @@ void tst_QAccessibility::tabTest() QVERIFY(leftButton->state().invisible); const int lots = 5; - for (int i = 0; i < lots; ++i) + for (int i = 0; i < lots; ++i) { tabBar->addTab("Foo"); + tabBar->setTabToolTip(i, QLatin1String("Cool tool tip")); + tabBar->setTabWhatsThis(i, QLatin1String("I don't know")); + } QAccessibleInterface *child1 = interface->child(0); QAccessibleInterface *child2 = interface->child(1); @@ -1201,6 +1265,10 @@ void tst_QAccessibility::tabTest() QVERIFY(child2); QCOMPARE(child2->role(), QAccessible::PageTab); + QCOMPARE(child1->text(QAccessible::Name), QLatin1String("Foo")); + QCOMPARE(child1->text(QAccessible::Description), QLatin1String("Cool tool tip")); + QCOMPARE(child1->text(QAccessible::Help), QLatin1String("I don't know")); + QVERIFY((child1->state().invisible) == false); tabBar->hide(); @@ -1652,6 +1720,11 @@ void tst_QAccessibility::textEditTest() QTest::qWaitForWindowShown(&edit); QAccessibleInterface *iface = QAccessible::queryAccessibleInterface(&edit); QCOMPARE(iface->text(QAccessible::Value), edit.toPlainText()); + QVERIFY(iface->state().focusable); + QVERIFY(!iface->state().selectable); + QVERIFY(!iface->state().selected); + QVERIFY(iface->state().selectableText); + QAccessibleTextInterface *textIface = iface->textInterface(); QVERIFY(textIface); @@ -1751,8 +1824,6 @@ void tst_QAccessibility::textEditTest() QAccessibleTextRemoveEvent remove(&edit, 0, " "); QVERIFY_EVENT(&remove); - // FIXME the new text is not there yet - QEXPECT_FAIL("", "Inserting should always contain the new text", Continue); QAccessibleTextInsertEvent insert(&edit, 0, "Accessibility rocks"); QVERIFY_EVENT(&insert); } @@ -1929,7 +2000,8 @@ void tst_QAccessibility::lineEditTest() QVERIFY(iface->state().sizeable); QVERIFY(iface->state().movable); QVERIFY(iface->state().focusable); - QVERIFY(iface->state().selectable); + QVERIFY(!iface->state().selectable); + QVERIFY(iface->state().selectableText); QVERIFY(!iface->state().hasPopup); QCOMPARE(bool(iface->state().focused), le->hasFocus()); @@ -1957,7 +2029,9 @@ void tst_QAccessibility::lineEditTest() QVERIFY(!(iface->state().sizeable)); QVERIFY(!(iface->state().movable)); QVERIFY(iface->state().focusable); - QVERIFY(iface->state().selectable); + QVERIFY(!iface->state().selectable); + QVERIFY(!iface->state().selected); + QVERIFY(iface->state().selectableText); QVERIFY(!iface->state().hasPopup); QCOMPARE(bool(iface->state().focused), le->hasFocus()); diff --git a/tests/auto/other/qaccessibilitylinux/tst_qaccessibilitylinux.cpp b/tests/auto/other/qaccessibilitylinux/tst_qaccessibilitylinux.cpp index 50bf342365..a8313215be 100644 --- a/tests/auto/other/qaccessibilitylinux/tst_qaccessibilitylinux.cpp +++ b/tests/auto/other/qaccessibilitylinux/tst_qaccessibilitylinux.cpp @@ -421,14 +421,22 @@ void tst_QAccessibilityLinux::testTextEdit() QCOMPARE(callResult.at(2).toInt(), 17); // Check if at least CharacterExtents and RangeExtents give a consistent result - QDBusReply<QRect> replyRect20 = textInterface->call(QDBus::Block, "GetCharacterExtents", 20, ATSPI_COORD_TYPE_SCREEN); - QVERIFY(replyRect20.isValid()); - QRect r1 = replyRect20.value(); - QDBusReply<QRect> replyRect21 = textInterface->call(QDBus::Block, "GetCharacterExtents", 21, ATSPI_COORD_TYPE_SCREEN); - QRect r2 = replyRect21.value(); - QDBusReply<QRect> reply = textInterface->call(QDBus::Block, "GetRangeExtents", 20, 21, ATSPI_COORD_TYPE_SCREEN); - QRect rect = reply.value(); - QCOMPARE(rect, r1|r2); + + QDBusMessage replyRect20 = textInterface->call(QDBus::Block, "GetCharacterExtents", 20, ATSPI_COORD_TYPE_SCREEN); + QCOMPARE(replyRect20.type(), QDBusMessage::ReplyMessage); + QCOMPARE(replyRect20.signature(), QStringLiteral("iiii")); + callResult = replyRect20.arguments(); + QRect r1 = QRect(callResult.at(0).toInt(), callResult.at(1).toInt(), callResult.at(2).toInt(), callResult.at(3).toInt()); + QDBusMessage replyRect21 = textInterface->call(QDBus::Block, "GetCharacterExtents", 21, ATSPI_COORD_TYPE_SCREEN); + QCOMPARE(replyRect21.type(), QDBusMessage::ReplyMessage); + QCOMPARE(replyRect21.signature(), QStringLiteral("iiii")); + callResult = replyRect21.arguments(); + QRect r2 = QRect(callResult.at(0).toInt(), callResult.at(1).toInt(), callResult.at(2).toInt(), callResult.at(3).toInt()); + + QDBusMessage replyRange = textInterface->call(QDBus::Block, "GetRangeExtents", 20, 21, ATSPI_COORD_TYPE_SCREEN); + callResult = replyRange.arguments(); + QRect rectRangeExtents = QRect(callResult.at(0).toInt(), callResult.at(1).toInt(), callResult.at(2).toInt(), callResult.at(3).toInt()); + QCOMPARE(rectRangeExtents, r1|r2); m_window->clearChildren(); delete textInterface; diff --git a/tests/auto/testlib/qsignalspy/tst_qsignalspy.cpp b/tests/auto/testlib/qsignalspy/tst_qsignalspy.cpp index 47d6789327..40e1070fcc 100644 --- a/tests/auto/testlib/qsignalspy/tst_qsignalspy.cpp +++ b/tests/auto/testlib/qsignalspy/tst_qsignalspy.cpp @@ -65,6 +65,19 @@ private slots: void wait_signalEmittedLater(); void wait_signalEmittedTooLate(); void wait_signalEmittedMultipleTimes(); + + void spyFunctionPointerWithoutArgs(); + void spyFunctionPointerWithBasicArgs(); + void spyFunctionPointerWithPointers(); + void spyFunctionPointerWithQtClasses(); + void spyFunctionPointerWithBasicQtClasses(); + void spyFunctionPointerWithQtTypedefs(); + + void waitFunctionPointer_signalEmitted(); + void waitFunctionPointer_timeout(); + void waitFunctionPointer_signalEmittedLater(); + void waitFunctionPointer_signalEmittedTooLate(); + void waitFunctionPointer_signalEmittedMultipleTimes(); }; class QtTestObject: public QObject @@ -278,5 +291,160 @@ void tst_QSignalSpy::wait_signalEmittedMultipleTimes() QCOMPARE(spy.count(), 3); } +void tst_QSignalSpy::spyFunctionPointerWithoutArgs() +{ + QtTestObject obj; + + QSignalSpy spy(&obj, &QtTestObject::sig0); + QCOMPARE(spy.count(), 0); + + emit obj.sig0(); + QCOMPARE(spy.count(), 1); + emit obj.sig0(); + QCOMPARE(spy.count(), 2); + + QList<QVariant> args = spy.takeFirst(); + QCOMPARE(args.count(), 0); +} + +void tst_QSignalSpy::spyFunctionPointerWithBasicArgs() +{ + QtTestObject obj; + QSignalSpy spy(&obj, &QtTestObject::sig1); + + emit obj.sig1(1, 2); + QCOMPARE(spy.count(), 1); + + QList<QVariant> args = spy.takeFirst(); + QCOMPARE(args.count(), 2); + QCOMPARE(args.at(0).toInt(), 1); + QCOMPARE(args.at(1).toInt(), 2); + + QSignalSpy spyl(&obj, &QtTestObject::sigLong); + + emit obj.sigLong(1l, 2l); + args = spyl.takeFirst(); + QCOMPARE(args.count(), 2); + QCOMPARE(qvariant_cast<long>(args.at(0)), 1l); + QCOMPARE(qvariant_cast<long>(args.at(1)), 2l); +} + + +void tst_QSignalSpy::spyFunctionPointerWithPointers() +{ + qRegisterMetaType<int *>("int*"); + + QtTestObject obj; + QSignalSpy spy(&obj, &QtTestObject::sig2); + + int i1 = 1; + int i2 = 2; + + emit obj.sig2(&i1, &i2); + QCOMPARE(spy.count(), 1); + + QList<QVariant> args = spy.takeFirst(); + QCOMPARE(args.count(), 2); + QCOMPARE(*static_cast<int * const *>(args.at(0).constData()), &i1); + QCOMPARE(*static_cast<int * const *>(args.at(1).constData()), &i2); +} + +void tst_QSignalSpy::spyFunctionPointerWithBasicQtClasses() +{ + QtTestObject2 obj; + + QSignalSpy spy(&obj, &QtTestObject2::sig); + emit obj.sig(QString("bubu")); + QCOMPARE(spy.count(), 1); + QCOMPARE(spy.at(0).count(), 1); + QCOMPARE(spy.at(0).at(0).toString(), QString("bubu")); + + QSignalSpy spy2(&obj, &QtTestObject2::sig5); + QVariant val(45); + emit obj.sig5(val); + QCOMPARE(spy2.count(), 1); + QCOMPARE(spy2.at(0).count(), 1); + QCOMPARE(spy2.at(0).at(0), val); + QCOMPARE(qvariant_cast<QVariant>(spy2.at(0).at(0)), val); +} + +void tst_QSignalSpy::spyFunctionPointerWithQtClasses() +{ + QtTestObject2 obj; + + QSignalSpy spy(&obj, &QtTestObject2::sig2); + QDateTime dt = QDateTime::currentDateTime(); + emit obj.sig2(dt); + QCOMPARE(spy.count(), 1); + QCOMPARE(spy.at(0).count(), 1); + QCOMPARE(spy.at(0).at(0).typeName(), "QDateTime"); + QCOMPARE(*static_cast<const QDateTime *>(spy.at(0).at(0).constData()), dt); + QCOMPARE(spy.at(0).at(0).toDateTime(), dt); + + QSignalSpy spy2(&obj, &QtTestObject2::sig3); + emit obj.sig3(this); + QCOMPARE(*static_cast<QObject * const *>(spy2.value(0).value(0).constData()), + (QObject *)this); + QCOMPARE(qvariant_cast<QObject *>(spy2.value(0).value(0)), (QObject*)this); + + QSignalSpy spy3(&obj, &QtTestObject2::sig4); + emit obj.sig4(QChar('A')); + QCOMPARE(qvariant_cast<QChar>(spy3.value(0).value(0)), QChar('A')); +} + +void tst_QSignalSpy::spyFunctionPointerWithQtTypedefs() +{ + QtTestObject3 obj; + + QSignalSpy spy2(&obj, &QtTestObject3::sig2); + emit obj.sig2(42, 43); + QCOMPARE(spy2.value(0).value(0).toInt(), 42); + QCOMPARE(spy2.value(0).value(1).toInt(), 43); +} + +void tst_QSignalSpy::waitFunctionPointer_signalEmitted() +{ + QTimer::singleShot(0, this, SIGNAL(sigFoo())); + QSignalSpy spy(this, &tst_QSignalSpy::sigFoo); + QVERIFY(spy.wait(1)); +} + +void tst_QSignalSpy::waitFunctionPointer_timeout() +{ + QSignalSpy spy(this, &tst_QSignalSpy::sigFoo); + QVERIFY(!spy.wait(1)); +} + +void tst_QSignalSpy::waitFunctionPointer_signalEmittedLater() +{ + QTimer::singleShot(500, this, SIGNAL(sigFoo())); + QSignalSpy spy(this, &tst_QSignalSpy::sigFoo); + QVERIFY(spy.wait(1000)); +} + +void tst_QSignalSpy::waitFunctionPointer_signalEmittedTooLate() +{ + QTimer::singleShot(500, this, SIGNAL(sigFoo())); + QSignalSpy spy(this, &tst_QSignalSpy::sigFoo); + QVERIFY(!spy.wait(200)); + QTest::qWait(400); + QCOMPARE(spy.count(), 1); +} + +void tst_QSignalSpy::waitFunctionPointer_signalEmittedMultipleTimes() +{ + QTimer::singleShot(100, this, SIGNAL(sigFoo())); + QTimer::singleShot(800, this, SIGNAL(sigFoo())); + QSignalSpy spy(this, &tst_QSignalSpy::sigFoo); + QVERIFY(spy.wait()); + QCOMPARE(spy.count(), 1); // we don't wait for the second signal... + QVERIFY(spy.wait()); + QCOMPARE(spy.count(), 2); + QVERIFY(!spy.wait(1)); + QTimer::singleShot(10, this, SIGNAL(sigFoo())); + QVERIFY(spy.wait()); + QCOMPARE(spy.count(), 3); +} + QTEST_MAIN(tst_QSignalSpy) #include "tst_qsignalspy.moc" diff --git a/tests/auto/testlib/selftests/expected_assert.lightxml b/tests/auto/testlib/selftests/expected_assert.lightxml index d2d4ae5153..b40ff41da3 100644 --- a/tests/auto/testlib/selftests/expected_assert.lightxml +++ b/tests/auto/testlib/selftests/expected_assert.lightxml @@ -1,5 +1,6 @@ <Environment> <QtVersion>@INSERT_QT_VERSION_HERE@</QtVersion> + <QtBuild/> <QTestVersion>@INSERT_QT_VERSION_HERE@</QTestVersion> </Environment> <TestFunction name="initTestCase"> diff --git a/tests/auto/testlib/selftests/expected_assert.xml b/tests/auto/testlib/selftests/expected_assert.xml index 9e5ea760ae..9770b3cd57 100644 --- a/tests/auto/testlib/selftests/expected_assert.xml +++ b/tests/auto/testlib/selftests/expected_assert.xml @@ -2,6 +2,7 @@ <TestCase name="tst_Assert"> <Environment> <QtVersion>@INSERT_QT_VERSION_HERE@</QtVersion> + <QtBuild/> <QTestVersion>@INSERT_QT_VERSION_HERE@</QTestVersion> </Environment> <TestFunction name="initTestCase"> diff --git a/tests/auto/testlib/selftests/expected_assert.xunitxml b/tests/auto/testlib/selftests/expected_assert.xunitxml index 0aebe72745..96daa33dcf 100644 --- a/tests/auto/testlib/selftests/expected_assert.xunitxml +++ b/tests/auto/testlib/selftests/expected_assert.xunitxml @@ -3,6 +3,7 @@ <properties> <property value="@INSERT_QT_VERSION_HERE@" name="QTestVersion"/> <property value="@INSERT_QT_VERSION_HERE@" name="QtVersion"/> + <property value="" name="QtBuild"/> </properties> <testcase result="pass" name="initTestCase"/> <testcase result="pass" name="testNumber1"/> diff --git a/tests/auto/testlib/selftests/expected_badxml.lightxml b/tests/auto/testlib/selftests/expected_badxml.lightxml index e4c79e3bb0..94f479a79a 100644 --- a/tests/auto/testlib/selftests/expected_badxml.lightxml +++ b/tests/auto/testlib/selftests/expected_badxml.lightxml @@ -1,5 +1,6 @@ <Environment> <QtVersion>@INSERT_QT_VERSION_HERE@</QtVersion> + <QtBuild/> <QTestVersion>@INSERT_QT_VERSION_HERE@</QTestVersion> </Environment> <TestFunction name="initTestCase"> diff --git a/tests/auto/testlib/selftests/expected_badxml.xml b/tests/auto/testlib/selftests/expected_badxml.xml index 0811db0f3a..c1266bfeed 100644 --- a/tests/auto/testlib/selftests/expected_badxml.xml +++ b/tests/auto/testlib/selftests/expected_badxml.xml @@ -2,6 +2,7 @@ <TestCase name="tst_BadXml"> <Environment> <QtVersion>@INSERT_QT_VERSION_HERE@</QtVersion> + <QtBuild/> <QTestVersion>@INSERT_QT_VERSION_HERE@</QTestVersion> </Environment> <TestFunction name="initTestCase"> diff --git a/tests/auto/testlib/selftests/expected_badxml.xunitxml b/tests/auto/testlib/selftests/expected_badxml.xunitxml index a696da58c9..49048fdad6 100644 --- a/tests/auto/testlib/selftests/expected_badxml.xunitxml +++ b/tests/auto/testlib/selftests/expected_badxml.xunitxml @@ -3,6 +3,7 @@ <properties> <property value="@INSERT_QT_VERSION_HERE@" name="QTestVersion"/> <property value="@INSERT_QT_VERSION_HERE@" name="QtVersion"/> + <property value="" name="QtBuild"/> </properties> <testcase result="pass" name="initTestCase"/> <testcase result="fail" name="badDataTag"> diff --git a/tests/auto/testlib/selftests/expected_benchlibcounting.lightxml b/tests/auto/testlib/selftests/expected_benchlibcounting.lightxml index 08872be733..6fe511462c 100644 --- a/tests/auto/testlib/selftests/expected_benchlibcounting.lightxml +++ b/tests/auto/testlib/selftests/expected_benchlibcounting.lightxml @@ -1,5 +1,6 @@ <Environment> <QtVersion>@INSERT_QT_VERSION_HERE@</QtVersion> + <QtBuild/> <QTestVersion>@INSERT_QT_VERSION_HERE@</QTestVersion> </Environment> <TestFunction name="initTestCase"> diff --git a/tests/auto/testlib/selftests/expected_benchlibcounting.xml b/tests/auto/testlib/selftests/expected_benchlibcounting.xml index ee6fd98ef2..d945511eec 100644 --- a/tests/auto/testlib/selftests/expected_benchlibcounting.xml +++ b/tests/auto/testlib/selftests/expected_benchlibcounting.xml @@ -2,6 +2,7 @@ <TestCase name="tst_BenchlibCounting"> <Environment> <QtVersion>@INSERT_QT_VERSION_HERE@</QtVersion> + <QtBuild/> <QTestVersion>@INSERT_QT_VERSION_HERE@</QTestVersion> </Environment> <TestFunction name="initTestCase"> diff --git a/tests/auto/testlib/selftests/expected_benchlibcounting.xunitxml b/tests/auto/testlib/selftests/expected_benchlibcounting.xunitxml index 83e429aa3a..05d1da9874 100644 --- a/tests/auto/testlib/selftests/expected_benchlibcounting.xunitxml +++ b/tests/auto/testlib/selftests/expected_benchlibcounting.xunitxml @@ -3,6 +3,7 @@ <properties> <property value="@INSERT_QT_VERSION_HERE@" name="QTestVersion"/> <property value="@INSERT_QT_VERSION_HERE@" name="QtVersion"/> + <property value="" name="QtBuild"/> </properties> <testcase result="pass" name="initTestCase"/> <testcase result="pass" name="passingBenchmark"> diff --git a/tests/auto/testlib/selftests/expected_benchlibeventcounter.lightxml b/tests/auto/testlib/selftests/expected_benchlibeventcounter.lightxml index cba91a374f..0bc00569e9 100644 --- a/tests/auto/testlib/selftests/expected_benchlibeventcounter.lightxml +++ b/tests/auto/testlib/selftests/expected_benchlibeventcounter.lightxml @@ -1,5 +1,6 @@ <Environment> <QtVersion>@INSERT_QT_VERSION_HERE@</QtVersion> + <QtBuild/> <QTestVersion>@INSERT_QT_VERSION_HERE@</QTestVersion> </Environment> <TestFunction name="initTestCase"> diff --git a/tests/auto/testlib/selftests/expected_benchlibeventcounter.xml b/tests/auto/testlib/selftests/expected_benchlibeventcounter.xml index 7d28975ead..f543e2775c 100644 --- a/tests/auto/testlib/selftests/expected_benchlibeventcounter.xml +++ b/tests/auto/testlib/selftests/expected_benchlibeventcounter.xml @@ -2,6 +2,7 @@ <TestCase name="tst_BenchlibEventCounter"> <Environment> <QtVersion>@INSERT_QT_VERSION_HERE@</QtVersion> + <QtBuild/> <QTestVersion>@INSERT_QT_VERSION_HERE@</QTestVersion> </Environment> <TestFunction name="initTestCase"> diff --git a/tests/auto/testlib/selftests/expected_benchlibeventcounter.xunitxml b/tests/auto/testlib/selftests/expected_benchlibeventcounter.xunitxml index 60dca28d4f..ce0a81110d 100644 --- a/tests/auto/testlib/selftests/expected_benchlibeventcounter.xunitxml +++ b/tests/auto/testlib/selftests/expected_benchlibeventcounter.xunitxml @@ -3,6 +3,7 @@ <properties> <property value="@INSERT_QT_VERSION_HERE@" name="QTestVersion"/> <property value="@INSERT_QT_VERSION_HERE@" name="QtVersion"/> + <property value="" name="QtBuild"/> </properties> <testcase result="pass" name="initTestCase"/> <testcase result="pass" name="events"> diff --git a/tests/auto/testlib/selftests/expected_benchlibtickcounter.lightxml b/tests/auto/testlib/selftests/expected_benchlibtickcounter.lightxml index 97422240d9..11296ad9c2 100644 --- a/tests/auto/testlib/selftests/expected_benchlibtickcounter.lightxml +++ b/tests/auto/testlib/selftests/expected_benchlibtickcounter.lightxml @@ -1,5 +1,6 @@ <Environment> <QtVersion>@INSERT_QT_VERSION_HERE@</QtVersion> + <QtBuild/> <QTestVersion>@INSERT_QT_VERSION_HERE@</QTestVersion> </Environment> <TestFunction name="initTestCase"> diff --git a/tests/auto/testlib/selftests/expected_benchlibtickcounter.xml b/tests/auto/testlib/selftests/expected_benchlibtickcounter.xml index 24c2e51084..3dd56b4af7 100644 --- a/tests/auto/testlib/selftests/expected_benchlibtickcounter.xml +++ b/tests/auto/testlib/selftests/expected_benchlibtickcounter.xml @@ -2,6 +2,7 @@ <TestCase name="tst_BenchlibTickCounter"> <Environment> <QtVersion>@INSERT_QT_VERSION_HERE@</QtVersion> + <QtBuild/> <QTestVersion>@INSERT_QT_VERSION_HERE@</QTestVersion> </Environment> <TestFunction name="initTestCase"> diff --git a/tests/auto/testlib/selftests/expected_benchlibtickcounter.xunitxml b/tests/auto/testlib/selftests/expected_benchlibtickcounter.xunitxml index 28c8f11143..779d3bdcbc 100644 --- a/tests/auto/testlib/selftests/expected_benchlibtickcounter.xunitxml +++ b/tests/auto/testlib/selftests/expected_benchlibtickcounter.xunitxml @@ -3,6 +3,7 @@ <properties> <property value="@INSERT_QT_VERSION_HERE@" name="QTestVersion"/> <property value="@INSERT_QT_VERSION_HERE@" name="QtVersion"/> + <property value="" name="QtBuild"/> </properties> <testcase result="pass" name="initTestCase"/> <testcase result="pass" name="threeBillionTicks"> diff --git a/tests/auto/testlib/selftests/expected_benchlibwalltime.lightxml b/tests/auto/testlib/selftests/expected_benchlibwalltime.lightxml index b2e819b26d..c75a6c944d 100644 --- a/tests/auto/testlib/selftests/expected_benchlibwalltime.lightxml +++ b/tests/auto/testlib/selftests/expected_benchlibwalltime.lightxml @@ -1,5 +1,6 @@ <Environment> <QtVersion>@INSERT_QT_VERSION_HERE@</QtVersion> + <QtBuild/> <QTestVersion>@INSERT_QT_VERSION_HERE@</QTestVersion> </Environment> <TestFunction name="initTestCase"> diff --git a/tests/auto/testlib/selftests/expected_benchlibwalltime.xml b/tests/auto/testlib/selftests/expected_benchlibwalltime.xml index 6ae355783a..a2f0edecc6 100644 --- a/tests/auto/testlib/selftests/expected_benchlibwalltime.xml +++ b/tests/auto/testlib/selftests/expected_benchlibwalltime.xml @@ -2,6 +2,7 @@ <TestCase name="tst_BenchlibWalltime"> <Environment> <QtVersion>@INSERT_QT_VERSION_HERE@</QtVersion> + <QtBuild/> <QTestVersion>@INSERT_QT_VERSION_HERE@</QTestVersion> </Environment> <TestFunction name="initTestCase"> diff --git a/tests/auto/testlib/selftests/expected_benchlibwalltime.xunitxml b/tests/auto/testlib/selftests/expected_benchlibwalltime.xunitxml index e4ffca4d09..6a0510c4c9 100644 --- a/tests/auto/testlib/selftests/expected_benchlibwalltime.xunitxml +++ b/tests/auto/testlib/selftests/expected_benchlibwalltime.xunitxml @@ -3,6 +3,7 @@ <properties> <property value="@INSERT_QT_VERSION_HERE@" name="QTestVersion"/> <property value="@INSERT_QT_VERSION_HERE@" name="QtVersion"/> + <property value="" name="QtBuild"/> </properties> <testcase result="pass" name="initTestCase"/> <testcase result="pass" name="waitForOneThousand"> diff --git a/tests/auto/testlib/selftests/expected_cmptest.lightxml b/tests/auto/testlib/selftests/expected_cmptest.lightxml index 3a776ea7cb..4a376b5c8b 100644 --- a/tests/auto/testlib/selftests/expected_cmptest.lightxml +++ b/tests/auto/testlib/selftests/expected_cmptest.lightxml @@ -1,5 +1,6 @@ <Environment> <QtVersion>@INSERT_QT_VERSION_HERE@</QtVersion> + <QtBuild/> <QTestVersion>@INSERT_QT_VERSION_HERE@</QTestVersion> </Environment> <TestFunction name="initTestCase"> diff --git a/tests/auto/testlib/selftests/expected_cmptest.xml b/tests/auto/testlib/selftests/expected_cmptest.xml index 970544e4b6..aefb1b5f4c 100644 --- a/tests/auto/testlib/selftests/expected_cmptest.xml +++ b/tests/auto/testlib/selftests/expected_cmptest.xml @@ -2,6 +2,7 @@ <TestCase name="tst_Cmptest"> <Environment> <QtVersion>@INSERT_QT_VERSION_HERE@</QtVersion> + <QtBuild/> <QTestVersion>@INSERT_QT_VERSION_HERE@</QTestVersion> </Environment> <TestFunction name="initTestCase"> diff --git a/tests/auto/testlib/selftests/expected_cmptest.xunitxml b/tests/auto/testlib/selftests/expected_cmptest.xunitxml index 7874c6c52e..7502d3cc54 100644 --- a/tests/auto/testlib/selftests/expected_cmptest.xunitxml +++ b/tests/auto/testlib/selftests/expected_cmptest.xunitxml @@ -3,6 +3,7 @@ <properties> <property value="@INSERT_QT_VERSION_HERE@" name="QTestVersion"/> <property value="@INSERT_QT_VERSION_HERE@" name="QtVersion"/> + <property value="" name="QtBuild"/> </properties> <testcase result="pass" name="initTestCase"/> <testcase result="pass" name="compare_boolfuncs"/> diff --git a/tests/auto/testlib/selftests/expected_commandlinedata.lightxml b/tests/auto/testlib/selftests/expected_commandlinedata.lightxml index c11017f022..894ae7ae23 100644 --- a/tests/auto/testlib/selftests/expected_commandlinedata.lightxml +++ b/tests/auto/testlib/selftests/expected_commandlinedata.lightxml @@ -1,5 +1,6 @@ <Environment> <QtVersion>@INSERT_QT_VERSION_HERE@</QtVersion> + <QtBuild/> <QTestVersion>@INSERT_QT_VERSION_HERE@</QTestVersion> </Environment> <TestFunction name="initTestCase"> diff --git a/tests/auto/testlib/selftests/expected_commandlinedata.xml b/tests/auto/testlib/selftests/expected_commandlinedata.xml index 20dc0c6a7c..b2aa98f6a7 100644 --- a/tests/auto/testlib/selftests/expected_commandlinedata.xml +++ b/tests/auto/testlib/selftests/expected_commandlinedata.xml @@ -2,6 +2,7 @@ <TestCase name="tst_DataTable"> <Environment> <QtVersion>@INSERT_QT_VERSION_HERE@</QtVersion> + <QtBuild/> <QTestVersion>@INSERT_QT_VERSION_HERE@</QTestVersion> </Environment> <TestFunction name="initTestCase"> diff --git a/tests/auto/testlib/selftests/expected_commandlinedata.xunitxml b/tests/auto/testlib/selftests/expected_commandlinedata.xunitxml index 45b833cf19..5072a7e6f4 100644 --- a/tests/auto/testlib/selftests/expected_commandlinedata.xunitxml +++ b/tests/auto/testlib/selftests/expected_commandlinedata.xunitxml @@ -3,6 +3,7 @@ <properties> <property value="@INSERT_QT_VERSION_HERE@" name="QTestVersion"/> <property value="@INSERT_QT_VERSION_HERE@" name="QtVersion"/> + <property value="" name="QtBuild"/> </properties> <testcase result="pass" name="initTestCase"/> <testcase result="pass" name="fiveTablePasses"> diff --git a/tests/auto/testlib/selftests/expected_counting.lightxml b/tests/auto/testlib/selftests/expected_counting.lightxml index e5fe1ee3cf..836c35fb85 100644 --- a/tests/auto/testlib/selftests/expected_counting.lightxml +++ b/tests/auto/testlib/selftests/expected_counting.lightxml @@ -1,5 +1,6 @@ <Environment> <QtVersion>@INSERT_QT_VERSION_HERE@</QtVersion> + <QtBuild/> <QTestVersion>@INSERT_QT_VERSION_HERE@</QTestVersion> </Environment> <TestFunction name="initTestCase"> diff --git a/tests/auto/testlib/selftests/expected_counting.xml b/tests/auto/testlib/selftests/expected_counting.xml index e015dddcc6..892fd762c6 100644 --- a/tests/auto/testlib/selftests/expected_counting.xml +++ b/tests/auto/testlib/selftests/expected_counting.xml @@ -2,6 +2,7 @@ <TestCase name="tst_Counting"> <Environment> <QtVersion>@INSERT_QT_VERSION_HERE@</QtVersion> + <QtBuild/> <QTestVersion>@INSERT_QT_VERSION_HERE@</QTestVersion> </Environment> <TestFunction name="initTestCase"> diff --git a/tests/auto/testlib/selftests/expected_counting.xunitxml b/tests/auto/testlib/selftests/expected_counting.xunitxml index 72bf047ba8..cb3a7815af 100644 --- a/tests/auto/testlib/selftests/expected_counting.xunitxml +++ b/tests/auto/testlib/selftests/expected_counting.xunitxml @@ -3,6 +3,7 @@ <properties> <property value="@INSERT_QT_VERSION_HERE@" name="QTestVersion"/> <property value="@INSERT_QT_VERSION_HERE@" name="QtVersion"/> + <property value="" name="QtBuild"/> </properties> <testcase result="pass" name="initTestCase"/> <testcase result="pass" name="testPassPass"/> diff --git a/tests/auto/testlib/selftests/expected_datatable.lightxml b/tests/auto/testlib/selftests/expected_datatable.lightxml index 6cc2d1c46f..c14a6a1940 100644 --- a/tests/auto/testlib/selftests/expected_datatable.lightxml +++ b/tests/auto/testlib/selftests/expected_datatable.lightxml @@ -1,5 +1,6 @@ <Environment> <QtVersion>@INSERT_QT_VERSION_HERE@</QtVersion> + <QtBuild/> <QTestVersion>@INSERT_QT_VERSION_HERE@</QTestVersion> </Environment> <TestFunction name="initTestCase"> diff --git a/tests/auto/testlib/selftests/expected_datatable.xml b/tests/auto/testlib/selftests/expected_datatable.xml index 79963db0a4..297cb0d5de 100644 --- a/tests/auto/testlib/selftests/expected_datatable.xml +++ b/tests/auto/testlib/selftests/expected_datatable.xml @@ -2,6 +2,7 @@ <TestCase name="tst_DataTable"> <Environment> <QtVersion>@INSERT_QT_VERSION_HERE@</QtVersion> + <QtBuild/> <QTestVersion>@INSERT_QT_VERSION_HERE@</QTestVersion> </Environment> <TestFunction name="initTestCase"> diff --git a/tests/auto/testlib/selftests/expected_datatable.xunitxml b/tests/auto/testlib/selftests/expected_datatable.xunitxml index 6bac80e0a2..89fc7ee819 100644 --- a/tests/auto/testlib/selftests/expected_datatable.xunitxml +++ b/tests/auto/testlib/selftests/expected_datatable.xunitxml @@ -3,6 +3,7 @@ <properties> <property value="@INSERT_QT_VERSION_HERE@" name="QTestVersion"/> <property value="@INSERT_QT_VERSION_HERE@" name="QtVersion"/> + <property value="" name="QtBuild"/> </properties> <testcase result="pass" name="initTestCase"/> <testcase result="pass" name="singleTestFunction1"/> diff --git a/tests/auto/testlib/selftests/expected_datetime.lightxml b/tests/auto/testlib/selftests/expected_datetime.lightxml index 02c60d04f9..48ad0933f7 100644 --- a/tests/auto/testlib/selftests/expected_datetime.lightxml +++ b/tests/auto/testlib/selftests/expected_datetime.lightxml @@ -1,5 +1,6 @@ <Environment> <QtVersion>@INSERT_QT_VERSION_HERE@</QtVersion> + <QtBuild/> <QTestVersion>@INSERT_QT_VERSION_HERE@</QTestVersion> </Environment> <TestFunction name="initTestCase"> diff --git a/tests/auto/testlib/selftests/expected_datetime.xml b/tests/auto/testlib/selftests/expected_datetime.xml index 03aec4430e..30afde60ec 100644 --- a/tests/auto/testlib/selftests/expected_datetime.xml +++ b/tests/auto/testlib/selftests/expected_datetime.xml @@ -2,6 +2,7 @@ <TestCase name="tst_DateTime"> <Environment> <QtVersion>@INSERT_QT_VERSION_HERE@</QtVersion> + <QtBuild/> <QTestVersion>@INSERT_QT_VERSION_HERE@</QTestVersion> </Environment> <TestFunction name="initTestCase"> diff --git a/tests/auto/testlib/selftests/expected_datetime.xunitxml b/tests/auto/testlib/selftests/expected_datetime.xunitxml index 00bd43f904..901462b6bf 100644 --- a/tests/auto/testlib/selftests/expected_datetime.xunitxml +++ b/tests/auto/testlib/selftests/expected_datetime.xunitxml @@ -3,6 +3,7 @@ <properties> <property value="@INSERT_QT_VERSION_HERE@" name="QTestVersion"/> <property value="@INSERT_QT_VERSION_HERE@" name="QtVersion"/> + <property value="" name="QtBuild"/> </properties> <testcase result="pass" name="initTestCase"/> <testcase result="fail" name="dateTime"> diff --git a/tests/auto/testlib/selftests/expected_exceptionthrow.lightxml b/tests/auto/testlib/selftests/expected_exceptionthrow.lightxml index 6c9675a2aa..2b802aabaf 100644 --- a/tests/auto/testlib/selftests/expected_exceptionthrow.lightxml +++ b/tests/auto/testlib/selftests/expected_exceptionthrow.lightxml @@ -1,5 +1,6 @@ <Environment> <QtVersion>@INSERT_QT_VERSION_HERE@</QtVersion> + <QtBuild/> <QTestVersion>@INSERT_QT_VERSION_HERE@</QTestVersion> </Environment> <TestFunction name="initTestCase"> @@ -7,7 +8,7 @@ <Duration msecs="0"/> </TestFunction> <TestFunction name="throwException"> -<Incident type="fail" file="/home/frederik/dev/qt/qt-src-dev/qtbase/src/testlib/qtestcase.cpp" line="2229"> +<Incident type="fail" file="qtestcase.cpp" line="2235"> <Description><![CDATA[Caught unhandled exception]]></Description> </Incident> <Duration msecs="0"/> diff --git a/tests/auto/testlib/selftests/expected_exceptionthrow.xml b/tests/auto/testlib/selftests/expected_exceptionthrow.xml index 87d9d2d431..a265d5ba5f 100644 --- a/tests/auto/testlib/selftests/expected_exceptionthrow.xml +++ b/tests/auto/testlib/selftests/expected_exceptionthrow.xml @@ -2,6 +2,7 @@ <TestCase name="tst_Exception"> <Environment> <QtVersion>@INSERT_QT_VERSION_HERE@</QtVersion> + <QtBuild/> <QTestVersion>@INSERT_QT_VERSION_HERE@</QTestVersion> </Environment> <TestFunction name="initTestCase"> @@ -9,7 +10,7 @@ <Duration msecs="0"/> </TestFunction> <TestFunction name="throwException"> -<Incident type="fail" file="/home/frederik/dev/qt/qt-src-dev/qtbase/src/testlib/qtestcase.cpp" line="2229"> +<Incident type="fail" file="qtestcase.cpp" line="2235"> <Description><![CDATA[Caught unhandled exception]]></Description> </Incident> <Duration msecs="0"/> diff --git a/tests/auto/testlib/selftests/expected_exceptionthrow.xunitxml b/tests/auto/testlib/selftests/expected_exceptionthrow.xunitxml index ab0d379255..7d10bf6f04 100644 --- a/tests/auto/testlib/selftests/expected_exceptionthrow.xunitxml +++ b/tests/auto/testlib/selftests/expected_exceptionthrow.xunitxml @@ -3,6 +3,7 @@ <properties> <property value="@INSERT_QT_VERSION_HERE@" name="QTestVersion"/> <property value="@INSERT_QT_VERSION_HERE@" name="QtVersion"/> + <property value="" name="QtBuild"/> </properties> <testcase result="pass" name="initTestCase"/> <testcase result="fail" name="throwException"> diff --git a/tests/auto/testlib/selftests/expected_expectfail.lightxml b/tests/auto/testlib/selftests/expected_expectfail.lightxml index e5fcca5875..cd5ab78fbe 100644 --- a/tests/auto/testlib/selftests/expected_expectfail.lightxml +++ b/tests/auto/testlib/selftests/expected_expectfail.lightxml @@ -1,5 +1,6 @@ <Environment> <QtVersion>@INSERT_QT_VERSION_HERE@</QtVersion> + <QtBuild/> <QTestVersion>@INSERT_QT_VERSION_HERE@</QTestVersion> </Environment> <TestFunction name="initTestCase"> diff --git a/tests/auto/testlib/selftests/expected_expectfail.xml b/tests/auto/testlib/selftests/expected_expectfail.xml index 14fee2129e..a98b97810c 100644 --- a/tests/auto/testlib/selftests/expected_expectfail.xml +++ b/tests/auto/testlib/selftests/expected_expectfail.xml @@ -2,6 +2,7 @@ <TestCase name="tst_ExpectFail"> <Environment> <QtVersion>@INSERT_QT_VERSION_HERE@</QtVersion> + <QtBuild/> <QTestVersion>@INSERT_QT_VERSION_HERE@</QTestVersion> </Environment> <TestFunction name="initTestCase"> diff --git a/tests/auto/testlib/selftests/expected_expectfail.xunitxml b/tests/auto/testlib/selftests/expected_expectfail.xunitxml index 45c260c77f..47483d71bf 100644 --- a/tests/auto/testlib/selftests/expected_expectfail.xunitxml +++ b/tests/auto/testlib/selftests/expected_expectfail.xunitxml @@ -3,6 +3,7 @@ <properties> <property value="@INSERT_QT_VERSION_HERE@" name="QTestVersion"/> <property value="@INSERT_QT_VERSION_HERE@" name="QtVersion"/> + <property value="" name="QtBuild"/> </properties> <testcase result="pass" name="initTestCase"/> <testcase result="xfail" name="xfailAndContinue"> diff --git a/tests/auto/testlib/selftests/expected_failcleanup.lightxml b/tests/auto/testlib/selftests/expected_failcleanup.lightxml index cfc18ef5da..b2db64c4e2 100644 --- a/tests/auto/testlib/selftests/expected_failcleanup.lightxml +++ b/tests/auto/testlib/selftests/expected_failcleanup.lightxml @@ -1,5 +1,6 @@ <Environment> <QtVersion>@INSERT_QT_VERSION_HERE@</QtVersion> + <QtBuild/> <QTestVersion>@INSERT_QT_VERSION_HERE@</QTestVersion> </Environment> <TestFunction name="initTestCase"> diff --git a/tests/auto/testlib/selftests/expected_failcleanup.xml b/tests/auto/testlib/selftests/expected_failcleanup.xml index 3aa7aa265d..476e56c4f4 100644 --- a/tests/auto/testlib/selftests/expected_failcleanup.xml +++ b/tests/auto/testlib/selftests/expected_failcleanup.xml @@ -2,6 +2,7 @@ <TestCase name="tst_FailCleanup"> <Environment> <QtVersion>@INSERT_QT_VERSION_HERE@</QtVersion> + <QtBuild/> <QTestVersion>@INSERT_QT_VERSION_HERE@</QTestVersion> </Environment> <TestFunction name="initTestCase"> diff --git a/tests/auto/testlib/selftests/expected_failcleanup.xunitxml b/tests/auto/testlib/selftests/expected_failcleanup.xunitxml index 6e35566be8..813e284ee0 100644 --- a/tests/auto/testlib/selftests/expected_failcleanup.xunitxml +++ b/tests/auto/testlib/selftests/expected_failcleanup.xunitxml @@ -3,6 +3,7 @@ <properties> <property value="@INSERT_QT_VERSION_HERE@" name="QTestVersion"/> <property value="@INSERT_QT_VERSION_HERE@" name="QtVersion"/> + <property value="" name="QtBuild"/> </properties> <testcase result="pass" name="initTestCase"/> <testcase result="pass" name="aTestFunction"/> diff --git a/tests/auto/testlib/selftests/expected_failinit.lightxml b/tests/auto/testlib/selftests/expected_failinit.lightxml index c0d193998d..5a940fc36b 100644 --- a/tests/auto/testlib/selftests/expected_failinit.lightxml +++ b/tests/auto/testlib/selftests/expected_failinit.lightxml @@ -1,5 +1,6 @@ <Environment> <QtVersion>@INSERT_QT_VERSION_HERE@</QtVersion> + <QtBuild/> <QTestVersion>@INSERT_QT_VERSION_HERE@</QTestVersion> </Environment> <TestFunction name="initTestCase"> diff --git a/tests/auto/testlib/selftests/expected_failinit.xml b/tests/auto/testlib/selftests/expected_failinit.xml index 70ad613f3f..51e1a7fce4 100644 --- a/tests/auto/testlib/selftests/expected_failinit.xml +++ b/tests/auto/testlib/selftests/expected_failinit.xml @@ -2,6 +2,7 @@ <TestCase name="tst_FailInit"> <Environment> <QtVersion>@INSERT_QT_VERSION_HERE@</QtVersion> + <QtBuild/> <QTestVersion>@INSERT_QT_VERSION_HERE@</QTestVersion> </Environment> <TestFunction name="initTestCase"> diff --git a/tests/auto/testlib/selftests/expected_failinit.xunitxml b/tests/auto/testlib/selftests/expected_failinit.xunitxml index 3c2e31be29..3715725ea5 100644 --- a/tests/auto/testlib/selftests/expected_failinit.xunitxml +++ b/tests/auto/testlib/selftests/expected_failinit.xunitxml @@ -3,6 +3,7 @@ <properties> <property value="@INSERT_QT_VERSION_HERE@" name="QTestVersion"/> <property value="@INSERT_QT_VERSION_HERE@" name="QtVersion"/> + <property value="" name="QtBuild"/> </properties> <testcase result="fail" name="initTestCase"> <failure message="'false' returned FALSE. ()" result="fail"/> diff --git a/tests/auto/testlib/selftests/expected_failinitdata.lightxml b/tests/auto/testlib/selftests/expected_failinitdata.lightxml index 285471470f..f9da42c060 100644 --- a/tests/auto/testlib/selftests/expected_failinitdata.lightxml +++ b/tests/auto/testlib/selftests/expected_failinitdata.lightxml @@ -1,5 +1,6 @@ <Environment> <QtVersion>@INSERT_QT_VERSION_HERE@</QtVersion> + <QtBuild/> <QTestVersion>@INSERT_QT_VERSION_HERE@</QTestVersion> </Environment> <TestFunction name="initTestCase"> diff --git a/tests/auto/testlib/selftests/expected_failinitdata.xml b/tests/auto/testlib/selftests/expected_failinitdata.xml index e86e102202..e843863bfc 100644 --- a/tests/auto/testlib/selftests/expected_failinitdata.xml +++ b/tests/auto/testlib/selftests/expected_failinitdata.xml @@ -2,6 +2,7 @@ <TestCase name="tst_FailInitData"> <Environment> <QtVersion>@INSERT_QT_VERSION_HERE@</QtVersion> + <QtBuild/> <QTestVersion>@INSERT_QT_VERSION_HERE@</QTestVersion> </Environment> <TestFunction name="initTestCase"> diff --git a/tests/auto/testlib/selftests/expected_failinitdata.xunitxml b/tests/auto/testlib/selftests/expected_failinitdata.xunitxml index f32ccd5e81..d245bc0dff 100644 --- a/tests/auto/testlib/selftests/expected_failinitdata.xunitxml +++ b/tests/auto/testlib/selftests/expected_failinitdata.xunitxml @@ -3,6 +3,7 @@ <properties> <property value="@INSERT_QT_VERSION_HERE@" name="QTestVersion"/> <property value="@INSERT_QT_VERSION_HERE@" name="QtVersion"/> + <property value="" name="QtBuild"/> </properties> <testcase result="fail" name="initTestCase"> <failure message="'false' returned FALSE. ()" result="fail"/> diff --git a/tests/auto/testlib/selftests/expected_fetchbogus.lightxml b/tests/auto/testlib/selftests/expected_fetchbogus.lightxml index c5587cf031..c62a93eb49 100644 --- a/tests/auto/testlib/selftests/expected_fetchbogus.lightxml +++ b/tests/auto/testlib/selftests/expected_fetchbogus.lightxml @@ -1,5 +1,6 @@ <Environment> <QtVersion>@INSERT_QT_VERSION_HERE@</QtVersion> + <QtBuild/> <QTestVersion>@INSERT_QT_VERSION_HERE@</QTestVersion> </Environment> <TestFunction name="initTestCase"> diff --git a/tests/auto/testlib/selftests/expected_fetchbogus.xml b/tests/auto/testlib/selftests/expected_fetchbogus.xml index 40295bdebc..c20de137a2 100644 --- a/tests/auto/testlib/selftests/expected_fetchbogus.xml +++ b/tests/auto/testlib/selftests/expected_fetchbogus.xml @@ -2,6 +2,7 @@ <TestCase name="tst_FetchBogus"> <Environment> <QtVersion>@INSERT_QT_VERSION_HERE@</QtVersion> + <QtBuild/> <QTestVersion>@INSERT_QT_VERSION_HERE@</QTestVersion> </Environment> <TestFunction name="initTestCase"> diff --git a/tests/auto/testlib/selftests/expected_fetchbogus.xunitxml b/tests/auto/testlib/selftests/expected_fetchbogus.xunitxml index fe31b4b600..77ccbd896a 100644 --- a/tests/auto/testlib/selftests/expected_fetchbogus.xunitxml +++ b/tests/auto/testlib/selftests/expected_fetchbogus.xunitxml @@ -3,6 +3,7 @@ <properties> <property value="@INSERT_QT_VERSION_HERE@" name="QTestVersion"/> <property value="@INSERT_QT_VERSION_HERE@" name="QtVersion"/> + <property value="" name="QtBuild"/> </properties> <testcase result="pass" name="initTestCase"/> <testcase result="fail" name="fetchBogus"> diff --git a/tests/auto/testlib/selftests/expected_findtestdata.lightxml b/tests/auto/testlib/selftests/expected_findtestdata.lightxml index 4c1c7298ed..e3c3cea7bc 100644 --- a/tests/auto/testlib/selftests/expected_findtestdata.lightxml +++ b/tests/auto/testlib/selftests/expected_findtestdata.lightxml @@ -1,5 +1,6 @@ <Environment> <QtVersion>@INSERT_QT_VERSION_HERE@</QtVersion> + <QtBuild/> <QTestVersion>@INSERT_QT_VERSION_HERE@</QTestVersion> </Environment> <TestFunction name="initTestCase"> diff --git a/tests/auto/testlib/selftests/expected_findtestdata.xml b/tests/auto/testlib/selftests/expected_findtestdata.xml index b1f33abaf6..6abaa15103 100644 --- a/tests/auto/testlib/selftests/expected_findtestdata.xml +++ b/tests/auto/testlib/selftests/expected_findtestdata.xml @@ -2,6 +2,7 @@ <TestCase name="FindTestData"> <Environment> <QtVersion>@INSERT_QT_VERSION_HERE@</QtVersion> + <QtBuild/> <QTestVersion>@INSERT_QT_VERSION_HERE@</QTestVersion> </Environment> <TestFunction name="initTestCase"> diff --git a/tests/auto/testlib/selftests/expected_findtestdata.xunitxml b/tests/auto/testlib/selftests/expected_findtestdata.xunitxml index 60283a1064..c1138da6cb 100644 --- a/tests/auto/testlib/selftests/expected_findtestdata.xunitxml +++ b/tests/auto/testlib/selftests/expected_findtestdata.xunitxml @@ -3,6 +3,7 @@ <properties> <property value="@INSERT_QT_VERSION_HERE@" name="QTestVersion"/> <property value="@INSERT_QT_VERSION_HERE@" name="QtVersion"/> + <property value="" name="QtBuild"/> </properties> <testcase result="pass" name="initTestCase"/> <testcase result="pass" name="paths"> diff --git a/tests/auto/testlib/selftests/expected_globaldata.lightxml b/tests/auto/testlib/selftests/expected_globaldata.lightxml index fd128d2c61..7d4c43905c 100644 --- a/tests/auto/testlib/selftests/expected_globaldata.lightxml +++ b/tests/auto/testlib/selftests/expected_globaldata.lightxml @@ -1,5 +1,6 @@ <Environment> <QtVersion>@INSERT_QT_VERSION_HERE@</QtVersion> + <QtBuild/> <QTestVersion>@INSERT_QT_VERSION_HERE@</QTestVersion> </Environment> <TestFunction name="initTestCase"> diff --git a/tests/auto/testlib/selftests/expected_globaldata.xml b/tests/auto/testlib/selftests/expected_globaldata.xml index 0867619fde..5e5d4d8922 100644 --- a/tests/auto/testlib/selftests/expected_globaldata.xml +++ b/tests/auto/testlib/selftests/expected_globaldata.xml @@ -2,6 +2,7 @@ <TestCase name="tst_globaldata"> <Environment> <QtVersion>@INSERT_QT_VERSION_HERE@</QtVersion> + <QtBuild/> <QTestVersion>@INSERT_QT_VERSION_HERE@</QTestVersion> </Environment> <TestFunction name="initTestCase"> diff --git a/tests/auto/testlib/selftests/expected_globaldata.xunitxml b/tests/auto/testlib/selftests/expected_globaldata.xunitxml index e8cd03a59c..bdd7e3f00a 100644 --- a/tests/auto/testlib/selftests/expected_globaldata.xunitxml +++ b/tests/auto/testlib/selftests/expected_globaldata.xunitxml @@ -3,6 +3,7 @@ <properties> <property value="@INSERT_QT_VERSION_HERE@" name="QTestVersion"/> <property value="@INSERT_QT_VERSION_HERE@" name="QtVersion"/> + <property value="" name="QtBuild"/> </properties> <testcase result="pass" name="initTestCase"> <!-- message="initTestCase initTestCase (null)" type="qdebug" --> diff --git a/tests/auto/testlib/selftests/expected_longstring.lightxml b/tests/auto/testlib/selftests/expected_longstring.lightxml index 45c6d3f78d..f8796bed4a 100644 --- a/tests/auto/testlib/selftests/expected_longstring.lightxml +++ b/tests/auto/testlib/selftests/expected_longstring.lightxml @@ -1,5 +1,6 @@ <Environment> <QtVersion>@INSERT_QT_VERSION_HERE@</QtVersion> + <QtBuild/> <QTestVersion>@INSERT_QT_VERSION_HERE@</QTestVersion> </Environment> <TestFunction name="initTestCase"> diff --git a/tests/auto/testlib/selftests/expected_longstring.xml b/tests/auto/testlib/selftests/expected_longstring.xml index efc29d6def..6623b7cd88 100644 --- a/tests/auto/testlib/selftests/expected_longstring.xml +++ b/tests/auto/testlib/selftests/expected_longstring.xml @@ -2,6 +2,7 @@ <TestCase name="tst_LongString"> <Environment> <QtVersion>@INSERT_QT_VERSION_HERE@</QtVersion> + <QtBuild/> <QTestVersion>@INSERT_QT_VERSION_HERE@</QTestVersion> </Environment> <TestFunction name="initTestCase"> diff --git a/tests/auto/testlib/selftests/expected_longstring.xunitxml b/tests/auto/testlib/selftests/expected_longstring.xunitxml index 6486817dbb..269c06fe08 100644 --- a/tests/auto/testlib/selftests/expected_longstring.xunitxml +++ b/tests/auto/testlib/selftests/expected_longstring.xunitxml @@ -3,6 +3,7 @@ <properties> <property value="@INSERT_QT_VERSION_HERE@" name="QTestVersion"/> <property value="@INSERT_QT_VERSION_HERE@" name="QtVersion"/> + <property value="" name="QtBuild"/> </properties> <testcase result="pass" name="initTestCase"/> <testcase result="fail" name="failWithLongString"> diff --git a/tests/auto/testlib/selftests/expected_maxwarnings.lightxml b/tests/auto/testlib/selftests/expected_maxwarnings.lightxml index ce6d828eb2..49db189352 100644 --- a/tests/auto/testlib/selftests/expected_maxwarnings.lightxml +++ b/tests/auto/testlib/selftests/expected_maxwarnings.lightxml @@ -1,5 +1,6 @@ <Environment> <QtVersion>@INSERT_QT_VERSION_HERE@</QtVersion> + <QtBuild/> <QTestVersion>@INSERT_QT_VERSION_HERE@</QTestVersion> </Environment> <TestFunction name="initTestCase"> diff --git a/tests/auto/testlib/selftests/expected_maxwarnings.xml b/tests/auto/testlib/selftests/expected_maxwarnings.xml index 758af9d6d5..614b054fad 100644 --- a/tests/auto/testlib/selftests/expected_maxwarnings.xml +++ b/tests/auto/testlib/selftests/expected_maxwarnings.xml @@ -2,6 +2,7 @@ <TestCase name="MaxWarnings"> <Environment> <QtVersion>@INSERT_QT_VERSION_HERE@</QtVersion> + <QtBuild/> <QTestVersion>@INSERT_QT_VERSION_HERE@</QTestVersion> </Environment> <TestFunction name="initTestCase"> diff --git a/tests/auto/testlib/selftests/expected_maxwarnings.xunitxml b/tests/auto/testlib/selftests/expected_maxwarnings.xunitxml index b1b0215cef..329fae5f1d 100644 --- a/tests/auto/testlib/selftests/expected_maxwarnings.xunitxml +++ b/tests/auto/testlib/selftests/expected_maxwarnings.xunitxml @@ -3,6 +3,7 @@ <properties> <property value="@INSERT_QT_VERSION_HERE@" name="QTestVersion"/> <property value="@INSERT_QT_VERSION_HERE@" name="QtVersion"/> + <property value="" name="QtBuild"/> </properties> <testcase result="pass" name="initTestCase"/> <testcase result="pass" name="warn"> diff --git a/tests/auto/testlib/selftests/expected_singleskip.lightxml b/tests/auto/testlib/selftests/expected_singleskip.lightxml index 685396a243..ce09c0a9ad 100644 --- a/tests/auto/testlib/selftests/expected_singleskip.lightxml +++ b/tests/auto/testlib/selftests/expected_singleskip.lightxml @@ -1,5 +1,6 @@ <Environment> <QtVersion>@INSERT_QT_VERSION_HERE@</QtVersion> + <QtBuild/> <QTestVersion>@INSERT_QT_VERSION_HERE@</QTestVersion> </Environment> <TestFunction name="initTestCase"> diff --git a/tests/auto/testlib/selftests/expected_singleskip.xml b/tests/auto/testlib/selftests/expected_singleskip.xml index c10626ca41..0c5cdade3d 100644 --- a/tests/auto/testlib/selftests/expected_singleskip.xml +++ b/tests/auto/testlib/selftests/expected_singleskip.xml @@ -2,6 +2,7 @@ <TestCase name="tst_SingleSkip"> <Environment> <QtVersion>@INSERT_QT_VERSION_HERE@</QtVersion> + <QtBuild/> <QTestVersion>@INSERT_QT_VERSION_HERE@</QTestVersion> </Environment> <TestFunction name="initTestCase"> diff --git a/tests/auto/testlib/selftests/expected_singleskip.xunitxml b/tests/auto/testlib/selftests/expected_singleskip.xunitxml index 70968fa1c4..2b2da2f504 100644 --- a/tests/auto/testlib/selftests/expected_singleskip.xunitxml +++ b/tests/auto/testlib/selftests/expected_singleskip.xunitxml @@ -3,6 +3,7 @@ <properties> <property value="@INSERT_QT_VERSION_HERE@" name="QTestVersion"/> <property value="@INSERT_QT_VERSION_HERE@" name="QtVersion"/> + <property value="" name="QtBuild"/> </properties> <testcase result="pass" name="initTestCase"/> <testcase name="myTest"> diff --git a/tests/auto/testlib/selftests/expected_skip.lightxml b/tests/auto/testlib/selftests/expected_skip.lightxml index 408bc44871..ee83d263b5 100644 --- a/tests/auto/testlib/selftests/expected_skip.lightxml +++ b/tests/auto/testlib/selftests/expected_skip.lightxml @@ -1,5 +1,6 @@ <Environment> <QtVersion>@INSERT_QT_VERSION_HERE@</QtVersion> + <QtBuild/> <QTestVersion>@INSERT_QT_VERSION_HERE@</QTestVersion> </Environment> <TestFunction name="initTestCase"> diff --git a/tests/auto/testlib/selftests/expected_skip.xml b/tests/auto/testlib/selftests/expected_skip.xml index b220722b6c..2c830bc9fb 100644 --- a/tests/auto/testlib/selftests/expected_skip.xml +++ b/tests/auto/testlib/selftests/expected_skip.xml @@ -2,6 +2,7 @@ <TestCase name="tst_Skip"> <Environment> <QtVersion>@INSERT_QT_VERSION_HERE@</QtVersion> + <QtBuild/> <QTestVersion>@INSERT_QT_VERSION_HERE@</QTestVersion> </Environment> <TestFunction name="initTestCase"> diff --git a/tests/auto/testlib/selftests/expected_skip.xunitxml b/tests/auto/testlib/selftests/expected_skip.xunitxml index 956d51f531..63e582f96a 100644 --- a/tests/auto/testlib/selftests/expected_skip.xunitxml +++ b/tests/auto/testlib/selftests/expected_skip.xunitxml @@ -3,6 +3,7 @@ <properties> <property value="@INSERT_QT_VERSION_HERE@" name="QTestVersion"/> <property value="@INSERT_QT_VERSION_HERE@" name="QtVersion"/> + <property value="" name="QtBuild"/> </properties> <testcase result="pass" name="initTestCase"/> <testcase name="test"> diff --git a/tests/auto/testlib/selftests/expected_skipcleanup.lightxml b/tests/auto/testlib/selftests/expected_skipcleanup.lightxml index 49c9d148f5..dbbc30c0db 100644 --- a/tests/auto/testlib/selftests/expected_skipcleanup.lightxml +++ b/tests/auto/testlib/selftests/expected_skipcleanup.lightxml @@ -1,5 +1,6 @@ <Environment> <QtVersion>@INSERT_QT_VERSION_HERE@</QtVersion> + <QtBuild/> <QTestVersion>@INSERT_QT_VERSION_HERE@</QTestVersion> </Environment> <TestFunction name="initTestCase"> diff --git a/tests/auto/testlib/selftests/expected_skipcleanup.xml b/tests/auto/testlib/selftests/expected_skipcleanup.xml index 0bf1fe53a3..7b787ebb3d 100644 --- a/tests/auto/testlib/selftests/expected_skipcleanup.xml +++ b/tests/auto/testlib/selftests/expected_skipcleanup.xml @@ -2,6 +2,7 @@ <TestCase name="tst_SkipCleanup"> <Environment> <QtVersion>@INSERT_QT_VERSION_HERE@</QtVersion> + <QtBuild/> <QTestVersion>@INSERT_QT_VERSION_HERE@</QTestVersion> </Environment> <TestFunction name="initTestCase"> diff --git a/tests/auto/testlib/selftests/expected_skipcleanup.xunitxml b/tests/auto/testlib/selftests/expected_skipcleanup.xunitxml index b8f67e2d07..9934584ec5 100644 --- a/tests/auto/testlib/selftests/expected_skipcleanup.xunitxml +++ b/tests/auto/testlib/selftests/expected_skipcleanup.xunitxml @@ -3,6 +3,7 @@ <properties> <property value="@INSERT_QT_VERSION_HERE@" name="QTestVersion"/> <property value="@INSERT_QT_VERSION_HERE@" name="QtVersion"/> + <property value="" name="QtBuild"/> </properties> <testcase result="pass" name="initTestCase"/> <testcase result="pass" name="aTestFunction"/> diff --git a/tests/auto/testlib/selftests/expected_skipinit.lightxml b/tests/auto/testlib/selftests/expected_skipinit.lightxml index e06c745205..3682068825 100644 --- a/tests/auto/testlib/selftests/expected_skipinit.lightxml +++ b/tests/auto/testlib/selftests/expected_skipinit.lightxml @@ -1,5 +1,6 @@ <Environment> <QtVersion>@INSERT_QT_VERSION_HERE@</QtVersion> + <QtBuild/> <QTestVersion>@INSERT_QT_VERSION_HERE@</QTestVersion> </Environment> <TestFunction name="initTestCase"> diff --git a/tests/auto/testlib/selftests/expected_skipinit.xml b/tests/auto/testlib/selftests/expected_skipinit.xml index 6a62b93614..9d6a38b82f 100644 --- a/tests/auto/testlib/selftests/expected_skipinit.xml +++ b/tests/auto/testlib/selftests/expected_skipinit.xml @@ -2,6 +2,7 @@ <TestCase name="tst_SkipInit"> <Environment> <QtVersion>@INSERT_QT_VERSION_HERE@</QtVersion> + <QtBuild/> <QTestVersion>@INSERT_QT_VERSION_HERE@</QTestVersion> </Environment> <TestFunction name="initTestCase"> diff --git a/tests/auto/testlib/selftests/expected_skipinit.xunitxml b/tests/auto/testlib/selftests/expected_skipinit.xunitxml index f62df71d96..bab08c375c 100644 --- a/tests/auto/testlib/selftests/expected_skipinit.xunitxml +++ b/tests/auto/testlib/selftests/expected_skipinit.xunitxml @@ -3,6 +3,7 @@ <properties> <property value="@INSERT_QT_VERSION_HERE@" name="QTestVersion"/> <property value="@INSERT_QT_VERSION_HERE@" name="QtVersion"/> + <property value="" name="QtBuild"/> </properties> <testcase name="initTestCase"> <!-- message="Skip inside initTestCase. This should skip all tests in the class." type="skip" --> diff --git a/tests/auto/testlib/selftests/expected_skipinitdata.lightxml b/tests/auto/testlib/selftests/expected_skipinitdata.lightxml index 41abd5dccd..26afcb4ab1 100644 --- a/tests/auto/testlib/selftests/expected_skipinitdata.lightxml +++ b/tests/auto/testlib/selftests/expected_skipinitdata.lightxml @@ -1,5 +1,6 @@ <Environment> <QtVersion>@INSERT_QT_VERSION_HERE@</QtVersion> + <QtBuild/> <QTestVersion>@INSERT_QT_VERSION_HERE@</QTestVersion> </Environment> <TestFunction name="initTestCase"> diff --git a/tests/auto/testlib/selftests/expected_skipinitdata.xml b/tests/auto/testlib/selftests/expected_skipinitdata.xml index 8efe12195e..9ab84f21a1 100644 --- a/tests/auto/testlib/selftests/expected_skipinitdata.xml +++ b/tests/auto/testlib/selftests/expected_skipinitdata.xml @@ -2,6 +2,7 @@ <TestCase name="tst_SkipInitData"> <Environment> <QtVersion>@INSERT_QT_VERSION_HERE@</QtVersion> + <QtBuild/> <QTestVersion>@INSERT_QT_VERSION_HERE@</QTestVersion> </Environment> <TestFunction name="initTestCase"> diff --git a/tests/auto/testlib/selftests/expected_skipinitdata.xunitxml b/tests/auto/testlib/selftests/expected_skipinitdata.xunitxml index 699d50f7a7..e61d50b06b 100644 --- a/tests/auto/testlib/selftests/expected_skipinitdata.xunitxml +++ b/tests/auto/testlib/selftests/expected_skipinitdata.xunitxml @@ -3,6 +3,7 @@ <properties> <property value="@INSERT_QT_VERSION_HERE@" name="QTestVersion"/> <property value="@INSERT_QT_VERSION_HERE@" name="QtVersion"/> + <property value="" name="QtBuild"/> </properties> <testcase name="initTestCase"> <!-- message="Skip inside initTestCase_data. This should skip all tests in the class." type="skip" --> diff --git a/tests/auto/testlib/selftests/expected_strcmp.lightxml b/tests/auto/testlib/selftests/expected_strcmp.lightxml index f0d266d400..298e910be8 100644 --- a/tests/auto/testlib/selftests/expected_strcmp.lightxml +++ b/tests/auto/testlib/selftests/expected_strcmp.lightxml @@ -1,5 +1,6 @@ <Environment> <QtVersion>@INSERT_QT_VERSION_HERE@</QtVersion> + <QtBuild/> <QTestVersion>@INSERT_QT_VERSION_HERE@</QTestVersion> </Environment> <TestFunction name="initTestCase"> diff --git a/tests/auto/testlib/selftests/expected_strcmp.xml b/tests/auto/testlib/selftests/expected_strcmp.xml index 20ffee0611..29208f9a87 100644 --- a/tests/auto/testlib/selftests/expected_strcmp.xml +++ b/tests/auto/testlib/selftests/expected_strcmp.xml @@ -2,6 +2,7 @@ <TestCase name="tst_StrCmp"> <Environment> <QtVersion>@INSERT_QT_VERSION_HERE@</QtVersion> + <QtBuild/> <QTestVersion>@INSERT_QT_VERSION_HERE@</QTestVersion> </Environment> <TestFunction name="initTestCase"> diff --git a/tests/auto/testlib/selftests/expected_strcmp.xunitxml b/tests/auto/testlib/selftests/expected_strcmp.xunitxml index dde9ff5299..14bef9ec47 100644 --- a/tests/auto/testlib/selftests/expected_strcmp.xunitxml +++ b/tests/auto/testlib/selftests/expected_strcmp.xunitxml @@ -3,6 +3,7 @@ <properties> <property value="@INSERT_QT_VERSION_HERE@" name="QTestVersion"/> <property value="@INSERT_QT_VERSION_HERE@" name="QtVersion"/> + <property value="" name="QtBuild"/> </properties> <testcase result="pass" name="initTestCase"/> <testcase result="pass" name="compareCharStars"/> diff --git a/tests/auto/testlib/selftests/expected_subtest.lightxml b/tests/auto/testlib/selftests/expected_subtest.lightxml index 467fabb7ac..2e484aafef 100644 --- a/tests/auto/testlib/selftests/expected_subtest.lightxml +++ b/tests/auto/testlib/selftests/expected_subtest.lightxml @@ -1,5 +1,6 @@ <Environment> <QtVersion>@INSERT_QT_VERSION_HERE@</QtVersion> + <QtBuild/> <QTestVersion>@INSERT_QT_VERSION_HERE@</QTestVersion> </Environment> <TestFunction name="initTestCase"> diff --git a/tests/auto/testlib/selftests/expected_subtest.xml b/tests/auto/testlib/selftests/expected_subtest.xml index 1107bcb070..f011489ec8 100644 --- a/tests/auto/testlib/selftests/expected_subtest.xml +++ b/tests/auto/testlib/selftests/expected_subtest.xml @@ -2,6 +2,7 @@ <TestCase name="tst_Subtest"> <Environment> <QtVersion>@INSERT_QT_VERSION_HERE@</QtVersion> + <QtBuild/> <QTestVersion>@INSERT_QT_VERSION_HERE@</QTestVersion> </Environment> <TestFunction name="initTestCase"> diff --git a/tests/auto/testlib/selftests/expected_subtest.xunitxml b/tests/auto/testlib/selftests/expected_subtest.xunitxml index 753711f837..b49c006940 100644 --- a/tests/auto/testlib/selftests/expected_subtest.xunitxml +++ b/tests/auto/testlib/selftests/expected_subtest.xunitxml @@ -3,6 +3,7 @@ <properties> <property value="@INSERT_QT_VERSION_HERE@" name="QTestVersion"/> <property value="@INSERT_QT_VERSION_HERE@" name="QtVersion"/> + <property value="" name="QtBuild"/> </properties> <testcase result="pass" name="initTestCase"> <!-- message="initTestCase initTestCase (null)" type="qdebug" --> diff --git a/tests/auto/testlib/selftests/expected_verbose1.lightxml b/tests/auto/testlib/selftests/expected_verbose1.lightxml index 45dca139fa..6d7ce13ea0 100644 --- a/tests/auto/testlib/selftests/expected_verbose1.lightxml +++ b/tests/auto/testlib/selftests/expected_verbose1.lightxml @@ -1,5 +1,6 @@ <Environment> <QtVersion>@INSERT_QT_VERSION_HERE@</QtVersion> + <QtBuild/> <QTestVersion>@INSERT_QT_VERSION_HERE@</QTestVersion> </Environment> <TestFunction name="initTestCase"> diff --git a/tests/auto/testlib/selftests/expected_verbose1.xml b/tests/auto/testlib/selftests/expected_verbose1.xml index 7a182183c1..b5ae1286cb 100644 --- a/tests/auto/testlib/selftests/expected_verbose1.xml +++ b/tests/auto/testlib/selftests/expected_verbose1.xml @@ -2,6 +2,7 @@ <TestCase name="tst_Counting"> <Environment> <QtVersion>@INSERT_QT_VERSION_HERE@</QtVersion> + <QtBuild/> <QTestVersion>@INSERT_QT_VERSION_HERE@</QTestVersion> </Environment> <TestFunction name="initTestCase"> diff --git a/tests/auto/testlib/selftests/expected_verbose1.xunitxml b/tests/auto/testlib/selftests/expected_verbose1.xunitxml index 72bf047ba8..cb3a7815af 100644 --- a/tests/auto/testlib/selftests/expected_verbose1.xunitxml +++ b/tests/auto/testlib/selftests/expected_verbose1.xunitxml @@ -3,6 +3,7 @@ <properties> <property value="@INSERT_QT_VERSION_HERE@" name="QTestVersion"/> <property value="@INSERT_QT_VERSION_HERE@" name="QtVersion"/> + <property value="" name="QtBuild"/> </properties> <testcase result="pass" name="initTestCase"/> <testcase result="pass" name="testPassPass"/> diff --git a/tests/auto/testlib/selftests/expected_verbose2.lightxml b/tests/auto/testlib/selftests/expected_verbose2.lightxml index 0ead76884c..85f9ec45af 100644 --- a/tests/auto/testlib/selftests/expected_verbose2.lightxml +++ b/tests/auto/testlib/selftests/expected_verbose2.lightxml @@ -1,5 +1,6 @@ <Environment> <QtVersion>@INSERT_QT_VERSION_HERE@</QtVersion> + <QtBuild/> <QTestVersion>@INSERT_QT_VERSION_HERE@</QTestVersion> </Environment> <TestFunction name="initTestCase"> diff --git a/tests/auto/testlib/selftests/expected_verbose2.xml b/tests/auto/testlib/selftests/expected_verbose2.xml index 6d592f4a52..94fef3eed7 100644 --- a/tests/auto/testlib/selftests/expected_verbose2.xml +++ b/tests/auto/testlib/selftests/expected_verbose2.xml @@ -2,6 +2,7 @@ <TestCase name="tst_Counting"> <Environment> <QtVersion>@INSERT_QT_VERSION_HERE@</QtVersion> + <QtBuild/> <QTestVersion>@INSERT_QT_VERSION_HERE@</QTestVersion> </Environment> <TestFunction name="initTestCase"> diff --git a/tests/auto/testlib/selftests/expected_verbose2.xunitxml b/tests/auto/testlib/selftests/expected_verbose2.xunitxml index 6dabbd34fc..6764a5564f 100644 --- a/tests/auto/testlib/selftests/expected_verbose2.xunitxml +++ b/tests/auto/testlib/selftests/expected_verbose2.xunitxml @@ -3,6 +3,7 @@ <properties> <property value="@INSERT_QT_VERSION_HERE@" name="QTestVersion"/> <property value="@INSERT_QT_VERSION_HERE@" name="QtVersion"/> + <property value="" name="QtBuild"/> </properties> <testcase result="pass" name="initTestCase"/> <testcase result="pass" name="testPassPass"> diff --git a/tests/auto/testlib/selftests/expected_verifyexceptionthrown.lightxml b/tests/auto/testlib/selftests/expected_verifyexceptionthrown.lightxml index fb8f61503e..d38363fb6e 100644 --- a/tests/auto/testlib/selftests/expected_verifyexceptionthrown.lightxml +++ b/tests/auto/testlib/selftests/expected_verifyexceptionthrown.lightxml @@ -1,5 +1,6 @@ <Environment> <QtVersion>@INSERT_QT_VERSION_HERE@</QtVersion> + <QtBuild/> <QTestVersion>@INSERT_QT_VERSION_HERE@</QTestVersion> </Environment> <TestFunction name="initTestCase"> diff --git a/tests/auto/testlib/selftests/expected_verifyexceptionthrown.xml b/tests/auto/testlib/selftests/expected_verifyexceptionthrown.xml index a89528cfb8..8c57fe5c0f 100644 --- a/tests/auto/testlib/selftests/expected_verifyexceptionthrown.xml +++ b/tests/auto/testlib/selftests/expected_verifyexceptionthrown.xml @@ -2,6 +2,7 @@ <TestCase name="tst_VerifyExceptionThrown"> <Environment> <QtVersion>@INSERT_QT_VERSION_HERE@</QtVersion> + <QtBuild/> <QTestVersion>@INSERT_QT_VERSION_HERE@</QTestVersion> </Environment> <TestFunction name="initTestCase"> diff --git a/tests/auto/testlib/selftests/expected_verifyexceptionthrown.xunitxml b/tests/auto/testlib/selftests/expected_verifyexceptionthrown.xunitxml index f49746a9af..003a31a1cc 100644 --- a/tests/auto/testlib/selftests/expected_verifyexceptionthrown.xunitxml +++ b/tests/auto/testlib/selftests/expected_verifyexceptionthrown.xunitxml @@ -3,6 +3,7 @@ <properties> <property value="@INSERT_QT_VERSION_HERE@" name="QTestVersion"/> <property value="@INSERT_QT_VERSION_HERE@" name="QtVersion"/> + <property value="" name="QtBuild"/> </properties> <testcase result="pass" name="initTestCase"/> <testcase result="pass" name="testCorrectStdTypes"/> diff --git a/tests/auto/testlib/selftests/expected_warnings.lightxml b/tests/auto/testlib/selftests/expected_warnings.lightxml index bbc96b7010..31b3d842aa 100644 --- a/tests/auto/testlib/selftests/expected_warnings.lightxml +++ b/tests/auto/testlib/selftests/expected_warnings.lightxml @@ -1,5 +1,6 @@ <Environment> <QtVersion>@INSERT_QT_VERSION_HERE@</QtVersion> + <QtBuild/> <QTestVersion>@INSERT_QT_VERSION_HERE@</QTestVersion> </Environment> <TestFunction name="initTestCase"> diff --git a/tests/auto/testlib/selftests/expected_warnings.xml b/tests/auto/testlib/selftests/expected_warnings.xml index acb80e4f2a..a3821f84df 100644 --- a/tests/auto/testlib/selftests/expected_warnings.xml +++ b/tests/auto/testlib/selftests/expected_warnings.xml @@ -2,6 +2,7 @@ <TestCase name="tst_Warnings"> <Environment> <QtVersion>@INSERT_QT_VERSION_HERE@</QtVersion> + <QtBuild/> <QTestVersion>@INSERT_QT_VERSION_HERE@</QTestVersion> </Environment> <TestFunction name="initTestCase"> diff --git a/tests/auto/testlib/selftests/expected_warnings.xunitxml b/tests/auto/testlib/selftests/expected_warnings.xunitxml index 7be47174c6..7ea66522c6 100644 --- a/tests/auto/testlib/selftests/expected_warnings.xunitxml +++ b/tests/auto/testlib/selftests/expected_warnings.xunitxml @@ -3,6 +3,7 @@ <properties> <property value="@INSERT_QT_VERSION_HERE@" name="QTestVersion"/> <property value="@INSERT_QT_VERSION_HERE@" name="QtVersion"/> + <property value="" name="QtBuild"/> </properties> <testcase result="pass" name="initTestCase"/> <testcase result="pass" name="testWarnings"> diff --git a/tests/auto/testlib/selftests/expected_xunit.lightxml b/tests/auto/testlib/selftests/expected_xunit.lightxml index 6660cf4e7a..95ab8f03f0 100644 --- a/tests/auto/testlib/selftests/expected_xunit.lightxml +++ b/tests/auto/testlib/selftests/expected_xunit.lightxml @@ -1,5 +1,6 @@ <Environment> <QtVersion>@INSERT_QT_VERSION_HERE@</QtVersion> + <QtBuild/> <QTestVersion>@INSERT_QT_VERSION_HERE@</QTestVersion> </Environment> <TestFunction name="initTestCase"> diff --git a/tests/auto/testlib/selftests/expected_xunit.xml b/tests/auto/testlib/selftests/expected_xunit.xml index af9fe1f502..f56ca947be 100644 --- a/tests/auto/testlib/selftests/expected_xunit.xml +++ b/tests/auto/testlib/selftests/expected_xunit.xml @@ -2,6 +2,7 @@ <TestCase name="tst_Xunit"> <Environment> <QtVersion>@INSERT_QT_VERSION_HERE@</QtVersion> + <QtBuild/> <QTestVersion>@INSERT_QT_VERSION_HERE@</QTestVersion> </Environment> <TestFunction name="initTestCase"> diff --git a/tests/auto/testlib/selftests/expected_xunit.xunitxml b/tests/auto/testlib/selftests/expected_xunit.xunitxml index 7d133da7a5..395b6efdd9 100644 --- a/tests/auto/testlib/selftests/expected_xunit.xunitxml +++ b/tests/auto/testlib/selftests/expected_xunit.xunitxml @@ -3,6 +3,7 @@ <properties> <property value="@INSERT_QT_VERSION_HERE@" name="QTestVersion"/> <property value="@INSERT_QT_VERSION_HERE@" name="QtVersion"/> + <property value="" name="QtBuild"/> </properties> <testcase result="pass" name="initTestCase"/> <testcase result="pass" name="testFunc1"> diff --git a/tests/auto/testlib/selftests/generate_expected_output.py b/tests/auto/testlib/selftests/generate_expected_output.py index 1c09faf4db..8c1de0d8b4 100755 --- a/tests/auto/testlib/selftests/generate_expected_output.py +++ b/tests/auto/testlib/selftests/generate_expected_output.py @@ -56,8 +56,11 @@ isWindows = sys.platform == 'win32' replacements = [ (qtver, r'@INSERT_QT_VERSION_HERE@'), + (r'Config: Using QtTest library.*', r'Config: Using QtTest library'), # Build string in text logs (rootPath.encode('unicode-escape').decode('utf-8'), r''), (r'( *)<Duration msecs="[\d\.]+"/>', r'\1<Duration msecs="0"/>'), + (r'( *)<QtBuild>[^<]+</QtBuild>', r'\1<QtBuild/>'), # Build element in xml, lightxml + (r'<property value="[^"]+" name="QtBuild"/>', r'<property value="" name="QtBuild"/>') # Build in xunitxml ] extraArgs = { diff --git a/tests/auto/testlib/selftests/tst_selftests.cpp b/tests/auto/testlib/selftests/tst_selftests.cpp index 9082561dc9..3e7262a7a0 100644 --- a/tests/auto/testlib/selftests/tst_selftests.cpp +++ b/tests/auto/testlib/selftests/tst_selftests.cpp @@ -169,12 +169,17 @@ QString tst_Selftests::logName(const QString &logger) const return (logger.startsWith("stdout") ? "" : QString(tempDir.path() + "/test_output." + logger)); } +static QString expectedFileNameFromTest(const QString &subdir, const QString &logger) +{ + return QStringLiteral("expected_") + subdir + QLatin1Char('.') + logFormat(logger); +} + // Load the expected test output for the nominated test (subdir) and logger // as an array of lines. If there is no expected output file, return an // empty array. -static QList<QByteArray> expectedResult(const QString &subdir, const QString &logger) +static QList<QByteArray> expectedResult(const QString &fileName) { - QFile file(":/expected_" + subdir + "." + logFormat(logger)); + QFile file(QStringLiteral(":/") + fileName); if (!file.open(QIODevice::ReadOnly)) return QList<QByteArray>(); return splitLines(file.readAll()); @@ -621,7 +626,8 @@ void tst_Selftests::doRunSubTest(QString const& subdir, QStringList const& logge for (int n = 0; n < loggers.count(); ++n) { QString logger = loggers[n]; QList<QByteArray> res = splitLines(actualOutputs[n]); - QList<QByteArray> exp = expectedResult(subdir, logger); + const QString expectedFileName = expectedFileNameFromTest(subdir, logger); + QList<QByteArray> exp = expectedResult(expectedFileName); #if defined (Q_CC_MSVC) || defined(Q_CC_MINGW) // MSVC, MinGW format double numbers differently if (n == 0 && subdir == QStringLiteral("float")) { @@ -640,7 +646,7 @@ void tst_Selftests::doRunSubTest(QString const& subdir, QStringList const& logge QList<QByteArray> tmp; int i = 1; do { - tmp = expectedResult(subdir + QString("_%1").arg(i++), logger); + tmp = expectedResult(expectedFileNameFromTest(subdir + QLatin1Char('_') + QString::number(i++), logger)); if (tmp.count()) expArr += tmp; } while (tmp.count()); @@ -669,8 +675,8 @@ void tst_Selftests::doRunSubTest(QString const& subdir, QStringList const& logge qDebug() << ">>>>>>"; QVERIFY2(res.count() == exp.count(), - qPrintable(QString::fromLatin1("Mismatch in line count: %1 != %2 (%3).") - .arg(res.count()).arg(exp.count()).arg(loggers.at(n)))); + qPrintable(QString::fromLatin1("Mismatch in line count: %1 != %2 (%3, %4).") + .arg(res.count()).arg(exp.count()).arg(loggers.at(n), expectedFileName))); } } @@ -713,6 +719,12 @@ void tst_Selftests::doRunSubTest(QString const& subdir, QStringList const& logge if (line.endsWith(" : failure location")) continue; + if (line.startsWith("Config: Using QtTest library") // Text build string + || line.startsWith(" <QtBuild") // XML, Light XML build string + || (line.startsWith(" <property value=") && line.endsWith("name=\"QtBuild\"/>"))) { // XUNIT-XML build string + continue; + } + const QString output(QString::fromLatin1(line)); const QString expected(QString::fromLatin1(exp.at(i)).replace("@INSERT_QT_VERSION_HERE@", QT_VERSION_STR)); @@ -742,8 +754,8 @@ void tst_Selftests::doRunSubTest(QString const& subdir, QStringList const& logge .arg(i).arg(loggers.at(n), output))); } else { QVERIFY2(output == expected, - qPrintable(QString::fromLatin1("Mismatch at line %1 (%2): '%3' != '%4'") - .arg(i).arg(loggers.at(n), output, expected))); + qPrintable(QString::fromLatin1("Mismatch at line %1 (%2, %3): '%4' != '%5'") + .arg(i + 1).arg(loggers.at(n), expectedFileName, output, expected))); } benchmark = line.startsWith("RESULT : "); diff --git a/tests/auto/tools/moc/tst_moc.cpp b/tests/auto/tools/moc/tst_moc.cpp index 2e1504383f..9a737ef96b 100644 --- a/tests/auto/tools/moc/tst_moc.cpp +++ b/tests/auto/tools/moc/tst_moc.cpp @@ -174,6 +174,9 @@ class TestClassinfoWithEscapes: public QObject Q_OBJECT Q_CLASSINFO("escaped", "\"bar\"") Q_CLASSINFO("\"escaped\"", "foo") + Q_CLASSINFO("cpp c*/omment", "f/*oo") + Q_CLASSINFO("endswith\\", "Or?\?/") + Q_CLASSINFO("newline\n inside\n", "Or \r") public slots: void slotWithAReallyLongName(int) { } @@ -800,6 +803,14 @@ void tst_Moc::classinfoWithEscapes() const QMetaObject *mobj = &TestClassinfoWithEscapes::staticMetaObject; QCOMPARE(mobj->methodCount() - mobj->methodOffset(), 1); + QCOMPARE(mobj->classInfoCount(), 5); + QCOMPARE(mobj->classInfo(2).name(), "cpp c*/omment"); + QCOMPARE(mobj->classInfo(2).value(), "f/*oo"); + QCOMPARE(mobj->classInfo(3).name(), "endswith\\"); + QCOMPARE(mobj->classInfo(3).value(), "Or?\?/"); + QCOMPARE(mobj->classInfo(4).name(), "newline\n inside\n"); + QCOMPARE(mobj->classInfo(4).value(), "Or \r"); + QMetaMethod mm = mobj->method(mobj->methodOffset()); QCOMPARE(mm.methodSignature(), QByteArray("slotWithAReallyLongName(int)")); } diff --git a/tests/auto/tools/rcc/data/images/images.expected b/tests/auto/tools/rcc/data/images/images.expected index 9334443ccc..2577b6319b 100644 --- a/tests/auto/tools/rcc/data/images/images.expected +++ b/tests/auto/tools/rcc/data/images/images.expected @@ -1,13 +1,11 @@ /**************************************************************************** ** Resource object code ** -IGNORE: ** Created by: The Resource Compiler for Qt version 5.0.0 +IGNORE: ** Created by: The Resource Compiler for Qt version 5.3.1 ** ** WARNING! All changes made in this file will be lost! *****************************************************************************/ -#include <QtCore/qglobal.h> - static const unsigned char qt_resource_data[] = { IGNORE: // /dev/qt5/qtbase/tests/auto/tools/rcc/data/images/images/circle.png 0x0,0x0,0x0,0xa5, @@ -94,16 +92,29 @@ static const unsigned char qt_resource_struct[] = { }; -QT_BEGIN_NAMESPACE +#ifdef QT_NAMESPACE +# define QT_PREPEND_NAMESPACE(name) ::QT_NAMESPACE::name +# define QT_MANGLE_NAMESPACE0(x) x +# define QT_MANGLE_NAMESPACE1(a, b) a##_##b +# define QT_MANGLE_NAMESPACE2(a, b) QT_MANGLE_NAMESPACE1(a,b) +# define QT_MANGLE_NAMESPACE(name) QT_MANGLE_NAMESPACE2( \ + QT_MANGLE_NAMESPACE0(name), QT_MANGLE_NAMESPACE0(QT_NAMESPACE)) +#else +# define QT_PREPEND_NAMESPACE(name) name +# define QT_MANGLE_NAMESPACE(name) name +#endif -extern Q_CORE_EXPORT bool qRegisterResourceData - (int, const unsigned char *, const unsigned char *, const unsigned char *); +#ifdef QT_NAMESPACE +namespace QT_NAMESPACE { +#endif -extern Q_CORE_EXPORT bool qUnregisterResourceData - (int, const unsigned char *, const unsigned char *, const unsigned char *); +bool qRegisterResourceData(int, const unsigned char *, const unsigned char *, const unsigned char *); -QT_END_NAMESPACE +bool qUnregisterResourceData(int, const unsigned char *, const unsigned char *, const unsigned char *); +#ifdef QT_NAMESPACE +} +#endif int QT_MANGLE_NAMESPACE(qInitResources)() { @@ -112,8 +123,6 @@ int QT_MANGLE_NAMESPACE(qInitResources)() return 1; } -Q_CONSTRUCTOR_FUNCTION(QT_MANGLE_NAMESPACE(qInitResources)) - int QT_MANGLE_NAMESPACE(qCleanupResources)() { QT_PREPEND_NAMESPACE(qUnregisterResourceData) @@ -121,5 +130,9 @@ int QT_MANGLE_NAMESPACE(qCleanupResources)() return 1; } -Q_DESTRUCTOR_FUNCTION(QT_MANGLE_NAMESPACE(qCleanupResources)) - +namespace { + struct initializer { + initializer() { QT_MANGLE_NAMESPACE(qInitResources)(); } + ~initializer() { QT_MANGLE_NAMESPACE(qCleanupResources)(); } + } dummy; +} diff --git a/tests/auto/widgets/graphicsview/qgraphicsitem/tst_qgraphicsitem.cpp b/tests/auto/widgets/graphicsview/qgraphicsitem/tst_qgraphicsitem.cpp index e9aae1ec59..c89b05616d 100644 --- a/tests/auto/widgets/graphicsview/qgraphicsitem/tst_qgraphicsitem.cpp +++ b/tests/auto/widgets/graphicsview/qgraphicsitem/tst_qgraphicsitem.cpp @@ -389,6 +389,8 @@ private slots: void itemClipsChildrenToShape5(); void itemClipsTextChildToShape(); void itemClippingDiscovery(); + void itemContainsChildrenInShape(); + void itemContainsChildrenInShape2(); void ancestorFlags(); void untransformable(); void contextMenuEventPropagation(); @@ -5855,6 +5857,102 @@ void tst_QGraphicsItem::itemClippingDiscovery() QCOMPARE(scene.itemAt(90, 90), (QGraphicsItem *)0); } +class ItemCountsBoundingRectCalls : public QGraphicsRectItem +{ +public: + ItemCountsBoundingRectCalls(const QRectF & rect, QGraphicsItem *parent = 0) + : QGraphicsRectItem(rect, parent), boundingRectCalls(0) {} + QRectF boundingRect () const { + ++boundingRectCalls; + return QGraphicsRectItem::boundingRect(); + } + mutable int boundingRectCalls; +}; + +void tst_QGraphicsItem::itemContainsChildrenInShape() +{ + ItemCountsBoundingRectCalls *parent = new ItemCountsBoundingRectCalls(QRectF(0,0, 10, 10)); + ItemCountsBoundingRectCalls *childOutsideShape = new ItemCountsBoundingRectCalls(QRectF(0,0, 10, 10), parent); + childOutsideShape->setPos(20,0); + + QGraphicsScene scene; + scene.setItemIndexMethod(QGraphicsScene::NoIndex); + scene.addItem(parent); + + QVERIFY(parent->boundingRectCalls == childOutsideShape->boundingRectCalls); + + int oldParentBoundingRectCalls = parent->boundingRectCalls; + int oldChildBoundingRectCalls = childOutsideShape->boundingRectCalls; + + // First test that both items are searched if no optimization flags are set + QGraphicsItem* item = scene.itemAt(25,5); + + QVERIFY(item == childOutsideShape); + QVERIFY(parent->boundingRectCalls > oldParentBoundingRectCalls); + QVERIFY(childOutsideShape->boundingRectCalls > oldChildBoundingRectCalls); + QVERIFY(parent->boundingRectCalls == childOutsideShape->boundingRectCalls); + + oldParentBoundingRectCalls = parent->boundingRectCalls; + oldChildBoundingRectCalls = childOutsideShape->boundingRectCalls; + + // Repeat the test to make sure that no caching/indexing is in effect + item = scene.itemAt(25,5); + + QVERIFY(item == childOutsideShape); + QVERIFY(parent->boundingRectCalls > oldParentBoundingRectCalls); + QVERIFY(childOutsideShape->boundingRectCalls > oldChildBoundingRectCalls); + QVERIFY(parent->boundingRectCalls == childOutsideShape->boundingRectCalls); + + oldParentBoundingRectCalls = parent->boundingRectCalls; + oldChildBoundingRectCalls = childOutsideShape->boundingRectCalls; + + // Set the optimization flag and make sure that the child is not returned + // and that the child's boundingRect() method is never called. + parent->setFlag(QGraphicsItem::ItemContainsChildrenInShape); + item = scene.itemAt(25,5); + + QVERIFY(!(item)); + QVERIFY(parent->boundingRectCalls > oldParentBoundingRectCalls); + QVERIFY(childOutsideShape->boundingRectCalls == oldChildBoundingRectCalls); + QVERIFY(parent->boundingRectCalls > childOutsideShape->boundingRectCalls); +} + +void tst_QGraphicsItem::itemContainsChildrenInShape2() +{ + //The tested flag behaves almost identically to ItemClipsChildrenToShape + //in terms of optimizations but does not enforce the clip. + //This test makes sure there is no clip. + QGraphicsScene scene; + QGraphicsItem *rect = scene.addRect(0, 0, 50, 50, QPen(Qt::NoPen), QBrush(Qt::yellow)); + + QGraphicsItem *ellipse = scene.addEllipse(0, 0, 100, 100, QPen(Qt::NoPen), QBrush(Qt::green)); + ellipse->setParentItem(rect); + + QGraphicsItem *clippedEllipse = scene.addEllipse(0, 0, 50, 50, QPen(Qt::NoPen), QBrush(Qt::blue)); + clippedEllipse->setParentItem(ellipse); + + QGraphicsItem *clippedEllipse2 = scene.addEllipse(0, 0, 25, 25, QPen(Qt::NoPen), QBrush(Qt::red)); + clippedEllipse2->setParentItem(clippedEllipse); + + QVERIFY(!(ellipse->flags() & QGraphicsItem::ItemClipsChildrenToShape)); + QVERIFY(!(ellipse->flags() & QGraphicsItem::ItemContainsChildrenInShape)); + ellipse->setFlags(QGraphicsItem::ItemContainsChildrenInShape); + QVERIFY(!(ellipse->flags() & QGraphicsItem::ItemClipsChildrenToShape)); + QVERIFY((ellipse->flags() & QGraphicsItem::ItemContainsChildrenInShape)); + + QImage image(100, 100, QImage::Format_ARGB32_Premultiplied); + image.fill(0); + QPainter painter(&image); + painter.setRenderHint(QPainter::Antialiasing); + scene.render(&painter); + painter.end(); + + QCOMPARE(image.pixel(2, 2), QColor(Qt::yellow).rgba()); + QCOMPARE(image.pixel(12, 12), QColor(Qt::red).rgba()); + QCOMPARE(image.pixel(2, 25), QColor(Qt::blue).rgba()); + QCOMPARE(image.pixel(2, 50), QColor(Qt::green).rgba()); +} + void tst_QGraphicsItem::ancestorFlags() { QGraphicsItem *level1 = new QGraphicsRectItem; @@ -5975,11 +6073,27 @@ void tst_QGraphicsItem::ancestorFlags() // Nobody handles child events level21->setHandlesChildEvents(false); - for (int i = 0; i < 2; ++i) { - QGraphicsItem::GraphicsItemFlag flag = !i ? QGraphicsItem::ItemClipsChildrenToShape - : QGraphicsItem::ItemIgnoresTransformations; - int ancestorFlag = !i ? QGraphicsItemPrivate::AncestorClipsChildren - : QGraphicsItemPrivate::AncestorIgnoresTransformations; + for (int i = 0; i < 3; ++i) { + QGraphicsItem::GraphicsItemFlag flag; + int ancestorFlag; + + switch (i) { + case(0): + flag = QGraphicsItem::ItemClipsChildrenToShape; + ancestorFlag = QGraphicsItemPrivate::AncestorClipsChildren; + break; + case(1): + flag = QGraphicsItem::ItemIgnoresTransformations; + ancestorFlag = QGraphicsItemPrivate::AncestorIgnoresTransformations; + break; + case(2): + flag = QGraphicsItem::ItemContainsChildrenInShape; + ancestorFlag = QGraphicsItemPrivate::AncestorContainsChildren; + break; + default: + qFatal("Unknown ancestor flag, please fix!"); + break; + } QCOMPARE(int(level1->d_ptr->ancestorFlags), 0); QCOMPARE(int(level21->d_ptr->ancestorFlags), 0); diff --git a/tests/auto/widgets/graphicsview/qgraphicsscene/tst_qgraphicsscene.cpp b/tests/auto/widgets/graphicsview/qgraphicsscene/tst_qgraphicsscene.cpp index dfc8465210..a4752126bc 100644 --- a/tests/auto/widgets/graphicsview/qgraphicsscene/tst_qgraphicsscene.cpp +++ b/tests/auto/widgets/graphicsview/qgraphicsscene/tst_qgraphicsscene.cpp @@ -267,6 +267,7 @@ private slots: void removeFullyTransparentItem(); void zeroScale(); void focusItemChangedSignal(); + void minimumRenderSize(); // task specific tests below me void task139710_bspTreeCrash(); @@ -4678,6 +4679,78 @@ void tst_QGraphicsScene::focusItemChangedSignal() } +class ItemCountsPaintCalls : public QGraphicsRectItem +{ +public: + ItemCountsPaintCalls(const QRectF & rect, QGraphicsItem *parent = 0) + : QGraphicsRectItem(rect, parent), repaints(0) {} + void paint ( QPainter * painter, const QStyleOptionGraphicsItem * option, QWidget * widget = 0 ) + { + QGraphicsRectItem::paint(painter, option, widget); + ++repaints; + } + int repaints; +}; + +void tst_QGraphicsScene::minimumRenderSize() +{ + Q_CHECK_PAINTEVENTS + + ItemCountsPaintCalls *bigParent = new ItemCountsPaintCalls(QRectF(0,0,100,100)); + ItemCountsPaintCalls *smallChild = new ItemCountsPaintCalls(QRectF(0,0,10,10), bigParent); + ItemCountsPaintCalls *smallerGrandChild = new ItemCountsPaintCalls(QRectF(0,0,1,1), smallChild); + QGraphicsScene scene; + scene.addItem(bigParent); + + CustomView view; + view.setScene(&scene); + view.show(); + QVERIFY(QTest::qWaitForWindowExposed(&view)); + qApp->processEvents(); + + // Initially, everything should be repainted the same number of times + int viewRepaints = 0; + QTRY_VERIFY(view.repaints > viewRepaints); + viewRepaints = view.repaints; + + QVERIFY(viewRepaints == bigParent->repaints); + QVERIFY(viewRepaints == smallChild->repaints); + QVERIFY(viewRepaints == smallerGrandChild->repaints); + + // Setting a minimum render size should cause a repaint + scene.setMinimumRenderSize(0.5); + qApp->processEvents(); + + QTRY_VERIFY(view.repaints > viewRepaints); + viewRepaints = view.repaints; + + QVERIFY(viewRepaints == bigParent->repaints); + QVERIFY(viewRepaints == smallChild->repaints); + QVERIFY(viewRepaints == smallerGrandChild->repaints); + + // Scaling should cause a repaint of big items only. + view.scale(0.1, 0.1); + qApp->processEvents(); + + QTRY_VERIFY(view.repaints > viewRepaints); + viewRepaints = view.repaints; + + QVERIFY(viewRepaints == bigParent->repaints); + QVERIFY(viewRepaints == smallChild->repaints); + QVERIFY(smallChild->repaints > smallerGrandChild->repaints); + + // Scaling further should cause even fewer items to be repainted + view.scale(0.1, 0.1); // Stacks with previous scale + qApp->processEvents(); + + QTRY_VERIFY(view.repaints > viewRepaints); + viewRepaints = view.repaints; + + QVERIFY(viewRepaints == bigParent->repaints); + QVERIFY(bigParent->repaints > smallChild->repaints); + QVERIFY(smallChild->repaints > smallerGrandChild->repaints); +} + void tst_QGraphicsScene::taskQTBUG_15977_renderWithDeviceCoordinateCache() { QGraphicsScene scene; diff --git a/tests/auto/widgets/itemviews/qabstractitemview/tst_qabstractitemview.cpp b/tests/auto/widgets/itemviews/qabstractitemview/tst_qabstractitemview.cpp index daca1d1516..237d4f8a29 100644 --- a/tests/auto/widgets/itemviews/qabstractitemview/tst_qabstractitemview.cpp +++ b/tests/auto/widgets/itemviews/qabstractitemview/tst_qabstractitemview.cpp @@ -248,6 +248,7 @@ private slots: void testFocusPolicy_data(); void testFocusPolicy(); void QTBUG31411_noSelection(); + void QTBUG39324_settingSameInstanceOfIndexWidget(); }; class MyAbstractItemDelegate : public QAbstractItemDelegate @@ -1830,5 +1831,22 @@ void tst_QAbstractItemView::QTBUG31411_noSelection() QCOMPARE(selectionChangeSpy.count(), 0); } +void tst_QAbstractItemView::QTBUG39324_settingSameInstanceOfIndexWidget() +{ + QStringList list; + list << "FOO" << "bar"; + QScopedPointer<QStringListModel> model(new QStringListModel(list)); + + QScopedPointer<QTableView> table(new QTableView()); + table->setModel(model.data()); + + QModelIndex index = model->index(0,0); + QLineEdit *lineEdit = new QLineEdit(); + table->setIndexWidget(index, lineEdit); + table->setIndexWidget(index, lineEdit); + QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete); + table->show(); +} + QTEST_MAIN(tst_QAbstractItemView) #include "tst_qabstractitemview.moc" diff --git a/tests/auto/widgets/itemviews/qtableview/tst_qtableview.cpp b/tests/auto/widgets/itemviews/qtableview/tst_qtableview.cpp index 38367fb4ee..33af273284 100644 --- a/tests/auto/widgets/itemviews/qtableview/tst_qtableview.cpp +++ b/tests/auto/widgets/itemviews/qtableview/tst_qtableview.cpp @@ -178,6 +178,8 @@ private slots: void spansAfterColumnInsertion(); void spansAfterRowRemoval(); void spansAfterColumnRemoval(); + void editSpanFromDirections_data(); + void editSpanFromDirections(); void checkHeaderReset(); void checkHeaderMinSize(); @@ -1240,28 +1242,28 @@ void tst_QTableView::moveCursorStrikesBack_data() << IntList() << QRect(1, 2, 2, 3) << 2 << 0 << (IntList() << int(QtTestTableView::MoveNext)) - << 2 << 2; + << 2 << 1; QTest::newRow("Span, anchor column disabled") << -1 << -1 << IntList() << (IntList() << 1) << QRect(1, 2, 2, 3) << 2 << 0 << (IntList() << int(QtTestTableView::MoveNext)) - << 2 << 2; + << 2 << 1; QTest::newRow("Span, anchor row hidden") << 2 << -1 << IntList() << IntList() << QRect(1, 2, 2, 3) << 1 << 2 << (IntList() << int(QtTestTableView::MoveDown)) - << 3 << 2; + << 2 << 1; QTest::newRow("Span, anchor row disabled") << -1 << -1 << (IntList() << 2) << IntList() << QRect(1, 2, 2, 3) << 1 << 2 << (IntList() << int(QtTestTableView::MoveDown)) - << 3 << 2; + << 2 << 1; QTest::newRow("Move through span right") << -1 << -1 << IntList() @@ -3278,6 +3280,159 @@ void tst_QTableView::spansAfterColumnRemoval() VERIFY_SPANS_CONSISTENCY(&view); } +Q_DECLARE_METATYPE(Qt::Key) + +void tst_QTableView::editSpanFromDirections_data() +{ + QTest::addColumn<QList<Qt::Key> >("keyPresses"); + QTest::addColumn<QSharedPointer<QStandardItemModel> >("model"); + QTest::addColumn<int>("row"); + QTest::addColumn<int>("column"); + QTest::addColumn<int>("rowSpan"); + QTest::addColumn<int>("columnSpan"); + QTest::addColumn<QModelIndex>("expectedVisualCursorIndex"); + QTest::addColumn<QModelIndex>("expectedEditedIndex"); + + /* x = the cell that should be edited + c = the cell that should actually be the current index + +---+---+ + | | | + +---+---+ + | | x | + +---+ + + | | c | + +---+---+ + | | ^ | + +---+---+ */ + QList<Qt::Key> keyPresses; + keyPresses << Qt::Key_Right << Qt::Key_PageDown << Qt::Key_Up; + QSharedPointer<QStandardItemModel> model(new QStandardItemModel(4, 2)); + QTest::newRow("row span, bottom up") + << keyPresses << model << 1 << 1 << 2 << 1 << model->index(2, 1) << model->index(1, 1); + + /* +---+---+ + | | v | + +---+---+ + | |x,c| + +---+ + + | | | + +---+---+ + | | | + +---+---+ */ + keyPresses.clear(); + keyPresses << Qt::Key_Right << Qt::Key_Down; + model.reset(new QStandardItemModel(4, 2)); + QTest::newRow("row span, top down") + << keyPresses << model << 1 << 1 << 2 << 1 << model->index(1, 1) << model->index(1, 1); + + /* +---+---+---+ + | | | | + +---+---+---+ + | |x,c| < | + +---+ +---+ + | | | | + +---+---+---+ */ + keyPresses.clear(); + keyPresses << Qt::Key_End << Qt::Key_Down << Qt::Key_Left; + model.reset(new QStandardItemModel(3, 3)); + QTest::newRow("row span, right to left") + << keyPresses << model << 1 << 1 << 2 << 1 << model->index(1, 1) << model->index(1, 1); + + /* +---+---+---+ + | | | | + +---+---+---+ + | | x | | + +---+ +---+ + | > | c | | + +---+---+---+ */ + keyPresses.clear(); + keyPresses << Qt::Key_PageDown << Qt::Key_Right; + model.reset(new QStandardItemModel(3, 3)); + QTest::newRow("row span, left to right") + << keyPresses << model << 1 << 1 << 2 << 1 << model->index(2, 1) << model->index(1, 1); + + /* +---+---+---+ + | | | | + +---+---+---+ + |x,c | + +---+---+---+ + | ^ | | | + +---+---+---+ */ + keyPresses.clear(); + keyPresses << Qt::Key_PageDown << Qt::Key_Up; + model.reset(new QStandardItemModel(3, 3)); + QTest::newRow("col span, bottom up") + << keyPresses << model << 1 << 0 << 1 << 3 << model->index(1, 0) << model->index(1, 0); + + /* +---+---+---+ + | | | | + +---+---+---+ + | x c | + +---+---+---+ + | | ^ | | + +---+---+---+ */ + keyPresses.clear(); + keyPresses << Qt::Key_PageDown << Qt::Key_Right << Qt::Key_Up; + model.reset(new QStandardItemModel(3, 3)); + QTest::newRow("col span, bottom up #2") + << keyPresses << model << 1 << 0 << 1 << 3 << model->index(1, 1) << model->index(1, 0); + + /* +---+---+---+ + | | | v | + +---+---+---+ + | x c | + +---+---+---+ + | | | | + +---+---+---+ */ + keyPresses.clear(); + keyPresses << Qt::Key_End << Qt::Key_Down; + model.reset(new QStandardItemModel(3, 3)); + QTest::newRow("col span, top down") + << keyPresses << model << 1 << 0 << 1 << 3 << model->index(1, 2) << model->index(1, 0); +} + +class TableViewWithCursorExposed : public QTableView +{ +public: + TableViewWithCursorExposed() : + QTableView() { + } + +public: + QModelIndex visualCursorIndex() { + QTableViewPrivate *d = static_cast<QTableViewPrivate*>(qt_widget_private(this)); + return d->model->index(d->visualCursor.y(), d->visualCursor.x()); + } +}; + +void tst_QTableView::editSpanFromDirections() +{ + QFETCH(QList<Qt::Key>, keyPresses); + QFETCH(QSharedPointer<QStandardItemModel>, model); + QFETCH(int, row); + QFETCH(int, column); + QFETCH(int, rowSpan); + QFETCH(int, columnSpan); + QFETCH(QModelIndex, expectedVisualCursorIndex); + QFETCH(QModelIndex, expectedEditedIndex); + + TableViewWithCursorExposed view; + view.setModel(model.data()); + view.setSpan(row, column, rowSpan, columnSpan); + view.show(); + QVERIFY(QTest::qWaitForWindowActive(&view)); + + foreach (Qt::Key key, keyPresses) { + QTest::keyClick(&view, key); + } + QCOMPARE(view.visualCursorIndex(), expectedVisualCursorIndex); + QCOMPARE(view.selectionModel()->currentIndex(), expectedEditedIndex); + + QTest::keyClick(&view, Qt::Key_X); + QTest::keyClick(QApplication::focusWidget(), Qt::Key_Enter); + QTRY_COMPARE(view.model()->data(expectedEditedIndex).toString(), QLatin1String("x")); +} + class Model : public QAbstractTableModel { Q_OBJECT diff --git a/tests/auto/widgets/kernel/qwidget_window/tst_qwidget_window.cpp b/tests/auto/widgets/kernel/qwidget_window/tst_qwidget_window.cpp index d6b7fc20ed..1809cdc16a 100644 --- a/tests/auto/widgets/kernel/qwidget_window/tst_qwidget_window.cpp +++ b/tests/auto/widgets/kernel/qwidget_window/tst_qwidget_window.cpp @@ -107,8 +107,7 @@ void tst_QWidget_window::cleanupTestCase() } /* Test if the maximum/minimum size constraints - * are propagated from the wid src/widgets/kernel/qwidgetwindow_qpa_p.h -get to the QWidgetWindow + * are propagated from the widget to the QWidgetWindow * independently of whether they were set before or after * window creation (QTBUG-26745). */ diff --git a/tests/auto/widgets/widgets/qspinbox/tst_qspinbox.cpp b/tests/auto/widgets/widgets/qspinbox/tst_qspinbox.cpp index 21034e8f1b..350ae23d8a 100644 --- a/tests/auto/widgets/widgets/qspinbox/tst_qspinbox.cpp +++ b/tests/auto/widgets/widgets/qspinbox/tst_qspinbox.cpp @@ -393,18 +393,31 @@ void tst_QSpinBox::valueChangedHelper(int value) actualValues << value; } +class MySpinBox: public QSpinBox +{ +public: + MySpinBox(QWidget *parent = 0) : QSpinBox(parent) {} + + void changeEvent(QEvent *ev) { + eventsReceived.append(ev->type()); + } + QList<QEvent::Type> eventsReceived; +}; + void tst_QSpinBox::setReadOnly() { - QSpinBox spin(0); + MySpinBox spin(0); spin.show(); QTest::keyClick(&spin, Qt::Key_Up); QCOMPARE(spin.value(), 1); spin.setReadOnly(true); + QCOMPARE(spin.eventsReceived, QList<QEvent::Type>() << QEvent::ReadOnlyChange); QTest::keyClick(&spin, Qt::Key_Up); QCOMPARE(spin.value(), 1); spin.stepBy(1); QCOMPARE(spin.value(), 2); spin.setReadOnly(false); + QCOMPARE(spin.eventsReceived, QList<QEvent::Type>() << QEvent::ReadOnlyChange << QEvent::ReadOnlyChange); QTest::keyClick(&spin, Qt::Key_Up); QCOMPARE(spin.value(), 3); } diff --git a/tests/manual/cocoa/qt_on_cocoa/main.mm b/tests/manual/cocoa/qt_on_cocoa/main.mm index 9a39788b02..7b4d4dd8d5 100644 --- a/tests/manual/cocoa/qt_on_cocoa/main.mm +++ b/tests/manual/cocoa/qt_on_cocoa/main.mm @@ -43,7 +43,7 @@ #include <QtDeclarative> #include <QtWidgets/QtWidgets> -#include <private/qwidgetwindow_qpa_p.h> +#include <private/qwidgetwindow_p.h> #include <QtGui/qpa/qplatformnativeinterface.h> #include <QtGui/QPixmap> diff --git a/tests/manual/manual.pro b/tests/manual/manual.pro index 9318824e6d..e593756a7d 100644 --- a/tests/manual/manual.pro +++ b/tests/manual/manual.pro @@ -47,7 +47,10 @@ unc !contains(QT_CONFIG, openssl):!contains(QT_CONFIG, openssl-linked):SUBDIRS -= qssloptions -contains(QT_CONFIG, opengl):SUBDIRS += qopengltextureblitter +contains(QT_CONFIG, opengl) { + SUBDIRS += qopengltextureblitter + contains(QT_CONFIG, egl): SUBDIRS += qopenglcontext +} win32 { SUBDIRS -= network_remote_stresstest network_stresstest diff --git a/tests/manual/qopenglcontext/main.cpp b/tests/manual/qopenglcontext/main.cpp new file mode 100644 index 0000000000..dd3178f466 --- /dev/null +++ b/tests/manual/qopenglcontext/main.cpp @@ -0,0 +1,54 @@ +/**************************************************************************** +** +** Copyright (C) 2014 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/QGuiApplication> +#include "qopenglcontextwindow.h" + +int main(int argc, char **argv) +{ + QGuiApplication app(argc, argv); + + QOpenGLContextWindow window; + window.resize(300, 300); + window.show(); + + return app.exec(); +} diff --git a/tests/manual/qopenglcontext/qopenglcontext.pro b/tests/manual/qopenglcontext/qopenglcontext.pro new file mode 100644 index 0000000000..c5943809c6 --- /dev/null +++ b/tests/manual/qopenglcontext/qopenglcontext.pro @@ -0,0 +1,9 @@ +TEMPLATE = app +TARGET = qopenglcontext + +QT += gui-private platformsupport-private + +HEADERS += $$PWD/qopenglcontextwindow.h + +SOURCES += $$PWD/main.cpp \ + $$PWD/qopenglcontextwindow.cpp diff --git a/tests/manual/qopenglcontext/qopenglcontextwindow.cpp b/tests/manual/qopenglcontext/qopenglcontextwindow.cpp new file mode 100644 index 0000000000..bf6fe30c00 --- /dev/null +++ b/tests/manual/qopenglcontext/qopenglcontextwindow.cpp @@ -0,0 +1,173 @@ +/**************************************************************************** +** +** Copyright (C) 2014 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 "qopenglcontextwindow.h" +#include <QtGui/QOpenGLFunctions> +#include <QtGui/QOffscreenSurface> +#include <QtGui/QGuiApplication> +#include <QtGui/QMatrix4x4> +#include <qpa/qplatformnativeinterface.h> + +#include <QtPlatformSupport/private/qeglconvenience_p.h> +#include <QtPlatformHeaders/QEGLNativeContext> + +QOpenGLContextWindow::QOpenGLContextWindow() + : m_blitter(0) +{ + setSurfaceType(OpenGLSurface); + + m_context = new QOpenGLContext(this); + m_context->setFormat(requestedFormat()); + m_context->create(); + + m_image = QImage(QStringLiteral("qticon64.png")).convertToFormat(QImage::Format_RGBA8888); + Q_ASSERT(!m_image.isNull()); + + create(); // to make sure format() returns something real + createForeignContext(); +} + +QOpenGLContextWindow::~QOpenGLContextWindow() +{ + if (m_blitter) { + m_blitter->destroy(); // the dtor does not call this for some reason + delete m_blitter; + } +} + +void QOpenGLContextWindow::render() +{ + if (!m_context->makeCurrent(this)) + qFatal("makeCurrent() failed"); + + QOpenGLFunctions *f = m_context->functions(); + f->glViewport(0, 0, dWidth(), dHeight()); + f->glClearColor(0, 0, 0, 1); + f->glClear(GL_COLOR_BUFFER_BIT); + + if (!m_blitter) { + m_blitter = new QOpenGLTextureBlitter; + m_blitter->create(); + } + + // Draw the image. If nothing gets shown, then something went wrong with the context + // adoption or sharing was not successfully enabled. + m_blitter->bind(); + QRectF r(0, 0, dWidth(), dHeight()); + QMatrix4x4 target = QOpenGLTextureBlitter::targetTransform(QRectF(100, 100, 100, 100), r.toRect()); + m_blitter->blit(m_textureId, target, QOpenGLTextureBlitter::OriginTopLeft); + m_blitter->release(); + + m_context->swapBuffers(this); +} + +void QOpenGLContextWindow::exposeEvent(QExposeEvent *) +{ + if (isExposed()) + render(); +} + +void QOpenGLContextWindow::createForeignContext() +{ + // Here a context will be created manually. This context will share with m_context's + // underlying native context. This way the texture, that belongs to the context + // created here, will be accessible from m_context too. + + EGLContext shareCtx = m_context->nativeHandle().value<QEGLNativeContext>().context(); + Q_ASSERT(shareCtx != EGL_NO_CONTEXT); + + EGLDisplay dpy = (EGLDisplay) qGuiApp->platformNativeInterface()->nativeResourceForWindow( + QByteArrayLiteral("egldisplay"), this); + Q_ASSERT(dpy != EGL_NO_DISPLAY); + + QSurfaceFormat fmt = format(); + EGLConfig config = q_configFromGLFormat(dpy, fmt); + + QVector<EGLint> contextAttrs; + contextAttrs.append(EGL_CONTEXT_CLIENT_VERSION); + contextAttrs.append(fmt.majorVersion()); + contextAttrs.append(EGL_NONE); + switch (fmt.renderableType()) { +#ifdef EGL_VERSION_1_4 + case QSurfaceFormat::OpenGL: + eglBindAPI(EGL_OPENGL_API); + break; +#endif // EGL_VERSION_1_4 + default: + eglBindAPI(EGL_OPENGL_ES_API); + break; + } + + EGLContext ctx = eglCreateContext(dpy, config, shareCtx, contextAttrs.constData()); + Q_ASSERT(ctx != EGL_NO_CONTEXT); + + // Wrap ctx into a QOpenGLContext. + QOpenGLContext *ctxWrap = new QOpenGLContext; + ctxWrap->setNativeHandle(QVariant::fromValue<QEGLNativeContext>(QEGLNativeContext(ctx, dpy))); + ctxWrap->setShareContext(m_context); // only needed for correct bookkeeping + if (!ctxWrap->create()) + qFatal("Failed to created wrapping context"); + Q_ASSERT(ctxWrap->nativeHandle().value<QEGLNativeContext>().context() == ctx); + + QOffscreenSurface surface; + surface.setFormat(fmt); + surface.create(); + + if (!ctxWrap->makeCurrent(&surface)) + qFatal("Failed to make pbuffer surface current"); + + // Create the texture. + QOpenGLFunctions *f = QOpenGLContext::currentContext()->functions(); + GLuint textureId = 0; + f->glGenTextures(1, &textureId); + f->glBindTexture(GL_TEXTURE_2D, textureId); + f->glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); + f->glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, m_image.width(), m_image.height(), 0, GL_RGBA, GL_UNSIGNED_BYTE, + m_image.constBits()); + Q_ASSERT(f->glGetError() == GL_NO_ERROR); + + ctxWrap->doneCurrent(); + delete ctxWrap; // ctx is not destroyed + eglDestroyContext(dpy, ctx); // resources like the texture stay alive until any context on the share list is alive + Q_ASSERT(eglGetError() == EGL_SUCCESS); + + m_textureId = textureId; +} diff --git a/tests/manual/qopenglcontext/qopenglcontextwindow.h b/tests/manual/qopenglcontext/qopenglcontextwindow.h new file mode 100644 index 0000000000..6fcb3633bf --- /dev/null +++ b/tests/manual/qopenglcontext/qopenglcontextwindow.h @@ -0,0 +1,76 @@ +/**************************************************************************** +** +** Copyright (C) 2014 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$ +** +****************************************************************************/ + +#ifndef QOPENGLCONTEXTWINDOW_H +#define QOPENGLCONTEXTWINDOW_H + +#include <QtGui/QWindow> +#include <QtGui/QOpenGLContext> +#include <QtGui/QImage> +#include <QtCore/QVariant> +#include <QtGui/private/qopengltextureblitter_p.h> + +class QOpenGLContextWindow : public QWindow +{ + Q_OBJECT + +public: + QOpenGLContextWindow(); + ~QOpenGLContextWindow(); + + void render(); + +protected: + void exposeEvent(QExposeEvent *event); + +private: + qreal dWidth() const { return width() * devicePixelRatio(); } + qreal dHeight() const { return height() * devicePixelRatio(); } + void createForeignContext(); + + QOpenGLContext *m_context; + QImage m_image; + QVariant m_nativeHandle; + uint m_textureId; + QOpenGLTextureBlitter *m_blitter; +}; + +#endif diff --git a/tests/manual/qopenglcontext/qticon64.png b/tests/manual/qopenglcontext/qticon64.png Binary files differnew file mode 100644 index 0000000000..76f02c6c96 --- /dev/null +++ b/tests/manual/qopenglcontext/qticon64.png diff --git a/tests/manual/widgets/itemviews/itemviews.pro b/tests/manual/widgets/itemviews/itemviews.pro index 6b91531a87..53f658d54d 100644 --- a/tests/manual/widgets/itemviews/itemviews.pro +++ b/tests/manual/widgets/itemviews/itemviews.pro @@ -1,2 +1,2 @@ TEMPLATE = subdirs -SUBDIRS = delegate qheaderview qtreeview qtreewidget +SUBDIRS = delegate qheaderview qtreeview qtreewidget tableview-span-navigation diff --git a/tests/manual/widgets/itemviews/qheaderview/qheaderviewtest.pro b/tests/manual/widgets/itemviews/qheaderview/qheaderview.pro index f83136266d..f83136266d 100644 --- a/tests/manual/widgets/itemviews/qheaderview/qheaderviewtest.pro +++ b/tests/manual/widgets/itemviews/qheaderview/qheaderview.pro diff --git a/tests/manual/widgets/itemviews/qtreeview/qtreeviewtest.pro b/tests/manual/widgets/itemviews/qtreeview/qtreeview.pro index c241ee1045..c241ee1045 100644 --- a/tests/manual/widgets/itemviews/qtreeview/qtreeviewtest.pro +++ b/tests/manual/widgets/itemviews/qtreeview/qtreeview.pro diff --git a/tests/manual/widgets/itemviews/qtreewidget/qtreewidgettest.pro b/tests/manual/widgets/itemviews/qtreewidget/qtreewidget.pro index 4b1da9be38..4b1da9be38 100644 --- a/tests/manual/widgets/itemviews/qtreewidget/qtreewidgettest.pro +++ b/tests/manual/widgets/itemviews/qtreewidget/qtreewidget.pro diff --git a/tests/manual/widgets/itemviews/tableview-span-navigation/main.cpp b/tests/manual/widgets/itemviews/tableview-span-navigation/main.cpp new file mode 100644 index 0000000000..8421d0661b --- /dev/null +++ b/tests/manual/widgets/itemviews/tableview-span-navigation/main.cpp @@ -0,0 +1,67 @@ +/**************************************************************************** +** +** Copyright (C) 2014 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Stephen Kelly <stephen.kelly@kdab.com> +** Contact: http://www.qt-project.org/legal +** +** This file is part of the QtGui module 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 <QApplication> +#include <QStandardItemModel> +#include <QTableView> + +int main(int argc, char *argv[]) +{ + QApplication app(argc, argv); + + QStandardItemModel model(4, 4); + QTableView tableView; + tableView.setSizeAdjustPolicy(QTableView::AdjustToContents); + tableView.setModel(&model); + + for (int row = 0; row < model.rowCount(); ++row) { + for (int column = 0; column < model.columnCount(); ++column) { + QModelIndex index = model.index(row, column, QModelIndex()); + model.setData(index, QVariant(QString("%1,%2").arg(row).arg(column))); + } + } + + tableView.setSpan(1, 1, 2, 2); + + tableView.show(); + + return app.exec(); +} diff --git a/tests/manual/widgets/itemviews/tableview-span-navigation/tableview-span-navigation.pro b/tests/manual/widgets/itemviews/tableview-span-navigation/tableview-span-navigation.pro new file mode 100644 index 0000000000..ffa006a2d8 --- /dev/null +++ b/tests/manual/widgets/itemviews/tableview-span-navigation/tableview-span-navigation.pro @@ -0,0 +1,8 @@ + +TEMPLATE = app +TARGET = tableview-span-navigation +INCLUDEPATH += . + +QT += widgets + +SOURCES += main.cpp diff --git a/tests/manual/widgets/kernel/layoutreplace/main.pro b/tests/manual/widgets/kernel/layoutreplace/layoutreplace.pro index 54c6a4a9fc..54c6a4a9fc 100644 --- a/tests/manual/widgets/kernel/layoutreplace/main.pro +++ b/tests/manual/widgets/kernel/layoutreplace/layoutreplace.pro diff --git a/tests/manual/widgets/kernel/qtooltip/main.pro b/tests/manual/widgets/kernel/qtooltip/qtooltip.pro index dac880a10e..dac880a10e 100644 --- a/tests/manual/widgets/kernel/qtooltip/main.pro +++ b/tests/manual/widgets/kernel/qtooltip/qtooltip.pro diff --git a/tests/manual/widgets/qgraphicsview/rubberband/rubberbandtest.pro b/tests/manual/widgets/qgraphicsview/rubberband/rubberband.pro index 805b0cc119..805b0cc119 100644 --- a/tests/manual/widgets/qgraphicsview/rubberband/rubberbandtest.pro +++ b/tests/manual/widgets/qgraphicsview/rubberband/rubberband.pro |