diff options
Diffstat (limited to 'tests/auto/gui')
-rw-r--r-- | tests/auto/gui/image/qimage/images/jpeg_exif_utf8_comment.jpg | bin | 0 -> 705 bytes | |||
-rw-r--r-- | tests/auto/gui/image/qimage/tst_qimage.cpp | 29 | ||||
-rw-r--r-- | tests/auto/gui/image/qpixmap/tst_qpixmap.cpp | 22 | ||||
-rw-r--r-- | tests/auto/gui/kernel/qwindow/tst_qwindow.cpp | 55 |
4 files changed, 103 insertions, 3 deletions
diff --git a/tests/auto/gui/image/qimage/images/jpeg_exif_utf8_comment.jpg b/tests/auto/gui/image/qimage/images/jpeg_exif_utf8_comment.jpg Binary files differnew file mode 100644 index 0000000000..42b305f5b8 --- /dev/null +++ b/tests/auto/gui/image/qimage/images/jpeg_exif_utf8_comment.jpg diff --git a/tests/auto/gui/image/qimage/tst_qimage.cpp b/tests/auto/gui/image/qimage/tst_qimage.cpp index 7ad4a9e9bb..55a670eb6f 100644 --- a/tests/auto/gui/image/qimage/tst_qimage.cpp +++ b/tests/auto/gui/image/qimage/tst_qimage.cpp @@ -192,6 +192,7 @@ private slots: void exif_QTBUG45865(); void exifInvalidData_data(); void exifInvalidData(); + void exifReadComments(); void cleanupFunctions(); @@ -3066,6 +3067,34 @@ void tst_QImage::exifInvalidData() QVERIFY(!image.isNull()); } +void tst_QImage::exifReadComments() +{ + QImage image; + QVERIFY(image.load(m_prefix + "jpeg_exif_utf8_comment.jpg")); + QVERIFY(!image.isNull()); + QCOMPARE(image.textKeys().size(), 1); + QCOMPARE(image.textKeys().first(), "Description"); + // check if exif comment is read as utf-8 + QCOMPARE(image.text("Description"), QString::fromUtf8("some unicode chars: ÖÄÜ€@")); + + QByteArray ba; + { + QBuffer buf(&ba); + QVERIFY(buf.open(QIODevice::WriteOnly)); + QVERIFY(image.save(&buf, "JPG")); + } + QVERIFY(!ba.isEmpty()); + image = QImage(); + QCOMPARE(image.textKeys().size(), 0); + { + QBuffer buf(&ba); + QVERIFY(buf.open(QIODevice::ReadOnly)); + QVERIFY(image.load(&buf, "JPG")); + } + // compare written (and reread) description text + QCOMPARE(image.text("Description"), QString::fromUtf8("some unicode chars: ÖÄÜ€@")); +} + static void cleanupFunction(void* info) { bool *called = static_cast<bool*>(info); diff --git a/tests/auto/gui/image/qpixmap/tst_qpixmap.cpp b/tests/auto/gui/image/qpixmap/tst_qpixmap.cpp index e3bda6c2df..9a338ad55a 100644 --- a/tests/auto/gui/image/qpixmap/tst_qpixmap.cpp +++ b/tests/auto/gui/image/qpixmap/tst_qpixmap.cpp @@ -90,6 +90,7 @@ private slots: void mask(); void bitmapMask(); + void bitmapFromImageRvalue(); void setGetMask_data(); void setGetMask(); void cacheKey(); @@ -596,6 +597,27 @@ void tst_QPixmap::bitmapMask() QVERIFY(image.pixel(1, 1)); } +void tst_QPixmap::bitmapFromImageRvalue() +{ + auto makeImage = [](){ + QImage image(3, 3, QImage::Format_MonoLSB); + image.setColor(0, Qt::color0); + image.setColor(1, Qt::color1); + image.fill(Qt::color0); + image.setPixel(1, 1, Qt::color1); + image.setPixel(0, 0, Qt::color1); + return image; + }; + + auto image1 = makeImage(); + auto image2 = makeImage(); + auto bitmap1 = QBitmap::fromImage(image1); + auto bitmap2 = QBitmap::fromImage(std::move(image2)); + QCOMPARE(bitmap1.toImage(), bitmap2.toImage()); + QVERIFY(!image1.isNull()); + QVERIFY(image2.isNull()); +} + void tst_QPixmap::setGetMask_data() { QTest::addColumn<QPixmap>("pixmap"); diff --git a/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp b/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp index 5a87ae6067..4fe2e769e7 100644 --- a/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp +++ b/tests/auto/gui/kernel/qwindow/tst_qwindow.cpp @@ -97,6 +97,7 @@ private slots: void modalWindowPosition(); #ifndef QT_NO_CURSOR void modalWindowEnterEventOnHide_QTBUG35109(); + void spuriousMouseMove(); #endif void windowsTransientChildren(); void requestUpdate(); @@ -892,7 +893,7 @@ void tst_QWindow::isActive() QVERIFY(child.isActive()); } -class InputTestWindow : public QWindow +class InputTestWindow : public ColoredWindow { public: void keyPressEvent(QKeyEvent *event) { @@ -986,7 +987,9 @@ public: enterEventCount = leaveEventCount = 0; } - InputTestWindow() { + explicit InputTestWindow(const QColor &color = Qt::white, QWindow *parent = nullptr) + : ColoredWindow(color, parent) + { keyPressCode = keyReleaseCode = 0; mousePressButton = mouseReleaseButton = mouseMoveButton = 0; ignoreMouse = ignoreTouch = false; @@ -2210,7 +2213,53 @@ void tst_QWindow::modalWindowEnterEventOnHide_QTBUG35109() QTRY_COMPARE(root.enterEventCount, 1); } } -#endif + +// Verify that no spurious mouse move events are received. On Windows, there is +// no enter event, the OS sends mouse move events instead. Test that the QPA +// plugin properly suppresses those since they can interfere with tests. +// Simulate a main window setup with a modal dialog on top, keep the cursor +// in the center and check that no mouse events are recorded. +void tst_QWindow::spuriousMouseMove() +{ + const QString &platformName = QGuiApplication::platformName(); + if (platformName == QLatin1String("offscreen") || platformName == QLatin1String("cocoa")) + QSKIP("No enter events sent"); + if (isPlatformWayland()) + QSKIP("QCursor::setPos() is not supported on Wayland"); + const QRect screenGeometry = QGuiApplication::primaryScreen()->geometry(); + const QPoint center = screenGeometry.center(); + QCursor::setPos(center); + QRect windowGeometry(QPoint(), 2 * m_testWindowSize); + windowGeometry.moveCenter(center); + QTRY_COMPARE(QCursor::pos(), center); + InputTestWindow topLevel; + topLevel.setTitle(QTest::currentTestFunction()); + topLevel.setGeometry(windowGeometry); + topLevel.show(); + QVERIFY(QTest::qWaitForWindowExposed(&topLevel)); + QTRY_VERIFY(topLevel.enterEventCount > 0); + InputTestWindow dialog(Qt::yellow); + dialog.setTransientParent(&topLevel); + dialog.setTitle("Dialog " + topLevel.title()); + dialog.setModality(Qt::ApplicationModal); + windowGeometry.setSize(m_testWindowSize); + windowGeometry.moveCenter(center); + dialog.setGeometry(windowGeometry); + dialog.show(); + QVERIFY(QTest::qWaitForWindowExposed(&dialog)); + QTRY_VERIFY(dialog.enterEventCount > 0); + dialog.setVisible(false); + QCOMPARE(dialog.mousePressedCount, 0); + QCOMPARE(dialog.mouseReleasedCount, 0); + QCOMPARE(dialog.mouseMovedCount, 0); + QCOMPARE(dialog.mouseDoubleClickedCount, 0); + topLevel.setVisible(false); + QCOMPARE(topLevel.mousePressedCount, 0); + QCOMPARE(topLevel.mouseReleasedCount, 0); + QCOMPARE(topLevel.mouseMovedCount, 0); + QCOMPARE(topLevel.mouseDoubleClickedCount, 0); +} +#endif // !QT_NO_CURSOR static bool isNativeWindowVisible(const QWindow *window) { |