From b063347228548eed177216e37801e800bda7e5b0 Mon Sep 17 00:00:00 2001 From: Rohan McGovern Date: Thu, 25 Feb 2010 16:19:56 +1000 Subject: Define a GNU-style `check' target for all projects. Reviewed-by: Marius Storm-Olsen --- mkspecs/features/default_post.prf | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/mkspecs/features/default_post.prf b/mkspecs/features/default_post.prf index 01074f4..155bfc3 100644 --- a/mkspecs/features/default_post.prf +++ b/mkspecs/features/default_post.prf @@ -8,3 +8,14 @@ incredibuild_xge { QMAKE_INCDIR += $$QMAKE_INCDIR_POST QMAKE_LIBDIR += $$QMAKE_LIBDIR_POST + +# Let every project have a standard GNU `check' target +!contains(QMAKE_EXTRA_TARGETS, check) { + # `make check' should iterate through all subdirs + contains(TEMPLATE, subdirs) { + check.CONFIG = recursive + check.recurse = $$SUBDIRS + check.recurse_target = check + } + QMAKE_EXTRA_TARGETS += check +} -- cgit v0.12 From 2d2e8a18e59adde641373f1801652eacbd02387a Mon Sep 17 00:00:00 2001 From: Rohan McGovern Date: Thu, 25 Feb 2010 17:00:24 +1000 Subject: Remove `make check' logic from auto.pro. The `check' target is now automatically recursive on all subdirs projects. --- tests/auto/auto.pro | 7 ------- 1 file changed, 7 deletions(-) diff --git a/tests/auto/auto.pro b/tests/auto/auto.pro index 3d25656..f3885a7 100644 --- a/tests/auto/auto.pro +++ b/tests/auto/auto.pro @@ -590,10 +590,3 @@ contains(QT_CONFIG, declarative): SUBDIRS += declarative xmlpatternsxqts \ xmlpatternsxslts - -############### make check recursively for testcases ################## -check.CONFIG = recursive -check.recurse = $$SUBDIRS -check.recurse_target = check -QMAKE_EXTRA_TARGETS += check -########################################################### -- cgit v0.12 From bb61a01001899e23ae12d2edd91a86807dba848a Mon Sep 17 00:00:00 2001 From: Thierry Bastian Date: Thu, 25 Feb 2010 11:21:59 +0100 Subject: Trying to make the animation autotests more robust Everywhere we have a qWait(duration) followed by a QCOMPARE, there was the risk that it fails because of the test machine being overloaded. So I changed them to QTRY_COMPARE. --- .../qpropertyanimation/tst_qpropertyanimation.cpp | 31 +++++++++++----------- .../tst_qsequentialanimationgroup.cpp | 18 ++++++------- 2 files changed, 25 insertions(+), 24 deletions(-) diff --git a/tests/auto/qpropertyanimation/tst_qpropertyanimation.cpp b/tests/auto/qpropertyanimation/tst_qpropertyanimation.cpp index d020d8f..0c444fc 100644 --- a/tests/auto/qpropertyanimation/tst_qpropertyanimation.cpp +++ b/tests/auto/qpropertyanimation/tst_qpropertyanimation.cpp @@ -40,6 +40,7 @@ ****************************************************************************/ #include +#include "../../shared/util.h" #include #include @@ -287,7 +288,7 @@ void tst_QPropertyAnimation::statesAndSignals() anim->start(); QTest::qWait(1000); - QCOMPARE(anim->state(), QAnimationGroup::Stopped); + QTRY_COMPARE(anim->state(), QAnimationGroup::Stopped); QCOMPARE(runningSpy.count(), 2); //started and stopped again runningSpy.clear(); QCOMPARE(finishedSpy.count(), 1); @@ -339,7 +340,7 @@ void tst_QPropertyAnimation::deletion1() QCOMPARE(anim->state(), QAnimationGroup::Running); QTest::qWait(150); QVERIFY(anim); //The animation should not have been deleted - QCOMPARE(anim->state(), QAnimationGroup::Stopped); + QTRY_COMPARE(anim->state(), QAnimationGroup::Stopped); QCOMPARE(runningSpy.count(), 2); QCOMPARE(finishedSpy.count(), 1); @@ -350,9 +351,9 @@ void tst_QPropertyAnimation::deletion1() QVERIFY(anim); QCOMPARE(anim->state(), QAnimationGroup::Running); QTest::qWait(150); - QVERIFY(!anim); //The animation must have been deleted - QCOMPARE(runningSpy.count(), 4); + QTRY_COMPARE(runningSpy.count(), 4); QCOMPARE(finishedSpy.count(), 2); + QVERIFY(!anim); //The animation must have been deleted delete object; } @@ -458,7 +459,7 @@ void tst_QPropertyAnimation::noStartValue() QTest::qWait(300); - QCOMPARE(o.values.first(), 42); + QTRY_COMPARE(o.values.first(), 42); QCOMPARE(o.values.last(), 420); } @@ -496,7 +497,7 @@ void tst_QPropertyAnimation::startWhenAnotherIsRunning() QSignalSpy runningSpy(anim, SIGNAL(stateChanged(QAbstractAnimation::State, QAbstractAnimation::State))); anim->start(QVariantAnimation::DeleteWhenStopped); QTest::qWait(anim->duration() + 100); - QCOMPARE(runningSpy.count(), 2); //started and then stopped + QTRY_COMPARE(runningSpy.count(), 2); //started and then stopped QVERIFY(!anim); } @@ -517,7 +518,7 @@ void tst_QPropertyAnimation::startWhenAnotherIsRunning() QVERIFY(!anim); //anim should have been deleted QVERIFY(anim2); QTest::qWait(anim2->duration()); - QVERIFY(!anim2); //anim2 is finished: it should have been deleted by now + QTRY_VERIFY(!anim2); //anim2 is finished: it should have been deleted by now QVERIFY(!anim); } @@ -590,7 +591,7 @@ void tst_QPropertyAnimation::startWithoutStartValue() QVERIFY(current < 100); QTest::qWait(200); - QCOMPARE(anim.state(), QVariantAnimation::Stopped); + QTRY_COMPARE(anim.state(), QVariantAnimation::Stopped); current = anim.currentValue().toInt(); QCOMPARE(current, 100); QCOMPARE(o.property("ole").toInt(), current); @@ -630,7 +631,7 @@ void tst_QPropertyAnimation::startBackwardWithoutEndValue() QVERIFY(current < 100); QTest::qWait(200); - QCOMPARE(anim.state(), QVariantAnimation::Stopped); + QTRY_COMPARE(anim.state(), QVariantAnimation::Stopped); current = anim.currentValue().toInt(); QCOMPARE(current, 100); QCOMPARE(o.property("ole").toInt(), current); @@ -660,7 +661,7 @@ void tst_QPropertyAnimation::playForwardBackward() anim.setEndValue(100); anim.start(); QTest::qWait(anim.duration() + 100); - QCOMPARE(anim.state(), QAbstractAnimation::Stopped); + QTRY_COMPARE(anim.state(), QAbstractAnimation::Stopped); QCOMPARE(anim.currentTime(), anim.duration()); //the animation is at the end @@ -668,7 +669,7 @@ void tst_QPropertyAnimation::playForwardBackward() anim.start(); QCOMPARE(anim.state(), QAbstractAnimation::Running); QTest::qWait(anim.duration() + 100); - QCOMPARE(anim.state(), QAbstractAnimation::Stopped); + QTRY_COMPARE(anim.state(), QAbstractAnimation::Stopped); QCOMPARE(anim.currentTime(), 0); //the direction is backward @@ -677,7 +678,7 @@ void tst_QPropertyAnimation::playForwardBackward() QCOMPARE(anim.state(), QAbstractAnimation::Running); QCOMPARE(anim.currentTime(), anim.duration()); QTest::qWait(anim.duration() + 100); - QCOMPARE(anim.state(), QAbstractAnimation::Stopped); + QTRY_COMPARE(anim.state(), QAbstractAnimation::Stopped); QCOMPARE(anim.currentTime(), 0); } @@ -1095,7 +1096,7 @@ void tst_QPropertyAnimation::valueChanged() QTest::qWait(anim.duration() + 100); - QCOMPARE(anim.state(), QAbstractAnimation::Stopped); + QTRY_COMPARE(anim.state(), QAbstractAnimation::Stopped); QCOMPARE(anim.currentTime(), anim.duration()); //let's check that the values go forward @@ -1145,7 +1146,7 @@ void tst_QPropertyAnimation::twoAnimations() o2.anim.start(); QTest::qWait(o1.anim.duration() + 100); - QCOMPARE(o1.anim.state(), QAbstractAnimation::Stopped); + QTRY_COMPARE(o1.anim.state(), QAbstractAnimation::Stopped); QCOMPARE(o2.anim.state(), QAbstractAnimation::Stopped); QCOMPARE(o1.ole(), 1000); @@ -1196,7 +1197,7 @@ void tst_QPropertyAnimation::deletedInUpdateCurrentTime() QCOMPARE(composedAnimation.state(), QAbstractAnimation::Running); QTest::qWait(composedAnimation.duration() + 100); - QCOMPARE(composedAnimation.state(), QAbstractAnimation::Stopped); + QTRY_COMPARE(composedAnimation.state(), QAbstractAnimation::Stopped); QCOMPARE(o.value(), 1000); } diff --git a/tests/auto/qsequentialanimationgroup/tst_qsequentialanimationgroup.cpp b/tests/auto/qsequentialanimationgroup/tst_qsequentialanimationgroup.cpp index 68daf1a..e154528 100644 --- a/tests/auto/qsequentialanimationgroup/tst_qsequentialanimationgroup.cpp +++ b/tests/auto/qsequentialanimationgroup/tst_qsequentialanimationgroup.cpp @@ -934,8 +934,8 @@ void tst_QSequentialAnimationGroup::startDelay() QTest::qWait(500); + QTRY_COMPARE(group.state(), QAnimationGroup::Stopped); QVERIFY(group.currentLoopTime() == 375); - QCOMPARE(group.state(), QAnimationGroup::Stopped); } void tst_QSequentialAnimationGroup::clearGroup() @@ -1029,7 +1029,7 @@ void tst_QSequentialAnimationGroup::groupWithZeroDurationAnimations() QTest::qWait(500); - QCOMPARE(o.property("myProperty").toInt(), 44); + QTRY_COMPARE(o.property("myProperty").toInt(), 44); QCOMPARE(o2.property("myProperty").toInt(), 42); QCOMPARE(o2.property("myOtherProperty").toInt(), 31); QCOMPARE(a1->state(), QAnimationGroup::Stopped); @@ -1171,7 +1171,7 @@ void tst_QSequentialAnimationGroup::deleteChildrenWithRunningGroup() QCOMPARE(anim1->state(), QAnimationGroup::Running); QTest::qWait(100); - QVERIFY(group.currentLoopTime() > 0); + QTRY_VERIFY(group.currentLoopTime() > 0); delete anim1; QCOMPARE(group.animationCount(), 0); @@ -1430,7 +1430,7 @@ void tst_QSequentialAnimationGroup::finishWithUncontrolledAnimation() QCOMPARE(notTimeDriven.currentLoopTime(), 0); QTest::qWait(300); //wait for the end of notTimeDriven - QCOMPARE(notTimeDriven.state(), QAnimationGroup::Stopped); + QTRY_COMPARE(notTimeDriven.state(), QAnimationGroup::Stopped); const int actualDuration = notTimeDriven.currentLoopTime(); QCOMPARE(group.state(), QAnimationGroup::Stopped); QCOMPARE(group.currentLoopTime(), actualDuration); @@ -1459,14 +1459,14 @@ void tst_QSequentialAnimationGroup::finishWithUncontrolledAnimation() QCOMPARE(animStateChangedSpy.count(), 0); QTest::qWait(300); //wait for the end of notTimeDriven - QCOMPARE(notTimeDriven.state(), QAnimationGroup::Stopped); + QTRY_COMPARE(notTimeDriven.state(), QAnimationGroup::Stopped); QCOMPARE(group.state(), QAnimationGroup::Running); QCOMPARE(anim.state(), QAnimationGroup::Running); QCOMPARE(group.currentAnimation(), static_cast(&anim)); QCOMPARE(animStateChangedSpy.count(), 1); QTest::qWait(300); //wait for the end of anim - QCOMPARE(anim.state(), QAnimationGroup::Stopped); + QTRY_COMPARE(anim.state(), QAnimationGroup::Stopped); QCOMPARE(anim.currentLoopTime(), anim.duration()); //we should simply be at the end @@ -1621,7 +1621,7 @@ void tst_QSequentialAnimationGroup::clear() group.start(); QTest::qWait(anim1->duration() + 100); - QCOMPARE(group.animationCount(), 0); + QTRY_COMPARE(group.animationCount(), 0); QCOMPARE(group.state(), QAbstractAnimation::Stopped); QCOMPARE(group.currentLoopTime(), 0); @@ -1629,8 +1629,8 @@ void tst_QSequentialAnimationGroup::clear() group.connect(anim1, SIGNAL(finished()), SLOT(refill())); group.start(); QTest::qWait(anim1->duration() + 100); + QTRY_COMPARE(group.state(), QAbstractAnimation::Running); QVERIFY(anim1 == 0); //anim1 should have been deleted - QCOMPARE(group.state(), QAbstractAnimation::Running); } void tst_QSequentialAnimationGroup::pauseResume() @@ -1645,7 +1645,7 @@ void tst_QSequentialAnimationGroup::pauseResume() QCOMPARE(group.duration(), 250); group.start(); QTest::qWait(100); - QCOMPARE(group.state(), QAnimationGroup::Running); + QTRY_COMPARE(group.state(), QAnimationGroup::Running); QCOMPARE(anim->state(), QAnimationGroup::Running); QCOMPARE(spy.count(), 1); spy.clear(); -- cgit v0.12 From 72f3752b5b517c14e64c4e15d354ddf32e386c20 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Thu, 25 Feb 2010 11:22:18 +0100 Subject: Set the roleNames of proxy models to the roleNames of the source model. This simplifies the use of model view with qml and proxies. Merge-request: 2315 Reviewed-by: Olivier Goffart --- src/gui/itemviews/qabstractproxymodel.cpp | 1 + .../tst_qabstractproxymodel.cpp | 82 ++++++++++++++++++++++ 2 files changed, 83 insertions(+) diff --git a/src/gui/itemviews/qabstractproxymodel.cpp b/src/gui/itemviews/qabstractproxymodel.cpp index 40345a7..43a1327 100644 --- a/src/gui/itemviews/qabstractproxymodel.cpp +++ b/src/gui/itemviews/qabstractproxymodel.cpp @@ -127,6 +127,7 @@ void QAbstractProxyModel::setSourceModel(QAbstractItemModel *sourceModel) } else { d->model = QAbstractItemModelPrivate::staticEmptyModel(); } + d->roleNames = d->model->roleNames(); } /*! diff --git a/tests/auto/qabstractproxymodel/tst_qabstractproxymodel.cpp b/tests/auto/qabstractproxymodel/tst_qabstractproxymodel.cpp index 6d92d03..88c2ef1 100644 --- a/tests/auto/qabstractproxymodel/tst_qabstractproxymodel.cpp +++ b/tests/auto/qabstractproxymodel/tst_qabstractproxymodel.cpp @@ -80,6 +80,7 @@ private slots: void setSourceModel(); void submit_data(); void submit(); + void testRoleNames(); }; // Subclass that exposes the protected functions. @@ -362,6 +363,87 @@ void tst_QAbstractProxyModel::submit() QCOMPARE(model.submit(), submit); } +class StandardItemModelWithCustomRoleNames : public QStandardItemModel +{ +public: + enum CustomRole { + CustomRole1 = Qt::UserRole, + CustomRole2 + }; + + StandardItemModelWithCustomRoleNames() { + QHash _roleNames = roleNames(); + _roleNames.insert(CustomRole1, "custom1"); + _roleNames.insert(CustomRole2, "custom2"); + setRoleNames(_roleNames); + } +}; + +class AnotherStandardItemModelWithCustomRoleNames : public QStandardItemModel +{ + public: + enum CustomRole { + AnotherCustomRole1 = Qt::UserRole + 10, // Different to StandardItemModelWithCustomRoleNames::CustomRole1 + AnotherCustomRole2 + }; + + AnotherStandardItemModelWithCustomRoleNames() { + QHash _roleNames = roleNames(); + _roleNames.insert(AnotherCustomRole1, "another_custom1"); + _roleNames.insert(AnotherCustomRole2, "another_custom2"); + setRoleNames(_roleNames); + } +}; + +/** + Verifies that @p subSet is a subset of @p superSet. That is, all keys in @p subSet exist in @p superSet and have the same values. +*/ +static void verifySubSetOf(const QHash &superSet, const QHash &subSet) +{ + QHash::const_iterator it = subSet.constBegin(); + const QHash::const_iterator end = subSet.constEnd(); + for ( ; it != end; ++it ) { + QVERIFY(superSet.contains(it.key())); + QVERIFY(it.value() == superSet.value(it.key())); + } +} + +void tst_QAbstractProxyModel::testRoleNames() +{ + QStandardItemModel defaultModel; + StandardItemModelWithCustomRoleNames model; + QHash rootModelRoleNames = model.roleNames(); + QHash defaultModelRoleNames = defaultModel.roleNames(); + + verifySubSetOf( rootModelRoleNames, defaultModelRoleNames); + QVERIFY( rootModelRoleNames.size() == defaultModelRoleNames.size() + 2 ); + QVERIFY( rootModelRoleNames.contains(StandardItemModelWithCustomRoleNames::CustomRole1)); + QVERIFY( rootModelRoleNames.contains(StandardItemModelWithCustomRoleNames::CustomRole2)); + QVERIFY( rootModelRoleNames.value(StandardItemModelWithCustomRoleNames::CustomRole1) == "custom1" ); + QVERIFY( rootModelRoleNames.value(StandardItemModelWithCustomRoleNames::CustomRole2) == "custom2" ); + + SubQAbstractProxyModel proxy1; + proxy1.setSourceModel(&model); + QHash proxy1RoleNames = proxy1.roleNames(); + verifySubSetOf( proxy1RoleNames, defaultModelRoleNames ); + QVERIFY( proxy1RoleNames.size() == defaultModelRoleNames.size() + 2 ); + QVERIFY( proxy1RoleNames.contains(StandardItemModelWithCustomRoleNames::CustomRole1)); + QVERIFY( proxy1RoleNames.contains(StandardItemModelWithCustomRoleNames::CustomRole2)); + QVERIFY( proxy1RoleNames.value(StandardItemModelWithCustomRoleNames::CustomRole1) == "custom1" ); + QVERIFY( proxy1RoleNames.value(StandardItemModelWithCustomRoleNames::CustomRole2) == "custom2" ); + + SubQAbstractProxyModel proxy2; + proxy2.setSourceModel(&proxy1); + QHash proxy2RoleNames = proxy2.roleNames(); + verifySubSetOf( proxy2RoleNames, defaultModelRoleNames ); + QVERIFY( proxy2RoleNames.size() == defaultModelRoleNames.size() + 2 ); + QVERIFY( proxy2RoleNames.contains(StandardItemModelWithCustomRoleNames::CustomRole1)); + QVERIFY( proxy2RoleNames.contains(StandardItemModelWithCustomRoleNames::CustomRole2)); + QVERIFY( proxy2RoleNames.value(StandardItemModelWithCustomRoleNames::CustomRole1) == "custom1" ); + QVERIFY( proxy2RoleNames.value(StandardItemModelWithCustomRoleNames::CustomRole2) == "custom2" ); + +} + QTEST_MAIN(tst_QAbstractProxyModel) #include "tst_qabstractproxymodel.moc" -- cgit v0.12