aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/quick/qquickitem
diff options
context:
space:
mode:
authorAndy Shaw <andy.shaw@qt.io>2020-02-14 13:56:59 +0100
committerAndy Shaw <andy.shaw@qt.io>2020-02-25 22:17:38 +0100
commit685d2ca3c7a9f221ac12f6db61e02bab40371f5f (patch)
tree9e29d8f91f68624a065276bfbdbc5a014b925654 /tests/auto/quick/qquickitem
parenta4b25aa3c16ba9ce6e2821e591f7c35bf675d961 (diff)
Propagate the LanguageChange events from the QQuickWindow to the items
Fixes: QTBUG-78141 Task-number: QTBUG-82020 Change-Id: Id47f8efe77cd3f6bfd330c8759059e19de5a86d2 Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
Diffstat (limited to 'tests/auto/quick/qquickitem')
-rw-r--r--tests/auto/quick/qquickitem/data/hellotr_la.qmbin0 -> 237 bytes
-rw-r--r--tests/auto/quick/qquickitem/tst_qquickitem.cpp35
2 files changed, 35 insertions, 0 deletions
diff --git a/tests/auto/quick/qquickitem/data/hellotr_la.qm b/tests/auto/quick/qquickitem/data/hellotr_la.qm
new file mode 100644
index 0000000000..25c0aad583
--- /dev/null
+++ b/tests/auto/quick/qquickitem/data/hellotr_la.qm
Binary files differ
diff --git a/tests/auto/quick/qquickitem/tst_qquickitem.cpp b/tests/auto/quick/qquickitem/tst_qquickitem.cpp
index 8aab13e095..b5e001a2b7 100644
--- a/tests/auto/quick/qquickitem/tst_qquickitem.cpp
+++ b/tests/auto/quick/qquickitem/tst_qquickitem.cpp
@@ -40,6 +40,7 @@
#include "../../shared/util.h"
#include "../shared/viewtestutil.h"
#include <QSignalSpy>
+#include <QTranslator>
#ifdef TEST_QTBUG_60123
#include <QWidget>
@@ -70,6 +71,7 @@ public:
ulong timestamp;
QPoint lastWheelEventPos;
QPoint lastWheelEventGlobalPos;
+ int languageChangeEventCount = 0;
protected:
virtual void focusInEvent(QFocusEvent *) { Q_ASSERT(!focused); focused = true; }
virtual void focusOutEvent(QFocusEvent *) { Q_ASSERT(focused); focused = false; }
@@ -86,6 +88,12 @@ protected:
lastWheelEventPos = event->position().toPoint();
lastWheelEventGlobalPos = event->globalPosition().toPoint();
}
+ bool event(QEvent *e) override
+ {
+ if (e->type() == QEvent::LanguageChange)
+ languageChangeEventCount++;
+ return QQuickItem::event(e);
+ }
};
class TestWindow: public QQuickWindow
@@ -198,6 +206,7 @@ private slots:
#endif
void setParentCalledInOnWindowChanged();
+ void receivesLanguageChangeEvent();
private:
@@ -2155,6 +2164,32 @@ void tst_qquickitem::setParentCalledInOnWindowChanged()
QVERIFY(ensureFocus(&view)); // should not crash
}
+void tst_qquickitem::receivesLanguageChangeEvent()
+{
+ QQuickWindow window;
+ window.setFramePosition(QPoint(100, 100));
+ window.resize(200, 200);
+ window.show();
+ QVERIFY(QTest::qWaitForWindowExposed(&window));
+
+ QScopedPointer<TestItem> child1(new TestItem);
+ child1->setObjectName(QStringLiteral("child1"));
+ child1->setSize(QSizeF(200, 100));
+ child1->setParentItem(window.contentItem());
+
+ QScopedPointer<TestItem> child2(new TestItem);
+ child2->setObjectName(QStringLiteral("child2"));
+ child2->setSize(QSizeF(50, 50));
+ child2->setParentItem(child1.data());
+
+ QTranslator t;
+ QVERIFY(t.load("hellotr_la.qm", dataDirectory()));
+ QVERIFY(QCoreApplication::installTranslator(&t));
+
+ QTRY_COMPARE(child1->languageChangeEventCount, 1);
+ QCOMPARE(child2->languageChangeEventCount, 1);
+}
+
QTEST_MAIN(tst_qquickitem)
#include "tst_qquickitem.moc"