diff options
author | Liang Qi <liang.qi@theqtcompany.com> | 2015-09-25 14:02:04 +0200 |
---|---|---|
committer | Liang Qi <liang.qi@theqtcompany.com> | 2015-09-25 14:02:04 +0200 |
commit | a1ad9a74ebb3c556c5f70f7e03be68b09598ac53 (patch) | |
tree | 615a96db418219a57a745a5899e39a9ac90744ec /tests/auto/corelib/itemmodels/qitemselectionmodel | |
parent | 6d78b7a0c46ea04f4bb771d960e2f7dff1362341 (diff) | |
parent | 462f355e4fb16cc7a1838fa2dda0f763eee58c84 (diff) |
Merge remote-tracking branch 'origin/5.6' into dev
Conflicts:
src/corelib/io/io.pri
src/corelib/io/qdatastream.cpp
src/corelib/io/qdatastream.h
src/network/socket/qabstractsocket.cpp
src/plugins/platforminputcontexts/ibus/qibusplatforminputcontext.cpp
src/plugins/platforms/cocoa/qcocoaaccessibilityelement.h
src/widgets/styles/qgtkstyle.cpp
tests/auto/corelib/mimetypes/qmimedatabase/qmimedatabase-cache/qmimedatabase-cache.pro
tests/auto/corelib/mimetypes/qmimedatabase/qmimedatabase-xml/qmimedatabase-xml.pro
tests/auto/dbus/qdbusconnection/qdbusconnection.pro
tests/auto/dbus/qdbuspendingcall/tst_qdbuspendingcall.cpp
tests/auto/network/access/qnetworkreply/tst_qnetworkreply.cpp
Change-Id: I347549a024eb5bfa986699e0a11f96cc55c797a7
Diffstat (limited to 'tests/auto/corelib/itemmodels/qitemselectionmodel')
-rw-r--r-- | tests/auto/corelib/itemmodels/qitemselectionmodel/tst_qitemselectionmodel.cpp | 94 |
1 files changed, 94 insertions, 0 deletions
diff --git a/tests/auto/corelib/itemmodels/qitemselectionmodel/tst_qitemselectionmodel.cpp b/tests/auto/corelib/itemmodels/qitemselectionmodel/tst_qitemselectionmodel.cpp index 9d1e1c9657..7d85377c7a 100644 --- a/tests/auto/corelib/itemmodels/qitemselectionmodel/tst_qitemselectionmodel.cpp +++ b/tests/auto/corelib/itemmodels/qitemselectionmodel/tst_qitemselectionmodel.cpp @@ -94,6 +94,9 @@ private slots: void testChainedSelectionClear(); void testClearCurrentIndex(); + void QTBUG48402_data(); + void QTBUG48402(); + private: QAbstractItemModel *model; QItemSelectionModel *selection; @@ -2756,5 +2759,96 @@ void tst_QItemSelectionModel::testClearCurrentIndex() QCOMPARE(currentIndexSpy.size(), 2); } +void tst_QItemSelectionModel::QTBUG48402_data() +{ + QTest::addColumn<int>("rows"); + QTest::addColumn<int>("columns"); + + QTest::addColumn<int>("selectTop"); + QTest::addColumn<int>("selectLeft"); + QTest::addColumn<int>("selectBottom"); + QTest::addColumn<int>("selectRight"); + + QTest::addColumn<int>("removeTop"); + QTest::addColumn<int>("removeBottom"); + + QTest::addColumn<int>("deselectTop"); + QTest::addColumn<int>("deselectLeft"); + QTest::addColumn<int>("deselectBottom"); + QTest::addColumn<int>("deselectRight"); + + QTest::newRow("4x4 top intersection") + << 4 << 4 + << 0 << 2 << 1 << 3 + << 1 << 1 + << 1 << 2 << 1 << 3; + + QTest::newRow("4x4 bottom intersection") + << 4 << 4 + << 0 << 2 << 1 << 3 + << 0 << 0 + << 0 << 2 << 0 << 3; + + QTest::newRow("4x4 middle intersection") + << 4 << 4 + << 0 << 2 << 2 << 3 + << 1 << 1 + << 1 << 2 << 1 << 3; + + QTest::newRow("4x4 full inclusion") + << 4 << 4 + << 0 << 2 << 1 << 3 + << 0 << 1 + << 0 << 2 << 1 << 3; +} +class QTBUG48402_helper : public QObject +{ + Q_OBJECT +public: + QModelIndex tl; + QModelIndex br; +public slots: + void changed(const QItemSelection &selected, const QItemSelection &deselected) + { + tl = deselected.first().topLeft(); + br = deselected.first().bottomRight(); + } +}; + +void tst_QItemSelectionModel::QTBUG48402() +{ + QFETCH(int, rows); + QFETCH(int, columns); + QFETCH(int, selectTop); + QFETCH(int, selectLeft); + QFETCH(int, selectBottom); + QFETCH(int, selectRight); + QFETCH(int, removeTop); + QFETCH(int, removeBottom); + QFETCH(int, deselectTop); + QFETCH(int, deselectLeft); + QFETCH(int, deselectBottom); + QFETCH(int, deselectRight); + + MyStandardItemModel model(rows, columns); + QItemSelectionModel selections(&model); + + QModelIndex stl = model.index(selectTop, selectLeft); + QModelIndex sbr = model.index(selectBottom, selectRight); + QModelIndex dtl = model.index(deselectTop, deselectLeft); + QModelIndex dbr = model.index(deselectBottom, deselectRight); + + selections.select(QItemSelection(stl, sbr), QItemSelectionModel::ClearAndSelect); + QTBUG48402_helper helper; + helper.connect(&selections, &QItemSelectionModel::selectionChanged, &helper, &QTBUG48402_helper::changed); + QVERIFY(selections.isSelected(stl)); + QVERIFY(selections.isSelected(sbr)); + QVERIFY(selections.hasSelection()); + + model.removeRows(removeTop, removeBottom - removeTop + 1); + + QCOMPARE(QItemSelectionRange(helper.tl, helper.br), QItemSelectionRange(dtl, dbr)); +} + QTEST_MAIN(tst_QItemSelectionModel) #include "tst_qitemselectionmodel.moc" |