summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorSamuel Rødal <samuel.rodal@nokia.com>2012-03-14 17:55:43 +0100
committerQt by Nokia <qt-info@nokia.com>2012-03-22 11:43:36 +0100
commit55fa3c189f88933d390177ad5606d3de9deacf93 (patch)
treea8c96bead830fa88de6bee2783b6eba3591bb014 /tests
parent9c7cdce672df7da5c84b0ae6ca10ff09a670a315 (diff)
Got rid of Map / Unmap events in favor of Expose event.
Since change 2e4d8f67a871f2033 the need for Map and Unmap events has gone away, as now the Expose event is used to notify the application about when it can start rendering. The Map and Unmap events weren't really used except by QWidget to set the WA_Mapped flag, which we now set based on the expose / unexpose. Also guarantee that a Resize event is always sent before the first Expose, by re-introducing an asynchronous expose event handler. Since an expose is required before rendering to a QWindow, show a warning if QOpenGLContext::swapBuffers() or QBackingStore::flush() if called on a window that has not received its first expose. Change-Id: Ia6b609aa275d5b463b5011a96f2fd9bbe52e9bc4 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@nokia.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/gui/kernel/kernel.pro1
-rw-r--r--tests/auto/gui/kernel/qbackingstore/qbackingstore.pro9
-rw-r--r--tests/auto/gui/kernel/qbackingstore/tst_qbackingstore.cpp103
-rw-r--r--tests/auto/gui/kernel/qwindow/qwindow.pro1
-rw-r--r--tests/auto/gui/kernel/qwindow/tst_qwindow.cpp58
-rw-r--r--tests/auto/widgets/graphicsview/qgraphicsitem/tst_qgraphicsitem.cpp15
-rw-r--r--tests/auto/widgets/graphicsview/qgraphicsscene/tst_qgraphicsscene.cpp32
7 files changed, 182 insertions, 37 deletions
diff --git a/tests/auto/gui/kernel/kernel.pro b/tests/auto/gui/kernel/kernel.pro
index 48d94b9bf8..0bd988b68c 100644
--- a/tests/auto/gui/kernel/kernel.pro
+++ b/tests/auto/gui/kernel/kernel.pro
@@ -1,5 +1,6 @@
TEMPLATE=subdirs
SUBDIRS=\
+ qbackingstore \
qclipboard \
qdrag \
qevent \
diff --git a/tests/auto/gui/kernel/qbackingstore/qbackingstore.pro b/tests/auto/gui/kernel/qbackingstore/qbackingstore.pro
new file mode 100644
index 0000000000..cc0a2c69f7
--- /dev/null
+++ b/tests/auto/gui/kernel/qbackingstore/qbackingstore.pro
@@ -0,0 +1,9 @@
+CONFIG += testcase
+TARGET = tst_qbackingstore
+
+QT += core-private gui-private testlib
+
+SOURCES += tst_qbackingstore.cpp
+
+mac: CONFIG += insignificant_test # QTBUG-23059
+win32: CONFIG += insignificant_test # QTBUG-24885
diff --git a/tests/auto/gui/kernel/qbackingstore/tst_qbackingstore.cpp b/tests/auto/gui/kernel/qbackingstore/tst_qbackingstore.cpp
new file mode 100644
index 0000000000..678e616b19
--- /dev/null
+++ b/tests/auto/gui/kernel/qbackingstore/tst_qbackingstore.cpp
@@ -0,0 +1,103 @@
+/****************************************************************************
+**
+** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
+** Contact: http://www.qt-project.org/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <qwindow.h>
+#include <qbackingstore.h>
+#include <qpainter.h>
+
+#include <QtTest/QtTest>
+
+#include <QEvent>
+
+// For QSignalSpy slot connections.
+Q_DECLARE_METATYPE(Qt::ScreenOrientation)
+
+class tst_QBackingStore : public QObject
+{
+ Q_OBJECT
+
+private slots:
+ void flush();
+};
+
+class Window : public QWindow
+{
+public:
+ Window()
+ : backingStore(this)
+ {
+ }
+
+ void resizeEvent(QResizeEvent *)
+ {
+ backingStore.resize(size());
+ }
+
+ void exposeEvent(QExposeEvent *event)
+ {
+ QRect rect(QPoint(), size());
+
+ backingStore.beginPaint(rect);
+
+ QPainter p(backingStore.paintDevice());
+ p.fillRect(rect, Qt::white);
+ p.end();
+
+ backingStore.endPaint();
+
+ backingStore.flush(event->region().boundingRect());
+ }
+
+private:
+ QBackingStore backingStore;
+};
+
+void tst_QBackingStore::flush()
+{
+ Window window;
+ window.setGeometry(20, 20, 200, 200);
+ window.showMaximized();
+
+ QTRY_VERIFY(window.isExposed());
+}
+
+#include <tst_qbackingstore.moc>
+QTEST_MAIN(tst_QBackingStore);
diff --git a/tests/auto/gui/kernel/qwindow/qwindow.pro b/tests/auto/gui/kernel/qwindow/qwindow.pro
index 363f7dd92e..fb8132afab 100644
--- a/tests/auto/gui/kernel/qwindow/qwindow.pro
+++ b/tests/auto/gui/kernel/qwindow/qwindow.pro
@@ -6,4 +6,5 @@ QT += core-private gui-private testlib
SOURCES += tst_qwindow.cpp
mac: CONFIG += insignificant_test # QTBUG-23059
+win32: CONFIG += insignificant_test # QTBUG-24904
diff --git a/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp b/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp
index f4556f7e32..ebd8823149 100644
--- a/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp
+++ b/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp
@@ -53,8 +53,10 @@ class tst_QWindow: public QObject
Q_OBJECT
private slots:
+ void eventOrderOnShow();
void mapGlobal();
void positioning();
+ void isExposed();
void isActive();
void testInputEvents();
void touchToMouseTranslation();
@@ -114,6 +116,7 @@ public:
bool event(QEvent *event)
{
m_received[event->type()]++;
+ m_order << event->type();
return QWindow::event(event);
}
@@ -123,10 +126,32 @@ public:
return m_received.value(type, 0);
}
+ int eventIndex(QEvent::Type type)
+ {
+ return m_order.indexOf(type);
+ }
+
private:
QHash<QEvent::Type, int> m_received;
+ QVector<QEvent::Type> m_order;
};
+void tst_QWindow::eventOrderOnShow()
+{
+ QRect geometry(80, 80, 40, 40);
+
+ Window window;
+ window.setGeometry(geometry);
+ window.show();
+
+ QTRY_COMPARE(window.received(QEvent::Show), 1);
+ QTRY_COMPARE(window.received(QEvent::Resize), 1);
+ QTRY_VERIFY(window.isExposed());
+
+ QVERIFY(window.eventIndex(QEvent::Show) < window.eventIndex(QEvent::Resize));
+ QVERIFY(window.eventIndex(QEvent::Resize) < window.eventIndex(QEvent::Expose));
+}
+
void tst_QWindow::positioning()
{
QRect geometry(80, 80, 40, 40);
@@ -137,7 +162,7 @@ void tst_QWindow::positioning()
window.show();
QTRY_COMPARE(window.received(QEvent::Resize), 1);
- QTRY_COMPARE(window.received(QEvent::Map), 1);
+ QTRY_VERIFY(window.received(QEvent::Expose) > 0);
QMargins originalMargins = window.frameMargins();
@@ -148,6 +173,9 @@ void tst_QWindow::positioning()
QPoint originalFramePos = window.framePos();
window.setWindowState(Qt::WindowFullScreen);
+#ifdef Q_OS_WIN
+ QEXPECT_FAIL("", "QTBUG-24904 - Too many resize events on setting window state", Continue);
+#endif
QTRY_COMPARE(window.received(QEvent::Resize), 2);
window.setWindowState(Qt::WindowNoState);
@@ -179,13 +207,32 @@ void tst_QWindow::positioning()
}
}
+void tst_QWindow::isExposed()
+{
+ QRect geometry(80, 80, 40, 40);
+
+ Window window;
+ window.setGeometry(geometry);
+ QCOMPARE(window.geometry(), geometry);
+ window.show();
+
+ QTRY_VERIFY(window.received(QEvent::Expose) > 0);
+ QTRY_VERIFY(window.isExposed());
+
+ window.hide();
+
+ QTRY_VERIFY(window.received(QEvent::Expose) > 1);
+ QTRY_VERIFY(!window.isExposed());
+}
+
+
void tst_QWindow::isActive()
{
Window window;
window.setGeometry(80, 80, 40, 40);
window.show();
- QTRY_COMPARE(window.received(QEvent::Map), 1);
+ QTRY_VERIFY(window.isExposed());
QTRY_COMPARE(window.received(QEvent::Resize), 1);
QTRY_VERIFY(QGuiApplication::focusWindow() == &window);
QVERIFY(window.isActive());
@@ -195,15 +242,14 @@ void tst_QWindow::isActive()
child.setGeometry(10, 10, 20, 20);
child.show();
- QTRY_COMPARE(child.received(QEvent::Map), 1);
+ QTRY_VERIFY(child.isExposed());
child.requestActivateWindow();
QTRY_VERIFY(QGuiApplication::focusWindow() == &child);
QVERIFY(child.isActive());
- // parent shouldn't receive new map or resize events from child being shown
- QTRY_COMPARE(window.received(QEvent::Map), 1);
+ // parent shouldn't receive new resize events from child being shown
QTRY_COMPARE(window.received(QEvent::Resize), 1);
QTRY_COMPARE(window.received(QEvent::FocusIn), 1);
QTRY_COMPARE(window.received(QEvent::FocusOut), 1);
@@ -219,7 +265,7 @@ void tst_QWindow::isActive()
dialog.requestActivateWindow();
- QTRY_COMPARE(dialog.received(QEvent::Map), 1);
+ QTRY_VERIFY(dialog.isExposed());
QTRY_COMPARE(dialog.received(QEvent::Resize), 1);
QTRY_VERIFY(QGuiApplication::focusWindow() == &dialog);
QVERIFY(dialog.isActive());
diff --git a/tests/auto/widgets/graphicsview/qgraphicsitem/tst_qgraphicsitem.cpp b/tests/auto/widgets/graphicsview/qgraphicsitem/tst_qgraphicsitem.cpp
index 98c3866dd2..639a1f61a9 100644
--- a/tests/auto/widgets/graphicsview/qgraphicsitem/tst_qgraphicsitem.cpp
+++ b/tests/auto/widgets/graphicsview/qgraphicsitem/tst_qgraphicsitem.cpp
@@ -11116,20 +11116,23 @@ void tst_QGraphicsItem::doNotMarkFullUpdateIfNotInScene()
view.showFullScreen();
else
view.show();
- QTest::qWaitForWindowShown(&view);
- QEXPECT_FAIL("", "QTBUG-22434", Abort);
- QTRY_COMPARE(view.repaints, 1);
- QTRY_COMPARE(item->painted, 1);
+ QTest::qWaitForWindowShown(view.windowHandle());
+ view.activateWindow();
+ QTRY_VERIFY(view.isActiveWindow());
+ QTRY_VERIFY(view.repaints >= 1);
+ int count = view.repaints;
+ QTRY_COMPARE(item->painted, count);
+ // cached as graphics effects, not painted multiple times
QTRY_COMPARE(item2->painted, 1);
QTRY_COMPARE(item3->painted, 1);
item2->update();
QApplication::processEvents();
- QTRY_COMPARE(item->painted, 2);
+ QTRY_COMPARE(item->painted, count + 1);
QTRY_COMPARE(item2->painted, 2);
QTRY_COMPARE(item3->painted, 2);
item2->update();
QApplication::processEvents();
- QTRY_COMPARE(item->painted, 3);
+ QTRY_COMPARE(item->painted, count + 2);
QTRY_COMPARE(item2->painted, 3);
QTRY_COMPARE(item3->painted, 3);
}
diff --git a/tests/auto/widgets/graphicsview/qgraphicsscene/tst_qgraphicsscene.cpp b/tests/auto/widgets/graphicsview/qgraphicsscene/tst_qgraphicsscene.cpp
index daa06d0762..d7b1ef9199 100644
--- a/tests/auto/widgets/graphicsview/qgraphicsscene/tst_qgraphicsscene.cpp
+++ b/tests/auto/widgets/graphicsview/qgraphicsscene/tst_qgraphicsscene.cpp
@@ -1078,19 +1078,14 @@ void tst_QGraphicsScene::addItem()
CustomView view;
view.setScene(&scene);
view.show();
-#ifdef Q_WS_X11
- qt_x11_wait_for_window_manager(&view);
-#endif
+ QTest::qWaitForWindowShown(view.windowHandle());
qApp->processEvents();
view.repaints = 0;
scene.addItem(path);
// Adding an item should always issue a repaint.
- qApp->processEvents(); // <- delayed update is called
- qApp->processEvents(); // <- scene schedules pending update
- qApp->processEvents(); // <- pending update is sent to view
- QVERIFY(view.repaints > 0);
+ QTRY_VERIFY(view.repaints > 0);
view.repaints = 0;
QCOMPARE(scene.itemAt(0, 0), path);
@@ -1103,10 +1098,7 @@ void tst_QGraphicsScene::addItem()
scene.addItem(path2);
// Adding an item should always issue a repaint.
- qApp->processEvents(); // <- delayed update is called
- qApp->processEvents(); // <- scene schedules pending update
- qApp->processEvents(); // <- pending update is sent to view
- QVERIFY(view.repaints > 0);
+ QTRY_VERIFY(view.repaints > 0);
QCOMPARE(scene.itemAt(100, 100), path2);
}
@@ -1285,9 +1277,7 @@ void tst_QGraphicsScene::removeItem()
QGraphicsView view(&scene);
view.setFixedSize(150, 150);
view.show();
-#ifdef Q_WS_X11
- qt_x11_wait_for_window_manager(&view);
-#endif
+ QTest::qWaitForWindowShown(view.windowHandle());
QTest::mouseMove(view.viewport(), QPoint(-1, -1));
{
QMouseEvent moveEvent(QEvent::MouseMove, view.mapFromScene(hoverItem->scenePos() + QPointF(20, 20)), Qt::NoButton, 0, 0);
@@ -1615,9 +1605,7 @@ void tst_QGraphicsScene::hoverEvents_siblings()
view.rotate(10);
view.scale(1.7, 1.7);
view.show();
-#ifdef Q_WS_X11
- qt_x11_wait_for_window_manager(&view);
-#endif
+ QTest::qWaitForWindowShown(view.windowHandle());
qApp->setActiveWindow(&view);
view.activateWindow();
QTest::qWait(70);
@@ -2748,11 +2736,8 @@ void tst_QGraphicsScene::contextMenuEvent()
QGraphicsView view(&scene);
view.show();
- QTest::qWaitForWindowShown(&view);
+ QTest::qWaitForWindowShown(view.windowHandle());
view.activateWindow();
-#ifdef Q_WS_X11
- qt_x11_wait_for_window_manager(&view);
-#endif
view.centerOn(item);
{
@@ -2785,10 +2770,7 @@ void tst_QGraphicsScene::contextMenuEvent_ItemIgnoresTransformations()
QGraphicsView view(&scene, &topLevel);
view.resize(200, 200);
topLevel.show();
-#ifdef Q_WS_X11
- qt_x11_wait_for_window_manager(&view);
-#endif
- QTest::qWaitForWindowShown(&topLevel);
+ QTest::qWaitForWindowShown(topLevel.windowHandle());
{
QPoint pos(50, 50);