diff options
author | Frederik Gladhorn <frederik.gladhorn@digia.com> | 2013-08-21 10:38:57 +0200 |
---|---|---|
committer | Frederik Gladhorn <frederik.gladhorn@digia.com> | 2013-08-21 11:03:18 +0200 |
commit | c8ca300e491c186304d0864a9e870337e891e6f7 (patch) | |
tree | f1d991c5960b5acc0bf2a709960e871d48d91acf /tests/auto/widgets/itemviews | |
parent | 31c96d34d27f8cad020238df28c10a71b2c4a34f (diff) | |
parent | 8b540f68a8404e4b9e3ac65a22c11416a91ee749 (diff) |
Merge remote-tracking branch 'origin/stable' into dev
Conflicts:
qmake/doc/src/qmake-manual.qdoc
src/plugins/platforms/xcb/qxcbconnection_xi2.cpp
src/src.pro
Change-Id: I0a560826c420e46988da3776bd8f9160c365459a
Diffstat (limited to 'tests/auto/widgets/itemviews')
-rw-r--r-- | tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp | 65 |
1 files changed, 65 insertions, 0 deletions
diff --git a/tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp b/tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp index ba3a150154..09f0161dff 100644 --- a/tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp +++ b/tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp @@ -46,6 +46,7 @@ #include <QStringListModel> #include <QSortFilterProxyModel> #include <QTableView> +#include <QProxyStyle> #include <qabstractitemmodel.h> #include <qapplication.h> @@ -59,6 +60,20 @@ typedef QList<int> IntList; typedef QList<bool> BoolList; +class TestStyle : public QProxyStyle +{ +public: + void drawControl(ControlElement element, const QStyleOption *option, QPainter *painter, const QWidget *widget) const + { + if (element == CE_HeaderSection) { + if (const QStyleOptionHeader *header = qstyleoption_cast<const QStyleOptionHeader *>(option)) + lastPosition = header->position; + } + QProxyStyle::drawControl(element, option, painter, widget); + } + mutable QStyleOptionHeader::SectionPosition lastPosition; +}; + class protected_QHeaderView : public QHeaderView { Q_OBJECT @@ -229,6 +244,7 @@ private slots: void mixedTests(); void resizeToContentTest(); void testStreamWithHide(); + void testStylePosition(); protected: void setupTestData(bool use_reset_model = false); @@ -2732,5 +2748,54 @@ void tst_QHeaderView::testStreamWithHide() #endif } +void tst_QHeaderView::testStylePosition() +{ + topLevel->show(); + QVERIFY(QTest::qWaitForWindowExposed(topLevel)); + + protected_QHeaderView *header = static_cast<protected_QHeaderView *>(view); + + TestStyle proxy; + header->setStyle(&proxy); + + QImage image(1, 1, QImage::Format_ARGB32); + QPainter p(&image); + + // 0, 1, 2, 3 + header->paintSection(&p, view->rect(), 0); + QCOMPARE(proxy.lastPosition, QStyleOptionHeader::Beginning); + header->paintSection(&p, view->rect(), 1); + QCOMPARE(proxy.lastPosition, QStyleOptionHeader::Middle); + header->paintSection(&p, view->rect(), 2); + QCOMPARE(proxy.lastPosition, QStyleOptionHeader::Middle); + header->paintSection(&p, view->rect(), 3); + QCOMPARE(proxy.lastPosition, QStyleOptionHeader::End); + + // (0),2,1,3 + view->setSectionHidden(0, true); + view->swapSections(1, 2); + header->paintSection(&p, view->rect(), 1); + QCOMPARE(proxy.lastPosition, QStyleOptionHeader::Middle); + header->paintSection(&p, view->rect(), 2); + QCOMPARE(proxy.lastPosition, QStyleOptionHeader::Beginning); + header->paintSection(&p, view->rect(), 3); + QCOMPARE(proxy.lastPosition, QStyleOptionHeader::End); + + // (1),2,0,(3) + view->setSectionHidden(3, true); + view->setSectionHidden(0, false); + view->setSectionHidden(1, true); + view->swapSections(0, 1); + header->paintSection(&p, view->rect(), 0); + QCOMPARE(proxy.lastPosition, QStyleOptionHeader::End); + header->paintSection(&p, view->rect(), 2); + QCOMPARE(proxy.lastPosition, QStyleOptionHeader::Beginning); + + // (1),2,(0),(3) + view->setSectionHidden(0, true); + header->paintSection(&p, view->rect(), 2); + QCOMPARE(proxy.lastPosition, QStyleOptionHeader::OnlyOneSection); +} + QTEST_MAIN(tst_QHeaderView) #include "tst_qheaderview.moc" |