diff options
author | Thiago Macieira <thiago.macieira@intel.com> | 2013-08-22 00:11:16 +0200 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-08-22 02:04:39 +0200 |
commit | c374f4441ab42d1849431bb42fec91a976a8e502 (patch) | |
tree | 0733146c5df48b91a39097730c445dbe9cd2359a /tests/auto/widgets | |
parent | 85b24bb2dea97c3a9b013bacd5a422b26fe5d14b (diff) | |
parent | c8ca300e491c186304d0864a9e870337e891e6f7 (diff) |
Merge "Merge remote-tracking branch 'origin/stable' into dev" into refs/staging/dev
Diffstat (limited to 'tests/auto/widgets')
4 files changed, 82 insertions, 4 deletions
diff --git a/tests/auto/widgets/graphicsview/qgraphicsitem/tst_qgraphicsitem.cpp b/tests/auto/widgets/graphicsview/qgraphicsitem/tst_qgraphicsitem.cpp index 9353aa0eba..2c03850181 100644 --- a/tests/auto/widgets/graphicsview/qgraphicsitem/tst_qgraphicsitem.cpp +++ b/tests/auto/widgets/graphicsview/qgraphicsitem/tst_qgraphicsitem.cpp @@ -4423,10 +4423,13 @@ void tst_QGraphicsItem::defaultItemTest_QGraphicsEllipseItem() QCOMPARE(item.boundingRect(), QRectF(0, 0, 100, 100)); item.setSpanAngle(90 * 16); - qFuzzyCompare(item.boundingRect().left(), qreal(50.0)); - qFuzzyCompare(item.boundingRect().top(), qreal(0.0)); - qFuzzyCompare(item.boundingRect().width(), qreal(50.0)); - qFuzzyCompare(item.boundingRect().height(), qreal(50.0)); + // for some reason, the bounding rect has very few significant digits + // (i.e. it's likely that floats are being used inside it), so we + // must force the conversion from qreals to float or these tests will fail + QCOMPARE(float(item.boundingRect().left()), 50.0f); + QVERIFY(qFuzzyIsNull(float(item.boundingRect().top()))); + QCOMPARE(float(item.boundingRect().width()), 50.0f); + QCOMPARE(float(item.boundingRect().height()), 50.0f); item.setPen(QPen(Qt::black, 1)); QCOMPARE(item.boundingRect(), QRectF(49.5, -0.5, 51, 51)); 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" diff --git a/tests/auto/widgets/kernel/qwidget/qwidget.pro b/tests/auto/widgets/kernel/qwidget/qwidget.pro index 6916ee85e6..a4fcde8a34 100644 --- a/tests/auto/widgets/kernel/qwidget/qwidget.pro +++ b/tests/auto/widgets/kernel/qwidget/qwidget.pro @@ -23,3 +23,4 @@ x11 { !wince*:win32: LIBS += -luser32 -lgdi32 mac:CONFIG+=insignificant_test # QTBUG-25300, QTBUG-23695 +linux-*:system(". /etc/lsb-release && [ $DISTRIB_CODENAME = oneiric ]"):DEFINES+=UBUNTU_ONEIRIC # QTBUG-30566
\ No newline at end of file diff --git a/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp b/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp index fefa7333d1..0085b75299 100644 --- a/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp +++ b/tests/auto/widgets/kernel/qwidget/tst_qwidget.cpp @@ -4859,6 +4859,9 @@ void tst_QWidget::moveChild_data() void tst_QWidget::moveChild() { +#if defined(UBUNTU_ONEIRIC) + QSKIP("QTBUG-30566 - Unstable auto-test"); +#endif QFETCH(QPoint, offset); ColorWidget parent; @@ -4909,6 +4912,9 @@ void tst_QWidget::moveChild() void tst_QWidget::showAndMoveChild() { +#if defined(UBUNTU_ONEIRIC) + QSKIP("QTBUG-30566 - Unstable auto-test"); +#endif QWidget parent(0, Qt::FramelessWindowHint); // prevent custom styles parent.setStyle(QStyleFactory::create(QLatin1String("Windows"))); @@ -7637,6 +7643,9 @@ void tst_QWidget::doubleRepaint() if (!macHasAccessToWindowsServer()) QSKIP("Not having window server access causes the wrong number of repaints to be issues"); #endif +#if defined(UBUNTU_ONEIRIC) + QSKIP("QTBUG-30566 - Unstable auto-test"); +#endif UpdateWidget widget; widget.setFocusPolicy(Qt::StrongFocus); // Filter out activation change and focus events to avoid update() calls in QWidget. |