QNX: Fix QGuiApplication autotests

On QNX a window can only be activated if it has either a egl surface
or a raster backingstore.

Change-Id: If075093e39f1553eb8b25e35f7d372b1b15aa8af
Reviewed-by: Sergio Ahumada <sahumada@blackberry.com>
bb10
Fabian Bumberger 2014-04-10 11:39:05 +02:00 committed by The Qt Project
parent 9cae7b5ee2
commit bf2fa58c02
1 changed files with 36 additions and 0 deletions

View File

@ -48,6 +48,10 @@
#include <qpa/qwindowsysteminterface.h>
#include <qgenericplugin.h>
#if defined(Q_OS_QNX)
#include <QOpenGLContext>
#endif
#include <QDebug>
#include "tst_qcoreapplication.h"
@ -124,6 +128,9 @@ void tst_QGuiApplication::focusObject()
const QRect screenGeometry = QGuiApplication::primaryScreen()->availableVirtualGeometry();
DummyWindow window1;
#if defined(Q_OS_QNX)
window1.setSurfaceType(QSurface::OpenGLSurface);
#endif
window1.resize(windowSize, windowSize);
window1.setTitle(QStringLiteral("focusObject:window1"));
window1.setFramePosition(QPoint(screenGeometry.left() + spacing, screenGeometry.top() + spacing));
@ -134,6 +141,15 @@ void tst_QGuiApplication::focusObject()
window1.show();
#if defined(Q_OS_QNX) // We either need to create a eglSurface or a create a backing store
// and then post the window in order for screen to show the window
QOpenGLContext context;
context.create();
context.makeCurrent(&window1);
QTest::qWaitForWindowExposed(&window1); // Buffer swap only succeeds with exposed window
context.swapBuffers(&window1);
#endif
QSignalSpy spy(&app, SIGNAL(focusObjectChanged(QObject*)));
@ -279,15 +295,35 @@ void tst_QGuiApplication::changeFocusWindow()
// focus is changed between FocusAboutToChange and FocusChanged
FocusChangeWindow window1;
#if defined(Q_OS_QNX)
window1.setSurfaceType(QSurface::OpenGLSurface);
#endif
window1.resize(windowSize, windowSize);
window1.setFramePosition(QPoint(screenGeometry.left() + spacing, screenGeometry.top() + spacing));
window1.setTitle(QStringLiteral("changeFocusWindow:window1"));
window1.show();
#if defined(Q_OS_QNX) // We either need to create a eglSurface or a create a backing store
// and then post the window in order for screen to show the window
QOpenGLContext context;
context.create();
context.makeCurrent(&window1);
QTest::qWaitForWindowExposed(&window1); // Buffer swap only succeeds with exposed window
context.swapBuffers(&window1);
#endif
FocusChangeWindow window2;
#if defined(Q_OS_QNX)
window2.setSurfaceType(QSurface::OpenGLSurface);
#endif
window2.resize(windowSize, windowSize);
window2.setFramePosition(QPoint(screenGeometry.left() + 2 * spacing + windowSize, screenGeometry.top() + spacing));
window2.setTitle(QStringLiteral("changeFocusWindow:window2"));
window2.show();
#if defined(Q_OS_QNX) // We either need to create a eglSurface or a create a backing store
// and then post the window in order for screen to show the window
context.makeCurrent(&window2);
QTest::qWaitForWindowExposed(&window2); // Buffer swap only succeeds with exposed window
context.swapBuffers(&window2);
#endif
QVERIFY(QTest::qWaitForWindowExposed(&window1));
QVERIFY(QTest::qWaitForWindowExposed(&window2));
window1.requestActivate();