diff options
author | J-P Nurmi <jpnurmi@digia.com> | 2012-09-20 15:35:21 +0200 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2012-10-13 05:51:19 +0200 |
commit | 6b04ee10e6a17999679de86e80ce66886ceab963 (patch) | |
tree | a939a0c9466e90d19ffeffc76bbd592ae2d3489a /tests/auto/widgets/graphicsview | |
parent | dc0d5bf387a0b440c74b9e822c46b09e20e00720 (diff) |
Auto tests: revise cursor dependant tests
Cursor dependant auto tests are currently skipped in various ways.
Some are checking PlatformQuirks::haveMouseCursor() that tries to
detect if the desktop environment is MeeGo, using obsolete Q_WS_X11.
Some are skipped if QT_NO_CURSOR or Q_OS_WINCE is defined and
some are actually missing the approriate guards.
=> unify by defining QTEST_NO_CURSOR in qtest-config.h when
appropriate ie. for platforms that have no regular mouse cursor
support or when QT_NO_CURSOR is defined.
Task-number: QTBUG-22551
Change-Id: I9a1e0e3156617945ae46226c79268955454c8a9a
Reviewed-by: Laszlo Papp <lpapp@kde.org>
Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
Reviewed-by: Caroline Chao <caroline.chao@digia.com>
Diffstat (limited to 'tests/auto/widgets/graphicsview')
4 files changed, 46 insertions, 60 deletions
diff --git a/tests/auto/widgets/graphicsview/qgraphicsitem/tst_qgraphicsitem.cpp b/tests/auto/widgets/graphicsview/qgraphicsitem/tst_qgraphicsitem.cpp index 73bca1ca3d..f78b40bdf0 100644 --- a/tests/auto/widgets/graphicsview/qgraphicsitem/tst_qgraphicsitem.cpp +++ b/tests/auto/widgets/graphicsview/qgraphicsitem/tst_qgraphicsitem.cpp @@ -73,7 +73,7 @@ Q_DECLARE_METATYPE(QPainterPath) Q_DECLARE_METATYPE(QPointF) Q_DECLARE_METATYPE(QRectF) -#include "../../../platformquirks.h" +#include "../../../qtest-config.h" #if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) #include <windows.h> @@ -360,7 +360,9 @@ private slots: void filtersChildEvents(); void filtersChildEvents2(); void ensureVisible(); +#ifndef QTEST_NO_CURSOR void cursor(); +#endif //void textControlGetterSetter(); void defaultItemTest_QGraphicsLineItem(); void defaultItemTest_QGraphicsPixmapItem(); @@ -4145,9 +4147,9 @@ void tst_QGraphicsItem::ensureVisible() QTest::qWait(25); } +#ifndef QTEST_NO_CURSOR void tst_QGraphicsItem::cursor() { -#ifndef QT_NO_CURSOR QGraphicsScene scene; QGraphicsRectItem *item1 = scene.addRect(QRectF(0, 0, 50, 50)); QGraphicsRectItem *item2 = scene.addRect(QRectF(0, 0, 50, 50)); @@ -4203,15 +4205,6 @@ void tst_QGraphicsItem::cursor() QApplication::sendEvent(view.viewport(), &event); } - if (!PlatformQuirks::haveMouseCursor()) - return; -#if !defined(Q_OS_WINCE) - QTest::qWait(250); -#else - // Test environment does not have any cursor, therefore no shape - return; -#endif - QCOMPARE(view.viewport()->cursor().shape(), item1->cursor().shape()); { @@ -4233,8 +4226,8 @@ void tst_QGraphicsItem::cursor() QTest::qWait(25); QCOMPARE(view.viewport()->cursor().shape(), cursor.shape()); -#endif } +#endif /* void tst_QGraphicsItem::textControlGetterSetter() { @@ -4499,7 +4492,7 @@ protected: case QGraphicsItem::ItemSceneHasChanged: break; case QGraphicsItem::ItemCursorChange: -#ifndef QT_NO_CURSOR +#ifndef QTEST_NO_CURSOR oldValues << cursor(); #endif break; diff --git a/tests/auto/widgets/graphicsview/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp b/tests/auto/widgets/graphicsview/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp index 88aaab3096..e9865f2b22 100644 --- a/tests/auto/widgets/graphicsview/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp +++ b/tests/auto/widgets/graphicsview/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp @@ -49,6 +49,8 @@ #include <QMacStyle> #endif +#include "../../../qtest-config.h" + static void sendMouseMove(QWidget *widget, const QPoint &point, Qt::MouseButton button = Qt::NoButton) { QMouseEvent event(QEvent::MouseMove, point, widget->mapToGlobal(point), button, button, 0); @@ -115,8 +117,10 @@ private slots: void focusNextPrevChild(); void focusOutEvent_data(); void focusOutEvent(); +#ifndef QTEST_NO_CURSOR void hoverEnterLeaveEvent_data(); void hoverEnterLeaveEvent(); +#endif void hoverMoveEvent_data(); void hoverMoveEvent(); void keyPressEvent_data(); @@ -154,7 +158,9 @@ private slots: void setFocus_complexTwoWidgets(); void popup_basic(); void popup_subwidget(); +#ifndef QTEST_NO_CURSOR void changingCursor_basic(); +#endif void tooltip_basic(); void childPos_data(); void childPos(); @@ -423,7 +429,7 @@ void tst_QGraphicsProxyWidget::setWidget() } QWidget *widget = new QWidget; -#ifndef QT_NO_CURSOR +#ifndef QTEST_NO_CURSOR widget->setCursor(Qt::IBeamCursor); #endif widget->setPalette(QPalette(Qt::magenta)); @@ -461,7 +467,7 @@ void tst_QGraphicsProxyWidget::setWidget() QVERIFY(subWidget->testAttribute(Qt::WA_DontShowOnScreen)); QVERIFY(!subWidget->testAttribute(Qt::WA_QuitOnClose)); QCOMPARE(proxy->acceptHoverEvents(), true); -#ifndef QT_NO_CURSOR +#ifndef QTEST_NO_CURSOR QVERIFY(proxy->hasCursor()); // These should match @@ -938,6 +944,7 @@ protected: } }; +#ifndef QTEST_NO_CURSOR void tst_QGraphicsProxyWidget::hoverEnterLeaveEvent_data() { QTest::addColumn<bool>("hasWidget"); @@ -954,10 +961,6 @@ void tst_QGraphicsProxyWidget::hoverEnterLeaveEvent() QFETCH(bool, hasWidget); QFETCH(bool, hoverEnabled); -#if defined(Q_OS_WINCE) && (!defined(GWES_ICONCURS) || defined(QT_NO_CURSOR)) - QSKIP("hover events not supported on this platform"); -#endif - // proxy should translate this into events that the widget would expect QGraphicsScene scene; @@ -1003,6 +1006,7 @@ void tst_QGraphicsProxyWidget::hoverEnterLeaveEvent() if (!hasWidget) delete widget; } +#endif void tst_QGraphicsProxyWidget::hoverMoveEvent_data() { @@ -1522,7 +1526,7 @@ void tst_QGraphicsProxyWidget::setWidget_simple() // Properties // QCOMPARE(proxy.focusPolicy(), lineEdit->focusPolicy()); // QCOMPARE(proxy.palette(), lineEdit->palette()); -#ifndef QT_NO_CURSOR +#ifndef QTEST_NO_CURSOR QCOMPARE(proxy.cursor().shape(), lineEdit->cursor().shape()); #endif QCOMPARE(proxy.layoutDirection(), lineEdit->layoutDirection()); @@ -2538,12 +2542,9 @@ void tst_QGraphicsProxyWidget::popup_subwidget() QCOMPARE(popup->size(), child->size().toSize()); } +#ifndef QTEST_NO_CURSOR void tst_QGraphicsProxyWidget::changingCursor_basic() { -#if defined(Q_OS_WINCE) && (!defined(GWES_ICONCURS) || defined(QT_NO_CURSOR)) - QSKIP("hover events not supported on this platform"); -#endif -#ifndef QT_NO_CURSOR // Confirm that mouse events are working properly by checking that // when moving the mouse over a line edit it will change the cursor into the I QGraphicsScene scene; @@ -2568,8 +2569,8 @@ void tst_QGraphicsProxyWidget::changingCursor_basic() QTest::mouseMove(view.viewport(), QPoint(1, 1)); sendMouseMove(view.viewport(), QPoint(1, 1)); QTRY_COMPARE(view.viewport()->cursor().shape(), Qt::ArrowCursor); -#endif } +#endif void tst_QGraphicsProxyWidget::tooltip_basic() { @@ -3617,7 +3618,7 @@ public slots: void tst_QGraphicsProxyWidget::QTBUG_6986_sendMouseEventToAlienWidget() { -#if defined(Q_OS_MAC) || defined(Q_OS_WIN) || defined(QT_NO_CURSOR) +#if defined(Q_OS_MAC) || defined(Q_OS_WIN) || defined(QTEST_NO_CURSOR) QSKIP("Test case unstable on this platform"); #endif QGraphicsView view; diff --git a/tests/auto/widgets/graphicsview/qgraphicsview/tst_qgraphicsview.cpp b/tests/auto/widgets/graphicsview/qgraphicsview/tst_qgraphicsview.cpp index 96aba11d52..0ddae14738 100644 --- a/tests/auto/widgets/graphicsview/qgraphicsview/tst_qgraphicsview.cpp +++ b/tests/auto/widgets/graphicsview/qgraphicsview/tst_qgraphicsview.cpp @@ -68,10 +68,11 @@ #include <QtWidgets/QDesktopWidget> #include <private/qgraphicsscene_p.h> #include <private/qgraphicsview_p.h> -#include "../../../platformquirks.h" #include "../../../shared/platforminputcontext.h" #include <private/qinputmethod_p.h> +#include "../../../qtest-config.h" + Q_DECLARE_METATYPE(QList<int>) Q_DECLARE_METATYPE(QList<QRectF>) Q_DECLARE_METATYPE(QMatrix) @@ -196,8 +197,10 @@ private slots: void mapFromScenePath(); void sendEvent(); void wheelEvent(); +#ifndef QTEST_NO_CURSOR void cursor(); void cursor2(); +#endif void transformationAnchor(); void resizeAnchor(); void viewportUpdateMode(); @@ -256,7 +259,9 @@ private slots: void QTBUG_4151_clipAndIgnore_data(); void QTBUG_4151_clipAndIgnore(); void QTBUG_5859_exposedRect(); +#ifndef QTEST_NO_CURSOR void QTBUG_7438_cursor(); +#endif void hoverLeave(); void QTBUG_16063_microFocusRect(); @@ -678,7 +683,7 @@ void tst_QGraphicsView::dragMode_scrollHand() for (int i = 0; i < 2; ++i) { // ScrollHandDrag -#ifndef QT_NO_CURSOR +#ifndef QTEST_NO_CURSOR Qt::CursorShape cursorShape = view.viewport()->cursor().shape(); #endif int horizontalScrollBarValue = view.horizontalScrollBar()->value(); @@ -697,7 +702,7 @@ void tst_QGraphicsView::dragMode_scrollHand() QTRY_VERIFY(item->isSelected()); for (int k = 0; k < 4; ++k) { -#ifndef QT_NO_CURSOR +#ifndef QTEST_NO_CURSOR QCOMPARE(view.viewport()->cursor().shape(), Qt::ClosedHandCursor); #endif { @@ -740,7 +745,7 @@ void tst_QGraphicsView::dragMode_scrollHand() QTRY_VERIFY(item->isSelected()); QCOMPARE(view.horizontalScrollBar()->value(), horizontalScrollBarValue - 10); QCOMPARE(view.verticalScrollBar()->value(), verticalScrollBarValue - 10); -#ifndef QT_NO_CURSOR +#ifndef QTEST_NO_CURSOR QCOMPARE(view.viewport()->cursor().shape(), cursorShape); #endif @@ -800,7 +805,7 @@ void tst_QGraphicsView::dragMode_rubberBand() for (int i = 0; i < 2; ++i) { // RubberBandDrag -#ifndef QT_NO_CURSOR +#ifndef QTEST_NO_CURSOR Qt::CursorShape cursorShape = view.viewport()->cursor().shape(); #endif int horizontalScrollBarValue = view.horizontalScrollBar()->value(); @@ -814,7 +819,7 @@ void tst_QGraphicsView::dragMode_rubberBand() QApplication::sendEvent(view.viewport(), &event); QVERIFY(event.isAccepted()); } -#ifndef QT_NO_CURSOR +#ifndef QTEST_NO_CURSOR QCOMPARE(view.viewport()->cursor().shape(), cursorShape); #endif @@ -862,7 +867,7 @@ void tst_QGraphicsView::dragMode_rubberBand() } QCOMPARE(view.horizontalScrollBar()->value(), horizontalScrollBarValue); QCOMPARE(view.verticalScrollBar()->value(), verticalScrollBarValue); -#ifndef QT_NO_CURSOR +#ifndef QTEST_NO_CURSOR QCOMPARE(view.viewport()->cursor().shape(), cursorShape); #endif @@ -2102,15 +2107,9 @@ void tst_QGraphicsView::wheelEvent() QVERIFY(widget->hasFocus()); } +#ifndef QTEST_NO_CURSOR void tst_QGraphicsView::cursor() { -#ifndef QT_NO_CURSOR -#if defined(Q_OS_WINCE) - QSKIP("Qt/CE does not have regular cursor support"); -#endif - if (PlatformQuirks::haveMouseCursor()) - QSKIP("The Platform does not have regular cursor support"); - QGraphicsScene scene; QGraphicsItem *item = scene.addRect(QRectF(-10, -10, 20, 20)); item->setCursor(Qt::IBeamCursor); @@ -2129,20 +2128,12 @@ void tst_QGraphicsView::cursor() sendMouseMove(view.viewport(), QPoint(5, 5)); QCOMPARE(view.viewport()->cursor().shape(), Qt::PointingHandCursor); -#endif } +#endif -// Qt/CE does not have regular cursor support. -#if !defined(QT_NO_CURSOR) && !defined(Q_OS_WINCE) +#ifndef QTEST_NO_CURSOR void tst_QGraphicsView::cursor2() { -#ifndef QT_NO_CURSOR -#if defined(Q_OS_WINCE) - QSKIP("Qt/CE does not have regular cursor support"); -#endif - if (PlatformQuirks::haveMouseCursor()) - QSKIP("The Platform does not have regular cursor support"); - QGraphicsScene scene; QGraphicsItem *item = scene.addRect(QRectF(-10, -10, 20, 20)); item->setCursor(Qt::IBeamCursor); @@ -2205,8 +2196,8 @@ void tst_QGraphicsView::cursor2() QCOMPARE(view.viewport()->cursor().shape(), Qt::IBeamCursor); sendMouseMove(view.viewport(), view.mapFromScene(-15, -15)); QCOMPARE(view.viewport()->cursor().shape(), Qt::SizeAllCursor); -#endif } +#endif void tst_QGraphicsView::transformationAnchor() { @@ -3529,7 +3520,7 @@ void tst_QGraphicsView::mouseTracking() QGraphicsView view(&scene); QGraphicsRectItem *item = new QGraphicsRectItem(10, 10, 10, 10); -#ifndef QT_NO_CURSOR +#ifndef QTEST_NO_CURSOR item->setCursor(Qt::CrossCursor); #endif scene.addItem(item); @@ -3539,7 +3530,7 @@ void tst_QGraphicsView::mouseTracking() // Adding an item to the scene before the scene is set on the view. QGraphicsScene scene(-10000, -10000, 20000, 20000); QGraphicsRectItem *item = new QGraphicsRectItem(10, 10, 10, 10); -#ifndef QT_NO_CURSOR +#ifndef QTEST_NO_CURSOR item->setCursor(Qt::CrossCursor); #endif scene.addItem(item); @@ -3556,7 +3547,7 @@ void tst_QGraphicsView::mouseTracking() QGraphicsView view3(&scene); QGraphicsRectItem *item = new QGraphicsRectItem(10, 10, 10, 10); -#ifndef QT_NO_CURSOR +#ifndef QTEST_NO_CURSOR item->setCursor(Qt::CrossCursor); #endif scene.addItem(item); @@ -4359,7 +4350,6 @@ void tst_QGraphicsView::task255529_transformationAnchorMouseAndViewportMargins() QEXPECT_FAIL("", message.constData(), Abort); #endif QVERIFY2(dx < slack && dy < slack, message.constData()); -#endif } void tst_QGraphicsView::task259503_scrollingArtifacts() @@ -4505,12 +4495,9 @@ void tst_QGraphicsView::QTBUG_5859_exposedRect() QCOMPARE(item.lastExposedRect, scene.lastBackgroundExposedRect); } +#ifndef QTEST_NO_CURSOR void tst_QGraphicsView::QTBUG_7438_cursor() { -#ifndef QT_NO_CURSOR -#if defined(Q_OS_WINCE) - QSKIP("Qt/CE does not have regular cursor support"); -#endif QGraphicsScene scene; QGraphicsItem *item = scene.addRect(QRectF(-10, -10, 20, 20)); item->setFlag(QGraphicsItem::ItemIsMovable); @@ -4529,8 +4516,8 @@ void tst_QGraphicsView::QTBUG_7438_cursor() QCOMPARE(view.viewport()->cursor().shape(), Qt::PointingHandCursor); sendMouseRelease(view.viewport(), view.mapFromScene(0, 0)); QCOMPARE(view.viewport()->cursor().shape(), Qt::PointingHandCursor); -#endif } +#endif class GraphicsItemWithHover : public QGraphicsRectItem { diff --git a/tests/auto/widgets/graphicsview/qgraphicswidget/tst_qgraphicswidget.cpp b/tests/auto/widgets/graphicsview/qgraphicswidget/tst_qgraphicswidget.cpp index 177670bb84..1987a37306 100644 --- a/tests/auto/widgets/graphicsview/qgraphicswidget/tst_qgraphicswidget.cpp +++ b/tests/auto/widgets/graphicsview/qgraphicswidget/tst_qgraphicswidget.cpp @@ -53,6 +53,7 @@ #include <qaction.h> #include <qwidgetaction.h> +#include "../../../qtest-config.h" class EventSpy : public QObject { @@ -3203,10 +3204,12 @@ void tst_QGraphicsWidget::itemChangeEvents() valueDuringEvents.insert(QEvent::ParentChange, QVariant::fromValue(parentItem())); break; } +#ifndef QTEST_NO_CURSOR case QEvent::CursorChange: { valueDuringEvents.insert(QEvent::CursorChange, int(cursor().shape())); break; } +#endif case QEvent::ToolTipChange: { valueDuringEvents.insert(QEvent::ToolTipChange, toolTip()); break; @@ -3252,9 +3255,11 @@ void tst_QGraphicsWidget::itemChangeEvents() QVERIFY(!item->isVisible()); QTRY_VERIFY(!item->valueDuringEvents.value(QEvent::Hide).toBool()); +#ifndef QTEST_NO_CURSOR // CursorChange should be triggered after the cursor has changed item->setCursor(Qt::PointingHandCursor); QTRY_COMPARE(item->valueDuringEvents.value(QEvent::CursorChange).toInt(), int(item->cursor().shape())); +#endif // ToolTipChange should be triggered after the tooltip has changed item->setToolTip("tooltipText"); |