diff options
author | Water-Team <water@pad.test.qt.nokia.com> | 2011-07-07 23:00:14 (GMT) |
---|---|---|
committer | Water-Team <water@pad.test.qt.nokia.com> | 2011-07-07 23:00:14 (GMT) |
commit | e7d9b0e9961de39590ffdee4d6a168e612ae7826 (patch) | |
tree | ed835ee599eb2b5bc929ead33d36d5f921204e15 /tests | |
parent | 997c2dfed7a04da2fac577f1c29b89bda4939e2d (diff) | |
parent | 233a146ae575de76e55abe2dc30bcde3b5570f23 (diff) | |
download | Qt-e7d9b0e9961de39590ffdee4d6a168e612ae7826.zip Qt-e7d9b0e9961de39590ffdee4d6a168e612ae7826.tar.gz Qt-e7d9b0e9961de39590ffdee4d6a168e612ae7826.tar.bz2 |
Merge branch '4.8-upstream' into master-water
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/qflags/tst_qflags.cpp | 28 | ||||
-rw-r--r-- | tests/auto/qprocess/tst_qprocess.cpp | 28 | ||||
-rw-r--r-- | tests/auto/qscopedpointer/tst_qscopedpointer.cpp | 22 |
3 files changed, 76 insertions, 2 deletions
diff --git a/tests/auto/qflags/tst_qflags.cpp b/tests/auto/qflags/tst_qflags.cpp index 87025b6..85e64a6 100644 --- a/tests/auto/qflags/tst_qflags.cpp +++ b/tests/auto/qflags/tst_qflags.cpp @@ -47,6 +47,7 @@ private slots: void testFlag() const; void testFlagZeroFlag() const; void testFlagMultiBits() const; + void constExpr(); }; void tst_QFlags::testFlag() const @@ -96,5 +97,32 @@ void tst_QFlags::testFlagMultiBits() const } } +template <int N, typename T> bool verifyConstExpr(T n) { return n == N; } + +void tst_QFlags::constExpr() +{ +#ifdef Q_COMPILER_CONSTEXPR + Qt::MouseButtons btn = Qt::LeftButton | Qt::RightButton; + switch (btn) { + case Qt::LeftButton: QVERIFY(false); break; + case Qt::RightButton: QVERIFY(false); break; + case Qt::LeftButton | Qt::RightButton: QVERIFY(true); break; + default: QVERIFY(false); + } + + QVERIFY(verifyConstExpr<(Qt::LeftButton | Qt::RightButton) & Qt::LeftButton>(Qt::LeftButton)); + QVERIFY(verifyConstExpr<(Qt::LeftButton | Qt::RightButton) & Qt::MiddleButton>(0)); + QVERIFY(verifyConstExpr<(Qt::LeftButton | Qt::RightButton) | Qt::MiddleButton>(Qt::LeftButton | Qt::RightButton | Qt::MiddleButton)); + QVERIFY(verifyConstExpr<~(Qt::LeftButton | Qt::RightButton)>(~(Qt::LeftButton | Qt::RightButton))); + QVERIFY(verifyConstExpr<Qt::MouseButtons(Qt::LeftButton) ^ Qt::RightButton>(Qt::LeftButton ^ Qt::RightButton)); + QVERIFY(verifyConstExpr<Qt::MouseButtons(0)>(0)); + QVERIFY(verifyConstExpr<Qt::MouseButtons(Qt::RightButton) & 0xff>(Qt::RightButton)); + QVERIFY(verifyConstExpr<Qt::MouseButtons(Qt::RightButton) | 0xff>(0xff)); + + QVERIFY(!verifyConstExpr<Qt::RightButton>(!Qt::MouseButtons(Qt::LeftButton))); +#endif +} + + QTEST_MAIN(tst_QFlags) #include "tst_qflags.moc" diff --git a/tests/auto/qprocess/tst_qprocess.cpp b/tests/auto/qprocess/tst_qprocess.cpp index 91e0abe..f54dfa3 100644 --- a/tests/auto/qprocess/tst_qprocess.cpp +++ b/tests/auto/qprocess/tst_qprocess.cpp @@ -73,7 +73,7 @@ Q_DECLARE_METATYPE(QProcess::ProcessState); { \ const bool ret = Process.Fn; \ if (ret == false) \ - qWarning("QProcess error: %d: %s", Process.error(), qPrintable(Process.errorString())); \ + qWarning("QProcess error: %d: %s", Process.error(), qPrintable(Process.errorString())); \ QVERIFY(ret); \ } @@ -157,6 +157,7 @@ private slots: void startFinishStartFinish(); void invalidProgramString_data(); void invalidProgramString(); + void onlyOneStartedSignal(); // keep these at the end, since they use lots of processes and sometimes // caused obscure failures to occur in tests that followed them (esp. on the Mac) @@ -2089,7 +2090,7 @@ void tst_QProcess::setStandardInputFile() #endif QPROCESS_VERIFY(process, waitForFinished()); - QByteArray all = process.readAll(); + QByteArray all = process.readAll(); QCOMPARE(all.size(), int(sizeof data) - 1); // testProcessEcho drops the ending \0 QVERIFY(all == data); } @@ -2442,6 +2443,29 @@ void tst_QProcess::invalidProgramString() QVERIFY(!QProcess::startDetached(programString)); } +//----------------------------------------------------------------------------- +void tst_QProcess::onlyOneStartedSignal() +{ + QProcess process; + + QSignalSpy spyStarted(&process, SIGNAL(started())); + QSignalSpy spyFinished(&process, SIGNAL(finished(int, QProcess::ExitStatus))); + + process.start("testProcessNormal/testProcessNormal"); + QVERIFY(process.waitForStarted(5000)); + QVERIFY(process.waitForFinished(5000)); + QCOMPARE(spyStarted.count(), 1); + QCOMPARE(spyFinished.count(), 1); + + spyStarted.clear(); + spyFinished.clear(); + + process.start("testProcessNormal/testProcessNormal"); + QVERIFY(process.waitForFinished(5000)); + QCOMPARE(spyStarted.count(), 1); + QCOMPARE(spyFinished.count(), 1); +} + QTEST_MAIN(tst_QProcess) #include "tst_qprocess.moc" #endif diff --git a/tests/auto/qscopedpointer/tst_qscopedpointer.cpp b/tests/auto/qscopedpointer/tst_qscopedpointer.cpp index 1a6f944..06c0ecb 100644 --- a/tests/auto/qscopedpointer/tst_qscopedpointer.cpp +++ b/tests/auto/qscopedpointer/tst_qscopedpointer.cpp @@ -72,6 +72,7 @@ private Q_SLOTS: void isNullSignature(); void objectSize(); void comparison(); + void array(); // TODO instanciate on const object }; @@ -437,5 +438,26 @@ void tst_QScopedPointer::comparison() QCOMPARE( int(RefCounted::instanceCount), 0 ); } +void tst_QScopedPointer::array() +{ + int instCount = RefCounted::instanceCount; + { + QScopedArrayPointer<RefCounted> array; + array.reset(new RefCounted[42]); + QCOMPARE(instCount + 42, int(RefCounted::instanceCount)); + } + QCOMPARE(instCount, int(RefCounted::instanceCount)); + { + QScopedArrayPointer<RefCounted> array(new RefCounted[42]); + QCOMPARE(instCount + 42, int(RefCounted::instanceCount)); + array.reset(new RefCounted[28]); + QCOMPARE(instCount + 28, int(RefCounted::instanceCount)); + array.reset(0); + QCOMPARE(instCount, int(RefCounted::instanceCount)); + } + QCOMPARE(instCount, int(RefCounted::instanceCount)); +} + + QTEST_MAIN(tst_QScopedPointer) #include "tst_qscopedpointer.moc" |