diff options
Diffstat (limited to 'tests/auto/corelib/kernel/qmimedata')
-rw-r--r-- | tests/auto/corelib/kernel/qmimedata/CMakeLists.txt | 11 | ||||
-rw-r--r-- | tests/auto/corelib/kernel/qmimedata/tst_qmimedata.cpp | 53 |
2 files changed, 33 insertions, 31 deletions
diff --git a/tests/auto/corelib/kernel/qmimedata/CMakeLists.txt b/tests/auto/corelib/kernel/qmimedata/CMakeLists.txt index ec5505d3e0..ba1d5e12cd 100644 --- a/tests/auto/corelib/kernel/qmimedata/CMakeLists.txt +++ b/tests/auto/corelib/kernel/qmimedata/CMakeLists.txt @@ -1,12 +1,19 @@ -# Generated from qmimedata.pro. +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: BSD-3-Clause ##################################################################### ## tst_qmimedata Test: ##################################################################### +if(NOT QT_BUILD_STANDALONE_TESTS AND NOT QT_BUILDING_QT) + cmake_minimum_required(VERSION 3.16) + project(tst_qmimedata LANGUAGES CXX) + find_package(Qt6BuildInternals REQUIRED COMPONENTS STANDALONE_TEST) +endif() + qt_internal_add_test(tst_qmimedata SOURCES tst_qmimedata.cpp - PUBLIC_LIBRARIES + LIBRARIES Qt::Gui ) diff --git a/tests/auto/corelib/kernel/qmimedata/tst_qmimedata.cpp b/tests/auto/corelib/kernel/qmimedata/tst_qmimedata.cpp index 92d745090d..e28a2e98cc 100644 --- a/tests/auto/corelib/kernel/qmimedata/tst_qmimedata.cpp +++ b/tests/auto/corelib/kernel/qmimedata/tst_qmimedata.cpp @@ -1,30 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #include <QTest> @@ -96,13 +71,28 @@ void tst_QMimeData::data() const // set text, verify mimeData.setData("text/plain", "pirates"); QCOMPARE(mimeData.data("text/plain"), QByteArray("pirates")); - QCOMPARE(mimeData.data("text/html").length(), 0); + QCOMPARE(mimeData.data("text/html").size(), 0); + QCOMPARE(mimeData.data("text/markdown").size(), 0); // html time mimeData.setData("text/html", "ninjas"); QCOMPARE(mimeData.data("text/html"), QByteArray("ninjas")); QCOMPARE(mimeData.data("text/plain"), QByteArray("pirates")); // make sure text not damaged QCOMPARE(mimeData.data("text/html"), mimeData.html().toLatin1()); + + // markdown time + mimeData.setData("text/markdown", "vikings"); + QCOMPARE(mimeData.data("text/markdown"), QByteArray("vikings")); + QCOMPARE(mimeData.data("text/html"), QByteArray("ninjas")); + QCOMPARE(mimeData.data("text/plain"), QByteArray("pirates")); + + // URI list + QByteArray list = "https://example.com/\r\nhttps://example.net/\r\nhttps://example.org/\r\n"; + mimeData.setData("text/uri-list", list); + QCOMPARE(mimeData.data("text/uri-list"), list); + + mimeData.setData("text/uri-list", list.chopped(2)); // without the ending CRLF + QCOMPARE(mimeData.data("text/uri-list"), list); } void tst_QMimeData::formats() const @@ -117,6 +107,10 @@ void tst_QMimeData::formats() const mimeData.setData("text/html", "ninjas"); QCOMPARE(mimeData.formats(), QStringList() << "text/plain" << "text/html"); + // set markdown, verify + mimeData.setData("text/markdown", "vikings"); + QCOMPARE(mimeData.formats(), QStringList() << "text/plain" << "text/html" << "text/markdown"); + // clear, verify mimeData.clear(); QCOMPARE(mimeData.formats(), QStringList()); @@ -324,7 +318,8 @@ void tst_QMimeData::setUrls() const QCOMPARE(mimeData.text(), QString("http://qt-project.org\nhttp://www.google.com\n")); // test and verify that setData doesn't corrupt url content - foreach (const QString &format, mimeData.formats()) { + const auto allFormats = mimeData.formats(); + for (const QString &format : allFormats) { QVariant before = mimeData.retrieveData(format, QMetaType(QMetaType::QByteArray)); mimeData.setData(format, mimeData.data(format)); QVariant after = mimeData.retrieveData(format, QMetaType(QMetaType::QByteArray)); |