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/tst_qaction.cpp133
-rw-r--r--tests/auto/widgets/kernel/qapplication/test/test.pro2
-rw-r--r--tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp50
-rw-r--r--tests/auto/widgets/kernel/qformlayout/tst_qformlayout.cpp275
-rw-r--r--tests/auto/widgets/kernel/qgridlayout/tst_qgridlayout.cpp43
-rw-r--r--tests/auto/widgets/kernel/qlayout/qlayout.pro8
-rw-r--r--tests/auto/widgets/kernel/qwidget/BLACKLIST2
-rw-r--r--tests/auto/widgets/kernel/qwidget/qwidget.pro6
-rw-r--r--tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp476
-rw-r--r--tests/auto/widgets/kernel/qwidget_window/qwidget_window.pro5
-rw-r--r--tests/auto/widgets/kernel/qwidget_window/tst_qwidget_window.cpp6
11 files changed, 521 insertions, 485 deletions
diff --git a/tests/auto/widgets/kernel/qaction/tst_qaction.cpp b/tests/auto/widgets/kernel/qaction/tst_qaction.cpp
index e6a615d4f5..83e1850524 100644
--- a/tests/auto/widgets/kernel/qaction/tst_qaction.cpp
+++ b/tests/auto/widgets/kernel/qaction/tst_qaction.cpp
@@ -42,15 +42,12 @@ class tst_QAction : public QObject
public:
tst_QAction();
- virtual ~tst_QAction();
-
void updateState(QActionEvent *e);
-public slots:
- void initTestCase();
- void cleanupTestCase();
private slots:
+ void init();
+ void cleanup();
void getSetCheck();
void setText_data();
void setText();
@@ -68,11 +65,26 @@ private slots:
private:
int m_lastEventType;
- int m_keyboardScheme;
+ const int m_keyboardScheme;
QAction *m_lastAction;
- QWidget *m_tstWidget;
};
+tst_QAction::tst_QAction()
+ : m_keyboardScheme(QGuiApplicationPrivate::platformTheme()->themeHint(QPlatformTheme::KeyboardScheme).toInt())
+{
+}
+
+void tst_QAction::init()
+{
+ m_lastEventType = 0;
+ m_lastAction = nullptr;
+}
+
+void tst_QAction::cleanup()
+{
+ QVERIFY(QApplication::topLevelWidgets().isEmpty());
+}
+
// Testing get/set functions
void tst_QAction::getSetCheck()
{
@@ -104,46 +116,16 @@ class MyWidget : public QWidget
{
Q_OBJECT
public:
- MyWidget(tst_QAction *tst, QWidget *parent = 0) : QWidget(parent) { this->tst = tst; }
+ explicit MyWidget(tst_QAction *tst, QWidget *parent = nullptr) : QWidget(parent), m_test(tst)
+ { setWindowTitle(QTest::currentTestFunction()); }
protected:
- virtual void actionEvent(QActionEvent *e) { tst->updateState(e); }
+ void actionEvent(QActionEvent *e) override { m_test->updateState(e); }
private:
- tst_QAction *tst;
+ tst_QAction *m_test;
};
-tst_QAction::tst_QAction() : m_keyboardScheme(QPlatformTheme::WindowsKeyboardScheme)
-{
- if (const QPlatformTheme *theme = QGuiApplicationPrivate::platformTheme())
- m_keyboardScheme = theme->themeHint(QPlatformTheme::KeyboardScheme).toInt();
-}
-
-tst_QAction::~tst_QAction()
-{
-
-}
-
-void tst_QAction::initTestCase()
-{
- m_lastEventType = 0;
- m_lastAction = 0;
-
- MyWidget *mw = new MyWidget(this);
- m_tstWidget = mw;
- mw->show();
- qApp->setActiveWindow(mw);
-}
-
-void tst_QAction::cleanupTestCase()
-{
- QWidget *testWidget = m_tstWidget;
- if (testWidget) {
- testWidget->hide();
- delete testWidget;
- }
-}
-
void tst_QAction::setText_data()
{
QTest::addColumn<QString>("text");
@@ -208,7 +190,10 @@ void tst_QAction::actionEvent()
a.setText("action text");
// add action
- m_tstWidget->addAction(&a);
+ MyWidget testWidget(this);
+ testWidget.show();
+ QApplication::setActiveWindow(&testWidget);
+ testWidget.addAction(&a);
qApp->processEvents();
QCOMPARE(m_lastEventType, (int)QEvent::ActionAdded);
@@ -222,7 +207,7 @@ void tst_QAction::actionEvent()
QCOMPARE(m_lastAction, &a);
// remove action
- m_tstWidget->removeAction(&a);
+ testWidget.removeAction(&a);
qApp->processEvents();
QCOMPARE(m_lastEventType, (int)QEvent::ActionRemoved);
@@ -262,22 +247,24 @@ void tst_QAction::alternateShortcuts()
{
//test the alternate shortcuts (by adding more than 1 shortcut)
- QWidget *wid = m_tstWidget;
+ MyWidget testWidget(this);
+ testWidget.show();
+ QApplication::setActiveWindow(&testWidget);
{
- QAction act(wid);
- wid->addAction(&act);
+ QAction act(&testWidget);
+ testWidget.addAction(&act);
QList<QKeySequence> shlist = QList<QKeySequence>() << QKeySequence("CTRL+P") << QKeySequence("CTRL+A");
act.setShortcuts(shlist);
QSignalSpy spy(&act, SIGNAL(triggered()));
act.setAutoRepeat(true);
- QTest::keyClick(wid, Qt::Key_A, Qt::ControlModifier);
+ QTest::keyClick(&testWidget, Qt::Key_A, Qt::ControlModifier);
QCOMPARE(spy.count(), 1); //act should have been triggered
act.setAutoRepeat(false);
- QTest::keyClick(wid, Qt::Key_A, Qt::ControlModifier);
+ QTest::keyClick(&testWidget, Qt::Key_A, Qt::ControlModifier);
QCOMPARE(spy.count(), 2); //act should have been triggered a 2nd time
//end of the scope of the action, it will be destroyed and removed from wid
@@ -286,11 +273,15 @@ void tst_QAction::alternateShortcuts()
//this tests a crash (if the action did not unregister its alternate shortcuts)
- QTest::keyClick(wid, Qt::Key_A, Qt::ControlModifier);
+ QTest::keyClick(&testWidget, Qt::Key_A, Qt::ControlModifier);
}
void tst_QAction::enabledVisibleInteraction()
{
+ MyWidget testWidget(this);
+ testWidget.show();
+ QApplication::setActiveWindow(&testWidget);
+
QAction act(0);
// check defaults
QVERIFY(act.isEnabled());
@@ -305,20 +296,20 @@ void tst_QAction::enabledVisibleInteraction()
QVERIFY(act.isVisible());
// check if shortcut is disabled if not visible
- m_tstWidget->addAction(&act);
+ testWidget.addAction(&act);
act.setShortcut(QKeySequence("Ctrl+T"));
QSignalSpy spy(&act, SIGNAL(triggered()));
act.setEnabled(true);
act.setVisible(false);
- QTest::keyClick(m_tstWidget, Qt::Key_T, Qt::ControlModifier);
+ QTest::keyClick(&testWidget, Qt::Key_T, Qt::ControlModifier);
QCOMPARE(spy.count(), 0); //act is not visible, so don't trigger
act.setVisible(false);
act.setEnabled(true);
- QTest::keyClick(m_tstWidget, Qt::Key_T, Qt::ControlModifier);
+ QTest::keyClick(&testWidget, Qt::Key_T, Qt::ControlModifier);
QCOMPARE(spy.count(), 0); //act is not visible, so don't trigger
act.setVisible(true);
act.setEnabled(true);
- QTest::keyClick(m_tstWidget, Qt::Key_T, Qt::ControlModifier);
+ QTest::keyClick(&testWidget, Qt::Key_T, Qt::ControlModifier);
QCOMPARE(spy.count(), 1); //act is visible and enabled, so trigger
}
@@ -378,38 +369,42 @@ void tst_QAction::task229128TriggeredSignalWhenInActiongroup()
void tst_QAction::repeat()
{
- QWidget *wid = m_tstWidget;
- QAction act(wid);
- wid->addAction(&act);
+ MyWidget testWidget(this);
+ testWidget.show();
+ QApplication::setActiveWindow(&testWidget);
+ QVERIFY(QTest::qWaitForWindowActive(&testWidget));
+
+ QAction act(&testWidget);
+ testWidget.addAction(&act);
act.setShortcut(QKeySequence(Qt::Key_F));
QSignalSpy spy(&act, SIGNAL(triggered()));
act.setAutoRepeat(true);
- QTest::keyPress(wid, Qt::Key_F);
- QTest::keyRelease(wid, Qt::Key_F);
+ QTest::keyPress(&testWidget, Qt::Key_F);
+ QTest::keyRelease(&testWidget, Qt::Key_F);
QCOMPARE(spy.count(), 1);
spy.clear();
- QTest::keyPress(wid, Qt::Key_F);
+ QTest::keyPress(&testWidget, Qt::Key_F);
// repeat event
- QTest::simulateEvent(wid, true, Qt::Key_F, Qt::NoModifier, QString("f"), true);
- QTest::simulateEvent(wid, true, Qt::Key_F, Qt::NoModifier, QString("f"), true);
- QTest::keyRelease(wid, Qt::Key_F);
+ QTest::simulateEvent(&testWidget, true, Qt::Key_F, Qt::NoModifier, QString("f"), true);
+ QTest::simulateEvent(&testWidget, true, Qt::Key_F, Qt::NoModifier, QString("f"), true);
+ QTest::keyRelease(&testWidget, Qt::Key_F);
QCOMPARE(spy.count(), 3);
spy.clear();
act.setAutoRepeat(false);
- QTest::keyPress(wid, Qt::Key_F);
- QTest::simulateEvent(wid, true, Qt::Key_F, Qt::NoModifier, QString("f"), true);
- QTest::simulateEvent(wid, true, Qt::Key_F, Qt::NoModifier, QString("f"), true);
- QTest::keyRelease(wid, Qt::Key_F);
+ QTest::keyPress(&testWidget, Qt::Key_F);
+ QTest::simulateEvent(&testWidget, true, Qt::Key_F, Qt::NoModifier, QString("f"), true);
+ QTest::simulateEvent(&testWidget, true, Qt::Key_F, Qt::NoModifier, QString("f"), true);
+ QTest::keyRelease(&testWidget, Qt::Key_F);
QCOMPARE(spy.count(), 1);
spy.clear();
act.setAutoRepeat(true);
- QTest::keyPress(wid, Qt::Key_F);
- QTest::simulateEvent(wid, true, Qt::Key_F, Qt::NoModifier, QString("f"), true);
- QTest::keyRelease(wid, Qt::Key_F);
+ QTest::keyPress(&testWidget, Qt::Key_F);
+ QTest::simulateEvent(&testWidget, true, Qt::Key_F, Qt::NoModifier, QString("f"), true);
+ QTest::keyRelease(&testWidget, Qt::Key_F);
QCOMPARE(spy.count(), 2);
}
diff --git a/tests/auto/widgets/kernel/qapplication/test/test.pro b/tests/auto/widgets/kernel/qapplication/test/test.pro
index 908aa846c0..92409e4bfe 100644
--- a/tests/auto/widgets/kernel/qapplication/test/test.pro
+++ b/tests/auto/widgets/kernel/qapplication/test/test.pro
@@ -11,7 +11,7 @@ TESTDATA = ../test/test.pro ../tmp/README
!winrt {
SUBPROGRAMS = desktopsettingsaware modal
- win32:!wince: SUBPROGRAMS += wincmdline
+ win32:SUBPROGRAMS += wincmdline
for(file, SUBPROGRAMS): TEST_HELPER_INSTALLS += "../$${file}/$${file}"
}
diff --git a/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp b/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp
index 779773eff0..d6f3728663 100644
--- a/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp
+++ b/tests/auto/widgets/kernel/qapplication/tst_qapplication.cpp
@@ -52,15 +52,9 @@
#include <QtWidgets/private/qapplication_p.h>
#include <QtWidgets/QStyle>
-#ifdef Q_OS_WINCE
-#include <windows.h>
-#endif
-
#include <qpa/qwindowsysteminterface.h>
#include <private/qhighdpiscaling_p.h>
-#include "../../../qtest-config.h"
-
QT_BEGIN_NAMESPACE
static QWindowSystemInterface::TouchPoint touchPoint(const QTouchEvent::TouchPoint& pt)
{
@@ -235,10 +229,6 @@ static char *argv0;
tst_QApplication::tst_QApplication()
: quitApplicationTriggered(false)
{
-#ifdef Q_OS_WINCE
- // Clean up environment previously to launching test
- qputenv("QT_PLUGIN_PATH", QByteArray());
-#endif
}
void tst_QApplication::cleanup()
@@ -897,19 +887,8 @@ bool isPathListIncluded(const QStringList &l, const QStringList &r)
#define QT_TST_QAPP_DEBUG
void tst_QApplication::libraryPaths()
{
-#ifndef Q_OS_WINCE
const QString testDir = QFileInfo(QFINDTESTDATA("test/test.pro")).absolutePath();
QVERIFY(!testDir.isEmpty());
-#else // !Q_OS_WINCE
- // On Windows CE we need QApplication object to have valid
- // current Path. Therefore we need to identify it ourselves
- // here for the test.
- QFileInfo filePath;
- wchar_t module_name[MAX_PATH];
- GetModuleFileName(0, module_name, MAX_PATH);
- filePath = QString::fromWCharArray(module_name);
- const QString testDir = filePath.path() + "/test";
-#endif // Q_OS_WINCE
{
QApplication::setLibraryPaths(QStringList() << testDir);
QCOMPARE(QApplication::libraryPaths(), (QStringList() << testDir));
@@ -1000,11 +979,7 @@ void tst_QApplication::libraryPaths()
QString appDirPath = app.applicationDirPath();
app.addLibraryPath(appDirPath);
-#ifdef Q_OS_WINCE
- app.addLibraryPath(appDirPath + "/../..");
-#else
app.addLibraryPath(appDirPath + "/..");
-#endif
#ifdef QT_TST_QAPP_DEBUG
qDebug() << "appDirPath" << appDirPath;
qDebug() << "After adding appDirPath && appDirPath + /..:" << app.libraryPaths();
@@ -1044,15 +1019,9 @@ void tst_QApplication::libraryPaths_qt_plugin_path_2()
QByteArray nonExistentPath = "/nonexistent";
QByteArray pluginPath = validPath + ':' + nonExistentPath;
#elif defined(Q_OS_WIN)
-# ifdef Q_OS_WINCE
- QByteArray validPath = "/Temp";
- QByteArray nonExistentPath = "/nonexistent";
- QByteArray pluginPath = validPath + ';' + nonExistentPath;
-# else
QByteArray validPath = "C:\\windows";
QByteArray nonExistentPath = "Z:\\nonexistent";
QByteArray pluginPath = validPath + ';' + nonExistentPath;
-# endif
#endif
{
@@ -1069,9 +1038,7 @@ void tst_QApplication::libraryPaths_qt_plugin_path_2()
<< QLibraryInfo::location(QLibraryInfo::PluginsPath)
<< QDir(app.applicationDirPath()).canonicalPath()
<< QDir(QDir::fromNativeSeparators(QString::fromLatin1(validPath))).canonicalPath();
-# ifdef Q_OS_WINCE
- expected = QSet<QString>::fromList(expected).toList();
-# endif
+
QVERIFY2(isPathListIncluded(app.libraryPaths(), expected),
qPrintable("actual:\n - " + app.libraryPaths().join("\n - ") +
"\nexpected:\n - " + expected.join("\n - ")));
@@ -1091,9 +1058,6 @@ void tst_QApplication::libraryPaths_qt_plugin_path_2()
QStringList()
<< QLibraryInfo::location(QLibraryInfo::PluginsPath)
<< app.applicationDirPath();
-# ifdef Q_OS_WINCE
- expected = QSet<QString>::fromList(expected).toList();
-# endif
QVERIFY(isPathListIncluded(app.libraryPaths(), expected));
qputenv("QT_PLUGIN_PATH", QByteArray());
@@ -1479,10 +1443,6 @@ void tst_QApplication::desktopSettingsAware()
}
QVERIFY2(!path.isEmpty(), "Cannot locate desktopsettingsaware helper application");
path += "desktopsettingsaware";
-#ifdef Q_OS_WINCE
- int argc = 0;
- QApplication tmpApp(argc, 0);
-#endif
QProcess testProcess;
testProcess.start(path);
QVERIFY2(testProcess.waitForStarted(),
@@ -1955,9 +1915,7 @@ void tst_QApplication::touchEventPropagation()
release.setState(Qt::TouchPointReleased);
releasedTouchPoints << release;
- QTouchDevice *device = new QTouchDevice;
- device->setType(QTouchDevice::TouchScreen);
- QWindowSystemInterface::registerTouchDevice(device);
+ QTouchDevice *device = QTest::createTouchDevice();
{
// touch event behavior on a window
@@ -2312,7 +2270,7 @@ Q_GLOBAL_STATIC(QPixmap, tst_qapp_pixmap);
Q_GLOBAL_STATIC(QFont, tst_qapp_font);
Q_GLOBAL_STATIC(QRegion, tst_qapp_region);
Q_GLOBAL_STATIC(QFontDatabase, tst_qapp_fontDatabase);
-#ifndef QTEST_NO_CURSOR
+#ifndef QT_NO_CURSOR
Q_GLOBAL_STATIC(QCursor, tst_qapp_cursor);
#endif
@@ -2337,7 +2295,7 @@ void tst_QApplication::globalStaticObjectDestruction()
QVERIFY(tst_qapp_font());
QVERIFY(tst_qapp_region());
QVERIFY(tst_qapp_fontDatabase());
-#ifndef QTEST_NO_CURSOR
+#ifndef QT_NO_CURSOR
QVERIFY(tst_qapp_cursor());
#endif
}
diff --git a/tests/auto/widgets/kernel/qformlayout/tst_qformlayout.cpp b/tests/auto/widgets/kernel/qformlayout/tst_qformlayout.cpp
index 1a15432c1a..d8239b5a28 100644
--- a/tests/auto/widgets/kernel/qformlayout/tst_qformlayout.cpp
+++ b/tests/auto/widgets/kernel/qformlayout/tst_qformlayout.cpp
@@ -55,6 +55,44 @@ static inline void setFrameless(QWidget *w)
w->setWindowFlags(flags);
}
+struct QFormLayoutTakeRowResultHolder {
+ QFormLayoutTakeRowResultHolder(QFormLayout::TakeRowResult result) Q_DECL_NOTHROW
+ : labelItem(result.labelItem),
+ fieldItem(result.fieldItem)
+ {
+ }
+ ~QFormLayoutTakeRowResultHolder()
+ {
+ // re-use a QFormLayout to recursively reap the QLayoutItems:
+ QFormLayout disposer;
+ if (labelItem)
+ disposer.setItem(0, QFormLayout::LabelRole, labelItem);
+ if (fieldItem)
+ disposer.setItem(0, QFormLayout::FieldRole, fieldItem);
+ }
+ QFormLayoutTakeRowResultHolder(QFormLayoutTakeRowResultHolder &&other) Q_DECL_NOTHROW
+ : labelItem(other.labelItem),
+ fieldItem(other.fieldItem)
+ {
+ other.labelItem = nullptr;
+ other.fieldItem = nullptr;
+ }
+ QFormLayoutTakeRowResultHolder &operator=(QFormLayoutTakeRowResultHolder &&other) Q_DECL_NOTHROW
+ {
+ swap(other);
+ return *this;
+ }
+
+ void swap(QFormLayoutTakeRowResultHolder &other) Q_DECL_NOTHROW
+ {
+ qSwap(labelItem, other.labelItem);
+ qSwap(fieldItem, other.fieldItem);
+ }
+
+ QLayoutItem *labelItem;
+ QLayoutItem *fieldItem;
+};
+
class tst_QFormLayout : public QObject
{
Q_OBJECT
@@ -88,6 +126,12 @@ private slots:
void insertRow_QString_QLayout();
void insertRow_QWidget();
void insertRow_QLayout();
+ void removeRow();
+ void removeRow_QWidget();
+ void removeRow_QLayout();
+ void takeRow();
+ void takeRow_QWidget();
+ void takeRow_QLayout();
void setWidget();
void setLayout();
@@ -694,6 +738,237 @@ void tst_QFormLayout::insertRow_QLayout()
// ### come back to this later
}
+void tst_QFormLayout::removeRow()
+{
+ QWidget topLevel;
+ QFormLayout *layout = new QFormLayout(&topLevel);
+
+ QCOMPARE(layout->count(), 0);
+ QCOMPARE(layout->rowCount(), 0);
+
+ QPointer<QWidget> w1 = new QWidget;
+ QPointer<QWidget> w2 = new QWidget;
+
+ layout->addRow("test1", w1);
+ layout->addRow(w2);
+
+ QCOMPARE(layout->count(), 3);
+ QCOMPARE(layout->rowCount(), 2);
+
+ layout->removeRow(1);
+
+ QVERIFY(!w1);
+ QCOMPARE(layout->count(), 1);
+ QCOMPARE(layout->rowCount(), 1);
+
+ layout->removeRow(0);
+
+ QVERIFY(!w2);
+ QCOMPARE(layout->count(), 0);
+ QCOMPARE(layout->rowCount(), 0);
+}
+
+void tst_QFormLayout::removeRow_QWidget()
+{
+ QWidget topLevel;
+ QFormLayout *layout = new QFormLayout(&topLevel);
+
+ QCOMPARE(layout->count(), 0);
+ QCOMPARE(layout->rowCount(), 0);
+
+ QPointer<QWidget> w1 = new QWidget;
+ QPointer<QWidget> w2 = new QWidget;
+
+ layout->addRow("test1", w1);
+ layout->addRow(w2);
+
+ QCOMPARE(layout->count(), 3);
+ QCOMPARE(layout->rowCount(), 2);
+
+ layout->removeRow(w1);
+
+ QVERIFY(!w1);
+ QCOMPARE(layout->count(), 1);
+ QCOMPARE(layout->rowCount(), 1);
+
+ layout->removeRow(w2);
+
+ QVERIFY(!w2);
+ QCOMPARE(layout->count(), 0);
+ QCOMPARE(layout->rowCount(), 0);
+
+ QWidget *w3 = new QWidget;
+ layout->removeRow(w3);
+ delete w3;
+}
+
+void tst_QFormLayout::removeRow_QLayout()
+{
+ QWidget topLevel;
+ QFormLayout *layout = new QFormLayout(&topLevel);
+
+ QCOMPARE(layout->count(), 0);
+ QCOMPARE(layout->rowCount(), 0);
+
+ QPointer<QHBoxLayout> l1 = new QHBoxLayout;
+ QPointer<QWidget> w1 = new QWidget;
+ l1->addWidget(w1);
+ QPointer<QHBoxLayout> l2 = new QHBoxLayout;
+ QPointer<QWidget> w2 = new QWidget;
+ l2->addWidget(w2);
+
+ layout->addRow("test1", l1);
+ layout->addRow(l2);
+
+ QCOMPARE(layout->count(), 3);
+ QCOMPARE(layout->rowCount(), 2);
+
+ layout->removeRow(l1);
+
+ QVERIFY(!l1);
+ QVERIFY(!w1);
+ QCOMPARE(layout->count(), 1);
+ QCOMPARE(layout->rowCount(), 1);
+
+ layout->removeRow(l2);
+
+ QVERIFY(!l2);
+ QVERIFY(!w2);
+ QCOMPARE(layout->count(), 0);
+ QCOMPARE(layout->rowCount(), 0);
+
+ QHBoxLayout *l3 = new QHBoxLayout;
+ layout->removeRow(l3);
+ delete l3;
+}
+
+void tst_QFormLayout::takeRow()
+{
+ QWidget topLevel;
+ QFormLayout *layout = new QFormLayout(&topLevel);
+
+ QCOMPARE(layout->count(), 0);
+ QCOMPARE(layout->rowCount(), 0);
+
+ QPointer<QWidget> w1 = new QWidget;
+ QPointer<QWidget> w2 = new QWidget;
+
+ layout->addRow("test1", w1);
+ layout->addRow(w2);
+
+ QCOMPARE(layout->count(), 3);
+ QCOMPARE(layout->rowCount(), 2);
+
+ QFormLayoutTakeRowResultHolder result = layout->takeRow(1);
+
+ QVERIFY(w2);
+ QVERIFY(result.fieldItem);
+ QVERIFY(result.labelItem);
+ QCOMPARE(layout->count(), 1);
+ QCOMPARE(layout->rowCount(), 1);
+
+ result = layout->takeRow(0);
+
+ QVERIFY(w1);
+ QVERIFY(result.fieldItem);
+ QVERIFY(!result.labelItem);
+ QCOMPARE(layout->count(), 0);
+ QCOMPARE(layout->rowCount(), 0);
+
+ result = layout->takeRow(0);
+
+ QVERIFY(!result.fieldItem);
+ QVERIFY(!result.labelItem);
+}
+
+void tst_QFormLayout::takeRow_QWidget()
+{
+ QWidget topLevel;
+ QFormLayout *layout = new QFormLayout(&topLevel);
+
+ QCOMPARE(layout->count(), 0);
+ QCOMPARE(layout->rowCount(), 0);
+
+ QPointer<QWidget> w1 = new QWidget;
+ QPointer<QWidget> w2 = new QWidget;
+
+ layout->addRow("test1", w1);
+ layout->addRow(w2);
+
+ QCOMPARE(layout->count(), 3);
+ QCOMPARE(layout->rowCount(), 2);
+
+ QFormLayoutTakeRowResultHolder result = layout->takeRow(w1);
+
+ QVERIFY(w1);
+ QVERIFY(result.fieldItem);
+ QVERIFY(result.labelItem);
+ QCOMPARE(layout->count(), 1);
+ QCOMPARE(layout->rowCount(), 1);
+
+ result = layout->takeRow(w2);
+
+ QVERIFY(w2);
+ QVERIFY(result.fieldItem);
+ QVERIFY(!result.labelItem);
+ QCOMPARE(layout->count(), 0);
+ QCOMPARE(layout->rowCount(), 0);
+
+ QWidget *w3 = new QWidget;
+ result = layout->takeRow(w3);
+ delete w3;
+
+ QVERIFY(!result.fieldItem);
+ QVERIFY(!result.labelItem);
+}
+
+void tst_QFormLayout::takeRow_QLayout()
+{
+ QWidget topLevel;
+ QFormLayout *layout = new QFormLayout(&topLevel);
+
+ QCOMPARE(layout->count(), 0);
+ QCOMPARE(layout->rowCount(), 0);
+
+ QPointer<QHBoxLayout> l1 = new QHBoxLayout;
+ QPointer<QWidget> w1 = new QWidget;
+ l1->addWidget(w1);
+ QPointer<QHBoxLayout> l2 = new QHBoxLayout;
+ QPointer<QWidget> w2 = new QWidget;
+ l2->addWidget(w2);
+
+ layout->addRow("test1", l1);
+ layout->addRow(l2);
+
+ QCOMPARE(layout->count(), 3);
+ QCOMPARE(layout->rowCount(), 2);
+
+ QFormLayoutTakeRowResultHolder result = layout->takeRow(l1);
+
+ QVERIFY(l1);
+ QVERIFY(w1);
+ QVERIFY(result.fieldItem);
+ QVERIFY(result.labelItem);
+ QCOMPARE(layout->count(), 1);
+ QCOMPARE(layout->rowCount(), 1);
+
+ result = layout->takeRow(l2);
+
+ QVERIFY(l2);
+ QVERIFY(w2);
+ QVERIFY(result.fieldItem);
+ QVERIFY(!result.labelItem);
+ QCOMPARE(layout->count(), 0);
+ QCOMPARE(layout->rowCount(), 0);
+
+ QHBoxLayout *l3 = new QHBoxLayout;
+ result = layout->takeRow(l3);
+ delete l3;
+
+ QVERIFY(!result.fieldItem);
+ QVERIFY(!result.labelItem);
+}
+
void tst_QFormLayout::setWidget()
{
QFormLayout layout;
diff --git a/tests/auto/widgets/kernel/qgridlayout/tst_qgridlayout.cpp b/tests/auto/widgets/kernel/qgridlayout/tst_qgridlayout.cpp
index e5da83ed37..c1ab5f51be 100644
--- a/tests/auto/widgets/kernel/qgridlayout/tst_qgridlayout.cpp
+++ b/tests/auto/widgets/kernel/qgridlayout/tst_qgridlayout.cpp
@@ -56,7 +56,6 @@ class tst_QGridLayout : public QObject
Q_OBJECT
private slots:
- void initTestCase();
void cleanup();
void getItemPosition();
void itemAtPosition();
@@ -81,17 +80,11 @@ private slots:
void taskQTBUG_27420_takeAtShouldUnparentLayout();
void taskQTBUG_40609_addingWidgetToItsOwnLayout();
void taskQTBUG_40609_addingLayoutToItself();
+ void taskQTBUG_52357_spacingWhenItemIsHidden();
void replaceWidget();
void dontCrashWhenExtendsToEnd();
};
-void tst_QGridLayout::initTestCase()
-{
-#ifdef Q_OS_WINCE //disable magic for WindowsCE
- qApp->setAutoMaximizeThreshold(-1);
-#endif
-}
-
static inline int visibleTopLevelWidgetCount()
{
int result= 0;
@@ -605,19 +598,6 @@ void tst_QGridLayout::spacingsAndMargins_data()
<< QPoint( 20, child_offset_y)
<< QPoint( 20, child_offset_y + 100 + 6)
);
-#if defined (Q_OS_WINCE) //There is not enough screenspace to run the test in original size on Windows CE. We use smaller widgets.
- child_offset_y = 11 + 9 + 50 + 6 + 50 + 6 + 50 + 6;
- QTest::newRow("1x3 grid") << 1 << 3 << QSize(50, 50)
- << (PointList() // toplevel
- << QPoint( 11, 11)
- << QPoint( 11, 11 + 50 + 6)
- << QPoint( 11, 11 + 50 + 6 + 50 + 6)
- // children
- << QPoint( 20, child_offset_y)
- << QPoint( 20, child_offset_y + 50 + 6)
- << QPoint( 20, child_offset_y + 50 + 6 + 50 + 6)
- );
-#else
child_offset_y = 11 + 9 + 100 + 6 + 100 + 6 + 100 + 6;
QTest::newRow("1x3 grid") << 1 << 3 << QSize(100, 100)
<< (PointList() // toplevel
@@ -629,7 +609,6 @@ void tst_QGridLayout::spacingsAndMargins_data()
<< QPoint( 20, child_offset_y + 100 + 6)
<< QPoint( 20, child_offset_y + 100 + 6 + 100 + 6)
);
-#endif
child_offset_y = 11 + 9 + 100 + 6 + 100 + 6;
QTest::newRow("2x2 grid") << 2 << 2 << QSize(100, 100)
@@ -1674,6 +1653,26 @@ void tst_QGridLayout::taskQTBUG_40609_addingLayoutToItself(){
QCOMPARE(layout.count(), 0);
}
+void tst_QGridLayout::taskQTBUG_52357_spacingWhenItemIsHidden()
+{
+ QWidget widget;
+ setFrameless(&widget);
+ QGridLayout layout(&widget);
+ layout.setMargin(0);
+ layout.setSpacing(5);
+ QPushButton button1;
+ layout.addWidget(&button1, 0, 0);
+ QPushButton button2;
+ layout.addWidget(&button2, 0, 1);
+ QPushButton button3;
+ layout.addWidget(&button3, 0, 2);
+ widget.show();
+ QVERIFY(QTest::qWaitForWindowExposed(&widget));
+ int tempWidth = button1.width() + button2.width() + button3.width() + 2 * layout.spacing();
+ button2.hide();
+ QTRY_COMPARE_WITH_TIMEOUT(tempWidth, button1.width() + button3.width() + layout.spacing(), 1000);
+}
+
void tst_QGridLayout::replaceWidget()
{
QWidget wdg;
diff --git a/tests/auto/widgets/kernel/qlayout/qlayout.pro b/tests/auto/widgets/kernel/qlayout/qlayout.pro
index 2213767950..d460785158 100644
--- a/tests/auto/widgets/kernel/qlayout/qlayout.pro
+++ b/tests/auto/widgets/kernel/qlayout/qlayout.pro
@@ -4,13 +4,7 @@ TARGET = tst_qlayout
QT += widgets widgets-private testlib
SOURCES += tst_qlayout.cpp
-wince* {
- addFiles.files = baseline
- addFiles.path = .
- DEPLOYMENT += addFiles
-} else {
- TESTDATA += baseline/*
-}
+TESTDATA += baseline/*
android {
RESOURCES += \
diff --git a/tests/auto/widgets/kernel/qwidget/BLACKLIST b/tests/auto/widgets/kernel/qwidget/BLACKLIST
index 98a4caf49e..6fe6bd2f67 100644
--- a/tests/auto/widgets/kernel/qwidget/BLACKLIST
+++ b/tests/auto/widgets/kernel/qwidget/BLACKLIST
@@ -3,6 +3,7 @@
ubuntu-14.04
[saveRestoreGeometry]
ubuntu-14.04
+ubuntu-16.04
[restoreVersion1Geometry]
ubuntu-14.04
osx
@@ -53,6 +54,7 @@ osx
osx
[maskedUpdate]
osx
+opensuse-42.1
[hideWhenFocusWidgetIsChild]
osx-10.10
[hideOpaqueChildWhileHidden]
diff --git a/tests/auto/widgets/kernel/qwidget/qwidget.pro b/tests/auto/widgets/kernel/qwidget/qwidget.pro
index a3fd622896..499ca65516 100644
--- a/tests/auto/widgets/kernel/qwidget/qwidget.pro
+++ b/tests/auto/widgets/kernel/qwidget/qwidget.pro
@@ -16,8 +16,4 @@ mac {
OBJECTIVE_SOURCES += tst_qwidget_mac_helpers.mm
}
-x11 {
- LIBS += $$QMAKE_LIBS_X11
-}
-
-win32:!wince:!winrt: LIBS += -luser32 -lgdi32
+win32:!winrt: LIBS += -luser32 -lgdi32
diff --git a/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp b/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp
index 5a00b0dad9..0c25a01ba0 100644
--- a/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp
+++ b/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp
@@ -67,15 +67,13 @@
#include <QtGui/qwindow.h>
#include <qtimer.h>
-#include "../../../qtest-config.h"
-
#if defined(Q_OS_OSX)
#include "tst_qwidget_mac_helpers.h" // Abstract the ObjC stuff out so not everyone must run an ObjC++ compile.
#endif
#include <QtTest/QTest>
-#ifdef Q_OS_WIN
+#if defined(Q_OS_WIN) && !defined(Q_OS_WINRT)
# include <QtCore/qt_windows.h>
# include <QtGui/private/qguiapplication_p.h>
#include <qpa/qplatformnativeinterface.h>
@@ -91,49 +89,12 @@ static HWND winHandleOf(const QWidget *w)
return 0;
}
-# ifdef Q_OS_WINCE
-# define Q_CHECK_PAINTEVENTS
-# ifdef Q_OS_WINCE_WM
-# include <qguifunctions_wince.h>
-// taken from qguifunctions_wce.cpp
-# define SPI_GETPLATFORMTYPE 257
-static bool qt_wince_is_platform(const QString &platformString) {
- wchar_t tszPlatform[64];
- if (SystemParametersInfo(SPI_GETPLATFORMTYPE,
- sizeof(tszPlatform)/sizeof(*tszPlatform),tszPlatform,0))
- if (0 == _tcsicmp(reinterpret_cast<const wchar_t *> (platformString.utf16()), tszPlatform))
- return true;
- return false;
-}
-static inline bool qt_wince_is_smartphone() { return qt_wince_is_platform(QString::fromLatin1("Smartphone")); }
-# endif // Q_OS_WINCE_WM
-# elif !defined(Q_OS_WINRT) // Q_OS_WINCE
-# define Q_CHECK_PAINTEVENTS \
+# define Q_CHECK_PAINTEVENTS \
if (::SwitchDesktop(::GetThreadDesktop(::GetCurrentThreadId())) == 0) \
QSKIP("desktop is not visible, this test would fail");
-# else // !Q_OS_WINCE && !Q_OS_WINRT
-# define Q_CHECK_PAINTEVENTS
-# endif // Q_OS_WINRT
-#else // Q_OS_WIN
+
+#else // Q_OS_WIN && !Q_OS_WINRT
# define Q_CHECK_PAINTEVENTS
-#endif // else Q_OS_WIN
-
-
-#if defined(Q_OS_WINCE_WM)
-#include <qguifunctions_wince.h>
-// taken from qguifunctions_wce.cpp
-#define SPI_GETPLATFORMTYPE 257
-bool qt_wince_is_platform(const QString &platformString) {
- wchar_t tszPlatform[64];
- if (SystemParametersInfo(SPI_GETPLATFORMTYPE,
- sizeof(tszPlatform)/sizeof(*tszPlatform),tszPlatform,0))
- if (0 == _tcsicmp(reinterpret_cast<const wchar_t *> (platformString.utf16()), tszPlatform))
- return true;
- return false;
-}
-bool qt_wince_is_smartphone() {
- return qt_wince_is_platform(QString::fromLatin1("Smartphone"));
-}
#endif
#ifdef Q_OS_OSX
@@ -163,7 +124,7 @@ static inline void centerOnScreen(QWidget *w)
w->move(QGuiApplication::primaryScreen()->availableGeometry().center() - offset);
}
-#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) && !defined(Q_OS_WINRT)
+#if defined(Q_OS_WIN) && !defined(Q_OS_WINRT)
static inline void setWindowsAnimationsEnabled(bool enabled)
{
ANIMATIONINFO animation = { sizeof(ANIMATIONINFO), enabled };
@@ -176,10 +137,10 @@ static inline bool windowsAnimationsEnabled()
SystemParametersInfo(SPI_GETANIMATION, 0, &animation, 0);
return animation.iMinAnimate;
}
-#else // Q_OS_WIN && !Q_OS_WINCE && !Q_OS_WINRT
+#else // Q_OS_WIN && !Q_OS_WINRT
inline void setWindowsAnimationsEnabled(bool) {}
static inline bool windowsAnimationsEnabled() { return false; }
-#endif // !Q_OS_WIN || Q_OS_WINCE || Q_OS_WINRT
+#endif // !Q_OS_WIN || Q_OS_WINRT
template <class T>
static QByteArray msgComparisonFailed(T v1, const char *op, T v2)
@@ -212,8 +173,6 @@ public:
public slots:
void initTestCase();
- void cleanupTestCase();
- void init();
void cleanup();
private slots:
void getSetCheck();
@@ -251,9 +210,7 @@ private slots:
void hideWhenFocusWidgetIsChild();
void normalGeometry();
void setGeometry();
-#ifndef Q_OS_WINCE
void windowOpacity();
-#endif
void raise();
void lower();
void stackUnder();
@@ -315,7 +272,7 @@ private slots:
void subtractOpaqueSiblings();
-#if defined (Q_OS_WIN) && !defined(Q_OS_WINCE) && !defined(Q_OS_WINRT)
+#if defined (Q_OS_WIN) && !defined(Q_OS_WINRT)
void setGeometry_win();
#endif
@@ -323,7 +280,7 @@ private slots:
void deleteStyle();
void multipleToplevelFocusCheck();
void setFocus();
-#ifndef QTEST_NO_CURSOR
+#ifndef QT_NO_CURSOR
void setCursor();
#endif
void setToolTip();
@@ -340,9 +297,7 @@ private slots:
void render_task188133();
void render_task211796();
void render_task217815();
-#ifndef Q_OS_WINCE
void render_windowOpacity();
-#endif
void render_systemClip();
void render_systemClip2_data();
void render_systemClip2();
@@ -358,9 +313,7 @@ private slots:
void repaintWhenChildDeleted();
void hideOpaqueChildWhileHidden();
-#if !defined(Q_OS_WINCE)
void updateWhileMinimized();
-#endif
void alienWidgets();
void adjustSize();
void adjustSize_data();
@@ -395,7 +348,7 @@ private slots:
void setClearAndResizeMask();
void maskedUpdate();
-#ifndef QTEST_NO_CURSOR
+#ifndef QT_NO_CURSOR
void syntheticEnterLeave();
void taskQTBUG_4055_sendSyntheticEnterLeave();
void underMouse();
@@ -407,9 +360,7 @@ private slots:
void toplevelLineEditFocus();
void focusWidget_task254563();
-#ifndef Q_OS_WINCE_WM
void rectOutsideCoordinatesLimit_task144779();
-#endif
void setGraphicsEffect();
#ifdef QT_BUILD_INTERNAL
@@ -458,13 +409,13 @@ private slots:
private:
bool ensureScreenSize(int width, int height);
- QWidget *testWidget;
const QString m_platform;
QSize m_testWidgetSize;
QPoint m_availableTopLeft;
QPoint m_safeCursorPos;
const bool m_windowsAnimationsEnabled;
+ QTouchDevice *m_touchScreen;
};
bool tst_QWidget::ensureScreenSize(int width, int height)
@@ -612,7 +563,7 @@ void tst_QWidget::getSetCheck()
QCOMPARE(true, obj1.autoFillBackground());
var1.reset();
-#if defined (Q_OS_WIN) && !defined(Q_OS_WINCE) && !defined(Q_OS_WINRT)
+#if defined (Q_OS_WIN) && !defined(Q_OS_WINRT)
obj1.setWindowFlags(Qt::FramelessWindowHint | Qt::WindowSystemMenuHint);
const HWND handle = reinterpret_cast<HWND>(obj1.winId()); // explicitly create window handle
QVERIFY(GetWindowLong(handle, GWL_STYLE) & WS_POPUP);
@@ -623,6 +574,7 @@ tst_QWidget::tst_QWidget()
: m_platform(QGuiApplication::platformName().toLower())
, m_safeCursorPos(0, 0)
, m_windowsAnimationsEnabled(windowsAnimationsEnabled())
+ , m_touchScreen(QTest::createTouchDevice())
{
if (m_windowsAnimationsEnabled) // Disable animations which can interfere with screen grabbing in moveChild(), showAndMoveChild()
setWindowsAnimationsEnabled(false);
@@ -635,8 +587,6 @@ tst_QWidget::tst_QWidget()
palette.setColor(QPalette::ToolTipBase, QColor(12, 13, 14));
palette.setColor(QPalette::Text, QColor(21, 22, 23));
qApp->setPalette(palette, "QPropagationTestWidget");
-
- testWidget = 0;
}
tst_QWidget::~tst_QWidget()
@@ -657,9 +607,6 @@ private:
void tst_QWidget::initTestCase()
{
-#ifdef Q_OS_WINCE //disable magic for WindowsCE
- qApp->setAutoMaximizeThreshold(-1);
-#endif
// Size of reference widget, 200 for < 2000, scale up for larger screens
// to avoid Windows warnings about minimum size for decorated windows.
int width = 200;
@@ -675,122 +622,23 @@ void tst_QWidget::initTestCase()
if (screenWidth > 2000)
width = 100 * ((screenWidth + 500) / 1000);
m_testWidgetSize = QSize(width, width);
- // Create the test class
- testWidget = new BezierViewer;
- testWidget->setWindowTitle(QStringLiteral("BezierViewer"));
- testWidget->move(m_availableTopLeft + QPoint(screenWidth / 3, 50));
- testWidget->resize(m_testWidgetSize);
- testWidget->show();
- QVERIFY(QTest::qWaitForWindowExposed(testWidget));
-}
-
-void tst_QWidget::cleanupTestCase()
-{
- delete testWidget;
- testWidget = 0;
-}
-
-void tst_QWidget::init()
-{
-// TODO: Add initialization code here.
-// This will be executed immediately before each test is run.
- testWidget->setFont(QFont());
- testWidget->setPalette(QPalette());
}
void tst_QWidget::cleanup()
{
- // Only 'testwidget', do not leak any other widgets.
- QCOMPARE(QApplication::topLevelWidgets().size(), 1);
-}
-
-// Helper class...
-
-BezierViewer::BezierViewer( QWidget* parent)
- : QWidget(parent)
-{
- setObjectName(QLatin1String("TestWidget"));
- setWindowTitle(objectName());
- QPalette pal;
- pal.setColor(backgroundRole(), Qt::white);
- setPalette(pal);
-}
-
-
-void BezierViewer::setPoints( const QPolygonF& a )
-{
- points = a;
-}
-
-#include "private/qbezier_p.h"
-void BezierViewer::paintEvent( QPaintEvent* )
-{
- if ( points.size() != 4 ) {
-#if defined(QT_CHECK_RANGE)
- qWarning( "QPolygon::bezier: The array must have 4 control points" );
-#endif
- return;
- }
-
- /* Calculate Bezier curve */
- QPolygonF bezier = QBezier::fromPoints(points.at(0),points.at(1),points.at(2),points.at(3)).toPolygon();
-
- QPainter painter( this );
-
- /* Calculate scale to fit in window */
- QRectF br = bezier.boundingRect() | points.boundingRect();
- QRectF pr = rect();
- int scl = qMax( qMin(pr.width()/br.width(), pr.height()/br.height()), qreal(1.) );
- int border = scl-1;
-
- /* Scale Bezier curve vertices */
- for ( QPolygonF::Iterator it = bezier.begin(); it != bezier.end(); ++it ) {
- it->setX( (it->x()-br.x()) * scl + border );
- it->setY( (it->y()-br.y()) * scl + border );
- }
-
- /* Draw grid */
- painter.setPen( Qt::lightGray );
- int i;
- for ( i = border; i <= pr.width(); i += scl ) {
- painter.drawLine( i, 0, i, pr.height() );
- }
- for ( int j = border; j <= pr.height(); j += scl ) {
- painter.drawLine( 0, j, pr.width(), j );
- }
-
- /* Write number of vertices */
- painter.setPen( Qt::red );
- painter.setFont( QFont("Helvetica", 14, QFont::DemiBold, true ) );
- QString caption;
- caption.setNum( bezier.size() );
- caption += QString::fromLatin1( " vertices" );
- painter.drawText( 10, pr.height()-10, caption );
-
- /* Draw Bezier curve */
- painter.setPen( Qt::black );
- painter.drawPolyline( bezier );
-
- /* Scale and draw control points */
- painter.setPen( Qt::darkGreen );
- for ( QPolygonF::Iterator p1 = points.begin(); p1 != points.end(); ++p1 ) {
- int x = (p1->x()-br.x()) * scl + border;
- int y = (p1->y()-br.y()) * scl + border;
- painter.drawLine( x-4, y-4, x+4, y+4 );
- painter.drawLine( x+4, y-4, x-4, y+4 );
- }
-
- /* Draw vertices */
- painter.setPen( Qt::red );
- painter.setBrush( Qt::red );
- for ( QPolygonF::Iterator p2 = bezier.begin(); p2 != bezier.end(); ++p2 )
- painter.drawEllipse( p2->x()-1, p2->y()-1, 3, 3 );
+ QVERIFY(QApplication::topLevelWidgets().isEmpty());
}
void tst_QWidget::fontPropagation()
{
+ QScopedPointer<QWidget> testWidget(new QWidget);
+ testWidget->resize(m_testWidgetSize);
+ testWidget->setWindowTitle(__FUNCTION__);
+ centerOnScreen(testWidget.data());
+ testWidget->show();
+ QVERIFY(QTest::qWaitForWindowExposed(testWidget.data()));
QFont font = testWidget->font();
- QWidget* childWidget = new QWidget( testWidget );
+ QWidget* childWidget = new QWidget( testWidget.data() );
childWidget->show();
QCOMPARE( font, childWidget->font() );
@@ -821,7 +669,7 @@ void tst_QWidget::fontPropagation()
font.setPointSize(font.pointSize() + 2);
testWidget->setFont(font);
- QWidget *one = new QWidget(testWidget);
+ QWidget *one = new QWidget(testWidget.data());
QWidget *two = new QWidget(one);
QWidget *three = new QWidget(two);
QWidget *four = new QWidget(two);
@@ -977,8 +825,15 @@ void tst_QWidget::fontPropagation2()
void tst_QWidget::palettePropagation()
{
+ QScopedPointer<QWidget> testWidget(new QWidget);
+ testWidget->resize(m_testWidgetSize);
+ testWidget->setWindowTitle(__FUNCTION__);
+ centerOnScreen(testWidget.data());
+ testWidget->show();
+ QVERIFY(QTest::qWaitForWindowExposed(testWidget.data()));
+
QPalette palette = testWidget->palette();
- QWidget* childWidget = new QWidget( testWidget );
+ QWidget* childWidget = new QWidget( testWidget.data() );
childWidget->show();
QCOMPARE( palette, childWidget->palette() );
@@ -1111,7 +966,13 @@ void tst_QWidget::palettePropagation2()
void tst_QWidget::enabledPropagation()
{
- QWidget* childWidget = new QWidget( testWidget );
+ QScopedPointer<QWidget> testWidget(new QWidget);
+ testWidget->resize(m_testWidgetSize);
+ testWidget->setWindowTitle(__FUNCTION__);
+ centerOnScreen(testWidget.data());
+ testWidget->show();
+ QVERIFY(QTest::qWaitForWindowExposed(testWidget.data()));
+ QWidget* childWidget = new QWidget( testWidget.data() );
childWidget->show();
QVERIFY( testWidget->isEnabled() );
QVERIFY( childWidget->isEnabled() );
@@ -1194,7 +1055,13 @@ void tst_QWidget::properTabHandlingWhenDisabled_QTBUG27417()
#ifndef QT_NO_DRAGANDDROP
void tst_QWidget::acceptDropsPropagation()
{
- QWidget *childWidget = new QWidget(testWidget);
+ QScopedPointer<QWidget> testWidget(new QWidget);
+ testWidget->resize(m_testWidgetSize);
+ testWidget->setWindowTitle(__FUNCTION__);
+ centerOnScreen(testWidget.data());
+ testWidget->show();
+ QVERIFY(QTest::qWaitForWindowExposed(testWidget.data()));
+ QWidget *childWidget = new QWidget(testWidget.data());
childWidget->show();
QVERIFY(!testWidget->acceptDrops());
QVERIFY(!childWidget->acceptDrops());
@@ -1241,32 +1108,38 @@ void tst_QWidget::acceptDropsPropagation()
void tst_QWidget::isEnabledTo()
{
- QWidget* childWidget = new QWidget( testWidget );
+ QWidget testWidget;
+ testWidget.resize(m_testWidgetSize);
+ testWidget.setWindowTitle(__FUNCTION__);
+ centerOnScreen(&testWidget);
+ testWidget.show();
+ QWidget* childWidget = new QWidget( &testWidget );
QWidget* grandChildWidget = new QWidget( childWidget );
- QVERIFY( childWidget->isEnabledTo( testWidget ) );
- QVERIFY( grandChildWidget->isEnabledTo( testWidget ) );
+ QVERIFY( childWidget->isEnabledTo( &testWidget ) );
+ QVERIFY( grandChildWidget->isEnabledTo( &testWidget ) );
childWidget->setEnabled( false );
- QVERIFY( !childWidget->isEnabledTo( testWidget ) );
+ QVERIFY( !childWidget->isEnabledTo( &testWidget ) );
QVERIFY( grandChildWidget->isEnabledTo( childWidget ) );
- QVERIFY( !grandChildWidget->isEnabledTo( testWidget ) );
+ QVERIFY( !grandChildWidget->isEnabledTo( &testWidget ) );
- QScopedPointer<QMainWindow> childDialog(new QMainWindow(testWidget));
- testWidget->setEnabled(false);
+ QScopedPointer<QMainWindow> childDialog(new QMainWindow(&testWidget));
+ testWidget.setEnabled(false);
QVERIFY(!childDialog->isEnabled());
QVERIFY(childDialog->isEnabledTo(0));
- testWidget->setEnabled(true);
}
void tst_QWidget::visible()
{
// Ensure that the testWidget is hidden for this test at the
// start
-
- testWidget->hide();
+ QScopedPointer<QWidget> testWidget(new QWidget);
+ testWidget->resize(m_testWidgetSize);
+ testWidget->setWindowTitle(__FUNCTION__);
+ centerOnScreen(testWidget.data());
QVERIFY( !testWidget->isVisible() );
- QWidget* childWidget = new QWidget( testWidget );
+ QWidget* childWidget = new QWidget( testWidget.data() );
QVERIFY( !childWidget->isVisible() );
testWidget->show();
@@ -1332,11 +1205,16 @@ void tst_QWidget::setLocale()
void tst_QWidget::visible_setWindowOpacity()
{
- testWidget->hide();
+ QScopedPointer<QWidget> testWidget(new QWidget);
+ testWidget->resize(m_testWidgetSize);
+ testWidget->setWindowTitle(__FUNCTION__);
+ centerOnScreen(testWidget.data());
+ testWidget->winId();
+
QVERIFY( !testWidget->isVisible() );
testWidget->setWindowOpacity(0.5);
#if defined(Q_OS_WIN) && !defined(Q_OS_WINRT)
- QVERIFY(!::IsWindowVisible(winHandleOf(testWidget)));
+ QVERIFY(!::IsWindowVisible(winHandleOf(testWidget.data())));
#endif
testWidget->setWindowOpacity(1.0);
}
@@ -1345,35 +1223,40 @@ void tst_QWidget::isVisibleTo()
{
// Ensure that the testWidget is hidden for this test at the
// start
+ QWidget testWidget;
+ testWidget.resize(m_testWidgetSize);
+ testWidget.setWindowTitle(__FUNCTION__);
+ centerOnScreen(&testWidget);
- testWidget->hide();
- QWidget* childWidget = new QWidget( testWidget );
- QVERIFY( childWidget->isVisibleTo( testWidget ) );
+ QWidget* childWidget = new QWidget( &testWidget );
+ QVERIFY( childWidget->isVisibleTo( &testWidget ) );
childWidget->hide();
- QVERIFY( !childWidget->isVisibleTo( testWidget ) );
+ QVERIFY( !childWidget->isVisibleTo( &testWidget ) );
QWidget* grandChildWidget = new QWidget( childWidget );
- QVERIFY( !grandChildWidget->isVisibleTo( testWidget ) );
+ QVERIFY( !grandChildWidget->isVisibleTo( &testWidget ) );
QVERIFY( grandChildWidget->isVisibleTo( childWidget ) );
- testWidget->show();
+ testWidget.show();
childWidget->show();
- QVERIFY( childWidget->isVisibleTo( testWidget ) );
+ QVERIFY( childWidget->isVisibleTo( &testWidget ) );
grandChildWidget->hide();
QVERIFY( !grandChildWidget->isVisibleTo( childWidget ) );
- QVERIFY( !grandChildWidget->isVisibleTo( testWidget ) );
-
+ QVERIFY( !grandChildWidget->isVisibleTo( &testWidget ) );
}
void tst_QWidget::isHidden()
{
// Ensure that the testWidget is hidden for this test at the
// start
+ QScopedPointer<QWidget> testWidget(new QWidget);
+ testWidget->resize(m_testWidgetSize);
+ testWidget->setWindowTitle(__FUNCTION__);
+ centerOnScreen(testWidget.data());
- testWidget->hide();
QVERIFY( testWidget->isHidden() );
- QWidget* childWidget = new QWidget( testWidget );
+ QWidget* childWidget = new QWidget( testWidget.data() );
QVERIFY( !childWidget->isHidden() );
testWidget->show();
@@ -1406,8 +1289,15 @@ void tst_QWidget::isHidden()
void tst_QWidget::fonts()
{
+ QWidget testWidget;
+ testWidget.resize(m_testWidgetSize);
+ testWidget.setWindowTitle(__FUNCTION__);
+ centerOnScreen(&testWidget);
+ testWidget.show();
+ QVERIFY(QTest::qWaitForWindowExposed(&testWidget));
+
// Tests setFont(), ownFont() and unsetFont()
- QWidget* cleanTestWidget = new QWidget( testWidget );
+ QWidget* cleanTestWidget = new QWidget( &testWidget );
QFont originalFont = cleanTestWidget->font();
QVERIFY( !cleanTestWidget->testAttribute(Qt::WA_SetFont) );
@@ -1416,7 +1306,7 @@ void tst_QWidget::fonts()
QFont newFont( "times", 18 );
cleanTestWidget->setFont( newFont );
- newFont = newFont.resolve( testWidget->font() );
+ newFont = newFont.resolve( testWidget.font() );
QVERIFY( cleanTestWidget->testAttribute(Qt::WA_SetFont) );
QVERIFY2( cleanTestWidget->font() == newFont,
@@ -1513,7 +1403,7 @@ void tst_QWidget::mapFromAndTo()
subWindow2->setGeometry(75, 75, 100, 100);
subSubWindow->setGeometry(10, 10, 10, 10);
-#if !defined(Q_OS_WINCE) && !defined(Q_OS_QNX)
+#if !defined(Q_OS_QNX)
//update visibility
if (windowMinimized) {
if (!windowHidden) {
@@ -1693,7 +1583,6 @@ void tst_QWidget::focusChainOnReparent()
void tst_QWidget::focusChainOnHide()
{
- testWidget->hide(); // We do not want to get disturbed by other widgets
// focus should move to the next widget in the focus chain when we hide it.
QScopedPointer<QWidget> parent(new QWidget());
parent->setObjectName(QLatin1String("focusChainOnHide"));
@@ -1717,8 +1606,6 @@ void tst_QWidget::focusChainOnHide()
QTRY_COMPARE(parent->hasFocus(), true);
QCOMPARE(parent.data(), qApp->focusWidget());
-
- testWidget->show(); //don't disturb later tests
}
class Container : public QWidget
@@ -1826,15 +1713,8 @@ void tst_QWidget::activation()
{
Q_CHECK_PAINTEVENTS
-#if defined(Q_OS_WINCE)
- int waitTime = 1000;
-#else
int waitTime = 100;
-#endif
-#ifdef Q_OS_WINCE
- qApp->processEvents();
-#endif
QWidget widget1;
widget1.setObjectName("activation-Widget1");
widget1.setWindowTitle(widget1.objectName());
@@ -1886,10 +1766,6 @@ void tst_QWidget::windowState()
size = QGuiApplication::primaryScreen()->size();
} else {
pos = QPoint(10, 10);
-#ifdef Q_OS_WINCE_WM
- if (qt_wince_is_smartphone()) { //small screen
- size = QSize(100,100);
-#endif
}
QWidget widget1;
@@ -2421,11 +2297,7 @@ void tst_QWidget::reparent()
childTLW.show();
QVERIFY(QTest::qWaitForWindowExposed(&parent));
-#ifdef Q_OS_WINCE
- parent.move(50, 50);
-#else
parent.move(parentPosition);
-#endif
QPoint childPos = parent.mapToGlobal(child.pos());
QPoint tlwPos = childTLW.pos();
@@ -2454,6 +2326,12 @@ void tst_QWidget::icon()
QPixmap p(20,20);
p.fill(Qt::red);
+ QScopedPointer<QWidget> testWidget(new QWidget);
+ testWidget->resize(m_testWidgetSize);
+ testWidget->setWindowTitle(__FUNCTION__);
+ centerOnScreen(testWidget.data());
+ testWidget->show();
+ QVERIFY(QTest::qWaitForWindowExposed(testWidget.data()));
testWidget->setWindowIcon(p);
QVERIFY(!testWidget->windowIcon().isNull());
@@ -2469,22 +2347,27 @@ void tst_QWidget::hideWhenFocusWidgetIsChild()
{
if (m_platform == QStringLiteral("wayland"))
QSKIP("Wayland: This fails. Figure out why.");
- testWidget->activateWindow();
- QScopedPointer<QWidget> parentWidget(new QWidget(testWidget));
+
+ QScopedPointer<QWidget> testWidget(new QWidget);
+ testWidget->setWindowTitle(__FUNCTION__);
+ testWidget->resize(m_testWidgetSize);
+ centerOnScreen(testWidget.data());
+ QWidget *parentWidget(new QWidget(testWidget.data()));
parentWidget->setObjectName("parentWidget");
parentWidget->setGeometry(0, 0, 100, 100);
- QLineEdit *edit = new QLineEdit(parentWidget.data());
+ QLineEdit *edit = new QLineEdit(parentWidget);
edit->setObjectName("edit1");
- QLineEdit *edit3 = new QLineEdit(parentWidget.data());
+ QLineEdit *edit3 = new QLineEdit(parentWidget);
edit3->setObjectName("edit3");
edit3->move(0,50);
- parentWidget->show();
- QLineEdit *edit2 = new QLineEdit(testWidget);
+ QLineEdit *edit2 = new QLineEdit(testWidget.data());
edit2->setObjectName("edit2");
- edit2->show();
edit2->move(110, 100);
edit->setFocus();
- qApp->processEvents();
+ testWidget->show();
+ testWidget->activateWindow();
+ QVERIFY(QTest::qWaitForWindowActive(testWidget.data()));
+
QString actualFocusWidget, expectedFocusWidget;
if (!qApp->focusWidget() && m_platform == QStringLiteral("xcb"))
QSKIP("X11: Your window manager is too broken for this test");
@@ -2640,8 +2523,6 @@ void tst_QWidget::setGeometry()
QCOMPARE(tlw.geometry(), tr);
}
-// Windows CE does not support windowOpacity.
-#ifndef Q_OS_WINCE
void tst_QWidget::windowOpacity()
{
QWidget widget;
@@ -2672,7 +2553,6 @@ void tst_QWidget::windowOpacity()
child.setWindowOpacity(-1.0);
QCOMPARE(child.windowOpacity(), 1.0);
}
-#endif
class UpdateWidget : public QWidget
{
@@ -2991,9 +2871,6 @@ void tst_QWidget::stackUnder()
foreach (UpdateWidget *child, allChildren) {
int expectedZOrderChangeEvents = child == child1 ? 1 : 0;
if (child == child3) {
-#ifdef Q_OS_WINCE
- qApp->processEvents();
-#endif
#ifndef Q_OS_OSX
QEXPECT_FAIL(0, "See QTBUG-493", Continue);
#endif
@@ -3385,9 +3262,6 @@ void tst_QWidget::widgetAt()
w2->setMask(rgn);
qApp->processEvents();
QTest::qWait(10);
-#if defined(Q_OS_WINCE)
- QEXPECT_FAIL("", "Windows CE does only support rectangular regions", Continue); //See also task 147191
-#endif
QTRY_VERIFY((wr = QApplication::widgetAt(testPos)));
QTRY_COMPARE(wr->objectName(), w1->objectName());
@@ -3403,9 +3277,6 @@ void tst_QWidget::widgetAt()
w2->setMask(bitmap);
qApp->processEvents();
QTest::qWait(10);
-#if defined(Q_OS_WINCE)
- QEXPECT_FAIL("", "Windows CE does only support rectangular regions", Continue); //See also task 147191
-#endif
QTRY_COMPARE(QApplication::widgetAt(testPos), w1.data());
QTRY_VERIFY(QApplication::widgetAt(testPos + QPoint(1, 1)) == w2.data());
}
@@ -3573,8 +3444,6 @@ bool verifyWidgetMask(QWidget *widget, QRect mask)
void tst_QWidget::setMask()
{
- testWidget->hide(); // get this out of the way.
-
{
MaskedPainter w;
w.resize(200, 200);
@@ -3730,7 +3599,7 @@ void tst_QWidget::optimizedResize_topLevel()
topLevel.partial = false;
topLevel.paintedRegion = QRegion();
-#if !defined(Q_OS_WIN32) && !defined(Q_OS_WINCE)
+#if !defined(Q_OS_WIN32)
topLevel.resize(topLevel.size() + QSize(10, 10));
#else
// Static contents does not work when programmatically resizing
@@ -3801,7 +3670,6 @@ void tst_QWidget::setMinimumSize()
// Setting a minimum size larger than the desktop does not work on WinCE,
// so skip this part of the test.
-#ifndef Q_OS_WINCE
QSize nonDefaultSize = defaultSize + QSize(5,5);
w.setMinimumSize(nonDefaultSize);
w.showNormal();
@@ -3810,7 +3678,6 @@ void tst_QWidget::setMinimumSize()
msgComparisonFailed(w.height(), ">=", nonDefaultSize.height()));
QVERIFY2(w.width() >= nonDefaultSize.width(),
msgComparisonFailed(w.width(), ">=", nonDefaultSize.width()));
-#endif
}
void tst_QWidget::setMaximumSize()
@@ -4787,7 +4654,7 @@ void tst_QWidget::setWindowGeometry()
}
}
-#if defined (Q_OS_WIN) && !defined(Q_OS_WINCE) && !defined(Q_OS_WINRT)
+#if defined (Q_OS_WIN) && !defined(Q_OS_WINRT)
void tst_QWidget::setGeometry_win()
{
QWidget widget;
@@ -4808,7 +4675,7 @@ void tst_QWidget::setGeometry_win()
QVERIFY2(rt.top <= m_availableTopLeft.y(),
msgComparisonFailed(int(rt.top), "<=", m_availableTopLeft.y()));
}
-#endif // defined (Q_OS_WIN) && !defined(Q_OS_WINCE) && !defined(Q_OS_WINRT)
+#endif // defined (Q_OS_WIN) && !defined(Q_OS_WINRT)
// Since X11 WindowManager operation are all async, and we have no way to know if the window
// manager has finished playing with the window geometry, this test can't be reliable on X11.
@@ -5134,12 +5001,8 @@ void tst_QWidget::moveChild()
parent.setStyle(style.data());
ColorWidget child(&parent, Qt::Widget, Qt::blue);
-#ifndef Q_OS_WINCE
parent.setGeometry(QRect(QPoint(QApplication::desktop()->availableGeometry(&parent).topLeft()) + QPoint(50, 50),
QSize(200, 200)));
-#else
- parent.setGeometry(60, 60, 150, 150);
-#endif
child.setGeometry(25, 25, 50, 50);
#ifndef QT_NO_CURSOR // Try to make sure the cursor is not in a taskbar area to prevent tooltips or window highlighting
QCursor::setPos(parent.geometry().topRight() + QPoint(50 , 50));
@@ -5365,11 +5228,18 @@ public:
void tst_QWidget::setFocus()
{
+ QScopedPointer<QWidget> testWidget(new QWidget);
+ testWidget->resize(m_testWidgetSize);
+ testWidget->setWindowTitle(__FUNCTION__);
+ centerOnScreen(testWidget.data());
+ testWidget->show();
+ QVERIFY(QTest::qWaitForWindowExposed(testWidget.data()));
+
const QPoint windowPos = testWidget->geometry().topRight() + QPoint(50, 0);
{
// move focus to another window
testWidget->activateWindow();
- QApplication::setActiveWindow(testWidget);
+ QApplication::setActiveWindow(testWidget.data());
if (testWidget->focusWidget())
testWidget->focusWidget()->clearFocus();
else
@@ -5415,7 +5285,7 @@ void tst_QWidget::setFocus()
// note: window may be active, but we don't want it to be
testWidget->activateWindow();
- QApplication::setActiveWindow(testWidget);
+ QApplication::setActiveWindow(testWidget.data());
if (testWidget->focusWidget())
testWidget->focusWidget()->clearFocus();
else
@@ -5584,7 +5454,7 @@ private:
int m_count;
};
-#ifndef QTEST_NO_CURSOR
+#ifndef QT_NO_CURSOR
void tst_QWidget::setCursor()
{
{
@@ -5727,8 +5597,6 @@ void tst_QWidget::setToolTip()
QCOMPARE(widget.toolTip(), QString());
QCOMPARE(spy.count(), 2);
- // Mouse over doesn't work on Windows mobile, so skip the rest of the test for that platform.
-#ifndef Q_OS_WINCE_WM
for (int pass = 0; pass < 2; ++pass) {
QCursor::setPos(m_safeCursorPos);
QScopedPointer<QWidget> popup(new QWidget(0, Qt::Popup));
@@ -5756,7 +5624,6 @@ void tst_QWidget::setToolTip()
QTest::qWait(2200); // delay is 2000
QTest::mouseMove(popupWindow);
}
-#endif
}
void tst_QWidget::testWindowIconChangeEventPropagation()
@@ -6837,7 +6704,6 @@ void tst_QWidget::render_task217815()
}
// Window Opacity is not supported on Windows CE.
-#ifndef Q_OS_WINCE
void tst_QWidget::render_windowOpacity()
{
const qreal opacity = 0.5;
@@ -6910,7 +6776,6 @@ void tst_QWidget::render_windowOpacity()
QCOMPARE(result, expected);
}
}
-#endif
void tst_QWidget::render_systemClip()
{
@@ -7368,14 +7233,10 @@ void tst_QWidget::repaintWhenChildDeleted()
}
#endif
ColorWidget w(0, Qt::FramelessWindowHint, Qt::red);
-#if !defined(Q_OS_WINCE)
QPoint startPoint = QApplication::desktop()->availableGeometry(&w).topLeft();
startPoint.rx() += 50;
startPoint.ry() += 50;
w.setGeometry(QRect(startPoint, QSize(100, 100)));
-#else
- w.setGeometry(60, 60, 110, 110);
-#endif
w.show();
QVERIFY(QTest::qWaitForWindowExposed(&w));
QTest::qWait(10);
@@ -7399,14 +7260,10 @@ void tst_QWidget::repaintWhenChildDeleted()
void tst_QWidget::hideOpaqueChildWhileHidden()
{
ColorWidget w(0, Qt::FramelessWindowHint, Qt::red);
-#if !defined(Q_OS_WINCE)
QPoint startPoint = QApplication::desktop()->availableGeometry(&w).topLeft();
startPoint.rx() += 50;
startPoint.ry() += 50;
w.setGeometry(QRect(startPoint, QSize(100, 100)));
-#else
- w.setGeometry(60, 60, 110, 110);
-#endif
ColorWidget child(&w, Qt::Widget, Qt::blue);
child.setGeometry(10, 10, 80, 80);
@@ -7435,7 +7292,6 @@ void tst_QWidget::hideOpaqueChildWhileHidden()
}
// This test doesn't make sense without support for showMinimized().
-#if !defined(Q_OS_WINCE)
void tst_QWidget::updateWhileMinimized()
{
if (m_platform == QStringLiteral("wayland"))
@@ -7473,7 +7329,6 @@ void tst_QWidget::updateWhileMinimized()
QTRY_COMPARE(widget.numPaintEvents, 1);
QCOMPARE(widget.paintedRegion, QRegion(0, 0, 50, 50));
}
-#endif
class PaintOnScreenWidget: public QWidget
{
@@ -7840,13 +7695,6 @@ void tst_QWidget::adjustSize()
QVERIFY2(child->size().height() < sizeHint.height(),
msgComparisonFailed(child->size().height(), "<", sizeHint.height()));
} else {
-#if defined (Q_OS_WINCE)
- if (!haveParent) {
- const QRect& desktopRect = qApp->desktop()->availableGeometry();
- expectedSize.setWidth(qMin(expectedSize.width(), desktopRect.width()));
- expectedSize.setHeight(qMin(expectedSize.height(), desktopRect.height()));
- }
-#endif
QCOMPARE(child->size(), expectedSize);
}
if (!haveParent)
@@ -8916,7 +8764,7 @@ void tst_QWidget::maskedUpdate()
QTRY_COMPARE(grandChild.paintedRegion, QRegion(grandChild.rect())); // Full update.
}
-#ifndef QTEST_NO_CURSOR
+#ifndef QT_NO_CURSOR
void tst_QWidget::syntheticEnterLeave()
{
if (m_platform == QStringLiteral("wayland"))
@@ -9022,7 +8870,7 @@ void tst_QWidget::syntheticEnterLeave()
}
#endif
-#ifndef QTEST_NO_CURSOR
+#ifndef QT_NO_CURSOR
void tst_QWidget::taskQTBUG_4055_sendSyntheticEnterLeave()
{
if (m_platform == QStringLiteral("wayland"))
@@ -9170,8 +9018,6 @@ void tst_QWidget::updateOnDestroyedSignal()
void tst_QWidget::toplevelLineEditFocus()
{
- testWidget->hide();
-
QLineEdit w;
w.setMinimumWidth(m_testWidgetSize.width());
w.show();
@@ -9237,10 +9083,9 @@ QWidgetBackingStore* backingStore(QWidget &widget)
}
// Tables of 5000 elements do not make sense on Windows Mobile.
-#ifndef Q_OS_WINCE_WM
void tst_QWidget::rectOutsideCoordinatesLimit_task144779()
{
-#ifndef QTEST_NO_CURSOR
+#ifndef QT_NO_CURSOR
QApplication::setOverrideCursor(Qt::BlankCursor); //keep the cursor out of screen grabs
#endif
QWidget main(0,Qt::FramelessWindowHint); //don't get confused by the size of the window frame
@@ -9275,11 +9120,10 @@ void tst_QWidget::rectOutsideCoordinatesLimit_task144779()
QTRY_COMPARE(mainPixmap.toImage().convertToFormat(QImage::Format_RGB32),
correct.toImage().convertToFormat(QImage::Format_RGB32));
-#ifndef QTEST_NO_CURSOR
+#ifndef QT_NO_CURSOR
QApplication::restoreOverrideCursor();
#endif
}
-#endif
void tst_QWidget::setGraphicsEffect()
{
@@ -9892,25 +9736,21 @@ void tst_QWidget::touchEventSynthesizedMouseEvent()
{
// Simple case, we ignore the touch events, we get mouse events instead
- QTouchDevice *device = new QTouchDevice;
- device->setType(QTouchDevice::TouchScreen);
- QWindowSystemInterface::registerTouchDevice(device);
-
TouchMouseWidget widget;
widget.show();
QVERIFY(QTest::qWaitForWindowExposed(widget.windowHandle()));
QCOMPARE(widget.m_touchEventCount, 0);
QCOMPARE(widget.m_mouseEventCount, 0);
- QTest::touchEvent(&widget, device).press(0, QPoint(10, 10), &widget);
+ QTest::touchEvent(&widget, m_touchScreen).press(0, QPoint(10, 10), &widget);
QCOMPARE(widget.m_touchEventCount, 0);
QCOMPARE(widget.m_mouseEventCount, 1);
QCOMPARE(widget.m_lastMouseEventPos, QPointF(10, 10));
- QTest::touchEvent(&widget, device).move(0, QPoint(15, 15), &widget);
+ QTest::touchEvent(&widget, m_touchScreen).move(0, QPoint(15, 15), &widget);
QCOMPARE(widget.m_touchEventCount, 0);
QCOMPARE(widget.m_mouseEventCount, 2);
QCOMPARE(widget.m_lastMouseEventPos, QPointF(15, 15));
- QTest::touchEvent(&widget, device).release(0, QPoint(20, 20), &widget);
+ QTest::touchEvent(&widget, m_touchScreen).release(0, QPoint(20, 20), &widget);
QCOMPARE(widget.m_touchEventCount, 0);
QCOMPARE(widget.m_mouseEventCount, 4); // we receive extra mouse move event
QCOMPARE(widget.m_lastMouseEventPos, QPointF(20, 20));
@@ -9918,10 +9758,6 @@ void tst_QWidget::touchEventSynthesizedMouseEvent()
{
// We accept the touch events, no mouse event is generated
- QTouchDevice *device = new QTouchDevice;
- device->setType(QTouchDevice::TouchScreen);
- QWindowSystemInterface::registerTouchDevice(device);
-
TouchMouseWidget widget;
widget.setAcceptTouch(true);
widget.show();
@@ -9929,13 +9765,13 @@ void tst_QWidget::touchEventSynthesizedMouseEvent()
QCOMPARE(widget.m_touchEventCount, 0);
QCOMPARE(widget.m_mouseEventCount, 0);
- QTest::touchEvent(&widget, device).press(0, QPoint(10, 10), &widget);
+ QTest::touchEvent(&widget, m_touchScreen).press(0, QPoint(10, 10), &widget);
QCOMPARE(widget.m_touchEventCount, 1);
QCOMPARE(widget.m_mouseEventCount, 0);
- QTest::touchEvent(&widget, device).move(0, QPoint(15, 15), &widget);
+ QTest::touchEvent(&widget, m_touchScreen).move(0, QPoint(15, 15), &widget);
QCOMPARE(widget.m_touchEventCount, 2);
QCOMPARE(widget.m_mouseEventCount, 0);
- QTest::touchEvent(&widget, device).release(0, QPoint(20, 20), &widget);
+ QTest::touchEvent(&widget, m_touchScreen).release(0, QPoint(20, 20), &widget);
QCOMPARE(widget.m_touchEventCount, 3);
QCOMPARE(widget.m_mouseEventCount, 0);
}
@@ -9943,10 +9779,6 @@ void tst_QWidget::touchEventSynthesizedMouseEvent()
{
// Parent accepts touch events, child ignore both mouse and touch
// We should see propagation of the TouchBegin
- QTouchDevice *device = new QTouchDevice;
- device->setType(QTouchDevice::TouchScreen);
- QWindowSystemInterface::registerTouchDevice(device);
-
TouchMouseWidget parent;
parent.setAcceptTouch(true);
TouchMouseWidget child(&parent);
@@ -9959,7 +9791,7 @@ void tst_QWidget::touchEventSynthesizedMouseEvent()
QCOMPARE(child.m_touchEventCount, 0);
QCOMPARE(child.m_mouseEventCount, 0);
- QTest::touchEvent(parent.window(), device).press(0, QPoint(10, 10), &child);
+ QTest::touchEvent(parent.window(), m_touchScreen).press(0, QPoint(10, 10), &child);
QCOMPARE(parent.m_touchEventCount, 1);
QCOMPARE(parent.m_mouseEventCount, 0);
QCOMPARE(child.m_touchEventCount, 0);
@@ -9969,10 +9801,6 @@ void tst_QWidget::touchEventSynthesizedMouseEvent()
{
// Parent accepts mouse events, child ignore both mouse and touch
// We should see propagation of the TouchBegin into a MouseButtonPress
- QTouchDevice *device = new QTouchDevice;
- device->setType(QTouchDevice::TouchScreen);
- QWindowSystemInterface::registerTouchDevice(device);
-
TouchMouseWidget parent;
TouchMouseWidget child(&parent);
child.move(5, 5);
@@ -9984,7 +9812,7 @@ void tst_QWidget::touchEventSynthesizedMouseEvent()
QCOMPARE(child.m_touchEventCount, 0);
QCOMPARE(child.m_mouseEventCount, 0);
- QTest::touchEvent(parent.window(), device).press(0, QPoint(10, 10), &child);
+ QTest::touchEvent(parent.window(), m_touchScreen).press(0, QPoint(10, 10), &child);
QCOMPARE(parent.m_touchEventCount, 0);
QCOMPARE(parent.m_mouseEventCount, 1);
QCOMPARE(parent.m_lastMouseEventPos, QPointF(15, 15));
@@ -9996,10 +9824,6 @@ void tst_QWidget::touchEventSynthesizedMouseEvent()
void tst_QWidget::touchUpdateOnNewTouch()
{
- QTouchDevice *device = new QTouchDevice;
- device->setType(QTouchDevice::TouchScreen);
- QWindowSystemInterface::registerTouchDevice(device);
-
TouchMouseWidget widget;
widget.setAcceptTouch(true);
QVBoxLayout *layout = new QVBoxLayout;
@@ -10012,23 +9836,23 @@ void tst_QWidget::touchUpdateOnNewTouch()
QCOMPARE(widget.m_touchBeginCount, 0);
QCOMPARE(widget.m_touchUpdateCount, 0);
QCOMPARE(widget.m_touchEndCount, 0);
- QTest::touchEvent(window, device).press(0, QPoint(20, 20), window);
+ QTest::touchEvent(window, m_touchScreen).press(0, QPoint(20, 20), window);
QCOMPARE(widget.m_touchBeginCount, 1);
QCOMPARE(widget.m_touchUpdateCount, 0);
QCOMPARE(widget.m_touchEndCount, 0);
- QTest::touchEvent(window, device).move(0, QPoint(25, 25), window);
+ QTest::touchEvent(window, m_touchScreen).move(0, QPoint(25, 25), window);
QCOMPARE(widget.m_touchBeginCount, 1);
QCOMPARE(widget.m_touchUpdateCount, 1);
QCOMPARE(widget.m_touchEndCount, 0);
- QTest::touchEvent(window, device).stationary(0).press(1, QPoint(40, 40), window);
+ QTest::touchEvent(window, m_touchScreen).stationary(0).press(1, QPoint(40, 40), window);
QCOMPARE(widget.m_touchBeginCount, 1);
QCOMPARE(widget.m_touchUpdateCount, 2);
QCOMPARE(widget.m_touchEndCount, 0);
- QTest::touchEvent(window, device).stationary(1).release(0, QPoint(25, 25), window);
+ QTest::touchEvent(window, m_touchScreen).stationary(1).release(0, QPoint(25, 25), window);
QCOMPARE(widget.m_touchBeginCount, 1);
QCOMPARE(widget.m_touchUpdateCount, 3);
QCOMPARE(widget.m_touchEndCount, 0);
- QTest::touchEvent(window, device).release(1, QPoint(40, 40), window);
+ QTest::touchEvent(window, m_touchScreen).release(1, QPoint(40, 40), window);
QCOMPARE(widget.m_touchBeginCount, 1);
QCOMPARE(widget.m_touchUpdateCount, 3);
QCOMPARE(widget.m_touchEndCount, 1);
@@ -10036,10 +9860,6 @@ void tst_QWidget::touchUpdateOnNewTouch()
void tst_QWidget::touchEventsForGesturePendingWidgets()
{
- QTouchDevice *device = new QTouchDevice;
- device->setType(QTouchDevice::TouchScreen);
- QWindowSystemInterface::registerTouchDevice(device);
-
TouchMouseWidget parent;
TouchMouseWidget child(&parent);
parent.grabGesture(Qt::TapAndHoldGesture);
@@ -10052,14 +9872,14 @@ void tst_QWidget::touchEventsForGesturePendingWidgets()
QCOMPARE(child.m_gestureEventCount, 0);
QCOMPARE(parent.m_touchEventCount, 0);
QCOMPARE(parent.m_gestureEventCount, 0);
- QTest::touchEvent(window, device).press(0, QPoint(20, 20), window);
+ QTest::touchEvent(window, m_touchScreen).press(0, QPoint(20, 20), window);
QCOMPARE(child.m_touchEventCount, 0);
QCOMPARE(child.m_gestureEventCount, 0);
QCOMPARE(parent.m_touchBeginCount, 1); // QTapAndHoldGestureRecognizer::create() sets Qt::WA_AcceptTouchEvents
QCOMPARE(parent.m_touchUpdateCount, 0);
QCOMPARE(parent.m_touchEndCount, 0);
QCOMPARE(parent.m_gestureEventCount, 0);
- QTest::touchEvent(window, device).move(0, QPoint(25, 25), window);
+ QTest::touchEvent(window, m_touchScreen).move(0, QPoint(25, 25), window);
QCOMPARE(child.m_touchEventCount, 0);
QCOMPARE(child.m_gestureEventCount, 0);
QCOMPARE(parent.m_touchBeginCount, 1);
@@ -10067,7 +9887,7 @@ void tst_QWidget::touchEventsForGesturePendingWidgets()
QCOMPARE(parent.m_touchEndCount, 0);
QCOMPARE(parent.m_gestureEventCount, 0);
QTest::qWait(1000);
- QTest::touchEvent(window, device).release(0, QPoint(25, 25), window);
+ QTest::touchEvent(window, m_touchScreen).release(0, QPoint(25, 25), window);
QCOMPARE(child.m_touchEventCount, 0);
QCOMPARE(child.m_gestureEventCount, 0);
QCOMPARE(parent.m_touchBeginCount, 1);
@@ -10184,7 +10004,7 @@ void tst_QWidget::destroyedSignal()
}
-#ifndef QTEST_NO_CURSOR
+#ifndef QT_NO_CURSOR
void tst_QWidget::underMouse()
{
// Move the mouse cursor to a safe location
@@ -10473,7 +10293,7 @@ void tst_QWidget::taskQTBUG_27643_enterEvents()
// Must only register only single enter on modal dialog's button after all said and done
QCOMPARE(dialog.enters, 1);
}
-#endif // QTEST_NO_CURSOR
+#endif // QT_NO_CURSOR
class KeyboardWidget : public QWidget
{
diff --git a/tests/auto/widgets/kernel/qwidget_window/qwidget_window.pro b/tests/auto/widgets/kernel/qwidget_window/qwidget_window.pro
index 8672c363a2..a6248dfd16 100644
--- a/tests/auto/widgets/kernel/qwidget_window/qwidget_window.pro
+++ b/tests/auto/widgets/kernel/qwidget_window/qwidget_window.pro
@@ -2,8 +2,3 @@ CONFIG += testcase
TARGET = tst_qwidget_window
QT += widgets testlib core-private gui-private
SOURCES += tst_qwidget_window.cpp
-
-x11 {
- LIBS += $$QMAKE_LIBS_X11
-}
-
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 35b1596003..6aaac6d135 100644
--- a/tests/auto/widgets/kernel/qwidget_window/tst_qwidget_window.cpp
+++ b/tests/auto/widgets/kernel/qwidget_window/tst_qwidget_window.cpp
@@ -331,8 +331,10 @@ void tst_QWidget_window::tst_showWithoutActivating()
QSKIP("Cocoa: This fails. Figure out why.");
else if (platformName != QStringLiteral("xcb")
&& platformName != QStringLiteral("windows")
- && platformName != QStringLiteral("ios"))
- QSKIP("Qt::WA_ShowWithoutActivating is currently supported only on xcb, windows, and ios platforms.");
+ && platformName != QStringLiteral("ios")
+ && platformName != QStringLiteral("tvos")
+ && platformName != QStringLiteral("watchos"))
+ QSKIP("Qt::WA_ShowWithoutActivating is currently supported only on xcb, windows, and ios/tvos/watchos platforms.");
QWidget w1;
w1.setAttribute(Qt::WA_ShowWithoutActivating);