diff options
author | Liang Qi <liang.qi@qt.io> | 2016-09-16 23:16:25 +0200 |
---|---|---|
committer | Liang Qi <liang.qi@qt.io> | 2016-09-16 23:16:25 +0200 |
commit | d148019f16e3c95916731e59e0324e7c470cc1fc (patch) | |
tree | d9c0640c9055f24379468b8f55b3419f30a37c47 /tests/auto | |
parent | 8ceab12814a7437a01d917c83ec28fd6e81c459e (diff) | |
parent | 6b9c57f8cd3df65702db327616913fa9d8172237 (diff) |
Merge remote-tracking branch 'origin/5.6' into 5.7
Conflicts:
src/plugins/platforms/qnx/qqnxscreeneventhandler.cpp
Change-Id: I0af32ee55936d523cbd259b6fe82eb9c409f9074
Diffstat (limited to 'tests/auto')
-rw-r--r-- | tests/auto/corelib/tools/qlatin1string/tst_qlatin1string.cpp | 57 | ||||
-rw-r--r-- | tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp | 45 | ||||
-rw-r--r-- | tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp | 53 |
3 files changed, 135 insertions, 20 deletions
diff --git a/tests/auto/corelib/tools/qlatin1string/tst_qlatin1string.cpp b/tests/auto/corelib/tools/qlatin1string/tst_qlatin1string.cpp index 1295a36c1a..878b4b52b6 100644 --- a/tests/auto/corelib/tools/qlatin1string/tst_qlatin1string.cpp +++ b/tests/auto/corelib/tools/qlatin1string/tst_qlatin1string.cpp @@ -30,6 +30,15 @@ #include <QString> +// Preserve QLatin1String-ness (QVariant(QLatin1String) creates a QVariant::String): +struct QLatin1StringContainer { + QLatin1String l1; +}; +QT_BEGIN_NAMESPACE +Q_DECLARE_TYPEINFO(QLatin1StringContainer, Q_MOVABLE_TYPE); +QT_END_NAMESPACE +Q_DECLARE_METATYPE(QLatin1StringContainer) + class tst_QLatin1String : public QObject { Q_OBJECT @@ -37,6 +46,8 @@ class tst_QLatin1String : public QObject private Q_SLOTS: void nullString(); void emptyString(); + void relationalOperators_data(); + void relationalOperators(); }; void tst_QLatin1String::nullString() @@ -114,7 +125,53 @@ void tst_QLatin1String::emptyString() } } +void tst_QLatin1String::relationalOperators_data() +{ + QTest::addColumn<QLatin1StringContainer>("lhs"); + QTest::addColumn<int>("lhsOrderNumber"); + QTest::addColumn<QLatin1StringContainer>("rhs"); + QTest::addColumn<int>("rhsOrderNumber"); + struct Data { + QLatin1String l1; + int order; + } data[] = { + { QLatin1String(), 0 }, + { QLatin1String(""), 0 }, + { QLatin1String("a"), 1 }, + { QLatin1String("aa"), 2 }, + { QLatin1String("b"), 3 }, + }; + + for (Data *lhs = data; lhs != data + sizeof data / sizeof *data; ++lhs) { + for (Data *rhs = data; rhs != data + sizeof data / sizeof *data; ++rhs) { + QLatin1StringContainer l = { lhs->l1 }, r = { rhs->l1 }; + QTest::newRow(qPrintable(QString::asprintf("\"%s\" <> \"%s\"", + lhs->l1.data() ? lhs->l1.data() : "nullptr", + rhs->l1.data() ? rhs->l1.data() : "nullptr"))) + << l << lhs->order << r << rhs->order; + } + } +} + +void tst_QLatin1String::relationalOperators() +{ + QFETCH(QLatin1StringContainer, lhs); + QFETCH(int, lhsOrderNumber); + QFETCH(QLatin1StringContainer, rhs); + QFETCH(int, rhsOrderNumber); + +#define CHECK(op) \ + QCOMPARE(lhs.l1 op rhs.l1, lhsOrderNumber op rhsOrderNumber) \ + /*end*/ + CHECK(==); + CHECK(!=); + CHECK(< ); + CHECK(> ); + CHECK(<=); + CHECK(>=); +#undef CHECK +} QTEST_APPLESS_MAIN(tst_QLatin1String) diff --git a/tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp b/tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp index 078a629df5..84e9643e77 100644 --- a/tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp +++ b/tests/auto/sql/kernel/qsqlquery/tst_qsqlquery.cpp @@ -4002,12 +4002,14 @@ void runIntegralTypesMysqlTest(QSqlDatabase &db, const QString &tableName, const QVERIFY_SQL(q, exec("DROP TABLE IF EXISTS " + tableName)); QVERIFY_SQL(q, exec("CREATE TABLE " + tableName + " (id " + type + ')')); - const int steps = 20; - const T increment = max / steps - min / steps; + const int steps = (max == min + 1) ? 2 : 20; + const T increment = (max == min + 1) ? 1 : (max / steps - min / steps); // insert some values QVector<T> values; + QVector<QVariant> variantValues; values.resize(steps); + variantValues.resize(steps); T v = min; if (withPreparedStatement) { QVERIFY_SQL(q, prepare("INSERT INTO " + tableName + " (id) VALUES (?)")); @@ -4020,17 +4022,30 @@ void runIntegralTypesMysqlTest(QSqlDatabase &db, const QString &tableName, const QVERIFY_SQL(q, exec("INSERT INTO " + tableName + " (id) VALUES (" + QString::number(v) + QLatin1Char(')'))); } values[i] = v; + variantValues[i] = QVariant::fromValue(v); v += increment; } // ensure we can read them back properly - QVERIFY_SQL(q, exec("SELECT id FROM " + tableName)); + if (withPreparedStatement) { + QVERIFY_SQL(q, prepare("SELECT id FROM " + tableName)); + QVERIFY_SQL(q, exec()); + } else { + QVERIFY_SQL(q, exec("SELECT id FROM " + tableName)); + } QVector<T> actualValues; + QVector<QVariant> actualVariantValues; actualValues.reserve(values.size()); while (q.next()) { - actualValues << q.value(0).value<T>(); + QVariant value = q.value(0); + actualVariantValues << value; + actualValues << value.value<T>(); + QVERIFY(actualVariantValues.last().userType() != qMetaTypeId<char>()); + QVERIFY(actualVariantValues.last().userType() != qMetaTypeId<signed char>()); + QVERIFY(actualVariantValues.last().userType() != qMetaTypeId<unsigned char>()); } QCOMPARE(actualValues, values); + QCOMPARE(actualVariantValues, variantValues); } void tst_QSqlQuery::integralTypesMysql() @@ -4041,16 +4056,18 @@ void tst_QSqlQuery::integralTypesMysql() for (int i = 0; i < 2; ++i) { const bool withPreparedStatement = (i == 1); - runIntegralTypesMysqlTest<char>(db, "tinyIntTest", "TINYINT", withPreparedStatement); - runIntegralTypesMysqlTest<unsigned char>(db, "unsignedTinyIntTest", "TINYINT UNSIGNED", withPreparedStatement); - runIntegralTypesMysqlTest<char>(db, "smallIntTest", "SMALLINT", withPreparedStatement); - runIntegralTypesMysqlTest<unsigned char>(db, "unsignedSmallIntTest", "SMALLINT UNSIGNED", withPreparedStatement); - runIntegralTypesMysqlTest<int>(db, "mediumIntTest", "MEDIUMINT", withPreparedStatement, -(1 << 23), (1 << 23) - 1); - runIntegralTypesMysqlTest<unsigned int>(db, "unsignedMediumIntTest", "MEDIUMINT UNSIGNED", withPreparedStatement, 0, (1 << 24) - 1); - runIntegralTypesMysqlTest<int>(db, "intTest", "INT", withPreparedStatement); - runIntegralTypesMysqlTest<unsigned int>(db, "unsignedIntTest", "INT UNSIGNED", withPreparedStatement); - runIntegralTypesMysqlTest<long long>(db, "bigIntTest", "BIGINT", withPreparedStatement); - runIntegralTypesMysqlTest<unsigned long long>(db, "unsignedBigIntTest", "BIGINT UNSIGNED", withPreparedStatement); + runIntegralTypesMysqlTest<bool>(db, "tinyInt1Test", "TINYINT(1)", withPreparedStatement); + runIntegralTypesMysqlTest<bool>(db, "unsignedTinyInt1Test", "TINYINT(1) UNSIGNED", withPreparedStatement); + runIntegralTypesMysqlTest<qint8>(db, "tinyIntTest", "TINYINT", withPreparedStatement); + runIntegralTypesMysqlTest<quint8>(db, "unsignedTinyIntTest", "TINYINT UNSIGNED", withPreparedStatement); + runIntegralTypesMysqlTest<qint16>(db, "smallIntTest", "SMALLINT", withPreparedStatement); + runIntegralTypesMysqlTest<quint16>(db, "unsignedSmallIntTest", "SMALLINT UNSIGNED", withPreparedStatement); + runIntegralTypesMysqlTest<qint32>(db, "mediumIntTest", "MEDIUMINT", withPreparedStatement, -(1 << 23), (1 << 23) - 1); + runIntegralTypesMysqlTest<quint32>(db, "unsignedMediumIntTest", "MEDIUMINT UNSIGNED", withPreparedStatement, 0, (1 << 24) - 1); + runIntegralTypesMysqlTest<qint32>(db, "intTest", "INT", withPreparedStatement); + runIntegralTypesMysqlTest<quint32>(db, "unsignedIntTest", "INT UNSIGNED", withPreparedStatement); + runIntegralTypesMysqlTest<qint64>(db, "bigIntTest", "BIGINT", withPreparedStatement); + runIntegralTypesMysqlTest<quint64>(db, "unsignedBigIntTest", "BIGINT UNSIGNED", withPreparedStatement); } } diff --git a/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp b/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp index 98b630b49d..bbff9f0e50 100644 --- a/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp +++ b/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp @@ -289,6 +289,7 @@ private slots: void showHideEvent_data(); void showHideEvent(); void showHideEventWhileMinimize(); + void showHideChildrenWhileMinimize_QTBUG50589(); void lostUpdatesOnHide(); @@ -4073,19 +4074,30 @@ class ShowHideEventWidget : public QWidget { public: int numberOfShowEvents, numberOfHideEvents; + int numberOfSpontaneousShowEvents, numberOfSpontaneousHideEvents; ShowHideEventWidget(QWidget *parent = 0) - : QWidget(parent), numberOfShowEvents(0), numberOfHideEvents(0) + : QWidget(parent) + , numberOfShowEvents(0), numberOfHideEvents(0) + , numberOfSpontaneousShowEvents(0), numberOfSpontaneousHideEvents(0) { } void create() { QWidget::create(); } - void showEvent(QShowEvent *) - { ++numberOfShowEvents; } + void showEvent(QShowEvent *e) + { + ++numberOfShowEvents; + if (e->spontaneous()) + ++numberOfSpontaneousShowEvents; + } - void hideEvent(QHideEvent *) - { ++numberOfHideEvents; } + void hideEvent(QHideEvent *e) + { + ++numberOfHideEvents; + if (e->spontaneous()) + ++numberOfSpontaneousHideEvents; + } }; void tst_QWidget::showHideEvent_data() @@ -4177,6 +4189,32 @@ void tst_QWidget::showHideEventWhileMinimize() QTRY_COMPARE(widget.numberOfShowEvents, showEventsBeforeMinimize + 1); } +void tst_QWidget::showHideChildrenWhileMinimize_QTBUG50589() +{ + const QPlatformIntegration *pi = QGuiApplicationPrivate::platformIntegration(); + if (!pi->hasCapability(QPlatformIntegration::MultipleWindows) + || !pi->hasCapability(QPlatformIntegration::NonFullScreenWindows) + || !pi->hasCapability(QPlatformIntegration::WindowManagement)) { + QSKIP("This test requires window management capabilities"); + } + + QWidget parent; + ShowHideEventWidget child(&parent); + + parent.setWindowTitle(QTest::currentTestFunction()); + parent.resize(m_testWidgetSize); + centerOnScreen(&parent); + parent.show(); + QVERIFY(QTest::qWaitForWindowExposed(&parent)); + + const int showEventsBeforeMinimize = child.numberOfSpontaneousShowEvents; + const int hideEventsBeforeMinimize = child.numberOfSpontaneousHideEvents; + parent.showMinimized(); + QTRY_COMPARE(child.numberOfSpontaneousHideEvents, hideEventsBeforeMinimize + 1); + parent.showNormal(); + QTRY_COMPARE(child.numberOfSpontaneousShowEvents, showEventsBeforeMinimize + 1); +} + void tst_QWidget::update() { #ifdef Q_OS_OSX @@ -10315,8 +10353,11 @@ void tst_QWidget::underMouse() QCOMPARE(childWidget2.leaves, 0); // Mouse leaves popup and enters topLevelWidget, should cause leave for popup - // but no enter to topLevelWidget. Again, artificial leave event needed. + // but no enter to topLevelWidget. +#ifdef Q_OS_DARWIN + // Artificial leave event needed for Cocoa. QWindowSystemInterface::handleLeaveEvent(popupWindow); +#endif QTest::mouseMove(popupWindow, popupWindow->mapFromGlobal(window->mapToGlobal(inWindowPoint))); QApplication::processEvents(); QVERIFY(!topLevelWidget.underMouse()); |