diff options
Diffstat (limited to 'tests/auto')
19 files changed, 393 insertions, 12 deletions
diff --git a/tests/auto/corelib/plugin/qfactoryloader/plugin1/plugin1.pro b/tests/auto/corelib/plugin/qfactoryloader/plugin1/plugin1.pro index b7a641959a..132f01092a 100644 --- a/tests/auto/corelib/plugin/qfactoryloader/plugin1/plugin1.pro +++ b/tests/auto/corelib/plugin/qfactoryloader/plugin1/plugin1.pro @@ -5,6 +5,7 @@ HEADERS = plugin1.h SOURCES = plugin1.cpp TARGET = $$qtLibraryTarget(plugin1) DESTDIR = ../bin +winrt:include(../winrt.pri) # This is testdata for the tst_qpluginloader test. target.path = $$[QT_INSTALL_TESTS]/tst_qfactoryloader/bin diff --git a/tests/auto/corelib/plugin/qfactoryloader/plugin2/plugin2.pro b/tests/auto/corelib/plugin/qfactoryloader/plugin2/plugin2.pro index b536aff486..b47ed91535 100644 --- a/tests/auto/corelib/plugin/qfactoryloader/plugin2/plugin2.pro +++ b/tests/auto/corelib/plugin/qfactoryloader/plugin2/plugin2.pro @@ -5,6 +5,7 @@ HEADERS = plugin2.h SOURCES = plugin2.cpp TARGET = $$qtLibraryTarget(plugin2) DESTDIR = ../bin +winrt:include(../winrt.pri) # This is testdata for the tst_qpluginloader test. target.path = $$[QT_INSTALL_TESTS]/tst_qfactoryloader/bin diff --git a/tests/auto/corelib/plugin/qfactoryloader/winrt.pri b/tests/auto/corelib/plugin/qfactoryloader/winrt.pri new file mode 100644 index 0000000000..31602634b2 --- /dev/null +++ b/tests/auto/corelib/plugin/qfactoryloader/winrt.pri @@ -0,0 +1,9 @@ +# We cannot use TESTDATA as plugins have to reside physically +# inside the package directory +winrt { + CONFIG(debug, debug|release) { + DESTDIR = ../debug/bin + } else { + DESTDIR = ../release/bin + } +} diff --git a/tests/auto/corelib/plugin/qlibrary/tst_qlibrary.cpp b/tests/auto/corelib/plugin/qlibrary/tst_qlibrary.cpp index d1c5ee92cb..ed41ab51e1 100644 --- a/tests/auto/corelib/plugin/qlibrary/tst_qlibrary.cpp +++ b/tests/auto/corelib/plugin/qlibrary/tst_qlibrary.cpp @@ -134,9 +134,11 @@ typedef int (*VersionFunction)(void); void tst_QLibrary::initTestCase() { +#ifndef Q_OS_WINRT // chdir to our testdata directory, and use relative paths in some tests. QString testdatadir = QFileInfo(QFINDTESTDATA("library_path")).absolutePath(); QVERIFY2(QDir::setCurrent(testdatadir), qPrintable("Could not chdir to " + testdatadir)); +#endif } void tst_QLibrary::version_data() @@ -412,7 +414,7 @@ void tst_QLibrary::loadHints_data() QString appDir = QCoreApplication::applicationDirPath(); lh |= QLibrary::ResolveAllSymbolsHint; -# if defined(Q_OS_WIN32) || defined(Q_OS_WINCE) +# if defined(Q_OS_WIN32) || defined(Q_OS_WINCE) || defined(Q_OS_WINRT) QTest::newRow( "ok01 (with suffix)" ) << appDir + "/mylib.dll" << int(lh) << true; QTest::newRow( "ok02 (with non-standard suffix)" ) << appDir + "/mylib.dl2" << int(lh) << true; QTest::newRow( "ok03 (with many dots)" ) << appDir + "/system.qt.test.mylib.dll" << int(lh) << true; @@ -464,7 +466,7 @@ void tst_QLibrary::fileName_data() QTest::newRow( "ok02" ) << sys_qualifiedLibraryName(QLatin1String("mylib")) << sys_qualifiedLibraryName(QLatin1String("mylib")); -#ifdef Q_OS_WIN +#if defined(Q_OS_WIN) && !defined(Q_OS_WINRT) #ifndef Q_OS_WINCE QTest::newRow( "ok03" ) << "user32" << "USER32.dll"; diff --git a/tests/auto/corelib/plugin/qpluginloader/lib/lib.pro b/tests/auto/corelib/plugin/qpluginloader/lib/lib.pro index bd6f19cb4f..44b71e6e99 100644 --- a/tests/auto/corelib/plugin/qpluginloader/lib/lib.pro +++ b/tests/auto/corelib/plugin/qpluginloader/lib/lib.pro @@ -4,6 +4,7 @@ CONFIG -= staticlib SOURCES = mylib.c TARGET = tst_qpluginloaderlib DESTDIR = ../bin +winrt:include(../winrt.pri) QT = core win32-msvc: DEFINES += WIN32_MSVC diff --git a/tests/auto/corelib/plugin/qpluginloader/theplugin/theplugin.pro b/tests/auto/corelib/plugin/qpluginloader/theplugin/theplugin.pro index 6ec4a8de05..6aa8161699 100644 --- a/tests/auto/corelib/plugin/qpluginloader/theplugin/theplugin.pro +++ b/tests/auto/corelib/plugin/qpluginloader/theplugin/theplugin.pro @@ -6,6 +6,7 @@ SOURCES = theplugin.cpp #TARGET = $$qtLibraryTarget(theplugin) TARGET = theplugin DESTDIR = ../bin +winrt:include(../winrt.pri) QT = core # This is testdata for the tst_qpluginloader test. diff --git a/tests/auto/corelib/plugin/qpluginloader/winrt.pri b/tests/auto/corelib/plugin/qpluginloader/winrt.pri new file mode 100644 index 0000000000..31602634b2 --- /dev/null +++ b/tests/auto/corelib/plugin/qpluginloader/winrt.pri @@ -0,0 +1,9 @@ +# We cannot use TESTDATA as plugins have to reside physically +# inside the package directory +winrt { + CONFIG(debug, debug|release) { + DESTDIR = ../debug/bin + } else { + DESTDIR = ../release/bin + } +} diff --git a/tests/auto/corelib/plugin/quuid/tst_quuid.cpp b/tests/auto/corelib/plugin/quuid/tst_quuid.cpp index 2e6b1a31cc..e2c137e25f 100644 --- a/tests/auto/corelib/plugin/quuid/tst_quuid.cpp +++ b/tests/auto/corelib/plugin/quuid/tst_quuid.cpp @@ -91,9 +91,11 @@ void tst_QUuid::initTestCase() //"{1ab6e93a-b1cb-4a87-ba47-ec7e99039a7b}"; uuidB = QUuid(0x1ab6e93a, 0xb1cb, 0x4a87, 0xba, 0x47, 0xec, 0x7e, 0x99, 0x03, 0x9a, 0x7b); +#ifndef QT_NO_PROCESS // chdir to the directory containing our testdata, then refer to it with relative paths QString testdata_dir = QFileInfo(QFINDTESTDATA("testProcessUniqueness")).absolutePath(); QVERIFY2(QDir::setCurrent(testdata_dir), qPrintable("Could not chdir to " + testdata_dir)); +#endif //"{3d813cbb-47fb-32ba-91df-831e1593ac29}"; http://www.rfc-editor.org/errata_search.php?rfc=4122&eid=1352 uuidC = QUuid(0x3d813cbb, 0x47fb, 0x32ba, 0x91, 0xdf, 0x83, 0x1e, 0x15, 0x93, 0xac, 0x29); diff --git a/tests/auto/corelib/tools/qdatetime/tst_qdatetime.cpp b/tests/auto/corelib/tools/qdatetime/tst_qdatetime.cpp index 9cadf60afb..ff049b7600 100644 --- a/tests/auto/corelib/tools/qdatetime/tst_qdatetime.cpp +++ b/tests/auto/corelib/tools/qdatetime/tst_qdatetime.cpp @@ -1610,8 +1610,14 @@ void tst_QDateTime::daylightSavingsTimeChange_data() { QTest::addColumn<QDate>("inDST"); QTest::addColumn<QDate>("outDST"); - QTest::newRow("Autumn") << QDate(2006, 8, 1) << QDate(2006, 12, 1); - QTest::newRow("Spring") << QDate(2006, 5, 1) << QDate(2006, 2, 1); + QTest::addColumn<int>("days"); // from in to out; -ve if reversed + QTest::addColumn<int>("months"); + + QTest::newRow("Autumn") << QDate(2006, 8, 1) << QDate(2006, 12, 1) + << 122 << 4; + + QTest::newRow("Spring") << QDate(2006, 5, 1) << QDate(2006, 2, 1) + << -89 << -3; } void tst_QDateTime::daylightSavingsTimeChange() @@ -1631,6 +1637,8 @@ void tst_QDateTime::daylightSavingsTimeChange() QFETCH(QDate, inDST); QFETCH(QDate, outDST); + QFETCH(int, days); + QFETCH(int, months); // First with simple construction QDateTime dt = QDateTime(outDST, QTime(0, 0, 0), Qt::LocalTime); @@ -1640,6 +1648,22 @@ void tst_QDateTime::daylightSavingsTimeChange() dt = dt.addSecs(1); QCOMPARE(dt, QDateTime(inDST, QTime(0, 0, 1))); + // now using addDays: + dt = dt.addDays(days).addSecs(1); + QCOMPARE(dt, QDateTime(outDST, QTime(0, 0, 2))); + + // ... and back again: + dt = dt.addDays(-days).addSecs(1); + QCOMPARE(dt, QDateTime(inDST, QTime(0, 0, 3))); + + // now using addMonths: + dt = dt.addMonths(months).addSecs(1); + QCOMPARE(dt, QDateTime(outDST, QTime(0, 0, 4))); + + // ... and back again: + dt = dt.addMonths(-months).addSecs(1); + QCOMPARE(dt, QDateTime(inDST, QTime(0, 0, 5))); + // now using fromTime_t dt = QDateTime::fromTime_t(outDSTsecs); QCOMPARE(dt, QDateTime(outDST, QTime(0, 0, 0))); @@ -1647,6 +1671,44 @@ void tst_QDateTime::daylightSavingsTimeChange() dt.setDate(inDST); dt = dt.addSecs(60); QCOMPARE(dt, QDateTime(inDST, QTime(0, 1, 0))); + + // using addMonths: + dt = dt.addMonths(months).addSecs(60); + QCOMPARE(dt, QDateTime(outDST, QTime(0, 2, 0))); + // back again: + dt = dt.addMonths(-months).addSecs(60); + QCOMPARE(dt, QDateTime(inDST, QTime(0, 3, 0))); + + // using addDays: + dt = dt.addDays(days).addSecs(60); + QCOMPARE(dt, QDateTime(outDST, QTime(0, 4, 0))); + // back again: + dt = dt.addDays(-days).addSecs(60); + QCOMPARE(dt, QDateTime(inDST, QTime(0, 5, 0))); + + // Now use the result of a UTC -> LocalTime conversion + dt = QDateTime(outDST, QTime(0, 0, 0), Qt::LocalTime).toUTC(); + dt = QDateTime(dt.date(), dt.time(), Qt::UTC).toLocalTime(); + QCOMPARE(dt, QDateTime(outDST, QTime(0, 0, 0))); + + // using addDays: + dt = dt.addDays(-days).addSecs(3600); + QCOMPARE(dt, QDateTime(inDST, QTime(1, 0, 0))); + // back again + dt = dt.addDays(days).addSecs(3600); + QCOMPARE(dt, QDateTime(outDST, QTime(2, 0, 0))); + + // using addMonths: + dt = dt.addMonths(-months).addSecs(3600); + QCOMPARE(dt, QDateTime(inDST, QTime(3, 0, 0))); + // back again: + dt = dt.addMonths(months).addSecs(3600); + QCOMPARE(dt, QDateTime(outDST, QTime(4, 0, 0))); + + // using setDate: + dt.setDate(inDST); + dt = dt.addSecs(3600); + QCOMPARE(dt, QDateTime(inDST, QTime(5, 0, 0))); } void tst_QDateTime::springForward_data() @@ -2222,7 +2284,9 @@ void tst_QDateTime::fromStringStringFormat_data() QTest::newRow("data5") << QString("10") << QString("'") << invalidDateTime(); QTest::newRow("data6") << QString("pm") << QString("ap") << QDateTime(defDate(), QTime(12, 0, 0)); QTest::newRow("data7") << QString("foo") << QString("ap") << invalidDateTime(); - QTest::newRow("data8") << QString("101010") << QString("dMyy") << QDateTime(QDate(1910, 10, 10), QTime()); + // Day non-conflict should not hide earlier year conflict (1963-03-01 was a + // Friday; asking for Thursday moves this, without conflict, to the 7th): + QTest::newRow("data8") << QString("77 03 1963 " + thu) << QString("yy MM yyyy ddd") << invalidDateTime(); QTest::newRow("data9") << QString("101010") << QString("dMyy") << QDateTime(QDate(1910, 10, 10), QTime()); QTest::newRow("data10") << QString("101010") << QString("dMyy") << QDateTime(QDate(1910, 10, 10), QTime()); QTest::newRow("data11") << date << QString("dd MMM yy") << QDateTime(QDate(1910, 10, 10), QTime()); diff --git a/tests/auto/dbus/qdbusconnection_no_libdbus/qdbusconnection_no_libdbus.pro b/tests/auto/dbus/qdbusconnection_no_libdbus/qdbusconnection_no_libdbus.pro index cb0eab1a18..d1b27ee8c0 100644 --- a/tests/auto/dbus/qdbusconnection_no_libdbus/qdbusconnection_no_libdbus.pro +++ b/tests/auto/dbus/qdbusconnection_no_libdbus/qdbusconnection_no_libdbus.pro @@ -1,5 +1,5 @@ CONFIG += testcase parallel_test TARGET = tst_qdbusconnection_no_libdbus QT = core dbus testlib -DEFINES += SIMULATE_LOAD_FAIL +DEFINES += SIMULATE_LOAD_FAIL tst_QDBusConnectionNoBus=tst_QDBusConnectionNoLibDBus1 SOURCES += ../qdbusconnection_no_bus/tst_qdbusconnection_no_bus.cpp diff --git a/tests/auto/gui/kernel/kernel.pro b/tests/auto/gui/kernel/kernel.pro index 5254e755d4..5000e1a926 100644 --- a/tests/auto/gui/kernel/kernel.pro +++ b/tests/auto/gui/kernel/kernel.pro @@ -11,6 +11,7 @@ SUBDIRS=\ qguitimer \ qguivariant \ qinputmethod \ + qkeyevent \ qkeysequence \ qmouseevent \ qmouseevent_modal \ diff --git a/tests/auto/gui/kernel/qkeyevent/qkeyevent.pro b/tests/auto/gui/kernel/qkeyevent/qkeyevent.pro new file mode 100644 index 0000000000..c0a5786e27 --- /dev/null +++ b/tests/auto/gui/kernel/qkeyevent/qkeyevent.pro @@ -0,0 +1,4 @@ +CONFIG += testcase +TARGET = tst_qkeyevent +SOURCES += tst_qkeyevent.cpp +QT = core gui testlib diff --git a/tests/auto/gui/kernel/qkeyevent/tst_qkeyevent.cpp b/tests/auto/gui/kernel/qkeyevent/tst_qkeyevent.cpp new file mode 100644 index 0000000000..bd68400047 --- /dev/null +++ b/tests/auto/gui/kernel/qkeyevent/tst_qkeyevent.cpp @@ -0,0 +1,189 @@ +/**************************************************************************** +** +** 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: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 <QtTest/QtTest> + +#include <QtCore/qcoreapplication.h> +#include <QtGui/qevent.h> +#include <QtGui/qwindow.h> + +class Window : public QWindow +{ +public: + ~Window() { reset(); } + + void keyPressEvent(QKeyEvent *event) { recordEvent(event); } + void keyReleaseEvent(QKeyEvent *event) { recordEvent(event); } + + void reset() { + qDeleteAll(keyEvents.begin(), keyEvents.end()); + keyEvents.clear(); + } +private: + void recordEvent(QKeyEvent *event) { + keyEvents.append(new QKeyEvent(event->type(), event->key(), event->modifiers(), event->nativeScanCode(), + event->nativeVirtualKey(), event->nativeModifiers(), event->text(), + event->isAutoRepeat(), event->count())); + } + +public: + QVector<QKeyEvent*> keyEvents; +}; + +class tst_QKeyEvent : public QObject +{ + Q_OBJECT +public: + tst_QKeyEvent(); + ~tst_QKeyEvent(); + +private slots: + void basicEventDelivery(); + void modifiers_data(); + void modifiers(); +}; + +tst_QKeyEvent::tst_QKeyEvent() +{ +} + +tst_QKeyEvent::~tst_QKeyEvent() +{ +} + +void tst_QKeyEvent::basicEventDelivery() +{ + Window window; + window.showNormal(); + QVERIFY(QTest::qWaitForWindowExposed(&window)); + + const Qt::Key key = Qt::Key_A; + const Qt::KeyboardModifier modifiers = Qt::NoModifier; + + QTest::keyClick(&window, key, modifiers); + + QCOMPARE(window.keyEvents.size(), 2); + QCOMPARE(window.keyEvents.first()->type(), QKeyEvent::KeyPress); + QCOMPARE(window.keyEvents.last()->type(), QKeyEvent::KeyRelease); + foreach (const QKeyEvent *event, window.keyEvents) { + QCOMPARE(Qt::Key(event->key()), key); + QCOMPARE(Qt::KeyboardModifiers(event->modifiers()), modifiers); + } +} + +static bool orderByModifier(const QVector<int> &v1, const QVector<int> &v2) +{ + if (v1.size() != v2.size()) + return v1.size() < v2.size(); + + for (int i = 0; i < qMin(v1.size(), v2.size()); ++i) { + if (v1.at(i) == v2.at(i)) + continue; + + return v1.at(i) < v2.at(i); + } + + return true; +} + +void tst_QKeyEvent::modifiers_data() +{ + struct Modifier + { + Qt::Key key; + Qt::KeyboardModifier modifier; + }; + static const Modifier modifiers[] = { + { Qt::Key_Shift, Qt::ShiftModifier }, + { Qt::Key_Control, Qt::ControlModifier }, + { Qt::Key_Alt, Qt::AltModifier }, + { Qt::Key_Meta, Qt::MetaModifier }, + }; + + QVector<QVector<int>> modifierCombinations; + + // Generate powerset (minus the empty set) of possible modifier combinations + static const int kNumModifiers = sizeof(modifiers) / sizeof(Modifier); + for (quint64 bitmask = 1; bitmask < (1 << kNumModifiers) ; ++bitmask) { + QVector<int> modifierCombination; + for (quint64 modifier = 0; modifier < kNumModifiers; ++modifier) { + if (bitmask & (1 << modifier)) + modifierCombination.append(modifier); + } + modifierCombinations.append(modifierCombination); + } + + qSort(modifierCombinations.begin(), modifierCombinations.end(), orderByModifier); + + QTest::addColumn<Qt::KeyboardModifiers>("modifiers"); + foreach (const QVector<int> combination, modifierCombinations) { + int keys[4] = {}; + Qt::KeyboardModifiers mods; + for (int i = 0; i < combination.size(); ++i) { + Modifier modifier = modifiers[combination.at(i)]; + keys[i] = modifier.key; + mods |= modifier.modifier; + } + QKeySequence keySequence(keys[0], keys[1], keys[2], keys[3]); + QTest::newRow(keySequence.toString(QKeySequence::NativeText).toUtf8().constData()) << mods; + } +} + +void tst_QKeyEvent::modifiers() +{ + Window window; + window.showNormal(); + QVERIFY(QTest::qWaitForWindowExposed(&window)); + + const Qt::Key key = Qt::Key_A; + QFETCH(Qt::KeyboardModifiers, modifiers); + + QTest::keyClick(&window, key, modifiers); + + int numKeys = qPopulationCount(quint64(modifiers)) + 1; + QCOMPARE(window.keyEvents.size(), numKeys * 2); + + for (int i = 0; i < window.keyEvents.size(); ++i) { + const QKeyEvent *event = window.keyEvents.at(i); + QCOMPARE(event->type(), i < numKeys ? QKeyEvent::KeyPress : QKeyEvent::KeyRelease); + if (i == numKeys - 1 || i == numKeys) { + QCOMPARE(Qt::Key(event->key()), key); + QCOMPARE(event->modifiers(), modifiers); + } else { + QVERIFY(Qt::Key(event->key()) != key); + } + } +} + +QTEST_MAIN(tst_QKeyEvent) +#include "tst_qkeyevent.moc" diff --git a/tests/auto/gui/kernel/qkeysequence/tst_qkeysequence.cpp b/tests/auto/gui/kernel/qkeysequence/tst_qkeysequence.cpp index cde9f95612..0d0b6ae81e 100644 --- a/tests/auto/gui/kernel/qkeysequence/tst_qkeysequence.cpp +++ b/tests/auto/gui/kernel/qkeysequence/tst_qkeysequence.cpp @@ -31,7 +31,6 @@ #include <qkeysequence.h> #include <qpa/qplatformtheme.h> #include <qpa/qplatformtheme_p.h> -#include <private/qkeysequence_p.h> #include <private/qguiapplication_p.h> #include <QTranslator> #include <QLibraryInfo> diff --git a/tests/auto/gui/text/qfontcache/tst_qfontcache.cpp b/tests/auto/gui/text/qfontcache/tst_qfontcache.cpp index 9a25eb353d..27796cda51 100644 --- a/tests/auto/gui/text/qfontcache/tst_qfontcache.cpp +++ b/tests/auto/gui/text/qfontcache/tst_qfontcache.cpp @@ -43,6 +43,9 @@ public: virtual ~tst_QFontCache(); private slots: + void engineData_data(); + void engineData(); + void clear(); }; @@ -64,6 +67,52 @@ tst_QFontCache::~tst_QFontCache() { } +void tst_QFontCache::engineData_data() +{ + QTest::addColumn<QString>("family"); + QTest::addColumn<QString>("cacheKey"); + + QTest::newRow("unquoted-family-name") << QString("Times New Roman") << QString("Times New Roman"); + QTest::newRow("quoted-family-name") << QString("'Times New Roman'") << QString("Times New Roman"); + QTest::newRow("invalid") << QString("invalid") << QString("invalid"); + QTest::newRow("multiple") << QString("invalid, Times New Roman") << QString("invalid,Times New Roman"); + QTest::newRow("multiple spaces") << QString("invalid, Times New Roman ") << QString("invalid,Times New Roman"); + QTest::newRow("multiple spaces quotes") << QString("'invalid', Times New Roman ") << QString("invalid,Times New Roman"); + QTest::newRow("multiple2") << QString("invalid, Times New Roman , foobar, 'baz'") << QString("invalid,Times New Roman,foobar,baz"); + QTest::newRow("invalid spaces") << QString("invalid spaces, Times New Roman ") << QString("invalid spaces,Times New Roman"); + QTest::newRow("invalid spaces quotes") << QString("'invalid spaces', 'Times New Roman' ") << QString("invalid spaces,Times New Roman"); +} + +void tst_QFontCache::engineData() +{ + QFETCH(QString, family); + QFETCH(QString, cacheKey); + + QFont f(family); + f.exactMatch(); // loads engine + + QFontPrivate *d = QFontPrivate::get(f); + + QFontDef req = d->request; + // copy-pasted from QFontDatabase::load(), to engineer the cache key + if (req.pixelSize == -1) { + req.pixelSize = std::floor(((req.pointSize * d->dpi) / 72) * 100 + 0.5) / 100; + req.pixelSize = qRound(req.pixelSize); + } + if (req.pointSize < 0) + req.pointSize = req.pixelSize*72.0/d->dpi; + if (req.weight == 0) + req.weight = QFont::Normal; + if (req.stretch == 0) + req.stretch = 100; + + req.family = cacheKey; + + QFontEngineData *engineData = QFontCache::instance()->findEngineData(req); + + QCOMPARE(engineData, QFontPrivate::get(f)->engineData); +} + void tst_QFontCache::clear() { #ifdef QT_BUILD_INTERNAL @@ -105,7 +154,7 @@ void tst_QFontCache::clear() fontEngine->ref.ref(); // cache the engine once again; there is a special case when the engine is cached more than once - QFontCache::instance()->insertEngine(QFontCache::Key(QFontDef(), 0, 0), fontEngine); + QFontCache::instance()->insertEngine(QFontCache::Key(QFontDef(), 0, 1), fontEngine); } // use it: diff --git a/tests/auto/sql/kernel/qsqldatabase/tst_qsqldatabase.cpp b/tests/auto/sql/kernel/qsqldatabase/tst_qsqldatabase.cpp index e6d31b8770..bd8fbcca0e 100644 --- a/tests/auto/sql/kernel/qsqldatabase/tst_qsqldatabase.cpp +++ b/tests/auto/sql/kernel/qsqldatabase/tst_qsqldatabase.cpp @@ -141,6 +141,7 @@ private slots: void mysql_multiselect(); // For task 144331 void mysql_savepointtest_data() { generic_data("QMYSQL"); } void mysql_savepointtest(); + void mysql_connectWithInvalidAddress(); void accessOdbc_strings_data() { generic_data(); } void accessOdbc_strings(); @@ -2187,6 +2188,14 @@ void tst_QSqlDatabase::mysql_savepointtest() QVERIFY_SQL(q, exec("savepoint foo")); } +void tst_QSqlDatabase::mysql_connectWithInvalidAddress() +{ + // Ensure that giving invalid connection parameters fails correctly + QSqlDatabase db = QSqlDatabase::addDatabase("QMYSQL"); + db.setHostName("invalid.local"); + QCOMPARE(db.open(), false); +} + void tst_QSqlDatabase::oci_tables() { QSKIP("Requires specific permissions to create a system table"); diff --git a/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp b/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp index 24f9471a92..afee548c9b 100644 --- a/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp +++ b/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp @@ -256,9 +256,7 @@ private slots: #endif void raise(); void lower(); -#ifndef QT_MAC_USE_COCOA void stackUnder(); -#endif void testContentsPropagation(); void saveRestoreGeometry(); void restoreVersion1Geometry_data(); @@ -315,9 +313,7 @@ private slots: void moveChild(); void showAndMoveChild(); -#ifndef QT_MAC_USE_COCOA void subtractOpaqueSiblings(); -#endif #if defined (Q_OS_WIN) && !defined(Q_OS_WINCE) && !defined(Q_OS_WINRT) void setGeometry_win(); diff --git a/tests/auto/widgets/kernel/qwindowcontainer/tst_qwindowcontainer.cpp b/tests/auto/widgets/kernel/qwindowcontainer/tst_qwindowcontainer.cpp index 3178b31e06..406b21ccf6 100644 --- a/tests/auto/widgets/kernel/qwindowcontainer/tst_qwindowcontainer.cpp +++ b/tests/auto/widgets/kernel/qwindowcontainer/tst_qwindowcontainer.cpp @@ -76,6 +76,7 @@ private slots: void testActivation(); void testAncestorChange(); void testDockWidget(); + void testNativeContainerParent(); void cleanup(); private: @@ -325,6 +326,23 @@ void tst_QWindowContainer::testDockWidget() QTRY_COMPARE(window->parent(), mainWindow.window()->windowHandle()); } +void tst_QWindowContainer::testNativeContainerParent() +{ + QWidget root; + root.setWindowTitle(QTest::currentTestFunction()); + root.setGeometry(m_availableGeometry.x() + 50, m_availableGeometry.y() + 50, 200, 200); + + Window *window = new Window(); + QWidget *container = QWidget::createWindowContainer(window, &root); + container->setAttribute(Qt::WA_NativeWindow); + container->setGeometry(50, 50, 150, 150); + + root.show(); + + QVERIFY(QTest::qWaitForWindowExposed(window)); + QTRY_COMPARE(window->parent(), container->windowHandle()); +} + QTEST_MAIN(tst_QWindowContainer) #include "tst_qwindowcontainer.moc" diff --git a/tests/auto/widgets/widgets/qdockwidget/tst_qdockwidget.cpp b/tests/auto/widgets/widgets/qdockwidget/tst_qdockwidget.cpp index baa1628714..cb55bd32b0 100644 --- a/tests/auto/widgets/widgets/qdockwidget/tst_qdockwidget.cpp +++ b/tests/auto/widgets/widgets/qdockwidget/tst_qdockwidget.cpp @@ -70,6 +70,7 @@ private slots: void titleBarDoubleClick(); void restoreStateOfFloating(); void restoreDockWidget(); + void restoreStateWhileStillFloating(); // task specific tests: void task165177_deleteFocusWidget(); void task169808_setFloating(); @@ -752,6 +753,31 @@ void tst_QDockWidget::restoreStateOfFloating() QVERIFY(!dock->isFloating()); } +void tst_QDockWidget::restoreStateWhileStillFloating() +{ + // When the dock widget is already floating then it takes a different code path + // so this test covers the case where the restoreState() is effectively just + // moving it back and resizing it + const QRect availGeom = QApplication::desktop()->availableGeometry(); + const QPoint startingDockPos = availGeom.center(); + QMainWindow mw; + QDockWidget *dock = createTestDock(mw); + mw.addDockWidget(Qt::TopDockWidgetArea, dock); + dock->setFloating(true); + dock->move(startingDockPos); + mw.show(); + QVERIFY(QTest::qWaitForWindowExposed(&mw)); + QVERIFY(dock->isFloating()); + QByteArray ba = mw.saveState(); + const QPoint dockPos = dock->pos(); + dock->move(availGeom.topLeft() + QPoint(10, 10)); + dock->resize(dock->size() + QSize(10, 10)); + QVERIFY(mw.restoreState(ba)); + QVERIFY(dock->isFloating()); + if (!QGuiApplication::platformName().compare("xcb", Qt::CaseInsensitive)) + QTRY_COMPARE(dock->pos(), dockPos); +} + void tst_QDockWidget::restoreDockWidget() { QByteArray geometry; |