diff options
author | Liang Qi <liang.qi@qt.io> | 2017-05-31 18:54:04 +0000 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2017-05-31 18:54:04 +0000 |
commit | e3bc01b0e339aa3730c619fb02201aa09468d557 (patch) | |
tree | ace583c75770f52f65b9d78c62303693038f672c /tests | |
parent | f33cf18d882ada727da0f378525e55d9421e3b16 (diff) | |
parent | 7ee80242de2744790e5c35662c14594981f8586d (diff) |
Merge "Merge remote-tracking branch 'origin/5.9.0' into 5.9" into refs/staging/5.9
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp b/tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp index 7bfec2831d..b13e7b2f33 100644 --- a/tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp +++ b/tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp @@ -171,6 +171,7 @@ private slots: void saveRestore(); void restoreQt4State(); void restoreToMoreColumns(); + void restoreToMoreColumnsNoMovedColumns(); void restoreBeforeSetModel(); void defaultSectionSizeTest(); void defaultSectionSizeTestStyles(); @@ -1690,6 +1691,55 @@ void tst_QHeaderView::restoreToMoreColumns() QCOMPARE(h4.hiddenSectionCount(), 1); QCOMPARE(h4.sortIndicatorSection(), 2); QCOMPARE(h4.sortIndicatorOrder(), Qt::DescendingOrder); + QCOMPARE(h4.logicalIndex(0), 2); + QCOMPARE(h4.logicalIndex(1), 1); + QCOMPARE(h4.logicalIndex(2), 0); + QCOMPARE(h4.visualIndex(0), 2); + QCOMPARE(h4.visualIndex(1), 1); + QCOMPARE(h4.visualIndex(2), 0); + + // Repainting shouldn't crash + h4.show(); + QVERIFY(QTest::qWaitForWindowExposed(&h4)); +} + +void tst_QHeaderView::restoreToMoreColumnsNoMovedColumns() +{ + // Given a model with 2 columns, for saving state + QHeaderView h1(Qt::Horizontal); + QStandardItemModel model1(1, 2); + h1.setModel(&model1); + QCOMPARE(h1.visualIndex(0), 0); + QCOMPARE(h1.visualIndex(1), 1); + QCOMPARE(h1.logicalIndex(0), 0); + QCOMPARE(h1.logicalIndex(1), 1); + const QByteArray savedState = h1.saveState(); + + // And a model with 3 columns, to apply that state upon + QHeaderView h2(Qt::Horizontal); + QStandardItemModel model2(1, 3); + h2.setModel(&model2); + QCOMPARE(h2.visualIndex(0), 0); + QCOMPARE(h2.visualIndex(1), 1); + QCOMPARE(h2.visualIndex(2), 2); + QCOMPARE(h2.logicalIndex(0), 0); + QCOMPARE(h2.logicalIndex(1), 1); + QCOMPARE(h2.logicalIndex(2), 2); + + // When calling restoreState() + QVERIFY(h2.restoreState(savedState)); + + // Then the index mapping should still be as default + QCOMPARE(h2.visualIndex(0), 0); + QCOMPARE(h2.visualIndex(1), 1); + QCOMPARE(h2.visualIndex(2), 2); + QCOMPARE(h2.logicalIndex(0), 0); + QCOMPARE(h2.logicalIndex(1), 1); + QCOMPARE(h2.logicalIndex(2), 2); + + // And repainting shouldn't crash + h2.show(); + QVERIFY(QTest::qWaitForWindowExposed(&h2)); } void tst_QHeaderView::restoreBeforeSetModel() |