aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/quick/qquickwindow/tst_qquickwindow.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/quick/qquickwindow/tst_qquickwindow.cpp')
-rw-r--r--tests/auto/quick/qquickwindow/tst_qquickwindow.cpp35
1 files changed, 35 insertions, 0 deletions
diff --git a/tests/auto/quick/qquickwindow/tst_qquickwindow.cpp b/tests/auto/quick/qquickwindow/tst_qquickwindow.cpp
index edfe487c5e..8d1fd7c0ba 100644
--- a/tests/auto/quick/qquickwindow/tst_qquickwindow.cpp
+++ b/tests/auto/quick/qquickwindow/tst_qquickwindow.cpp
@@ -446,6 +446,7 @@ private slots:
void grab_data();
void grab();
+ void earlyGrab();
void multipleWindows();
void animationsWhileHidden();
@@ -1564,6 +1565,40 @@ void tst_qquickwindow::grab()
}
}
+class Grabber : public QObject
+{
+ Q_OBJECT
+public:
+ Q_INVOKABLE void grab(QObject *obj) {
+ QQuickWindow *window = qobject_cast<QQuickWindow *>(obj);
+ images.append(window->grabWindow());
+ }
+ QVector<QImage> images;
+};
+
+void tst_qquickwindow::earlyGrab()
+{
+ if ((QGuiApplication::platformName() == QLatin1String("offscreen"))
+ || (QGuiApplication::platformName() == QLatin1String("minimal")))
+ QSKIP("Skipping due to grabWindow not functional on offscreen/minimal platforms");
+
+ qmlRegisterType<Grabber>("Test", 1, 0, "Grabber");
+ QQmlEngine engine;
+ QQmlComponent component(&engine);
+ component.loadUrl(testFileUrl("earlyGrab.qml"));
+ QScopedPointer<QQuickWindow> window(qobject_cast<QQuickWindow *>(component.create()));
+ QVERIFY(!window.isNull());
+ window->setTitle(QTest::currentTestFunction());
+
+ QVERIFY(QTest::qWaitForWindowExposed(window.data()));
+
+ Grabber *grabber = qobject_cast<Grabber *>(window->findChild<QObject *>("grabber"));
+ QVERIFY(grabber);
+ QCOMPARE(grabber->images.count(), 1);
+ QVERIFY(!grabber->images[0].isNull());
+ QCOMPARE(grabber->images[0].convertToFormat(QImage::Format_RGBX8888).pixel(10, 20), QColor(Qt::red).rgb());
+}
+
void tst_qquickwindow::multipleWindows()
{
QList<QQuickWindow *> windows;