summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorSergio Ahumada <sergio.ahumada@digia.com>2013-09-21 17:32:39 +0200
committerSergio Ahumada <sergio.ahumada@digia.com>2013-09-21 17:33:15 +0200
commita5d34b34fbd867bd13ce94cdaf55d96576d4d14d (patch)
treebb3b8b902f13bda65e49485a789f0eca07329ab5 /tests
parent5957f245c6c77c98d7e90d614c9fe2cdbfe7e8e6 (diff)
parenta23ff58d716f62b02ec825a3ea3c6b07616ee3f0 (diff)
Merge branch 'stable' into dev
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/corelib/io/qfilesystemwatcher/tst_qfilesystemwatcher.cpp81
-rw-r--r--tests/auto/gui/text/qtextlayout/tst_qtextlayout.cpp2
-rw-r--r--tests/auto/widgets/dialogs/qmessagebox/tst_qmessagebox.cpp45
3 files changed, 128 insertions, 0 deletions
diff --git a/tests/auto/corelib/io/qfilesystemwatcher/tst_qfilesystemwatcher.cpp b/tests/auto/corelib/io/qfilesystemwatcher/tst_qfilesystemwatcher.cpp
index 4105a43735..20ef7b5a76 100644
--- a/tests/auto/corelib/io/qfilesystemwatcher/tst_qfilesystemwatcher.cpp
+++ b/tests/auto/corelib/io/qfilesystemwatcher/tst_qfilesystemwatcher.cpp
@@ -79,6 +79,8 @@ private slots:
void QTBUG2331();
void QTBUG2331_data() { basicTest_data(); }
+ void signalsEmittedAfterFileMoved();
+
private:
QString m_tempDirPattern;
};
@@ -596,5 +598,84 @@ void tst_QFileSystemWatcher::QTBUG2331()
QCOMPARE(watcher.directories(), QStringList());
}
+class SignalReceiver : public QObject
+{
+ Q_OBJECT
+public:
+ SignalReceiver(const QDir &moveSrcDir,
+ const QString &moveDestination,
+ QFileSystemWatcher *watcher,
+ QObject *parent = 0)
+ : QObject(parent),
+ added(false),
+ moveSrcDir(moveSrcDir),
+ moveDestination(QDir(moveDestination)),
+ watcher(watcher)
+ {}
+
+public slots:
+ void fileChanged(const QString &path)
+ {
+ QFileInfo finfo(path);
+
+ QCOMPARE(finfo.absolutePath(), moveSrcDir.absolutePath());
+
+ if (!added) {
+ foreach (const QFileInfo &fi, moveDestination.entryInfoList(QDir::Files | QDir::NoSymLinks))
+ watcher->addPath(fi.absoluteFilePath());
+ added = true;
+ }
+ }
+
+private:
+ bool added;
+ QDir moveSrcDir;
+ QDir moveDestination;
+ QFileSystemWatcher *watcher;
+};
+
+// regression test for QTBUG-33211.
+// using inotify backend if a file is moved and then added to the watcher
+// before all the fileChanged signals are emitted the remaining signals are
+// emitted with the destination path instead of the starting path
+void tst_QFileSystemWatcher::signalsEmittedAfterFileMoved()
+{
+ QTemporaryDir temporaryDirectory(m_tempDirPattern);
+ QVERIFY(temporaryDirectory.isValid());
+ QDir testDir(temporaryDirectory.path());
+ QVERIFY(testDir.mkdir("movehere"));
+ QString movePath = testDir.filePath("movehere");
+
+ for (int i = 0; i < 10; i++) {
+ QFile f(testDir.filePath(QString("test%1.txt").arg(i)));
+ QVERIFY(f.open(QIODevice::WriteOnly));
+ f.write(QByteArray("i am " + i));
+ f.close();
+ }
+
+ QFileSystemWatcher watcher;
+ QVERIFY(watcher.addPath(testDir.path()));
+ QVERIFY(watcher.addPath(movePath));
+
+ // add files to watcher
+ QFileInfoList files = testDir.entryInfoList(QDir::Files | QDir::NoSymLinks);
+ foreach (const QFileInfo &finfo, files)
+ QVERIFY(watcher.addPath(finfo.absoluteFilePath()));
+
+ // create the signal receiver
+ SignalReceiver signalReceiver(testDir, movePath, &watcher);
+ connect(&watcher, SIGNAL(fileChanged(QString)), &signalReceiver, SLOT(fileChanged(QString)));
+
+ // watch signals
+ QSignalSpy changedSpy(&watcher, SIGNAL(fileChanged(QString)));
+ QVERIFY(changedSpy.isValid());
+
+ // move files to second directory
+ foreach (const QFileInfo &finfo, files)
+ QVERIFY(testDir.rename(finfo.fileName(), QString("movehere/%2").arg(finfo.fileName())));
+
+ QTRY_COMPARE(changedSpy.count(), 10);
+}
+
QTEST_MAIN(tst_QFileSystemWatcher)
#include "tst_qfilesystemwatcher.moc"
diff --git a/tests/auto/gui/text/qtextlayout/tst_qtextlayout.cpp b/tests/auto/gui/text/qtextlayout/tst_qtextlayout.cpp
index 6c56d3c2fa..90137079f3 100644
--- a/tests/auto/gui/text/qtextlayout/tst_qtextlayout.cpp
+++ b/tests/auto/gui/text/qtextlayout/tst_qtextlayout.cpp
@@ -1587,6 +1587,8 @@ void tst_QTextLayout::testTabDPIScale()
case QPaintDevice::PdmPhysicalDpiX:
case QPaintDevice::PdmPhysicalDpiY:
return 72;
+ case QPaintDevice::PdmDevicePixelRatio:
+ ; // fall through
}
return 0;
}
diff --git a/tests/auto/widgets/dialogs/qmessagebox/tst_qmessagebox.cpp b/tests/auto/widgets/dialogs/qmessagebox/tst_qmessagebox.cpp
index c3faa93309..0425db3098 100644
--- a/tests/auto/widgets/dialogs/qmessagebox/tst_qmessagebox.cpp
+++ b/tests/auto/widgets/dialogs/qmessagebox/tst_qmessagebox.cpp
@@ -114,6 +114,7 @@ private slots:
void about();
void detailsText();
void detailsButtonText();
+ void expandDetails_QTBUG_32473();
#ifndef Q_OS_MAC
void shortcut();
@@ -137,6 +138,19 @@ private:
QTimer keySendTimer;
};
+class tst_ResizingMessageBox : public QMessageBox
+{
+public:
+ tst_ResizingMessageBox() : QMessageBox(), resized(false) { }
+ bool resized;
+
+protected:
+ void resizeEvent ( QResizeEvent * event ) {
+ resized = true;
+ QMessageBox::resizeEvent(event);
+ }
+};
+
tst_QMessageBox::tst_QMessageBox() : keyToSend(-1)
{
}
@@ -603,6 +617,37 @@ void tst_QMessageBox::detailsButtonText()
}
}
+void tst_QMessageBox::expandDetails_QTBUG_32473()
+{
+ tst_ResizingMessageBox box;
+ box.setDetailedText("bla");
+ box.show();
+ QApplication::postEvent(&box, new QEvent(QEvent::LanguageChange));
+ QApplication::processEvents();
+ QDialogButtonBox* bb = box.findChild<QDialogButtonBox*>("qt_msgbox_buttonbox");
+ QVERIFY(bb);
+
+ QList<QAbstractButton *> list = bb->buttons();
+ QAbstractButton* moreButton = NULL;
+ foreach (QAbstractButton* btn, list)
+ if (btn && bb->buttonRole(btn) == QDialogButtonBox::ActionRole)
+ moreButton = btn;
+ QVERIFY(moreButton);
+ QVERIFY(QTest::qWaitForWindowExposed(&box));
+ QRect geom = box.geometry();
+ box.resized = false;
+ moreButton->click();
+ QTRY_VERIFY(box.resized);
+ // After we receive the expose event for a second widget, it's likely
+ // that the window manager is also done manipulating the first QMessageBox.
+ QWidget fleece;
+ fleece.show();
+ QTest::qWaitForWindowExposed(&fleece);
+ if (geom.topLeft() == box.geometry().topLeft())
+ QTest::qWait(500);
+ QCOMPARE(geom.topLeft(), box.geometry().topLeft());
+}
+
void tst_QMessageBox::incorrectDefaultButton()
{
keyToSend = Qt::Key_Escape;