summaryrefslogtreecommitdiffstats
path: root/tests/auto/qgraphicswidget
diff options
context:
space:
mode:
authorAlexis Menard <alexis.menard@nokia.com>2009-11-30 14:58:43 +0100
committerAlexis Menard <alexis.menard@nokia.com>2009-11-30 15:09:02 +0100
commit011d3aa2bdf49127169f0726b78e13e8e9bcd73e (patch)
tree2b1c5da212a2bc2f4efaa7324a172d365ff4e4cb /tests/auto/qgraphicswidget
parent069d544f698ba020a329bdc45169ed08e8dd0357 (diff)
Only call updateFont if the font have changed.
When receiving the polish event, we call updateFont only if the font has changed (from the QApplication::font()). This avoid to clear sizeHints cache. Task-number:QTBUG-6272 Reviewed-by:janarve
Diffstat (limited to 'tests/auto/qgraphicswidget')
-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 3b98c2fcb8..3303df5553 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;