summaryrefslogtreecommitdiffstats
path: root/tests/auto/qgraphicswidget/tst_qgraphicswidget.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/qgraphicswidget/tst_qgraphicswidget.cpp')
-rw-r--r--tests/auto/qgraphicswidget/tst_qgraphicswidget.cpp35
1 files changed, 35 insertions, 0 deletions
diff --git a/tests/auto/qgraphicswidget/tst_qgraphicswidget.cpp b/tests/auto/qgraphicswidget/tst_qgraphicswidget.cpp
index 3b98c2f..3303df5 100644
--- a/tests/auto/qgraphicswidget/tst_qgraphicswidget.cpp
+++ b/tests/auto/qgraphicswidget/tst_qgraphicswidget.cpp
@@ -106,6 +106,7 @@ private slots:
void font_data();
void font();
void fontPropagation();
+ void fontChangedEvent();
void fontPropagationWidgetItemWidget();
void fontPropagationSceneChange();
void geometry_data();
@@ -673,6 +674,40 @@ void tst_QGraphicsWidget::fontPropagation()
QCOMPARE(child2->font().pointSize(), 43);
}
+void tst_QGraphicsWidget::fontChangedEvent()
+{
+ QGraphicsWidget *root = new QGraphicsWidget;
+ QGraphicsScene scene;
+ scene.addItem(root);
+
+ // Check that only the application fonts apply.
+ QFont appFont = QApplication::font();
+ QCOMPARE(scene.font(), appFont);
+ QCOMPARE(root->font(), appFont);
+
+ EventSpy rootSpyFont(root, QEvent::FontChange);
+ EventSpy rootSpyPolish(root, QEvent::Polish);
+ QCOMPARE(rootSpyFont.count(), 0);
+ QApplication::processEvents(); //The polish event is sent
+ QCOMPARE(rootSpyPolish.count(), 1);
+ QApplication::processEvents(); //Process events to see if we get the font change event
+ //The font is still the same so no fontChangeEvent
+ QCOMPARE(rootSpyFont.count(), 0);
+
+ QFont font;
+ font.setPointSize(43);
+ root->setFont(font);
+ QApplication::processEvents(); //Process events to get the font change event
+ //The font changed
+ QCOMPARE(rootSpyFont.count(), 1);
+
+ //then roll back to the default one.
+ root->setFont(appFont);
+ QApplication::processEvents(); //Process events to get the font change event
+ //The font changed
+ QCOMPARE(rootSpyFont.count(), 2);
+}
+
void tst_QGraphicsWidget::fontPropagationWidgetItemWidget()
{
QGraphicsWidget *widget = new QGraphicsWidget;