summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorWarwick Allison <warwick.allison@nokia.com>2010-03-23 23:11:53 (GMT)
committerWarwick Allison <warwick.allison@nokia.com>2010-03-23 23:11:53 (GMT)
commit838e4cc024f4589322d5279acd96e3ca4d00e1f5 (patch)
tree8a5d4e50ac67e07d6116a504b39de8768ed5540e /tests
parent6801a97671f64ef30ab312b38d16abc964ad6ac5 (diff)
parente3999a4f91194b7508dbd1d3e6f595f729022ed7 (diff)
downloadQt-838e4cc024f4589322d5279acd96e3ca4d00e1f5.zip
Qt-838e4cc024f4589322d5279acd96e3ca4d00e1f5.tar.gz
Qt-838e4cc024f4589322d5279acd96e3ca4d00e1f5.tar.bz2
Merge branch '4.7' of scm.dev.nokia.troll.no:qt/qt into 4.7
Conflicts: tests/auto/declarative/qdeclarativedom/data/importlib/sublib/qmldir
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp12
-rw-r--r--tests/auto/qitemselectionmodel/tst_qitemselectionmodel.cpp27
-rw-r--r--tests/auto/qobject/tst_qobject.cpp78
3 files changed, 97 insertions, 20 deletions
diff --git a/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp b/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp
index c0ad8bf..92a7f2e 100644
--- a/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp
+++ b/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp
@@ -7719,7 +7719,7 @@ void tst_QGraphicsItem::hitTestGraphicsEffectItem()
QTest::qWait(50);
// Make sure all visible items are repainted.
- QCOMPARE(item1->repaints, 0);
+ QCOMPARE(item1->repaints, 1);
QCOMPARE(item2->repaints, 1);
QCOMPARE(item3->repaints, 1);
@@ -9819,6 +9819,16 @@ void tst_QGraphicsItem::scenePosChange()
QCOMPARE(child1->changes.count(QGraphicsItem::ItemScenePositionHasChanged), 4);
QCOMPARE(grandChild1->changes.count(QGraphicsItem::ItemScenePositionHasChanged), 1);
QCOMPARE(child2->changes.count(QGraphicsItem::ItemScenePositionHasChanged), 0);
+
+ root->setX(1);
+ QCOMPARE(child1->changes.count(QGraphicsItem::ItemScenePositionHasChanged), 5);
+ QCOMPARE(grandChild1->changes.count(QGraphicsItem::ItemScenePositionHasChanged), 1);
+ QCOMPARE(child2->changes.count(QGraphicsItem::ItemScenePositionHasChanged), 0);
+
+ root->setY(1);
+ QCOMPARE(child1->changes.count(QGraphicsItem::ItemScenePositionHasChanged), 6);
+ QCOMPARE(grandChild1->changes.count(QGraphicsItem::ItemScenePositionHasChanged), 1);
+ QCOMPARE(child2->changes.count(QGraphicsItem::ItemScenePositionHasChanged), 0);
}
void tst_QGraphicsItem::QTBUG_5418_textItemSetDefaultColor()
diff --git a/tests/auto/qitemselectionmodel/tst_qitemselectionmodel.cpp b/tests/auto/qitemselectionmodel/tst_qitemselectionmodel.cpp
index 6ef4305..3b2a716 100644
--- a/tests/auto/qitemselectionmodel/tst_qitemselectionmodel.cpp
+++ b/tests/auto/qitemselectionmodel/tst_qitemselectionmodel.cpp
@@ -93,6 +93,7 @@ private slots:
void task232634_childrenDeselectionSignal();
void task260134_layoutChangedWithAllSelected();
void QTBUG5671_layoutChangedWithAllSelected();
+ void QTBUG2804_layoutChangedTreeSelection();
private:
QAbstractItemModel *model;
@@ -2327,5 +2328,31 @@ void tst_QItemSelectionModel::QTBUG5671_layoutChangedWithAllSelected()
QVERIFY(selection.isSelected(index));
}
+void tst_QItemSelectionModel::QTBUG2804_layoutChangedTreeSelection()
+{
+ QStandardItemModel model;
+ QStandardItem top1("Child1"), top2("Child2"), top3("Child3");
+ QStandardItem sub11("Alpha"), sub12("Beta"), sub13("Gamma"), sub14("Delta"),
+ sub21("Alpha"), sub22("Beta"), sub23("Gamma"), sub24("Delta");
+ top1.appendColumn(QList<QStandardItem*>() << &sub11 << &sub12 << &sub13 << &sub14);
+ top2.appendColumn(QList<QStandardItem*>() << &sub21 << &sub22 << &sub23 << &sub24);
+ model.appendColumn(QList<QStandardItem*>() << &top1 << &top2 << &top3);
+
+ QItemSelectionModel selModel(&model);
+
+ selModel.select(sub11.index(), QItemSelectionModel::Select);
+ selModel.select(sub12.index(), QItemSelectionModel::Select);
+ selModel.select(sub21.index(), QItemSelectionModel::Select);
+ selModel.select(sub23.index(), QItemSelectionModel::Select);
+
+ QModelIndexList list = selModel.selectedIndexes();
+ QCOMPARE(list.count(), 4);
+
+ model.sort(0); //this will provoke a relayout
+
+ QCOMPARE(selModel.selectedIndexes().count(), 4);
+}
+
+
QTEST_MAIN(tst_QItemSelectionModel)
#include "tst_qitemselectionmodel.moc"
diff --git a/tests/auto/qobject/tst_qobject.cpp b/tests/auto/qobject/tst_qobject.cpp
index 0161a68..8da3484 100644
--- a/tests/auto/qobject/tst_qobject.cpp
+++ b/tests/auto/qobject/tst_qobject.cpp
@@ -128,6 +128,7 @@ private slots:
void isSignalConnected();
void qMetaObjectConnect();
void qMetaObjectDisconnectOne();
+ void sameName();
protected:
};
@@ -162,7 +163,7 @@ class SenderObject : public QObject
Q_OBJECT
public:
- SenderObject() : recursionCount(0) {}
+ SenderObject() : aPublicSlotCalled(0), recursionCount(0) {}
void emitSignal1AfterRecursion()
{
@@ -185,11 +186,12 @@ signals:
QT_MOC_COMPAT void signal5();
public slots:
- void aPublicSlot(){}
+ void aPublicSlot() { aPublicSlotCalled++; }
public:
Q_INVOKABLE void invoke1(){}
Q_SCRIPTABLE void sinvoke1(){}
+ int aPublicSlotCalled;
protected:
Q_INVOKABLE QT_MOC_COMPAT void invoke2(){}
Q_INVOKABLE QT_MOC_COMPAT void invoke2(int){}
@@ -429,12 +431,14 @@ public:
public slots:
void on_Sender_signalNoParams() { ++called_slot1; }
- void on_Sender_signalWithParams(int i = 0) { ++called_slot2; }
- void on_Sender_signalWithParams(int i, QString string) { ++called_slot3; }
+ void on_Sender_signalWithParams(int i = 0) { ++called_slot2; Q_UNUSED(i); }
+ void on_Sender_signalWithParams(int i, QString string) { ++called_slot3; Q_UNUSED(i);Q_UNUSED(string); }
void on_Sender_signalManyParams() { ++called_slot4; }
- void on_Sender_signalManyParams(int i1, int i2, int i3, QString string, bool onoff) { ++called_slot5; }
- void on_Sender_signalManyParams(int i1, int i2, int i3, QString string, bool onoff, bool dummy) { ++called_slot6; }
- void on_Sender_signalManyParams2(int i1, int i2, int i3, QString string, bool onoff) { ++called_slot7; }
+ void on_Sender_signalManyParams(int i1, int i2, int i3, QString string, bool onoff) { ++called_slot5; Q_UNUSED(i1);Q_UNUSED(i2);Q_UNUSED(i3);Q_UNUSED(string);Q_UNUSED(onoff); }
+ void on_Sender_signalManyParams(int i1, int i2, int i3, QString string, bool onoff, bool dummy)
+ { ++called_slot6; Q_UNUSED(i1);Q_UNUSED(i2);Q_UNUSED(i3);Q_UNUSED(string);Q_UNUSED(onoff); Q_UNUSED(dummy);}
+ void on_Sender_signalManyParams2(int i1, int i2, int i3, QString string, bool onoff)
+ { ++called_slot7; Q_UNUSED(i1);Q_UNUSED(i2);Q_UNUSED(i3);Q_UNUSED(string);Q_UNUSED(onoff); }
void slotLoopBack() { ++called_slot8; }
protected slots:
@@ -2090,21 +2094,21 @@ public slots:
void constUintPointerSlot(const uint *) { }
void constUlongPointerSlot(const ulong *) { }
- void structSlot(Struct s) { }
- void classSlot(Class c) { }
- void enumSlot(Enum e) { }
+ void structSlot(Struct s) { Q_UNUSED(s); }
+ void classSlot(Class c) { Q_UNUSED(c); }
+ void enumSlot(Enum e) { Q_UNUSED(e); }
- void structPointerSlot(Struct *s) { }
- void classPointerSlot(Class *c) { }
- void enumPointerSlot(Enum *e) { }
+ void structPointerSlot(Struct *s) { Q_UNUSED(s); }
+ void classPointerSlot(Class *c) { Q_UNUSED(c); }
+ void enumPointerSlot(Enum *e) { Q_UNUSED(e); }
- void constStructPointerSlot(const Struct *s) { }
- void constClassPointerSlot(const Class *c) { }
- void constEnumPointerSlot(const Enum *e) { }
+ void constStructPointerSlot(const Struct *s) { Q_UNUSED(s); }
+ void constClassPointerSlot(const Class *c) { Q_UNUSED(c); }
+ void constEnumPointerSlot(const Enum *e) { Q_UNUSED(e); }
- void constStructPointerConstPointerSlot(const Struct * const *s) { }
- void constClassPointerConstPointerSlot(const Class * const *c) { }
- void constEnumPointerConstPointerSlot(const Enum * const *e) { }
+ void constStructPointerConstPointerSlot(const Struct * const *s) { Q_UNUSED(s); }
+ void constClassPointerConstPointerSlot(const Class * const *c) { Q_UNUSED(c); }
+ void constEnumPointerConstPointerSlot(const Enum * const *e) { Q_UNUSED(e); }
void uintSlot(uint) {};
void unsignedintSlot(unsigned int) {};
@@ -3550,5 +3554,41 @@ void tst_QObject::qMetaObjectDisconnectOne()
delete r1;
}
+class ConfusingObject : public SenderObject
+{ Q_OBJECT
+public slots:
+ void signal1() { s++; }
+signals:
+ void aPublicSlot();
+public:
+ int s;
+ ConfusingObject() : s(0) {}
+ friend class tst_QObject;
+};
+
+void tst_QObject::sameName()
+{
+ ConfusingObject c1, c2;
+ QVERIFY(connect(&c1, SIGNAL(signal1()), &c1, SLOT(signal1())));
+ c1.emitSignal1();
+ QCOMPARE(c1.s, 1);
+
+ QVERIFY(connect(&c2, SIGNAL(signal1()), &c1, SIGNAL(signal1())));
+ c2.emitSignal1();
+ QCOMPARE(c1.s, 2);
+
+ QVERIFY(connect(&c2, SIGNAL(aPublicSlot()), &c1, SLOT(signal1())));
+ c2.aPublicSlot();
+ QCOMPARE(c2.aPublicSlotCalled, 0);
+ QCOMPARE(c1.aPublicSlotCalled, 0);
+ QCOMPARE(c1.s, 3);
+
+ QVERIFY(connect(&c2, SIGNAL(aPublicSlot()), &c1, SLOT(aPublicSlot())));
+ c2.aPublicSlot();
+ QCOMPARE(c2.aPublicSlotCalled, 0);
+ QCOMPARE(c1.aPublicSlotCalled, 1);
+ QCOMPARE(c1.s, 4);
+}
+
QTEST_MAIN(tst_QObject)
#include "tst_qobject.moc"