diff options
Diffstat (limited to 'tests/auto')
9 files changed, 315 insertions, 36 deletions
diff --git a/tests/auto/corelib/json/tst_qtjson.cpp b/tests/auto/corelib/json/tst_qtjson.cpp index 6811551769..543226978c 100644 --- a/tests/auto/corelib/json/tst_qtjson.cpp +++ b/tests/auto/corelib/json/tst_qtjson.cpp @@ -44,6 +44,7 @@ #include "qjsonobject.h" #include "qjsonvalue.h" #include "qjsondocument.h" +#include <limits> #define INVALID_UNICODE "\357\277\277" // "\uffff" #define UNICODE_DJE "\320\202" // Character from the Serbian Cyrillic alphabet @@ -94,6 +95,8 @@ private Q_SLOTS: void toVariantList(); void toJson(); + void toJsonSillyNumericValues(); + void toJsonLargeNumericValues(); void fromJson(); void fromJsonErrors(); void fromBinary(); @@ -1080,6 +1083,89 @@ void tst_QtJson::toJson() } } +void tst_QtJson::toJsonSillyNumericValues() +{ + QJsonObject object; + QJsonArray array; + array.append(QJsonValue(std::numeric_limits<double>::infinity())); // encode to: null + array.append(QJsonValue(-std::numeric_limits<double>::infinity())); // encode to: null + array.append(QJsonValue(std::numeric_limits<double>::quiet_NaN())); // encode to: null + object.insert("Array", array); + + QByteArray json = QJsonDocument(object).toJson(); + + QByteArray expected = + "{\n" + " \"Array\": [\n" + " null,\n" + " null,\n" + " null\n" + " ]\n" + "}\n"; + + QCOMPARE(json, expected); + + QJsonDocument doc; + doc.setObject(object); + json = doc.toJson(); + QCOMPARE(json, expected); +} + +void tst_QtJson::toJsonLargeNumericValues() +{ + QJsonObject object; + QJsonArray array; + array.append(QJsonValue(1.234567)); // actual precision bug in Qt 5.0.0 + array.append(QJsonValue(1.7976931348623157e+308)); // JS Number.MAX_VALUE + array.append(QJsonValue(5e-324)); // JS Number.MIN_VALUE + array.append(QJsonValue(std::numeric_limits<double>::min())); + array.append(QJsonValue(std::numeric_limits<double>::max())); + array.append(QJsonValue(std::numeric_limits<double>::epsilon())); + array.append(QJsonValue(std::numeric_limits<double>::denorm_min())); + array.append(QJsonValue(0.0)); + array.append(QJsonValue(-std::numeric_limits<double>::min())); + array.append(QJsonValue(-std::numeric_limits<double>::max())); + array.append(QJsonValue(-std::numeric_limits<double>::epsilon())); + array.append(QJsonValue(-std::numeric_limits<double>::denorm_min())); + array.append(QJsonValue(-0.0)); + array.append(QJsonValue(9007199254740992LL)); // JS Number max integer + array.append(QJsonValue(-9007199254740992LL)); // JS Number min integer + object.insert("Array", array); + + QByteArray json = QJsonDocument(object).toJson(); + + QByteArray expected = + "{\n" + " \"Array\": [\n" + " 1.234567,\n" + " 1.7976931348623157e+308,\n" + // ((4.9406564584124654e-324 == 5e-324) == true) + // I can only think JavaScript has a special formatter to + // emit this value for this IEEE754 bit pattern. + " 4.9406564584124654e-324,\n" + " 2.2250738585072014e-308,\n" + " 1.7976931348623157e+308,\n" + " 2.2204460492503131e-16,\n" + " 4.9406564584124654e-324,\n" + " 0,\n" + " -2.2250738585072014e-308,\n" + " -1.7976931348623157e+308,\n" + " -2.2204460492503131e-16,\n" + " -4.9406564584124654e-324,\n" + " 0,\n" + " 9007199254740992,\n" + " -9007199254740992\n" + " ]\n" + "}\n"; + + QCOMPARE(json, expected); + + QJsonDocument doc; + doc.setObject(object); + json = doc.toJson(); + QCOMPARE(json, expected); +} + void tst_QtJson::fromJson() { { diff --git a/tests/auto/corelib/kernel/qmetatype/tst_qmetatype.cpp b/tests/auto/corelib/kernel/qmetatype/tst_qmetatype.cpp index 77ea39da53..f412ee2970 100644 --- a/tests/auto/corelib/kernel/qmetatype/tst_qmetatype.cpp +++ b/tests/auto/corelib/kernel/qmetatype/tst_qmetatype.cpp @@ -1302,15 +1302,20 @@ Q_DECLARE_METATYPE(MyObjectPtr) void tst_QMetaType::automaticTemplateRegistration() { - { - QList<int> intList; - intList << 42; - QVERIFY(QVariant::fromValue(intList).value<QList<int> >().first() == 42); - QVector<QList<int> > vectorList; - vectorList << intList; - QVERIFY(QVariant::fromValue(vectorList).value<QVector<QList<int> > >().first().first() == 42); +#define TEST_SEQUENTIAL_CONTAINER(CONTAINER, VALUE_TYPE) \ + { \ + CONTAINER<VALUE_TYPE> innerContainer; \ + innerContainer.push_back(42); \ + QVERIFY(*QVariant::fromValue(innerContainer).value<CONTAINER<VALUE_TYPE> >().begin() == 42); \ + QVector<CONTAINER<VALUE_TYPE> > outerContainer; \ + outerContainer << innerContainer; \ + QVERIFY(*QVariant::fromValue(outerContainer).value<QVector<CONTAINER<VALUE_TYPE> > >().first().begin() == 42); \ } + TEST_SEQUENTIAL_CONTAINER(QList, int) + TEST_SEQUENTIAL_CONTAINER(std::vector, int) + TEST_SEQUENTIAL_CONTAINER(std::list, int) + { QList<QByteArray> bytearrayList; bytearrayList << QByteArray("foo"); @@ -1323,14 +1328,9 @@ void tst_QMetaType::automaticTemplateRegistration() QCOMPARE(::qMetaTypeId<QVariantList>(), (int)QMetaType::QVariantList); QCOMPARE(::qMetaTypeId<QList<QVariant> >(), (int)QMetaType::QVariantList); - { - QList<QVariant> variantList; - variantList << 42; - QVERIFY(QVariant::fromValue(variantList).value<QList<QVariant> >().first() == 42); - QVector<QList<QVariant> > vectorList; - vectorList << variantList; - QVERIFY(QVariant::fromValue(vectorList).value<QVector<QList<QVariant> > >().first().first() == 42); - } + TEST_SEQUENTIAL_CONTAINER(QList, QVariant) + TEST_SEQUENTIAL_CONTAINER(std::vector, QVariant) + TEST_SEQUENTIAL_CONTAINER(std::list, QVariant) { QList<QSharedPointer<QObject> > sharedPointerList; @@ -1395,6 +1395,31 @@ void tst_QMetaType::automaticTemplateRegistration() QCOMPARE(QVariant::fromValue(variantMap).value<QVariantMap>().value(QStringLiteral("4")), QVariant(2)); } { + typedef std::map<int, int> IntIntMap; + IntIntMap intIntMap; + intIntMap[4] = 2; + QCOMPARE(QVariant::fromValue(intIntMap).value<IntIntMap>()[4], 2); + } + { + typedef std::map<int, uint> StdIntUIntMap; + StdIntUIntMap intUIntMap; + intUIntMap[4] = 2; + QCOMPARE(QVariant::fromValue(intUIntMap).value<StdIntUIntMap>()[4], (uint)2); + } + { + typedef std::map<int, CustomObject*> StdMapIntCustomObject ; + StdMapIntCustomObject intComparableMap; + CustomObject *o = 0; + intComparableMap[4] = o; + QCOMPARE(QVariant::fromValue(intComparableMap).value<StdMapIntCustomObject >()[4], o); + } + { + typedef std::map<QString, QVariant> StdMapStringVariant; + StdMapStringVariant variantMap; + variantMap[QStringLiteral("4")] = 2; + QCOMPARE(QVariant::fromValue(variantMap).value<StdMapStringVariant>()[QStringLiteral("4")], QVariant(2)); + } + { typedef QPair<int, int> IntIntPair; IntIntPair intIntPair = qMakePair(4, 2); QCOMPARE(QVariant::fromValue(intIntPair).value<IntIntPair>().first, 4); @@ -1412,6 +1437,25 @@ void tst_QMetaType::automaticTemplateRegistration() QCOMPARE(QVariant::fromValue(intComparablePair).value<IntComparablePair>().second, m); } { + typedef std::pair<int, int> IntIntPair; + IntIntPair intIntPair = std::make_pair(4, 2); + QCOMPARE(QVariant::fromValue(intIntPair).value<IntIntPair>().first, 4); + QCOMPARE(QVariant::fromValue(intIntPair).value<IntIntPair>().second, 2); + } + { + typedef std::pair<int, uint> StdIntUIntPair; + StdIntUIntPair intUIntPair = std::make_pair<int, uint>(4, 2); + QCOMPARE(QVariant::fromValue(intUIntPair).value<StdIntUIntPair>().first, 4); + QCOMPARE(QVariant::fromValue(intUIntPair).value<StdIntUIntPair>().second, (uint)2); + } + { + typedef std::pair<int, CustomQObject*> StdIntComparablePair; + CustomQObject* o = 0; + StdIntComparablePair intComparablePair = std::make_pair(4, o); + QCOMPARE(QVariant::fromValue(intComparablePair).value<StdIntComparablePair>().first, 4); + QCOMPARE(QVariant::fromValue(intComparablePair).value<StdIntComparablePair>().second, o); + } + { typedef QHash<int, UnregisteredType> IntUnregisteredTypeHash; QVERIFY(qRegisterMetaType<IntUnregisteredTypeHash>("IntUnregisteredTypeHash") > 0); } diff --git a/tests/auto/corelib/tools/qalgorithms/tst_qalgorithms.cpp b/tests/auto/corelib/tools/qalgorithms/tst_qalgorithms.cpp index 72bf5c58ca..c18ba4d05c 100644 --- a/tests/auto/corelib/tools/qalgorithms/tst_qalgorithms.cpp +++ b/tests/auto/corelib/tools/qalgorithms/tst_qalgorithms.cpp @@ -78,10 +78,22 @@ private slots: void qCountContainer() const; void binaryFindOnLargeContainer() const; -#if Q_TEST_PERFORMANCE + void popCount08_data() { popCount_data_impl(sizeof(quint8 )); } + void popCount16_data() { popCount_data_impl(sizeof(quint16)); } + void popCount32_data() { popCount_data_impl(sizeof(quint32)); } + void popCount64_data() { popCount_data_impl(sizeof(quint64)); } + void popCount08() { popCount_impl<quint8 >(); } + void popCount16() { popCount_impl<quint16>(); } + void popCount32() { popCount_impl<quint32>(); } + void popCount64() { popCount_impl<quint64>(); } + private: +#if Q_TEST_PERFORMANCE void performance(); #endif + void popCount_data_impl(size_t sizeof_T_Int); + template <typename T_Int> + void popCount_impl(); }; class TestInt @@ -1007,6 +1019,72 @@ void tst_QAlgorithms::binaryFindOnLargeContainer() const QCOMPARE(foundIt.pos(), 1073987655); } +// alternative implementation of qPopulationCount for comparison: +static const uint bitsSetInNibble[] = { + 0, 1, 1, 2, 1, 2, 2, 3, + 1, 2, 2, 3, 2, 3, 3, 4, +}; +Q_STATIC_ASSERT(sizeof bitsSetInNibble / sizeof *bitsSetInNibble == 16); + +static Q_DECL_CONSTEXPR uint bitsSetInByte(quint8 byte) +{ + return bitsSetInNibble[byte & 0xF] + bitsSetInNibble[byte >> 4]; +} +static Q_DECL_CONSTEXPR uint bitsSetInShort(quint16 word) +{ + return bitsSetInByte(word & 0xFF) + bitsSetInByte(word >> 8); +} +static Q_DECL_CONSTEXPR uint bitsSetInInt(quint32 word) +{ + return bitsSetInShort(word & 0xFFFF) + bitsSetInShort(word >> 16); +} +static Q_DECL_CONSTEXPR uint bitsSetInInt64(quint64 word) +{ + return bitsSetInInt(word & 0xFFFFFFFF) + bitsSetInInt(word >> 32); +} + + +void tst_QAlgorithms::popCount_data_impl(size_t sizeof_T_Int) +{ + using namespace QTest; + addColumn<quint64>("input"); + addColumn<uint>("expected"); + + for (uint i = 0; i < UCHAR_MAX; ++i) { + const uchar byte = static_cast<uchar>(i); + const uint bits = bitsSetInByte(byte); + const quint64 value = static_cast<quint64>(byte); + const quint64 input = value << ((i % sizeof_T_Int) * 8U); + newRow(qPrintable(QString().sprintf("0x%016llx", input))) << input << bits; + } + + // and some random ones: + if (sizeof_T_Int >= 8) + for (size_t i = 0; i < 1000; ++i) { + const quint64 input = quint64(qrand()) << 32 | quint32(qrand()); + newRow(qPrintable(QString().sprintf("0x%016llx", input))) << input << bitsSetInInt64(input); + } + else if (sizeof_T_Int >= 2) + for (size_t i = 0; i < 1000 ; ++i) { + const quint32 input = qrand(); + if (sizeof_T_Int >= 4) + newRow(qPrintable(QString().sprintf("0x%08x", input))) << quint64(input) << bitsSetInInt(input); + else + newRow(qPrintable(QString().sprintf("0x%04x", quint16(input & 0xFFFF)))) << quint64(input & 0xFFFF) << bitsSetInShort(input & 0xFFFF); + } +} + +template <typename T_Int> +void tst_QAlgorithms::popCount_impl() +{ + QFETCH(quint64, input); + QFETCH(uint, expected); + + const T_Int value = static_cast<T_Int>(input); + + QCOMPARE(qPopulationCount(value), expected); +} + QTEST_APPLESS_MAIN(tst_QAlgorithms) #include "tst_qalgorithms.moc" diff --git a/tests/auto/network/access/qnetworkaccessmanager/tst_qnetworkaccessmanager.cpp b/tests/auto/network/access/qnetworkaccessmanager/tst_qnetworkaccessmanager.cpp index 25301feee4..125eab2f8c 100644 --- a/tests/auto/network/access/qnetworkaccessmanager/tst_qnetworkaccessmanager.cpp +++ b/tests/auto/network/access/qnetworkaccessmanager/tst_qnetworkaccessmanager.cpp @@ -77,30 +77,43 @@ void tst_QNetworkAccessManager::networkAccessible() QSignalSpy spy(&manager, SIGNAL(networkAccessibleChanged(QNetworkAccessManager::NetworkAccessibility))); - QCOMPARE(manager.networkAccessible(), QNetworkAccessManager::UnknownAccessibility); + // if there is no session, we cannot know in which state we are in + QNetworkAccessManager::NetworkAccessibility initialAccessibility = + manager.networkAccessible(); + QCOMPARE(manager.networkAccessible(), initialAccessibility); manager.setNetworkAccessible(QNetworkAccessManager::NotAccessible); - QCOMPARE(spy.count(), 1); - QCOMPARE(spy.takeFirst().at(0).value<QNetworkAccessManager::NetworkAccessibility>(), - QNetworkAccessManager::NotAccessible); + int expectedCount = (initialAccessibility == QNetworkAccessManager::Accessible) ? 1 : 0; + QCOMPARE(spy.count(), expectedCount); + if (expectedCount > 0) + QCOMPARE(spy.takeFirst().at(0).value<QNetworkAccessManager::NetworkAccessibility>(), + QNetworkAccessManager::NotAccessible); QCOMPARE(manager.networkAccessible(), QNetworkAccessManager::NotAccessible); manager.setNetworkAccessible(QNetworkAccessManager::Accessible); - QCOMPARE(spy.count(), 1); - QCOMPARE(spy.takeFirst().at(0).value<QNetworkAccessManager::NetworkAccessibility>(), - QNetworkAccessManager::UnknownAccessibility); - QCOMPARE(manager.networkAccessible(), QNetworkAccessManager::UnknownAccessibility); + QCOMPARE(spy.count(), expectedCount); + if (expectedCount > 0) + QCOMPARE(spy.takeFirst().at(0).value<QNetworkAccessManager::NetworkAccessibility>(), + initialAccessibility); + QCOMPARE(manager.networkAccessible(), initialAccessibility); QNetworkConfigurationManager configManager; + bool sessionRequired = (configManager.capabilities() + & QNetworkConfigurationManager::NetworkSessionRequired); QNetworkConfiguration defaultConfig = configManager.defaultConfiguration(); if (defaultConfig.isValid()) { manager.setConfiguration(defaultConfig); - QCOMPARE(spy.count(), 1); - QCOMPARE(spy.takeFirst().at(0).value<QNetworkAccessManager::NetworkAccessibility>(), - QNetworkAccessManager::Accessible); + // the accessibility has not changed if no session is required + if (sessionRequired) { + QCOMPARE(spy.count(), 1); + QCOMPARE(spy.takeFirst().at(0).value<QNetworkAccessManager::NetworkAccessibility>(), + QNetworkAccessManager::Accessible); + } else { + QCOMPARE(spy.count(), 0); + } QCOMPARE(manager.networkAccessible(), QNetworkAccessManager::Accessible); manager.setNetworkAccessible(QNetworkAccessManager::NotAccessible); diff --git a/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp b/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp index bcc0641973..97f9667140 100644 --- a/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp +++ b/tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp @@ -5920,7 +5920,7 @@ void tst_QNetworkReply::sslSessionSharing() warmupRequest.setAttribute(QNetworkRequest::User, sessionSharingEnabled); // so we can read it from the slot if (! sessionSharingEnabled) { QSslConfiguration configuration(QSslConfiguration::defaultConfiguration()); - configuration.setSslOption(QSsl::SslOptionDisableSessionTickets, true); + configuration.setSslOption(QSsl::SslOptionDisableSessionSharing, true); warmupRequest.setSslConfiguration(configuration); } QNetworkReply *reply = manager.get(warmupRequest); diff --git a/tests/auto/network/socket/qtcpsocket/tst_qtcpsocket.cpp b/tests/auto/network/socket/qtcpsocket/tst_qtcpsocket.cpp index 2b9dfc5081..ee5c7e42d8 100644 --- a/tests/auto/network/socket/qtcpsocket/tst_qtcpsocket.cpp +++ b/tests/auto/network/socket/qtcpsocket/tst_qtcpsocket.cpp @@ -513,7 +513,7 @@ void tst_QTcpSocket::bind() { QFETCH_GLOBAL(bool, setProxy); if (setProxy) - QSKIP("QTBUG-22964"); + return; // QTBUG-22964 for proxies, QTBUG-29972 for QSKIP QFETCH(QString, stringAddr); QFETCH(bool, successExpected); QFETCH(QString, stringExpectedLocalAddress); diff --git a/tests/auto/widgets/graphicsview/qgraphicsgridlayout/tst_qgraphicsgridlayout.cpp b/tests/auto/widgets/graphicsview/qgraphicsgridlayout/tst_qgraphicsgridlayout.cpp index 41e5ed466c..92caeb7803 100644 --- a/tests/auto/widgets/graphicsview/qgraphicsgridlayout/tst_qgraphicsgridlayout.cpp +++ b/tests/auto/widgets/graphicsview/qgraphicsgridlayout/tst_qgraphicsgridlayout.cpp @@ -126,6 +126,7 @@ private slots: void spanningItem2x3_data(); void spanningItem2x3(); void spanningItem(); + void spanAcrossEmptyRow(); void heightForWidth(); void widthForHeight(); void heightForWidthWithSpanning(); @@ -3180,23 +3181,19 @@ void tst_QGraphicsGridLayout::heightForWidthWithSpanning() QCOMPARE(layout->effectiveSizeHint(Qt::MinimumSize, QSizeF(-1, -1)), QSizeF(1, 1)); QCOMPARE(layout->effectiveSizeHint(Qt::PreferredSize, QSizeF(-1, -1)), QSizeF(200, 100)); - QEXPECT_FAIL("", "Due to an old bug this wrongly returns QWIDGETSIZE_MAX", Continue); QCOMPARE(layout->effectiveSizeHint(Qt::MaximumSize, QSizeF(-1, -1)), QSizeF(30000, 30000)); QCOMPARE(layout->effectiveSizeHint(Qt::MinimumSize, QSizeF(200, -1)), QSizeF(200, 100)); QCOMPARE(layout->effectiveSizeHint(Qt::PreferredSize, QSizeF(200, -1)), QSizeF(200, 100)); - QEXPECT_FAIL("", "Due to an old bug this wrongly returns QWIDGETSIZE_MAX", Continue); QCOMPARE(layout->effectiveSizeHint(Qt::MaximumSize, QSizeF(200, -1)), QSizeF(200, 100)); QCOMPARE(layout->effectiveSizeHint(Qt::MinimumSize, QSizeF(2, -1)), QSizeF(2, 10000)); QCOMPARE(layout->effectiveSizeHint(Qt::PreferredSize, QSizeF(2, -1)), QSizeF(2, 10000)); - QEXPECT_FAIL("", "Due to an old bug this wrongly returns QWIDGETSIZE_MAX", Continue); QCOMPARE(layout->effectiveSizeHint(Qt::MaximumSize, QSizeF(2, -1)), QSizeF(2, 10000)); QCOMPARE(layout->effectiveSizeHint(Qt::MinimumSize, QSizeF(200, -1)), QSizeF(200, 100)); QCOMPARE(layout->effectiveSizeHint(Qt::PreferredSize, QSizeF(200, -1)), QSizeF(200, 100)); - QEXPECT_FAIL("", "Due to an old bug this wrongly returns QWIDGETSIZE_MAX", Continue); - QCOMPARE(layout->effectiveSizeHint(Qt::MaximumSize, QSizeF(200, -1)), QSizeF(200, 10000)); + QCOMPARE(layout->effectiveSizeHint(Qt::MaximumSize, QSizeF(200, -1)), QSizeF(200, 100)); } Q_DECLARE_METATYPE(QSizePolicy::Policy) @@ -3352,6 +3349,37 @@ void tst_QGraphicsGridLayout::spanningItem() QCOMPARE(layout->maximumSize(), QSizeF(160,80)); } +void tst_QGraphicsGridLayout::spanAcrossEmptyRow() +{ + QGraphicsWidget *form = new QGraphicsWidget(0, Qt::Window); + QGraphicsGridLayout *layout = new QGraphicsGridLayout(form); + layout->setContentsMargins(0, 0, 0, 0); + layout->setSpacing(0); + RectWidget *w1 = new RectWidget; + RectWidget *w2 = new RectWidget; + RectWidget *w3 = new RectWidget; + + QSizeF size(10, 10); + for (int i = 0; i < 3; ++i) { + w1->setSizeHint((Qt::SizeHint)i, size); + w2->setSizeHint((Qt::SizeHint)i, size); + w3->setSizeHint((Qt::SizeHint)i, size); + size+=size; //[(10,10), (20,20), (40,40)] + } + layout->addItem(w1, 0, 0, 1, 1); + layout->addItem(w2, 0, 1, 1, 2); + layout->addItem(w3, 0, 99, 1, 1); + + form->resize(60,20); + QCOMPARE(w1->geometry(), QRectF( 0, 0, 20, 20)); + QCOMPARE(w2->geometry(), QRectF(20, 0, 20, 20)); + QCOMPARE(w3->geometry(), QRectF(40, 0, 20, 20)); + + QCOMPARE(layout->effectiveSizeHint(Qt::MinimumSize), QSizeF(30, 10)); + QCOMPARE(layout->effectiveSizeHint(Qt::PreferredSize), QSizeF(60, 20)); + QCOMPARE(layout->effectiveSizeHint(Qt::MaximumSize), QSizeF(120, 40)); +} + void tst_QGraphicsGridLayout::stretchAndHeightForWidth() { QGraphicsWidget *widget = new QGraphicsWidget(0, Qt::Window); diff --git a/tests/auto/widgets/itemviews/qtableview/tst_qtableview.cpp b/tests/auto/widgets/itemviews/qtableview/tst_qtableview.cpp index 13476a7ffa..3710645514 100644 --- a/tests/auto/widgets/itemviews/qtableview/tst_qtableview.cpp +++ b/tests/auto/widgets/itemviews/qtableview/tst_qtableview.cpp @@ -106,6 +106,8 @@ private slots: void moveCursorStrikesBack_data(); void moveCursorStrikesBack(); + void moveCursorBiggerJump(); + void hideRows_data(); void hideRows(); @@ -1353,6 +1355,34 @@ void tst_QTableView::moveCursorStrikesBack() QCOMPARE(newColumn, expectedColumn); } +void tst_QTableView::moveCursorBiggerJump() +{ + QtTestTableModel model(50, 7); + QTableView view; + view.setModel(&model); + view.show(); + QVERIFY(QTest::qWaitForWindowExposed(&view)); + + int height = view.horizontalHeader()->height(); + for (int i=0;i<8;i++) + height += view.verticalHeader()->sectionSize(i); + view.resize(view.width(), height); + view.setCurrentIndex(model.index(0,0)); + + QTest::keyClick(&view, Qt::Key_PageDown); + QCOMPARE(view.indexAt(QPoint(0,0)), model.index(1,0)); + QTest::keyClick(&view, Qt::Key_PageDown); + QCOMPARE(view.indexAt(QPoint(0,0)), model.index(8,0)); + QTest::keyClick(&view, Qt::Key_PageDown); + QCOMPARE(view.indexAt(QPoint(0,0)), model.index(15,0)); + QTest::keyClick(&view, Qt::Key_PageUp); + QCOMPARE(view.indexAt(QPoint(0,0)), model.index(14,0)); + QTest::keyClick(&view, Qt::Key_PageUp); + QCOMPARE(view.indexAt(QPoint(0,0)), model.index(7,0)); + QTest::keyClick(&view, Qt::Key_PageUp); + QCOMPARE(view.indexAt(QPoint(0,0)), model.index(0,0)); +} + void tst_QTableView::hideRows_data() { QTest::addColumn<int>("rowCount"); @@ -3761,8 +3791,6 @@ void tst_QTableView::task259308_scrollVerticalHeaderSwappedSections() QTRY_COMPARE(tv.rowAt(0), tv.verticalHeader()->logicalIndex(0)); int newRow = tv.rowAt(tv.viewport()->height()); - if (newRow == tv.rowAt(tv.viewport()->height() - 1)) // Overlapping row - newRow++; QTest::keyClick(&tv, Qt::Key_PageDown); // Scroll down and check current QTRY_COMPARE(tv.currentIndex().row(), newRow); diff --git a/tests/auto/widgets/itemviews/qtreeview/tst_qtreeview.cpp b/tests/auto/widgets/itemviews/qtreeview/tst_qtreeview.cpp index 9a7b7956d8..dcda9f7fd7 100644 --- a/tests/auto/widgets/itemviews/qtreeview/tst_qtreeview.cpp +++ b/tests/auto/widgets/itemviews/qtreeview/tst_qtreeview.cpp @@ -2017,6 +2017,8 @@ void tst_QTreeView::clicked() view.setModel(&model); view.show(); + QVERIFY(QTest::qWaitForWindowExposed(&view)); + QModelIndex firstIndex = model.index(0, 0, QModelIndex()); QVERIFY(firstIndex.isValid()); int itemHeight = view.visualRect(firstIndex).height(); |