summaryrefslogtreecommitdiffstats
path: root/tests/auto/qgraphicsscene
diff options
context:
space:
mode:
authorBjørn Erik Nilsen <bjorn.nilsen@nokia.com>2009-07-01 13:59:17 +0200
committerBjørn Erik Nilsen <bjorn.nilsen@nokia.com>2009-07-01 14:00:03 +0200
commit5f9758295715c088c23f51d294b2b1b0fb361872 (patch)
tree65d8c9fbf8804bcc681c513616ccf16174b442d7 /tests/auto/qgraphicsscene
parent574fdf0b7e61c1c9994739035d9adb51af2629d0 (diff)
parentd43a10d6d9a5f13fc8deac052926720927e09e83 (diff)
Merge commit 'qt/master' into graphicssceneindex
Diffstat (limited to 'tests/auto/qgraphicsscene')
-rw-r--r--tests/auto/qgraphicsscene/tst_qgraphicsscene.cpp29
1 files changed, 28 insertions, 1 deletions
diff --git a/tests/auto/qgraphicsscene/tst_qgraphicsscene.cpp b/tests/auto/qgraphicsscene/tst_qgraphicsscene.cpp
index 1a7a076008..24acd6319b 100644
--- a/tests/auto/qgraphicsscene/tst_qgraphicsscene.cpp
+++ b/tests/auto/qgraphicsscene/tst_qgraphicsscene.cpp
@@ -141,7 +141,7 @@ protected:
}
};
-class EventSpy : public QObject
+class EventSpy : public QGraphicsWidget
{
Q_OBJECT
public:
@@ -151,6 +151,13 @@ public:
watched->installEventFilter(this);
}
+ EventSpy(QGraphicsScene *scene, QGraphicsItem *watched, QEvent::Type type)
+ : _count(0), spied(type)
+ {
+ scene->addItem(this);
+ watched->installSceneEventFilter(this);
+ }
+
int count() const { return _count; }
protected:
@@ -162,6 +169,14 @@ protected:
return false;
}
+ bool sceneEventFilter(QGraphicsItem *watched, QEvent *event)
+ {
+ Q_UNUSED(watched);
+ if (event->type() == spied)
+ ++_count;
+ return false;
+ }
+
int _count;
QEvent::Type spied;
};
@@ -236,6 +251,7 @@ private slots:
void changedSignal();
void stickyFocus_data();
void stickyFocus();
+ void sendEvent();
// task specific tests below me
void task139710_bspTreeCrash();
@@ -3607,5 +3623,16 @@ void tst_QGraphicsScene::stickyFocus()
QCOMPARE(text->hasFocus(), sticky);
}
+void tst_QGraphicsScene::sendEvent()
+{
+ QGraphicsScene scene;
+ QGraphicsTextItem *item = scene.addText(QString());
+ EventSpy *spy = new EventSpy(&scene, item, QEvent::User);
+ QCOMPARE(spy->count(), 0);
+ QEvent event(QEvent::User);
+ scene.sendEvent(item, &event);
+ QCOMPARE(spy->count(), 1);
+}
+
QTEST_MAIN(tst_QGraphicsScene)
#include "tst_qgraphicsscene.moc"