Check for WindowActivation capability instead of platform

Before running tests that depend on QWindow::requestActivate

Gets rid of several Wayland platform checks in tst_QWindow.

Change-Id: I7a5e029044a968dfcf87ecbb5105c01d52852d35
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Reviewed-by: Pier Luigi Fiorini <pierluigi.fiorini@liri.io>
This commit is contained in:
Johan Klokkhammer Helsing 2018-03-02 15:24:32 +01:00 committed by Liang Qi
parent 499b4991f4
commit 3eb42abab6
3 changed files with 14 additions and 13 deletions

View File

@ -265,7 +265,7 @@ QPlatformServices *QPlatformIntegration::services() const
bool QPlatformIntegration::hasCapability(Capability cap) const
{
return cap == NonFullScreenWindows || cap == NativeWidgets || cap == WindowManagement
|| cap == TopStackedNativeChildWindows;
|| cap == TopStackedNativeChildWindows || cap == WindowActivation;
}
QPlatformPixmap *QPlatformIntegration::createPlatformPixmap(QPlatformPixmap::PixelType type) const

View File

@ -97,6 +97,7 @@ public:
NonFullScreenWindows,
NativeWidgets,
WindowManagement,
WindowActivation, // whether requestActivate is supported
SyncState,
RasterGLSurface,
AllGLFunctionsQueryable,

View File

@ -795,8 +795,8 @@ void tst_QWindow::isExposed()
void tst_QWindow::isActive()
{
if (!QGuiApplication::platformName().compare(QLatin1String("wayland"), Qt::CaseInsensitive))
QSKIP("Wayland: This fails. Figure out why.");
if (!QGuiApplicationPrivate::platformIntegration()->hasCapability(QPlatformIntegration::WindowActivation))
QSKIP("QWindow::requestActivate() is not supported.");
Window window;
// Some platforms enforce minimum widths for windows, which can cause extra resize
@ -1480,8 +1480,8 @@ void tst_QWindow::close()
void tst_QWindow::activateAndClose()
{
if (!QGuiApplication::platformName().compare(QLatin1String("wayland"), Qt::CaseInsensitive))
QSKIP("Wayland: This fails. Figure out why.");
if (!QGuiApplicationPrivate::platformIntegration()->hasCapability(QPlatformIntegration::WindowActivation))
QSKIP("QWindow::requestActivate() is not supported.");
for (int i = 0; i < 10; ++i) {
QWindow window;
@ -1876,8 +1876,8 @@ static bool isPlatformOffscreenOrMinimal()
void tst_QWindow::modalDialog()
{
if (!QGuiApplication::platformName().compare(QLatin1String("wayland"), Qt::CaseInsensitive))
QSKIP("Wayland: This fails. Figure out why.");
if (!QGuiApplicationPrivate::platformIntegration()->hasCapability(QPlatformIntegration::WindowActivation))
QSKIP("QWindow::requestActivate() is not supported.");
if (QGuiApplication::platformName() == QLatin1String("cocoa"))
QSKIP("Test fails due to QTBUG-61965, and is slow due to QTBUG-61964");
@ -1957,8 +1957,8 @@ void tst_QWindow::modalDialogClosingOneOfTwoModal()
void tst_QWindow::modalWithChildWindow()
{
if (!QGuiApplication::platformName().compare(QLatin1String("wayland"), Qt::CaseInsensitive))
QSKIP("Wayland: This fails. Figure out why.");
if (!QGuiApplicationPrivate::platformIntegration()->hasCapability(QPlatformIntegration::WindowActivation))
QSKIP("QWindow::requestActivate() is not supported.");
QWindow normalWindow;
normalWindow.setFramePosition(m_availableTopLeft + QPoint(80, 80));
@ -1991,8 +1991,8 @@ void tst_QWindow::modalWithChildWindow()
void tst_QWindow::modalWindowModallity()
{
if (!QGuiApplication::platformName().compare(QLatin1String("wayland"), Qt::CaseInsensitive))
QSKIP("Wayland: This fails. Figure out why.");
if (!QGuiApplicationPrivate::platformIntegration()->hasCapability(QPlatformIntegration::WindowActivation))
QSKIP("QWindow::requestActivate() is not supported.");
QWindow normal_window;
normal_window.setFramePosition(m_availableTopLeft + QPoint(80, 80));
@ -2037,8 +2037,8 @@ void tst_QWindow::modalWindowPosition()
#ifndef QT_NO_CURSOR
void tst_QWindow::modalWindowEnterEventOnHide_QTBUG35109()
{
if (!QGuiApplication::platformName().compare(QLatin1String("wayland"), Qt::CaseInsensitive))
QSKIP("Wayland: QWindow::requestActivate() is not supported");
if (!QGuiApplicationPrivate::platformIntegration()->hasCapability(QPlatformIntegration::WindowActivation))
QSKIP("QWindow::requestActivate() is not supported.");
if (isPlatformOffscreenOrMinimal())
QSKIP("Can't test window focusing on offscreen/minimal");