Stabilize tst_QWindowContainer.
Fix window/widget leaks, observe available geometry. Change-Id: I19784d34a62c6e05dbc403852364cfb5e4d12dd5 Reviewed-by: Oliver Wolff <oliver.wolff@theqtcompany.com>bb10
parent
8860522d7e
commit
82d54a6593
|
|
@ -40,6 +40,8 @@
|
|||
|
||||
#include <qdockwidget.h>
|
||||
#include <qmainwindow.h>
|
||||
#include <qscreen.h>
|
||||
#include <qscopedpointer.h>
|
||||
|
||||
|
||||
class Window : public QWindow
|
||||
|
|
@ -65,6 +67,10 @@ public:
|
|||
class tst_QWindowContainer: public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
tst_QWindowContainer() : m_availableGeometry(QGuiApplication::primaryScreen()->availableGeometry()) {}
|
||||
|
||||
private slots:
|
||||
void testShow();
|
||||
void testPositionAndSize();
|
||||
|
|
@ -75,14 +81,22 @@ private slots:
|
|||
void testActivation();
|
||||
void testAncestorChange();
|
||||
void testDockWidget();
|
||||
void cleanup();
|
||||
|
||||
private:
|
||||
const QRect m_availableGeometry;
|
||||
};
|
||||
|
||||
|
||||
void tst_QWindowContainer::cleanup()
|
||||
{
|
||||
QVERIFY(QGuiApplication::topLevelWindows().isEmpty());
|
||||
}
|
||||
|
||||
void tst_QWindowContainer::testShow()
|
||||
{
|
||||
QWidget root;
|
||||
root.setGeometry(100, 100, 400, 400);
|
||||
root.setWindowTitle(QTest::currentTestFunction());
|
||||
root.setGeometry(m_availableGeometry.x() + 100, m_availableGeometry.y() + 100, 400, 400);
|
||||
|
||||
Window *window = new Window();
|
||||
QWidget *container = QWidget::createWindowContainer(window, &root);
|
||||
|
|
@ -99,14 +113,15 @@ void tst_QWindowContainer::testShow()
|
|||
void tst_QWindowContainer::testPositionAndSize()
|
||||
{
|
||||
QWindow *window = new QWindow();
|
||||
window->setGeometry(300, 400, 500, 600);
|
||||
window->setGeometry(m_availableGeometry.x() + 300, m_availableGeometry.y() + 400, 500, 600);
|
||||
|
||||
QWidget *container = QWidget::createWindowContainer(window);
|
||||
QScopedPointer<QWidget> container(QWidget::createWindowContainer(window));
|
||||
container->setWindowTitle(QTest::currentTestFunction());
|
||||
container->setGeometry(50, 50, 200, 200);
|
||||
|
||||
|
||||
container->show();
|
||||
QVERIFY(QTest::qWaitForWindowExposed(container));
|
||||
QVERIFY(QTest::qWaitForWindowExposed(container.data()));
|
||||
|
||||
QCOMPARE(window->x(), 0);
|
||||
QCOMPARE(window->y(), 0);
|
||||
|
|
@ -120,11 +135,12 @@ void tst_QWindowContainer::testExposeObscure()
|
|||
{
|
||||
Window *window = new Window();
|
||||
|
||||
QWidget *container = QWidget::createWindowContainer(window);
|
||||
container->setGeometry(50, 50, 200, 200);
|
||||
QScopedPointer<QWidget> container(QWidget::createWindowContainer(window));
|
||||
container->setWindowTitle(QTest::currentTestFunction());
|
||||
container->setGeometry(m_availableGeometry.x() + 50, m_availableGeometry.y() + 50, 200, 200);
|
||||
|
||||
container->show();
|
||||
QVERIFY(QTest::qWaitForWindowExposed(container));
|
||||
QVERIFY(QTest::qWaitForWindowExposed(container.data()));
|
||||
QVERIFY(QTest::qWaitForWindowExposed(window));
|
||||
|
||||
QVERIFY(window->numberOfExposes > 0);
|
||||
|
|
@ -173,12 +189,13 @@ void tst_QWindowContainer::testBehindTheScenesDeletion()
|
|||
void tst_QWindowContainer::testActivation()
|
||||
{
|
||||
QWidget root;
|
||||
root.setWindowTitle(QTest::currentTestFunction());
|
||||
|
||||
QWindow *window = new QWindow();
|
||||
QWidget *container = QWidget::createWindowContainer(window, &root);
|
||||
|
||||
container->setGeometry(100, 100, 200, 100);
|
||||
root.setGeometry(100, 100, 400, 300);
|
||||
root.setGeometry(m_availableGeometry.x() + 100, m_availableGeometry.y() + 100, 400, 300);
|
||||
|
||||
root.show();
|
||||
root.activateWindow();
|
||||
|
|
@ -212,14 +229,15 @@ void tst_QWindowContainer::testActivation()
|
|||
void tst_QWindowContainer::testUnparenting()
|
||||
{
|
||||
QWindow *window = new QWindow();
|
||||
QWidget *container = QWidget::createWindowContainer(window);
|
||||
container->setGeometry(100, 100, 200, 100);
|
||||
QScopedPointer<QWidget> container(QWidget::createWindowContainer(window));
|
||||
container->setWindowTitle(QTest::currentTestFunction());
|
||||
container->setGeometry(m_availableGeometry.x() + 100, m_availableGeometry.y() + 100, 200, 100);
|
||||
|
||||
window->setParent(0);
|
||||
|
||||
container->show();
|
||||
|
||||
QVERIFY(QTest::qWaitForWindowExposed(container));
|
||||
QVERIFY(QTest::qWaitForWindowExposed(container.data()));
|
||||
|
||||
// Window should not be made visible by container..
|
||||
QVERIFY(!window->isVisible());
|
||||
|
|
@ -228,10 +246,12 @@ void tst_QWindowContainer::testUnparenting()
|
|||
void tst_QWindowContainer::testAncestorChange()
|
||||
{
|
||||
QWidget root;
|
||||
root.setWindowTitle(QStringLiteral("Root ") + QTest::currentTestFunction());
|
||||
QWidget *left = new QWidget(&root);
|
||||
QWidget *right = new QWidget(&root);
|
||||
|
||||
root.setGeometry(0, 0, 200, 100);
|
||||
|
||||
root.setGeometry(m_availableGeometry.x() + 50, m_availableGeometry.y() + 50, 200, 100);
|
||||
left->setGeometry(0, 0, 100, 100);
|
||||
right->setGeometry(100, 0, 100, 100);
|
||||
|
||||
|
|
@ -257,6 +277,7 @@ void tst_QWindowContainer::testAncestorChange()
|
|||
QCOMPARE(window->geometry(), QRect(100, 0, 100, 100));
|
||||
|
||||
QWidget *newRoot = new QWidget(&root);
|
||||
newRoot->setWindowTitle(QStringLiteral("newRoot ") + QTest::currentTestFunction());
|
||||
newRoot->setGeometry(50, 50, 200, 200);
|
||||
right->setParent(newRoot);
|
||||
// Root
|
||||
|
|
@ -270,7 +291,8 @@ void tst_QWindowContainer::testAncestorChange()
|
|||
QCOMPARE(window->geometry(), QRect(100, 0, 100, 100));
|
||||
|
||||
newRoot->setParent(0);
|
||||
newRoot->setGeometry(100, 100, 200, 200);
|
||||
QScopedPointer<QWidget> newRootGuard(newRoot);
|
||||
newRoot->setGeometry(m_availableGeometry.x() + 100, m_availableGeometry.y() + 100, 200, 200);
|
||||
newRoot->show();
|
||||
QVERIFY(QTest::qWaitForWindowExposed(newRoot));
|
||||
QCOMPARE(newRoot->windowHandle(), window->parent());
|
||||
|
|
@ -285,9 +307,11 @@ void tst_QWindowContainer::testAncestorChange()
|
|||
void tst_QWindowContainer::testDockWidget()
|
||||
{
|
||||
QMainWindow mainWindow;
|
||||
mainWindow.setWindowTitle(QTest::currentTestFunction());
|
||||
mainWindow.resize(200, 200);
|
||||
mainWindow.move(m_availableGeometry.center() - QPoint(100, 100));
|
||||
|
||||
QDockWidget *dock = new QDockWidget();
|
||||
QDockWidget *dock = new QDockWidget(QStringLiteral("Dock ") + QTest::currentTestFunction());
|
||||
QWindow *window = new QWindow();
|
||||
QWidget *container = QWidget::createWindowContainer(window);
|
||||
dock->setWidget(container);
|
||||
|
|
|
|||
Loading…
Reference in New Issue