mirror of
https://github.com/crystalidea/qt6windows7.git
synced 2025-07-06 01:05:23 +08:00
qt 6.5.1 original
This commit is contained in:
16
tests/auto/gui/kernel/qclipboard/paster/CMakeLists.txt
Normal file
16
tests/auto/gui/kernel/qclipboard/paster/CMakeLists.txt
Normal file
@ -0,0 +1,16 @@
|
||||
# Copyright (C) 2022 The Qt Company Ltd.
|
||||
# SPDX-License-Identifier: BSD-3-Clause
|
||||
|
||||
#####################################################################
|
||||
## paster Binary:
|
||||
#####################################################################
|
||||
|
||||
set(args OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}")
|
||||
|
||||
qt_internal_add_executable(paster
|
||||
${args}
|
||||
SOURCES
|
||||
main.cpp
|
||||
LIBRARIES
|
||||
Qt::Gui
|
||||
)
|
56
tests/auto/gui/kernel/qclipboard/paster/main.cpp
Normal file
56
tests/auto/gui/kernel/qclipboard/paster/main.cpp
Normal file
@ -0,0 +1,56 @@
|
||||
// Copyright (C) 2016 The Qt Company Ltd.
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
||||
#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);
|
||||
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
|
||||
// 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;
|
||||
}
|
||||
|
||||
QString expected;
|
||||
if (parser.isSet(textOption))
|
||||
expected = parser.value(textOption);
|
||||
if (!expected.isEmpty()) {
|
||||
#ifndef QT_NO_CLIPBOARD
|
||||
const QString actual = QGuiApplication::clipboard()->text();
|
||||
#else
|
||||
const QString actual;
|
||||
#endif
|
||||
return actual == expected ? 0 : 1;
|
||||
}
|
||||
return -2;
|
||||
}
|
Reference in New Issue
Block a user