diff options
author | Gunnar Sletta <gunnar@sletta.org> | 2015-10-15 15:21:17 +0200 |
---|---|---|
committer | Gunnar Sletta <gunnar@sletta.org> | 2015-10-16 10:42:06 +0000 |
commit | cac24aee6c799cf6fb8a9b19c825ae77502af18b (patch) | |
tree | 3c5b9a443cf3d0a06d41510a68ba4a7bc4a897dc /tests/auto | |
parent | f1b169293b75cd85b75747b5f5e2b95461c279cf (diff) |
Support alpha in QQuickWindow::grabWindow().
Change-Id: I2dd69745427d8f5e882303d2a4de3935ddca02e9
Task-number: QTBUG-48787
Reviewed-by: Laszlo Agocs <laszlo.agocs@theqtcompany.com>
Diffstat (limited to 'tests/auto')
-rw-r--r-- | tests/auto/quick/qquickwindow/tst_qquickwindow.cpp | 29 |
1 files changed, 23 insertions, 6 deletions
diff --git a/tests/auto/quick/qquickwindow/tst_qquickwindow.cpp b/tests/auto/quick/qquickwindow/tst_qquickwindow.cpp index e1ea068a62..f53ade9541 100644 --- a/tests/auto/quick/qquickwindow/tst_qquickwindow.cpp +++ b/tests/auto/quick/qquickwindow/tst_qquickwindow.cpp @@ -277,6 +277,10 @@ class tst_qquickwindow : public QQmlDataTest { Q_OBJECT public: + tst_qquickwindow() + { + QQuickWindow::setDefaultAlphaBuffer(true); + } private slots: void initTestCase() @@ -1081,17 +1085,25 @@ void tst_qquickwindow::defaultState() void tst_qquickwindow::grab_data() { QTest::addColumn<bool>("visible"); - QTest::newRow("visible") << true; - QTest::newRow("invisible") << false; + QTest::addColumn<bool>("alpha"); + QTest::newRow("visible,opaque") << true << false; + QTest::newRow("invisible,opaque") << false << false; + QTest::newRow("visible,transparent") << true << true; + QTest::newRow("invisible,transparent") << false << true; } void tst_qquickwindow::grab() { QFETCH(bool, visible); + QFETCH(bool, alpha); QQuickWindow window; window.setTitle(QLatin1String(QTest::currentTestFunction()) + QLatin1Char(' ') + QLatin1String(QTest::currentDataTag())); - window.setColor(Qt::red); + if (alpha) { + window.setColor(QColor(0, 0, 0, 0)); + } else { + window.setColor(Qt::red); + } window.resize(250, 250); @@ -1103,9 +1115,14 @@ void tst_qquickwindow::grab() } QImage content = window.grabWindow(); - QCOMPARE(content.width(), window.width()); - QCOMPARE(content.height(), window.height()); - QCOMPARE((uint) content.convertToFormat(QImage::Format_RGB32).pixel(0, 0), (uint) 0xffff0000); + QCOMPARE(content.width(), int(window.width() * window.devicePixelRatio())); + QCOMPARE(content.height(), int(window.height() * window.devicePixelRatio())); + + if (alpha) { + QCOMPARE((uint) content.convertToFormat(QImage::Format_ARGB32_Premultiplied).pixel(0, 0), (uint) 0x00000000); + } else { + QCOMPARE((uint) content.convertToFormat(QImage::Format_RGB32).pixel(0, 0), (uint) 0xffff0000); + } } void tst_qquickwindow::multipleWindows() |