diff options
Diffstat (limited to 'tests/manual/corelib')
27 files changed, 710 insertions, 162 deletions
diff --git a/tests/manual/corelib/CMakeLists.txt b/tests/manual/corelib/CMakeLists.txt new file mode 100644 index 0000000000..8ed7441e77 --- /dev/null +++ b/tests/manual/corelib/CMakeLists.txt @@ -0,0 +1,6 @@ +# Copyright (C) 2023 The Qt Company Ltd. +# SPDX-License-Identifier: BSD-3-Clause + +add_subdirectory(qdatastream) +add_subdirectory(time) +add_subdirectory(tools) diff --git a/tests/manual/corelib/qdatastream/CMakeLists.txt b/tests/manual/corelib/qdatastream/CMakeLists.txt new file mode 100644 index 0000000000..5d26a862e5 --- /dev/null +++ b/tests/manual/corelib/qdatastream/CMakeLists.txt @@ -0,0 +1,15 @@ +# Copyright (C) 2023 The Qt Company Ltd. +# SPDX-License-Identifier: BSD-3-Clause + +##################################################################### +## tst_manual_qdatastream Test: +##################################################################### + +qt_internal_add_manual_test(tst_manual_qdatastream + SOURCES + tst_manualqdatastream.cpp + LIBRARIES + Qt::Core + ENABLE_AUTOGEN_TOOLS + uic +) diff --git a/tests/manual/corelib/qdatastream/qdatastream.pro b/tests/manual/corelib/qdatastream/qdatastream.pro new file mode 100644 index 0000000000..9143f62851 --- /dev/null +++ b/tests/manual/corelib/qdatastream/qdatastream.pro @@ -0,0 +1,6 @@ +CONFIG += testcase + +SOURCES += tst_manualqdatastream.cpp +QT = core testlib + +TARGET = tst_manual_qdatastream diff --git a/tests/manual/corelib/qdatastream/tst_manualqdatastream.cpp b/tests/manual/corelib/qdatastream/tst_manualqdatastream.cpp new file mode 100644 index 0000000000..37e5b80950 --- /dev/null +++ b/tests/manual/corelib/qdatastream/tst_manualqdatastream.cpp @@ -0,0 +1,234 @@ +// Copyright (C) 2023 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only + +#include <QDataStream> +#include <QHash> +#include <QList> +#include <QMap> +#include <QScopeGuard> +#include <QSet> +#include <QTest> + +// These tests are way too slow to be part of automatic unit tests +class tst_QDataStream : public QObject +{ + Q_OBJECT + + template <class T> + void fill(T &input); + + void fill(QSet<qsizetype> &input); + void fill(QMap<qsizetype, qsizetype> &input); + void fill(QHash<qsizetype, qsizetype> &input); + + template <class T> + void stream_big(); + +public slots: + void initTestCase(); + +private slots: + void stream_bigQString(); + void stream_bigQByteArray(); + void stream_bigQList(); + void stream_bigQSet(); + void stream_bigQMap(); + void stream_bigQHash(); + void stream_bigCString(); +}; + +void tst_QDataStream::initTestCase() +{ + qputenv("QTEST_FUNCTION_TIMEOUT", "9000000"); + + QTest::addColumn<QDataStream::Version>("streamVersion"); + QTest::addRow("current") << QDataStream::Qt_DefaultCompiledVersion; + QTest::addRow("Qt_6_6") << QDataStream::Qt_6_6; +} + +template <class T> +void tst_QDataStream::fill(T &input) +{ + constexpr qsizetype GiB = 1024 * 1024 * 1024; + constexpr qsizetype BaseSize = 4 * GiB + 1; + qDebug("Filling container with %lld entries", qint64(BaseSize)); + QElapsedTimer timer; + timer.start(); + try { + input.reserve(BaseSize); + input.resize(BaseSize, 'a'); + } catch (const std::bad_alloc &) { + QSKIP("Could not allocate 4 GiB of RAM."); + } + qDebug("Created dataset in %lld ms", timer.elapsed()); +} + +void tst_QDataStream::fill(QSet<qsizetype> &input) +{ + constexpr qsizetype GiB = 1024 * 1024 * 1024; + constexpr qsizetype BaseSize = 4 * GiB + 1; + qDebug("Filling container with %lld entries", qint64(BaseSize)); + QElapsedTimer timer; + timer.start(); + try { + input.reserve(BaseSize); + for (qsizetype i = 0; i < BaseSize; ++i) + input.insert(i); + } catch (const std::bad_alloc &) { + QSKIP("Could not allocate 4 Gi entries."); + } + qDebug("Created dataset in %lld ms", timer.elapsed()); +} + +void tst_QDataStream::fill(QMap<qsizetype, qsizetype> &input) +{ + constexpr qsizetype GiB = 1024 * 1024 * 1024; + constexpr qsizetype BaseSize = 4 * GiB + 1; + qDebug("Filling container with %lld entries", qint64(BaseSize)); + QElapsedTimer timer; + timer.start(); + try { + for (qsizetype i = 0; i < BaseSize; ++i) + input.insert(i, i); + } catch (const std::bad_alloc &) { + QSKIP("Could not allocate 4 Gi entries."); + } + qDebug("Created dataset in %lld ms", timer.elapsed()); +} + +void tst_QDataStream::fill(QHash<qsizetype, qsizetype> &input) +{ + constexpr qsizetype GiB = 1024 * 1024 * 1024; + constexpr qsizetype BaseSize = 4 * GiB + 1; + qDebug("Filling container with %lld entries", qint64(BaseSize)); + QElapsedTimer timer; + timer.start(); + try { + input.reserve(BaseSize); + for (qsizetype i = 0; i < BaseSize; ++i) + input.emplace(i, i); + } catch (const std::bad_alloc &) { + QSKIP("Could not allocate 4 Gi entries."); + } + qDebug("Created dataset in %lld ms", timer.elapsed()); +} + +template <class T> +void tst_QDataStream::stream_big() +{ +#if QT_POINTER_SIZE > 4 + QFETCH_GLOBAL(const QDataStream::Version, streamVersion); + QElapsedTimer timer; + T input; + fill(input); + QByteArray ba; + QDataStream inputstream(&ba, QIODevice::WriteOnly); + inputstream.setVersion(streamVersion); + timer.start(); + try { + inputstream << input; + } catch (const std::bad_alloc &) { + QSKIP("Not enough memory to copy into QDataStream."); + } + qDebug("Streamed into QDataStream in %lld ms", timer.elapsed()); + if (streamVersion < QDataStream::Qt_6_7) { + // old versions do not support data size more than 4 GiB + QCOMPARE(inputstream.status(), QDataStream::SizeLimitExceeded); + QVERIFY(ba.isEmpty()); + } else { + T output; + QDataStream outputstream(ba); + timer.start(); + try { + outputstream >> output; + } catch (const std::bad_alloc &) { + QSKIP("Not enough memory to copy out of QDataStream."); + } + qDebug("Streamed out of QDataStream in %lld ms", timer.elapsed()); + QCOMPARE(input.size(), output.size()); + QCOMPARE(input, output); + } +#else + QSKIP("This test is 64-bit only."); +#endif +} + +void tst_QDataStream::stream_bigQString() +{ + stream_big<QString>(); +} + +void tst_QDataStream::stream_bigQByteArray() +{ + stream_big<QByteArray>(); +} +void tst_QDataStream::stream_bigQList() +{ + stream_big<QList<char>>(); +} + +void tst_QDataStream::stream_bigQSet() +{ + stream_big<QSet<qsizetype>>(); +} + +void tst_QDataStream::stream_bigQMap() +{ + stream_big<QMap<qsizetype, qsizetype>>(); +} +void tst_QDataStream::stream_bigQHash() +{ + stream_big<QHash<qsizetype, qsizetype>>(); +} + +void tst_QDataStream::stream_bigCString() +{ + if constexpr (sizeof(void*) == sizeof(int)) + QSKIP("This test is 64-bit only."); + + QFETCH_GLOBAL(const QDataStream::Version, streamVersion); + constexpr qint64 GiB = 1024 * 1024 * 1024; + constexpr qint64 BaseSize = 4 * GiB + 1; + std::string input; + qDebug("Creating an array with %lld entries", BaseSize); + QElapsedTimer timer; + timer.start(); + try { + input.resize(BaseSize, 'a'); + } catch (const std::bad_alloc &) { + QSKIP("Could not allocate 4 Gi + 2 entries."); + } + qDebug("Created dataset in %lld ms", timer.elapsed()); + QByteArray ba; + QDataStream inputstream(&ba, QIODevice::WriteOnly); + inputstream.setVersion(streamVersion); + timer.start(); + try { + inputstream << input.data(); + } catch (const std::bad_alloc &) { + QSKIP("Not enough memory to copy into QDataStream."); + } + qDebug("Streamed into QDataStream in %lld ms", timer.elapsed()); + if (streamVersion < QDataStream::Qt_6_7) { + // old versions do not support data size more than 4 GiB + QCOMPARE(inputstream.status(), QDataStream::SizeLimitExceeded); + QVERIFY(ba.isEmpty()); + } else { + char *output = nullptr; + auto cleanup = qScopeGuard([&output] { delete [] output; }); + QDataStream outputstream(ba); + timer.start(); + try { + outputstream >> output; + } catch (const std::bad_alloc &) { + QSKIP("Not enough memory to copy out of QDataStream."); + } + qDebug("Streamed out of QDataStream in %lld ms", timer.elapsed()); + QCOMPARE(qstrlen(output), input.size()); + QVERIFY(memcmp(input.data(), output, BaseSize + 1) == 0); + } +} + +QTEST_MAIN(tst_QDataStream) + +#include "tst_manualqdatastream.moc" diff --git a/tests/manual/corelib/time/CMakeLists.txt b/tests/manual/corelib/time/CMakeLists.txt new file mode 100644 index 0000000000..b8e6aa2f18 --- /dev/null +++ b/tests/manual/corelib/time/CMakeLists.txt @@ -0,0 +1,4 @@ +# Copyright (C) 2023 The Qt Company Ltd. +# SPDX-License-Identifier: BSD-3-Clause + +add_subdirectory(zonechange) diff --git a/tests/manual/corelib/time/foreachzone b/tests/manual/corelib/time/foreachzone new file mode 100755 index 0000000000..480679885a --- /dev/null +++ b/tests/manual/corelib/time/foreachzone @@ -0,0 +1,30 @@ +#!/bin/sh +# Usage: foreachzone command [args...] +# +# The command is run with eval, so can include embedded shell +# metacharacters such as | and ||. It is run in a sub-shell, so can +# change environment or cd to a different directory without +# complicating later runs of the same command. +# +# It is run repeatedly, with the TZ environment variable set to each +# timezone name in turn, excluding the copies of zoneinfo/ under its +# posix/ and right/ sub-dirs. Symbolic links are included (as long as +# they point to valid zone data). +# +# For example, in the top level of a build tree, +# foreachzone ninja tst_qdate_check +# will run all the QDate tests in every time zone (this may take some +# time). + +DIR=/usr/share/zoneinfo +[ -d "$DIR" ] || DIR=/usr/lib/zoneinfo + +find $DIR -type d \( -name posix -o -name right \) -prune -o \( -type f -o -type l \) -print \ + | while read f +do + # To filter out symlinks in zoneinfo/ itself, uncomment this line: + # echo "$f" | grep -wq 'zoneinfo/.*/' || [ ! -h "$f" ] || continue + # To skip all symlinks, omit the -L here: + file -L "$f" | grep -wq 'timezone data .*, version' || continue + ( export TZ=${f#*/zoneinfo/}; eval "$@" ) +done diff --git a/tests/manual/corelib/time/zonechange/CMakeLists.txt b/tests/manual/corelib/time/zonechange/CMakeLists.txt new file mode 100644 index 0000000000..474779849f --- /dev/null +++ b/tests/manual/corelib/time/zonechange/CMakeLists.txt @@ -0,0 +1,9 @@ +# Copyright (C) 2023 The Qt Company Ltd. +# SPDX-License-Identifier: BSD-3-Clause + +qt_internal_add_manual_test(zonechange + SOURCES + tst_zonechange.cpp + LIBRARIES + Qt::Core +) diff --git a/tests/manual/corelib/time/zonechange/tst_zonechange.cpp b/tests/manual/corelib/time/zonechange/tst_zonechange.cpp new file mode 100644 index 0000000000..5ca33f1396 --- /dev/null +++ b/tests/manual/corelib/time/zonechange/tst_zonechange.cpp @@ -0,0 +1,60 @@ +// Copyright (C) 2023 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only + +#include <QtCore/qcoreapplication.h> + +#include <QtCore/qdatetime.h> +#if QT_CONFIG(timezone) +#include <QtCore/qtimezone.h> +#endif + +#include <chrono> +#include <thread> + +using namespace std::chrono; + +bool distinct(const QDateTime &left, const QDateTime &right) +{ + if (left == right) + return false; + + qInfo() << " Actual:" << left << "\nExpected:" << right; + return true; +} + +// Exit status: 0 success, 1 test failed, 2 test not viable. +int main(int argc, char **argv) +{ + // Other things may need this indirectly, so make sure it exists: + QCoreApplication ignored(argc, argv); + if (!qEnvironmentVariableIsEmpty("TZ")) { + qInfo("Environment variable TZ over-rides system setting; you need to clear it."); + return 2; + } + + QDateTime date = QDateTime(QDate(2020, 2, 20), QTime(20, 20, 20)); + QDateTime copy = date; + if (distinct(date, copy)) + return 1; +#if QT_CONFIG(timezone) + const auto prior = QTimeZone::systemTimeZoneId(); +#endif + + qInfo("You have two minutes in which to change the system time-zone setting."); + std::this_thread::sleep_for(120s); +#if QT_CONFIG(timezone) + if (QTimeZone::systemTimeZoneId() == prior) { + qInfo("Too slow."); + return 2; + } +#endif + + if (distinct(copy, date)) + return 1; + QDateTime copy2 = copy.addMSecs(2); + QDateTime date2 = date.addMSecs(2); + if (distinct(copy2, date2)) + return 1; + + return 0; +} diff --git a/tests/manual/corelib/tools/CMakeLists.txt b/tests/manual/corelib/tools/CMakeLists.txt new file mode 100644 index 0000000000..4300db8859 --- /dev/null +++ b/tests/manual/corelib/tools/CMakeLists.txt @@ -0,0 +1,12 @@ +# Copyright (C) 2023 The Qt Company Ltd. +# SPDX-License-Identifier: BSD-3-Clause + +add_subdirectory(customtype) +add_subdirectory(customtypesending) +# Needs conversion from qmake: +# add_subdirectory(qhash) +# add_subdirectory(qlist) +# add_subdirectory(qmap) +# add_subdirectory(qset) +# add_subdirectory(qvarlengtharray) +# add_subdirectory(qvector) diff --git a/tests/manual/corelib/tools/customtype/CMakeLists.txt b/tests/manual/corelib/tools/customtype/CMakeLists.txt new file mode 100644 index 0000000000..4cb1c024b3 --- /dev/null +++ b/tests/manual/corelib/tools/customtype/CMakeLists.txt @@ -0,0 +1,15 @@ +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: BSD-3-Clause + +cmake_minimum_required(VERSION 3.16) + +qt_internal_add_manual_test(customtype + GUI + SOURCES + main.cpp + message.cpp message.h + LIBRARIES + Qt6::Core + Qt6::Gui + Qt6::Widgets +) diff --git a/tests/manual/corelib/tools/customtype/customtype.pro b/tests/manual/corelib/tools/customtype/customtype.pro new file mode 100644 index 0000000000..0a5a90f541 --- /dev/null +++ b/tests/manual/corelib/tools/customtype/customtype.pro @@ -0,0 +1,7 @@ +HEADERS = message.h +SOURCES = main.cpp \ + message.cpp +QT += widgets +INCLUDEPATH += . +TARGET = customtype + diff --git a/tests/manual/corelib/tools/customtype/main.cpp b/tests/manual/corelib/tools/customtype/main.cpp new file mode 100644 index 0000000000..2368db6ec0 --- /dev/null +++ b/tests/manual/corelib/tools/customtype/main.cpp @@ -0,0 +1,37 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only + +#include <QCoreApplication> +#include <QDebug> +#include <QVariant> +#include "message.h" + +int main(int argc, char *argv[]) +{ + QCoreApplication app(argc, argv); + QStringList headers; + headers << "Subject: Hello World" + << "From: address@example.com"; + QString body = "This is a test.\r\n"; + +//! [printing a custom type] + Message message(body, headers); + qDebug() << "Original:" << message; +//! [printing a custom type] + +//! [storing a custom value] + QVariant stored; + stored.setValue(message); +//! [storing a custom value] + + qDebug() << "Stored:" << stored; + +//! [retrieving a custom value] + Message retrieved = qvariant_cast<Message>(stored); + qDebug() << "Retrieved:" << retrieved; + retrieved = qvariant_cast<Message>(stored); + qDebug() << "Retrieved:" << retrieved; +//! [retrieving a custom value] + + return 0; +} diff --git a/tests/manual/corelib/tools/customtype/message.cpp b/tests/manual/corelib/tools/customtype/message.cpp new file mode 100644 index 0000000000..221480d56f --- /dev/null +++ b/tests/manual/corelib/tools/customtype/message.cpp @@ -0,0 +1,38 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only + +#include "message.h" + +#include <QDebug> + +Message::Message(const QString &body, const QStringList &headers) + : m_body(body), m_headers(headers) +{ +} + +//! [custom type streaming operator] +QDebug operator<<(QDebug dbg, const Message &message) +{ + QDebugStateSaver saver(dbg); + QList<QStringView> pieces = message.body().split(u"\r\n", Qt::SkipEmptyParts); + if (pieces.isEmpty()) + dbg.nospace() << "Message()"; + else if (pieces.size() == 1) + dbg.nospace() << "Message(" << pieces.first() << ")"; + else + dbg.nospace() << "Message(" << pieces.first() << " ...)"; + return dbg; +} +//! [custom type streaming operator] + +//! [getter functions] +QStringView Message::body() const +{ + return m_body; +} + +QStringList Message::headers() const +{ + return m_headers; +} +//! [getter functions] diff --git a/tests/manual/corelib/tools/customtype/message.h b/tests/manual/corelib/tools/customtype/message.h new file mode 100644 index 0000000000..3b91938eb7 --- /dev/null +++ b/tests/manual/corelib/tools/customtype/message.h @@ -0,0 +1,38 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only + +#ifndef MESSAGE_H +#define MESSAGE_H + +#include <QMetaType> +#include <QStringList> + +//! [custom type definition] +class Message +{ +public: + Message() = default; + ~Message() = default; + Message(const Message &) = default; + Message &operator=(const Message &) = default; + + Message(const QString &body, const QStringList &headers); + + QStringView body() const; + QStringList headers() const; + +private: + QString m_body; + QStringList m_headers; +}; +//! [custom type definition] + +//! [custom type meta-type declaration] +Q_DECLARE_METATYPE(Message); +//! [custom type meta-type declaration] + +//! [custom type streaming operator] +QDebug operator<<(QDebug dbg, const Message &message); +//! [custom type streaming operator] + +#endif diff --git a/tests/manual/corelib/tools/customtypesending/CMakeLists.txt b/tests/manual/corelib/tools/customtypesending/CMakeLists.txt new file mode 100644 index 0000000000..c22d5e23c1 --- /dev/null +++ b/tests/manual/corelib/tools/customtypesending/CMakeLists.txt @@ -0,0 +1,16 @@ +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: BSD-3-Clause + +cmake_minimum_required(VERSION 3.16) + +qt_internal_add_manual_test(customtypesending + GUI + SOURCES + main.cpp + message.cpp message.h + window.cpp window.h + LIBRARIES + Qt6::Core + Qt6::Gui + Qt6::Widgets +) diff --git a/tests/manual/corelib/tools/customtypesending/customtypesending.pro b/tests/manual/corelib/tools/customtypesending/customtypesending.pro new file mode 100644 index 0000000000..d316787f76 --- /dev/null +++ b/tests/manual/corelib/tools/customtypesending/customtypesending.pro @@ -0,0 +1,9 @@ +HEADERS = message.h \ + window.h +SOURCES = main.cpp \ + message.cpp \ + window.cpp +QT += widgets +INCLUDEPATH += . +TARGET = customtypesending + diff --git a/tests/manual/corelib/tools/customtypesending/main.cpp b/tests/manual/corelib/tools/customtypesending/main.cpp new file mode 100644 index 0000000000..a8f95ffe8e --- /dev/null +++ b/tests/manual/corelib/tools/customtypesending/main.cpp @@ -0,0 +1,31 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only + +#include <QApplication> +#include "message.h" +#include "window.h" + +//! [main function] +int main(int argc, char *argv[]) +{ + QApplication app(argc, argv); + + QStringList headers; + headers << "Subject: Hello World" + << "From: address@example.com"; + QString body = "This is a test.\r\n"; + Message message(body, headers); + + Window window1; + window1.setMessage(message); + + Window window2; + QObject::connect(&window1, &Window::messageSent, + &window2, &Window::setMessage); + QObject::connect(&window2, &Window::messageSent, + &window1, &Window::setMessage); + window1.show(); + window2.show(); + return app.exec(); +} +//! [main function] diff --git a/tests/manual/corelib/tools/customtypesending/message.cpp b/tests/manual/corelib/tools/customtypesending/message.cpp new file mode 100644 index 0000000000..a7a8722673 --- /dev/null +++ b/tests/manual/corelib/tools/customtypesending/message.cpp @@ -0,0 +1,19 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only + +#include "message.h" + +Message::Message(const QString &body, const QStringList &headers) + : m_body(body), m_headers(headers) +{ +} + +QString Message::body() const +{ + return m_body; +} + +QStringList Message::headers() const +{ + return m_headers; +} diff --git a/tests/manual/corelib/tools/customtypesending/message.h b/tests/manual/corelib/tools/customtypesending/message.h new file mode 100644 index 0000000000..b16c92f177 --- /dev/null +++ b/tests/manual/corelib/tools/customtypesending/message.h @@ -0,0 +1,34 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only + +#ifndef MESSAGE_H +#define MESSAGE_H + +#include <QMetaType> +#include <QStringList> + +//! [custom type definition] +class Message +{ +public: + Message() = default; + ~Message() = default; + Message(const Message &) = default; + Message &operator=(const Message &) = default; + + Message(const QString &body, const QStringList &headers); + + QString body() const; + QStringList headers() const; + +private: + QString m_body; + QStringList m_headers; +}; +//! [custom type definition] + +//! [custom type meta-type declaration] +Q_DECLARE_METATYPE(Message); +//! [custom type meta-type declaration] + +#endif diff --git a/tests/manual/corelib/tools/customtypesending/window.cpp b/tests/manual/corelib/tools/customtypesending/window.cpp new file mode 100644 index 0000000000..fc158f10e6 --- /dev/null +++ b/tests/manual/corelib/tools/customtypesending/window.cpp @@ -0,0 +1,43 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only + +#include <QtWidgets> +#include "window.h" + +//! [Window constructor] +Window::Window(QWidget *parent) + : QWidget(parent), editor(new QTextEdit(this)) +{ + QPushButton *sendButton = new QPushButton(tr("&Send message")); + + connect(sendButton, &QPushButton::clicked, + this, &Window::sendMessage); + + QHBoxLayout *buttonLayout = new QHBoxLayout; + buttonLayout->addStretch(); + buttonLayout->addWidget(sendButton); + buttonLayout->addStretch(); + + QVBoxLayout *layout = new QVBoxLayout(this); + layout->addWidget(editor); + layout->addLayout(buttonLayout); + + setWindowTitle(tr("Custom Type Sending")); +} +//! [Window constructor] + +//! [sending a message] +void Window::sendMessage() +{ + thisMessage = Message(editor->toPlainText(), thisMessage.headers()); + emit messageSent(thisMessage); +} +//! [sending a message] + +//! [receiving a message] +void Window::setMessage(const Message &message) +{ + thisMessage = message; + editor->setPlainText(thisMessage.body()); +} +//! [receiving a message] diff --git a/tests/manual/corelib/tools/customtypesending/window.h b/tests/manual/corelib/tools/customtypesending/window.h new file mode 100644 index 0000000000..974e7a7629 --- /dev/null +++ b/tests/manual/corelib/tools/customtypesending/window.h @@ -0,0 +1,35 @@ +// Copyright (C) 2016 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only + +#ifndef WINDOW_H +#define WINDOW_H + +#include <QWidget> +#include "message.h" + +QT_FORWARD_DECLARE_CLASS(QTextEdit) + +//! [Window class definition] +class Window : public QWidget +{ + Q_OBJECT + +public: + Window(QWidget *parent = nullptr); + +signals: + void messageSent(const Message &message); + +public slots: + void setMessage(const Message &message); + +private slots: + void sendMessage(); + +private: + Message thisMessage; + QTextEdit *editor; +}; +//! [Window class definition] + +#endif diff --git a/tests/manual/corelib/tools/qhash/main.cpp b/tests/manual/corelib/tools/qhash/main.cpp index 298d1777ea..6c9006ace2 100644 --- a/tests/manual/corelib/tools/qhash/main.cpp +++ b/tests/manual/corelib/tools/qhash/main.cpp @@ -1,30 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2013 Thorbjørn Lund Martsum - tmartsum[at]gmail.com -** 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) 2013 Thorbjørn Lund Martsum - tmartsum[at]gmail.com +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #include <QDebug> #include <QHash> diff --git a/tests/manual/corelib/tools/qlist/main.cpp b/tests/manual/corelib/tools/qlist/main.cpp index 1553962d32..2f3e8c0c73 100644 --- a/tests/manual/corelib/tools/qlist/main.cpp +++ b/tests/manual/corelib/tools/qlist/main.cpp @@ -1,30 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2013 Thorbjørn Lund Martsum - tmartsum[at]gmail.com -** 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) 2013 Thorbjørn Lund Martsum - tmartsum[at]gmail.com +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #include <QDebug> #include <QList> diff --git a/tests/manual/corelib/tools/qmap/main.cpp b/tests/manual/corelib/tools/qmap/main.cpp index 586bfb2750..b3c163e515 100644 --- a/tests/manual/corelib/tools/qmap/main.cpp +++ b/tests/manual/corelib/tools/qmap/main.cpp @@ -1,30 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Thorbjørn Lund Martsum - tmartsum[at]gmail.com -** 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) 2012 Thorbjørn Lund Martsum - tmartsum[at]gmail.com +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only //#define Q_NO_DEBUGMAP_PARENT_TEST // Comment in line above to skip the parent test. diff --git a/tests/manual/corelib/tools/qset/main.cpp b/tests/manual/corelib/tools/qset/main.cpp index 701c8889db..6b86d2fb06 100644 --- a/tests/manual/corelib/tools/qset/main.cpp +++ b/tests/manual/corelib/tools/qset/main.cpp @@ -1,30 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2013 Thorbjørn Lund Martsum - tmartsum[at]gmail.com -** 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) 2013 Thorbjørn Lund Martsum - tmartsum[at]gmail.com +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #include <QDebug> #include <QSet> diff --git a/tests/manual/corelib/tools/qvarlengtharray/main.cpp b/tests/manual/corelib/tools/qvarlengtharray/main.cpp index 0544bb0c4b..0ad8d75b6c 100644 --- a/tests/manual/corelib/tools/qvarlengtharray/main.cpp +++ b/tests/manual/corelib/tools/qvarlengtharray/main.cpp @@ -1,30 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2013 Thorbjørn Lund Martsum - tmartsum[at]gmail.com -** 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) 2013 Thorbjørn Lund Martsum - tmartsum[at]gmail.com +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #include <QDebug> #include <QVarLengthArray> diff --git a/tests/manual/corelib/tools/qvector/main.cpp b/tests/manual/corelib/tools/qvector/main.cpp index 1b35123f15..40462f272f 100644 --- a/tests/manual/corelib/tools/qvector/main.cpp +++ b/tests/manual/corelib/tools/qvector/main.cpp @@ -1,30 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2013 Thorbjørn Lund Martsum - tmartsum[at]gmail.com -** 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) 2013 Thorbjørn Lund Martsum - tmartsum[at]gmail.com +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only #include <QDebug> #include <QVector> |