diff options
author | Olivier Goffart <ogoffart@trolltech.com> | 2009-10-13 09:05:24 (GMT) |
---|---|---|
committer | Olivier Goffart <ogoffart@trolltech.com> | 2009-10-13 09:05:48 (GMT) |
commit | dee871b4375c2625217448f2b15e4518b7f9d993 (patch) | |
tree | 62a1fd5e271dbf0b9359d4f7fbad006541a88cef /tests/auto | |
parent | 9c6e466dc09813dd4a641b2cf385f35ac99346f5 (diff) | |
parent | 6a1be803bf94b8af4a4766e31df9b441d1c81eed (diff) | |
download | Qt-dee871b4375c2625217448f2b15e4518b7f9d993.zip Qt-dee871b4375c2625217448f2b15e4518b7f9d993.tar.gz Qt-dee871b4375c2625217448f2b15e4518b7f9d993.tar.bz2 |
Merge qt-team-widgets/4.6 into origin/4.6
Diffstat (limited to 'tests/auto')
-rw-r--r-- | tests/auto/auto.pro | 1 | ||||
-rw-r--r-- | tests/auto/bic/tst_bic.cpp | 2 | ||||
-rw-r--r-- | tests/auto/qfilesystemmodel/tst_qfilesystemmodel.cpp | 2 | ||||
-rw-r--r-- | tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp | 2 | ||||
-rw-r--r-- | tests/auto/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp | 81 | ||||
-rw-r--r-- | tests/auto/qgraphicsscene/tst_qgraphicsscene.cpp | 28 | ||||
-rw-r--r-- | tests/auto/qgraphicsview/tst_qgraphicsview.cpp | 14 | ||||
-rw-r--r-- | tests/auto/qgraphicswidget/tst_qgraphicswidget.cpp | 53 | ||||
-rw-r--r-- | tests/auto/qpauseanimation/qpauseanimation.pro | 5 | ||||
-rw-r--r-- | tests/auto/qpauseanimation/tst_qpauseanimation.cpp | 409 | ||||
-rw-r--r-- | tests/auto/qtableview/tst_qtableview.cpp | 166 | ||||
-rw-r--r-- | tests/auto/qwidgetaction/tst_qwidgetaction.cpp | 2 |
12 files changed, 745 insertions, 20 deletions
diff --git a/tests/auto/auto.pro b/tests/auto/auto.pro index 9bc1d5c..8e3ce81 100644 --- a/tests/auto/auto.pro +++ b/tests/auto/auto.pro @@ -234,6 +234,7 @@ SUBDIRS += \ qpainterpath \ qpalette \ qparallelanimationgroup \ + qpauseanimation \ qpathclipper \ qpen \ qpicture \ diff --git a/tests/auto/bic/tst_bic.cpp b/tests/auto/bic/tst_bic.cpp index 82c8dc0..8c6056e 100644 --- a/tests/auto/bic/tst_bic.cpp +++ b/tests/auto/bic/tst_bic.cpp @@ -252,6 +252,7 @@ QBic::Info tst_Bic::getCurrentInfo(const QString &libName) } if (proc.exitCode() != 0) { qWarning() << "gcc returned with" << proc.exitCode(); + qDebug() << proc.readAllStandardError(); return QBic::Info(); } @@ -268,6 +269,7 @@ QBic::Info tst_Bic::getCurrentInfo(const QString &libName) qFatal("Could not locate the GCC output file, update this test"); return QBic::Info(); } else if (files.size() > 1) { + qDebug() << files; qFatal("Located more than one output file, please clean up before running this test"); return QBic::Info(); } diff --git a/tests/auto/qfilesystemmodel/tst_qfilesystemmodel.cpp b/tests/auto/qfilesystemmodel/tst_qfilesystemmodel.cpp index 29e4fe6..3b24352 100644 --- a/tests/auto/qfilesystemmodel/tst_qfilesystemmodel.cpp +++ b/tests/auto/qfilesystemmodel/tst_qfilesystemmodel.cpp @@ -874,7 +874,7 @@ void tst_QFileSystemModel::sort() } else { for(int i = 0; i < myModel->rowCount(parent); ++i) { - QVERIFY(dirPath + QChar('/') + myModel->index(i, 1, parent).data(QFileSystemModel::FileNameRole).toString() == expectedOrder.at(i)); + QTRY_COMPARE(dirPath + QChar('/') + myModel->index(i, 1, parent).data(QFileSystemModel::FileNameRole).toString(), expectedOrder.at(i)); } } diff --git a/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp b/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp index e4eaf4e..49b76ac 100644 --- a/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp +++ b/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp @@ -6183,7 +6183,7 @@ void tst_QGraphicsItem::opacity2() MyGraphicsView view(&scene); view.show(); QTest::qWaitForWindowShown(&view); - QTRY_COMPARE(view.repaints, 1); + QTRY_VERIFY(view.repaints >= 1); #define RESET_REPAINT_COUNTERS \ parent->repaints = 0; \ diff --git a/tests/auto/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp b/tests/auto/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp index 76e7202..58d7896 100644 --- a/tests/auto/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp +++ b/tests/auto/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp @@ -170,6 +170,7 @@ private slots: void dontCrashWhenDie(); void createProxyForChildWidget(); void actionsContextMenu(); + void actionsContextMenu_data(); void deleteProxyForChildWidget(); void bypassGraphicsProxyWidget_data(); void bypassGraphicsProxyWidget(); @@ -1756,6 +1757,8 @@ void tst_QGraphicsProxyWidget::tabFocus_simpleWidget() QTRY_VERIFY(leftDial->hasFocus()); QCOMPARE(eventSpy.counts[QEvent::FocusIn], 2); QCOMPARE(eventSpy.counts[QEvent::FocusOut], 2); + + delete view; } void tst_QGraphicsProxyWidget::tabFocus_simpleTwoWidgets() @@ -1878,6 +1881,8 @@ void tst_QGraphicsProxyWidget::tabFocus_simpleTwoWidgets() QVERIFY(leftDial->hasFocus()); QCOMPARE(eventSpy.counts[QEvent::FocusIn], 2); QCOMPARE(eventSpy.counts[QEvent::FocusOut], 2); + + delete view; } void tst_QGraphicsProxyWidget::tabFocus_complexWidget() @@ -1988,6 +1993,8 @@ void tst_QGraphicsProxyWidget::tabFocus_complexWidget() QApplication::processEvents(); QVERIFY(!box->hasFocus()); leftDial->hasFocus(); + + delete view; } void tst_QGraphicsProxyWidget::tabFocus_complexTwoWidgets() @@ -2156,6 +2163,8 @@ void tst_QGraphicsProxyWidget::tabFocus_complexTwoWidgets() QApplication::processEvents(); QVERIFY(!box->hasFocus()); leftDial->hasFocus(); + + delete view; } void tst_QGraphicsProxyWidget::setFocus_simpleWidget() @@ -2222,6 +2231,8 @@ void tst_QGraphicsProxyWidget::setFocus_simpleWidget() // Symmetry editProxy->clearFocus(); QVERIFY(!edit->hasFocus()); + + delete view; } void tst_QGraphicsProxyWidget::setFocus_simpleTwoWidgets() @@ -2272,6 +2283,8 @@ void tst_QGraphicsProxyWidget::setFocus_simpleTwoWidgets() QVERIFY(!editProxy->hasFocus()); QVERIFY(edit2->hasFocus()); QVERIFY(edit2Proxy->hasFocus()); + + delete view; } void tst_QGraphicsProxyWidget::setFocus_complexTwoWidgets() @@ -2391,6 +2404,8 @@ void tst_QGraphicsProxyWidget::setFocus_complexTwoWidgets() QCOMPARE(eventSpyBox.counts[QEvent::FocusOut], 1); QCOMPARE(eventSpyBox_2.counts[QEvent::FocusIn], 0); QCOMPARE(eventSpyBox_2.counts[QEvent::FocusOut], 0); + + delete view; } void tst_QGraphicsProxyWidget::popup_basic() @@ -2780,13 +2795,13 @@ void tst_QGraphicsProxyWidget::palettePropagation() QCOMPARE(proxySpy.counts[QEvent::PaletteChange], 0); QVERIFY(edit->testAttribute(Qt::WA_SetPalette)); QVERIFY(!proxy.testAttribute(Qt::WA_SetPalette)); - QCOMPARE(proxy.palette(), lineEditPalette); + QCOMPARE(proxy.palette(), QPalette()); edit->setPalette(QPalette()); QCOMPARE(editSpy.counts[QEvent::PaletteChange], 2); QCOMPARE(proxySpy.counts[QEvent::PaletteChange], 0); QVERIFY(!edit->testAttribute(Qt::WA_SetPalette)); QVERIFY(!proxy.testAttribute(Qt::WA_SetPalette)); - QCOMPARE(proxy.palette(), lineEditPalette); + QCOMPARE(proxy.palette(), QPalette()); // Proxy to widget proxy.setPalette(palette); @@ -2896,6 +2911,9 @@ void tst_QGraphicsProxyWidget::dontCrashWhenDie() QTest::qWait(100); QTest::mouseMove(w->view->viewport(), w->view->mapFromScene(w->widget->mapToScene(w->widget->boundingRect().center()))); delete w->item; + + QApplication::processEvents(); + delete w; } void tst_QGraphicsProxyWidget::createProxyForChildWidget() @@ -3014,30 +3032,67 @@ private slots: } }; +void tst_QGraphicsProxyWidget::actionsContextMenu_data() +{ + QTest::addColumn<bool>("actionsContextMenu"); + QTest::addColumn<bool>("hasFocus"); + + QTest::newRow("without actionsContextMenu and with focus") << false << true; + QTest::newRow("without actionsContextMenu and without focus") << false << false; + QTest::newRow("with actionsContextMenu and focus") << true << true; + QTest::newRow("with actionsContextMenu without focus") << true << false; +} + void tst_QGraphicsProxyWidget::actionsContextMenu() { - ContextMenuWidget *widget = new ContextMenuWidget; - widget->addAction(new QAction("item 1", widget)); - widget->addAction(new QAction("item 2", widget)); - widget->addAction(new QAction("item 3", widget)); - widget->setContextMenuPolicy(Qt::ActionsContextMenu); + QFETCH(bool, hasFocus); + QFETCH(bool, actionsContextMenu); + ContextMenuWidget *widget = new ContextMenuWidget; + if (actionsContextMenu) { + widget->addAction(new QAction("item 1", widget)); + widget->addAction(new QAction("item 2", widget)); + widget->addAction(new QAction("item 3", widget)); + widget->setContextMenuPolicy(Qt::ActionsContextMenu); + } QGraphicsScene scene; - scene.addWidget(widget); QGraphicsView view(&scene); view.show(); -#ifdef Q_WS_X11 - qt_x11_wait_for_window_manager(&view); -#endif + QApplication::setActiveWindow(&view); + QTest::qWaitForWindowShown(&view); + view.setFocus(); + QTRY_VERIFY(view.hasFocus()); + + if (hasFocus) + scene.addWidget(widget)->setFocus(); + else + scene.addWidget(widget)->clearFocus(); + + QApplication::processEvents(); + QContextMenuEvent contextMenuEvent(QContextMenuEvent::Mouse, view.viewport()->rect().center(), view.viewport()->mapToGlobal(view.viewport()->rect().center())); contextMenuEvent.accept(); qApp->sendEvent(view.viewport(), &contextMenuEvent); - QVERIFY(widget->embeddedPopup); - QVERIFY(!widget->gotContextMenuEvent); + if (hasFocus) { + if (actionsContextMenu) { + //actionsContextMenu embedded popup but no contextMenuEvent (widget has focus) + QVERIFY(widget->embeddedPopup); + QVERIFY(!widget->gotContextMenuEvent); + } else { + //no embedded popup but contextMenuEvent (widget has focus) + QVERIFY(!widget->embeddedPopup); + QVERIFY(widget->gotContextMenuEvent); + } + } else { + //qgraphicsproxywidget doesn't have the focus, the widget must not receive any contextMenuEvent and must not create any QMenu + QVERIFY(!widget->embeddedPopup); + QVERIFY(!widget->gotContextMenuEvent); + } + } diff --git a/tests/auto/qgraphicsscene/tst_qgraphicsscene.cpp b/tests/auto/qgraphicsscene/tst_qgraphicsscene.cpp index f5e9acb..0589994 100644 --- a/tests/auto/qgraphicsscene/tst_qgraphicsscene.cpp +++ b/tests/auto/qgraphicsscene/tst_qgraphicsscene.cpp @@ -266,6 +266,7 @@ private slots: void dispatchHoverOnPress(); void initialFocus_data(); void initialFocus(); + void polishItems(); // task specific tests below me void task139710_bspTreeCrash(); @@ -3882,5 +3883,32 @@ void tst_QGraphicsScene::initialFocus() QCOMPARE(rect->hasFocus(), shouldHaveFocus); } +class PolishItem : public QGraphicsTextItem +{ +public: + PolishItem(QGraphicsItem *parent = 0) : QGraphicsTextItem(parent) { } + +protected: + QVariant itemChange(GraphicsItemChange change, const QVariant& value) + { + if (change == ItemVisibleChange) { + if (value.toBool()) + qDeleteAll(childItems()); + } + return QGraphicsItem::itemChange(change, value); + } +}; + +void tst_QGraphicsScene::polishItems() +{ + QGraphicsScene scene; + PolishItem *parent = new PolishItem; + scene.addItem(parent); + PolishItem *child = new PolishItem(parent); + Q_UNUSED(child) + // test that QGraphicsScenePrivate::_q_polishItems() doesn't crash + QMetaObject::invokeMethod(&scene,"_q_polishItems"); +} + QTEST_MAIN(tst_QGraphicsScene) #include "tst_qgraphicsscene.moc" diff --git a/tests/auto/qgraphicsview/tst_qgraphicsview.cpp b/tests/auto/qgraphicsview/tst_qgraphicsview.cpp index df3ebef..8acaa72 100644 --- a/tests/auto/qgraphicsview/tst_qgraphicsview.cpp +++ b/tests/auto/qgraphicsview/tst_qgraphicsview.cpp @@ -84,6 +84,12 @@ Q_DECLARE_METATYPE(QPolygonF) Q_DECLARE_METATYPE(QRectF) Q_DECLARE_METATYPE(Qt::ScrollBarPolicy) +#ifdef Q_WS_MAC +//On mac we get full update. So check that the expected region is contained inside the actual +#define COMPARE_REGIONS(ACTUAL, EXPECTED) QVERIFY((EXPECTED).subtracted(ACTUAL).isEmpty()) +#else +#define COMPARE_REGIONS QCOMPARE +#endif static void sendMousePress(QWidget *widget, const QPoint &point, Qt::MouseButton button = Qt::LeftButton) { @@ -115,6 +121,7 @@ public: } int count() const { return _count; } + void reset() { _count = 0; } protected: bool eventFilter(QObject *watched, QEvent *event) @@ -2938,10 +2945,11 @@ void tst_QGraphicsView::task239729_noViewUpdate() view->show(); QTest::qWaitForWindowShown(view); - QTRY_COMPARE(spy.count(), 1); + QTRY_VERIFY(spy.count() >= 1); + spy.reset(); scene.update(); QApplication::processEvents(); - QTRY_COMPARE(spy.count(), 2); + QTRY_COMPARE(spy.count(), 1); delete view; } @@ -3177,7 +3185,7 @@ void tst_QGraphicsView::moveItemWhileScrolling() int a = adjustForAntialiasing ? 2 : 1; expectedRegion += QRect(40, 50, 10, 10).adjusted(-a, -a, a, a); expectedRegion += QRect(40, 60, 10, 10).adjusted(-a, -a, a, a); - QCOMPARE(view.lastPaintedRegion, expectedRegion); + COMPARE_REGIONS(view.lastPaintedRegion, expectedRegion); } void tst_QGraphicsView::centerOnDirtyItem() diff --git a/tests/auto/qgraphicswidget/tst_qgraphicswidget.cpp b/tests/auto/qgraphicswidget/tst_qgraphicswidget.cpp index 26021e0..6b5ad09 100644 --- a/tests/auto/qgraphicswidget/tst_qgraphicswidget.cpp +++ b/tests/auto/qgraphicswidget/tst_qgraphicswidget.cpp @@ -159,6 +159,7 @@ private slots: void ensureClipping(); void widgetSendsGeometryChanges(); void respectHFW(); + void addChildInpolishEvent(); // Task fixes void task236127_bspTreeIndexFails(); @@ -2716,6 +2717,58 @@ void tst_QGraphicsWidget::respectHFW() #endif } +class PolishWidget : public QGraphicsWidget +{ +public: + + PolishWidget(Qt::GlobalColor color, QGraphicsItem *parent=0) : + QGraphicsWidget(parent), mColor(color) + { + } + + void paint(QPainter *painter, const QStyleOptionGraphicsItem *, QWidget *) + { + painter->setBrush(QBrush(mColor)); + painter->drawRect(boundingRect()); + } + + void polishEvent() + { + if (!parentWidget()) { + //We add a child in the polish event for the parent + PolishWidget *childWidget = new PolishWidget(Qt::black, this); + childWidget->setGeometry(QRectF(10,10,30,30)); + } + + QGraphicsWidget::polishEvent(); + mColor = Qt::red; + update(); + numberOfPolish++; + } + + static int numberOfPolish; + +private: + Qt::GlobalColor mColor; +}; + +int PolishWidget::numberOfPolish = 0; + +void tst_QGraphicsWidget::addChildInpolishEvent() +{ + QGraphicsScene scene; + + PolishWidget *parentWidget = new PolishWidget(Qt::white); + scene.addItem(parentWidget); + + QGraphicsView view(&scene); + view.resize(200, 200); + view.show(); + QTest::qWaitForWindowShown(&view); + QCOMPARE(PolishWidget::numberOfPolish, 2); +} + + QTEST_MAIN(tst_QGraphicsWidget) #include "tst_qgraphicswidget.moc" diff --git a/tests/auto/qpauseanimation/qpauseanimation.pro b/tests/auto/qpauseanimation/qpauseanimation.pro new file mode 100644 index 0000000..4599cf0 --- /dev/null +++ b/tests/auto/qpauseanimation/qpauseanimation.pro @@ -0,0 +1,5 @@ +load(qttest_p4) +QT = core gui +SOURCES += tst_qpauseanimation.cpp + + diff --git a/tests/auto/qpauseanimation/tst_qpauseanimation.cpp b/tests/auto/qpauseanimation/tst_qpauseanimation.cpp new file mode 100644 index 0000000..62b43c4 --- /dev/null +++ b/tests/auto/qpauseanimation/tst_qpauseanimation.cpp @@ -0,0 +1,409 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include <QtTest/QtTest> + +#include <QtCore/qpauseanimation.h> +#include <QtCore/qpropertyanimation.h> +#include <QtCore/qsequentialanimationgroup.h> + +#include <private/qabstractanimation_p.h> + +//TESTED_CLASS=QPauseAnimation +//TESTED_FILES= + +class TestablePauseAnimation : public QPauseAnimation +{ + Q_OBJECT +public: + TestablePauseAnimation(QObject *parent = 0) + : QPauseAnimation(parent), + m_updateCurrentTimeCount(0) + { + } + + int m_updateCurrentTimeCount; +protected: + void updateCurrentTime(int currentTime) + { + //qDebug() << this << "update current time: " << currentTime; + QPauseAnimation::updateCurrentTime(currentTime); + ++m_updateCurrentTimeCount; + } +}; + +class EnableConsistentTiming +{ +public: + EnableConsistentTiming() + { + QUnifiedTimer *timer = QUnifiedTimer::instance(); + timer->setConsistentTiming(true); + } + ~EnableConsistentTiming() + { + QUnifiedTimer *timer = QUnifiedTimer::instance(); + timer->setConsistentTiming(false); + } +}; + +class tst_QPauseAnimation : public QObject +{ + Q_OBJECT +public: + tst_QPauseAnimation(); + virtual ~tst_QPauseAnimation(); + +public Q_SLOTS: + void init(); + void cleanup(); + +private slots: + void changeDirectionWhileRunning(); + void noTimerUpdates_data(); + void noTimerUpdates(); + void mulitplePauseAnimations(); + void pauseAndPropertyAnimations(); + void pauseResume(); + void sequentialPauseGroup(); + void sequentialGroupWithPause(); + void multipleSequentialGroups(); + void zeroDuration(); +}; + +tst_QPauseAnimation::tst_QPauseAnimation() +{ +} + +tst_QPauseAnimation::~tst_QPauseAnimation() +{ +} + +void tst_QPauseAnimation::init() +{ + qRegisterMetaType<QAbstractAnimation::State>("QAbstractAnimation::State"); + qRegisterMetaType<QAbstractAnimation::DeletionPolicy>("QAbstractAnimation::DeletionPolicy"); +} + +void tst_QPauseAnimation::cleanup() +{ +} + +void tst_QPauseAnimation::changeDirectionWhileRunning() +{ + QUnifiedTimer *timer = QUnifiedTimer::instance(); + timer->setConsistentTiming(true); + + TestablePauseAnimation animation; + animation.setDuration(400); + animation.start(); + QTest::qWait(100); + QVERIFY(animation.state() == QAbstractAnimation::Running); + animation.setDirection(QAbstractAnimation::Backward); + QTest::qWait(animation.totalDuration() + 50); + QVERIFY(animation.state() == QAbstractAnimation::Stopped); + + timer->setConsistentTiming(false); +} + +void tst_QPauseAnimation::noTimerUpdates_data() +{ + QTest::addColumn<int>("duration"); + QTest::addColumn<int>("loopCount"); + + QTest::newRow("0") << 200 << 1; + QTest::newRow("1") << 160 << 1; + QTest::newRow("2") << 160 << 2; + QTest::newRow("3") << 200 << 3; +} + +void tst_QPauseAnimation::noTimerUpdates() +{ + QUnifiedTimer *timer = QUnifiedTimer::instance(); + timer->setConsistentTiming(true); + + QFETCH(int, duration); + QFETCH(int, loopCount); + + TestablePauseAnimation animation; + animation.setDuration(duration); + animation.setLoopCount(loopCount); + animation.start(); + QTest::qWait(animation.totalDuration() + 100); + QVERIFY(animation.state() == QAbstractAnimation::Stopped); + QCOMPARE(animation.m_updateCurrentTimeCount, 2); + + timer->setConsistentTiming(false); +} + +void tst_QPauseAnimation::mulitplePauseAnimations() +{ + QUnifiedTimer *timer = QUnifiedTimer::instance(); + timer->setConsistentTiming(true); + + TestablePauseAnimation animation; + animation.setDuration(200); + + TestablePauseAnimation animation2; + animation2.setDuration(800); + + animation.start(); + animation2.start(); + QTest::qWait(animation.totalDuration() + 100); + QVERIFY(animation.state() == QAbstractAnimation::Stopped); + QVERIFY(animation2.state() == QAbstractAnimation::Running); + QCOMPARE(animation.m_updateCurrentTimeCount, 2); + QCOMPARE(animation2.m_updateCurrentTimeCount, 2); + + QTest::qWait(550); + QVERIFY(animation2.state() == QAbstractAnimation::Stopped); + QCOMPARE(animation2.m_updateCurrentTimeCount, 3); + + timer->setConsistentTiming(false); +} + +void tst_QPauseAnimation::pauseAndPropertyAnimations() +{ + EnableConsistentTiming enabled; + + TestablePauseAnimation pause; + pause.setDuration(200); + + QObject o; + o.setProperty("ole", 42); + + QPropertyAnimation animation(&o, "ole"); + animation.setEndValue(43); + + pause.start(); + + QTest::qWait(100); + animation.start(); + + QVERIFY(animation.state() == QAbstractAnimation::Running); + QVERIFY(pause.state() == QAbstractAnimation::Running); + QCOMPARE(pause.m_updateCurrentTimeCount, 2); + + QTest::qWait(animation.totalDuration() + 100); + +#ifdef Q_OS_WIN + if (animation.state() != QAbstractAnimation::Stopped) + QEXPECT_FAIL("", "On windows, consistent timing is not working properly due to bad timer resolution", Abort); +#endif + QVERIFY(animation.state() == QAbstractAnimation::Stopped); + QVERIFY(pause.state() == QAbstractAnimation::Stopped); + QVERIFY(pause.m_updateCurrentTimeCount > 3); +} + +void tst_QPauseAnimation::pauseResume() +{ + TestablePauseAnimation animation; + animation.setDuration(400); + animation.start(); + QVERIFY(animation.state() == QAbstractAnimation::Running); + QTest::qWait(200); + animation.pause(); + QVERIFY(animation.state() == QAbstractAnimation::Paused); + animation.start(); + QTest::qWait(250); + QVERIFY(animation.state() == QAbstractAnimation::Stopped); + QCOMPARE(animation.m_updateCurrentTimeCount, 3); +} + +void tst_QPauseAnimation::sequentialPauseGroup() +{ + QSequentialAnimationGroup group; + + TestablePauseAnimation animation1(&group); + animation1.setDuration(200); + TestablePauseAnimation animation2(&group); + animation2.setDuration(200); + TestablePauseAnimation animation3(&group); + animation3.setDuration(200); + + group.start(); + + QVERIFY(group.state() == QAbstractAnimation::Running); + QVERIFY(animation1.state() == QAbstractAnimation::Running); + QVERIFY(animation2.state() == QAbstractAnimation::Stopped); + QVERIFY(animation3.state() == QAbstractAnimation::Stopped); + + group.setCurrentTime(250); + + QVERIFY(group.state() == QAbstractAnimation::Running); + QVERIFY(animation1.state() == QAbstractAnimation::Stopped); + QCOMPARE(&animation2, group.currentAnimation()); + QVERIFY(animation2.state() == QAbstractAnimation::Running); + QVERIFY(animation3.state() == QAbstractAnimation::Stopped); + + group.setCurrentTime(500); + + QVERIFY(group.state() == QAbstractAnimation::Running); + QVERIFY(animation1.state() == QAbstractAnimation::Stopped); + QVERIFY(animation2.state() == QAbstractAnimation::Stopped); + QCOMPARE(&animation3, group.currentAnimation()); + QVERIFY(animation3.state() == QAbstractAnimation::Running); + + group.setCurrentTime(750); + + QVERIFY(group.state() == QAbstractAnimation::Stopped); + QVERIFY(animation1.state() == QAbstractAnimation::Stopped); + QVERIFY(animation2.state() == QAbstractAnimation::Stopped); + QVERIFY(animation3.state() == QAbstractAnimation::Stopped); + + QCOMPARE(animation1.m_updateCurrentTimeCount, 2); + QCOMPARE(animation2.m_updateCurrentTimeCount, 2); + QCOMPARE(animation3.m_updateCurrentTimeCount, 2); +} + +void tst_QPauseAnimation::sequentialGroupWithPause() +{ + QSequentialAnimationGroup group; + + QObject o; + o.setProperty("ole", 42); + + QPropertyAnimation animation(&o, "ole", &group); + animation.setEndValue(43); + TestablePauseAnimation pause(&group); + pause.setDuration(250); + + group.start(); + + QVERIFY(group.state() == QAbstractAnimation::Running); + QVERIFY(animation.state() == QAbstractAnimation::Running); + QVERIFY(pause.state() == QAbstractAnimation::Stopped); + + group.setCurrentTime(300); + + QVERIFY(group.state() == QAbstractAnimation::Running); + QVERIFY(animation.state() == QAbstractAnimation::Stopped); + QCOMPARE(&pause, group.currentAnimation()); + QVERIFY(pause.state() == QAbstractAnimation::Running); + + group.setCurrentTime(600); + + QVERIFY(group.state() == QAbstractAnimation::Stopped); + QVERIFY(animation.state() == QAbstractAnimation::Stopped); + QVERIFY(pause.state() == QAbstractAnimation::Stopped); + + QCOMPARE(pause.m_updateCurrentTimeCount, 2); +} + +void tst_QPauseAnimation::multipleSequentialGroups() +{ + EnableConsistentTiming enabled; + + QParallelAnimationGroup group; + group.setLoopCount(2); + + QSequentialAnimationGroup subgroup1(&group); + + QObject o; + o.setProperty("ole", 42); + + QPropertyAnimation animation(&o, "ole", &subgroup1); + animation.setEndValue(43); + animation.setDuration(300); + TestablePauseAnimation pause(&subgroup1); + pause.setDuration(200); + + QSequentialAnimationGroup subgroup2(&group); + + o.setProperty("ole2", 42); + QPropertyAnimation animation2(&o, "ole2", &subgroup2); + animation2.setEndValue(43); + animation2.setDuration(200); + TestablePauseAnimation pause2(&subgroup2); + pause2.setDuration(250); + + QSequentialAnimationGroup subgroup3(&group); + + TestablePauseAnimation pause3(&subgroup3); + pause3.setDuration(400); + + o.setProperty("ole3", 42); + QPropertyAnimation animation3(&o, "ole3", &subgroup3); + animation3.setEndValue(43); + animation3.setDuration(200); + + QSequentialAnimationGroup subgroup4(&group); + + TestablePauseAnimation pause4(&subgroup4); + pause4.setDuration(310); + + TestablePauseAnimation pause5(&subgroup4); + pause5.setDuration(60); + + group.start(); + + QVERIFY(group.state() == QAbstractAnimation::Running); + QVERIFY(subgroup1.state() == QAbstractAnimation::Running); + QVERIFY(subgroup2.state() == QAbstractAnimation::Running); + QVERIFY(subgroup3.state() == QAbstractAnimation::Running); + QVERIFY(subgroup4.state() == QAbstractAnimation::Running); + + QTest::qWait(group.totalDuration() + 100); + +#ifdef Q_OS_WIN + if (group.state() != QAbstractAnimation::Stopped) + QEXPECT_FAIL("", "On windows, consistent timing is not working properly due to bad timer resolution", Abort); +#endif + QVERIFY(group.state() == QAbstractAnimation::Stopped); + QVERIFY(subgroup1.state() == QAbstractAnimation::Stopped); + QVERIFY(subgroup2.state() == QAbstractAnimation::Stopped); + QVERIFY(subgroup3.state() == QAbstractAnimation::Stopped); + QVERIFY(subgroup4.state() == QAbstractAnimation::Stopped); + + QCOMPARE(pause5.m_updateCurrentTimeCount, 4); +} + +void tst_QPauseAnimation::zeroDuration() +{ + TestablePauseAnimation animation; + animation.start(); + QTest::qWait(animation.totalDuration() + 100); + QVERIFY(animation.state() == QAbstractAnimation::Stopped); + QCOMPARE(animation.m_updateCurrentTimeCount, 1); +} + +QTEST_MAIN(tst_QPauseAnimation) +#include "tst_qpauseanimation.moc" diff --git a/tests/auto/qtableview/tst_qtableview.cpp b/tests/auto/qtableview/tst_qtableview.cpp index 55da180..eab5a35 100644 --- a/tests/auto/qtableview/tst_qtableview.cpp +++ b/tests/auto/qtableview/tst_qtableview.cpp @@ -100,6 +100,9 @@ private slots: void moveCursor_data(); void moveCursor(); + void moveCursorStrikesBack_data(); + void moveCursorStrikesBack(); + void hideRows_data(); void hideRows(); @@ -252,12 +255,43 @@ public: row_count(rows), column_count(columns), can_fetch_more(false), - fetch_more_count(0) {} + fetch_more_count(0), + disabled_rows(), + disabled_columns() {} int rowCount(const QModelIndex& = QModelIndex()) const { return row_count; } int columnCount(const QModelIndex& = QModelIndex()) const { return column_count; } bool isEditable(const QModelIndex &) const { return true; } + Qt::ItemFlags flags(const QModelIndex &index) const + { + Qt::ItemFlags index_flags = QAbstractTableModel::flags(index); + if (disabled_rows.contains(index.row()) + || disabled_columns.contains(index.column())) + index_flags &= ~Qt::ItemIsEnabled; + return index_flags; + } + + void disableRow(int row) + { + disabled_rows.insert(row); + } + + void enableRow(int row) + { + disabled_rows.remove(row); + } + + void disableColumn(int column) + { + disabled_columns.insert(column); + } + + void enableColumn(int column) + { + disabled_columns.remove(column); + } + QVariant data(const QModelIndex &idx, int role) const { if (!idx.isValid() || idx.row() >= row_count || idx.column() >= column_count) { @@ -363,6 +397,8 @@ public: int column_count; bool can_fetch_more; int fetch_more_count; + QSet<int> disabled_rows; + QSet<int> disabled_columns; }; class QtTestTableView : public QTableView @@ -834,7 +870,7 @@ void tst_QTableView::moveCursor_data() << 4 << 4 << -1 << 2 << 0 << 2 << int(QtTestTableView::MoveNext) << int(Qt::NoModifier) - << 1 << 0 << IntPair(0,0) << IntPair(3,0); + << 1 << 3 << IntPair(0,0) << IntPair(3,0); // MoveLeft QTest::newRow("MoveLeft (0,0)") @@ -1137,6 +1173,132 @@ void tst_QTableView::moveCursor() QCOMPARE(newIndex.column(), expectedColumn); } +void tst_QTableView::moveCursorStrikesBack_data() +{ + QTest::addColumn<int>("hideRow"); + QTest::addColumn<int>("hideColumn"); + QTest::addColumn<IntList>("disableRows"); + QTest::addColumn<IntList>("disableColumns"); + QTest::addColumn<QRect>("span"); + + QTest::addColumn<int>("startRow"); + QTest::addColumn<int>("startColumn"); + QTest::addColumn<IntList>("cursorMoveActions"); + QTest::addColumn<int>("expectedRow"); + QTest::addColumn<int>("expectedColumn"); + + QTest::newRow("Last column disabled. Task QTBUG-3878") << -1 << -1 + << IntList() + << (IntList() << 6) + << QRect() + << 0 << 5 << (IntList() << int(QtTestTableView::MoveNext)) + << 1 << 0; + + QTest::newRow("Span, anchor column hidden") << -1 << 1 + << IntList() + << IntList() + << QRect(1, 2, 2, 3) + << 2 << 0 << (IntList() << int(QtTestTableView::MoveNext)) + << 2 << 2; + + QTest::newRow("Span, anchor column disabled") << -1 << -1 + << IntList() + << (IntList() << 1) + << QRect(1, 2, 2, 3) + << 2 << 0 << (IntList() << int(QtTestTableView::MoveNext)) + << 2 << 2; + + QTest::newRow("Span, anchor row hidden") << 2 << -1 + << IntList() + << IntList() + << QRect(1, 2, 2, 3) + << 1 << 2 << (IntList() << int(QtTestTableView::MoveDown)) + << 3 << 2; + + QTest::newRow("Span, anchor row disabled") << -1 << -1 + << (IntList() << 2) + << IntList() + << QRect(1, 2, 2, 3) + << 1 << 2 << (IntList() << int(QtTestTableView::MoveDown)) + << 3 << 2; + + QTest::newRow("Move through span right") << -1 << -1 + << IntList() + << IntList() + << QRect(1, 2, 2, 3) + << 3 << 0 << (IntList() << int(QtTestTableView::MoveRight) << int(QtTestTableView::MoveRight)) + << 3 << 3; + + QTest::newRow("Move through span left") << -1 << -1 + << IntList() + << IntList() + << QRect(1, 2, 2, 3) + << 3 << 3 << (IntList() << int(QtTestTableView::MoveLeft) << int(QtTestTableView::MoveLeft)) + << 3 << 0; + + QTest::newRow("Move through span down") << -1 << -1 + << IntList() + << IntList() + << QRect(1, 2, 2, 3) + << 1 << 2 << (IntList() << int(QtTestTableView::MoveDown) << int(QtTestTableView::MoveDown)) + << 5 << 2; + + QTest::newRow("Move through span up") << -1 << -1 + << IntList() + << IntList() + << QRect(1, 2, 2, 3) + << 5 << 2 << (IntList() << int(QtTestTableView::MoveUp) << int(QtTestTableView::MoveUp)) + << 1 << 2; +} + +void tst_QTableView::moveCursorStrikesBack() +{ + QFETCH(int, hideRow); + QFETCH(int, hideColumn); + QFETCH(IntList, disableRows); + QFETCH(IntList, disableColumns); + QFETCH(QRect, span); + + QFETCH(int, startRow); + QFETCH(int, startColumn); + QFETCH(IntList, cursorMoveActions); + QFETCH(int, expectedRow); + QFETCH(int, expectedColumn); + + QtTestTableModel model(7, 7); + QtTestTableView view; + view.setModel(&model); + view.hideRow(hideRow); + view.hideColumn(hideColumn); + + foreach (int row, disableRows) + model.disableRow(row); + foreach (int column, disableColumns) + model.disableColumn(column); + + if (span.height() && span.width()) + view.setSpan(span.top(), span.left(), span.height(), span.width()); + view.show(); + + QModelIndex index = model.index(startRow, startColumn); + view.setCurrentIndex(index); + + int newRow = -1; + int newColumn = -1; + foreach (int cursorMoveAction, cursorMoveActions) { + QModelIndex newIndex = view.moveCursor((QtTestTableView::CursorAction)cursorMoveAction, 0); + view.setCurrentIndex(newIndex); + newRow = newIndex.row(); + newColumn = newIndex.column(); + } + + // expected fails, task 119433 + if(newRow == -1) + return; + QCOMPARE(newRow, expectedRow); + QCOMPARE(newColumn, expectedColumn); +} + void tst_QTableView::hideRows_data() { QTest::addColumn<int>("rowCount"); diff --git a/tests/auto/qwidgetaction/tst_qwidgetaction.cpp b/tests/auto/qwidgetaction/tst_qwidgetaction.cpp index 586a707..50b3337 100644 --- a/tests/auto/qwidgetaction/tst_qwidgetaction.cpp +++ b/tests/auto/qwidgetaction/tst_qwidgetaction.cpp @@ -125,6 +125,7 @@ void tst_QWidgetAction::defaultWidget() tb1.addAction(action); QVERIFY(combo->parent() == &tb1); qApp->processEvents(); + qApp->processEvents(); QVERIFY(combo->isVisible()); // not supported, not supposed to work, hence the parent() check @@ -139,6 +140,7 @@ void tst_QWidgetAction::defaultWidget() tb2.addAction(action); qApp->processEvents(); //the call to hide is delayd by the toolbar layout + qApp->processEvents(); QVERIFY(combo->parent() == &tb2); QVERIFY(combo->isVisible()); |