summaryrefslogtreecommitdiffstats
path: root/tests/auto
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto')
-rw-r--r--tests/auto/corelib/io/qstandardpaths/tst_qstandardpaths.cpp14
-rw-r--r--tests/auto/corelib/io/qurl/tst_qurl.cpp50
-rw-r--r--tests/auto/corelib/thread/qthread/tst_qthread.cpp4
-rw-r--r--tests/auto/other/qaccessibility/tst_qaccessibility.cpp5
-rw-r--r--tests/auto/widgets/dialogs/qfiledialog2/tst_qfiledialog2.cpp10
-rw-r--r--tests/auto/widgets/itemviews/qlistwidget/tst_qlistwidget.cpp8
-rw-r--r--tests/auto/widgets/itemviews/qtablewidget/tst_qtablewidget.cpp8
-rw-r--r--tests/auto/widgets/kernel/qformlayout/tst_qformlayout.cpp42
-rw-r--r--tests/auto/widgets/widgets/qdatetimeedit/tst_qdatetimeedit.cpp2
9 files changed, 109 insertions, 34 deletions
diff --git a/tests/auto/corelib/io/qstandardpaths/tst_qstandardpaths.cpp b/tests/auto/corelib/io/qstandardpaths/tst_qstandardpaths.cpp
index 5b18ab9d68..a7a761a2da 100644
--- a/tests/auto/corelib/io/qstandardpaths/tst_qstandardpaths.cpp
+++ b/tests/auto/corelib/io/qstandardpaths/tst_qstandardpaths.cpp
@@ -33,6 +33,9 @@
#include <qfileinfo.h>
#include <qsysinfo.h>
#include <qregexp.h>
+#if defined(Q_OS_WIN) && !defined(Q_OS_WINRT) && !defined(Q_OS_WINCE)
+# include <qt_windows.h>
+#endif
#ifdef Q_OS_UNIX
#include <unistd.h>
@@ -126,6 +129,16 @@ static const char * const enumNames[MaxStandardLocation + 1 - int(QStandardPaths
void tst_qstandardpaths::initTestCase()
{
+#if defined(Q_OS_WIN) && !defined(Q_OS_WINRT) && !defined(Q_OS_WINCE)
+ // Disable WOW64 redirection, see testFindExecutable()
+ if (QSysInfo::buildCpuArchitecture() != QSysInfo::currentCpuArchitecture()) {
+ void *oldMode;
+ const bool disabledDisableWow64FsRedirection = Wow64DisableWow64FsRedirection(&oldMode) == TRUE;
+ if (!disabledDisableWow64FsRedirection)
+ qErrnoWarning("Wow64DisableWow64FsRedirection() failed");
+ QVERIFY(disabledDisableWow64FsRedirection);
+ }
+#endif // Q_OS_WIN && !Q_OS_WINRT && !Q_OS_WINCE
QVERIFY2(m_localConfigTempDir.isValid(), qPrintable(m_localConfigTempDir.errorString()));
QVERIFY2(m_globalConfigTempDir.isValid(), qPrintable(m_globalConfigTempDir.errorString()));
QVERIFY2(m_localAppTempDir.isValid(), qPrintable(m_localAppTempDir.errorString()));
@@ -375,6 +388,7 @@ void tst_qstandardpaths::testFindExecutable_data()
if (QSysInfo::windowsVersion() >= QSysInfo::WV_WINDOWS8) {
// The logo executable on Windows 8 is perfectly suited for testing that the
// suffix mechanism is not thrown off by dots in the name.
+ // Note: Requires disabling WOW64 redirection, see initTestCase()
const QString logo = QLatin1String("microsoft.windows.softwarelogo.showdesktop");
const QString logoPath = cmdFi.absolutePath() + QLatin1Char('/') + logo + QLatin1String(".exe");
QTest::newRow("win8-logo")
diff --git a/tests/auto/corelib/io/qurl/tst_qurl.cpp b/tests/auto/corelib/io/qurl/tst_qurl.cpp
index f589fe1d6d..a4461a12d3 100644
--- a/tests/auto/corelib/io/qurl/tst_qurl.cpp
+++ b/tests/auto/corelib/io/qurl/tst_qurl.cpp
@@ -177,6 +177,8 @@ private slots:
void streaming();
void detach();
void testThreading();
+ void matches_data();
+ void matches();
private:
void testThreadingHelper();
@@ -4020,6 +4022,54 @@ void tst_QUrl::testThreading()
delete s_urlStorage;
}
+void tst_QUrl::matches_data()
+{
+ QTest::addColumn<QString>("urlStrOne");
+ QTest::addColumn<QString>("urlStrTwo");
+ QTest::addColumn<uint>("options");
+ QTest::addColumn<bool>("matches");
+
+ QTest::newRow("matchingString-none") << "http://www.website.com/directory/?#ref"
+ << "http://www.website.com/directory/?#ref"
+ << uint(QUrl::None) << true;
+ QTest::newRow("nonMatchingString-none") << "http://www.website.com/directory/?#ref"
+ << "http://www.nomatch.com/directory/?#ref"
+ << uint(QUrl::None) << false;
+ QTest::newRow("matchingHost-removePath") << "http://www.website.com/directory"
+ << "http://www.website.com/differentdir"
+ << uint(QUrl::RemovePath) << true;
+ QTest::newRow("nonMatchingHost-removePath") << "http://www.website.com/directory"
+ << "http://www.different.com/differentdir"
+ << uint(QUrl::RemovePath) << false;
+ QTest::newRow("matchingHost-removePathAuthority") << "http://user:pass@www.website.com/directory"
+ << "http://www.website.com/differentdir"
+ << uint(QUrl::RemovePath | QUrl::RemoveAuthority)
+ << true;
+ QTest::newRow("nonMatchingHost-removePathAuthority") << "http://user:pass@www.website.com/directory"
+ << "http://user:pass@www.different.com/differentdir"
+ << uint(QUrl::RemovePath | QUrl::RemoveAuthority)
+ << true;
+ QTest::newRow("matchingHostAuthority-removePathAuthority")
+ << "http://user:pass@www.website.com/directory" << "http://www.website.com/differentdir"
+ << uint(QUrl::RemovePath | QUrl::RemoveAuthority) << true;
+ QTest::newRow("nonMatchingAuthority-removePathAuthority")
+ << "http://user:pass@www.website.com/directory"
+ << "http://otheruser:otherpass@www.website.com/directory"
+ << uint(QUrl::RemovePath | QUrl::RemoveAuthority) << true;
+}
+
+void tst_QUrl::matches()
+{
+ QFETCH(QString, urlStrOne);
+ QFETCH(QString, urlStrTwo);
+ QFETCH(uint, options);
+ QFETCH(bool, matches);
+
+ QUrl urlOne(urlStrOne);
+ QUrl urlTwo(urlStrTwo);
+ QCOMPARE(urlOne.matches(urlTwo, QUrl::FormattingOptions(options)), matches);
+}
+
QTEST_MAIN(tst_QUrl)
#include "tst_qurl.moc"
diff --git a/tests/auto/corelib/thread/qthread/tst_qthread.cpp b/tests/auto/corelib/thread/qthread/tst_qthread.cpp
index b4d0866d01..bbd319d2db 100644
--- a/tests/auto/corelib/thread/qthread/tst_qthread.cpp
+++ b/tests/auto/corelib/thread/qthread/tst_qthread.cpp
@@ -1077,8 +1077,8 @@ void tst_QThread::wait2()
thread.start();
timer.start();
QVERIFY(!thread.wait(Waiting_Thread::WaitTime));
- qint64 elapsed = timer.elapsed(); // On Windows, we sometimes get (WaitTime - 1).
- QVERIFY2(elapsed >= Waiting_Thread::WaitTime - 1, qPrintable(QString::fromLatin1("elapsed: %1").arg(elapsed)));
+ qint64 elapsed = timer.elapsed(); // On Windows, we sometimes get (WaitTime - 9).
+ QVERIFY2(elapsed >= Waiting_Thread::WaitTime - 10, qPrintable(QString::fromLatin1("elapsed: %1").arg(elapsed)));
timer.start();
thread.cond1.wakeOne();
diff --git a/tests/auto/other/qaccessibility/tst_qaccessibility.cpp b/tests/auto/other/qaccessibility/tst_qaccessibility.cpp
index 99e3fc5bf2..a77daa7cb0 100644
--- a/tests/auto/other/qaccessibility/tst_qaccessibility.cpp
+++ b/tests/auto/other/qaccessibility/tst_qaccessibility.cpp
@@ -2898,7 +2898,10 @@ void tst_QAccessibility::listTest()
QAccessibleInterface *cellMunich3 = table2->cellAt(2,0);
QCOMPARE(cell4, cellMunich3);
QCOMPARE(axidMunich, QAccessible::uniqueId(cellMunich3));
-
+ delete listView->takeItem(2);
+ // list: Oslo, Helsinki
+ // verify that it doesn't return an invalid item from the cache
+ QVERIFY(table2->cellAt(2,0) == 0);
delete listView;
}
diff --git a/tests/auto/widgets/dialogs/qfiledialog2/tst_qfiledialog2.cpp b/tests/auto/widgets/dialogs/qfiledialog2/tst_qfiledialog2.cpp
index 82934982c4..d6a1c264c7 100644
--- a/tests/auto/widgets/dialogs/qfiledialog2/tst_qfiledialog2.cpp
+++ b/tests/auto/widgets/dialogs/qfiledialog2/tst_qfiledialog2.cpp
@@ -350,8 +350,7 @@ void tst_QFileDialog2::task143519_deleteAndRenameActionBehavior()
// test based on task233037_selectingDirectory
struct TestContext {
- TestContext()
- : current(QDir::current()) {}
+ explicit TestContext(const QString &path) : current(path) {}
~TestContext() {
file.remove();
current.rmdir(test.dirName());
@@ -359,7 +358,9 @@ void tst_QFileDialog2::task143519_deleteAndRenameActionBehavior()
QDir current;
QDir test;
QFile file;
- } ctx;
+ };
+
+ TestContext ctx(tempDir.path());
// setup testbed
QVERIFY(ctx.current.mkdir("task143519_deleteAndRenameActionBehavior_test")); // ensure at least one item
@@ -373,6 +374,7 @@ void tst_QFileDialog2::task143519_deleteAndRenameActionBehavior()
QFileDialog fd;
fd.setViewMode(QFileDialog::List);
fd.setDirectory(ctx.test.absolutePath());
+ fd.selectFile(ctx.file.fileName());
fd.show();
QTest::qWaitForWindowActive(&fd);
@@ -387,7 +389,7 @@ void tst_QFileDialog2::task143519_deleteAndRenameActionBehavior()
// defaults
QVERIFY(openContextMenu(fd));
- QCOMPARE(fd.selectedFiles().size(), 1);
+ QCOMPARE(fd.selectedFiles(), QStringList(ctx.file.fileName()));
QCOMPARE(rm->isEnabled(), !fd.isReadOnly());
QCOMPARE(mv->isEnabled(), !fd.isReadOnly());
diff --git a/tests/auto/widgets/itemviews/qlistwidget/tst_qlistwidget.cpp b/tests/auto/widgets/itemviews/qlistwidget/tst_qlistwidget.cpp
index e8bd86bee5..f8ab64e4d6 100644
--- a/tests/auto/widgets/itemviews/qlistwidget/tst_qlistwidget.cpp
+++ b/tests/auto/widgets/itemviews/qlistwidget/tst_qlistwidget.cpp
@@ -1672,16 +1672,16 @@ void tst_QListWidget::mimeData()
QMimeData *data;
- QVERIFY(data = list.mimeData(tableWidgetItemList));
+ QVERIFY((data = list.mimeData(tableWidgetItemList)));
delete data;
- QVERIFY(data = list.model()->mimeData(modelIndexList));
+ QVERIFY((data = list.model()->mimeData(modelIndexList)));
delete data;
- QVERIFY(data = list.model()->mimeData(modelIndexList));
+ QVERIFY((data = list.model()->mimeData(modelIndexList)));
delete data;
- QVERIFY(data = list.mimeData(tableWidgetItemList));
+ QVERIFY((data = list.mimeData(tableWidgetItemList)));
delete data;
// check the saved data is actually the same
diff --git a/tests/auto/widgets/itemviews/qtablewidget/tst_qtablewidget.cpp b/tests/auto/widgets/itemviews/qtablewidget/tst_qtablewidget.cpp
index 8f871b03f6..a86ffbc30d 100644
--- a/tests/auto/widgets/itemviews/qtablewidget/tst_qtablewidget.cpp
+++ b/tests/auto/widgets/itemviews/qtablewidget/tst_qtablewidget.cpp
@@ -1520,16 +1520,16 @@ void tst_QTableWidget::mimeData()
QMimeData *data;
- QVERIFY(data = table.mimeData(tableWidgetItemList));
+ QVERIFY((data = table.mimeData(tableWidgetItemList)));
delete data;
- QVERIFY(data = table.model()->mimeData(modelIndexList));
+ QVERIFY((data = table.model()->mimeData(modelIndexList)));
delete data;
- QVERIFY(data = table.model()->mimeData(modelIndexList));
+ QVERIFY((data = table.model()->mimeData(modelIndexList)));
delete data;
- QVERIFY(data = table.mimeData(tableWidgetItemList));
+ QVERIFY((data = table.mimeData(tableWidgetItemList)));
delete data;
// check the saved data is actually the same
diff --git a/tests/auto/widgets/kernel/qformlayout/tst_qformlayout.cpp b/tests/auto/widgets/kernel/qformlayout/tst_qformlayout.cpp
index 6c7197b85e..1a15432c1a 100644
--- a/tests/auto/widgets/kernel/qformlayout/tst_qformlayout.cpp
+++ b/tests/auto/widgets/kernel/qformlayout/tst_qformlayout.cpp
@@ -43,6 +43,10 @@
#include <qformlayout.h>
+// ItemRole has enumerators for numerical values 0..2, thus the only
+// valid numerical values for storing into an ItemRole variable are 0..3:
+Q_CONSTEXPR QFormLayout::ItemRole invalidRole = QFormLayout::ItemRole(3);
+
static inline void setFrameless(QWidget *w)
{
Qt::WindowFlags flags = w->windowFlags();
@@ -523,7 +527,7 @@ void tst_QFormLayout::insertRow_QWidget_QWidget()
{
int row = -1;
- QFormLayout::ItemRole role = QFormLayout::ItemRole(-123);
+ QFormLayout::ItemRole role = invalidRole;
layout->getWidgetPosition(lbl1, &row, &role);
QCOMPARE(row, 0);
QCOMPARE(int(role), int(QFormLayout::LabelRole));
@@ -531,7 +535,7 @@ void tst_QFormLayout::insertRow_QWidget_QWidget()
{
int row = -1;
- QFormLayout::ItemRole role = QFormLayout::ItemRole(-123);
+ QFormLayout::ItemRole role = invalidRole;
layout->getWidgetPosition(fld1, &row, &role);
QCOMPARE(row, 0);
QCOMPARE(int(role), int(QFormLayout::FieldRole));
@@ -592,7 +596,7 @@ void tst_QFormLayout::insertRow_QWidget_QLayout()
{
int row = -1;
- QFormLayout::ItemRole role = QFormLayout::ItemRole(-123);
+ QFormLayout::ItemRole role = invalidRole;
layout->getWidgetPosition(lbl1, &row, &role);
QCOMPARE(row, 0);
QCOMPARE(int(role), int(QFormLayout::LabelRole));
@@ -600,7 +604,7 @@ void tst_QFormLayout::insertRow_QWidget_QLayout()
{
int row = -1;
- QFormLayout::ItemRole role = QFormLayout::ItemRole(-123);
+ QFormLayout::ItemRole role = invalidRole;
layout->getLayoutPosition(fld1, &row, &role);
QCOMPARE(row, 0);
QCOMPARE(int(role), int(QFormLayout::FieldRole));
@@ -717,7 +721,7 @@ void tst_QFormLayout::setWidget()
{
int row = -1;
- QFormLayout::ItemRole role = QFormLayout::ItemRole(-123);
+ QFormLayout::ItemRole role = invalidRole;
layout.getWidgetPosition(&w1, &row, &role);
QCOMPARE(row, 5);
QCOMPARE(int(role), int(QFormLayout::LabelRole));
@@ -725,7 +729,7 @@ void tst_QFormLayout::setWidget()
{
int row = -1;
- QFormLayout::ItemRole role = QFormLayout::ItemRole(-123);
+ QFormLayout::ItemRole role = invalidRole;
layout.getWidgetPosition(&w2, &row, &role);
QCOMPARE(row, 3);
QCOMPARE(int(role), int(QFormLayout::FieldRole));
@@ -733,7 +737,7 @@ void tst_QFormLayout::setWidget()
{
int row = -1;
- QFormLayout::ItemRole role = QFormLayout::ItemRole(-123);
+ QFormLayout::ItemRole role = invalidRole;
layout.getWidgetPosition(&w3, &row, &role);
QCOMPARE(row, 3);
QCOMPARE(int(role), int(QFormLayout::LabelRole));
@@ -741,18 +745,20 @@ void tst_QFormLayout::setWidget()
{
int row = -1;
- QFormLayout::ItemRole role = QFormLayout::ItemRole(-123);
+ QFormLayout::ItemRole role = invalidRole;
layout.getWidgetPosition(&w4, &row, &role);
+ // not found
QCOMPARE(row, -1);
- QCOMPARE(int(role), -123);
+ QCOMPARE(int(role), int(invalidRole));
}
{
int row = -1;
- QFormLayout::ItemRole role = QFormLayout::ItemRole(-123);
+ QFormLayout::ItemRole role = invalidRole;
layout.getWidgetPosition(0, &row, &role);
+ // not found
QCOMPARE(row, -1);
- QCOMPARE(int(role), -123);
+ QCOMPARE(int(role), int(invalidRole));
}
}
@@ -785,7 +791,7 @@ void tst_QFormLayout::setLayout()
{
int row = -1;
- QFormLayout::ItemRole role = QFormLayout::ItemRole(-123);
+ QFormLayout::ItemRole role = invalidRole;
layout.getLayoutPosition(&l1, &row, &role);
QCOMPARE(row, 5);
QCOMPARE(int(role), int(QFormLayout::LabelRole));
@@ -793,7 +799,7 @@ void tst_QFormLayout::setLayout()
{
int row = -1;
- QFormLayout::ItemRole role = QFormLayout::ItemRole(-123);
+ QFormLayout::ItemRole role = invalidRole;
layout.getLayoutPosition(&l2, &row, &role);
QCOMPARE(row, 3);
QCOMPARE(int(role), int(QFormLayout::FieldRole));
@@ -801,7 +807,7 @@ void tst_QFormLayout::setLayout()
{
int row = -1;
- QFormLayout::ItemRole role = QFormLayout::ItemRole(-123);
+ QFormLayout::ItemRole role = invalidRole;
layout.getLayoutPosition(&l3, &row, &role);
QCOMPARE(row, 3);
QCOMPARE(int(role), int(QFormLayout::LabelRole));
@@ -809,18 +815,18 @@ void tst_QFormLayout::setLayout()
{
int row = -1;
- QFormLayout::ItemRole role = QFormLayout::ItemRole(-123);
+ QFormLayout::ItemRole role = invalidRole;
layout.getLayoutPosition(&l4, &row, &role);
QCOMPARE(row, -1);
- QCOMPARE(int(role), -123);
+ QCOMPARE(int(role), int(invalidRole));
}
{
int row = -1;
- QFormLayout::ItemRole role = QFormLayout::ItemRole(-123);
+ QFormLayout::ItemRole role = invalidRole;
layout.getLayoutPosition(0, &row, &role);
QCOMPARE(row, -1);
- QCOMPARE(int(role), -123);
+ QCOMPARE(int(role), int(invalidRole));
}
}
diff --git a/tests/auto/widgets/widgets/qdatetimeedit/tst_qdatetimeedit.cpp b/tests/auto/widgets/widgets/qdatetimeedit/tst_qdatetimeedit.cpp
index 31eb05a957..9e09d17903 100644
--- a/tests/auto/widgets/widgets/qdatetimeedit/tst_qdatetimeedit.cpp
+++ b/tests/auto/widgets/widgets/qdatetimeedit/tst_qdatetimeedit.cpp
@@ -3734,7 +3734,7 @@ void tst_QDateTimeEdit::dateEditCorrectSectionSize()
QTest::keyClick(&edit, keyPair.first, keyPair.second);
QDateTimeEditPrivate* edit_d_ptr(static_cast<QDateTimeEditPrivate*>(qt_widget_private(&edit)));
- QCOMPARE(edit_d_ptr->text, expectedDisplayString);
+ QCOMPARE(edit_d_ptr->QDateTimeParser::displayText(), expectedDisplayString);
}
#endif