summaryrefslogtreecommitdiffstats
path: root/tests/auto/corelib
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/corelib')
-rw-r--r--tests/auto/corelib/io/qbuffer/tst_qbuffer.cpp2
-rw-r--r--tests/auto/corelib/io/qfile/tst_qfile.cpp4
-rw-r--r--tests/auto/corelib/io/qiodevice/tst_qiodevice.cpp2
-rw-r--r--tests/auto/corelib/io/qlockfile/tst_qlockfile.cpp48
-rw-r--r--tests/auto/corelib/kernel/qmetatype/tst_qmetatype.cpp9
-rw-r--r--tests/auto/corelib/kernel/qobject/tst_qobject.cpp24
6 files changed, 84 insertions, 5 deletions
diff --git a/tests/auto/corelib/io/qbuffer/tst_qbuffer.cpp b/tests/auto/corelib/io/qbuffer/tst_qbuffer.cpp
index f792b34d48..3b730d97f9 100644
--- a/tests/auto/corelib/io/qbuffer/tst_qbuffer.cpp
+++ b/tests/auto/corelib/io/qbuffer/tst_qbuffer.cpp
@@ -151,7 +151,7 @@ void tst_QBuffer::readBlock()
QCOMPARE(b.bytesAvailable(), (qint64) arraySize);
b.open(QIODevice::WriteOnly);
QCOMPARE(b.bytesAvailable(), (qint64) arraySize);
- QTest::ignoreMessage(QtWarningMsg, "QIODevice::read: WriteOnly device");
+ QTest::ignoreMessage(QtWarningMsg, "QIODevice::read (QBuffer): WriteOnly device");
QCOMPARE(b.read(a, arraySize), (qint64) -1); // no read access
b.close();
diff --git a/tests/auto/corelib/io/qfile/tst_qfile.cpp b/tests/auto/corelib/io/qfile/tst_qfile.cpp
index 98963108be..5025dd38db 100644
--- a/tests/auto/corelib/io/qfile/tst_qfile.cpp
+++ b/tests/auto/corelib/io/qfile/tst_qfile.cpp
@@ -2334,7 +2334,7 @@ void tst_QFile::readFromWriteOnlyFile()
QFile file("writeonlyfile");
QVERIFY(file.open(QFile::WriteOnly));
char c;
- QTest::ignoreMessage(QtWarningMsg, "QIODevice::read: WriteOnly device");
+ QTest::ignoreMessage(QtWarningMsg, "QIODevice::read (QFile, \"writeonlyfile\"): WriteOnly device");
QCOMPARE(file.read(&c, 1), qint64(-1));
}
@@ -2343,7 +2343,7 @@ void tst_QFile::writeToReadOnlyFile()
QFile file("readonlyfile");
QVERIFY(file.open(QFile::ReadOnly));
char c = 0;
- QTest::ignoreMessage(QtWarningMsg, "QIODevice::write: ReadOnly device");
+ QTest::ignoreMessage(QtWarningMsg, "QIODevice::write (QFile, \"readonlyfile\"): ReadOnly device");
QCOMPARE(file.write(&c, 1), qint64(-1));
}
diff --git a/tests/auto/corelib/io/qiodevice/tst_qiodevice.cpp b/tests/auto/corelib/io/qiodevice/tst_qiodevice.cpp
index f756588e80..565ca18899 100644
--- a/tests/auto/corelib/io/qiodevice/tst_qiodevice.cpp
+++ b/tests/auto/corelib/io/qiodevice/tst_qiodevice.cpp
@@ -224,7 +224,7 @@ void tst_QIODevice::unget()
buf[0] = '@';
buf[1] = '@';
QTest::ignoreMessage(QtWarningMsg,
- "QIODevice::readLine: Called with maxSize < 2");
+ "QIODevice::readLine (QBuffer): Called with maxSize < 2");
QCOMPARE(buffer.readLine(buf, 1), qint64(-1));
QCOMPARE(buffer.readLine(buf, 2), qint64(i < 4 ? 1 : -1));
switch (i) {
diff --git a/tests/auto/corelib/io/qlockfile/tst_qlockfile.cpp b/tests/auto/corelib/io/qlockfile/tst_qlockfile.cpp
index 8d890e81fa..27614e0eb8 100644
--- a/tests/auto/corelib/io/qlockfile/tst_qlockfile.cpp
+++ b/tests/auto/corelib/io/qlockfile/tst_qlockfile.cpp
@@ -57,6 +57,7 @@ private slots:
void waitForLock();
void staleLockFromCrashedProcess_data();
void staleLockFromCrashedProcess();
+ void staleLockFromCrashedProcessReusedPid();
void staleShortLockFromBusyProcess();
void staleLongLockFromBusyProcess();
void staleLockRace();
@@ -64,6 +65,9 @@ private slots:
void noPermissionsWindows();
void corruptedLockFile();
+private:
+ static bool overwritePidInLockFile(const QString &filePath, qint64 pid);
+
public:
QString m_helperApp;
QTemporaryDir dir;
@@ -277,6 +281,30 @@ void tst_QLockFile::staleLockFromCrashedProcess()
#endif // !QT_NO_PROCESS
}
+void tst_QLockFile::staleLockFromCrashedProcessReusedPid()
+{
+#if defined(QT_NO_PROCESS)
+ QSKIP("This test requires QProcess support");
+#elif defined(Q_OS_WINRT) || defined(Q_OS_WINCE) || defined(Q_OS_IOS)
+ QSKIP("We cannot retrieve information about other processes on this platform.");
+#else
+ const QString fileName = dir.path() + "/staleLockFromCrashedProcessReusedPid";
+
+ int ret = QProcess::execute(m_helperApp, QStringList() << fileName << "-crash");
+ QCOMPARE(ret, int(QLockFile::NoError));
+ QVERIFY(QFile::exists(fileName));
+ QVERIFY(overwritePidInLockFile(fileName, QCoreApplication::applicationPid()));
+
+ QLockFile secondLock(fileName);
+ qint64 pid = 0;
+ secondLock.getLockInfo(&pid, 0, 0);
+ QCOMPARE(pid, QCoreApplication::applicationPid());
+ secondLock.setStaleLockTime(0);
+ QVERIFY(secondLock.tryLock());
+ QCOMPARE(int(secondLock.error()), int(QLockFile::NoError));
+#endif // !QT_NO_PROCESS
+}
+
void tst_QLockFile::staleShortLockFromBusyProcess()
{
#ifdef QT_NO_PROCESS
@@ -497,5 +525,25 @@ void tst_QLockFile::corruptedLockFile()
QCOMPARE(int(secondLock.error()), int(QLockFile::NoError));
}
+bool tst_QLockFile::overwritePidInLockFile(const QString &filePath, qint64 pid)
+{
+ QFile f(filePath);
+ if (!f.open(QFile::ReadWrite)) {
+ qWarning("Cannot open %s.", qPrintable(filePath));
+ return false;
+ }
+ QByteArray buf = f.readAll();
+ int i = buf.indexOf('\n');
+ if (i < 0) {
+ qWarning("Unexpected lockfile content.");
+ return false;
+ }
+ buf.remove(0, i);
+ buf.prepend(QByteArray::number(pid));
+ f.seek(0);
+ f.resize(buf.size());
+ return f.write(buf) == buf.size();
+}
+
QTEST_MAIN(tst_QLockFile)
#include "tst_qlockfile.moc"
diff --git a/tests/auto/corelib/kernel/qmetatype/tst_qmetatype.cpp b/tests/auto/corelib/kernel/qmetatype/tst_qmetatype.cpp
index b3333c6d68..9cdb1f47f8 100644
--- a/tests/auto/corelib/kernel/qmetatype/tst_qmetatype.cpp
+++ b/tests/auto/corelib/kernel/qmetatype/tst_qmetatype.cpp
@@ -142,8 +142,14 @@ public:
class CustomGadget {
Q_GADGET
};
+class CustomGadget_NonDefaultConstructible {
+ Q_GADGET
+public:
+ CustomGadget_NonDefaultConstructible(int) {};
+};
class CustomNonQObject {};
+class GadgetDerived : public CustomGadget {};
void tst_QMetaType::defined()
{
@@ -153,11 +159,12 @@ void tst_QMetaType::defined()
QCOMPARE(int(QMetaTypeId2<int*>::Defined), 0);
QCOMPARE(int(QMetaTypeId2<CustomQObject::CustomQEnum>::Defined), 1);
QCOMPARE(int(QMetaTypeId2<CustomGadget>::Defined), 1);
+ QVERIFY(!QMetaTypeId2<GadgetDerived>::Defined);
QVERIFY(int(QMetaTypeId2<CustomQObject*>::Defined));
QVERIFY(!QMetaTypeId2<CustomQObject>::Defined);
QVERIFY(!QMetaTypeId2<CustomNonQObject>::Defined);
QVERIFY(!QMetaTypeId2<CustomNonQObject*>::Defined);
- QVERIFY(!QMetaTypeId2<CustomGadget*>::Defined);
+ QVERIFY(!QMetaTypeId2<CustomGadget_NonDefaultConstructible>::Defined);
}
struct Bar
diff --git a/tests/auto/corelib/kernel/qobject/tst_qobject.cpp b/tests/auto/corelib/kernel/qobject/tst_qobject.cpp
index 263cc5a07a..3ec84b5198 100644
--- a/tests/auto/corelib/kernel/qobject/tst_qobject.cpp
+++ b/tests/auto/corelib/kernel/qobject/tst_qobject.cpp
@@ -128,6 +128,7 @@ private slots:
void connectWithReference();
void connectManyArguments();
void connectForwardDeclare();
+ void connectNoDefaultConstructorArg();
void returnValue_data();
void returnValue();
void returnValue2_data();
@@ -5227,6 +5228,29 @@ void tst_QObject::connectForwardDeclare()
QVERIFY(connect(&ob, &ForwardDeclareArguments::mySignal, &ob, &ForwardDeclareArguments::mySlot, Qt::QueuedConnection));
}
+class NoDefaultConstructor
+{
+ Q_GADGET
+public:
+ NoDefaultConstructor(int) {}
+};
+
+class NoDefaultContructorArguments : public QObject
+{
+ Q_OBJECT
+signals:
+ void mySignal(const NoDefaultConstructor&);
+public slots:
+ void mySlot(const NoDefaultConstructor&) {}
+};
+
+void tst_QObject::connectNoDefaultConstructorArg()
+{
+ NoDefaultContructorArguments ob;
+ // it should compile
+ QVERIFY(connect(&ob, &NoDefaultContructorArguments::mySignal, &ob, &NoDefaultContructorArguments::mySlot, Qt::QueuedConnection));
+}
+
class ReturnValue : public QObject {
friend class tst_QObject;
Q_OBJECT