From 9150563940f61be9fb17510be49c0734244866a5 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Tue, 1 Jul 2014 12:21:03 +0200 Subject: Windows clipboard: Deny CF_DIB support for images with alpha. Support CF_DIBV5 for these images so that transparency is preserved. Task-number: QTBUG-11463 Change-Id: I51881ae8bfbd05b92abd309766f4da9a7ea26c2d Reviewed-by: Joerg Bornemann --- .../auto/gui/kernel/qclipboard/tst_qclipboard.cpp | 33 ++++++++++++++++++++-- 1 file changed, 30 insertions(+), 3 deletions(-) (limited to 'tests/auto/gui/kernel/qclipboard/tst_qclipboard.cpp') diff --git a/tests/auto/gui/kernel/qclipboard/tst_qclipboard.cpp b/tests/auto/gui/kernel/qclipboard/tst_qclipboard.cpp index 8a2009a601..b677ee1ea4 100644 --- a/tests/auto/gui/kernel/qclipboard/tst_qclipboard.cpp +++ b/tests/auto/gui/kernel/qclipboard/tst_qclipboard.cpp @@ -46,6 +46,8 @@ #include #include #include +#include +#include #include "../../../shared/platformclipboard.h" class tst_QClipboard : public QObject @@ -59,6 +61,7 @@ private slots: void init(); #if defined(Q_OS_WIN) || defined(Q_OS_MAC) || defined(Q_OS_QNX) void copy_exit_paste(); + void copyImage(); #endif void capabilityFunctions(); void modes(); @@ -278,18 +281,42 @@ void tst_QClipboard::copy_exit_paste() // ### It's still possible to test copy/paste - just keep the apps running if (!PlatformClipboard::isAvailable()) QSKIP("Native clipboard not working in this setup"); - const QStringList stringArgument(QStringLiteral("Test string.")); + const QString stringArgument(QStringLiteral("Test string.")); QByteArray errorMessage; - QVERIFY2(runHelper(QStringLiteral("copier/copier"), stringArgument, &errorMessage), + QVERIFY2(runHelper(QStringLiteral("copier/copier"), QStringList(stringArgument), &errorMessage), errorMessage.constData()); #ifdef Q_OS_MAC // The Pasteboard needs a moment to breathe (at least on older Macs). QTest::qWait(100); #endif // Q_OS_MAC - QVERIFY2(runHelper(QStringLiteral("paster/paster"), stringArgument, &errorMessage), + QVERIFY2(runHelper(QStringLiteral("paster/paster"), + QStringList() << QStringLiteral("--text") << stringArgument, + &errorMessage), errorMessage.constData()); #endif // QT_NO_PROCESS } + +void tst_QClipboard::copyImage() +{ +#ifndef QT_NO_PROCESS + if (!PlatformClipboard::isAvailable()) + QSKIP("Native clipboard not working in this setup"); + QImage image(100, 100, QImage::Format_ARGB32); + image.fill(QColor(Qt::transparent)); + image.setPixel(QPoint(1, 0), QColor(Qt::blue).rgba()); + QGuiApplication::clipboard()->setImage(image); +#ifdef Q_OS_OSX + // The Pasteboard needs a moment to breathe (at least on older Macs). + QTest::qWait(100); +#endif // Q_OS_OSX + // paster will perform hard-coded checks on the copied image. + QByteArray errorMessage; + QVERIFY2(runHelper(QStringLiteral("paster/paster"), + QStringList(QStringLiteral("--image")), &errorMessage), + errorMessage.constData()); +#endif // QT_NO_PROCESS +} + #endif // Q_OS_WIN || Q_OS_MAC || Q_OS_QNX void tst_QClipboard::setMimeData() -- cgit v1.2.3