QHeaderView - adding an auto test with saveState and restoreState

This test is nice to have regardless though the main reason for it
is a refactor of hiddenSections in QHeaderView.

Change-Id: Id41a1d5edda2ef75bf432a78cdb3e952303eae92
Reviewed-by: Stephen Kelly <stephen.kelly@kdab.com>
This commit is contained in:
Thorbjørn Lund Martsum 2012-06-23 20:06:19 +02:00 committed by Qt by Nokia
parent f8f6acb05c
commit 5dc9036e18

View File

@ -230,6 +230,7 @@ private slots:
void insertTest();
void mixedTests();
void resizeToContentTest();
void testStreamWithHide();
protected:
void setupTestData(bool use_reset_model = false);
@ -2698,5 +2699,26 @@ void tst_QHeaderView::resizeToContentTest()
calculateAndCheck(__LINE__, precalced_results);
}
void tst_QHeaderView::testStreamWithHide()
{
#ifndef QT_NO_DATASTREAM
m_tableview->setVerticalHeader(view);
m_tableview->setModel(model);
view->setDefaultSectionSize(25);
view->hideSection(2);
view->swapSections(1, 2);
QByteArray s = view->saveState();
view->swapSections(1, 2);
view->setDefaultSectionSize(30); // To make sure our precalced data are correct.
view->restoreState(s);
const int precalced_results[] = { -1116614432, -1528653200, -1914165644, 244434607, -1111214068, 750357900, 75};
calculateAndCheck(__LINE__, precalced_results);
#else
QSKIP("Datastream required for testStreamWithHide. Skipping this test.");
#endif
}
QTEST_MAIN(tst_QHeaderView)
#include "tst_qheaderview.moc"