Brush up and stabilize tst_QSizeGrip
- Remove unused dummyWidget and thus empty slots initTestCase(), cleanupTestCase(). - Add slot cleanup() checking for an empty top level widgets list and introduce QScopedPointer to ensure it passes. - Use QTRY_VERIFY in hideAndShowOnWindowStateChange(). Flakyness has been observed on openSUSE: FAIL! : tst_QSizeGrip::hideAndShowOnWindowStateChange(Qt::Window) '!sizeGrip->isVisible()' returned FALSE. () Loc: [tst_qsizegrip.cpp(126)] Change-Id: I340fc1892dc00bcff1985e5a8a1e535975736484 Reviewed-by: Christian Ehrlicher <ch.ehrlicher@gmx.de>
This commit is contained in:
parent
accf7ce024
commit
06d753e87b
@ -59,25 +59,22 @@ class tst_QSizeGrip : public QObject
|
|||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public slots:
|
public slots:
|
||||||
void initTestCase();
|
void cleanup();
|
||||||
void cleanupTestCase();
|
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void hideAndShowOnWindowStateChange_data();
|
void hideAndShowOnWindowStateChange_data();
|
||||||
void hideAndShowOnWindowStateChange();
|
void hideAndShowOnWindowStateChange();
|
||||||
void orientation();
|
void orientation();
|
||||||
void dontCrashOnTLWChange();
|
void dontCrashOnTLWChange();
|
||||||
|
|
||||||
private:
|
|
||||||
QLineEdit *dummyWidget;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
class TestWidget : public QWidget
|
class TestWidget : public QWidget
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
TestWidget(QWidget *parent = 0, Qt::WindowFlags flags = 0) : QWidget(parent, flags) {}
|
using QWidget::QWidget;
|
||||||
QSize sizeHint() const { return QSize(300, 200); }
|
|
||||||
void changeEvent(QEvent *event)
|
QSize sizeHint() const override { return QSize(300, 200); }
|
||||||
|
void changeEvent(QEvent *event) override
|
||||||
{
|
{
|
||||||
QWidget::changeEvent(event);
|
QWidget::changeEvent(event);
|
||||||
if (isWindow() && event->type() == QEvent::WindowStateChange)
|
if (isWindow() && event->type() == QEvent::WindowStateChange)
|
||||||
@ -85,16 +82,9 @@ public:
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
void tst_QSizeGrip::initTestCase()
|
void tst_QSizeGrip::cleanup()
|
||||||
{
|
{
|
||||||
dummyWidget = new QLineEdit;
|
QVERIFY(QApplication::topLevelWidgets().isEmpty());
|
||||||
dummyWidget->show();
|
|
||||||
}
|
|
||||||
|
|
||||||
void tst_QSizeGrip::cleanupTestCase()
|
|
||||||
{
|
|
||||||
delete dummyWidget;
|
|
||||||
dummyWidget = 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void tst_QSizeGrip::hideAndShowOnWindowStateChange_data()
|
void tst_QSizeGrip::hideAndShowOnWindowStateChange_data()
|
||||||
@ -111,46 +101,45 @@ void tst_QSizeGrip::hideAndShowOnWindowStateChange()
|
|||||||
QSKIP("Broken on WinRT - QTBUG-68297");
|
QSKIP("Broken on WinRT - QTBUG-68297");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
QWidget *parentWidget = windowType == Qt::Window ? 0 : new QWidget;
|
QScopedPointer<QWidget> parentWidget;
|
||||||
TestWidget *widget = new TestWidget(parentWidget, Qt::WindowFlags(windowType));
|
if (windowType != Qt::Window)
|
||||||
QSizeGrip *sizeGrip = new QSizeGrip(widget);
|
parentWidget.reset(new QWidget);
|
||||||
|
QScopedPointer<TestWidget> widget(new TestWidget(parentWidget.data(), Qt::WindowFlags(windowType)));
|
||||||
|
QSizeGrip *sizeGrip = new QSizeGrip(widget.data());
|
||||||
|
|
||||||
// Normal.
|
// Normal.
|
||||||
if (parentWidget)
|
if (parentWidget)
|
||||||
parentWidget->show();
|
parentWidget->show();
|
||||||
else
|
else
|
||||||
widget->show();
|
widget->show();
|
||||||
QVERIFY(sizeGrip->isVisible());
|
QTRY_VERIFY(sizeGrip->isVisible());
|
||||||
|
|
||||||
widget->showFullScreen();
|
widget->showFullScreen();
|
||||||
QVERIFY(!sizeGrip->isVisible());
|
QTRY_VERIFY(!sizeGrip->isVisible());
|
||||||
|
|
||||||
widget->showNormal();
|
widget->showNormal();
|
||||||
QVERIFY(sizeGrip->isVisible());
|
QTRY_VERIFY(sizeGrip->isVisible());
|
||||||
|
|
||||||
widget->showMaximized();
|
widget->showMaximized();
|
||||||
#ifndef Q_OS_MAC
|
#ifndef Q_OS_MAC
|
||||||
QVERIFY(!sizeGrip->isVisible());
|
QTRY_VERIFY(!sizeGrip->isVisible());
|
||||||
#else
|
#else
|
||||||
QEXPECT_FAIL("", "QTBUG-23681", Abort);
|
QEXPECT_FAIL("", "QTBUG-23681", Abort);
|
||||||
QVERIFY(sizeGrip->isVisible());
|
QVERIFY(sizeGrip->isVisible());
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
widget->showNormal();
|
widget->showNormal();
|
||||||
QVERIFY(sizeGrip->isVisible());
|
QTRY_VERIFY(sizeGrip->isVisible());
|
||||||
|
|
||||||
sizeGrip->hide();
|
sizeGrip->hide();
|
||||||
QVERIFY(!sizeGrip->isVisible());
|
QTRY_VERIFY(!sizeGrip->isVisible());
|
||||||
|
|
||||||
widget->showFullScreen();
|
widget->showFullScreen();
|
||||||
widget->showNormal();
|
widget->showNormal();
|
||||||
QVERIFY(!sizeGrip->isVisible());
|
QTRY_VERIFY(!sizeGrip->isVisible());
|
||||||
widget->showMaximized();
|
widget->showMaximized();
|
||||||
widget->showNormal();
|
widget->showNormal();
|
||||||
QVERIFY(!sizeGrip->isVisible());
|
QTRY_VERIFY(!sizeGrip->isVisible());
|
||||||
|
|
||||||
delete widget;
|
|
||||||
delete parentWidget;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void tst_QSizeGrip::orientation()
|
void tst_QSizeGrip::orientation()
|
||||||
@ -196,10 +185,10 @@ void tst_QSizeGrip::dontCrashOnTLWChange()
|
|||||||
QMdiArea mdiArea;
|
QMdiArea mdiArea;
|
||||||
mdiArea.show();
|
mdiArea.show();
|
||||||
|
|
||||||
QMainWindow *mw = new QMainWindow();
|
QScopedPointer<QMainWindow> mw(new QMainWindow);
|
||||||
QMdiSubWindow *mdi = mdiArea.addSubWindow(mw);
|
QMdiSubWindow *mdi = mdiArea.addSubWindow(mw.data());
|
||||||
mw->statusBar()->setSizeGripEnabled(true);
|
mw->statusBar()->setSizeGripEnabled(true);
|
||||||
mdiArea.removeSubWindow(mw);
|
mdiArea.removeSubWindow(mw.data());
|
||||||
delete mdi;
|
delete mdi;
|
||||||
mw->show();
|
mw->show();
|
||||||
|
|
||||||
@ -209,7 +198,7 @@ void tst_QSizeGrip::dontCrashOnTLWChange()
|
|||||||
QEXPECT_FAIL("", "Broken on WinRT - QTBUG-68297", Abort);
|
QEXPECT_FAIL("", "Broken on WinRT - QTBUG-68297", Abort);
|
||||||
#endif
|
#endif
|
||||||
QVERIFY(QTest::qWaitForWindowExposed(&mdiArea));
|
QVERIFY(QTest::qWaitForWindowExposed(&mdiArea));
|
||||||
QVERIFY(QTest::qWaitForWindowExposed(mw));
|
QVERIFY(QTest::qWaitForWindowExposed(mw.data()));
|
||||||
}
|
}
|
||||||
|
|
||||||
QTEST_MAIN(tst_QSizeGrip)
|
QTEST_MAIN(tst_QSizeGrip)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user