summaryrefslogtreecommitdiffstats
path: root/tests/auto/widgets/kernel
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/widgets/kernel')
-rw-r--r--tests/auto/widgets/kernel/qaction/BLACKLIST2
-rw-r--r--tests/auto/widgets/kernel/qaction/tst_qaction.cpp2
-rw-r--r--tests/auto/widgets/kernel/qactiongroup/BLACKLIST2
-rw-r--r--tests/auto/widgets/kernel/qactiongroup/tst_qactiongroup.cpp3
-rw-r--r--tests/auto/widgets/kernel/qapplication/BLACKLIST4
-rw-r--r--tests/auto/widgets/kernel/qapplication/qapplication.pro1
-rw-r--r--tests/auto/widgets/kernel/qapplication/test/BLACKLIST2
-rw-r--r--tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp159
-rw-r--r--tests/auto/widgets/kernel/qapplication/wincmdline/main.cpp46
-rw-r--r--tests/auto/widgets/kernel/qapplication/wincmdline/wincmdline.pro5
-rw-r--r--tests/auto/widgets/kernel/qboxlayout/tst_qboxlayout.cpp103
-rw-r--r--tests/auto/widgets/kernel/qdesktopwidget/tst_qdesktopwidget.cpp1
-rw-r--r--tests/auto/widgets/kernel/qformlayout/tst_qformlayout.cpp429
-rw-r--r--tests/auto/widgets/kernel/qgridlayout/tst_qgridlayout.cpp160
-rw-r--r--tests/auto/widgets/kernel/qlayout/tst_qlayout.cpp7
-rw-r--r--tests/auto/widgets/kernel/qshortcut/tst_qshortcut.cpp1
-rw-r--r--tests/auto/widgets/kernel/qsizepolicy/tst_qsizepolicy.cpp21
-rw-r--r--tests/auto/widgets/kernel/qtooltip/BLACKLIST4
-rw-r--r--tests/auto/widgets/kernel/qwidget/BLACKLIST78
-rw-r--r--tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp112
-rw-r--r--tests/auto/widgets/kernel/qwidget_window/tst_qwidget_window.cpp45
-rw-r--r--tests/auto/widgets/kernel/qwidgetaction/tst_qwidgetaction.cpp33
-rw-r--r--tests/auto/widgets/kernel/qwidgetsvariant/tst_qwidgetsvariant.cpp6
-rw-r--r--tests/auto/widgets/kernel/qwindowcontainer/tst_qwindowcontainer.cpp2
24 files changed, 581 insertions, 647 deletions
diff --git a/tests/auto/widgets/kernel/qaction/BLACKLIST b/tests/auto/widgets/kernel/qaction/BLACKLIST
index f67a3c471e..1ad524fdbf 100644
--- a/tests/auto/widgets/kernel/qaction/BLACKLIST
+++ b/tests/auto/widgets/kernel/qaction/BLACKLIST
@@ -1,2 +1,2 @@
[setStandardKeys]
-ubuntu-14.04
+linux
diff --git a/tests/auto/widgets/kernel/qaction/tst_qaction.cpp b/tests/auto/widgets/kernel/qaction/tst_qaction.cpp
index 897128d40e..71b55d71ea 100644
--- a/tests/auto/widgets/kernel/qaction/tst_qaction.cpp
+++ b/tests/auto/widgets/kernel/qaction/tst_qaction.cpp
@@ -242,7 +242,7 @@ void tst_QAction::setStandardKeys()
QList<QKeySequence> list;
act.setShortcuts(list);
act.setShortcuts(QKeySequence::Copy);
- QVERIFY(act.shortcut() == act.shortcuts().first());
+ QCOMPARE(act.shortcut(), act.shortcuts().first());
QList<QKeySequence> expected;
const QKeySequence ctrlC = QKeySequence(QStringLiteral("CTRL+C"));
diff --git a/tests/auto/widgets/kernel/qactiongroup/BLACKLIST b/tests/auto/widgets/kernel/qactiongroup/BLACKLIST
new file mode 100644
index 0000000000..fdc424b6ac
--- /dev/null
+++ b/tests/auto/widgets/kernel/qactiongroup/BLACKLIST
@@ -0,0 +1,2 @@
+[QTBUG_14292_filesystem]
+linux
diff --git a/tests/auto/widgets/kernel/qactiongroup/tst_qactiongroup.cpp b/tests/auto/widgets/kernel/qactiongroup/tst_qactiongroup.cpp
index 8ce9941238..81e5542e91 100644
--- a/tests/auto/widgets/kernel/qactiongroup/tst_qactiongroup.cpp
+++ b/tests/auto/widgets/kernel/qactiongroup/tst_qactiongroup.cpp
@@ -42,6 +42,7 @@ class tst_QActionGroup : public QObject
Q_OBJECT
private slots:
+ void cleanup() { QVERIFY(QApplication::topLevelWidgets().isEmpty()); }
void enabledPropagation();
void visiblePropagation();
void exclusive();
@@ -223,7 +224,7 @@ void tst_QActionGroup::unCheckCurrentAction()
current->setChecked(false);
QVERIFY(!action1.isChecked());
QVERIFY(!action2.isChecked());
- QVERIFY(group.checkedAction() == 0);
+ QVERIFY(!group.checkedAction());
}
diff --git a/tests/auto/widgets/kernel/qapplication/BLACKLIST b/tests/auto/widgets/kernel/qapplication/BLACKLIST
new file mode 100644
index 0000000000..6abb1d9988
--- /dev/null
+++ b/tests/auto/widgets/kernel/qapplication/BLACKLIST
@@ -0,0 +1,4 @@
+[quitOnLastWindowClosed]
+osx-10.10
+[touchEventPropagation]
+xcb
diff --git a/tests/auto/widgets/kernel/qapplication/qapplication.pro b/tests/auto/widgets/kernel/qapplication/qapplication.pro
index 3d167827a3..5154c915cd 100644
--- a/tests/auto/widgets/kernel/qapplication/qapplication.pro
+++ b/tests/auto/widgets/kernel/qapplication/qapplication.pro
@@ -2,6 +2,5 @@ TEMPLATE = subdirs
SUBDIRS = desktopsettingsaware modal
-win32:!wince: SUBDIRS += wincmdline
test.depends += $$SUBDIRS
SUBDIRS += test
diff --git a/tests/auto/widgets/kernel/qapplication/test/BLACKLIST b/tests/auto/widgets/kernel/qapplication/test/BLACKLIST
new file mode 100644
index 0000000000..f4a9cb6166
--- /dev/null
+++ b/tests/auto/widgets/kernel/qapplication/test/BLACKLIST
@@ -0,0 +1,2 @@
+[quitOnLastWindowClosed]
+osx-10.10
diff --git a/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp b/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp
index 84956d0a02..878136b4a0 100644
--- a/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp
+++ b/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp
@@ -62,6 +62,7 @@
#endif
#include <qpa/qwindowsysteminterface.h>
+#include <private/qhighdpiscaling_p.h>
#include "../../../qtest-config.h"
@@ -162,9 +163,6 @@ private slots:
void setAttribute();
- void windowsCommandLine_data();
- void windowsCommandLine();
-
void touchEventPropagation();
void qtbug_12673();
@@ -1160,7 +1158,7 @@ void tst_QApplication::sendPostedEvents()
QMetaObject::invokeMethod(&app, "quit", Qt::QueuedConnection);
QPointer<SendPostedEventsTester> p = tester;
(void) app.exec();
- QVERIFY(p == 0);
+ QVERIFY(p.isNull());
}
void tst_QApplication::thread()
@@ -1178,8 +1176,8 @@ void tst_QApplication::thread()
// *before* the QApplication has a thread
QObject object;
QObject child(&object);
- QVERIFY(object.thread() == currentThread);
- QVERIFY(child.thread() == currentThread);
+ QCOMPARE(object.thread(), currentThread);
+ QCOMPARE(child.thread(), currentThread);
{
int argc = 0;
@@ -1209,8 +1207,8 @@ void tst_QApplication::thread()
QVERIFY(!currentThread->isFinished());
// should still have a thread
- QVERIFY(object.thread() == currentThread);
- QVERIFY(child.thread() == currentThread);
+ QCOMPARE(object.thread(), currentThread);
+ QCOMPARE(child.thread(), currentThread);
// do the test again, making sure that the thread is the same as
// before
@@ -1231,8 +1229,8 @@ void tst_QApplication::thread()
QVERIFY(!currentThread->isFinished());
// should still have a thread
- QVERIFY(object.thread() == currentThread);
- QVERIFY(child.thread() == currentThread);
+ QCOMPARE(object.thread(), currentThread);
+ QCOMPARE(child.thread(), currentThread);
QTestEventLoop::instance().enterLoop(1);
}
@@ -1246,8 +1244,8 @@ void tst_QApplication::thread()
QVERIFY(!currentThread->isFinished());
// should still have a thread
- QVERIFY(object.thread() == currentThread);
- QVERIFY(child.thread() == currentThread);
+ QCOMPARE(object.thread(), currentThread);
+ QCOMPARE(child.thread(), currentThread);
}
class DeleteLaterWidget : public QWidget
@@ -1561,9 +1559,9 @@ void tst_QApplication::focusChanged()
QCOMPARE(spy.at(0).count(), 2);
old = qvariant_cast<QWidget*>(spy.at(0).at(0));
now = qvariant_cast<QWidget*>(spy.at(0).at(1));
- QVERIFY(now == &le1);
- QVERIFY(now == QApplication::focusWidget());
- QVERIFY(old == 0);
+ QCOMPARE(now, &le1);
+ QCOMPARE(now, QApplication::focusWidget());
+ QVERIFY(!old);
spy.clear();
QCOMPARE(spy.count(), 0);
@@ -1571,27 +1569,27 @@ void tst_QApplication::focusChanged()
QCOMPARE(spy.count(), 1);
old = qvariant_cast<QWidget*>(spy.at(0).at(0));
now = qvariant_cast<QWidget*>(spy.at(0).at(1));
- QVERIFY(now == &pb1);
- QVERIFY(now == QApplication::focusWidget());
- QVERIFY(old == &le1);
+ QCOMPARE(now, &pb1);
+ QCOMPARE(now, QApplication::focusWidget());
+ QCOMPARE(old, &le1);
spy.clear();
lb1.setFocus();
QCOMPARE(spy.count(), 1);
old = qvariant_cast<QWidget*>(spy.at(0).at(0));
now = qvariant_cast<QWidget*>(spy.at(0).at(1));
- QVERIFY(now == &lb1);
- QVERIFY(now == QApplication::focusWidget());
- QVERIFY(old == &pb1);
+ QCOMPARE(now, &lb1);
+ QCOMPARE(now, QApplication::focusWidget());
+ QCOMPARE(old, &pb1);
spy.clear();
lb1.clearFocus();
QCOMPARE(spy.count(), 1);
old = qvariant_cast<QWidget*>(spy.at(0).at(0));
now = qvariant_cast<QWidget*>(spy.at(0).at(1));
- QVERIFY(now == 0);
- QVERIFY(now == QApplication::focusWidget());
- QVERIFY(old == &lb1);
+ QVERIFY(!now);
+ QCOMPARE(now, QApplication::focusWidget());
+ QCOMPARE(old, &lb1);
spy.clear();
QWidget parent2;
@@ -1608,9 +1606,9 @@ void tst_QApplication::focusChanged()
QVERIFY(spy.count() > 0); // one for deactivation, one for activation on Windows
old = qvariant_cast<QWidget*>(spy.at(spy.count()-1).at(0));
now = qvariant_cast<QWidget*>(spy.at(spy.count()-1).at(1));
- QVERIFY(now == &le2);
- QVERIFY(now == QApplication::focusWidget());
- QVERIFY(old == 0);
+ QCOMPARE(now, &le2);
+ QCOMPARE(now, QApplication::focusWidget());
+ QVERIFY(!old);
spy.clear();
QTestKeyEvent tab(QTest::Press, Qt::Key_Tab, 0, 0);
@@ -1632,82 +1630,82 @@ void tst_QApplication::focusChanged()
tab.simulate(now);
if (!tabAllControls) {
- QVERIFY(spy.count() == 0);
- QVERIFY(now == QApplication::focusWidget());
+ QCOMPARE(spy.count(), 0);
+ QCOMPARE(now, QApplication::focusWidget());
} else {
QVERIFY(spy.count() > 0);
old = qvariant_cast<QWidget*>(spy.at(0).at(0));
now = qvariant_cast<QWidget*>(spy.at(0).at(1));
- QVERIFY(now == &pb2);
- QVERIFY(now == QApplication::focusWidget());
- QVERIFY(old == &le2);
+ QCOMPARE(now, &pb2);
+ QCOMPARE(now, QApplication::focusWidget());
+ QCOMPARE(old, &le2);
spy.clear();
}
if (!tabAllControls) {
- QVERIFY(spy.count() == 0);
- QVERIFY(now == QApplication::focusWidget());
+ QCOMPARE(spy.count(), 0);
+ QCOMPARE(now, QApplication::focusWidget());
} else {
tab.simulate(now);
QVERIFY(spy.count() > 0);
old = qvariant_cast<QWidget*>(spy.at(0).at(0));
now = qvariant_cast<QWidget*>(spy.at(0).at(1));
- QVERIFY(now == &le2);
- QVERIFY(now == QApplication::focusWidget());
- QVERIFY(old == &pb2);
+ QCOMPARE(now, &le2);
+ QCOMPARE(now, QApplication::focusWidget());
+ QCOMPARE(old, &pb2);
spy.clear();
}
if (!tabAllControls) {
- QVERIFY(spy.count() == 0);
- QVERIFY(now == QApplication::focusWidget());
+ QCOMPARE(spy.count(), 0);
+ QCOMPARE(now, QApplication::focusWidget());
} else {
backtab.simulate(now);
QVERIFY(spy.count() > 0);
old = qvariant_cast<QWidget*>(spy.at(0).at(0));
now = qvariant_cast<QWidget*>(spy.at(0).at(1));
- QVERIFY(now == &pb2);
- QVERIFY(now == QApplication::focusWidget());
- QVERIFY(old == &le2);
+ QCOMPARE(now, &pb2);
+ QCOMPARE(now, QApplication::focusWidget());
+ QCOMPARE(old, &le2);
spy.clear();
}
if (!tabAllControls) {
- QVERIFY(spy.count() == 0);
- QVERIFY(now == QApplication::focusWidget());
+ QCOMPARE(spy.count(), 0);
+ QCOMPARE(now, QApplication::focusWidget());
old = &pb2;
} else {
backtab.simulate(now);
QVERIFY(spy.count() > 0);
old = qvariant_cast<QWidget*>(spy.at(0).at(0));
now = qvariant_cast<QWidget*>(spy.at(0).at(1));
- QVERIFY(now == &le2);
- QVERIFY(now == QApplication::focusWidget());
- QVERIFY(old == &pb2);
+ QCOMPARE(now, &le2);
+ QCOMPARE(now, QApplication::focusWidget());
+ QCOMPARE(old, &pb2);
spy.clear();
}
click.simulate(old);
if (!(pb2.focusPolicy() & Qt::ClickFocus)) {
- QVERIFY(spy.count() == 0);
- QVERIFY(now == QApplication::focusWidget());
+ QCOMPARE(spy.count(), 0);
+ QCOMPARE(now, QApplication::focusWidget());
} else {
QVERIFY(spy.count() > 0);
old = qvariant_cast<QWidget*>(spy.at(0).at(0));
now = qvariant_cast<QWidget*>(spy.at(0).at(1));
- QVERIFY(now == &pb2);
- QVERIFY(now == QApplication::focusWidget());
- QVERIFY(old == &le2);
+ QCOMPARE(now, &pb2);
+ QCOMPARE(now, QApplication::focusWidget());
+ QCOMPARE(old, &le2);
spy.clear();
click.simulate(old);
QVERIFY(spy.count() > 0);
old = qvariant_cast<QWidget*>(spy.at(0).at(0));
now = qvariant_cast<QWidget*>(spy.at(0).at(1));
- QVERIFY(now == &le2);
- QVERIFY(now == QApplication::focusWidget());
- QVERIFY(old == &pb2);
+ QCOMPARE(now, &le2);
+ QCOMPARE(now, QApplication::focusWidget());
+ QCOMPARE(old, &pb2);
spy.clear();
}
@@ -1722,9 +1720,9 @@ void tst_QApplication::focusChanged()
else
old = qvariant_cast<QWidget*>(spy.at(spy.count()-2).at(0));
now = qvariant_cast<QWidget*>(spy.at(spy.count()-1).at(1));
- QVERIFY(now == &le1);
- QVERIFY(now == QApplication::focusWidget());
- QVERIFY(old == &le2);
+ QCOMPARE(now, &le1);
+ QCOMPARE(now, QApplication::focusWidget());
+ QCOMPARE(old, &le2);
spy.clear();
}
@@ -1933,39 +1931,6 @@ void tst_QApplication::setAttribute()
delete w;
}
-void tst_QApplication::windowsCommandLine_data()
-{
-#if defined(Q_OS_WIN)
- QTest::addColumn<QString>("args");
- QTest::addColumn<QString>("expected");
-
- QTest::newRow("hello world")
- << QString("Hello \"World\"")
- << QString("Hello \"World\"");
- QTest::newRow("sql")
- << QString("SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = 'PNR' AND TABLE_TYPE = 'VIEW' ORDER BY TABLE_NAME")
- << QString("SELECT TABLE_NAME FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA = 'PNR' AND TABLE_TYPE = 'VIEW' ORDER BY TABLE_NAME");
-#endif
-}
-
-void tst_QApplication::windowsCommandLine()
-{
-#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) && !defined(Q_OS_WINRT)
- QFETCH(QString, args);
- QFETCH(QString, expected);
-
- QProcess testProcess;
- const QString path = QStringLiteral("wincmdline/wincmdline");
- testProcess.start(path, QStringList(args));
- QVERIFY2(testProcess.waitForStarted(),
- qPrintable(QString::fromLatin1("Cannot start '%1': %2").arg(path, testProcess.errorString())));
- QVERIFY(testProcess.waitForFinished(10000));
- QByteArray error = testProcess.readAllStandardError();
- QString procError(error);
- QCOMPARE(procError, expected);
-#endif
-}
-
class TouchEventPropagationTestWidget : public QWidget
{
Q_OBJECT
@@ -2038,8 +2003,10 @@ void tst_QApplication::touchEventPropagation()
QVERIFY(QTest::qWaitForWindowExposed(&window));
// QPA always takes screen positions and since we map the TouchPoint back to QPA's structure first,
// we must ensure there is a screen position in the TouchPoint that maps to a local 0, 0.
- pressedTouchPoints[0].setScreenPos(window.mapToGlobal(QPoint(0, 0)));
- releasedTouchPoints[0].setScreenPos(window.mapToGlobal(QPoint(0, 0)));
+ const QPoint deviceGlobalPos =
+ QHighDpi::toNativePixels(window.mapToGlobal(QPoint(0, 0)), window.windowHandle()->screen());
+ pressedTouchPoints[0].setScreenPos(deviceGlobalPos);
+ releasedTouchPoints[0].setScreenPos(deviceGlobalPos);
QWindowSystemInterface::handleTouchEvent(window.windowHandle(),
0,
@@ -2092,8 +2059,10 @@ void tst_QApplication::touchEventPropagation()
widget.setObjectName("2. widget");
window.show();
QVERIFY(QTest::qWaitForWindowExposed(&window));
- pressedTouchPoints[0].setScreenPos(window.mapToGlobal(QPoint(50, 50)));
- releasedTouchPoints[0].setScreenPos(window.mapToGlobal(QPoint(50, 50)));
+ const QPoint deviceGlobalPos =
+ QHighDpi::toNativePixels(window.mapToGlobal(QPoint(50, 50)), window.windowHandle()->screen());
+ pressedTouchPoints[0].setScreenPos(deviceGlobalPos);
+ releasedTouchPoints[0].setScreenPos(deviceGlobalPos);
QWindowSystemInterface::handleTouchEvent(window.windowHandle(),
0,
diff --git a/tests/auto/widgets/kernel/qapplication/wincmdline/main.cpp b/tests/auto/widgets/kernel/qapplication/wincmdline/main.cpp
deleted file mode 100644
index 2d86b46875..0000000000
--- a/tests/auto/widgets/kernel/qapplication/wincmdline/main.cpp
+++ /dev/null
@@ -1,46 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2015 The Qt Company Ltd.
-** Contact: http://www.qt.io/licensing/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:LGPL21$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see http://www.qt.io/terms-conditions. For further
-** information use the contact form at http://www.qt.io/contact-us.
-**
-** GNU Lesser General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU Lesser
-** General Public License version 2.1 or version 3 as published by the Free
-** Software Foundation and appearing in the file LICENSE.LGPLv21 and
-** LICENSE.LGPLv3 included in the packaging of this file. Please review the
-** following information to ensure the GNU Lesser General Public License
-** requirements will be met: https://www.gnu.org/licenses/lgpl.html and
-** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
-**
-** As a special exception, The Qt Company gives you certain additional
-** rights. These rights are described in The Qt Company LGPL Exception
-** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-#include <QApplication>
-#include <stdio.h>
-
-int main(int argc, char *argv[])
-{
- QApplication app(argc, argv);
- if (argc > 1)
- fprintf(stderr, "%s", argv[1]);
- else
- fprintf(stderr, "Failed");
- fflush(stderr);
- return 0;
-}
-
diff --git a/tests/auto/widgets/kernel/qapplication/wincmdline/wincmdline.pro b/tests/auto/widgets/kernel/qapplication/wincmdline/wincmdline.pro
deleted file mode 100644
index 3e32a6798d..0000000000
--- a/tests/auto/widgets/kernel/qapplication/wincmdline/wincmdline.pro
+++ /dev/null
@@ -1,5 +0,0 @@
-QT += widgets
-CONFIG -= app_bundle debug_and_release_target
-SOURCES += main.cpp
-DESTDIR = ./
-
diff --git a/tests/auto/widgets/kernel/qboxlayout/tst_qboxlayout.cpp b/tests/auto/widgets/kernel/qboxlayout/tst_qboxlayout.cpp
index 35a8636f0b..aeaf1e7bf0 100644
--- a/tests/auto/widgets/kernel/qboxlayout/tst_qboxlayout.cpp
+++ b/tests/auto/widgets/kernel/qboxlayout/tst_qboxlayout.cpp
@@ -48,17 +48,8 @@ class tst_QBoxLayout : public QObject
{
Q_OBJECT
-public:
- tst_QBoxLayout();
- virtual ~tst_QBoxLayout();
-
-public slots:
- void initTestCase();
- void cleanupTestCase();
- void init();
- void cleanup();
-
private slots:
+ void cleanup();
void insertSpacerItem();
void insertLayout();
void sizeHint();
@@ -120,34 +111,15 @@ int CustomLayoutStyle::pixelMetric(PixelMetric metric, const QStyleOption * opti
return QProxyStyle::pixelMetric(metric, option, widget);
}
-
-tst_QBoxLayout::tst_QBoxLayout()
-{
-}
-
-tst_QBoxLayout::~tst_QBoxLayout()
-{
-}
-
-void tst_QBoxLayout::initTestCase()
-{
-}
-
-void tst_QBoxLayout::cleanupTestCase()
-{
-}
-
-void tst_QBoxLayout::init()
-{
-}
-
void tst_QBoxLayout::cleanup()
{
+ QVERIFY(QApplication::topLevelWidgets().isEmpty());
}
void tst_QBoxLayout::insertSpacerItem()
{
- QWidget *window = new QWidget;
+ QWidget window;
+ window.setWindowTitle(QTest::currentTestFunction());
QSpacerItem *spacer1 = new QSpacerItem(20, 10, QSizePolicy::Expanding, QSizePolicy::Expanding);
QSpacerItem *spacer2 = new QSpacerItem(40, 20, QSizePolicy::Expanding, QSizePolicy::Expanding);
@@ -157,44 +129,43 @@ void tst_QBoxLayout::insertSpacerItem()
layout->addSpacerItem(spacer1);
layout->addWidget(new QLineEdit("Baaaaaaaaaaaaaaaaaaaaaaaaar"));
layout->insertSpacerItem(0, spacer2);
- window->setLayout(layout);
+ window.setLayout(layout);
- QVERIFY(layout->itemAt(0) == spacer2);
- QVERIFY(layout->itemAt(2) == spacer1);
+ QCOMPARE(layout->itemAt(0), spacer2);
+ QCOMPARE(layout->itemAt(2), spacer1);
- window->show();
+ window.show();
}
void tst_QBoxLayout::insertLayout()
{
- QWidget *window = new QWidget;
- QVBoxLayout *vbox = new QVBoxLayout(window);
- QVBoxLayout *dummyParentLayout = new QVBoxLayout;
+ QWidget window;
+ QVBoxLayout *vbox = new QVBoxLayout(&window);
+ QScopedPointer<QVBoxLayout> dummyParentLayout(new QVBoxLayout);
QHBoxLayout *subLayout = new QHBoxLayout;
dummyParentLayout->addLayout(subLayout);
- QCOMPARE(subLayout->parent(), dummyParentLayout);
+ QCOMPARE(subLayout->parent(), dummyParentLayout.data());
QCOMPARE(dummyParentLayout->count(), 1);
// add subLayout to another layout
QTest::ignoreMessage(QtWarningMsg, "QLayout::addChildLayout: layout \"\" already has a parent");
vbox->addLayout(subLayout);
QCOMPARE((subLayout->parent() == vbox), (vbox->count() == 1));
-
- delete dummyParentLayout;
- delete window;
}
void tst_QBoxLayout::sizeHint()
{
- QWidget *window = new QWidget;
+ QWidget window;
+ window.setWindowTitle(QTest::currentTestFunction());
QHBoxLayout *lay1 = new QHBoxLayout;
QHBoxLayout *lay2 = new QHBoxLayout;
QLabel *label = new QLabel("widget twooooooooooooooooooooooooooooooooooooooooooooooooooooooo");
lay2->addWidget(label);
lay1->addLayout(lay2);
- window->setLayout(lay1);
- window->show();
+ window.setLayout(lay1);
+ window.show();
+ QTest::qWaitForWindowExposed(&window);
label->setText("foooooooo baaaaaaar");
QSize sh = lay1->sizeHint();
QApplication::processEvents();
@@ -207,24 +178,26 @@ void tst_QBoxLayout::sizeHint()
void tst_QBoxLayout::sizeConstraints()
{
- QWidget *window = new QWidget;
+ QWidget window;
+ window.setWindowTitle(QTest::currentTestFunction());
QHBoxLayout *lay = new QHBoxLayout;
lay->addWidget(new QLabel("foooooooooooooooooooooooooooooooooooo"));
lay->addWidget(new QLabel("baaaaaaaaaaaaaaaaaaaaaaaaaaaaaar"));
lay->setSizeConstraint(QLayout::SetFixedSize);
- window->setLayout(lay);
- window->show();
- QApplication::processEvents();
- QSize sh = window->sizeHint();
+ window.setLayout(lay);
+ window.show();
+ QTest::qWaitForWindowExposed(&window);
+ QSize sh = window.sizeHint();
lay->takeAt(1);
- QVERIFY(sh.width() >= window->sizeHint().width() &&
- sh.height() >= window->sizeHint().height());
+ QVERIFY(sh.width() >= window.sizeHint().width() &&
+ sh.height() >= window.sizeHint().height());
}
void tst_QBoxLayout::setGeometry()
{
QWidget toplevel;
+ toplevel.setWindowTitle(QTest::currentTestFunction());
setFrameless(&toplevel);
QWidget w(&toplevel);
QVBoxLayout *lay = new QVBoxLayout;
@@ -247,33 +220,30 @@ void tst_QBoxLayout::setGeometry()
void tst_QBoxLayout::setStyleShouldChangeSpacing()
{
- QWidget *window = new QWidget;
- QHBoxLayout *hbox = new QHBoxLayout(window);
+ QWidget window;
+ window.setWindowTitle(QTest::currentTestFunction());
+ QHBoxLayout *hbox = new QHBoxLayout(&window);
QPushButton *pb1 = new QPushButton(tr("The spacing between this"));
QPushButton *pb2 = new QPushButton(tr("and this button should depend on the style of the parent widget"));;
pb1->setAttribute(Qt::WA_LayoutUsesWidgetRect);
pb2->setAttribute(Qt::WA_LayoutUsesWidgetRect);
hbox->addWidget(pb1);
hbox->addWidget(pb2);
- CustomLayoutStyle *style1 = new CustomLayoutStyle;
+ QScopedPointer<CustomLayoutStyle> style1(new CustomLayoutStyle);
style1->hspacing = 6;
- window->setStyle(style1);
- window->show();
+ window.setStyle(style1.data());
+ window.show();
+ QTest::qWaitForWindowExposed(&window);
- QTest::qWait(100);
int spacing = pb2->geometry().left() - pb1->geometry().right() - 1;
QCOMPARE(spacing, 6);
- CustomLayoutStyle *style2 = new CustomLayoutStyle();
+ QScopedPointer<CustomLayoutStyle> style2(new CustomLayoutStyle());
style2->hspacing = 10;
- window->setStyle(style2);
+ window.setStyle(style2.data());
QTest::qWait(100);
spacing = pb2->geometry().left() - pb1->geometry().right() - 1;
QCOMPARE(spacing, 10);
-
- delete window;
- delete style1;
- delete style2;
}
void tst_QBoxLayout::taskQTBUG_7103_minMaxWidthNotRespected()
@@ -287,6 +257,7 @@ void tst_QBoxLayout::taskQTBUG_7103_minMaxWidthNotRespected()
layout->addSpacerItem(new QSpacerItem(1, 1, QSizePolicy::Fixed, QSizePolicy::Expanding));
QWidget widget;
+ widget.setWindowTitle(QTest::currentTestFunction());
widget.setLayout(layout);
widget.show();
QVERIFY(QTest::qWaitForWindowExposed(&widget));
@@ -325,6 +296,7 @@ void tst_QBoxLayout::taskQTBUG_27420_takeAtShouldUnparentLayout()
void tst_QBoxLayout::taskQTBUG_40609_addingWidgetToItsOwnLayout(){
QWidget widget;
+ widget.setWindowTitle(QTest::currentTestFunction());
widget.setObjectName("347b469225a24a0ef05150a");
QVBoxLayout layout(&widget);
layout.setObjectName("ef9e2b42298e0e6420105bb");
@@ -340,6 +312,7 @@ void tst_QBoxLayout::taskQTBUG_40609_addingWidgetToItsOwnLayout(){
void tst_QBoxLayout::taskQTBUG_40609_addingLayoutToItself(){
QWidget widget;
+ widget.setWindowTitle(QTest::currentTestFunction());
widget.setObjectName("fe44e5cb6c08006597126a");
QVBoxLayout layout(&widget);
layout.setObjectName("cc751dd0f50f62b05a62da");
diff --git a/tests/auto/widgets/kernel/qdesktopwidget/tst_qdesktopwidget.cpp b/tests/auto/widgets/kernel/qdesktopwidget/tst_qdesktopwidget.cpp
index b717c1deb1..e94dfa5754 100644
--- a/tests/auto/widgets/kernel/qdesktopwidget/tst_qdesktopwidget.cpp
+++ b/tests/auto/widgets/kernel/qdesktopwidget/tst_qdesktopwidget.cpp
@@ -73,6 +73,7 @@ void tst_QDesktopWidget::init()
void tst_QDesktopWidget::cleanup()
{
+ QVERIFY(QApplication::topLevelWidgets().isEmpty());
}
void tst_QDesktopWidget::numScreens()
diff --git a/tests/auto/widgets/kernel/qformlayout/tst_qformlayout.cpp b/tests/auto/widgets/kernel/qformlayout/tst_qformlayout.cpp
index 8588df7afa..e1b494c9f1 100644
--- a/tests/auto/widgets/kernel/qformlayout/tst_qformlayout.cpp
+++ b/tests/auto/widgets/kernel/qformlayout/tst_qformlayout.cpp
@@ -60,17 +60,8 @@ class tst_QFormLayout : public QObject
{
Q_OBJECT
-public:
- tst_QFormLayout();
- ~tst_QFormLayout();
-
-public slots:
- void initTestCase();
- void cleanupTestCase();
- void init();
- void cleanup();
-
private slots:
+ void cleanup();
void rowCount();
void buddies();
void getItemPosition();
@@ -132,34 +123,15 @@ private slots:
};
-tst_QFormLayout::tst_QFormLayout()
-{
-}
-
-tst_QFormLayout::~tst_QFormLayout()
-{
-}
-
-void tst_QFormLayout::initTestCase()
-{
-}
-
-void tst_QFormLayout::cleanupTestCase()
-{
-}
-
-void tst_QFormLayout::init()
-{
-}
-
void tst_QFormLayout::cleanup()
{
+ QVERIFY(QApplication::topLevelWidgets().isEmpty());
}
void tst_QFormLayout::rowCount()
{
- QWidget *w = new QWidget;
- QFormLayout *fl = new QFormLayout(w);
+ QWidget w;
+ QFormLayout *fl = new QFormLayout(&w);
fl->addRow(tr("Label 1"), new QLineEdit);
fl->addRow(tr("Label 2"), new QLineEdit);
@@ -174,14 +146,12 @@ void tst_QFormLayout::rowCount()
QCOMPARE(fl->rowCount(), 6);
//TODO: remove items
-
- delete w;
}
void tst_QFormLayout::buddies()
{
- QWidget *w = new QWidget;
- QFormLayout *fl = new QFormLayout(w);
+ QWidget w;
+ QFormLayout *fl = new QFormLayout(&w);
//normal buddy case
QLineEdit *le = new QLineEdit;
@@ -195,23 +165,21 @@ void tst_QFormLayout::buddies()
QLineEdit *le2 = new QLineEdit;
fl->addRow(0, le2);
QWidget *label2 = fl->labelForField(le2);
- QVERIFY(label2 == 0);
+ QVERIFY(!label2);
//no label
QLineEdit *le3 = new QLineEdit;
fl->addRow(le3);
QWidget *label3 = fl->labelForField(le3);
- QVERIFY(label3 == 0);
+ QVERIFY(!label3);
//TODO: empty label?
-
- delete w;
}
void tst_QFormLayout::getItemPosition()
{
- QWidget *w = new QWidget;
- QFormLayout *fl = new QFormLayout(w);
+ QWidget w;
+ QFormLayout *fl = new QFormLayout(&w);
QList<QLabel*> labels;
QList<QLineEdit*> fields;
@@ -249,14 +217,12 @@ void tst_QFormLayout::getItemPosition()
QCOMPARE(row, 2);
QCOMPARE(role, QFormLayout::FieldRole);
}
-
- delete w;
}
void tst_QFormLayout::wrapping()
{
- QWidget *w = new QWidget;
- QFormLayout *fl = new QFormLayout(w);
+ QWidget w;
+ QFormLayout *fl = new QFormLayout(&w);
fl->setRowWrapPolicy(QFormLayout::WrapLongRows);
QLineEdit *le = new QLineEdit;
@@ -264,14 +230,13 @@ void tst_QFormLayout::wrapping()
le->setMinimumWidth(200);
fl->addRow(lbl, le);
- w->setFixedWidth(240);
- w->show();
+ w.setFixedWidth(240);
+ w.setWindowTitle(QTest::currentTestFunction());
+ w.show();
QCOMPARE(le->geometry().y() > lbl->geometry().y(), true);
//TODO: additional tests covering different wrapping cases
-
- delete w;
}
class CustomLayoutStyle : public QProxyStyle
@@ -309,12 +274,12 @@ int CustomLayoutStyle::pixelMetric(PixelMetric metric, const QStyleOption * opti
void tst_QFormLayout::spacing()
{
//TODO: confirm spacing behavior
- QWidget *w = new QWidget;
- CustomLayoutStyle *style = new CustomLayoutStyle;
+ QWidget w;
+ QScopedPointer<CustomLayoutStyle> style(new CustomLayoutStyle);
style->hspacing = 5;
style->vspacing = 10;
- w->setStyle(style);
- QFormLayout *fl = new QFormLayout(w);
+ w.setStyle(style.data());
+ QFormLayout *fl = new QFormLayout(&w);
QCOMPARE(style->hspacing, fl->horizontalSpacing());
QCOMPARE(style->vspacing, fl->verticalSpacing());
@@ -351,12 +316,10 @@ void tst_QFormLayout::spacing()
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;
+ w.resize(200, 100);
+ w.setWindowTitle(QTest::currentTestFunction());
+ w.show();
+ QVERIFY(QTest::qWaitForWindowExposed(&w));
}
void tst_QFormLayout::contentsRect()
@@ -366,6 +329,7 @@ void tst_QFormLayout::contentsRect()
QFormLayout form;
w.setLayout(&form);
form.addRow("Label", new QPushButton(&w));
+ w.setWindowTitle(QTest::currentTestFunction());
w.show();
QVERIFY(QTest::qWaitForWindowExposed(&w));
int l, t, r, b;
@@ -425,18 +389,18 @@ void tst_QFormLayout::setFormStyle()
#if 0 // QT_NO_STYLE_PLASTIQUE
widget.setStyle(new QPlastiqueStyle());
- QVERIFY(layout.labelAlignment() == Qt::AlignRight);
+ QCOMPARE(layout.labelAlignment(), Qt::AlignRight);
QVERIFY(layout.formAlignment() == (Qt::AlignLeft | Qt::AlignTop));
- QVERIFY(layout.fieldGrowthPolicy() == QFormLayout::ExpandingFieldsGrow);
- QVERIFY(layout.rowWrapPolicy() == QFormLayout::DontWrapRows);
+ QCOMPARE(layout.fieldGrowthPolicy(), QFormLayout::ExpandingFieldsGrow);
+ QCOMPARE(layout.rowWrapPolicy(), QFormLayout::DontWrapRows);
#endif
widget.setStyle(QStyleFactory::create("windows"));
- QVERIFY(layout.labelAlignment() == Qt::AlignLeft);
+ QCOMPARE(layout.labelAlignment(), Qt::AlignLeft);
QVERIFY(layout.formAlignment() == (Qt::AlignLeft | Qt::AlignTop));
- QVERIFY(layout.fieldGrowthPolicy() == QFormLayout::AllNonFixedFieldsGrow);
- QVERIFY(layout.rowWrapPolicy() == QFormLayout::DontWrapRows);
+ QCOMPARE(layout.fieldGrowthPolicy(), QFormLayout::AllNonFixedFieldsGrow);
+ QCOMPARE(layout.rowWrapPolicy(), QFormLayout::DontWrapRows);
/* can't directly create mac style or qtopia style, since
this test is cross platform.. so create dummy styles that
@@ -444,17 +408,17 @@ void tst_QFormLayout::setFormStyle()
*/
widget.setStyle(new DummyMacStyle());
- QVERIFY(layout.labelAlignment() == Qt::AlignRight);
+ QCOMPARE(layout.labelAlignment(), Qt::AlignRight);
QVERIFY(layout.formAlignment() == (Qt::AlignHCenter | Qt::AlignTop));
- QVERIFY(layout.fieldGrowthPolicy() == QFormLayout::FieldsStayAtSizeHint);
- QVERIFY(layout.rowWrapPolicy() == QFormLayout::DontWrapRows);
+ QCOMPARE(layout.fieldGrowthPolicy(), QFormLayout::FieldsStayAtSizeHint);
+ QCOMPARE(layout.rowWrapPolicy(), QFormLayout::DontWrapRows);
widget.setStyle(new DummyQtopiaStyle());
- QVERIFY(layout.labelAlignment() == Qt::AlignRight);
+ QCOMPARE(layout.labelAlignment(), Qt::AlignRight);
QVERIFY(layout.formAlignment() == (Qt::AlignLeft | Qt::AlignTop));
- QVERIFY(layout.fieldGrowthPolicy() == QFormLayout::AllNonFixedFieldsGrow);
- QVERIFY(layout.rowWrapPolicy() == QFormLayout::WrapLongRows);
+ QCOMPARE(layout.fieldGrowthPolicy(), QFormLayout::AllNonFixedFieldsGrow);
+ QCOMPARE(layout.rowWrapPolicy(), QFormLayout::WrapLongRows);
}
void tst_QFormLayout::setFieldGrowthPolicy()
@@ -479,14 +443,14 @@ void tst_QFormLayout::setFieldGrowthPolicy()
layout.activate();
if (i == 0) {
- QVERIFY(fld1.width() == fld2.width());
- QVERIFY(fld2.width() == fld3.width());
+ QCOMPARE(fld1.width(), fld2.width());
+ QCOMPARE(fld2.width(), fld3.width());
} else if (i == 1) {
- QVERIFY(fld1.width() == fld2.width());
+ QCOMPARE(fld1.width(), fld2.width());
QVERIFY(fld2.width() < fld3.width());
} else {
QVERIFY(fld1.width() < fld2.width());
- QVERIFY(fld2.width() == fld3.width());
+ QCOMPARE(fld2.width(), fld3.width());
}
}
}
@@ -505,33 +469,39 @@ void tst_QFormLayout::setFormAlignment()
void tst_QFormLayout::addRow()
{
- QFormLayout layout;
- QWidget w1, w2, w3;
- QHBoxLayout l1, l2, l3;
- QLabel lbl1, lbl2;
-
- QCOMPARE(layout.rowCount(), 0);
-
- layout.addRow(&lbl1, &w1);
- layout.addRow(&lbl2, &l1);
- layout.addRow("Foo:", &w2);
- layout.addRow("Bar:", &l2);
- layout.addRow(&w3);
- layout.addRow(&l3);
-
- QCOMPARE(layout.rowCount(), 6);
-
- QVERIFY(layout.itemAt(0, QFormLayout::LabelRole)->widget() == &lbl1);
- QVERIFY(layout.itemAt(1, QFormLayout::LabelRole)->widget() == &lbl2);
- QVERIFY(layout.itemAt(2, QFormLayout::LabelRole)->widget()->property("text") == "Foo:");
- QVERIFY(layout.itemAt(3, QFormLayout::LabelRole)->widget()->property("text") == "Bar:");
- QVERIFY(layout.itemAt(4, QFormLayout::LabelRole) == 0);
- QVERIFY(layout.itemAt(5, QFormLayout::LabelRole) == 0);
-
- QVERIFY(layout.itemAt(0, QFormLayout::FieldRole)->widget() == &w1);
- QVERIFY(layout.itemAt(1, QFormLayout::FieldRole)->layout() == &l1);
- QVERIFY(layout.itemAt(2, QFormLayout::FieldRole)->widget() == &w2);
- QVERIFY(layout.itemAt(3, QFormLayout::FieldRole)->layout() == &l2);
+ QWidget topLevel;
+ QFormLayout *layout = new QFormLayout(&topLevel);
+ QWidget *w1 = new QWidget(&topLevel);
+ QWidget *w2 = new QWidget(&topLevel);
+ QWidget *w3 = new QWidget(&topLevel);
+ QHBoxLayout *l1 = new QHBoxLayout;
+ QHBoxLayout *l2 = new QHBoxLayout;
+ QHBoxLayout *l3 = new QHBoxLayout;
+ QLabel *lbl1 = new QLabel(&topLevel);
+ QLabel *lbl2 = new QLabel(&topLevel);
+
+ QCOMPARE(layout->rowCount(), 0);
+
+ layout->addRow(lbl1, w1);
+ layout->addRow(lbl2, l1);
+ layout->addRow("Foo:", w2);
+ layout->addRow("Bar:", l2);
+ layout->addRow(w3);
+ layout->addRow(l3);
+
+ QCOMPARE(layout->rowCount(), 6);
+
+ QVERIFY(layout->itemAt(0, QFormLayout::LabelRole)->widget() == lbl1);
+ QVERIFY(layout->itemAt(1, QFormLayout::LabelRole)->widget() == lbl2);
+ QVERIFY(layout->itemAt(2, QFormLayout::LabelRole)->widget()->property("text") == "Foo:");
+ QVERIFY(layout->itemAt(3, QFormLayout::LabelRole)->widget()->property("text") == "Bar:");
+ QVERIFY(layout->itemAt(4, QFormLayout::LabelRole) == 0);
+ QVERIFY(layout->itemAt(5, QFormLayout::LabelRole) == 0);
+
+ QVERIFY(layout->itemAt(0, QFormLayout::FieldRole)->widget() == w1);
+ QVERIFY(layout->itemAt(1, QFormLayout::FieldRole)->layout() == l1);
+ QVERIFY(layout->itemAt(2, QFormLayout::FieldRole)->widget() == w2);
+ QVERIFY(layout->itemAt(3, QFormLayout::FieldRole)->layout() == l2);
// ### should have a third role, FullRowRole?
// QVERIFY(layout.itemAt(4, QFormLayout::FieldRole) == 0);
// QVERIFY(layout.itemAt(5, QFormLayout::FieldRole) == 0);
@@ -539,17 +509,24 @@ void tst_QFormLayout::addRow()
void tst_QFormLayout::insertRow_QWidget_QWidget()
{
- QFormLayout layout;
- QLabel lbl1, lbl2, lbl3, lbl4;
- QLineEdit fld1, fld2, fld3, fld4;
+ QWidget topLevel;
+ QFormLayout *layout = new QFormLayout(&topLevel);
+ QLabel *lbl1 = new QLabel(&topLevel);
+ QLabel *lbl2 = new QLabel(&topLevel);
+ QLabel *lbl3 = new QLabel(&topLevel);
+ QLabel *lbl4 = new QLabel(&topLevel);
+ QLineEdit *fld1 = new QLineEdit(&topLevel);
+ QLineEdit *fld2 = new QLineEdit(&topLevel);
+ QLineEdit *fld3 = new QLineEdit(&topLevel);
+ QLineEdit *fld4 = new QLineEdit(&topLevel);
- layout.insertRow(0, &lbl1, &fld1);
- QCOMPARE(layout.rowCount(), 1);
+ layout->insertRow(0, lbl1, fld1);
+ QCOMPARE(layout->rowCount(), 1);
{
int row = -1;
QFormLayout::ItemRole role = QFormLayout::ItemRole(-123);
- layout.getWidgetPosition(&lbl1, &row, &role);
+ layout->getWidgetPosition(lbl1, &row, &role);
QCOMPARE(row, 0);
QCOMPARE(int(role), int(QFormLayout::LabelRole));
}
@@ -557,63 +534,68 @@ void tst_QFormLayout::insertRow_QWidget_QWidget()
{
int row = -1;
QFormLayout::ItemRole role = QFormLayout::ItemRole(-123);
- layout.getWidgetPosition(&fld1, &row, &role);
+ layout->getWidgetPosition(fld1, &row, &role);
QCOMPARE(row, 0);
QCOMPARE(int(role), int(QFormLayout::FieldRole));
}
// check that negative values append
- layout.insertRow(-2, &lbl2, &fld2);
- QCOMPARE(layout.rowCount(), 2);
+ layout->insertRow(-2, lbl2, fld2);
+ QCOMPARE(layout->rowCount(), 2);
- QVERIFY(layout.itemAt(0, QFormLayout::LabelRole)->widget() == &lbl1);
- QVERIFY(layout.itemAt(1, QFormLayout::LabelRole)->widget() == &lbl2);
+ QVERIFY(layout->itemAt(0, QFormLayout::LabelRole)->widget() == lbl1);
+ QVERIFY(layout->itemAt(1, QFormLayout::LabelRole)->widget() == lbl2);
// check that too large values append
- layout.insertRow(100, &lbl3, &fld3);
- QCOMPARE(layout.rowCount(), 3);
- QCOMPARE(layout.count(), 6);
+ layout->insertRow(100, lbl3, fld3);
+ QCOMPARE(layout->rowCount(), 3);
+ QCOMPARE(layout->count(), 6);
- layout.insertRow(3, (QWidget *)0, (QWidget *)0);
- QCOMPARE(layout.rowCount(), 4);
- QCOMPARE(layout.count(), 6);
+ layout->insertRow(3, (QWidget *)0, (QWidget *)0);
+ QCOMPARE(layout->rowCount(), 4);
+ QCOMPARE(layout->count(), 6);
- layout.insertRow(4, (QWidget *)0, &fld4);
- QCOMPARE(layout.rowCount(), 5);
- QCOMPARE(layout.count(), 7);
+ layout->insertRow(4, (QWidget *)0, fld4);
+ QCOMPARE(layout->rowCount(), 5);
+ QCOMPARE(layout->count(), 7);
- layout.insertRow(5, &lbl4, (QWidget *)0);
- QCOMPARE(layout.rowCount(), 6);
- QCOMPARE(layout.count(), 8);
-
- QVERIFY(layout.itemAt(0, QFormLayout::LabelRole)->widget() == &lbl1);
- QVERIFY(layout.itemAt(1, QFormLayout::LabelRole)->widget() == &lbl2);
- QVERIFY(layout.itemAt(2, QFormLayout::LabelRole)->widget() == &lbl3);
- QVERIFY(layout.itemAt(3, QFormLayout::LabelRole) == 0);
- QVERIFY(layout.itemAt(4, QFormLayout::LabelRole) == 0);
- QVERIFY(layout.itemAt(5, QFormLayout::LabelRole)->widget() == &lbl4);
-
- QVERIFY(layout.itemAt(0, QFormLayout::FieldRole)->widget() == &fld1);
- QVERIFY(layout.itemAt(1, QFormLayout::FieldRole)->widget() == &fld2);
- QVERIFY(layout.itemAt(2, QFormLayout::FieldRole)->widget() == &fld3);
- QVERIFY(layout.itemAt(3, QFormLayout::FieldRole) == 0);
- QVERIFY(layout.itemAt(4, QFormLayout::FieldRole)->widget() == &fld4);
- QVERIFY(layout.itemAt(5, QFormLayout::FieldRole) == 0);
+ layout->insertRow(5, lbl4, (QWidget *)0);
+ QCOMPARE(layout->rowCount(), 6);
+ QCOMPARE(layout->count(), 8);
+
+ QVERIFY(layout->itemAt(0, QFormLayout::LabelRole)->widget() == lbl1);
+ QVERIFY(layout->itemAt(1, QFormLayout::LabelRole)->widget() == lbl2);
+ QVERIFY(layout->itemAt(2, QFormLayout::LabelRole)->widget() == lbl3);
+ QVERIFY(layout->itemAt(3, QFormLayout::LabelRole) == 0);
+ QVERIFY(layout->itemAt(4, QFormLayout::LabelRole) == 0);
+ QVERIFY(layout->itemAt(5, QFormLayout::LabelRole)->widget() == lbl4);
+
+ QVERIFY(layout->itemAt(0, QFormLayout::FieldRole)->widget() == fld1);
+ QVERIFY(layout->itemAt(1, QFormLayout::FieldRole)->widget() == fld2);
+ QVERIFY(layout->itemAt(2, QFormLayout::FieldRole)->widget() == fld3);
+ QVERIFY(layout->itemAt(3, QFormLayout::FieldRole) == 0);
+ QVERIFY(layout->itemAt(4, QFormLayout::FieldRole)->widget() == fld4);
+ QVERIFY(layout->itemAt(5, QFormLayout::FieldRole) == 0);
}
void tst_QFormLayout::insertRow_QWidget_QLayout()
{
- QFormLayout layout;
- QLabel lbl1, lbl2, lbl3, lbl4;
- QHBoxLayout fld1, fld2, fld3, fld4;
+ QWidget topLevel;
+ QFormLayout *layout = new QFormLayout(&topLevel);
+ QLabel *lbl1 = new QLabel(&topLevel);
+ QLabel *lbl2 = new QLabel(&topLevel);
+ QLabel *lbl3 = new QLabel(&topLevel);
+ QHBoxLayout *fld1 = new QHBoxLayout;
+ QHBoxLayout *fld2 = new QHBoxLayout;
+ QHBoxLayout *fld3 = new QHBoxLayout;
- layout.insertRow(0, &lbl1, &fld1);
- QCOMPARE(layout.rowCount(), 1);
+ layout->insertRow(0, lbl1, fld1);
+ QCOMPARE(layout->rowCount(), 1);
{
int row = -1;
QFormLayout::ItemRole role = QFormLayout::ItemRole(-123);
- layout.getWidgetPosition(&lbl1, &row, &role);
+ layout->getWidgetPosition(lbl1, &row, &role);
QCOMPARE(row, 0);
QCOMPARE(int(role), int(QFormLayout::LabelRole));
}
@@ -621,77 +603,83 @@ void tst_QFormLayout::insertRow_QWidget_QLayout()
{
int row = -1;
QFormLayout::ItemRole role = QFormLayout::ItemRole(-123);
- layout.getLayoutPosition(&fld1, &row, &role);
+ layout->getLayoutPosition(fld1, &row, &role);
QCOMPARE(row, 0);
QCOMPARE(int(role), int(QFormLayout::FieldRole));
}
// check that negative values append
- layout.insertRow(-2, &lbl2, &fld2);
- QCOMPARE(layout.rowCount(), 2);
+ layout->insertRow(-2, lbl2, fld2);
+ QCOMPARE(layout->rowCount(), 2);
- QVERIFY(layout.itemAt(0, QFormLayout::LabelRole)->widget() == &lbl1);
- QVERIFY(layout.itemAt(1, QFormLayout::LabelRole)->widget() == &lbl2);
+ QVERIFY(layout->itemAt(0, QFormLayout::LabelRole)->widget() == lbl1);
+ QVERIFY(layout->itemAt(1, QFormLayout::LabelRole)->widget() == lbl2);
// check that too large values append
- layout.insertRow(100, &lbl3, &fld3);
- QCOMPARE(layout.rowCount(), 3);
+ layout->insertRow(100, lbl3, fld3);
+ QCOMPARE(layout->rowCount(), 3);
- QVERIFY(layout.itemAt(0, QFormLayout::LabelRole)->widget() == &lbl1);
- QVERIFY(layout.itemAt(1, QFormLayout::LabelRole)->widget() == &lbl2);
- QVERIFY(layout.itemAt(2, QFormLayout::LabelRole)->widget() == &lbl3);
+ QVERIFY(layout->itemAt(0, QFormLayout::LabelRole)->widget() == lbl1);
+ QVERIFY(layout->itemAt(1, QFormLayout::LabelRole)->widget() == lbl2);
+ QVERIFY(layout->itemAt(2, QFormLayout::LabelRole)->widget() == lbl3);
- QVERIFY(layout.itemAt(0, QFormLayout::FieldRole)->layout() == &fld1);
- QVERIFY(layout.itemAt(1, QFormLayout::FieldRole)->layout() == &fld2);
- QVERIFY(layout.itemAt(2, QFormLayout::FieldRole)->layout() == &fld3);
+ QVERIFY(layout->itemAt(0, QFormLayout::FieldRole)->layout() == fld1);
+ QVERIFY(layout->itemAt(1, QFormLayout::FieldRole)->layout() == fld2);
+ QVERIFY(layout->itemAt(2, QFormLayout::FieldRole)->layout() == fld3);
}
void tst_QFormLayout::insertRow_QString_QWidget()
{
- QFormLayout layout;
- QLineEdit fld1, fld2, fld3;
+ QWidget topLevel;
+ QFormLayout *layout = new QFormLayout(&topLevel);
+ QLineEdit *fld1 = new QLineEdit(&topLevel);
+ QLineEdit *fld2 = new QLineEdit(&topLevel);
+ QLineEdit *fld3 = new QLineEdit(&topLevel);
- layout.insertRow(-5, "&Name:", &fld1);
- QLabel *label1 = qobject_cast<QLabel *>(layout.itemAt(0, QFormLayout::LabelRole)->widget());
+ layout->insertRow(-5, "&Name:", fld1);
+ QLabel *label1 = qobject_cast<QLabel *>(layout->itemAt(0, QFormLayout::LabelRole)->widget());
QVERIFY(label1 != 0);
- QVERIFY(label1->buddy() == &fld1);
+ QCOMPARE(label1->buddy(), fld1);
- layout.insertRow(0, "&Email:", &fld2);
- QLabel *label2 = qobject_cast<QLabel *>(layout.itemAt(0, QFormLayout::LabelRole)->widget());
+ layout->insertRow(0, "&Email:", fld2);
+ QLabel *label2 = qobject_cast<QLabel *>(layout->itemAt(0, QFormLayout::LabelRole)->widget());
QVERIFY(label2 != 0);
- QVERIFY(label2->buddy() == &fld2);
+ QCOMPARE(label2->buddy(), fld2);
- layout.insertRow(5, "&Age:", &fld3);
- QLabel *label3 = qobject_cast<QLabel *>(layout.itemAt(2, QFormLayout::LabelRole)->widget());
+ layout->insertRow(5, "&Age:", fld3);
+ QLabel *label3 = qobject_cast<QLabel *>(layout->itemAt(2, QFormLayout::LabelRole)->widget());
QVERIFY(label3 != 0);
- QVERIFY(label3->buddy() == &fld3);
+ QCOMPARE(label3->buddy(), fld3);
}
void tst_QFormLayout::insertRow_QString_QLayout()
{
- QFormLayout layout;
- QHBoxLayout fld1, fld2, fld3;
+ QWidget topLevel;
+ QFormLayout *layout = new QFormLayout(&topLevel);
+ QHBoxLayout *fld1 = new QHBoxLayout;
+ QHBoxLayout *fld2 = new QHBoxLayout;
+ QHBoxLayout *fld3 = new QHBoxLayout;
- layout.insertRow(-5, "&Name:", &fld1);
- QLabel *label1 = qobject_cast<QLabel *>(layout.itemAt(0, QFormLayout::LabelRole)->widget());
+ layout->insertRow(-5, "&Name:", fld1);
+ QLabel *label1 = qobject_cast<QLabel *>(layout->itemAt(0, QFormLayout::LabelRole)->widget());
QVERIFY(label1 != 0);
- QVERIFY(label1->buddy() == 0);
+ QVERIFY(!label1->buddy());
- QCOMPARE(layout.rowCount(), 1);
+ QCOMPARE(layout->rowCount(), 1);
- layout.insertRow(0, "&Email:", &fld2);
- QLabel *label2 = qobject_cast<QLabel *>(layout.itemAt(0, QFormLayout::LabelRole)->widget());
+ layout->insertRow(0, "&Email:", fld2);
+ QLabel *label2 = qobject_cast<QLabel *>(layout->itemAt(0, QFormLayout::LabelRole)->widget());
QVERIFY(label2 != 0);
- QVERIFY(label2->buddy() == 0);
+ QVERIFY(!label2->buddy());
- QCOMPARE(layout.rowCount(), 2);
+ QCOMPARE(layout->rowCount(), 2);
- layout.insertRow(5, "&Age:", &fld3);
- QLabel *label3 = qobject_cast<QLabel *>(layout.itemAt(2, QFormLayout::LabelRole)->widget());
+ layout->insertRow(5, "&Age:", fld3);
+ QLabel *label3 = qobject_cast<QLabel *>(layout->itemAt(2, QFormLayout::LabelRole)->widget());
QVERIFY(label3 != 0);
- QVERIFY(label3->buddy() == 0);
+ QVERIFY(!label3->buddy());
- QCOMPARE(layout.rowCount(), 3);
+ QCOMPARE(layout->rowCount(), 3);
}
void tst_QFormLayout::insertRow_QWidget()
@@ -840,39 +828,40 @@ void tst_QFormLayout::setLayout()
void tst_QFormLayout::itemAt()
{
- QFormLayout layout;
+ QWidget topLevel;
+ QFormLayout *layout = new QFormLayout(&topLevel);
- QWidget w1;
- QWidget w2;
- QWidget w3;
- QWidget w4;
- QWidget w5;
- QHBoxLayout l6;
+ QWidget *w1 = new QWidget(&topLevel);
+ QWidget *w2 = new QWidget(&topLevel);
+ QWidget *w3 = new QWidget(&topLevel);
+ QWidget *w4 = new QWidget(&topLevel);
+ QWidget *w5 = new QWidget(&topLevel);
+ QHBoxLayout *l6 = new QHBoxLayout;
- layout.setWidget(5, QFormLayout::LabelRole, &w1);
- layout.setWidget(3, QFormLayout::FieldRole, &w2);
- layout.setWidget(3, QFormLayout::LabelRole, &w3);
- layout.addRow(&w4, &w5);
- layout.addRow("Foo:", &l6);
+ layout->setWidget(5, QFormLayout::LabelRole, w1);
+ layout->setWidget(3, QFormLayout::FieldRole, w2);
+ layout->setWidget(3, QFormLayout::LabelRole, w3);
+ layout->addRow(w4, w5);
+ layout->addRow("Foo:", l6);
- QCOMPARE(layout.count(), 7);
+ QCOMPARE(layout->count(), 7);
QBitArray scoreBoard(7);
for (int i = 0; i < 7; ++i) {
- QLayoutItem *item = layout.itemAt(i);
+ QLayoutItem *item = layout->itemAt(i);
QVERIFY(item != 0);
- if (item->widget() == &w1) {
+ if (item->widget() == w1) {
scoreBoard[0] = true;
- } else if (item->widget() == &w2) {
+ } else if (item->widget() == w2) {
scoreBoard[1] = true;
- } else if (item->widget() == &w3) {
+ } else if (item->widget() == w3) {
scoreBoard[2] = true;
- } else if (item->widget() == &w4) {
+ } else if (item->widget() == w4) {
scoreBoard[3] = true;
- } else if (item->widget() == &w5) {
+ } else if (item->widget() == w5) {
scoreBoard[4] = true;
- } else if (item->layout() == &l6) {
+ } else if (item->layout() == l6) {
scoreBoard[5] = true;
} else if (qobject_cast<QLabel *>(item->widget())) {
scoreBoard[6] = true;
@@ -883,26 +872,27 @@ void tst_QFormLayout::itemAt()
void tst_QFormLayout::takeAt()
{
- QFormLayout layout;
+ QWidget topLevel;
+ QFormLayout *layout = new QFormLayout(&topLevel);
- QWidget w1;
- QWidget w2;
- QWidget w3;
- QWidget w4;
- QWidget w5;
- QHBoxLayout l6;
+ QWidget *w1 = new QWidget(&topLevel);
+ QWidget *w2 = new QWidget(&topLevel);
+ QWidget *w3 = new QWidget(&topLevel);
+ QWidget *w4 = new QWidget(&topLevel);
+ QWidget *w5 = new QWidget(&topLevel);
+ QHBoxLayout *l6 = new QHBoxLayout;
- layout.setWidget(5, QFormLayout::LabelRole, &w1);
- layout.setWidget(3, QFormLayout::FieldRole, &w2);
- layout.setWidget(3, QFormLayout::LabelRole, &w3);
- layout.addRow(&w4, &w5);
- layout.addRow("Foo:", &l6);
+ layout->setWidget(5, QFormLayout::LabelRole, w1);
+ layout->setWidget(3, QFormLayout::FieldRole, w2);
+ layout->setWidget(3, QFormLayout::LabelRole, w3);
+ layout->addRow(w4, w5);
+ layout->addRow("Foo:", l6);
- QCOMPARE(layout.count(), 7);
+ QCOMPARE(layout->count(), 7);
for (int i = 6; i >= 0; --i) {
- layout.takeAt(0);
- QCOMPARE(layout.count(), i);
+ layout->takeAt(0);
+ QCOMPARE(layout->count(), i);
}
}
@@ -917,6 +907,7 @@ void tst_QFormLayout::layoutAlone()
QHBoxLayout hlay;
layout.setLayout(1, QFormLayout::LabelRole, &hlay);
QCOMPARE(layout.count(), 2);
+ w.setWindowTitle(QTest::currentTestFunction());
w.show();
layout.activate();
QTest::qWait(500);
diff --git a/tests/auto/widgets/kernel/qgridlayout/tst_qgridlayout.cpp b/tests/auto/widgets/kernel/qgridlayout/tst_qgridlayout.cpp
index 7f3c289fb4..1e67c675ef 100644
--- a/tests/auto/widgets/kernel/qgridlayout/tst_qgridlayout.cpp
+++ b/tests/auto/widgets/kernel/qgridlayout/tst_qgridlayout.cpp
@@ -60,18 +60,9 @@ class tst_QGridLayout : public QObject
{
Q_OBJECT
-public:
- tst_QGridLayout();
- virtual ~tst_QGridLayout();
-
-
-public slots:
+private slots:
void initTestCase();
- void cleanupTestCase();
- void init();
void cleanup();
-
-private slots:
void getItemPosition();
void itemAtPosition();
void badDistributionBug();
@@ -97,76 +88,72 @@ private slots:
void taskQTBUG_40609_addingLayoutToItself();
void replaceWidget();
void dontCrashWhenExtendsToEnd();
-
-private:
- QWidget *testWidget;
- QGridLayout *testLayout;
- QWidget *w1;
- QWidget *w2;
- QWidget *w3;
- QSpacerItem *sp;
-
- QGridLayout *m_grid;
- QWidget *m_toplevel;
};
-
-tst_QGridLayout::tst_QGridLayout()
+void tst_QGridLayout::initTestCase()
{
- m_grid = 0;
- m_toplevel = 0;
+#ifdef Q_OS_WINCE //disable magic for WindowsCE
+ qApp->setAutoMaximizeThreshold(-1);
+#endif
}
-tst_QGridLayout::~tst_QGridLayout()
+static inline int visibleTopLevelWidgetCount()
{
- delete m_toplevel;
+ int result= 0;
+ foreach (const QWidget *topLevel, QApplication::topLevelWidgets()) {
+ if (topLevel->isVisible())
+ ++result;
+ }
+ return result;
}
-void tst_QGridLayout::initTestCase()
+void tst_QGridLayout::cleanup()
{
-#ifdef Q_OS_WINCE //disable magic for WindowsCE
- qApp->setAutoMaximizeThreshold(-1);
-#endif
- // Create the test class
- testWidget = new QWidget(0);
+ // Verify that no visible top levels are leaked. Cannot check for
+ // topLevelWidgets().isEmpty() here since the data driven test layoutSpacing()
+ // will appear to "leak" top levels due to it creating widgets in the test data.
+ QCOMPARE(visibleTopLevelWidgetCount(), 0);
+}
- testLayout = new QGridLayout(testWidget);
+class ItemTestWidget : public QWidget {
+public:
+ ItemTestWidget();
+
+ QGridLayout *testLayout;
+ QWidget *w1;
+ QWidget *w2;
+ QWidget *w3;
+ QSpacerItem *sp;
+};
+
+ItemTestWidget::ItemTestWidget()
+ : testLayout(new QGridLayout(this))
+ , w1(new QWidget(this))
+ , w2(new QWidget(this))
+ , w3(new QWidget(this))
+ , sp(new QSpacerItem(4, 4))
+{
+ setObjectName("testWidget");
+ setWindowTitle(QTest::currentTestFunction());
- w1 = new QWidget(testWidget);
w1->setPalette(QPalette(Qt::red));
testLayout->addWidget(w1, 0, 0);
- w2 = new QWidget(testWidget);
testLayout->addWidget(w2, 1, 1, 2, 2);
w2->setPalette(QPalette(Qt::green));
- w3 = new QWidget(testWidget);
testLayout->addWidget(w3, 0, 1, 1, 2);
w3->setPalette(QPalette(Qt::blue));
- sp = new QSpacerItem(4, 4);
testLayout->addItem(sp, 1, 3, 2, 1);
-
- testWidget->resize( 200, 200 );
- testWidget->show();
-}
-
-void tst_QGridLayout::cleanupTestCase()
-{
- delete testWidget;
- testWidget = 0;
-}
-
-void tst_QGridLayout::init()
-{
-}
-
-void tst_QGridLayout::cleanup()
-{
}
void tst_QGridLayout::getItemPosition()
{
+ ItemTestWidget testWidget;
+ testWidget.resize(200, 200);
+ testWidget.show();
+
QLayoutItem *item;
int counter = 0;
@@ -175,28 +162,28 @@ void tst_QGridLayout::getItemPosition()
bool seenW3 = false;
bool seenSpacer = false;
- while ((item = testLayout->itemAt(counter))) {
+ while ((item = testWidget.testLayout->itemAt(counter))) {
QWidget *w = item->widget();
int r,c,rs,cs;
- testLayout->getItemPosition(counter, &r, &c, &rs, &cs);
+ testWidget.testLayout->getItemPosition(counter, &r, &c, &rs, &cs);
// qDebug() << "item" << counter << "has" <<r << c << rs << cs;
- if (w == w1) {
+ if (w == testWidget.w1) {
QVERIFY(!seenW1);
seenW1 = true;
QCOMPARE(r, 0);
QCOMPARE(c, 0);
QCOMPARE(rs, 1);
QCOMPARE(cs, 1);
- } else if (w == w2) {
+ } else if (w == testWidget.w2) {
QVERIFY(!seenW2);
seenW2 = true;
QCOMPARE(r, 1);
QCOMPARE(c, 1);
QCOMPARE(rs, 2);
QCOMPARE(cs, 2);
- } else if (w == w3) {
+ } else if (w == testWidget.w3) {
QVERIFY(!seenW3);
seenW3 = true;
QCOMPARE(r, 0);
@@ -223,16 +210,20 @@ void tst_QGridLayout::getItemPosition()
void tst_QGridLayout::itemAtPosition()
{
+ ItemTestWidget testWidget;
+ testWidget.resize(200, 200);
+ testWidget.show();
+
void *table[4][5] = {
- { w1, w3, w3, 0, 0 },
- { 0, w2, w2, sp, 0 },
- { 0, w2, w2, sp, 0 },
+ { testWidget.w1, testWidget.w3,testWidget.w3, 0, 0 },
+ { 0, testWidget.w2, testWidget.w2, testWidget.sp, 0 },
+ { 0, testWidget.w2, testWidget.w2, testWidget.sp, 0 },
{ 0, 0, 0, 0, 0 }
};
for (int row = 0; row < 4; ++row) {
for (int col = 0; col < 5; ++col) {
- QLayoutItem *item = testLayout->itemAtPosition(row, col);
+ QLayoutItem *item = testWidget.testLayout->itemAtPosition(row, col);
QVERIFY(item == table[row][col]
|| (item && item->widget() == table[row][col]));
}
@@ -860,32 +851,31 @@ void tst_QGridLayout::minMaxSize()
}
}
QApplication::setStyle(style);
- if (!m_grid)
- m_grid = new QGridLayout();
- if (!m_toplevel) {
- m_toplevel = new QWidget();
- setFrameless(m_toplevel);
- }
+ QWidget toplevel;
+ toplevel.setWindowTitle(QLatin1String(QTest::currentTestFunction())
+ + QLatin1Char(' ') + QLatin1String(QTest::currentDataTag()));
+ setFrameless(&toplevel);
+ QGridLayout *grid = new QGridLayout;
if (fixedSize.isValid()) {
- m_toplevel->setFixedSize(fixedSize);
+ toplevel.setFixedSize(fixedSize);
} else {
- m_toplevel->setMinimumSize(QSize(0,0));
- m_toplevel->setMaximumSize(QSize(QWIDGETSIZE_MAX,QWIDGETSIZE_MAX));
+ toplevel.setMinimumSize(QSize(0,0));
+ toplevel.setMaximumSize(QSize(QWIDGETSIZE_MAX,QWIDGETSIZE_MAX));
}
// Do a two-pass one using the real testdata, the other pass enables heightForWidth
// on the widget, but the heightForWidth() function just return sizeHint().width()
for (int pass = 0; pass < 2; ++pass) {
- m_toplevel->hide();
+ toplevel.hide();
QApplication::processEvents();
QTest::qWait(20);
// Test if removeItem uninitializes data properly
- while (m_grid->count()) {
- QLayoutItem *item = m_grid->itemAt(0);
- m_grid->removeItem(item);
+ while (grid->count()) {
+ QLayoutItem *item = grid->itemAt(0);
+ grid->removeItem(item);
delete item->widget();
delete item;
}
- m_toplevel->setLayout(m_grid);
+ toplevel.setLayout(grid);
// a layout with a top-level parent widget
QList<QPointer<SizeHinterFrame> > sizehinters;
@@ -899,29 +889,29 @@ void tst_QGridLayout::minMaxSize()
QSizePolicy sp = sh->sizePolicy();
sp.setHorizontalPolicy((QSizePolicy::Policy)sizePolicy);
sh->setSizePolicy(sp);
- sh->setParent(m_toplevel);
+ sh->setParent(&toplevel);
if (si.minSize.isValid())
sh->setMinimumSize(si.minSize);
if (si.maxSize.isValid())
sh->setMaximumSize(si.maxSize);
sizehinters.append(sh);
- m_grid->addWidget(sh, i, j);
+ grid->addWidget(sh, i, j);
}
}
- m_toplevel->show();
- QVERIFY(QTest::qWaitForWindowExposed(m_toplevel));
- m_toplevel->adjustSize();
+ toplevel.show();
+ QVERIFY(QTest::qWaitForWindowExposed(&toplevel));
+ toplevel.adjustSize();
QTest::qWait(240); // wait for the implicit adjustSize
// If the following fails we might have to wait longer.
// If that does not help there is likely a problem with the implicit adjustSize in show()
if (!fixedSize.isValid()) {
// Note that this can fail if the desktop has large fonts on windows.
- QTRY_COMPARE(m_toplevel->size(), m_toplevel->sizeHint());
+ QTRY_COMPARE(toplevel.size(), toplevel.sizeHint());
}
// We are relying on the order here...
for (int pi = 0; pi < sizehinters.count(); ++pi) {
- QPoint pt = sizehinters.at(pi)->mapTo(m_toplevel, QPoint(0, 0));
+ QPoint pt = sizehinters.at(pi)->mapTo(&toplevel, QPoint(0, 0));
QCOMPARE(pt, sizeinfos.at(pi).expectedPos);
}
}
diff --git a/tests/auto/widgets/kernel/qlayout/tst_qlayout.cpp b/tests/auto/widgets/kernel/qlayout/tst_qlayout.cpp
index d661c074ac..4d15ac9a93 100644
--- a/tests/auto/widgets/kernel/qlayout/tst_qlayout.cpp
+++ b/tests/auto/widgets/kernel/qlayout/tst_qlayout.cpp
@@ -66,6 +66,7 @@ public:
virtual ~tst_QLayout();
private slots:
+ void cleanup() { QVERIFY(QApplication::topLevelWidgets().isEmpty()); }
void getSetCheck();
void geometry();
void smartMaxSize();
@@ -217,12 +218,12 @@ void tst_QLayout::setLayoutBugs()
}
widget.setLayout(hBoxLayout);
- QVERIFY(widget.layout() == hBoxLayout);
+ QCOMPARE(widget.layout(), hBoxLayout);
QWidget containerWidget(0);
containerWidget.setLayout(widget.layout());
- QVERIFY(widget.layout() == 0);
- QVERIFY(containerWidget.layout() == hBoxLayout);
+ QVERIFY(!widget.layout());
+ QCOMPARE(containerWidget.layout(), hBoxLayout);
}
class MyLayout : public QLayout
diff --git a/tests/auto/widgets/kernel/qshortcut/tst_qshortcut.cpp b/tests/auto/widgets/kernel/qshortcut/tst_qshortcut.cpp
index 7b9eaa418f..f206a5fe9a 100644
--- a/tests/auto/widgets/kernel/qshortcut/tst_qshortcut.cpp
+++ b/tests/auto/widgets/kernel/qshortcut/tst_qshortcut.cpp
@@ -108,6 +108,7 @@ public slots:
public slots:
void initTestCase();
void cleanupTestCase();
+ void cleanup() { QCOMPARE(QApplication::topLevelWidgets().size(), 1); }
private slots:
void number_data();
diff --git a/tests/auto/widgets/kernel/qsizepolicy/tst_qsizepolicy.cpp b/tests/auto/widgets/kernel/qsizepolicy/tst_qsizepolicy.cpp
index 6c88f8731b..0f8c9d1c9e 100644
--- a/tests/auto/widgets/kernel/qsizepolicy/tst_qsizepolicy.cpp
+++ b/tests/auto/widgets/kernel/qsizepolicy/tst_qsizepolicy.cpp
@@ -44,6 +44,7 @@ class tst_QSizePolicy : public QObject
Q_OBJECT
private Q_SLOTS:
+ void cleanup() { QVERIFY(QApplication::topLevelWidgets().isEmpty()); }
void qtest();
void defaultValues();
void getSetCheck_data() { data(); }
@@ -51,6 +52,8 @@ private Q_SLOTS:
void dataStream();
void horizontalStretch();
void verticalStretch();
+ void qhash_data() { data(); }
+ void qhash();
private:
void data() const;
};
@@ -149,8 +152,6 @@ void tst_QSizePolicy::getSetCheck()
QCOMPARE(sp.expandingDirections(), ed);
}
-#undef FETCH_TEST_DATA
-
static void makeRow(QSizePolicy sp, QSizePolicy::Policy hp, QSizePolicy::Policy vp,
int hst, int vst, QSizePolicy::ControlType ct, bool hfw, bool wfh,
Qt::Orientations orients)
@@ -314,5 +315,21 @@ void tst_QSizePolicy::verticalStretch()
QCOMPARE(sp.verticalStretch(), 255);
}
+void tst_QSizePolicy::qhash()
+{
+ FETCH_TEST_DATA;
+ Q_UNUSED(ed);
+
+ QSizePolicy sp2(hp, vp, ct);
+ sp2.setVerticalStretch(vst);
+ sp2.setHorizontalStretch(hst);
+ if (hfw) sp2.setHeightForWidth(true);
+ if (wfh) sp2.setWidthForHeight(true);
+ QCOMPARE(sp, sp2);
+ QCOMPARE(qHash(sp), qHash(sp2));
+}
+
+#undef FETCH_TEST_DATA
+
QTEST_MAIN(tst_QSizePolicy)
#include "tst_qsizepolicy.moc"
diff --git a/tests/auto/widgets/kernel/qtooltip/BLACKLIST b/tests/auto/widgets/kernel/qtooltip/BLACKLIST
new file mode 100644
index 0000000000..f8d062cc46
--- /dev/null
+++ b/tests/auto/widgets/kernel/qtooltip/BLACKLIST
@@ -0,0 +1,4 @@
+[whatsThis]
+ubuntu-14.04
+[task183679]
+opensuse-13.1
diff --git a/tests/auto/widgets/kernel/qwidget/BLACKLIST b/tests/auto/widgets/kernel/qwidget/BLACKLIST
index 591aa9e40f..78ccbe302a 100644
--- a/tests/auto/widgets/kernel/qwidget/BLACKLIST
+++ b/tests/auto/widgets/kernel/qwidget/BLACKLIST
@@ -12,7 +12,7 @@ osx
ubuntu-14.04
osx
[focusProxyAndInputMethods]
-ubuntu-14.04
+linux
[touchEventSynthesizedMouseEvent]
ubuntu-14.04
[grabMouse]
@@ -28,73 +28,17 @@ osx
[stackUnder]
osx
[raise]
-osx-10.9
+osx
[widgetAt]
osx
[sheetOpacity]
osx
[resizeEvent]
osx
-[setWindowGeometry:100,123 200x200, flags 0]
-osx-10.10
-[windowMoveResize:100,123 200x200, flags 0]
-osx-10.10
-[setWindowGeometry:100,122 200x200, flags 0]
-osx-10.9
-[windowMoveResize:100,122 200x200, flags 0]
-osx-10.9
-[setWindowGeometry:100,100 824x564, flags 0]
-osx-10.10
-[windowMoveResize:100,100 824x564, flags 0]
-osx-10.10
-[setWindowGeometry:100,100 824x516, flags 0]
-osx-10.10
-[windowMoveResize:100,100 824x516, flags 0]
-osx-10.10
-[setWindowGeometry:100,73 200x0, flags 0]
-osx-10.10
-[windowMoveResize:100,73 200x0, flags 0]
-osx-10.10
-[setWindowGeometry:100,100 824x519, flags 0]
-osx-10.10
-[windowMoveResize:100,100 824x519, flags 0]
-osx-10.10
-[setWindowGeometry:100,100 824x518, flags 0]
-osx-10.10
-[windowMoveResize:100,100 824x518, flags 0]
-osx-10.10
-[setWindowGeometry:100,72 200x0, flags 0]
-osx-10.9
-[windowMoveResize:100,72 200x0, flags 0]
-osx-10.9
-[setWindowGeometry:100,122 952x574, flags 0]
-osx-10.9
-[windowMoveResize:100,122 952x574, flags 0]
-osx-10.9
-[setWindowGeometry:100,122 952x578, flags 0]
-osx-10.9
-[windowMoveResize:100,122 952x578, flags 0]
-osx-10.9
-[setWindowGeometry:100,122 952x576, flags 0]
-osx-10.9
-[windowMoveResize:100,122 952x576, flags 0]
-osx-10.9
-[setWindowGeometry:100,100 824x521, flags 0]
-osx-10.10
-[windowMoveResize:100,100 824x521, flags 0]
-osx-10.10
-[setWindowGeometry:100,122 952x577, flags 0]
-osx-10.9
-[windowMoveResize:100,122 952x577, flags 0]
-osx-10.9
-[setWindowGeometry:100,122 952x580, flags 0]
-osx-10.9
-[windowMoveResize:100,122 952x580, flags 0]
-osx-10.9
-[windowMoveResize:130,72 0x0, flags 0]
-osx-10.9
-[windowMoveResize:130,122 0x200, flags 0]
-osx-10.9
+[setWindowGeometry]
+osx
+[windowMoveResize]
+osx
[childEvents]
osx
[renderInvisible]
@@ -114,9 +58,9 @@ osx
[showMinimizedKeepsFocus]
osx-10.10
[moveWindowInShowEvent:1]
-osx-10.9
+osx
[moveWindowInShowEvent:2]
-osx-10.9
+osx
[taskQTBUG_4055_sendSyntheticEnterLeave]
osx
[syntheticEnterLeave]
@@ -128,10 +72,14 @@ osx-10.10
[hideOpaqueChildWhileHidden]
osx
[resizeStaticContentsChildWidget_QTBUG35282]
-osx-10.9
+osx
[lower]
osx
[setClearAndResizeMask]
osx
[setToolTip]
osx-10.9
+[moveInResizeEvent]
+ubuntu-14.04
+[moveChild:right]
+osx
diff --git a/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp b/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp
index a0d94d2dc9..34bd575646 100644
--- a/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp
+++ b/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp
@@ -51,6 +51,7 @@
#include <qdesktopwidget.h>
#include <private/qwidget_p.h>
#include <private/qapplication_p.h>
+#include <private/qhighdpiscaling_p.h>
#include <qcalendarwidget.h>
#include <qmainwindow.h>
#include <qdockwidget.h>
@@ -193,6 +194,19 @@ static QByteArray msgComparisonFailed(T v1, const char *op, T v2)
return s.toLocal8Bit();
}
+// Compare a window position that may go through scaling in the platform plugin with fuzz.
+static inline bool qFuzzyCompareWindowPosition(const QPoint &p1, const QPoint p2, int fuzz)
+{
+ return (p1 - p2).manhattanLength() <= fuzz;
+}
+
+static QString msgPointMismatch(const QPoint &p1, const QPoint p2)
+{
+ QString result;
+ QDebug(&result) << p1 << "!=" << p2 << ", manhattanLength=" << (p1 - p2).manhattanLength();
+ return result;
+}
+
class tst_QWidget : public QObject
{
Q_OBJECT
@@ -1905,8 +1919,10 @@ void tst_QWidget::windowState()
widget1.setWindowState(widget1.windowState() ^ Qt::WindowMaximized);
QTest::qWait(100);
+ const int fuzz = int(QHighDpiScaling::factor(widget1.windowHandle()));
QVERIFY(!(widget1.windowState() & Qt::WindowMaximized));
- QTRY_COMPARE(widget1.pos(), pos);
+ QTRY_VERIFY2(qFuzzyCompareWindowPosition(widget1.pos(), pos, fuzz),
+ qPrintable(msgPointMismatch(widget1.pos(), pos)));
QCOMPARE(widget1.windowHandle()->windowState(), Qt::WindowNoState);
widget1.setWindowState(Qt::WindowMinimized);
@@ -1927,7 +1943,8 @@ void tst_QWidget::windowState()
widget1.setWindowState(widget1.windowState() ^ Qt::WindowMaximized);
QTest::qWait(100);
QVERIFY(!(widget1.windowState() & (Qt::WindowMinimized|Qt::WindowMaximized)));
- QTRY_COMPARE(widget1.pos(), pos);
+ QTRY_VERIFY2(qFuzzyCompareWindowPosition(widget1.pos(), pos, fuzz),
+ qPrintable(msgPointMismatch(widget1.pos(), pos)));
QCOMPARE(widget1.windowHandle()->windowState(), Qt::WindowNoState);
widget1.setWindowState(Qt::WindowFullScreen);
@@ -1948,7 +1965,8 @@ void tst_QWidget::windowState()
widget1.setWindowState(Qt::WindowNoState);
QTest::qWait(100);
VERIFY_STATE(Qt::WindowNoState);
- QTRY_COMPARE(widget1.pos(), pos);
+ QTRY_VERIFY2(qFuzzyCompareWindowPosition(widget1.pos(), pos, fuzz),
+ qPrintable(msgPointMismatch(widget1.pos(), pos)));
QCOMPARE(widget1.windowHandle()->windowState(), Qt::WindowNoState);
widget1.setWindowState(Qt::WindowFullScreen);
@@ -1981,7 +1999,8 @@ void tst_QWidget::windowState()
QVERIFY(!(widget1.windowState() & stateMask));
QCOMPARE(widget1.windowHandle()->windowState(), Qt::WindowNoState);
- QTRY_COMPARE(widget1.pos(), pos);
+ QTRY_VERIFY2(qFuzzyCompareWindowPosition(widget1.pos(), pos, fuzz),
+ qPrintable(msgPointMismatch(widget1.pos(), pos)));
QTRY_COMPARE(widget1.size(), size);
}
@@ -3079,12 +3098,12 @@ void tst_QWidget::saveRestoreGeometry()
const QByteArray four("abca");
const QByteArray garbage("abcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabcabc");
- QVERIFY(widget.restoreGeometry(empty) == false);
- QVERIFY(widget.restoreGeometry(one) == false);
- QVERIFY(widget.restoreGeometry(two) == false);
- QVERIFY(widget.restoreGeometry(three) == false);
- QVERIFY(widget.restoreGeometry(four) == false);
- QVERIFY(widget.restoreGeometry(garbage) == false);
+ QVERIFY(!widget.restoreGeometry(empty));
+ QVERIFY(!widget.restoreGeometry(one));
+ QVERIFY(!widget.restoreGeometry(two));
+ QVERIFY(!widget.restoreGeometry(three));
+ QVERIFY(!widget.restoreGeometry(four));
+ QVERIFY(!widget.restoreGeometry(garbage));
QVERIFY(widget.restoreGeometry(savedGeometry));
widget.showNormal();
@@ -3354,7 +3373,7 @@ void tst_QWidget::widgetAt()
#if defined(Q_OS_WINCE)
QEXPECT_FAIL("", "Windows CE does only support rectangular regions", Continue); //See also task 147191
#endif
- QTRY_VERIFY(QApplication::widgetAt(testPos) == w1.data());
+ QTRY_COMPARE(QApplication::widgetAt(testPos), w1.data());
QTRY_VERIFY(QApplication::widgetAt(testPos + QPoint(1, 1)) == w2.data());
}
@@ -3401,24 +3420,24 @@ void tst_QWidget::testDeletionInEventHandlers()
QPointer<Widget> w = new Widget;
w->deleteThis = true;
w->close();
- QVERIFY(w == 0);
+ QVERIFY(w.isNull());
delete w;
// focusOut (crashes)
//w = new Widget;
//w->show();
//w->setFocus();
- //QVERIFY(qApp->focusWidget() == w);
+ //QCOMPARE(qApp->focusWidget(), w);
//w->deleteThis = true;
//w->clearFocus();
- //QVERIFY(w == 0);
+ //QVERIFY(w.isNull());
// key press
w = new Widget;
w->show();
w->deleteThis = true;
QTest::keyPress(w, Qt::Key_A);
- QVERIFY(w == 0);
+ QVERIFY(w.isNull());
delete w;
// key release
@@ -3426,7 +3445,7 @@ void tst_QWidget::testDeletionInEventHandlers()
w->show();
w->deleteThis = true;
QTest::keyRelease(w, Qt::Key_A);
- QVERIFY(w == 0);
+ QVERIFY(w.isNull());
delete w;
// mouse press
@@ -3434,15 +3453,16 @@ void tst_QWidget::testDeletionInEventHandlers()
w->show();
w->deleteThis = true;
QTest::mousePress(w, Qt::LeftButton);
- QVERIFY(w == 0);
+ QVERIFY(w.isNull());
delete w;
// mouse release
w = new Widget;
w->show();
w->deleteThis = true;
- QTest::mouseRelease(w, Qt::LeftButton);
- QVERIFY(w == 0);
+ QMouseEvent me(QEvent::MouseButtonRelease, QPoint(1, 1), Qt::LeftButton, Qt::LeftButton, 0);
+ qApp->notify(w, &me);
+ QVERIFY(w.isNull());
delete w;
// mouse double click
@@ -3450,7 +3470,7 @@ void tst_QWidget::testDeletionInEventHandlers()
w->show();
w->deleteThis = true;
QTest::mouseDClick(w, Qt::LeftButton);
- QVERIFY(w == 0);
+ QVERIFY(w.isNull());
delete w;
// hide event (crashes)
@@ -3458,13 +3478,13 @@ void tst_QWidget::testDeletionInEventHandlers()
//w->show();
//w->deleteThis = true;
//w->hide();
- //QVERIFY(w == 0);
+ //QVERIFY(w.isNull());
// action event
w = new Widget;
w->deleteThis = true;
w->addAction(new QAction(w));
- QVERIFY(w == 0);
+ QVERIFY(w.isNull());
delete w;
// change event
@@ -3472,16 +3492,16 @@ void tst_QWidget::testDeletionInEventHandlers()
w->show();
w->deleteThis = true;
w->setMouseTracking(true);
- QVERIFY(w == 0);
+ QVERIFY(w.isNull());
delete w;
w = new Widget;
w->setMouseTracking(true);
w->show();
w->deleteThis = true;
- QMouseEvent me(QEvent::MouseMove, QPoint(0, 0), Qt::NoButton, Qt::NoButton, Qt::NoModifier);
+ me = QMouseEvent(QEvent::MouseMove, QPoint(0, 0), Qt::NoButton, Qt::NoButton, Qt::NoModifier);
QApplication::sendEvent(w, &me);
- QVERIFY(w == 0);
+ QVERIFY(w.isNull());
delete w;
}
@@ -3675,6 +3695,8 @@ void tst_QWidget::optimizedResizeMove()
void tst_QWidget::optimizedResize_topLevel()
{
+ if (QHighDpiScaling::isActive())
+ QSKIP("Skip due to rounding errors in the regions.");
StaticWidget topLevel;
topLevel.gotPaintEvent = false;
topLevel.show();
@@ -3909,7 +3931,7 @@ void tst_QWidget::winIdChangeEvent()
QCOMPARE(winIdBefore, winIdAfter);
QCOMPARE(child.winIdChangeEventCount(), 3);
// winId is set to zero during reparenting
- QVERIFY(0 == child.m_winIdList[1]);
+ QCOMPARE(WId(0), child.m_winIdList[1]);
}
{
@@ -3949,7 +3971,7 @@ void tst_QWidget::winIdChangeEvent()
QCOMPARE(winIdBefore, winIdAfter);
QCOMPARE(child.winIdChangeEventCount(), 3);
// winId is set to zero during reparenting
- QVERIFY(0 == child.m_winIdList[1]);
+ QCOMPARE(WId(0), child.m_winIdList[1]);
}
}
@@ -4495,7 +4517,7 @@ void tst_QWidget::qobject_castInDestroyedSlot()
QObject::connect(widget, SIGNAL(destroyed(QObject*)), &checker, SLOT(destroyedSlot(QObject*)));
delete widget;
- QVERIFY(checker.wasQWidget == true);
+ QVERIFY(checker.wasQWidget);
}
// Since X11 WindowManager operations are all async, and we have no way to know if the window
@@ -6007,10 +6029,13 @@ void tst_QWidget::childEvents()
expected =
EventRecorder::EventList()
<< qMakePair(&widget, QEvent::Polish)
+ << qMakePair(&widget, QEvent::PlatformSurface)
<< qMakePair(&widget, QEvent::WinIdChange)
+ << qMakePair(&widget, QEvent::WindowIconChange)
<< qMakePair(&widget, QEvent::Move)
<< qMakePair(&widget, QEvent::Resize)
<< qMakePair(&widget, QEvent::Show)
+ << qMakePair(&widget, QEvent::CursorChange)
<< qMakePair(&widget, QEvent::ShowToParent);
QVERIFY2(spy.eventList() == expected,
@@ -6022,13 +6047,9 @@ void tst_QWidget::childEvents()
EventRecorder::EventList()
<< qMakePair(&widget, QEvent::PolishRequest)
<< qMakePair(&widget, QEvent::Type(QEvent::User + 1))
-#if defined(Q_OS_OSX) || defined(Q_OS_QNX)
<< qMakePair(&widget, QEvent::UpdateLater)
-#endif
<< qMakePair(&widget, QEvent::UpdateRequest);
- if (m_platform == QStringLiteral("windows") || m_platform == QStringLiteral("xcb"))
- QEXPECT_FAIL("", EventRecorder::msgExpectFailQtBug26424(expected, spy.eventList()).constData(), Continue);
QVERIFY2(spy.eventList() == expected,
EventRecorder::msgEventListMismatch(expected, spy.eventList()).constData());
}
@@ -6097,10 +6118,13 @@ void tst_QWidget::childEvents()
<< qMakePair(&widget, QEvent::Polish)
<< qMakePair(&widget, QEvent::ChildPolished)
<< qMakePair(&widget, QEvent::ChildPolished)
+ << qMakePair(&widget, QEvent::PlatformSurface)
<< qMakePair(&widget, QEvent::WinIdChange)
+ << qMakePair(&widget, QEvent::WindowIconChange)
<< qMakePair(&widget, QEvent::Move)
<< qMakePair(&widget, QEvent::Resize)
<< qMakePair(&widget, QEvent::Show)
+ << qMakePair(&widget, QEvent::CursorChange)
<< qMakePair(&widget, QEvent::ShowToParent);
QVERIFY2(spy.eventList() == expected,
@@ -6113,13 +6137,9 @@ void tst_QWidget::childEvents()
<< qMakePair(&widget, QEvent::PolishRequest)
<< qMakePair(&widget, QEvent::Type(QEvent::User + 1))
<< qMakePair(&widget, QEvent::Type(QEvent::User + 2))
-#if defined(Q_OS_OSX) || defined(Q_OS_QNX)
<< qMakePair(&widget, QEvent::UpdateLater)
-#endif
<< qMakePair(&widget, QEvent::UpdateRequest);
- if (m_platform == QStringLiteral("windows") || m_platform == QStringLiteral("xcb"))
- QEXPECT_FAIL("", EventRecorder::msgExpectFailQtBug26424(expected, spy.eventList()).constData(), Continue);
QVERIFY2(spy.eventList() == expected,
EventRecorder::msgEventListMismatch(expected, spy.eventList()).constData());
}
@@ -6190,10 +6210,13 @@ void tst_QWidget::childEvents()
EventRecorder::EventList()
<< qMakePair(&widget, QEvent::Polish)
<< qMakePair(&widget, QEvent::ChildPolished)
+ << qMakePair(&widget, QEvent::PlatformSurface)
<< qMakePair(&widget, QEvent::WinIdChange)
+ << qMakePair(&widget, QEvent::WindowIconChange)
<< qMakePair(&widget, QEvent::Move)
<< qMakePair(&widget, QEvent::Resize)
<< qMakePair(&widget, QEvent::Show)
+ << qMakePair(&widget, QEvent::CursorChange)
<< qMakePair(&widget, QEvent::ShowToParent);
QVERIFY2(spy.eventList() == expected,
@@ -6206,13 +6229,9 @@ void tst_QWidget::childEvents()
<< qMakePair(&widget, QEvent::PolishRequest)
<< qMakePair(&widget, QEvent::Type(QEvent::User + 1))
<< qMakePair(&widget, QEvent::Type(QEvent::User + 2))
-#if defined(Q_OS_OSX) || defined(Q_OS_QNX)
<< qMakePair(&widget, QEvent::UpdateLater)
-#endif
<< qMakePair(&widget, QEvent::UpdateRequest);
- if (m_platform == QStringLiteral("windows") || m_platform == QStringLiteral("xcb"))
- QEXPECT_FAIL("", EventRecorder::msgExpectFailQtBug26424(expected, spy.eventList()).constData(), Continue);
QVERIFY2(spy.eventList() == expected,
EventRecorder::msgEventListMismatch(expected, spy.eventList()).constData());
}
@@ -8957,7 +8976,7 @@ void tst_QWidget::taskQTBUG_4055_sendSyntheticEnterLeave()
int numEnterEvents, numMouseMoveEvents;
};
- QCursor::setPos(QPoint(0,0));
+ QCursor::setPos(QPoint(0,0));
SELParent parent;
parent.move(200, 200);
@@ -8965,8 +8984,7 @@ void tst_QWidget::taskQTBUG_4055_sendSyntheticEnterLeave()
SELChild child(&parent);
child.resize(200, 200);
parent.show();
- QVERIFY(QTest::qWaitForWindowExposed(&parent));
- QTest::qWait(150);
+ QVERIFY(QTest::qWaitForWindowActive(&parent));
QCursor::setPos(child.mapToGlobal(QPoint(100, 100)));
// Make sure the cursor has entered the child.
@@ -9714,8 +9732,9 @@ void tst_QWidget::grabMouse()
QVERIFY(QTest::qWaitForWindowActive(&w));
QStringList expectedLog;
- grabber->grabMouse();
QPoint mousePos = QPoint(w.width() / 2, 10);
+ QTest::mouseMove(w.windowHandle(), mousePos);
+ grabber->grabMouse();
const int step = w.height() / 5;
for ( ; mousePos.y() < w.height() ; mousePos.ry() += step) {
QTest::mouseClick(w.windowHandle(), Qt::LeftButton, 0, mousePos);
@@ -10385,6 +10404,9 @@ public:
void tst_QWidget::keyboardModifiers()
{
KeyboardWidget w;
+ w.resize(300, 300);
+ w.show();
+ QVERIFY(QTest::qWaitForWindowActive(&w));
QTest::mouseClick(&w, Qt::LeftButton, Qt::ControlModifier);
QCOMPARE(w.m_eventCounter, 1);
QCOMPARE(int(w.m_modifiers), int(Qt::ControlModifier));
@@ -10462,7 +10484,7 @@ void tst_QWidget::qmlSetParentHelper()
QWidget child;
QVERIFY(QAbstractDeclarativeData::setWidgetParent);
QAbstractDeclarativeData::setWidgetParent(&child, &parent);
- QVERIFY(child.parentWidget() == &parent);
+ QCOMPARE(child.parentWidget(), &parent);
QAbstractDeclarativeData::setWidgetParent(&child, 0);
QVERIFY(!child.parentWidget());
#else
diff --git a/tests/auto/widgets/kernel/qwidget_window/tst_qwidget_window.cpp b/tests/auto/widgets/kernel/qwidget_window/tst_qwidget_window.cpp
index 148c2352a5..4bdb299213 100644
--- a/tests/auto/widgets/kernel/qwidget_window/tst_qwidget_window.cpp
+++ b/tests/auto/widgets/kernel/qwidget_window/tst_qwidget_window.cpp
@@ -97,6 +97,8 @@ private slots:
void tst_resize_count();
void tst_move_count();
+
+ void tst_eventfilter_on_toplevel();
};
void tst_QWidget_window::initTestCase()
@@ -762,5 +764,48 @@ void tst_QWidget_window::tst_move_count()
QTRY_VERIFY(move.moveCount >= 1);
}
+class EventFilter : public QObject
+{
+public:
+ int eventCount;
+
+ EventFilter()
+ : QObject(),
+ eventCount(0)
+ {
+ }
+
+ static QEvent::Type filterEventType()
+ {
+ static int type = QEvent::registerEventType();
+ return static_cast<QEvent::Type>(type);
+ }
+
+protected:
+ bool eventFilter(QObject *o, QEvent *e) Q_DECL_OVERRIDE
+ {
+ if (e->type() == filterEventType())
+ ++eventCount;
+
+ return QObject::eventFilter(o, e);
+ }
+};
+
+void tst_QWidget_window::tst_eventfilter_on_toplevel()
+{
+ QWidget w;
+ EventFilter filter;
+ w.installEventFilter(&filter);
+ w.show();
+ QVERIFY(QTest::qWaitForWindowActive(&w));
+ QVERIFY(w.isWindow());
+ QCOMPARE(filter.eventCount, 0);
+
+ // send an event not handled in a special way by QWidgetWindow::event,
+ // and check that it's received by the event filter
+ QCoreApplication::postEvent(w.windowHandle(), new QEvent(EventFilter::filterEventType()));
+ QTRY_COMPARE(filter.eventCount, 1);
+}
+
QTEST_MAIN(tst_QWidget_window)
#include "tst_qwidget_window.moc"
diff --git a/tests/auto/widgets/kernel/qwidgetaction/tst_qwidgetaction.cpp b/tests/auto/widgets/kernel/qwidgetaction/tst_qwidgetaction.cpp
index df54d22a2f..207ce00dbf 100644
--- a/tests/auto/widgets/kernel/qwidgetaction/tst_qwidgetaction.cpp
+++ b/tests/auto/widgets/kernel/qwidgetaction/tst_qwidgetaction.cpp
@@ -55,6 +55,8 @@ class tst_QWidgetAction : public QObject
{
Q_OBJECT
private slots:
+ void initTestCase();
+ void cleanup();
void defaultWidget();
void visibilityUpdate();
void customWidget();
@@ -65,6 +67,19 @@ private slots:
void releaseWidgetCrash();
};
+void tst_QWidgetAction::initTestCase()
+{
+ // Disable menu/combo animations to prevent the alpha widgets from getting in the
+ // way in popup(), failing the top level leak check in cleanup().
+ QApplication::setEffectEnabled(Qt::UI_AnimateMenu, false);
+ QApplication::setEffectEnabled(Qt::UI_AnimateCombo, false);
+}
+
+void tst_QWidgetAction::cleanup()
+{
+ QVERIFY(QApplication::topLevelWidgets().isEmpty());
+}
+
void tst_QWidgetAction::defaultWidget()
{
{
@@ -123,14 +138,14 @@ void tst_QWidgetAction::defaultWidget()
action->setDefaultWidget(combo);
tb1.addAction(action);
- QVERIFY(combo->parent() == &tb1);
+ QCOMPARE(combo->parent(), &tb1);
qApp->processEvents();
qApp->processEvents();
QVERIFY(combo->isVisible());
// not supported, not supposed to work, hence the parent() check
tb2.addAction(action);
- QVERIFY(combo->parent() == &tb1);
+ QCOMPARE(combo->parent(), &tb1);
tb2.removeAction(action);
tb1.removeAction(action);
@@ -141,11 +156,11 @@ void tst_QWidgetAction::defaultWidget()
tb2.addAction(action);
qApp->processEvents(); //the call to hide is delayd by the toolbar layout
qApp->processEvents();
- QVERIFY(combo->parent() == &tb2);
+ QCOMPARE(combo->parent(), &tb2);
QVERIFY(combo->isVisible());
tb1.addAction(action);
- QVERIFY(combo->parent() == &tb2);
+ QCOMPARE(combo->parent(), &tb2);
delete action;
QVERIFY(!combo);
@@ -156,17 +171,17 @@ void tst_QWidgetAction::defaultWidget()
QPointer<QComboBox> combo1 = new QComboBox;
a->setDefaultWidget(combo1);
- QVERIFY(a->defaultWidget() == combo1);
+ QCOMPARE(a->defaultWidget(), combo1.data());
a->setDefaultWidget(combo1);
QVERIFY(combo1);
- QVERIFY(a->defaultWidget() == combo1);
+ QCOMPARE(a->defaultWidget(), combo1.data());
QPointer<QComboBox> combo2 = new QComboBox;
QVERIFY(combo1 != combo2);
a->setDefaultWidget(combo2);
QVERIFY(!combo1);
- QVERIFY(a->defaultWidget() == combo2);
+ QCOMPARE(a->defaultWidget(), combo2.data());
delete a;
QVERIFY(!combo2);
@@ -238,7 +253,7 @@ void tst_QWidgetAction::customWidget()
combos = action->createdWidgets();
QCOMPARE(combos.count(), 2);
- QVERIFY(combos.at(0) == combo1);
+ QCOMPARE(combos.at(0), combo1.data());
QPointer<QComboBox> combo2 = qobject_cast<QComboBox *>(combos.at(1));
QVERIFY(combo2);
@@ -262,7 +277,7 @@ void tst_QWidgetAction::keepOwnership()
{
QToolBar *tb = new QToolBar;
tb->addAction(action);
- QVERIFY(combo->parent() == tb);
+ QCOMPARE(combo->parent(), tb);
delete tb;
}
diff --git a/tests/auto/widgets/kernel/qwidgetsvariant/tst_qwidgetsvariant.cpp b/tests/auto/widgets/kernel/qwidgetsvariant/tst_qwidgetsvariant.cpp
index 8b566713f9..690ef30f71 100644
--- a/tests/auto/widgets/kernel/qwidgetsvariant/tst_qwidgetsvariant.cpp
+++ b/tests/auto/widgets/kernel/qwidgetsvariant/tst_qwidgetsvariant.cpp
@@ -84,13 +84,13 @@ void tst_QWidgetsVariant::constructor_invalid()
QTest::ignoreMessage(QtWarningMsg, QRegularExpression("^Trying to construct an instance of an invalid type, type id:"));
QVariant variant(static_cast<QVariant::Type>(typeId));
QVERIFY(!variant.isValid());
- QVERIFY(variant.userType() == QMetaType::UnknownType);
+ QCOMPARE(variant.userType(), int(QMetaType::UnknownType));
}
{
QTest::ignoreMessage(QtWarningMsg, QRegularExpression("^Trying to construct an instance of an invalid type, type id:"));
QVariant variant(typeId, /* copy */ 0);
QVERIFY(!variant.isValid());
- QVERIFY(variant.userType() == QMetaType::UnknownType);
+ QCOMPARE(variant.userType(), int(QMetaType::UnknownType));
}
}
@@ -208,7 +208,7 @@ void tst_QWidgetsVariant::qvariant_cast_QObject_derived()
CustomQWidget customWidget;
QWidget *widget = &customWidget;
QVariant data = QVariant::fromValue(widget);
- QVERIFY(data.userType() == qMetaTypeId<QWidget*>());
+ QCOMPARE(data.userType(), qMetaTypeId<QWidget*>());
QCOMPARE(data.value<QObject*>(), widget);
QCOMPARE(data.value<QWidget*>(), widget);
diff --git a/tests/auto/widgets/kernel/qwindowcontainer/tst_qwindowcontainer.cpp b/tests/auto/widgets/kernel/qwindowcontainer/tst_qwindowcontainer.cpp
index 33427788f6..7d48ab760d 100644
--- a/tests/auto/widgets/kernel/qwindowcontainer/tst_qwindowcontainer.cpp
+++ b/tests/auto/widgets/kernel/qwindowcontainer/tst_qwindowcontainer.cpp
@@ -327,7 +327,7 @@ void tst_QWindowContainer::testDockWidget()
QTest::qWait(1000);
dock->setFloating(false);
- QTRY_VERIFY(window->parent() == mainWindow.window()->windowHandle());
+ QTRY_COMPARE(window->parent(), mainWindow.window()->windowHandle());
}
QTEST_MAIN(tst_QWindowContainer)