summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorQt Continuous Integration System <qt-info@nokia.com>2010-08-24 15:15:18 (GMT)
committerQt Continuous Integration System <qt-info@nokia.com>2010-08-24 15:15:18 (GMT)
commit11c844de157bab85caec3ec0afe01b3f81f53bf0 (patch)
treec1ab853f576b9f765376167a2797fdacc919b951 /tests
parent1e55b0ecf415d023bbb5f291a2f26ba50c1a508b (diff)
parentf3771c5d91995b2beaa73bd3e3c783b76a887b50 (diff)
downloadQt-11c844de157bab85caec3ec0afe01b3f81f53bf0.zip
Qt-11c844de157bab85caec3ec0afe01b3f81f53bf0.tar.gz
Qt-11c844de157bab85caec3ec0afe01b3f81f53bf0.tar.bz2
Merge branch '4.7' of scm.dev.nokia.troll.no:qt/oslo-staging-2 into 4.7-integration
* '4.7' of scm.dev.nokia.troll.no:qt/oslo-staging-2: Fix mispositioned text with QStaticText and OpenVG graphics system Use binarysort to find items. QGraphicsView: Fix assert that may occurs if there are 'empty' item to draw, and changed() signal connected Fix tst_Collections::QTBUG13079_collectionInsideCollection Fix assignment of a Q(Explicitly)SharedDataPointer included in the data itself Fix assignment of a container included in the container itself
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/collections/tst_collections.cpp129
-rw-r--r--tests/auto/qgraphicsscene/tst_qgraphicsscene.cpp26
2 files changed, 155 insertions, 0 deletions
diff --git a/tests/auto/collections/tst_collections.cpp b/tests/auto/collections/tst_collections.cpp
index d092c34..f81535e 100644
--- a/tests/auto/collections/tst_collections.cpp
+++ b/tests/auto/collections/tst_collections.cpp
@@ -165,6 +165,7 @@ private slots:
void containerTypedefs();
void forwardDeclared();
void alignment();
+ void QTBUG13079_collectionInsideCollection();
};
struct LargeStatic {
@@ -3589,5 +3590,133 @@ void tst_Collections::alignment()
}
#endif
+#ifndef QT_NO_TEMPLATE_TEMPLATE_PARAMETERS
+
+template<template<class> class C>
+struct QTBUG13079_Node {
+ C<QTBUG13079_Node> children;
+ QString s;
+
+ ~QTBUG13079_Node() {
+ children.begin(); //play with memory
+ }
+};
+template<template<class> class C> void QTBUG13079_collectionInsideCollectionImpl()
+{
+ C<QTBUG13079_Node<C> > nodeList;
+ nodeList << QTBUG13079_Node<C>();
+ nodeList.first().s = "parent";
+ nodeList.first().children << QTBUG13079_Node<C>();
+ nodeList.first().children.first().s = "child";
+
+ nodeList = nodeList.first().children;
+ QCOMPARE(nodeList.first().s, QString::fromLatin1("child"));
+
+ nodeList = nodeList.first().children;
+ QCOMPARE(nodeList.count(), 0);
+ nodeList << QTBUG13079_Node<C>();
+}
+
+template<template<class, class> class C>
+struct QTBUG13079_NodeAssoc {
+ C<int, QTBUG13079_NodeAssoc> children;
+ QString s;
+
+ ~QTBUG13079_NodeAssoc() {
+ children.begin(); //play with memory
+ }
+};
+template<template<class, class> class C> void QTBUG13079_collectionInsideCollectionAssocImpl()
+{
+ C<int, QTBUG13079_NodeAssoc<C> > nodeMap;
+ nodeMap[18] = QTBUG13079_NodeAssoc<C>();
+ nodeMap[18].s = "parent";
+ nodeMap[18].children[12] = QTBUG13079_NodeAssoc<C>();
+ nodeMap[18].children[12].s = "child";
+
+ nodeMap = nodeMap[18].children;
+ QCOMPARE(nodeMap[12].s, QString::fromLatin1("child"));
+
+ nodeMap = nodeMap[12].children;
+ QCOMPARE(nodeMap.count(), 0);
+ nodeMap[42] = QTBUG13079_NodeAssoc<C>();
+}
+
+
+static quint32 qHash(const QTBUG13079_Node<QSet> &)
+{
+ return 0;
+}
+
+bool operator==(const QTBUG13079_Node<QSet> &a, const QTBUG13079_Node<QSet> &b)
+{
+ return a.s == b.s && a.children == b.children;
+}
+
+template<template<class> class C>
+struct QTBUG13079_NodePtr : QSharedData {
+ C<QTBUG13079_NodePtr> child;
+ QTBUG13079_NodePtr *next;
+ QString s;
+
+ QTBUG13079_NodePtr() : next(0) {}
+ ~QTBUG13079_NodePtr() {
+ next = child.data(); //play with memory
+ }
+};
+template<template<class> class C> void QTBUG13079_collectionInsidePtrImpl()
+{
+ typedef C<QTBUG13079_NodePtr<C> > Ptr;
+ {
+ Ptr nodePtr;
+ nodePtr = Ptr(new QTBUG13079_NodePtr<C>());
+ nodePtr->s = "parent";
+ nodePtr->child = Ptr(new QTBUG13079_NodePtr<C>());
+ nodePtr->child->s = "child";
+ nodePtr = nodePtr->child;
+ QCOMPARE(nodePtr->s, QString::fromLatin1("child"));
+ nodePtr = nodePtr->child;
+ QVERIFY(!nodePtr);
+ }
+ {
+ Ptr nodePtr;
+ nodePtr = Ptr(new QTBUG13079_NodePtr<C>());
+ nodePtr->s = "parent";
+ nodePtr->next = new QTBUG13079_NodePtr<C>();
+ nodePtr->next->s = "next";
+ nodePtr = Ptr(nodePtr->next);
+ QCOMPARE(nodePtr->s, QString::fromLatin1("next"));
+ nodePtr = Ptr(nodePtr->next);
+ QVERIFY(!nodePtr);
+ }
+}
+
+#endif
+
+void tst_Collections::QTBUG13079_collectionInsideCollection()
+{
+#ifndef QT_NO_TEMPLATE_TEMPLATE_PARAMETERS
+ QTBUG13079_collectionInsideCollectionImpl<QVector>();
+ QTBUG13079_collectionInsideCollectionImpl<QStack>();
+ QTBUG13079_collectionInsideCollectionImpl<QList>();
+ QTBUG13079_collectionInsideCollectionImpl<QLinkedList>();
+ QTBUG13079_collectionInsideCollectionImpl<QQueue>();
+
+ {
+ QSet<QTBUG13079_Node<QSet> > nodeSet;
+ nodeSet << QTBUG13079_Node<QSet>();
+ nodeSet = nodeSet.begin()->children;
+ QCOMPARE(nodeSet.count(), 0);
+ }
+
+ QTBUG13079_collectionInsideCollectionAssocImpl<QMap>();
+ QTBUG13079_collectionInsideCollectionAssocImpl<QHash>();
+
+ QTBUG13079_collectionInsidePtrImpl<QSharedPointer>();
+ QTBUG13079_collectionInsidePtrImpl<QExplicitlySharedDataPointer>();
+ QTBUG13079_collectionInsidePtrImpl<QSharedDataPointer>();
+#endif
+}
+
QTEST_APPLESS_MAIN(tst_Collections)
#include "tst_collections.moc"
diff --git a/tests/auto/qgraphicsscene/tst_qgraphicsscene.cpp b/tests/auto/qgraphicsscene/tst_qgraphicsscene.cpp
index 903977c..7ee2a48 100644
--- a/tests/auto/qgraphicsscene/tst_qgraphicsscene.cpp
+++ b/tests/auto/qgraphicsscene/tst_qgraphicsscene.cpp
@@ -276,6 +276,7 @@ private slots:
void isActive();
void siblingIndexAlwaysValid();
void removeFullyTransparentItem();
+ void zeroScale();
// task specific tests below me
void task139710_bspTreeCrash();
@@ -4564,5 +4565,30 @@ void tst_QGraphicsScene::taskQTBUG_7863_paintIntoCacheWithTransparentParts()
}
}
+void tst_QGraphicsScene::zeroScale()
+{
+ //should not crash
+ QGraphicsScene scene;
+ scene.setSceneRect(-100, -100, 100, 100);
+ QGraphicsView view(&scene);
+
+ ChangedListener cl;
+ connect(&scene, SIGNAL(changed(const QList<QRectF> &)), &cl, SLOT(changed(const QList<QRectF> &)));
+
+ QGraphicsRectItem *rect1 = new QGraphicsRectItem(0, 0, 0.0000001, 0.00000001);
+ scene.addItem(rect1);
+ rect1->setRotation(82);
+ rect1->setScale(0.00000001);
+
+ QApplication::processEvents();
+ QCOMPARE(cl.changes.count(), 1);
+ QGraphicsRectItem *rect2 = new QGraphicsRectItem(-0.0000001, -0.0000001, 0.0000001, 0.0000001);
+ rect2->setScale(0.00000001);
+ scene.addItem(rect2);
+ rect1->setPos(20,20);
+ QApplication::processEvents();
+ QCOMPARE(cl.changes.count(), 2);
+}
+
QTEST_MAIN(tst_QGraphicsScene)
#include "tst_qgraphicsscene.moc"