From 39efe3c84db554411f2e2fc5e491659c5398a059 Mon Sep 17 00:00:00 2001 From: Joerg Bornemann Date: Wed, 9 Mar 2016 15:28:26 +0100 Subject: Fix glitch in tst_QLocalSocket::sendData In one code path the test checked for the emission of a readyRead() signal without waiting for it. This code path was never hit, neither on Windows nor on Unix platforms. Change-Id: Ifbe464400a2a1ba8eab49bd60315289040e6bbde Reviewed-by: Oswald Buddenhagen --- tests/auto/network/socket/qlocalsocket/tst_qlocalsocket.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'tests') diff --git a/tests/auto/network/socket/qlocalsocket/tst_qlocalsocket.cpp b/tests/auto/network/socket/qlocalsocket/tst_qlocalsocket.cpp index 0505544a29..d12a6b53c3 100644 --- a/tests/auto/network/socket/qlocalsocket/tst_qlocalsocket.cpp +++ b/tests/auto/network/socket/qlocalsocket/tst_qlocalsocket.cpp @@ -525,6 +525,7 @@ void tst_QLocalSocket::sendData() // test creating a connection socket.connectToServer(name); bool timedOut = true; + int expectedReadyReadSignals = 0; QCOMPARE(server.waitForNewConnection(3000, &timedOut), canListen); @@ -548,15 +549,17 @@ void tst_QLocalSocket::sendData() out << testLine << endl; bool wrote = serverSocket->waitForBytesWritten(3000); - if (!socket.canReadLine()) + if (!socket.canReadLine()) { + expectedReadyReadSignals = 1; QVERIFY(socket.waitForReadyRead()); + } QVERIFY(socket.bytesAvailable() >= 0); QCOMPARE(socket.bytesToWrite(), (qint64)0); QCOMPARE(socket.flush(), false); QCOMPARE(socket.isValid(), canListen); QCOMPARE(socket.readBufferSize(), (qint64)0); - QCOMPARE(spyReadyRead.count(), 1); + QCOMPARE(spyReadyRead.count(), expectedReadyReadSignals); QVERIFY(testLine.startsWith(in.readLine())); @@ -571,7 +574,7 @@ void tst_QLocalSocket::sendData() QCOMPARE(spyDisconnected.count(), canListen ? 1 : 0); QCOMPARE(spyError.count(), canListen ? 0 : 1); QCOMPARE(spyStateChanged.count(), canListen ? 4 : 2); - QCOMPARE(spyReadyRead.count(), canListen ? 1 : 0); + QCOMPARE(spyReadyRead.count(), canListen ? expectedReadyReadSignals : 0); server.close(); -- cgit v1.2.3 From 8589bb334f1e90630897c600c747541902434fab Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Thu, 10 Mar 2016 13:15:50 +0100 Subject: Enable most of tst_qstatictext on non-developer builds Only two tests inside tst_qstatictext required private symbols, so we can enable the rest on all builds. Change-Id: Id222ba01d9676c40b6447c1526ee127fcc2090d3 Reviewed-by: Oswald Buddenhagen --- tests/auto/gui/text/qstatictext/qstatictext.pro | 4 +++- tests/auto/gui/text/qstatictext/tst_qstatictext.cpp | 6 ++++++ tests/auto/gui/text/text.pro | 1 - 3 files changed, 9 insertions(+), 2 deletions(-) (limited to 'tests') diff --git a/tests/auto/gui/text/qstatictext/qstatictext.pro b/tests/auto/gui/text/qstatictext/qstatictext.pro index 435b132ffd..acffbe700b 100644 --- a/tests/auto/gui/text/qstatictext/qstatictext.pro +++ b/tests/auto/gui/text/qstatictext/qstatictext.pro @@ -3,5 +3,7 @@ CONFIG += parallel_test linux: CONFIG += insignificant_test TARGET = tst_qstatictext QT += testlib -QT += core-private gui-private + SOURCES += tst_qstatictext.cpp + +contains(QT_CONFIG, private_tests): QT += core-private gui-private diff --git a/tests/auto/gui/text/qstatictext/tst_qstatictext.cpp b/tests/auto/gui/text/qstatictext/tst_qstatictext.cpp index 4b322efa7c..121584b87f 100644 --- a/tests/auto/gui/text/qstatictext/tst_qstatictext.cpp +++ b/tests/auto/gui/text/qstatictext/tst_qstatictext.cpp @@ -39,7 +39,9 @@ #include #include +#ifdef QT_BUILD_INTERNAL #include +#endif // #define DEBUG_SAVE_IMAGE @@ -90,8 +92,10 @@ private slots: void unprintableCharacter_qtbug12614(); +#ifdef QT_BUILD_INTERNAL void underlinedColor_qtbug20159(); void textDocumentColor(); +#endif private: bool supportsTransformations() const; @@ -829,6 +833,7 @@ void tst_QStaticText::unprintableCharacter_qtbug12614() QVERIFY(staticText.size().isValid()); // Force layout. Should not crash. } +#ifdef QT_BUILD_INTERNAL void tst_QStaticText::underlinedColor_qtbug20159() { QString multiScriptText; @@ -865,6 +870,7 @@ void tst_QStaticText::textDocumentColor() QCOMPARE(d->items[1].color, QColor(Qt::red)); } +#endif QTEST_MAIN(tst_QStaticText) #include "tst_qstatictext.moc" diff --git a/tests/auto/gui/text/text.pro b/tests/auto/gui/text/text.pro index 6c0def4d63..dc67794a98 100644 --- a/tests/auto/gui/text/text.pro +++ b/tests/auto/gui/text/text.pro @@ -30,6 +30,5 @@ win32:SUBDIRS -= qtextpiecetable !contains(QT_CONFIG, private_tests): SUBDIRS -= \ qfontcache \ qcssparser \ - qstatictext \ qtextlayout \ qtextpiecetable \ -- cgit v1.2.3 From ac8dae8b5eafa07704155dd636d8da2ec21d1c6f Mon Sep 17 00:00:00 2001 From: Joerg Bornemann Date: Thu, 10 Mar 2016 14:07:16 +0100 Subject: QLocalServer/Win: Fix race condition in listen(). Suppose a client connects while the QLocalServer is still in the loop that calls addListener. The connection would SetEvent(eventHandle), but every call to ConnectNamedPipe would ResetEvent(eventHandle). Thus, the connection is never detected by the notifier on eventHandle. Callers of addListener must check the connection state of every listener to make sure that no client connected while setting up listeners. Task-number: QTBUG-49254 Change-Id: Ia961927ea76973708e6e3f73510695eb5d6a0e4c Reviewed-by: Oswald Buddenhagen --- tests/auto/network/socket/qlocalsocket/BLACKLIST | 2 -- 1 file changed, 2 deletions(-) delete mode 100644 tests/auto/network/socket/qlocalsocket/BLACKLIST (limited to 'tests') diff --git a/tests/auto/network/socket/qlocalsocket/BLACKLIST b/tests/auto/network/socket/qlocalsocket/BLACKLIST deleted file mode 100644 index 11ddef30a5..0000000000 --- a/tests/auto/network/socket/qlocalsocket/BLACKLIST +++ /dev/null @@ -1,2 +0,0 @@ -[processConnection:1 client] -windows -- cgit v1.2.3 From 71a36d0b6576b2174b708a714f92bbbe1b309d05 Mon Sep 17 00:00:00 2001 From: Maurice Kalinowski Date: Thu, 10 Mar 2016 14:34:45 +0100 Subject: Disable tests requiring shared build when compiling statically Change-Id: I06ec53e46d2f61f1685899b0f8a4d385051095d6 Reviewed-by: Oliver Wolff --- tests/auto/corelib/plugin/plugin.pro | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'tests') diff --git a/tests/auto/corelib/plugin/plugin.pro b/tests/auto/corelib/plugin/plugin.pro index 506f6abaeb..e132d9da1a 100644 --- a/tests/auto/corelib/plugin/plugin.pro +++ b/tests/auto/corelib/plugin/plugin.pro @@ -5,3 +5,9 @@ SUBDIRS=\ qplugin \ qpluginloader \ quuid + +contains(CONFIG, static) { + message(Disabling tests requiring shared build of Qt) + SUBDIRS -= qfactoryloader \ + qpluginloader +} -- cgit v1.2.3 From a8c72b7671637d18b1915d7e46fc601e8ffde2d7 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Thu, 10 Mar 2016 16:35:53 +0100 Subject: tst_QTextStream::textModeOnEmptyRead(): Create file in temporary directory. A test should not write to its directory. Amends change d0b54cede8d8ea0b8431c64abb51d0cd1a71327b. Task-number: QTBUG-47176 Change-Id: If15258b4aed199792fab422b7ac1d74e22a9e322 Reviewed-by: Maurice Kalinowski --- tests/auto/corelib/io/qtextstream/tst_qtextstream.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'tests') diff --git a/tests/auto/corelib/io/qtextstream/tst_qtextstream.cpp b/tests/auto/corelib/io/qtextstream/tst_qtextstream.cpp index a0348f3c54..24dd05223f 100644 --- a/tests/auto/corelib/io/qtextstream/tst_qtextstream.cpp +++ b/tests/auto/corelib/io/qtextstream/tst_qtextstream.cpp @@ -3049,12 +3049,10 @@ void tst_QTextStream::int_write_with_locale() void tst_QTextStream::textModeOnEmptyRead() { - const QString filename("textmodetest.txt"); - QFile::remove(filename); // Remove file if exists - + const QString filename(tempDir.path() + QLatin1String("/textmodetest.txt")); QFile file(filename); - QVERIFY(file.open(QIODevice::ReadWrite | QIODevice::Text)); + QVERIFY2(file.open(QIODevice::ReadWrite | QIODevice::Text), qPrintable(file.errorString())); QTextStream stream(&file); QVERIFY(file.isTextModeEnabled()); QString emptyLine = stream.readLine(); // Text mode flag cleared here -- cgit v1.2.3 From 514c202da95bbe876c9759961a8032eae4b96bdd Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Fri, 8 Jan 2016 10:04:02 +0100 Subject: Add a manual test for foreign windows. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add a command line tool that can either take a list of window ids and output information on them using a verbose debug stream or embed foreign windows using QWidget::createWindowContainer(). Task-number: QTBUG-41186 Change-Id: I14e436b5d08828f5b78b29e0701daeffe11367d3 Reviewed-by: Morten Johan Sørvig --- tests/manual/foreignwindows/foreignwindows.pro | 6 + tests/manual/foreignwindows/main.cpp | 329 +++++++++++++++++++++++++ tests/manual/manual.pro | 4 +- 3 files changed, 338 insertions(+), 1 deletion(-) create mode 100644 tests/manual/foreignwindows/foreignwindows.pro create mode 100644 tests/manual/foreignwindows/main.cpp (limited to 'tests') diff --git a/tests/manual/foreignwindows/foreignwindows.pro b/tests/manual/foreignwindows/foreignwindows.pro new file mode 100644 index 0000000000..6a370a6813 --- /dev/null +++ b/tests/manual/foreignwindows/foreignwindows.pro @@ -0,0 +1,6 @@ +TEMPLATE = app +QT += widgets +CONFIG += console c++11 +CONFIG -= app_bundle +SOURCES += main.cpp +include(../diaglib/diaglib.pri) diff --git a/tests/manual/foreignwindows/main.cpp b/tests/manual/foreignwindows/main.cpp new file mode 100644 index 0000000000..6c722a3f6f --- /dev/null +++ b/tests/manual/foreignwindows/main.cpp @@ -0,0 +1,329 @@ +/**************************************************************************** +** +** Copyright (C) 2015 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL21$ +** 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 http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** As a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#include +#include +#include +#include +#include +#include +#include + +#ifdef Q_OS_WIN +# include +#endif + +#include // diaglib +#include +#include +#include + +#include +#include + +QT_USE_NAMESPACE + +typedef QSharedPointer WidgetPtr; +typedef QList WidgetPtrList; +typedef QList WIdList; + +// Create some pre-defined Windows controls by class name +static WId createInternalWindow(const QString &name) +{ + WId result = 0; +#ifdef Q_OS_WIN + if (name == QLatin1String("BUTTON") || name == QLatin1String("COMBOBOX") + || name == QLatin1String("EDIT") || name.startsWith(QLatin1String("RICHEDIT"))) { + const HWND hwnd = + CreateWindowEx(0, reinterpret_cast(name.utf16()), + L"NativeCtrl", WS_OVERLAPPEDWINDOW, + CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, + 0, 0, GetModuleHandle(NULL), NULL); + if (hwnd) { + SetWindowText(hwnd, L"Demo"); + result = WId(hwnd); + } else { + qErrnoWarning("Cannot create window \"%s\"", qPrintable(name)); + } + } +#else // Q_OS_WIN + Q_UNUSED(name) +#endif + return result; +} + +// Embed a foreign window using createWindowContainer() providing +// menu actions to dump information. +class EmbeddingWindow : public QMainWindow +{ + Q_OBJECT +public: + explicit EmbeddingWindow(QWindow *window); + +public slots: + void releaseForeignWindow(); + +private: + QWindow *m_window; + QAction *m_releaseAction; +}; + +EmbeddingWindow::EmbeddingWindow(QWindow *window) : m_window(window) +{ + const QString title = QLatin1String("Qt ") + QLatin1String(QT_VERSION_STR) + + QLatin1String(" 0x") + QString::number(window->winId(), 16); + setWindowTitle(title); + setObjectName("MainWindow"); + QWidget *container = QWidget::createWindowContainer(window, Q_NULLPTR, Qt::Widget); + container->setObjectName("Container"); + setCentralWidget(container); + + QMenu *fileMenu = menuBar()->addMenu("File"); + fileMenu->setObjectName("FileMenu"); + QToolBar *toolbar = new QToolBar; + addToolBar(Qt::TopToolBarArea, toolbar); + + // Manipulation + QAction *action = fileMenu->addAction("Visible"); + action->setCheckable(true); + action->setChecked(true); + connect(action, &QAction::toggled, m_window, &QWindow::setVisible); + toolbar->addAction(action); + + m_releaseAction = fileMenu->addAction("Release", this, &EmbeddingWindow::releaseForeignWindow); + toolbar->addAction(m_releaseAction); + + fileMenu->addSeparator(); // Diaglib actions + action = fileMenu->addAction("Dump Widgets", + this, [] () { QtDiag::dumpAllWidgets(); }); + toolbar->addAction(action); + action = fileMenu->addAction("Dump Windows", + this, [] () { QtDiag::dumpAllWindows(); }); + toolbar->addAction(action); + action = fileMenu->addAction("Dump Native Windows", + this, [this] () { QtDiag::dumpNativeWindows(winId()); }); + toolbar->addAction(action); + + fileMenu->addSeparator(); + action = fileMenu->addAction("Quit", qApp, &QCoreApplication::quit); + toolbar->addAction(action); + action->setShortcut(Qt::CTRL + Qt::Key_Q); +} + +void EmbeddingWindow::releaseForeignWindow() +{ + if (m_window) { + m_window->setParent(Q_NULLPTR); + m_window = Q_NULLPTR; + m_releaseAction->setEnabled(false); + } +} + +// Dump information about foreign windows. +class WindowDumper : public QObject { + Q_OBJECT +public: + explicit WindowDumper(const QWindowList &watchedWindows) + : m_watchedWindows(watchedWindows) {} + +public slots: + void dump() const; + +private: + const QWindowList m_watchedWindows; +}; + +void WindowDumper::dump() const +{ + static int n = 0; + QString s; + QDebug debug(&s); + debug.nospace(); + debug.setVerbosity(3); + debug << '#' << n++; + if (m_watchedWindows.size() > 1) + debug << '\n'; + foreach (const QWindow *w, m_watchedWindows) { + const QPoint globalPos = w->mapToGlobal(QPoint()); + debug << " " << w << " pos=" << globalPos.x() << ',' << globalPos.y() << '\n'; + } + + std::cout << qPrintable(s); +} + +static QString description(const QString &appName) +{ + QString result; + QTextStream(&result) + << "\nDumps information about foreign windows passed on the command line or\n" + "tests embedding foreign windows into Qt.\n\nUse cases:\n\n" + << appName << " -a Dump a list of all native window ids.\n" + << appName << " Dump information on the window.\n" + << appName << " -c Dump information on the window continuously.\n" + << appName << " -e Embed window into a Qt widget.\n" + << "\nOn Windows, class names of well known controls (EDIT, BUTTON...) can be\n" + "passed as along with -e, which will create the control.\n"; + return result; +} + +struct EventFilterOption +{ + const char *name; + const char *description; + QtDiag::EventFilter::EventCategories categories; +}; + +EventFilterOption eventFilterOptions[] = { +{"mouse-events", "Dump mouse events.", QtDiag::EventFilter::MouseEvents}, +{"keyboard-events", "Dump keyboard events.", QtDiag::EventFilter::KeyEvents}, +{"state-events", "Dump state/focus change events.", QtDiag::EventFilter::StateChangeEvents | QtDiag::EventFilter::FocusEvents} +}; + +static inline bool isOptionSet(int argc, char *argv[], const char *option) +{ + return (argv + argc) != + std::find_if(argv + 1, argv + argc, + [option] (const char *arg) { return !qstrcmp(arg, option); }); +} + +int main(int argc, char *argv[]) +{ + // Check for no scaling before QApplication is instantiated. + if (isOptionSet(argc, argv, "-s")) + QCoreApplication::setAttribute(Qt::AA_DisableHighDpiScaling); + QCoreApplication::setApplicationVersion(QLatin1String(QT_VERSION_STR)); + QGuiApplication::setApplicationDisplayName("Foreign window tester"); + + QApplication app(argc, argv); + + QCommandLineParser parser; + parser.setSingleDashWordOptionMode(QCommandLineParser::ParseAsLongOptions); + parser.setApplicationDescription(description(QCoreApplication::applicationName())); + parser.addHelpOption(); + parser.addVersionOption(); + QCommandLineOption noScalingDummy(QStringLiteral("s"), + QStringLiteral("Disable High DPI scaling.")); + parser.addOption(noScalingDummy); + QCommandLineOption outputAllOption(QStringList() << QStringLiteral("a") << QStringLiteral("all"), + QStringLiteral("Output all native window ids (requires diaglib).")); + parser.addOption(outputAllOption); + QCommandLineOption continuousOption(QStringList() << QStringLiteral("c") << QStringLiteral("continuous"), + QStringLiteral("Output continuously.")); + parser.addOption(continuousOption); + QCommandLineOption embedOption(QStringList() << QStringLiteral("e") << QStringLiteral("embed"), + QStringLiteral("Embed a foreign window into a Qt widget.")); + parser.addOption(embedOption); + const int eventFilterOptionCount = int(sizeof(eventFilterOptions) / sizeof(eventFilterOptions[0])); + for (int i = 0; i < eventFilterOptionCount; ++i) { + parser.addOption(QCommandLineOption(QLatin1String(eventFilterOptions[i].name), + QLatin1String(eventFilterOptions[i].description))); + } + parser.addPositionalArgument(QStringLiteral("[windows]"), QStringLiteral("Window IDs.")); + + parser.process(QCoreApplication::arguments()); + + if (parser.isSet(outputAllOption)) { + QtDiag::dumpNativeWindows(); + return 0; + } + + QWindowList windows; + foreach (const QString &argument, parser.positionalArguments()) { + bool ok = true; + WId wid = createInternalWindow(argument); + if (!wid) + wid = argument.toULongLong(&ok, 0); + if (!wid || !ok) { + std::cerr << "Invalid window id: \"" << qPrintable(argument) << "\"\n"; + return -1; + } + QWindow *foreignWindow = QWindow::fromWinId(wid); + foreignWindow->setObjectName("ForeignWindow" + QString::number(wid, 16)); + windows.append(foreignWindow); + } + + if (windows.isEmpty()) + parser.showHelp(0); + + int exitCode = 0; + + if (parser.isSet(embedOption)) { + QtDiag::EventFilter::EventCategories eventCategories = 0; + for (int i = 0; i < eventFilterOptionCount; ++i) { + if (parser.isSet(QLatin1String(eventFilterOptions[i].name))) + eventCategories |= eventFilterOptions[i].categories; + } + if (eventCategories) + app.installEventFilter(new QtDiag::EventFilter(eventCategories, &app)); + + const QRect availableGeometry = QApplication::desktop()->availableGeometry(0); + QPoint pos = availableGeometry.topLeft() + QPoint(availableGeometry.width(), availableGeometry.height()) / 3; + + WidgetPtrList mainWindows; + foreach (QWindow *window, windows) { + WidgetPtr mainWindow(new EmbeddingWindow(window)); + mainWindow->move(pos); + mainWindow->resize(availableGeometry.size() / 4); + mainWindow->show(); + pos += QPoint(40, 40); + mainWindows.append(mainWindow); + } + exitCode = app.exec(); + + } else if (parser.isSet(continuousOption)) { + WindowDumper dumper(windows); + dumper.dump(); + QTimer *timer = new QTimer(&dumper); + QObject::connect(timer, &QTimer::timeout, &dumper, &WindowDumper::dump); + timer->start(1000); + exitCode = app.exec(); + + } else { + WindowDumper(windows).dump(); + } + + return exitCode; +} + +#include "main.moc" diff --git a/tests/manual/manual.pro b/tests/manual/manual.pro index cffe76b2b4..8777cc6e11 100644 --- a/tests/manual/manual.pro +++ b/tests/manual/manual.pro @@ -2,6 +2,7 @@ TEMPLATE=subdirs SUBDIRS = bearerex \ filetest \ +foreignwindows \ gestures \ inputmethodhints \ keypadnavigation \ @@ -62,4 +63,5 @@ win32 { } lessThan(QT_MAJOR_VERSION, 5): SUBDIRS -= bearerex lance qnetworkaccessmanager/qget qmimedatabase qnetworkreply \ -qpainfo qscreen socketengine xembed-raster xembed-widgets windowtransparency +qpainfo qscreen socketengine xembed-raster xembed-widgets windowtransparency \ +foreignwindows -- cgit v1.2.3 From 1a9e1fbbfc96b84bf96927b3573a6528bffc98a5 Mon Sep 17 00:00:00 2001 From: Milla Pohjanheimo Date: Thu, 10 Mar 2016 12:28:57 +0200 Subject: Remove restoreDockWidget from BLACKLIST MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Tested on the Ubuntu 14.04 VM. The test didn't fail anymore with 2000 test rounds Change-Id: Ic12c60e5ebf9c234358a6983bf87fa0a88d7886e Reviewed-by: Tony Sarajärvi --- tests/auto/widgets/widgets/qdockwidget/BLACKLIST | 2 -- 1 file changed, 2 deletions(-) delete mode 100644 tests/auto/widgets/widgets/qdockwidget/BLACKLIST (limited to 'tests') diff --git a/tests/auto/widgets/widgets/qdockwidget/BLACKLIST b/tests/auto/widgets/widgets/qdockwidget/BLACKLIST deleted file mode 100644 index 60adfb9f4b..0000000000 --- a/tests/auto/widgets/widgets/qdockwidget/BLACKLIST +++ /dev/null @@ -1,2 +0,0 @@ -[restoreDockWidget] -ubuntu-14.04 -- cgit v1.2.3 From add95c55108dcda46286846dae5ad12d6ee9057b Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Sat, 12 Mar 2016 15:03:16 +0100 Subject: tst_QSqlQuery: fix UBs (invalid downcasts, member calls) The existing code derived a helper class from QSqlResult and overloaded two protected functions as public ones so the test could call them after casting QSqlResults to that helper class. Both the cast (which is a C-style cast, but with combined static_cast and const_cast semanics) and the following member function call are undefined behavior. Fix by making the test class a friend of QSqlResult, and dropping the casts. Change-Id: I09de2e2b46976d01cfce25892aec6ad36881d3eb Reviewed-by: Mark Brand --- tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp | 82 +++++++++-------------- 1 file changed, 32 insertions(+), 50 deletions(-) (limited to 'tests') diff --git a/tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp b/tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp index b98ab68ae9..bd553d5ffd 100644 --- a/tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp +++ b/tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp @@ -1753,24 +1753,6 @@ void tst_QSqlQuery::synonyms() QCOMPARE( rec.field( 2 ).name().toLower(), QString( "t_varchar" ) ); } -// This class is used to test protected QSqlResult methods -class ResultHelper: public QSqlResult -{ - -public: - ResultHelper(): QSqlResult( 0 ) {} // don't call, it's only for stupid compilers - - bool execBatch( bool bindArray = false ) - { - return QSqlResult::execBatch( bindArray ); - } - - QString boundValueName( int pos ) const - { - return QSqlResult::boundValueName( pos ); - } -}; - // It doesn't make sense to split this into several tests void tst_QSqlQuery::prepare_bind_exec() { @@ -1895,81 +1877,81 @@ void tst_QSqlQuery::prepare_bind_exec() q.bindValue( 0, 0 ); q.bindValue( 1, values[ 0 ] ); QCOMPARE( q.boundValues().size(), 2 ); - QCOMPARE( q.boundValues()[ ((ResultHelper*)q.result())->boundValueName(0) ].toInt(), 0 ); - QCOMPARE( q.boundValues()[ ((ResultHelper*)q.result())->boundValueName(1) ].toString(), values[0] ); + QCOMPARE(q.boundValues()[q.result()->boundValueName(0)].toInt(), 0); + QCOMPARE(q.boundValues()[q.result()->boundValueName(1)].toString(), values[0]); QVERIFY_SQL( q, exec() ); QCOMPARE( q.boundValues().size(), 2 ); - QCOMPARE( q.boundValues()[ ((ResultHelper*)q.result())->boundValueName(0) ].toInt(), 0 ); - QCOMPARE( q.boundValues()[ ((ResultHelper*)q.result())->boundValueName(1) ].toString(), values[0] ); + QCOMPARE(q.boundValues()[q.result()->boundValueName(0)].toInt(), 0); + QCOMPARE(q.boundValues()[q.result()->boundValueName(1)].toString(), values[0]); q.addBindValue( 1 ); q.addBindValue( values[ 1 ] ); QCOMPARE( q.boundValues().size(), 2 ); - QCOMPARE( q.boundValues()[ ((ResultHelper*)q.result())->boundValueName(0) ].toInt(), 1 ); - QCOMPARE( q.boundValues()[ ((ResultHelper*)q.result())->boundValueName(1) ].toString(), values[1] ); + QCOMPARE(q.boundValues()[q.result()->boundValueName(0)].toInt(), 1); + QCOMPARE(q.boundValues()[q.result()->boundValueName(1)].toString(), values[1]); QVERIFY_SQL( q, exec() ); QCOMPARE( q.boundValues().size(), 2 ); - QCOMPARE( q.boundValues()[ ((ResultHelper*)q.result())->boundValueName(0) ].toInt(), 1 ); - QCOMPARE( q.boundValues()[ ((ResultHelper*)q.result())->boundValueName(1) ].toString(), values[1] ); + QCOMPARE(q.boundValues()[q.result()->boundValueName(0)].toInt(), 1); + QCOMPARE(q.boundValues()[q.result()->boundValueName(1)].toString(), values[1]); q.addBindValue( 2 ); q.addBindValue( values[ 2 ] ); QCOMPARE( q.boundValues().size(), 2 ); - QCOMPARE( q.boundValues()[ ((ResultHelper*)q.result())->boundValueName(0) ].toInt(), 2 ); - QCOMPARE( q.boundValues()[ ((ResultHelper*)q.result())->boundValueName(1) ].toString(), values[2] ); + QCOMPARE(q.boundValues()[q.result()->boundValueName(0)].toInt(), 2); + QCOMPARE(q.boundValues()[q.result()->boundValueName(1)].toString(), values[2]); QVERIFY_SQL( q, exec() ); QCOMPARE( q.boundValues().size(), 2 ); - QCOMPARE( q.boundValues()[ ((ResultHelper*)q.result())->boundValueName(0) ].toInt(), 2 ); - QCOMPARE( q.boundValues()[ ((ResultHelper*)q.result())->boundValueName(1) ].toString(), values[2] ); + QCOMPARE(q.boundValues()[q.result()->boundValueName(0)].toInt(), 2); + QCOMPARE(q.boundValues()[q.result()->boundValueName(1)].toString(), values[2]); q.addBindValue( 3 ); q.addBindValue( values[ 3 ] ); QCOMPARE( q.boundValues().size(), 2 ); - QCOMPARE( q.boundValues()[ ((ResultHelper*)q.result())->boundValueName(0) ].toInt(), 3 ); - QCOMPARE( q.boundValues()[ ((ResultHelper*)q.result())->boundValueName(1) ].toString(), values[3] ); + QCOMPARE(q.boundValues()[q.result()->boundValueName(0)].toInt(), 3); + QCOMPARE(q.boundValues()[q.result()->boundValueName(1)].toString(), values[3]); QVERIFY_SQL( q, exec() ); QCOMPARE( q.boundValues().size(), 2 ); - QCOMPARE( q.boundValues()[ ((ResultHelper*)q.result())->boundValueName(0) ].toInt(), 3 ); - QCOMPARE( q.boundValues()[ ((ResultHelper*)q.result())->boundValueName(1) ].toString(), values[3] ); + QCOMPARE(q.boundValues()[q.result()->boundValueName(0)].toInt(), 3); + QCOMPARE(q.boundValues()[q.result()->boundValueName(1)].toString(), values[3]); q.addBindValue( 4 ); q.addBindValue( values[ 4 ] ); QCOMPARE( q.boundValues().size(), 2 ); - QCOMPARE( q.boundValues()[ ((ResultHelper*)q.result())->boundValueName(0) ].toInt(), 4 ); - QCOMPARE( q.boundValues()[ ((ResultHelper*)q.result())->boundValueName(1) ].toString(), values[4] ); + QCOMPARE(q.boundValues()[q.result()->boundValueName(0)].toInt(), 4); + QCOMPARE(q.boundValues()[q.result()->boundValueName(1)].toString(), values[4]); QVERIFY_SQL( q, exec() ); QCOMPARE( q.boundValues().size(), 2 ); - QCOMPARE( q.boundValues()[ ((ResultHelper*)q.result())->boundValueName(0) ].toInt(), 4 ); - QCOMPARE( q.boundValues()[ ((ResultHelper*)q.result())->boundValueName(1) ].toString(), values[4] ); + QCOMPARE(q.boundValues()[q.result()->boundValueName(0)].toInt(), 4); + QCOMPARE(q.boundValues()[q.result()->boundValueName(1)].toString(), values[4]); q.bindValue( 1, values[ 5 ] ); q.bindValue( 0, 5 ); QCOMPARE( q.boundValues().size(), 2 ); - QCOMPARE( q.boundValues()[ ((ResultHelper*)q.result())->boundValueName(0) ].toInt(), 5 ); - QCOMPARE( q.boundValues()[ ((ResultHelper*)q.result())->boundValueName(1) ].toString(), values[5] ); + QCOMPARE(q.boundValues()[q.result()->boundValueName(0)].toInt(), 5); + QCOMPARE(q.boundValues()[q.result()->boundValueName(1)].toString(), values[5]); QVERIFY_SQL( q, exec() ); QCOMPARE( q.boundValues().size(), 2 ); - QCOMPARE( q.boundValues()[ ((ResultHelper*)q.result())->boundValueName(0) ].toInt(), 5 ); - QCOMPARE( q.boundValues()[ ((ResultHelper*)q.result())->boundValueName(1) ].toString(), values[5] ); + QCOMPARE(q.boundValues()[q.result()->boundValueName(0)].toInt(), 5); + QCOMPARE(q.boundValues()[q.result()->boundValueName(1)].toString(), values[5]); q.bindValue( 0, 6 ); q.bindValue( 1, QString() ); QCOMPARE( q.boundValues().size(), 2 ); - QCOMPARE( q.boundValues()[ ((ResultHelper*)q.result())->boundValueName(0) ].toInt(), 6 ); - QCOMPARE( q.boundValues()[ ((ResultHelper*)q.result())->boundValueName(1) ].toString(), QString() ); + QCOMPARE(q.boundValues()[q.result()->boundValueName(0)].toInt(), 6); + QCOMPARE(q.boundValues()[q.result()->boundValueName(1)].toString(), QString()); QVERIFY_SQL( q, exec() ); QCOMPARE( q.boundValues().size(), 2 ); - QCOMPARE( q.boundValues()[ ((ResultHelper*)q.result())->boundValueName(0) ].toInt(), 6 ); - QCOMPARE( q.boundValues()[ ((ResultHelper*)q.result())->boundValueName(1) ].toString(), QString() ); + QCOMPARE(q.boundValues()[q.result()->boundValueName(0)].toInt(), 6); + QCOMPARE(q.boundValues()[q.result()->boundValueName(1)].toString(), QString()); if ( db.driver()->hasFeature( QSqlDriver::Unicode ) ) { q.bindValue( 0, 7 ); q.bindValue( 1, utf8str ); - QCOMPARE( q.boundValues()[ ((ResultHelper*)q.result())->boundValueName(0) ].toInt(), 7 ); - QCOMPARE( q.boundValues()[ ((ResultHelper*)q.result())->boundValueName(1) ].toString(), utf8str ); + QCOMPARE(q.boundValues()[q.result()->boundValueName(0)].toInt(), 7); + QCOMPARE(q.boundValues()[q.result()->boundValueName(1)].toString(), utf8str); QVERIFY_SQL( q, exec() ); - QCOMPARE( q.boundValues()[ ((ResultHelper*)q.result())->boundValueName(0) ].toInt(), 7 ); - QCOMPARE( q.boundValues()[ ((ResultHelper*)q.result())->boundValueName(1) ].toString(), utf8str ); + QCOMPARE(q.boundValues()[q.result()->boundValueName(0)].toInt(), 7); + QCOMPARE(q.boundValues()[q.result()->boundValueName(1)].toString(), utf8str); } QVERIFY_SQL( q, exec( "SELECT * FROM " + qtest_prepare + " order by id" ) ); -- cgit v1.2.3 From 5784c064a9c89ceb1e6dc9857e2c1ed6edf9a7b8 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Mon, 14 Mar 2016 14:51:45 +0100 Subject: tst_QRect: drop a test that depends on int overflow The compiler can statically check that this is undefined behavior: tst_qrect.cpp:3173:52: warning: integer overflow in expression [-Woverflow] << QRect(QPoint(0,0), QPoint(INT_MAX+(0-INT_MIN),INT_MAX+(0-INT_MIN))); ~^~ tst_qrect.cpp:3173:72: warning: integer overflow in expression [-Woverflow] << QRect(QPoint(0,0), QPoint(INT_MAX+(0-INT_MIN),INT_MAX+(0-INT_MIN))); ~^~ Fix by skipping the test (like most of the others are in the block). Change-Id: I359a5e16db6c660c9f11d7dd8fbb40730bd63887 Reviewed-by: Lars Knoll --- tests/auto/corelib/tools/qrect/tst_qrect.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'tests') diff --git a/tests/auto/corelib/tools/qrect/tst_qrect.cpp b/tests/auto/corelib/tools/qrect/tst_qrect.cpp index 585cf5d4d0..c6907dcac2 100644 --- a/tests/auto/corelib/tools/qrect/tst_qrect.cpp +++ b/tests/auto/corelib/tools/qrect/tst_qrect.cpp @@ -3171,8 +3171,7 @@ void tst_QRect::newMoveTopLeft_data() } { - QTest::newRow("LargestCoordQRect_NullQPoint") << getQRectCase(LargestCoordQRect) << getQPointCase(NullQPoint) - << QRect(QPoint(0,0), QPoint(INT_MAX+(0-INT_MIN),INT_MAX+(0-INT_MIN))); + // QTest::newRow("LargestCoordQRect_NullQPoint") -- Not tested as it would cause an overflow QTest::newRow("LargestCoordQRect_SmallestCoordQPoint") << getQRectCase(LargestCoordQRect) << getQPointCase(SmallestCoordQPoint) << QRect(QPoint(INT_MIN,INT_MIN), QPoint(INT_MAX,INT_MAX)); // QTest::newRow("LargestCoordQRect_MiddleNegCoordQPoint") -- Not tested as it would cause an overflow -- cgit v1.2.3 From e4c6d73f925671a9c96558293472ed213861239c Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Mon, 14 Mar 2016 15:18:11 +0100 Subject: QRect: fix UB (int overflow) in center() QRect::center() should be defined for any QRect(x1,y1,x2,x2), INT_MIN <= x1, x2, y1, y2 <= INT_MAX because the average of two signed integers is always representable as a signed integer. But not when it's calculated as (x1+x2)/2, since that expression overflows when x1 > INT_MAX - x2. Instead of playing games with Hacker's Delight-style expressions, or use Google's patented algorithm, which requires two divisions, take advantage of the fact that int is not intmax_t and perform the calculation in the qint64 domain. The cast back to int is always well- defined since, as mentioned, the result is always representable in an int. Fix a test-case that expected a nonsensical result due to overflow. [ChangeLog][QtCore][QRect] Fixed integer overflow in center(). This fixes the result for some corner-cases like a 1x1 rectangle at (INT_MIN, INT_MIN), for which the previous implementation could return anything (due to invoking undefined behavior), but commonly returned (0, 0). Change-Id: I1a885ca6dff770327dd31655c3eb473fcfeb8878 Reviewed-by: Lars Knoll --- tests/auto/corelib/tools/qrect/tst_qrect.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/auto/corelib/tools/qrect/tst_qrect.cpp b/tests/auto/corelib/tools/qrect/tst_qrect.cpp index c6907dcac2..1377e801a7 100644 --- a/tests/auto/corelib/tools/qrect/tst_qrect.cpp +++ b/tests/auto/corelib/tools/qrect/tst_qrect.cpp @@ -2349,7 +2349,7 @@ void tst_QRect::center_data() QTest::newRow( "SmallestQRect" ) << getQRectCase( SmallestQRect ) << QPoint(1,1); QTest::newRow( "MiddleQRect" ) << getQRectCase( MiddleQRect ) << QPoint(0,0); QTest::newRow( "LargestQRect" ) << getQRectCase( LargestQRect ) << QPoint(INT_MAX/2,INT_MAX/2); - QTest::newRow( "SmallestCoordQRect" ) << getQRectCase( SmallestCoordQRect ) << QPoint(0,0); + QTest::newRow( "SmallestCoordQRect" ) << getQRectCase( SmallestCoordQRect ) << QPoint(INT_MIN, INT_MIN); QTest::newRow( "LargestCoordQRect" ) << getQRectCase( LargestCoordQRect ) << QPoint(0,0); QTest::newRow( "RandomQRect" ) << getQRectCase( RandomQRect ) << QPoint(105,207); QTest::newRow( "NegativeSizeQRect" ) << getQRectCase( NegativeSizeQRect ) << QPoint(-4,-4); -- cgit v1.2.3 From e3638174983849c355f9d336759439f78497a3ee Mon Sep 17 00:00:00 2001 From: Milla Pohjanheimo Date: Tue, 15 Mar 2016 07:44:09 +0200 Subject: tst_qtabbar sizeHints fix tst_qtabbar uses fixed values to check the minimumSizeHint and it fails with screens that have a higher resolution. The test still uses the default values, but now in the beginning it creates enough tabs so that it goes over the default. Change-Id: I3f891d2661288d7fad50ad522d73f634b3e91958 Reviewed-by: Andy Shaw --- tests/auto/widgets/widgets/qtabbar/tst_qtabbar.cpp | 26 +++++++++------------- 1 file changed, 10 insertions(+), 16 deletions(-) (limited to 'tests') diff --git a/tests/auto/widgets/widgets/qtabbar/tst_qtabbar.cpp b/tests/auto/widgets/widgets/qtabbar/tst_qtabbar.cpp index ced2253a74..3f1badeda1 100644 --- a/tests/auto/widgets/widgets/qtabbar/tst_qtabbar.cpp +++ b/tests/auto/widgets/widgets/qtabbar/tst_qtabbar.cpp @@ -279,36 +279,30 @@ void tst_QTabBar::sizeHints() { QTabBar tabBar; tabBar.setFont(QFont("Arial", 10)); - tabBar.addTab("tab 01"); - tabBar.addTab("tab 02"); - tabBar.addTab("tab 03"); - tabBar.addTab("tab 04"); - tabBar.addTab("tab 05"); - tabBar.addTab("tab 06"); - tabBar.addTab("This is tab7"); - tabBar.addTab("This is tab8"); - tabBar.addTab("This is tab9 with a very long title"); // No eliding and no scrolling -> tabbar becomes very wide tabBar.setUsesScrollButtons(false); tabBar.setElideMode(Qt::ElideNone); -// qDebug() << tabBar.minimumSizeHint() << tabBar.sizeHint(); -#ifdef Q_OS_MAC - QEXPECT_FAIL("", "QTBUG-27230", Abort); -#endif + tabBar.addTab("tab 01"); + + // Fetch the minimum size hint width and make sure that we create enough + // tabs. + int minimumSizeHintWidth = tabBar.minimumSizeHint().width(); + for (int i = 0; i <= 700 / minimumSizeHintWidth; ++i) + tabBar.addTab(QString("tab 0%1").arg(i+2)); + + //qDebug() << tabBar.minimumSizeHint() << tabBar.sizeHint(); QVERIFY(tabBar.minimumSizeHint().width() > 700); QVERIFY(tabBar.sizeHint().width() > 700); // Scrolling enabled -> no reason to become very wide tabBar.setUsesScrollButtons(true); - // qDebug() << tabBar.minimumSizeHint() << tabBar.sizeHint(); QVERIFY(tabBar.minimumSizeHint().width() < 200); QVERIFY(tabBar.sizeHint().width() > 700); // unchanged // Eliding enabled -> no reason to become very wide tabBar.setUsesScrollButtons(false); tabBar.setElideMode(Qt::ElideRight); -// qDebug() << tabBar.minimumSizeHint() << tabBar.sizeHint(); // The sizeHint is very much dependent on the screen DPI value // so we can not really predict it. @@ -317,7 +311,7 @@ void tst_QTabBar::sizeHints() QVERIFY(tabBarMinSizeHintWidth < tabBarSizeHintWidth); QVERIFY(tabBarSizeHintWidth > 700); // unchanged - tabBar.addTab("This is tab10 with a very long title"); + tabBar.addTab("This is tab with a very long title"); QVERIFY(tabBar.minimumSizeHint().width() > tabBarMinSizeHintWidth); QVERIFY(tabBar.sizeHint().width() > tabBarSizeHintWidth); } -- cgit v1.2.3 From eef3afaa978a25743af7efdda169052b67cc744a Mon Sep 17 00:00:00 2001 From: Maurice Kalinowski Date: Fri, 11 Mar 2016 11:14:49 +0100 Subject: QTextStream test: Change current directory For platforms with builtin testdata/sandboxed platforms we need to change the current directory to be able to create files. Change-Id: I440205c95dd6df1308c6bf24b1b0f67fd697feab Reviewed-by: Oliver Wolff --- tests/auto/corelib/io/qtextstream/test/test.pro | 4 ++++ tests/auto/corelib/io/qtextstream/tst_qtextstream.cpp | 16 ++++++++++++++++ 2 files changed, 20 insertions(+) (limited to 'tests') diff --git a/tests/auto/corelib/io/qtextstream/test/test.pro b/tests/auto/corelib/io/qtextstream/test/test.pro index 39d181344f..073aecdfba 100644 --- a/tests/auto/corelib/io/qtextstream/test/test.pro +++ b/tests/auto/corelib/io/qtextstream/test/test.pro @@ -21,3 +21,7 @@ TESTDATA += \ ../tst_qtextstream.cpp \ ../resources DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0 + +builtin_testdata { + DEFINES += BUILTIN_TESTDATA +} diff --git a/tests/auto/corelib/io/qtextstream/tst_qtextstream.cpp b/tests/auto/corelib/io/qtextstream/tst_qtextstream.cpp index 24dd05223f..13be58a1f1 100644 --- a/tests/auto/corelib/io/qtextstream/tst_qtextstream.cpp +++ b/tests/auto/corelib/io/qtextstream/tst_qtextstream.cpp @@ -65,6 +65,7 @@ public: public slots: void initTestCase(); void cleanup(); + void cleanupTestCase(); private slots: void getSetCheck(); @@ -241,6 +242,9 @@ private: QTemporaryDir tempDir; QString testFileName; +#ifdef BUILTIN_TESTDATA + QSharedPointer m_dataDir; +#endif const QString m_rfc3261FilePath; const QString m_shiftJisFilePath; }; @@ -267,9 +271,14 @@ void tst_QTextStream::initTestCase() testFileName = tempDir.path() + "/testfile"; +#ifdef BUILTIN_TESTDATA + m_dataDir = QEXTRACTTESTDATA("/"); + QVERIFY2(QDir::setCurrent(m_dataDir->path()), qPrintable("Could not chdir to " + m_dataDir->path())); +#else // chdir into the testdata dir and refer to our helper apps with relative paths QString testdata_dir = QFileInfo(QFINDTESTDATA("stdinProcess")).absolutePath(); QVERIFY2(QDir::setCurrent(testdata_dir), qPrintable("Could not chdir to " + testdata_dir)); +#endif } // Testing get/set functions @@ -392,6 +401,13 @@ void tst_QTextStream::cleanup() QCoreApplication::instance()->processEvents(); } +void tst_QTextStream::cleanupTestCase() +{ +#ifdef BUILTIN_TESTDATA + QDir::setCurrent(QCoreApplication::applicationDirPath()); +#endif +} + // ------------------------------------------------------------------------------ void tst_QTextStream::construction() { -- cgit v1.2.3 From e830fa8fc251f697ffee2c215c0121028eeef8ca Mon Sep 17 00:00:00 2001 From: Maurice Kalinowski Date: Fri, 11 Mar 2016 11:12:40 +0100 Subject: tst_QXmlStream::writerHangs(): Create file in temporary directory A test should not write to its directory. Change-Id: I34dfc36387cf5a637b325be29c8a19ff51d9b9c3 Reviewed-by: Oliver Wolff --- tests/auto/corelib/xml/qxmlstream/tst_qxmlstream.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/auto/corelib/xml/qxmlstream/tst_qxmlstream.cpp b/tests/auto/corelib/xml/qxmlstream/tst_qxmlstream.cpp index 341b169113..1da29ac3bd 100644 --- a/tests/auto/corelib/xml/qxmlstream/tst_qxmlstream.cpp +++ b/tests/auto/corelib/xml/qxmlstream/tst_qxmlstream.cpp @@ -905,7 +905,8 @@ void tst_QXmlStream::testFalsePrematureError() const // Regression test for crash due to using empty QStack. void tst_QXmlStream::writerHangs() const { - QFile file("test.xml"); + QTemporaryDir dir(QDir::tempPath() + QLatin1String("/tst_qxmlstream.XXXXXX")); + QFile file(dir.path() + "/test.xml"); QVERIFY(file.open(QIODevice::WriteOnly)); -- cgit v1.2.3 From 9c3c350627c1fc9d7f6e063f9360b096f159a6d7 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Tue, 9 Feb 2016 13:40:42 +0100 Subject: Manual High DPI test: Add test for window masks. Add a toggle for setting a triangular mask on the main window. Task-number: QTBUG-50938 Change-Id: Id4a3ee0b80e170f4ee1d195e60ce7bfa8e524359 Reviewed-by: Shawn Rutledge --- tests/manual/highdpi/main.cpp | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/manual/highdpi/main.cpp b/tests/manual/highdpi/main.cpp index 692a60d511..83aefdb88a 100644 --- a/tests/manual/highdpi/main.cpp +++ b/tests/manual/highdpi/main.cpp @@ -380,16 +380,22 @@ Labels::Labels() class MainWindow : public QMainWindow { + Q_OBJECT public: MainWindow(); QMenu *addNewMenu(const QString &title, int itemCount = 5); +private slots: + void maskActionToggled(bool t); + +private: QIcon qtIcon; QIcon qtIcon1x; QIcon qtIcon2x; QToolBar *fileToolBar; int menuCount; + QAction *m_maskAction; }; MainWindow::MainWindow() @@ -408,7 +414,12 @@ MainWindow::MainWindow() addNewMenu("&Edit"); addNewMenu("&Build"); addNewMenu("&Debug", 4); - addNewMenu("&Transmogrify", 7); + QMenu *menu = addNewMenu("&Transmogrify", 7); + menu->addSeparator(); + m_maskAction = menu->addAction("Mask"); + m_maskAction->setCheckable(true); + connect(m_maskAction, &QAction::toggled, this, &MainWindow::maskActionToggled); + fileToolBar->addAction(m_maskAction); addNewMenu("T&ools"); addNewMenu("&Help", 2); } @@ -431,6 +442,16 @@ QMenu *MainWindow::addNewMenu(const QString &title, int itemCount) return menu; } +void MainWindow::maskActionToggled(bool t) +{ + if (t) { + QVector upperLeftTriangle; + upperLeftTriangle << QPoint(0, 0) << QPoint(width(), 0) << QPoint(0, height()); + setMask(QRegion(QPolygon(upperLeftTriangle))); + } else { + clearMask(); + } +} class StandardIcons : public QWidget { -- cgit v1.2.3 From e7cd32274e144144c1630d65d09d24a1ae0af2d7 Mon Sep 17 00:00:00 2001 From: Maurice Kalinowski Date: Tue, 15 Mar 2016 13:04:50 +0100 Subject: WinRT: Fix QTimeZone transitions by switching backend Previously WinRT was using the UTC backend which fails on all platforms for some QDateTime autotests related to timezone items. Hence switch to the Windows implementation for WinRT as well. However, the windows backend does query the registry heavily, which is not supported on WinRT. Instead use the API version provided by the SDK. Long-term we might want to switch to this version on desktop windows as well, as direct registry access would not be required and we could harmonize the codepaths for both platforms. Change-Id: I620b614e9994aa77b531e5c34c9be1da7e272a30 Reviewed-by: Oliver Wolff --- tests/auto/corelib/tools/qtimezone/tst_qtimezone.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/auto/corelib/tools/qtimezone/tst_qtimezone.cpp b/tests/auto/corelib/tools/qtimezone/tst_qtimezone.cpp index b511abf670..32bb2aa394 100644 --- a/tests/auto/corelib/tools/qtimezone/tst_qtimezone.cpp +++ b/tests/auto/corelib/tools/qtimezone/tst_qtimezone.cpp @@ -898,7 +898,7 @@ void tst_QTimeZone::macTest() void tst_QTimeZone::winTest() { -#if defined(QT_BUILD_INTERNAL) && defined(Q_OS_WIN) && !defined(Q_OS_WINRT) +#if defined(QT_BUILD_INTERNAL) && defined(Q_OS_WIN) // Known datetimes qint64 std = QDateTime(QDate(2012, 1, 1), QTime(0, 0, 0), Qt::UTC).toMSecsSinceEpoch(); qint64 dst = QDateTime(QDate(2012, 6, 1), QTime(0, 0, 0), Qt::UTC).toMSecsSinceEpoch(); -- cgit v1.2.3 From ca4c33a886fb4cec50f1a4140fc29ec731240ecb Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Tue, 9 Feb 2016 14:15:58 +0100 Subject: Manual High DPI test: Create Dnd pixmap with device pixel ratio. Apply the device pixel ratio from the widget unless Shift is pressed. Task-number: QTBUG-46068 Task-number: QTBUG-50938 Change-Id: Ib806b7e545fa228043566800d22d1002728732bf Reviewed-by: Shawn Rutledge --- tests/manual/highdpi/dragwidget.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'tests') diff --git a/tests/manual/highdpi/dragwidget.cpp b/tests/manual/highdpi/dragwidget.cpp index b203566696..193a90cd18 100644 --- a/tests/manual/highdpi/dragwidget.cpp +++ b/tests/manual/highdpi/dragwidget.cpp @@ -168,7 +168,11 @@ void DragWidget::mousePressEvent(QMouseEvent *event) mimeData->setData("application/x-hotspot", QByteArray::number(hotSpot.x()) + " " + QByteArray::number(hotSpot.y())); - QPixmap pixmap(child->size()); + const qreal dpr = devicePixelRatioF() > 1 && !(QGuiApplication::keyboardModifiers() & Qt::ShiftModifier) + ? devicePixelRatioF() : 1; + + QPixmap pixmap(child->size() * dpr); + pixmap.setDevicePixelRatio(dpr); child->render(&pixmap); QDrag *drag = new QDrag(this); -- cgit v1.2.3 From 6ec89bec0a2f06365dc18bda6e95b6c253c19227 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Tue, 23 Feb 2016 01:13:47 +0100 Subject: Fix QFINDTESTDATA when using cmake ninja generator The Qt CI does not have ninja, but the autotest can be used for manual regression finding. cd qtbase/tests/auto/cmake qmake make check cd build cmake . -DHAVE_NINJA=ON ctest -R FINDTESTDATA Change-Id: Ic3f3748f6ab04e37fa5287c59486e5cd46dcabb4 Reviewed-by: Stephen Kelly --- tests/auto/cmake/CMakeLists.txt | 18 +++++++ tests/auto/cmake/test_QFINDTESTDATA/CMakeLists.txt | 11 +++++ .../cmake/test_QFINDTESTDATA/tests/CMakeLists.txt | 4 ++ tests/auto/cmake/test_QFINDTESTDATA/tests/main.cpp | 55 ++++++++++++++++++++++ .../cmake/test_QFINDTESTDATA/tests/testdata.txt | 1 + 5 files changed, 89 insertions(+) create mode 100644 tests/auto/cmake/test_QFINDTESTDATA/CMakeLists.txt create mode 100644 tests/auto/cmake/test_QFINDTESTDATA/tests/CMakeLists.txt create mode 100644 tests/auto/cmake/test_QFINDTESTDATA/tests/main.cpp create mode 100644 tests/auto/cmake/test_QFINDTESTDATA/tests/testdata.txt (limited to 'tests') diff --git a/tests/auto/cmake/CMakeLists.txt b/tests/auto/cmake/CMakeLists.txt index 5248f75a84..1abbef0d68 100644 --- a/tests/auto/cmake/CMakeLists.txt +++ b/tests/auto/cmake/CMakeLists.txt @@ -68,6 +68,24 @@ expect_fail(test_wrap_cpp_options) expect_pass(test_platform_defs_include) expect_pass(test_qtmainwin_library) +if (HAVE_NINJA) + make_directory("${CMAKE_CURRENT_SOURCE_DIR}/test_QFINDTESTDATA/build") + add_test(test_QFINDTESTDATA ${CMAKE_CTEST_COMMAND} + --build-and-test + "${CMAKE_CURRENT_SOURCE_DIR}/test_QFINDTESTDATA" + # Build in a subdir of the source dir. + # This causes Ninja to use relative paths. + "${CMAKE_CURRENT_SOURCE_DIR}/test_QFINDTESTDATA/build" + --build-generator Ninja + --build-options "-DCMAKE_PREFIX_PATH=${CMAKE_PREFIX_PATH}" + ) + add_test(NAME run_test_QFINDTESTDATA COMMAND sh -c "cd \"${CMAKE_SOURCE_DIR}/test_QFINDTESTDATA/build/tests\" && ./test_QFINDTESTDATA -v2") + + set_property(TEST run_test_QFINDTESTDATA + PROPERTY DEPENDS test_QFINDTESTDATA + ) +endif() + if (NOT NO_DBUS) expect_pass(test_dbus_module) endif() diff --git a/tests/auto/cmake/test_QFINDTESTDATA/CMakeLists.txt b/tests/auto/cmake/test_QFINDTESTDATA/CMakeLists.txt new file mode 100644 index 0000000000..e56c3c5eb9 --- /dev/null +++ b/tests/auto/cmake/test_QFINDTESTDATA/CMakeLists.txt @@ -0,0 +1,11 @@ + +cmake_minimum_required(VERSION 2.8.11) + +project(test_QFINDTESTDATA) + +find_package(Qt5Test REQUIRED) + +set(CMAKE_AUTOMOC ON) +set(CMAKE_INCLUDE_CURRENT_DIR ON) + +add_subdirectory(tests) diff --git a/tests/auto/cmake/test_QFINDTESTDATA/tests/CMakeLists.txt b/tests/auto/cmake/test_QFINDTESTDATA/tests/CMakeLists.txt new file mode 100644 index 0000000000..dfe321982a --- /dev/null +++ b/tests/auto/cmake/test_QFINDTESTDATA/tests/CMakeLists.txt @@ -0,0 +1,4 @@ + +add_executable(test_QFINDTESTDATA WIN32 main.cpp) + +target_link_libraries(test_QFINDTESTDATA Qt5::Test) diff --git a/tests/auto/cmake/test_QFINDTESTDATA/tests/main.cpp b/tests/auto/cmake/test_QFINDTESTDATA/tests/main.cpp new file mode 100644 index 0000000000..0a5b6acd32 --- /dev/null +++ b/tests/auto/cmake/test_QFINDTESTDATA/tests/main.cpp @@ -0,0 +1,55 @@ +/**************************************************************************** +** +** Copyright (C) 2016 Stephen Kelly +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL21$ +** 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 http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** As a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include + +class TestClass : public QObject +{ + Q_OBJECT +public: + TestClass(QObject* parent = 0) {} + +private slots: + void doTest(); +}; + +void TestClass::doTest() +{ + QFile f(QFINDTESTDATA("testdata.txt")); + QVERIFY(f.open(QFile::ReadOnly)); + QCOMPARE(f.readAll().trimmed(), QByteArrayLiteral("This is a test.")); +} + +QTEST_MAIN(TestClass) +#include "main.moc" diff --git a/tests/auto/cmake/test_QFINDTESTDATA/tests/testdata.txt b/tests/auto/cmake/test_QFINDTESTDATA/tests/testdata.txt new file mode 100644 index 0000000000..484ba93ef5 --- /dev/null +++ b/tests/auto/cmake/test_QFINDTESTDATA/tests/testdata.txt @@ -0,0 +1 @@ +This is a test. -- cgit v1.2.3