diff options
Diffstat (limited to 'tests/auto')
-rw-r--r-- | tests/auto/auto.pro | 7 | ||||
-rw-r--r-- | tests/auto/qabstractproxymodel/tst_qabstractproxymodel.cpp | 82 | ||||
-rw-r--r-- | tests/auto/qgraphicsscene/tst_qgraphicsscene.cpp | 36 | ||||
-rw-r--r-- | tests/auto/qgraphicsview/tst_qgraphicsview.cpp | 26 | ||||
-rw-r--r-- | tests/auto/qpropertyanimation/tst_qpropertyanimation.cpp | 29 | ||||
-rw-r--r-- | tests/auto/qscriptstring/tst_qscriptstring.cpp | 6 | ||||
-rw-r--r-- | tests/auto/qscriptvalue/qscriptvalue.pro | 7 | ||||
-rw-r--r-- | tests/auto/qsequentialanimationgroup/tst_qsequentialanimationgroup.cpp | 18 | ||||
-rw-r--r-- | tests/auto/qurl/tst_qurl.cpp | 4 |
9 files changed, 181 insertions, 34 deletions
diff --git a/tests/auto/auto.pro b/tests/auto/auto.pro index 5fd2dca..37d389c 100644 --- a/tests/auto/auto.pro +++ b/tests/auto/auto.pro @@ -608,10 +608,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 -########################################################### 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<int, QByteArray> _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<int, QByteArray> _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<int, QByteArray> &superSet, const QHash<int, QByteArray> &subSet) +{ + QHash<int, QByteArray>::const_iterator it = subSet.constBegin(); + const QHash<int, QByteArray>::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<int, QByteArray> rootModelRoleNames = model.roleNames(); + QHash<int, QByteArray> 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<int, QByteArray> 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<int, QByteArray> 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" diff --git a/tests/auto/qgraphicsscene/tst_qgraphicsscene.cpp b/tests/auto/qgraphicsscene/tst_qgraphicsscene.cpp index 2ef0419..d37ff76 100644 --- a/tests/auto/qgraphicsscene/tst_qgraphicsscene.cpp +++ b/tests/auto/qgraphicsscene/tst_qgraphicsscene.cpp @@ -245,6 +245,7 @@ private slots: #endif void render_data(); void render(); + void renderItemsWithNegativeWidthOrHeight(); void contextMenuEvent(); void contextMenuEvent_ItemIgnoresTransformations(); void update(); @@ -2751,6 +2752,41 @@ void tst_QGraphicsScene::render() } } +void tst_QGraphicsScene::renderItemsWithNegativeWidthOrHeight() +{ + QGraphicsScene scene(0, 0, 150, 150); + + // Add item with negative width. + QGraphicsRectItem *item1 = new QGraphicsRectItem(0, 0, -150, 50); + item1->setBrush(Qt::red); + item1->setPos(150, 50); + scene.addItem(item1); + + // Add item with negative height. + QGraphicsRectItem *item2 = new QGraphicsRectItem(0, 0, 50, -150); + item2->setBrush(Qt::blue); + item2->setPos(50, 150); + scene.addItem(item2); + + QGraphicsView view(&scene); + view.setFrameStyle(QFrame::NoFrame); + view.resize(150, 150); + view.show(); + QCOMPARE(view.viewport()->size(), QSize(150, 150)); + + QImage expected(view.viewport()->size(), QImage::Format_RGB32); + view.viewport()->render(&expected); + + // Make sure the scene background is the same as the viewport background. + scene.setBackgroundBrush(view.viewport()->palette().brush(view.viewport()->backgroundRole())); + QImage actual(150, 150, QImage::Format_RGB32); + QPainter painter(&actual); + scene.render(&painter); + painter.end(); + + QCOMPARE(actual, expected); +} + void tst_QGraphicsScene::contextMenuEvent() { QGraphicsScene scene; diff --git a/tests/auto/qgraphicsview/tst_qgraphicsview.cpp b/tests/auto/qgraphicsview/tst_qgraphicsview.cpp index 59bffeb..c77f76d 100644 --- a/tests/auto/qgraphicsview/tst_qgraphicsview.cpp +++ b/tests/auto/qgraphicsview/tst_qgraphicsview.cpp @@ -218,6 +218,7 @@ private slots: void update(); void inputMethodSensitivity(); void inputContextReset(); + void indirectPainting(); // task specific tests below me void task172231_untransformableItems(); @@ -3799,6 +3800,31 @@ void tst_QGraphicsView::inputContextReset() QCOMPARE(inputContext.resets, 0); } +void tst_QGraphicsView::indirectPainting() +{ + class MyScene : public QGraphicsScene + { public: + MyScene() : QGraphicsScene(), drawCount(0) {} + void drawItems(QPainter *, int, QGraphicsItem **, const QStyleOptionGraphicsItem *, QWidget *) + { ++drawCount; } + int drawCount; + }; + + MyScene scene; + QGraphicsItem *item = scene.addRect(0, 0, 50, 50); + + QGraphicsView view(&scene); + view.setOptimizationFlag(QGraphicsView::IndirectPainting); + view.show(); + QTest::qWaitForWindowShown(&view); + QTest::qWait(100); + + scene.drawCount = 0; + item->setPos(20, 20); + QApplication::processEvents(); + QTRY_VERIFY(scene.drawCount > 0); +} + void tst_QGraphicsView::task253415_reconnectUpdateSceneOnSceneChanged() { QGraphicsView view; diff --git a/tests/auto/qpropertyanimation/tst_qpropertyanimation.cpp b/tests/auto/qpropertyanimation/tst_qpropertyanimation.cpp index 66cfeb7..849b8b2 100644 --- a/tests/auto/qpropertyanimation/tst_qpropertyanimation.cpp +++ b/tests/auto/qpropertyanimation/tst_qpropertyanimation.cpp @@ -40,6 +40,7 @@ ****************************************************************************/ #include <QtTest/QtTest> +#include "../../shared/util.h" #include <QtCore/qpropertyanimation.h> #include <QtCore/qvariantanimation.h> @@ -288,7 +289,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); @@ -340,7 +341,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); @@ -351,9 +352,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; } @@ -459,7 +460,7 @@ void tst_QPropertyAnimation::noStartValue() QTest::qWait(300); - QCOMPARE(o.values.first(), 42); + QTRY_COMPARE(o.values.first(), 42); QCOMPARE(o.values.last(), 420); } @@ -497,7 +498,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); } @@ -518,7 +519,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); } @@ -591,7 +592,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); @@ -631,7 +632,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); @@ -661,7 +662,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 @@ -669,7 +670,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 @@ -678,7 +679,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); } @@ -1146,7 +1147,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); @@ -1197,7 +1198,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/qscriptstring/tst_qscriptstring.cpp b/tests/auto/qscriptstring/tst_qscriptstring.cpp index 808b643..ea4a92b 100644 --- a/tests/auto/qscriptstring/tst_qscriptstring.cpp +++ b/tests/auto/qscriptstring/tst_qscriptstring.cpp @@ -177,6 +177,12 @@ void tst_QScriptString::toArrayIndex_data() QTest::newRow("101a") << QString::fromLatin1("101a") << false << quint32(0xffffffff); QTest::newRow("4294967294") << QString::fromLatin1("4294967294") << true << quint32(0xfffffffe); QTest::newRow("4294967295") << QString::fromLatin1("4294967295") << false << quint32(0xffffffff); + QTest::newRow("0.0") << QString::fromLatin1("0.0") << false << quint32(0xffffffff); + QTest::newRow("1.0") << QString::fromLatin1("1.0") << false << quint32(0xffffffff); + QTest::newRow("1.5") << QString::fromLatin1("1.5") << false << quint32(0xffffffff); + QTest::newRow("1.") << QString::fromLatin1("1.") << false << quint32(0xffffffff); + QTest::newRow(".1") << QString::fromLatin1(".1") << false << quint32(0xffffffff); + QTest::newRow("1e0") << QString::fromLatin1("1e0") << false << quint32(0xffffffff); } void tst_QScriptString::toArrayIndex() diff --git a/tests/auto/qscriptvalue/qscriptvalue.pro b/tests/auto/qscriptvalue/qscriptvalue.pro index 1588cc5..191cd4a 100644 --- a/tests/auto/qscriptvalue/qscriptvalue.pro +++ b/tests/auto/qscriptvalue/qscriptvalue.pro @@ -5,3 +5,10 @@ HEADERS += tst_qscriptvalue.h # Generated by testgen SOURCES += tst_qscriptvalue_generated.cpp + + +win32-msvc* { + # With -O2, MSVC takes up to 24 minutes to compile this test! + QMAKE_CXXFLAGS_RELEASE -= -O1 -O2 + QMAKE_CXXFLAGS_RELEASE += -Od +} 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<QAbstractAnimation*>(&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(); diff --git a/tests/auto/qurl/tst_qurl.cpp b/tests/auto/qurl/tst_qurl.cpp index 72ce393..83109b5 100644 --- a/tests/auto/qurl/tst_qurl.cpp +++ b/tests/auto/qurl/tst_qurl.cpp @@ -2513,13 +2513,9 @@ void tst_QUrl::schemeValidator() void tst_QUrl::invalidSchemeValidator() { - // enable that test when QUrl is fixed - return; - // test that if scheme does not start with an ALPHA, QUrl::isValid() returns false { QUrl url("1http://qt.nokia.com", QUrl::StrictMode); - qDebug() << url; QCOMPARE(url.isValid(), false); } { |