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.cpp46
-rw-r--r--tests/auto/widgets/kernel/qformlayout/tst_qformlayout.cpp237
-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/qwidget.pro2
-rw-r--r--tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp418
-rw-r--r--tests/auto/widgets/kernel/qwidget_window/tst_qwidget_window.cpp5
9 files changed, 461 insertions, 433 deletions
diff --git a/tests/auto/widgets/kernel/qaction/tst_qaction.cpp b/tests/auto/widgets/kernel/qaction/tst_qaction.cpp
index 205067d89c..7796627bd9 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 b7e8cded7a..f942f78b1d 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(),
@@ -2331,7 +2291,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
@@ -2356,7 +2316,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 a19f4aea56..b7ca5d21c7 100644
--- a/tests/auto/widgets/kernel/qformlayout/tst_qformlayout.cpp
+++ b/tests/auto/widgets/kernel/qformlayout/tst_qformlayout.cpp
@@ -84,6 +84,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();
@@ -687,6 +693,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);
+
+ QFormLayout::TakeRowResult 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);
+
+ QFormLayout::TakeRowResult 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);
+
+ QFormLayout::TakeRowResult 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 07dcfca28f..3c4c1a1d41 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;
@@ -603,19 +596,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
@@ -627,7 +607,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)
@@ -1672,6 +1651,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/qwidget.pro b/tests/auto/widgets/kernel/qwidget/qwidget.pro
index a3fd622896..ba4e51a416 100644
--- a/tests/auto/widgets/kernel/qwidget/qwidget.pro
+++ b/tests/auto/widgets/kernel/qwidget/qwidget.pro
@@ -20,4 +20,4 @@ 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 958bef3e6e..78fbae768a 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();
@@ -314,7 +271,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
@@ -322,7 +279,7 @@ private slots:
void deleteStyle();
void multipleToplevelFocusCheck();
void setFocus();
-#ifndef QTEST_NO_CURSOR
+#ifndef QT_NO_CURSOR
void setCursor();
#endif
void setToolTip();
@@ -339,9 +296,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();
@@ -357,9 +312,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,7 +409,6 @@ private slots:
private:
bool ensureScreenSize(int width, int height);
- QWidget *testWidget;
const QString m_platform;
QSize m_testWidgetSize;
@@ -612,7 +562,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);
@@ -635,8 +585,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 +605,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 +620,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 +667,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 +823,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 +964,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 +1053,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 +1106,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 +1203,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 +1221,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 +1287,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 +1304,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 +1401,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 +1581,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 +1604,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 +1711,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 +1764,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 +2295,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 +2324,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 +2345,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 +2521,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 +2551,6 @@ void tst_QWidget::windowOpacity()
child.setWindowOpacity(-1.0);
QCOMPARE(child.windowOpacity(), 1.0);
}
-#endif
class UpdateWidget : public QWidget
{
@@ -2991,9 +2869,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 +3260,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 +3275,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 +3442,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 +3597,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 +3668,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 +3676,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()
@@ -4750,7 +4615,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;
@@ -4771,7 +4636,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.
@@ -5096,12 +4961,8 @@ void tst_QWidget::moveChild()
parent.setStyle(QStyleFactory::create(QLatin1String("Windows")));
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));
@@ -5326,11 +5187,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
@@ -5376,7 +5244,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
@@ -5545,7 +5413,7 @@ private:
int m_count;
};
-#ifndef QTEST_NO_CURSOR
+#ifndef QT_NO_CURSOR
void tst_QWidget::setCursor()
{
{
@@ -5688,8 +5556,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));
@@ -5717,7 +5583,6 @@ void tst_QWidget::setToolTip()
QTest::qWait(2200); // delay is 2000
QTest::mouseMove(popupWindow);
}
-#endif
}
void tst_QWidget::testWindowIconChangeEventPropagation()
@@ -6796,7 +6661,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;
@@ -6869,7 +6733,6 @@ void tst_QWidget::render_windowOpacity()
QCOMPARE(result, expected);
}
}
-#endif
void tst_QWidget::render_systemClip()
{
@@ -7327,14 +7190,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);
@@ -7358,14 +7217,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);
@@ -7394,7 +7249,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"))
@@ -7432,7 +7286,6 @@ void tst_QWidget::updateWhileMinimized()
QTRY_COMPARE(widget.numPaintEvents, 1);
QCOMPARE(widget.paintedRegion, QRegion(0, 0, 50, 50));
}
-#endif
class PaintOnScreenWidget: public QWidget
{
@@ -7799,13 +7652,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)
@@ -8894,7 +8740,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"))
@@ -9000,7 +8846,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"))
@@ -9148,8 +8994,6 @@ void tst_QWidget::updateOnDestroyedSignal()
void tst_QWidget::toplevelLineEditFocus()
{
- testWidget->hide();
-
QLineEdit w;
w.setMinimumWidth(m_testWidgetSize.width());
w.show();
@@ -9215,10 +9059,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
@@ -9253,11 +9096,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()
{
@@ -10162,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
@@ -10449,7 +10291,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/tst_qwidget_window.cpp b/tests/auto/widgets/kernel/qwidget_window/tst_qwidget_window.cpp
index 200c8a6ced..301ddf441e 100644
--- a/tests/auto/widgets/kernel/qwidget_window/tst_qwidget_window.cpp
+++ b/tests/auto/widgets/kernel/qwidget_window/tst_qwidget_window.cpp
@@ -330,8 +330,9 @@ 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"))
+ QSKIP("Qt::WA_ShowWithoutActivating is currently supported only on xcb, windows, and ios/tvos platforms.");
QWidget w1;
w1.setAttribute(Qt::WA_ShowWithoutActivating);