Add QTestPrivate::ensurePositionTopLeft() for reliable positioning
Implement ensurePositionTopLeft() to set a window's position to the available top-left corner and verify that it is correctly positioned. Incorrect updates to window.position and window.framePosition have been identified as one of the main sources of flakiness on Opensuse. This test function addresses this issue and improves test reliablity. Task-number: QTQAINFRA-7050 Change-Id: I946f74c7d2c1db9cfe4fec7db272e12876b3ed43 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io> Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
This commit is contained in:
parent
a5268131e2
commit
7929852c1d
@ -24,6 +24,7 @@
|
||||
#ifdef QT_GUI_LIB
|
||||
#include <QtGui/QGuiApplication>
|
||||
#include <QtGui/QScreen>
|
||||
#include <QtGui/QWindow>
|
||||
#endif
|
||||
|
||||
#ifdef QT_WIDGETS_LIB
|
||||
@ -91,6 +92,24 @@ static inline void androidCompatibleShow(QWidget *widget)
|
||||
}
|
||||
#endif // QT_WIDGETS_LIB
|
||||
|
||||
#ifdef QT_GUI_LIB
|
||||
bool ensurePositionTopLeft(QWindow *window)
|
||||
{
|
||||
const QPoint availableTopLeft = QGuiApplication::primaryScreen()->availableGeometry().topLeft();
|
||||
window->setFramePosition(availableTopLeft);
|
||||
bool positionCorrect = true;
|
||||
|
||||
if (!window->flags().testFlag(Qt::FramelessWindowHint))
|
||||
positionCorrect = QTest::qWaitFor([&]{ return window->framePosition() != window->position() ;});
|
||||
|
||||
const bool positionUpdated = QTest::qWaitFor([&]{ return window->framePosition() == availableTopLeft ;});
|
||||
if (!positionUpdated)
|
||||
positionCorrect = false;
|
||||
|
||||
return positionCorrect;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef QT_NETWORK_LIB
|
||||
inline bool isSecureTransportBlockingTest()
|
||||
{
|
||||
|
@ -18,6 +18,7 @@ qt_internal_add_test(tst_qwindow
|
||||
Qt::CorePrivate
|
||||
Qt::Gui
|
||||
Qt::GuiPrivate
|
||||
Qt::TestPrivate
|
||||
)
|
||||
|
||||
if(APPLE OR WIN32 OR QT_FEATURE_xcb)
|
||||
|
Loading…
x
Reference in New Issue
Block a user