diff options
author | Bartlomiej Moskal <bartlomiej.moskal@qt.io> | 2023-06-27 09:14:57 +0200 |
---|---|---|
committer | Bartlomiej Moskal <bartlomiej.moskal@qt.io> | 2023-07-12 00:53:58 +0200 |
commit | fdccb66a4e9a8b22c881c4775895b7af174b0b24 (patch) | |
tree | ccc55bf67a9dab229994d0e1914f349a28555e89 /tests/auto/gui | |
parent | 93b87b5cbfae3c50e539f6ec37bd7b95e89e455e (diff) |
Android: Fix for checking clipboard text mime type
Different mime types are widely used on mobile devices. For example all
text copied from gmail is copied as text/html type.
After 2937cf91c74b6562bf56e8872dfd2bfaafebb3cc commit there is a
regression that makes it impossible to paste any text different than
"text/plain".
To fix it, any "text/*" mime type should be treat as it contains a text
(not only "text/plain"). That will allow to paste different text mime
types.
During this work also tst_qclipboard testset was turned on for Android
and new test (getTextFromHTMLMimeType) was added.
Pick-to: 6.6 6.5 6.2
Fixes: QTBUG-113461
Change-Id: I3ef9476b8facdc3b61f144bd55222898390127c9
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
Diffstat (limited to 'tests/auto/gui')
-rw-r--r-- | tests/auto/gui/kernel/CMakeLists.txt | 2 | ||||
-rw-r--r-- | tests/auto/gui/kernel/qclipboard/test/BLACKLIST | 5 | ||||
-rw-r--r-- | tests/auto/gui/kernel/qclipboard/tst_qclipboard.cpp | 21 |
3 files changed, 26 insertions, 2 deletions
diff --git a/tests/auto/gui/kernel/CMakeLists.txt b/tests/auto/gui/kernel/CMakeLists.txt index a178942d5a..5377a04a64 100644 --- a/tests/auto/gui/kernel/CMakeLists.txt +++ b/tests/auto/gui/kernel/CMakeLists.txt @@ -29,7 +29,7 @@ endif() add_subdirectory(qpixelformat) add_subdirectory(qrasterwindow) add_subdirectory(qaddpostroutine) -if(NOT ANDROID AND NOT UIKIT) +if(NOT UIKIT) add_subdirectory(qclipboard) endif() if(TARGET Qt::Network) 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/tst_qclipboard.cpp b/tests/auto/gui/kernel/qclipboard/tst_qclipboard.cpp index 0b694bff73..520233bf69 100644 --- a/tests/auto/gui/kernel/qclipboard/tst_qclipboard.cpp +++ b/tests/auto/gui/kernel/qclipboard/tst_qclipboard.cpp @@ -41,6 +41,7 @@ private slots: void testSignals(); void setMimeData(); void clearBeforeSetText(); + void getTextFromHTMLMimeType(); # ifdef Q_OS_WIN void testWindowsMimeRegisterType(); void testWindowsMime_data(); @@ -61,7 +62,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 @@ -424,6 +425,24 @@ 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 QWindowsMimeConverter = QWindowsMimeConverter; |