summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/corelib/io/qsettings/tst_qsettings.cpp45
-rw-r--r--tests/auto/corelib/kernel/qsystemsemaphore/test/tst_qsystemsemaphore.cpp26
-rw-r--r--tests/auto/corelib/thread/qreadwritelock/tst_qreadwritelock.cpp10
-rw-r--r--tests/auto/corelib/tools/qcommandlineparser/testhelper/qcommandlineparser_test_helper.cpp11
-rw-r--r--tests/auto/corelib/tools/qcommandlineparser/tst_qcommandlineparser.cpp49
-rw-r--r--tests/auto/printsupport/kernel/qprinterinfo/tst_qprinterinfo.cpp9
-rw-r--r--tests/auto/testlib/selftests/tst_selftests.cpp68
-rw-r--r--tests/auto/widgets/dialogs/qprogressdialog/tst_qprogressdialog.cpp30
-rw-r--r--tests/auto/widgets/itemviews/qabstractitemview/tst_qabstractitemview.cpp154
-rw-r--r--tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp2
-rw-r--r--tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp58
-rw-r--r--tests/auto/widgets/kernel/qformlayout/tst_qformlayout.cpp14
-rw-r--r--tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp6
-rw-r--r--tests/auto/widgets/widgets/qkeysequenceedit/tst_qkeysequenceedit.cpp24
-rw-r--r--tests/auto/widgets/widgets/qmdisubwindow/tst_qmdisubwindow.cpp8
-rw-r--r--tests/auto/widgets/widgets/qmenu/tst_qmenu.cpp53
-rw-r--r--tests/benchmarks/corelib/io/qprocess/testProcessLoopback/testProcessLoopback.pro1
-rw-r--r--tests/benchmarks/corelib/thread/qmutex/tst_qmutex.cpp4
18 files changed, 435 insertions, 137 deletions
diff --git a/tests/auto/corelib/io/qsettings/tst_qsettings.cpp b/tests/auto/corelib/io/qsettings/tst_qsettings.cpp
index dc83cf2fc4..c5a9b421ee 100644
--- a/tests/auto/corelib/io/qsettings/tst_qsettings.cpp
+++ b/tests/auto/corelib/io/qsettings/tst_qsettings.cpp
@@ -507,32 +507,26 @@ void tst_QSettings::ctor()
QCOMPARE(settings1.value("%General/%General").toInt(), 11);
/*
- Test that the organization and product parameters is
- case-insensitive on Windows and Mac, case-sensitive on
- Unix.
+ Test that the organization and product parameters are
+ case-insensitive on case-insensitive file systems.
*/
QSettings settings5(format, QSettings::UserScope, "SoftWare.ORG", "killerApp");
+
+ bool caseSensitive = true;
+#if defined(Q_OS_MAC)
if (format == QSettings::NativeFormat) {
-#if defined(Q_OS_WIN) || defined(Q_OS_DARWIN)
-# ifdef Q_OS_OSX
- if (QSysInfo::MacintoshVersion == QSysInfo::MV_10_8)
- QEXPECT_FAIL("native", "See QTBUG-32655", Continue);
-# endif // Q_OS_OSX
- QCOMPARE(settings5.value("key 1").toString(), QString("gurgle"));
-#else
- QVERIFY(!settings5.contains("key 1"));
-#endif
+ // more details in QMacSettingsPrivate::QMacSettingsPrivate(), organization was comify()-ed
+ caseSensitive = settings5.fileName().contains("SoftWare.ORG");;
} else {
-#if defined(Q_OS_WIN) || defined(Q_OS_DARWIN)
-# ifdef Q_OS_OSX
- if (QSysInfo::MacintoshVersion == QSysInfo::MV_10_8)
- QEXPECT_FAIL("", "See QTBUG-32655", Continue);
-# endif // Q_OS_OSX
- QCOMPARE(settings5.value("key 1").toString(), QString("gurgle"));
-#else
- QVERIFY(!settings5.contains("key 1"));
-#endif
+ caseSensitive = pathconf(QDir::currentPath().toLatin1().constData(), _PC_CASE_SENSITIVE);
}
+#elif defined(Q_OS_WIN32)
+ caseSensitive = false;
+#endif
+ if (caseSensitive)
+ QVERIFY(!settings5.contains("key 1"));
+ else
+ QVERIFY(settings5.contains("key 1"));
}
{
@@ -3168,6 +3162,11 @@ void tst_QSettings::rainersSyncBugOnMac()
{
QFETCH(QSettings::Format, format);
+#ifdef Q_OS_OSX
+ if (format == QSettings::NativeFormat)
+ QSKIP("OSX does not support direct reads from and writes to .plist files, due to caching and background syncing. See QTBUG-34899.");
+#endif
+
QString fileName;
{
@@ -3183,10 +3182,6 @@ void tst_QSettings::rainersSyncBugOnMac()
{
QSettings s3(format, QSettings::UserScope, "software.org", "KillerAPP");
-#ifdef Q_OS_OSX
- if (QSysInfo::MacintoshVersion == QSysInfo::MV_10_8)
- QEXPECT_FAIL("native", "See QTBUG-32655", Continue);
-#endif
QCOMPARE(s3.value("key1", 30).toInt(), 25);
}
}
diff --git a/tests/auto/corelib/kernel/qsystemsemaphore/test/tst_qsystemsemaphore.cpp b/tests/auto/corelib/kernel/qsystemsemaphore/test/tst_qsystemsemaphore.cpp
index d2b6848dab..9e33f56a34 100644
--- a/tests/auto/corelib/kernel/qsystemsemaphore/test/tst_qsystemsemaphore.cpp
+++ b/tests/auto/corelib/kernel/qsystemsemaphore/test/tst_qsystemsemaphore.cpp
@@ -65,6 +65,7 @@ private slots:
void basicacquire();
void complexacquire();
+ void release();
#ifndef QT_NO_PROCESS
void basicProcesses();
@@ -145,12 +146,37 @@ void tst_QSystemSemaphore::complexacquire()
{
QSystemSemaphore sem("QSystemSemaphore_complexacquire", 2, QSystemSemaphore::Create);
QVERIFY(sem.acquire());
+ QCOMPARE(sem.error(), QSystemSemaphore::NoError);
QVERIFY(sem.release());
+ QCOMPARE(sem.error(), QSystemSemaphore::NoError);
QVERIFY(sem.acquire());
+ QCOMPARE(sem.error(), QSystemSemaphore::NoError);
QVERIFY(sem.release());
+ QCOMPARE(sem.error(), QSystemSemaphore::NoError);
QVERIFY(sem.acquire());
+ QCOMPARE(sem.error(), QSystemSemaphore::NoError);
QVERIFY(sem.acquire());
+ QCOMPARE(sem.error(), QSystemSemaphore::NoError);
QVERIFY(sem.release());
+ QCOMPARE(sem.error(), QSystemSemaphore::NoError);
+ QVERIFY(sem.release());
+ QCOMPARE(sem.error(), QSystemSemaphore::NoError);
+ QCOMPARE(sem.errorString(), QString());
+}
+
+void tst_QSystemSemaphore::release()
+{
+ QSystemSemaphore sem("QSystemSemaphore_release", 0, QSystemSemaphore::Create);
+ QVERIFY(sem.release());
+ QCOMPARE(sem.error(), QSystemSemaphore::NoError);
+ QVERIFY(sem.release());
+ QCOMPARE(sem.error(), QSystemSemaphore::NoError);
+ QVERIFY(sem.acquire());
+ QCOMPARE(sem.error(), QSystemSemaphore::NoError);
+ QVERIFY(sem.acquire());
+ QCOMPARE(sem.error(), QSystemSemaphore::NoError);
+ QVERIFY(sem.release());
+ QCOMPARE(sem.error(), QSystemSemaphore::NoError);
QVERIFY(sem.release());
QCOMPARE(sem.error(), QSystemSemaphore::NoError);
QCOMPARE(sem.errorString(), QString());
diff --git a/tests/auto/corelib/thread/qreadwritelock/tst_qreadwritelock.cpp b/tests/auto/corelib/thread/qreadwritelock/tst_qreadwritelock.cpp
index 7d041e69cb..ac8d433f96 100644
--- a/tests/auto/corelib/thread/qreadwritelock/tst_qreadwritelock.cpp
+++ b/tests/auto/corelib/thread/qreadwritelock/tst_qreadwritelock.cpp
@@ -49,9 +49,13 @@
#ifdef Q_OS_UNIX
#include <unistd.h>
#endif
-#if defined(Q_OS_WIN32) || defined(Q_OS_WINCE)
-#include <windows.h>
-#define sleep(X) Sleep(X)
+#if defined(Q_OS_WIN)
+# include <qt_windows.h>
+# ifndef Q_OS_WINRT
+# define sleep(X) Sleep(X)
+# else
+# define sleep(X) WaitForSingleObjectEx(GetCurrentThread(), X, FALSE);
+# endif
#endif
//on solaris, threads that loop on the release bool variable
diff --git a/tests/auto/corelib/tools/qcommandlineparser/testhelper/qcommandlineparser_test_helper.cpp b/tests/auto/corelib/tools/qcommandlineparser/testhelper/qcommandlineparser_test_helper.cpp
index 07f8ddfc8e..2b30b0486b 100644
--- a/tests/auto/corelib/tools/qcommandlineparser/testhelper/qcommandlineparser_test_helper.cpp
+++ b/tests/auto/corelib/tools/qcommandlineparser/testhelper/qcommandlineparser_test_helper.cpp
@@ -69,9 +69,18 @@ int main(int argc, char *argv[])
// An option with a longer description, to test wrapping
QCommandLineOption noImplicitIncludesOption(QStringList() << QStringLiteral("n") << QStringLiteral("no-implicit-includes"));
- noImplicitIncludesOption.setDescription(QStringLiteral("Disable automatic generation of implicit #include-directives."));
+ noImplicitIncludesOption.setDescription(QStringLiteral("Disable magic generation of implicit #include-directives."));
parser.addOption(noImplicitIncludesOption);
+ QCommandLineOption newlineOption(QStringList() << QStringLiteral("newline"));
+ newlineOption.setDescription(QString::fromLatin1("This is an option with a rather long\n"
+ "description using explicit newline characters "
+ "(but testing automatic wrapping too). In addition, "
+ "here, we test breaking after a comma. Testing -option. "
+ "Long URL: http://qt-project.org/wiki/How_to_create_a_library_with_Qt_and_use_it_in_an_application "
+ "abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz"));
+ parser.addOption(newlineOption);
+
// This program supports different options depending on the "command" (first argument).
// Call parse() to find out the positional arguments.
parser.parse(QCoreApplication::arguments());
diff --git a/tests/auto/corelib/tools/qcommandlineparser/tst_qcommandlineparser.cpp b/tests/auto/corelib/tools/qcommandlineparser/tst_qcommandlineparser.cpp
index d8965dee5d..f37e192ad3 100644
--- a/tests/auto/corelib/tools/qcommandlineparser/tst_qcommandlineparser.cpp
+++ b/tests/auto/corelib/tools/qcommandlineparser/tst_qcommandlineparser.cpp
@@ -459,27 +459,40 @@ void tst_QCommandLineParser::testVersionOption()
#endif // !QT_NO_PROCESS
}
+static const char expectedOptionsHelp[] =
+ "Options:\n"
+ " -h, --help Displays this help.\n"
+ " -v, --version Displays version information.\n"
+ " --load <url> Load file from URL.\n"
+ " -o, --output <file> Set output file.\n"
+ " -D <key=value> Define macro.\n"
+ " -n, --no-implicit-includes Disable magic generation of implicit\n"
+ " #include-directives.\n"
+ " --newline This is an option with a rather long\n"
+ " description using explicit newline characters (but\n"
+ " testing automatic wrapping too). In addition,\n"
+ " here, we test breaking after a comma. Testing\n"
+ " -option. Long URL:\n"
+ " http://qt-project.org/wiki/How_to_create_a_library\n"
+ " _with_Qt_and_use_it_in_an_application\n"
+ " abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwx\n"
+ " yzabcdefghijklmnopqrstuvwxyz\n";
+
void tst_QCommandLineParser::testHelpOption_data()
{
QTest::addColumn<QCommandLineParser::SingleDashWordOptionMode>("parsingMode");
QTest::addColumn<QString>("expectedHelpOutput");
- QString expectedOutput =
+ QString expectedOutput = QString::fromLatin1(
"Usage: testhelper/qcommandlineparser_test_helper [options] parsingMode command\n"
"Test helper\n"
- "\n"
- "Options:\n"
- " -h, --help Displays this help.\n"
- " -v, --version Displays version information.\n"
- " --load <url> Load file from URL.\n"
- " -o, --output <file> Set output file.\n"
- " -D <key=value> Define macro.\n"
- " -n, --no-implicit-includes Disable automatic generation of implicit #include\n"
- " -directives.\n"
+ "\n")
+ + QString::fromLatin1(expectedOptionsHelp) +
+ QString::fromLatin1(
"\n"
"Arguments:\n"
" parsingMode The parsing mode to test.\n"
- " command The command to execute.\n";
+ " command The command to execute.\n");
#ifdef Q_OS_WIN
expectedOutput.replace(" -h, --help Displays this help.\n",
" -?, -h, --help Displays this help.\n");
@@ -510,6 +523,7 @@ void tst_QCommandLineParser::testHelpOption()
#ifdef Q_OS_WIN
output.replace(QStringLiteral("\r\n"), QStringLiteral("\n"));
#endif
+ QCOMPARE(output.split('\n'), expectedHelpOutput.split('\n')); // easier to debug than the next line, on failure
QCOMPARE(output, expectedHelpOutput);
process.start("testhelper/qcommandlineparser_test_helper", QStringList() << "0" << "resize" << "--help");
@@ -519,18 +533,11 @@ void tst_QCommandLineParser::testHelpOption()
#ifdef Q_OS_WIN
output.replace(QStringLiteral("\r\n"), QStringLiteral("\n"));
#endif
- QByteArray expectedResizeHelp =
+ QByteArray expectedResizeHelp = QByteArrayLiteral(
"Usage: testhelper/qcommandlineparser_test_helper [options] resize [resize_options]\n"
"Test helper\n"
- "\n"
- "Options:\n"
- " -h, --help Displays this help.\n"
- " -v, --version Displays version information.\n"
- " --load <url> Load file from URL.\n"
- " -o, --output <file> Set output file.\n"
- " -D <key=value> Define macro.\n"
- " -n, --no-implicit-includes Disable automatic generation of implicit #include\n"
- " -directives.\n"
+ "\n")
+ + expectedOptionsHelp +
" --size <size> New size.\n"
"\n"
"Arguments:\n"
diff --git a/tests/auto/printsupport/kernel/qprinterinfo/tst_qprinterinfo.cpp b/tests/auto/printsupport/kernel/qprinterinfo/tst_qprinterinfo.cpp
index 7deb31c2c9..9416224440 100644
--- a/tests/auto/printsupport/kernel/qprinterinfo/tst_qprinterinfo.cpp
+++ b/tests/auto/printsupport/kernel/qprinterinfo/tst_qprinterinfo.cpp
@@ -275,6 +275,9 @@ void tst_QPrinterInfo::testConstructors()
QCOMPARE(null.printerName(), QString());
QVERIFY(null.isNull());
+ QPrinterInfo null2(null);
+ QVERIFY(null2.isNull());
+
QList<QPrinterInfo> printers = QPrinterInfo::availablePrinters();
for (int i = 0; i < printers.size(); ++i) {
@@ -295,6 +298,12 @@ void tst_QPrinterInfo::testConstructors()
void tst_QPrinterInfo::testAssignment()
{
+ QPrinterInfo null;
+ QVERIFY(null.isNull());
+ QPrinterInfo null2;
+ null2 = null;
+ QVERIFY(null2.isNull());
+
QList<QPrinterInfo> printers = QPrinterInfo::availablePrinters();
for (int i = 0; i < printers.size(); ++i) {
diff --git a/tests/auto/testlib/selftests/tst_selftests.cpp b/tests/auto/testlib/selftests/tst_selftests.cpp
index b737f823c8..e332f01861 100644
--- a/tests/auto/testlib/selftests/tst_selftests.cpp
+++ b/tests/auto/testlib/selftests/tst_selftests.cpp
@@ -63,7 +63,7 @@ private slots:
void cleanup();
private:
- void doRunSubTest(QString const& subdir, QStringList const& loggers, QStringList const& arguments);
+ void doRunSubTest(QString const& subdir, QStringList const& loggers, QStringList const& arguments, bool crashes);
QString logName(const QString &logger) const;
QList<LoggerSet> allLoggerSets() const;
@@ -324,6 +324,7 @@ void tst_Selftests::runSubTest_data()
QTest::addColumn<QString>("subdir");
QTest::addColumn<QStringList>("loggers");
QTest::addColumn<QStringList>("arguments");
+ QTest::addColumn<bool>("crashes");
QStringList tests = QStringList()
// << "alive" // timer dependent
@@ -479,11 +480,14 @@ void tst_Selftests::runSubTest_data()
continue;
}
}
-
+ const bool crashes = subtest == QLatin1String("assert") || subtest == QLatin1String("exceptionthrow")
+ || subtest == QLatin1String("fetchbogus") || subtest == QLatin1String("crashedterminate")
+ || subtest == QLatin1String("crashes") || subtest == QLatin1String("silent");
QTest::newRow(qPrintable(QString("%1 %2").arg(subtest).arg(loggerSet.name)))
<< subtest
<< loggers
<< arguments
+ << crashes
;
}
}
@@ -491,30 +495,41 @@ void tst_Selftests::runSubTest_data()
#ifndef QT_NO_PROCESS
-static void insertEnvironmentVariable(QString const& name, QProcessEnvironment &result)
-{
- const QProcessEnvironment systemEnvironment = QProcessEnvironment::systemEnvironment();
- const QString value = systemEnvironment.value(name);
- if (!value.isEmpty())
- result.insert(name, value);
-}
-
-static inline QProcessEnvironment processEnvironment()
+static QProcessEnvironment processEnvironment()
{
- QProcessEnvironment result;
- insertEnvironmentVariable(QStringLiteral("PATH"), result);
- // Preserve DISPLAY for X11 as some tests use Qt GUI.
-#if defined(Q_OS_UNIX) && !defined(Q_OS_MAC)
- insertEnvironmentVariable(QStringLiteral("DISPLAY"), result);
-#endif
- insertEnvironmentVariable(QStringLiteral("QT_QPA_PLATFORM"), result);
+ static QProcessEnvironment result;
+ if (result.isEmpty()) {
+ const QProcessEnvironment systemEnvironment = QProcessEnvironment::systemEnvironment();
+ foreach (const QString &key, systemEnvironment.keys()) {
+ const bool useVariable = key == QLatin1String("PATH") || key == QLatin1String("QT_QPA_PLATFORM")
+#ifdef Q_OS_UNIX
+ || key == QLatin1String("HOME") || key == QLatin1String("USER") // Required for X11 on openSUSE
+# ifndef Q_OS_MAC
+ || key == QLatin1String("DISPLAY") || key == QLatin1String("XAUTHLOCALHOSTNAME")
+ || key.startsWith(QLatin1String("XDG_"))
+# endif // !Q_OS_MAC
+#endif // Q_OS_UNIX
#ifdef __COVERAGESCANNER__
- insertEnvironmentVariable(QStringLiteral("QT_TESTCOCOON_ACTIVE"), result);
+ || key == QLatin1String("QT_TESTCOCOON_ACTIVE")
#endif
+ ;
+ if (useVariable)
+ result.insert(key, systemEnvironment.value(key));
+ }
+ }
return result;
}
-void tst_Selftests::doRunSubTest(QString const& subdir, QStringList const& loggers, QStringList const& arguments)
+static inline QByteArray msgProcessError(const QString &binary, const QStringList &args,
+ const QProcessEnvironment &e, const QString &what)
+{
+ QString result;
+ QTextStream(&result) <<"Error running " << binary << ' ' << args.join(' ')
+ << " with environment " << e.toStringList().join(' ') << ": " << what;
+ return result.toLocal8Bit();
+}
+
+void tst_Selftests::doRunSubTest(QString const& subdir, QStringList const& loggers, QStringList const& arguments, bool crashes)
{
#if defined(__GNUC__) && defined(__i386) && defined(Q_OS_LINUX)
if (arguments.contains("-callgrind")) {
@@ -532,8 +547,14 @@ void tst_Selftests::doRunSubTest(QString const& subdir, QStringList const& logge
proc.setProcessEnvironment(environment);
const QString path = subdir + QLatin1Char('/') + subdir;
proc.start(path, arguments);
- QVERIFY2(proc.waitForStarted(), qPrintable(QString::fromLatin1("Cannot start '%1': %2").arg(path, proc.errorString())));
- QVERIFY2(proc.waitForFinished(), qPrintable(proc.errorString()));
+ QVERIFY2(proc.waitForStarted(), msgProcessError(path, arguments, environment, QStringLiteral("Cannot start: ") + proc.errorString()));
+ QVERIFY2(proc.waitForFinished(), msgProcessError(path, arguments, environment, QStringLiteral("Timed out: ") + proc.errorString()));
+ if (!crashes) {
+ QVERIFY2(proc.exitStatus() == QProcess::NormalExit,
+ msgProcessError(path, arguments, environment,
+ QStringLiteral("Crashed: ") + proc.errorString()
+ + QStringLiteral(": ") + QString::fromLocal8Bit(proc.readAllStandardError())));
+ }
QList<QByteArray> actualOutputs;
for (int i = 0; i < loggers.count(); ++i) {
@@ -700,8 +721,9 @@ void tst_Selftests::runSubTest()
QFETCH(QString, subdir);
QFETCH(QStringList, loggers);
QFETCH(QStringList, arguments);
+ QFETCH(bool, crashes);
- doRunSubTest(subdir, loggers, arguments);
+ doRunSubTest(subdir, loggers, arguments, crashes);
#endif // !QT_NO_PROCESS
}
diff --git a/tests/auto/widgets/dialogs/qprogressdialog/tst_qprogressdialog.cpp b/tests/auto/widgets/dialogs/qprogressdialog/tst_qprogressdialog.cpp
index 68502f0d8d..060fa51293 100644
--- a/tests/auto/widgets/dialogs/qprogressdialog/tst_qprogressdialog.cpp
+++ b/tests/auto/widgets/dialogs/qprogressdialog/tst_qprogressdialog.cpp
@@ -57,6 +57,8 @@ public:
virtual ~tst_QProgressDialog();
private slots:
+ void autoShow_data();
+ void autoShow();
void getSetCheck();
void task198202();
void QTBUG_31046();
@@ -70,6 +72,34 @@ tst_QProgressDialog::~tst_QProgressDialog()
{
}
+void tst_QProgressDialog::autoShow_data()
+{
+ QTest::addColumn<int>("min");
+ QTest::addColumn<int>("max");
+ QTest::addColumn<int>("delay");
+ QTest::addColumn<bool>("expectedAutoShow");
+
+ QTest::newRow("50_to_100_long") << 50 << 100 << 100 << true; // 50*100ms = 5s
+ QTest::newRow("50_to_100_short") << 50 << 1 << 100 << false; // 50*1ms = 50ms
+
+ QTest::newRow("0_to_100_long") << 0 << 100 << 100 << true; // 100*100ms = 10s
+ QTest::newRow("0_to_10_short") << 0 << 10 << 100 << false; // 10*100ms = 1s
+}
+
+void tst_QProgressDialog::autoShow()
+{
+ QFETCH(int, min);
+ QFETCH(int, max);
+ QFETCH(int, delay);
+ QFETCH(bool, expectedAutoShow);
+
+ QProgressDialog dlg("", "", min, max);
+ dlg.setValue(0);
+ QThread::msleep(delay);
+ dlg.setValue(min+1);
+ QCOMPARE(dlg.isVisible(), expectedAutoShow);
+}
+
// Testing get/set functions
void tst_QProgressDialog::getSetCheck()
{
diff --git a/tests/auto/widgets/itemviews/qabstractitemview/tst_qabstractitemview.cpp b/tests/auto/widgets/itemviews/qabstractitemview/tst_qabstractitemview.cpp
index 0c6d369254..36bf76564f 100644
--- a/tests/auto/widgets/itemviews/qabstractitemview/tst_qabstractitemview.cpp
+++ b/tests/auto/widgets/itemviews/qabstractitemview/tst_qabstractitemview.cpp
@@ -58,17 +58,8 @@
#include <qscrollbar.h>
#include <qboxlayout.h>
#include <qlineedit.h>
-
-// Will try to wait for the condition while allowing event processing
-// for a maximum of 5 seconds.
-#define TRY_COMPARE(expr, expected) \
- do { \
- const int step = 50; \
- for (int q = 0; q < 5000 && ((expr) != (expected)); q+=step) { \
- QTest::qWait(step); \
- } \
- QCOMPARE(expr, expected); \
- } while(0)
+#include <qscreen.h>
+#include <qscopedpointer.h>
static inline void setFrameless(QWidget *w)
{
@@ -78,6 +69,22 @@ static inline void setFrameless(QWidget *w)
w->setWindowFlags(flags);
}
+static inline void centerOnScreen(QWidget *w)
+{
+ const QPoint offset = QPoint(w->width() / 2, w->height() / 2);
+ w->move(QGuiApplication::primaryScreen()->availableGeometry().center() - offset);
+}
+
+// Move cursor out of widget area to avoid undesired interaction on Mac.
+static inline void moveCursorAway(const QWidget *topLevel)
+{
+#ifndef QT_NO_CURSOR
+ QCursor::setPos(topLevel->geometry().topRight() + QPoint(100, 0));
+#else
+ Q_UNUSED(topLevel)
+#endif
+}
+
class TestView : public QAbstractItemView
{
Q_OBJECT
@@ -374,25 +381,27 @@ void tst_QAbstractItemView::emptyModels()
{
QFETCH(QString, viewType);
- TestView *view = 0;
+ QScopedPointer<QAbstractItemView> view;
if (viewType == "QListView")
- view = reinterpret_cast<TestView*>(new QListView());
+ view.reset(new QListView());
else if (viewType == "QTableView")
- view = reinterpret_cast<TestView*>(new QTableView());
+ view.reset(new QTableView());
else if (viewType == "QTreeView")
- view = reinterpret_cast<TestView*>(new QTreeView());
+ view.reset(new QTreeView());
else if (viewType == "QHeaderView")
- view = reinterpret_cast<TestView*>(new QHeaderView(Qt::Vertical));
+ view.reset(new QHeaderView(Qt::Vertical));
else
QVERIFY(0);
+ centerOnScreen(view.data());
+ moveCursorAway(view.data());
view->show();
+ QVERIFY(QTest::qWaitForWindowExposed(view.data()));
QVERIFY(!view->model());
QVERIFY(!view->selectionModel());
//QVERIFY(view->itemDelegate() != 0);
- basic_tests(view);
- delete view;
+ basic_tests(reinterpret_cast<TestView*>(view.data()));
}
void tst_QAbstractItemView::setModel_data()
@@ -408,24 +417,28 @@ void tst_QAbstractItemView::setModel_data()
void tst_QAbstractItemView::setModel()
{
QFETCH(QString, viewType);
- TestView *view = 0;
+
+ QScopedPointer<QAbstractItemView> view;
+
if (viewType == "QListView")
- view = reinterpret_cast<TestView*>(new QListView());
+ view.reset(new QListView());
else if (viewType == "QTableView")
- view = reinterpret_cast<TestView*>(new QTableView());
+ view.reset(new QTableView());
else if (viewType == "QTreeView")
- view = reinterpret_cast<TestView*>(new QTreeView());
+ view.reset(new QTreeView());
else if (viewType == "QHeaderView")
- view = reinterpret_cast<TestView*>(new QHeaderView(Qt::Vertical));
+ view.reset(new QHeaderView(Qt::Vertical));
else
QVERIFY(0);
+ centerOnScreen(view.data());
+ moveCursorAway(view.data());
view->show();
+ QVERIFY(QTest::qWaitForWindowExposed(view.data()));
QStandardItemModel model(20,20);
view->setModel(0);
view->setModel(&model);
- basic_tests(view);
- delete view;
+ basic_tests(reinterpret_cast<TestView*>(view.data()));
}
void tst_QAbstractItemView::basic_tests(TestView *view)
@@ -636,7 +649,10 @@ void tst_QAbstractItemView::noModel()
view.setModel(&model);
// Make the viewport smaller than the contents, so that we can scroll
view.resize(100,100);
+ centerOnScreen(&view);
+ moveCursorAway(&view);
view.show();
+ QVERIFY(QTest::qWaitForWindowExposed(&view));
// make sure that the scrollbars are not at value 0
view.scrollTo(view.model()->index(10,10));
@@ -656,7 +672,10 @@ void tst_QAbstractItemView::dragSelect()
QTableView view;
view.setModel(&model);
+ centerOnScreen(&view);
+ moveCursorAway(&view);
view.setVisible(true);
+ QVERIFY(QTest::qWaitForWindowExposed(&view));
const int delay = 2;
for (int i = 0; i < 2; ++i) {
@@ -677,7 +696,10 @@ void tst_QAbstractItemView::rowDelegate()
QTableView view;
view.setModel(&model);
view.setItemDelegateForRow(3, &delegate);
+ centerOnScreen(&view);
+ moveCursorAway(&view);
view.show();
+ QVERIFY(QTest::qWaitForWindowExposed(&view));
QModelIndex index = model.index(3, 0);
view.openPersistentEditor(index);
@@ -694,7 +716,10 @@ void tst_QAbstractItemView::columnDelegate()
QTableView view;
view.setModel(&model);
view.setItemDelegateForColumn(3, &delegate);
+ centerOnScreen(&view);
+ moveCursorAway(&view);
view.show();
+ QVERIFY(QTest::qWaitForWindowExposed(&view));
QModelIndex index = model.index(0, 3);
view.openPersistentEditor(index);
@@ -747,11 +772,13 @@ void tst_QAbstractItemView::persistentEditorFocus()
view.setCurrentIndex(model.index(0, 0));
QCOMPARE(view.currentIndex(), model.index(0, 0));
+ centerOnScreen(&view);
+ moveCursorAway(&view);
view.show();
- QTRY_VERIFY(view.isVisible());
+ QVERIFY(QTest::qWaitForWindowExposed(&view));
for (int i = 0; i < list.count(); ++i) {
- TRY_COMPARE(list.at(i)->isVisible(), true);
+ QTRY_VERIFY(list.at(i)->isVisible());
QPoint p = QPoint(5, 5);
QMouseEvent mouseEvent(QEvent::MouseButtonPress, p, Qt::LeftButton,
Qt::LeftButton, Qt::NoModifier);
@@ -1045,6 +1072,8 @@ void tst_QAbstractItemView::setItemDelegate()
}
}
}
+ centerOnScreen(&v);
+ moveCursorAway(&v);
v.show();
#ifdef Q_WS_X11
QCursor::setPos(v.geometry().center());
@@ -1056,7 +1085,7 @@ void tst_QAbstractItemView::setItemDelegate()
v.edit(index);
// This will close the editor
- TRY_COMPARE(QApplication::focusWidget() == 0, false);
+ QTRY_VERIFY(QApplication::focusWidget());
QWidget *editor = QApplication::focusWidget();
QVERIFY(editor);
editor->hide();
@@ -1122,20 +1151,25 @@ void tst_QAbstractItemView::setCurrentIndex()
QFETCH(int, itemFlags);
QFETCH(bool, result);
- TestView *view = 0;
+ QScopedPointer<QAbstractItemView> view;
+
if (viewType == "QListView")
- view = reinterpret_cast<TestView*>(new QListView());
+ view.reset(new QListView());
else if (viewType == "QTableView")
- view = reinterpret_cast<TestView*>(new QTableView());
+ view.reset(new QTableView());
else if (viewType == "QTreeView")
- view = reinterpret_cast<TestView*>(new QTreeView());
+ view.reset(new QTreeView());
else if (viewType == "QHeaderView")
- view = reinterpret_cast<TestView*>(new QHeaderView(Qt::Vertical));
+ view.reset(new QHeaderView(Qt::Vertical));
else
QVERIFY(0);
+
+ centerOnScreen(view.data());
+ moveCursorAway(view.data());
view->show();
+ QVERIFY(QTest::qWaitForWindowExposed(view.data()));
- QStandardItemModel *model = new QStandardItemModel(view);
+ QStandardItemModel *model = new QStandardItemModel(view.data());
QStandardItem *item = new QStandardItem("first item");
item->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
model->appendRow(item);
@@ -1150,8 +1184,6 @@ void tst_QAbstractItemView::setCurrentIndex()
QVERIFY(view->currentIndex() == model->index(0,0));
view->setCurrentIndex(model->index(1,0));
QVERIFY(view->currentIndex() == model->index(result ? 1 : 0,0));
-
- delete view;
}
void tst_QAbstractItemView::task221955_selectedEditor()
@@ -1170,11 +1202,13 @@ void tst_QAbstractItemView::task221955_selectedEditor()
tree.setItemWidget(dummy, 0, button = new QPushButton("More..."));
button->setAutoFillBackground(true); // as recommended in doc
+ centerOnScreen(&tree);
+ moveCursorAway(&tree);
tree.show();
tree.setFocus();
tree.setCurrentIndex(tree.model()->index(1,0));
- QTest::qWait(100);
QApplication::setActiveWindow(&tree);
+ QVERIFY(QTest::qWaitForWindowActive(&tree));
QVERIFY(! tree.selectionModel()->selectedIndexes().contains(tree.model()->index(3,0)));
@@ -1218,9 +1252,11 @@ void tst_QAbstractItemView::task250754_fontChange()
}
tree.setModel(m);
+ w.resize(160, 240); // Minimum width for windows with frame on Windows 8
+ centerOnScreen(&w);
+ moveCursorAway(&w);
w.show();
- w.resize(150,240);
- QTest::qWait(30);
+ QVERIFY(QTest::qWaitForWindowExposed(&w));
QFont font = tree.font();
font.setPixelSize(10);
tree.setFont(font);
@@ -1244,8 +1280,10 @@ void tst_QAbstractItemView::task200665_itemEntered()
QStandardItemModel model(1000,1);
QListView view;
view.setModel(&model);
+ centerOnScreen(&view);
+ moveCursorAway(&view);
view.show();
- QTest::qWait(200);
+ QVERIFY(QTest::qWaitForWindowExposed(&view));
QRect rect = view.visualRect(model.index(0,0));
QCursor::setPos( view.viewport()->mapToGlobal(rect.center()) );
QSignalSpy spy(&view, SIGNAL(entered(QModelIndex)));
@@ -1267,7 +1305,10 @@ void tst_QAbstractItemView::task257481_emptyEditor()
QTreeView treeView;
treeView.setRootIsDecorated(false);
treeView.setModel(&model);
+ centerOnScreen(&treeView);
+ moveCursorAway(&treeView);
treeView.show();
+ QVERIFY(QTest::qWaitForWindowExposed(&treeView));
treeView.edit(model.index(0,0));
QList<QLineEdit *> lineEditors = treeView.viewport()->findChildren<QLineEdit *>();
@@ -1298,14 +1339,16 @@ void tst_QAbstractItemView::shiftArrowSelectionAfterScrolling()
}
QListView view;
- view.setFixedSize(150, 250);
+ view.setFixedSize(160, 250); // Minimum width for windows with frame on Windows 8
view.setFlow(QListView::LeftToRight);
view.setGridSize(QSize(100, 100));
view.setSelectionMode(QListView::ExtendedSelection);
view.setViewMode(QListView::IconMode);
view.setModel(&model);
+ centerOnScreen(&view);
+ moveCursorAway(&view);
view.show();
- QTest::qWait(30);
+ QVERIFY(QTest::qWaitForWindowExposed(&view));
QModelIndex index0 = model.index(0, 0);
QModelIndex index1 = model.index(1, 0);
@@ -1333,14 +1376,16 @@ void tst_QAbstractItemView::shiftSelectionAfterRubberbandSelection()
}
QListView view;
- view.setFixedSize(150, 450);
+ view.setFixedSize(160, 450); // Minimum width for windows with frame on Windows 8
view.setFlow(QListView::LeftToRight);
view.setGridSize(QSize(100, 100));
view.setSelectionMode(QListView::ExtendedSelection);
view.setViewMode(QListView::IconMode);
view.setModel(&model);
+ centerOnScreen(&view);
+ moveCursorAway(&view);
view.show();
- QTest::qWait(30);
+ QVERIFY(QTest::qWaitForWindowExposed(&view));
QModelIndex index0 = model.index(0, 0);
QModelIndex index1 = model.index(1, 0);
@@ -1408,14 +1453,16 @@ void tst_QAbstractItemView::ctrlRubberbandSelection()
}
QListView view;
- view.setFixedSize(150, 450);
+ view.setFixedSize(160, 450); // Minimum width for windows with frame on Windows 8
view.setFlow(QListView::LeftToRight);
view.setGridSize(QSize(100, 100));
view.setSelectionMode(QListView::ExtendedSelection);
view.setViewMode(QListView::IconMode);
view.setModel(&model);
+ centerOnScreen(&view);
+ moveCursorAway(&view);
view.show();
- QTest::qWait(30);
+ QVERIFY(QTest::qWaitForWindowExposed(&view));
QModelIndex index1 = model.index(1, 0);
QModelIndex index2 = model.index(2, 0);
@@ -1454,6 +1501,8 @@ void tst_QAbstractItemView::QTBUG6407_extendedSelection()
font.setPixelSize(10);
view.setFont(font);
view.resize(200,240);
+ centerOnScreen(&view);
+ moveCursorAway(&view);
view.show();
QApplication::setActiveWindow(&view);
@@ -1493,7 +1542,11 @@ void tst_QAbstractItemView::QTBUG6753_selectOnSelection()
for (int j = 0; j < table.columnCount(); ++j)
table.setItem(i, j, new QTableWidgetItem("choo-be-doo-wah"));
+ centerOnScreen(&table);
+ moveCursorAway(&table);
table.show();
+ QVERIFY(QTest::qWaitForWindowExposed(&table));
+
table.setSelectionMode(QAbstractItemView::ExtendedSelection);
table.selectAll();
QVERIFY(QTest::qWaitForWindowExposed(&table));
@@ -1523,6 +1576,8 @@ void tst_QAbstractItemView::testClickedSignal()
{
QTableWidget view(5, 5);
+ centerOnScreen(&view);
+ moveCursorAway(&view);
view.show();
QApplication::setActiveWindow(&view);
QVERIFY(QTest::qWaitForWindowActive(&view));
@@ -1591,6 +1646,8 @@ void tst_QAbstractItemView::testChangeEditorState()
view.setEditTriggers(QAbstractItemView::CurrentChanged);
view.setItemDelegate(new StateChangeDelegate);
view.setModel(&model);
+ centerOnScreen(&view);
+ moveCursorAway(&view);
view.show();
QApplication::setActiveWindow(&view);
QVERIFY(QTest::qWaitForWindowActive(&view));
@@ -1607,7 +1664,10 @@ void tst_QAbstractItemView::deselectInSingleSelection()
s.setRowCount(10);
s.setColumnCount(10);
view.setModel(&s);
+ centerOnScreen(&view);
+ moveCursorAway(&view);
view.show();
+ QVERIFY(QTest::qWaitForWindowExposed(&view));
view.setSelectionMode(QAbstractItemView::SingleSelection);
view.setEditTriggers(QAbstractItemView::NoEditTriggers);
QApplication::setActiveWindow(&view);
@@ -1650,6 +1710,8 @@ void tst_QAbstractItemView::testNoActivateOnDisabledItem()
model.setItem(0, 0, item);
item->setFlags(Qt::NoItemFlags);
treeView.setModel(&model);
+ centerOnScreen(&treeView);
+ moveCursorAway(&treeView);
treeView.show();
QApplication::setActiveWindow(&treeView);
diff --git a/tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp b/tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp
index 398b1b4d98..3e6df0f136 100644
--- a/tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp
+++ b/tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp
@@ -368,6 +368,8 @@ void tst_QHeaderView::getSetCheck()
QCOMPARE(0, obj1.minimumSectionSize());
obj1.setMinimumSectionSize(99999);
QCOMPARE(99999, obj1.minimumSectionSize());
+ obj1.setMinimumSectionSize(-1);
+ QVERIFY(obj1.minimumSectionSize() < 100);
// int QHeaderView::offset()
// void QHeaderView::setOffset(int)
diff --git a/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp b/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp
index 8d75298673..091927abe4 100644
--- a/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp
+++ b/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp
@@ -153,6 +153,7 @@ private slots:
void focusChanged();
void focusOut();
+ void focusMouseClick();
void execAfterExit();
@@ -1771,6 +1772,63 @@ void tst_QApplication::focusOut()
QTest::qWait(2000);
}
+class SpontaneousEvent
+{
+ Q_GADGET
+ QDOC_PROPERTY(bool accepted READ isAccepted WRITE setAccepted)
+ Q_ENUMS(Type)
+public:
+ enum Type {
+ Void
+ };
+
+ virtual ~SpontaneousEvent() {}
+
+ QEventPrivate *d;
+ ushort t;
+
+ ushort posted : 1;
+ ushort spont : 1;
+};
+
+void tst_QApplication::focusMouseClick()
+{
+ int argc = 1;
+ QApplication app(argc, &argv0);
+
+ QWidget w;
+ w.setFocusPolicy(Qt::StrongFocus);
+ QWidget w2(&w);
+ w2.setFocusPolicy(Qt::TabFocus);
+ w.show();
+ w.setFocus();
+ QTRY_COMPARE(QApplication::focusWidget(), &w);
+
+ // front most widget has Qt::TabFocus, parent widget accepts clicks as well
+ // now send a mouse button press event and check what happens with the focus
+ // it should be given to the parent widget
+ QMouseEvent ev(QEvent::MouseButtonPress, QPointF(), Qt::LeftButton, Qt::LeftButton, Qt::NoModifier);
+ reinterpret_cast<SpontaneousEvent *>(&ev)->spont = 1;
+ QVERIFY(ev.spontaneous());
+ qApp->notify(&w2, &ev);
+ QCOMPARE(QApplication::focusWidget(), &w);
+
+ // then we give the inner widget strong focus -> it should get focus
+ w2.setFocusPolicy(Qt::StrongFocus);
+ reinterpret_cast<SpontaneousEvent *>(&ev)->spont = 1;
+ QVERIFY(ev.spontaneous());
+ qApp->notify(&w2, &ev);
+ QTRY_COMPARE(QApplication::focusWidget(), &w2);
+
+ // now back to tab focus and click again (it already had focus) -> focus should stay
+ // (focus was revoked as of QTBUG-34042)
+ w2.setFocusPolicy(Qt::TabFocus);
+ reinterpret_cast<SpontaneousEvent *>(&ev)->spont = 1;
+ QVERIFY(ev.spontaneous());
+ qApp->notify(&w2, &ev);
+ QCOMPARE(QApplication::focusWidget(), &w2);
+}
+
void tst_QApplication::execAfterExit()
{
int argc = 1;
diff --git a/tests/auto/widgets/kernel/qformlayout/tst_qformlayout.cpp b/tests/auto/widgets/kernel/qformlayout/tst_qformlayout.cpp
index 135605f185..d04b812878 100644
--- a/tests/auto/widgets/kernel/qformlayout/tst_qformlayout.cpp
+++ b/tests/auto/widgets/kernel/qformlayout/tst_qformlayout.cpp
@@ -47,6 +47,7 @@
#include <qproxystyle.h>
#include <qsizepolicy.h>
+#include <QtWidgets/QCheckBox>
#include <QtWidgets/QLabel>
#include <QtWidgets/QLineEdit>
#include <QtWidgets/QPushButton>
@@ -347,6 +348,19 @@ void tst_QFormLayout::spacing()
style->hspacing = 20;
//QCOMPARE(fl->spacing(), 20);
+
+
+ // Do not assert if spacings are negative (QTBUG-34731)
+ style->vspacing = -1;
+ style->hspacing = -1;
+ QLabel *label = new QLabel(tr("Asserts"));
+ QCheckBox *checkBox = new QCheckBox(tr("Yes"));
+ fl->setWidget(0, QFormLayout::LabelRole, label);
+ fl->setWidget(1, QFormLayout::FieldRole, checkBox);
+ w->resize(200, 100);
+ w->show();
+ QVERIFY(QTest::qWaitForWindowExposed(w));
+
delete w;
delete style;
}
diff --git a/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp b/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp
index 03d6c1cdbd..36a3a8bad5 100644
--- a/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp
+++ b/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp
@@ -171,7 +171,7 @@ static inline void centerOnScreen(QWidget *w)
w->move(QGuiApplication::primaryScreen()->availableGeometry().center() - offset);
}
-#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE)
+#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) && !defined(Q_OS_WINRT)
static inline void setWindowsAnimationsEnabled(bool enabled)
{
ANIMATIONINFO animation = { sizeof(ANIMATIONINFO), enabled };
@@ -184,10 +184,10 @@ static inline bool windowsAnimationsEnabled()
SystemParametersInfo(SPI_GETANIMATION, 0, &animation, 0);
return animation.iMinAnimate;
}
-#else // Q_OS_WIN && !Q_OS_WINCE
+#else // Q_OS_WIN && !Q_OS_WINCE && !Q_OS_WINRT
inline void setWindowsAnimationsEnabled(bool) {}
static inline bool windowsAnimationsEnabled() { return false; }
-#endif // !Q_OS_WIN || Q_OS_WINCE
+#endif // !Q_OS_WIN || Q_OS_WINCE || Q_OS_WINRT
class tst_QWidget : public QObject
{
diff --git a/tests/auto/widgets/widgets/qkeysequenceedit/tst_qkeysequenceedit.cpp b/tests/auto/widgets/widgets/qkeysequenceedit/tst_qkeysequenceedit.cpp
index 8c010abfe6..1434d98e59 100644
--- a/tests/auto/widgets/widgets/qkeysequenceedit/tst_qkeysequenceedit.cpp
+++ b/tests/auto/widgets/widgets/qkeysequenceedit/tst_qkeysequenceedit.cpp
@@ -43,6 +43,8 @@
#include <QtTest/QtTest>
#include <QKeySequenceEdit>
+#include <QLineEdit>
+#include <QString>
Q_DECLARE_METATYPE(Qt::Key)
Q_DECLARE_METATYPE(Qt::KeyboardModifiers)
@@ -55,6 +57,7 @@ private slots:
void testSetters();
void testKeys_data();
void testKeys();
+ void testLineEditContents();
};
void tst_QKeySequenceEdit::testSetters()
@@ -100,5 +103,26 @@ void tst_QKeySequenceEdit::testKeys()
QTRY_COMPARE(spy.count(), 1);
}
+void tst_QKeySequenceEdit::testLineEditContents()
+{
+ QKeySequenceEdit edit;
+ QLineEdit *le = edit.findChild<QLineEdit*>();
+ QVERIFY(le);
+
+ QCOMPARE(le->text(), QString());
+
+ edit.setKeySequence(QKeySequence::New);
+ QCOMPARE(edit.keySequence(), QKeySequence(QKeySequence::New));
+
+ edit.clear();
+ QCOMPARE(le->text(), QString());
+
+ edit.setKeySequence(QKeySequence::New);
+ QVERIFY(le->text() != QString());
+
+ edit.setKeySequence(QKeySequence());
+ QCOMPARE(le->text(), QString());
+}
+
QTEST_MAIN(tst_QKeySequenceEdit)
#include "tst_qkeysequenceedit.moc"
diff --git a/tests/auto/widgets/widgets/qmdisubwindow/tst_qmdisubwindow.cpp b/tests/auto/widgets/widgets/qmdisubwindow/tst_qmdisubwindow.cpp
index 5b146cf443..b3e50b8ba8 100644
--- a/tests/auto/widgets/widgets/qmdisubwindow/tst_qmdisubwindow.cpp
+++ b/tests/auto/widgets/widgets/qmdisubwindow/tst_qmdisubwindow.cpp
@@ -954,9 +954,6 @@ void tst_QMdiSubWindow::mouseDoubleClick()
QStyleOptionTitleBar options;
options.initFrom(window);
int height = window->style()->pixelMetric(QStyle::PM_TitleBarHeight, &options);
- // ### Remove this after mac style has been fixed
- if (window->style()->inherits("QMacStyle"))
- height -= 4;
// has border
if (!window->style()->styleHint(QStyle::SH_TitleBar_NoBorder, &options, window))
height += window->isMinimized() ? 8 : 4;
@@ -1692,11 +1689,6 @@ void tst_QMdiSubWindow::fixedMinMaxSize()
QStyleOptionTitleBar options;
options.initFrom(subWindow);
int minimizedHeight = subWindow->style()->pixelMetric(QStyle::PM_TitleBarHeight, &options);
-#if defined(Q_OS_MAC) && !defined(QT_NO_STYLE_MAC)
- // ### Remove this after mac style has been fixed
- if (subWindow->style()->inherits("QMacStyle"))
- minimizedHeight -= 4;
-#endif
if (!subWindow->style()->styleHint(QStyle::SH_TitleBar_NoBorder, &options, subWindow))
minimizedHeight += 8;
int minimizedWidth = subWindow->style()->pixelMetric(QStyle::PM_MDIMinimizedWidth, &options);
diff --git a/tests/auto/widgets/widgets/qmenu/tst_qmenu.cpp b/tests/auto/widgets/widgets/qmenu/tst_qmenu.cpp
index 7c1bb957d6..81ed983d0f 100644
--- a/tests/auto/widgets/widgets/qmenu/tst_qmenu.cpp
+++ b/tests/auto/widgets/widgets/qmenu/tst_qmenu.cpp
@@ -50,6 +50,7 @@
#include <QListWidget>
#include <QWidgetAction>
#include <QDesktopWidget>
+#include <QScreen>
#include <qdialog.h>
#include <qmenu.h>
@@ -59,6 +60,17 @@
Q_DECLARE_METATYPE(Qt::Key);
Q_DECLARE_METATYPE(Qt::KeyboardModifiers);
+static inline void centerOnScreen(QWidget *w, const QSize &size)
+{
+ const QPoint offset = QPoint(size.width() / 2, size.height() / 2);
+ w->move(QGuiApplication::primaryScreen()->availableGeometry().center() - offset);
+}
+
+static inline void centerOnScreen(QWidget *w)
+{
+ centerOnScreen(w, w->geometry().size());
+}
+
class tst_QMenu : public QObject
{
Q_OBJECT
@@ -257,9 +269,12 @@ void tst_QMenu::addActionsAndClear()
void tst_QMenu::mouseActivation()
{
QWidget topLevel;
+ topLevel.resize(300, 200);
+ centerOnScreen(&topLevel);
QMenu menu(&topLevel);
topLevel.show();
menu.addAction("Menu Action");
+ menu.move(topLevel.geometry().topRight() + QPoint(50, 0));
menu.show();
QTest::mouseClick(&menu, Qt::LeftButton, 0, menu.rect().center(), 300);
QVERIFY(!menu.isVisible());
@@ -275,8 +290,10 @@ void tst_QMenu::mouseActivation()
QMenu submenu("Menu");
submenu.addAction("action");
QAction *action = menubar.addMenu(&submenu);
+ menubar.move(topLevel.geometry().topRight() + QPoint(300, 0));
menubar.show();
+
QTest::mouseClick(&menubar, Qt::LeftButton, 0, menubar.actionGeometry(action).center(), 300);
QVERIFY(submenu.isVisible());
QTest::mouseClick(&submenu, Qt::LeftButton, 0, QPoint(5, 5), 300);
@@ -378,13 +395,16 @@ void tst_QMenu::focus()
#endif
QWidget window;
+ window.resize(300, 200);
QPushButton button("Push me", &window);
+ centerOnScreen(&window);
window.show();
qApp->setActiveWindow(&window);
QVERIFY(button.hasFocus());
QCOMPARE(QApplication::focusWidget(), (QWidget *)&button);
QCOMPARE(QApplication::activeWindow(), &window);
+ menu.move(window.geometry().topRight() + QPoint(50, 0));
menu.show();
QVERIFY(button.hasFocus());
QCOMPARE(QApplication::focusWidget(), (QWidget *)&button);
@@ -399,6 +419,8 @@ void tst_QMenu::overrideMenuAction()
{
//test the override menu action by first creating an action to which we set its menu
QMainWindow w;
+ w.resize(300, 200);
+ centerOnScreen(&w);
QAction *aFileMenu = new QAction("&File", &w);
w.menuBar()->addAction(aFileMenu);
@@ -442,6 +464,8 @@ void tst_QMenu::statusTip()
{
//check that the statustip of actions inserted into the menu are displayed
QMainWindow w;
+ w.resize(300, 200);
+ centerOnScreen(&w);
connect(w.statusBar(), SIGNAL(messageChanged(QString)), SLOT(onStatusMessageChanged(QString)));; //creates the status bar
QToolBar tb;
QAction a("main action", &tb);
@@ -540,10 +564,12 @@ void tst_QMenu::tearOff()
menu->addAction("bbb");
QVERIFY(menu->isTearOffEnabled());
+ widget.resize(300, 200);
+ centerOnScreen(&widget);
widget.show();
widget.activateWindow();
QVERIFY(QTest::qWaitForWindowActive(&widget));
- menu->popup(QPoint(0,0));
+ menu->popup(widget.geometry().topRight() + QPoint(50, 0));
QVERIFY(QTest::qWaitForWindowActive(menu));
QVERIFY(!menu->isTearOffMenuVisible());
@@ -568,14 +594,18 @@ void tst_QMenu::layoutDirection()
{
QMainWindow win;
win.setLayoutDirection(Qt::RightToLeft);
+ win.resize(300, 200);
+ centerOnScreen(&win);
QMenu menu(&win);
+ menu.move(win.geometry().topRight() + QPoint(50, 0));
menu.show();
QVERIFY(QTest::qWaitForWindowExposed(&menu));
QCOMPARE(menu.layoutDirection(), Qt::RightToLeft);
menu.close();
menu.setParent(0);
+ menu.move(win.geometry().topRight() + QPoint(50, 0));
menu.show();
QVERIFY(QTest::qWaitForWindowExposed(&menu));
QCOMPARE(menu.layoutDirection(), QApplication::layoutDirection());
@@ -702,6 +732,7 @@ void tst_QMenu::task256918_setFont()
QFont f;
f.setPointSize(30);
action->setFont(f);
+ centerOnScreen(&menu, QSize(120, 40));
menu.show(); //ensures that the actiongeometry are calculated
QVERIFY(menu.actionGeometry(action).height() > f.pointSize());
}
@@ -830,6 +861,13 @@ void PopulateOnAboutToShowTestMenu::populateMenu()
addSeparator();
}
+static inline QByteArray msgGeometryIntersects(const QRect &r1, const QRect &r2)
+{
+ QString result;
+ QDebug(&result) << r1 << "intersects" << r2;
+ return result.toLocal8Bit();
+}
+
void tst_QMenu::pushButtonPopulateOnAboutToShow()
{
QPushButton b("Test PushButton");
@@ -842,7 +880,7 @@ void tst_QMenu::pushButtonPopulateOnAboutToShow()
const QRect screen = QApplication::desktop()->screenGeometry(scrNumber);
QRect desiredGeometry = b.geometry();
- desiredGeometry.moveTopLeft(QPoint(10, screen.bottom()-b.height()-5));
+ desiredGeometry.moveTopLeft(QPoint(screen.x() + 10, screen.bottom() - b.height() - 5));
b.setGeometry(desiredGeometry);
QVERIFY(QTest::qWaitForWindowExposed(&b));
@@ -859,13 +897,13 @@ void tst_QMenu::pushButtonPopulateOnAboutToShow()
QTimer::singleShot(300, buttonMenu, SLOT(hide()));
QTest::mouseClick(&b, Qt::LeftButton, Qt::NoModifier, b.rect().center());
- QVERIFY(!buttonMenu->geometry().intersects(b.geometry()));
+ QVERIFY2(!buttonMenu->geometry().intersects(b.geometry()), msgGeometryIntersects(buttonMenu->geometry(), b.geometry()));
// note: we're assuming that, if we previously got the desired geometry, we'll get it here too
b.move(10, screen.bottom()-buttonMenu->height()-5);
QTimer::singleShot(300, buttonMenu, SLOT(hide()));
QTest::mouseClick(&b, Qt::LeftButton, Qt::NoModifier, b.rect().center());
- QVERIFY(!buttonMenu->geometry().intersects(b.geometry()));
+ QVERIFY2(!buttonMenu->geometry().intersects(b.geometry()), msgGeometryIntersects(buttonMenu->geometry(), b.geometry()));
}
void tst_QMenu::QTBUG7907_submenus_autoselect()
@@ -878,6 +916,7 @@ void tst_QMenu::QTBUG7907_submenus_autoselect()
set1.addMenu(&subset);
menu.addMenu(&set1);
menu.addMenu(&set2);
+ centerOnScreen(&menu, QSize(120, 100));
menu.show();
QVERIFY(QTest::qWaitForWindowExposed(&menu));
QTest::mouseClick(&menu, Qt::LeftButton, Qt::NoModifier, QPoint(5,5) );
@@ -893,6 +932,7 @@ void tst_QMenu::QTBUG7411_submenus_activate()
sub1.addAction("foo");
sub1.setTitle("&sub1");
QAction *act1 = menu.addMenu(&sub1);
+ centerOnScreen(&menu, QSize(120, 100));
menu.show();
QVERIFY(QTest::qWaitForWindowExposed(&menu));
menu.setActiveAction(act);
@@ -911,12 +951,12 @@ void tst_QMenu::QTBUG30595_rtl_submenu()
sub.addAction("bar");
sub.setTitle("&sub");
menu.addMenu(&sub);
- menu.move(200, 20);
+ centerOnScreen(&menu, QSize(120, 40));
menu.show();
QVERIFY(QTest::qWaitForWindowExposed(&menu));
QTest::mouseClick(&menu, Qt::LeftButton, Qt::NoModifier, QPoint(5,5) );
QTRY_VERIFY(sub.isVisible());
- QVERIFY(sub.pos().x() < menu.pos().x());
+ QVERIFY2(sub.pos().x() < menu.pos().x(), QByteArray::number(sub.pos().x()) + QByteArrayLiteral(" not less than ") + QByteArray::number(menu.pos().x()));
}
void tst_QMenu::QTBUG20403_nested_popup_on_shortcut_trigger()
@@ -927,6 +967,7 @@ void tst_QMenu::QTBUG20403_nested_popup_on_shortcut_trigger()
subsub1.addAction("foo");
sub1.addMenu(&subsub1);
menu.addMenu(&sub1);
+ centerOnScreen(&menu, QSize(120, 100));
menu.show();
QVERIFY(QTest::qWaitForWindowExposed(&menu));
QTest::keyPress(&menu, Qt::Key_S);
diff --git a/tests/benchmarks/corelib/io/qprocess/testProcessLoopback/testProcessLoopback.pro b/tests/benchmarks/corelib/io/qprocess/testProcessLoopback/testProcessLoopback.pro
index 3940ddbf98..8fd4db6b4b 100644
--- a/tests/benchmarks/corelib/io/qprocess/testProcessLoopback/testProcessLoopback.pro
+++ b/tests/benchmarks/corelib/io/qprocess/testProcessLoopback/testProcessLoopback.pro
@@ -1,5 +1,6 @@
SOURCES = main.cpp
CONFIG -= qt app_bundle
CONFIG += console
+winrt: QMAKE_LFLAGS += /ENTRY:mainCRTStartup
DESTDIR = ./
DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0
diff --git a/tests/benchmarks/corelib/thread/qmutex/tst_qmutex.cpp b/tests/benchmarks/corelib/thread/qmutex/tst_qmutex.cpp
index a7480e6afe..47227ef630 100644
--- a/tests/benchmarks/corelib/thread/qmutex/tst_qmutex.cpp
+++ b/tests/benchmarks/corelib/thread/qmutex/tst_qmutex.cpp
@@ -88,7 +88,9 @@ void NativeMutexUnlock(NativeMutexType *mutex)
}
#endif
#elif defined(Q_OS_WIN)
-# define _WIN32_WINNT 0x0400
+# ifndef Q_OS_WINRT
+# define _WIN32_WINNT 0x0400
+# endif
# include <windows.h>
typedef CRITICAL_SECTION NativeMutexType;
void NativeMutexInitialize(NativeMutexType *mutex)