diff options
author | Friedemann Kleint <Friedemann.Kleint@digia.com> | 2014-07-01 12:21:03 +0200 |
---|---|---|
committer | Friedemann Kleint <Friedemann.Kleint@digia.com> | 2014-07-03 22:43:17 +0200 |
commit | 9150563940f61be9fb17510be49c0734244866a5 (patch) | |
tree | ebbd771a825f6a9d3912f023c2ed9e259c6d8ecd /tests/auto/gui/kernel/qclipboard/paster/main.cpp | |
parent | 71c58f036957fdda4012703c6de7891c20455242 (diff) |
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 <joerg.bornemann@digia.com>
Diffstat (limited to 'tests/auto/gui/kernel/qclipboard/paster/main.cpp')
-rw-r--r-- | tests/auto/gui/kernel/qclipboard/paster/main.cpp | 55 |
1 files changed, 47 insertions, 8 deletions
diff --git a/tests/auto/gui/kernel/qclipboard/paster/main.cpp b/tests/auto/gui/kernel/qclipboard/paster/main.cpp index 0dd7dd87af..3fd4267598 100644 --- a/tests/auto/gui/kernel/qclipboard/paster/main.cpp +++ b/tests/auto/gui/kernel/qclipboard/paster/main.cpp @@ -40,20 +40,59 @@ ****************************************************************************/ #include <QtGui/QGuiApplication> #include <QtGui/QClipboard> +#include <QtGui/QImage> +#include <QtGui/QColor> #include <QtCore/QStringList> +#include <QtCore/QCommandLineParser> int main(int argc, char **argv) { QGuiApplication app(argc, argv); - QString expected = QStringLiteral("testString.!"); -#ifndef Q_OS_WINCE - const QStringList arguments = app.arguments(); - if (arguments.size() > 1) - expected = arguments.at(1); + QCommandLineParser parser; + parser.addHelpOption(); + QCommandLineOption textOption(QStringLiteral("text"), + QStringLiteral("Text to compare"), + QStringLiteral("text")); + parser.addOption(textOption); + QCommandLineOption imageOption(QStringLiteral("image"), + QStringLiteral("Perform image check")); + parser.addOption(imageOption); + parser.process(QCoreApplication::arguments()); + + if (parser.isSet(imageOption)) { +#ifndef QT_NO_CLIPBOARD + const QImage actual = QGuiApplication::clipboard()->image(); +#else + const QImage actual; #endif - QString actual; + // Perform hard-coded checks on copied image (size, pixel 0,0: transparent, + // pixel 1,0: blue). Note: Windows sets RGB of transparent to 0xFF when converting + // to DIB5. + if (actual.size() != QSize(100, 100)) + return 1; + const QRgb pixel00 = actual.pixel(QPoint(0, 0)); + if (qAlpha(pixel00)) + return 2; + const QRgb pixel01 = actual.pixel(QPoint(1, 0)); + if (pixel01 != QColor(Qt::blue).rgba()) + return 3; + return 0; + } + +#ifndef Q_OS_WINCE + QString expected; + if (parser.isSet(textOption)) + expected = parser.value(textOption); +#else // !Q_OS_WINCE + const QString expected = QStringLiteral("testString.!"); +#endif // Q_OS_WINCE + if (!expected.isEmpty()) { #ifndef QT_NO_CLIPBOARD - actual = QGuiApplication::clipboard()->text(); + const QString actual = QGuiApplication::clipboard()->text(); +#else + const QString actual; #endif - return actual == expected ? 0 : 1; + return actual == expected ? 0 : 1; + } + return -2; } |