diff options
Diffstat (limited to 'tests/auto/gui/kernel/qclipboard')
8 files changed, 66 insertions, 60 deletions
diff --git a/tests/auto/gui/kernel/qclipboard/CMakeLists.txt b/tests/auto/gui/kernel/qclipboard/CMakeLists.txt index c779174136..b7a0467758 100644 --- a/tests/auto/gui/kernel/qclipboard/CMakeLists.txt +++ b/tests/auto/gui/kernel/qclipboard/CMakeLists.txt @@ -1,7 +1,11 @@ # Copyright (C) 2022 The Qt Company Ltd. # SPDX-License-Identifier: BSD-3-Clause -# Generated from qclipboard.pro. +if(NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT) + cmake_minimum_required(VERSION 3.16) + project(tst_qclipboard LANGUAGES CXX) + find_package(Qt6BuildInternals REQUIRED COMPONENTS STANDALONE_TEST) +endif() add_subdirectory(copier) add_subdirectory(paster) diff --git a/tests/auto/gui/kernel/qclipboard/copier/CMakeLists.txt b/tests/auto/gui/kernel/qclipboard/copier/CMakeLists.txt index 8ec9889037..ea7def8c0d 100644 --- a/tests/auto/gui/kernel/qclipboard/copier/CMakeLists.txt +++ b/tests/auto/gui/kernel/qclipboard/copier/CMakeLists.txt @@ -1,26 +1,16 @@ # Copyright (C) 2022 The Qt Company Ltd. # SPDX-License-Identifier: BSD-3-Clause -# Generated from copier.pro. - ##################################################################### ## copier Binary: ##################################################################### -# special case begin set(args OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}") -# special case end qt_internal_add_executable(copier - ${args} # special case + ${args} SOURCES main.cpp LIBRARIES Qt::Gui ) - -## Scopes: -##################################################################### - -#### Keys ignored in scope 2:.:.:copier.pro:WIN32: -# DESTDIR = "../copier" diff --git a/tests/auto/gui/kernel/qclipboard/copier/main.cpp b/tests/auto/gui/kernel/qclipboard/copier/main.cpp index 411ac1e00e..362ede38b7 100644 --- a/tests/auto/gui/kernel/qclipboard/copier/main.cpp +++ b/tests/auto/gui/kernel/qclipboard/copier/main.cpp @@ -1,5 +1,5 @@ // Copyright (C) 2016 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #include <QtGui/QGuiApplication> #include <QtGui/QClipboard> #include <QtCore/QStringList> diff --git a/tests/auto/gui/kernel/qclipboard/paster/CMakeLists.txt b/tests/auto/gui/kernel/qclipboard/paster/CMakeLists.txt index 1f6f2bd221..9bc1985ee4 100644 --- a/tests/auto/gui/kernel/qclipboard/paster/CMakeLists.txt +++ b/tests/auto/gui/kernel/qclipboard/paster/CMakeLists.txt @@ -1,26 +1,16 @@ # Copyright (C) 2022 The Qt Company Ltd. # SPDX-License-Identifier: BSD-3-Clause -# Generated from paster.pro. - ##################################################################### ## paster Binary: ##################################################################### -# special case begin set(args OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}") -# special case end qt_internal_add_executable(paster - ${args} # special case + ${args} SOURCES main.cpp LIBRARIES Qt::Gui ) - -## Scopes: -##################################################################### - -#### Keys ignored in scope 2:.:.:paster.pro:WIN32: -# DESTDIR = "../paster" diff --git a/tests/auto/gui/kernel/qclipboard/paster/main.cpp b/tests/auto/gui/kernel/qclipboard/paster/main.cpp index 06db447569..bf47b10ba6 100644 --- a/tests/auto/gui/kernel/qclipboard/paster/main.cpp +++ b/tests/auto/gui/kernel/qclipboard/paster/main.cpp @@ -1,5 +1,5 @@ // Copyright (C) 2016 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #include <QtGui/QGuiApplication> #include <QtGui/QClipboard> #include <QtGui/QImage> diff --git a/tests/auto/gui/kernel/qclipboard/test/BLACKLIST b/tests/auto/gui/kernel/qclipboard/test/BLACKLIST new file mode 100644 index 0000000000..3ca7791b37 --- /dev/null +++ b/tests/auto/gui/kernel/qclipboard/test/BLACKLIST @@ -0,0 +1,5 @@ +# QTBUG-87429 +[testSignals] +android +[setMimeData] +android diff --git a/tests/auto/gui/kernel/qclipboard/test/CMakeLists.txt b/tests/auto/gui/kernel/qclipboard/test/CMakeLists.txt index aef88e9346..fad30c16fd 100644 --- a/tests/auto/gui/kernel/qclipboard/test/CMakeLists.txt +++ b/tests/auto/gui/kernel/qclipboard/test/CMakeLists.txt @@ -1,8 +1,6 @@ # Copyright (C) 2022 The Qt Company Ltd. # SPDX-License-Identifier: BSD-3-Clause -# Generated from test.pro. - ##################################################################### ## tst_qclipboard Test: ##################################################################### @@ -24,5 +22,4 @@ qt_internal_extend_target(tst_qclipboard CONDITION MACOS ${FWAppKit} ) -#### Keys ignored in scope 6:.:.:test.pro:NOT ANDROID: # TEST_HELPER_INSTALLS = "../copier/copier" "../paster/paster" diff --git a/tests/auto/gui/kernel/qclipboard/tst_qclipboard.cpp b/tests/auto/gui/kernel/qclipboard/tst_qclipboard.cpp index 4163d072e0..30366c6aa1 100644 --- a/tests/auto/gui/kernel/qclipboard/tst_qclipboard.cpp +++ b/tests/auto/gui/kernel/qclipboard/tst_qclipboard.cpp @@ -1,5 +1,5 @@ // Copyright (C) 2016 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #include <QTest> @@ -21,8 +21,9 @@ #ifdef Q_OS_WIN # include <QtGui/private/qguiapplication_p.h> -# include <QtGui/private/qwindowsmime_p.h> +# include <QtGui/qwindowsmimeconverter.h> # include <QtGui/qpa/qplatformintegration.h> +# include <QtCore/qt_windows.h> #endif class tst_QClipboard : public QObject @@ -41,6 +42,7 @@ private slots: void testSignals(); void setMimeData(); void clearBeforeSetText(); + void getTextFromHTMLMimeType(); # ifdef Q_OS_WIN void testWindowsMimeRegisterType(); void testWindowsMime_data(); @@ -61,7 +63,7 @@ void tst_QClipboard::initTestCase() #if QT_CONFIG(clipboard) void tst_QClipboard::init() { -#if QT_CONFIG(process) +#if QT_CONFIG(process) && !defined(Q_OS_ANDROID) const QString testdataDir = QFileInfo(QFINDTESTDATA("copier")).absolutePath(); QVERIFY2(QDir::setCurrent(testdataDir), qPrintable("Could not chdir to " + testdataDir)); #endif @@ -124,7 +126,7 @@ public: operator bool() const { - if (m_timer.elapsed() && !m_spy.count()) + if (m_timer.elapsed() && !m_spy.size()) return true; m_spy.clear(); return false; @@ -166,11 +168,11 @@ void tst_QClipboard::testSignals() // Test the default mode signal. clipboard->setText(text); - QTRY_COMPARE(dataChangedSpy.count(), 1); - QCOMPARE(searchChangedSpy.count(), 0); - QCOMPARE(selectionChangedSpy.count(), 0); - QCOMPARE(changedSpy.count(), 1); - QCOMPARE(changedSpy.at(0).count(), 1); + QTRY_COMPARE(dataChangedSpy.size(), 1); + QCOMPARE(searchChangedSpy.size(), 0); + QCOMPARE(selectionChangedSpy.size(), 0); + QCOMPARE(changedSpy.size(), 1); + QCOMPARE(changedSpy.at(0).size(), 1); QCOMPARE(qvariant_cast<QClipboard::Mode>(changedSpy.at(0).at(0)), QClipboard::Clipboard); changedSpy.clear(); @@ -178,29 +180,29 @@ void tst_QClipboard::testSignals() // Test the selection mode signal. if (clipboard->supportsSelection()) { clipboard->setText(text, QClipboard::Selection); - QCOMPARE(selectionChangedSpy.count(), 1); - QCOMPARE(changedSpy.count(), 1); - QCOMPARE(changedSpy.at(0).count(), 1); + QCOMPARE(selectionChangedSpy.size(), 1); + QCOMPARE(changedSpy.size(), 1); + QCOMPARE(changedSpy.at(0).size(), 1); QCOMPARE(qvariant_cast<QClipboard::Mode>(changedSpy.at(0).at(0)), QClipboard::Selection); } else { - QCOMPARE(selectionChangedSpy.count(), 0); + QCOMPARE(selectionChangedSpy.size(), 0); } - QCOMPARE(dataChangedSpy.count(), 1); - QCOMPARE(searchChangedSpy.count(), 0); + QCOMPARE(dataChangedSpy.size(), 1); + QCOMPARE(searchChangedSpy.size(), 0); changedSpy.clear(); // Test the search mode signal. if (clipboard->supportsFindBuffer()) { clipboard->setText(text, QClipboard::FindBuffer); - QCOMPARE(searchChangedSpy.count(), 1); - QCOMPARE(changedSpy.count(), 1); - QCOMPARE(changedSpy.at(0).count(), 1); + QCOMPARE(searchChangedSpy.size(), 1); + QCOMPARE(changedSpy.size(), 1); + QCOMPARE(changedSpy.at(0).size(), 1); QCOMPARE(qvariant_cast<QClipboard::Mode>(changedSpy.at(0).at(0)), QClipboard::FindBuffer); } else { - QCOMPARE(searchChangedSpy.count(), 0); + QCOMPARE(searchChangedSpy.size(), 0); } - QCOMPARE(dataChangedSpy.count(), 1); + QCOMPARE(dataChangedSpy.size(), 1); } #if defined(Q_OS_WIN) || defined(Q_OS_MAC) || defined(Q_OS_QNX) @@ -340,16 +342,16 @@ void tst_QClipboard::setMimeData() QGuiApplication::clipboard()->clear(QClipboard::FindBuffer); if (QGuiApplication::clipboard()->supportsSelection()) - QCOMPARE(spySelection.count(), 1); + QCOMPARE(spySelection.size(), 1); else - QCOMPARE(spySelection.count(), 0); + QCOMPARE(spySelection.size(), 0); if (QGuiApplication::clipboard()->supportsFindBuffer()) - QCOMPARE(spyFindBuffer.count(), 1); + QCOMPARE(spyFindBuffer.size(), 1); else - QCOMPARE(spyFindBuffer.count(), 0); + QCOMPARE(spyFindBuffer.size(), 0); - QTRY_COMPARE(spyData.count(), 1); + QTRY_COMPARE(spyData.size(), 1); // an other crash test data = new QMimeData; @@ -376,16 +378,16 @@ void tst_QClipboard::setMimeData() QGuiApplication::clipboard()->setMimeData(newData, QClipboard::FindBuffer); if (QGuiApplication::clipboard()->supportsSelection()) - QCOMPARE(spySelection.count(), 1); + QCOMPARE(spySelection.size(), 1); else - QCOMPARE(spySelection.count(), 0); + QCOMPARE(spySelection.size(), 0); if (QGuiApplication::clipboard()->supportsFindBuffer()) - QCOMPARE(spyFindBuffer.count(), 1); + QCOMPARE(spyFindBuffer.size(), 1); else - QCOMPARE(spyFindBuffer.count(), 0); + QCOMPARE(spyFindBuffer.size(), 0); - QTRY_COMPARE(spyData.count(), 1); + QTRY_COMPARE(spyData.size(), 1); } void tst_QClipboard::clearBeforeSetText() @@ -424,12 +426,30 @@ void tst_QClipboard::clearBeforeSetText() QCOMPARE(QGuiApplication::clipboard()->text(), text); } +void tst_QClipboard::getTextFromHTMLMimeType() +{ + QClipboard * clipboard = QGuiApplication::clipboard(); + QMimeData * mimeData = new QMimeData(); + const QString testString("TEST"); + const QString htmlString(QLatin1String("<html><body>") + testString + QLatin1String("</body></html>")); + + mimeData->setText(testString); + mimeData->setHtml(htmlString); + clipboard->setMimeData(mimeData); + + QCOMPARE(clipboard->text(), testString); + QVERIFY(clipboard->mimeData()->hasText()); + QVERIFY(clipboard->mimeData()->hasHtml()); + QCOMPARE(clipboard->mimeData()->text(), testString); + QCOMPARE(clipboard->mimeData()->html(), htmlString); +} + # ifdef Q_OS_WIN -using QWindowsMime = QNativeInterface::Private::QWindowsMime; +using QWindowsMimeConverter = QWindowsMimeConverter; using QWindowsApplication = QNativeInterface::Private::QWindowsApplication; -class TestMime : public QWindowsMime +class TestMime : public QWindowsMimeConverter { public: bool canConvertFromMime(const FORMATETC &, const QMimeData *) const override |