aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/quick/qquickitem/tst_qquickitem.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/quick/qquickitem/tst_qquickitem.cpp')
-rw-r--r--tests/auto/quick/qquickitem/tst_qquickitem.cpp38
1 files changed, 38 insertions, 0 deletions
diff --git a/tests/auto/quick/qquickitem/tst_qquickitem.cpp b/tests/auto/quick/qquickitem/tst_qquickitem.cpp
index 8aab13e095..137162099f 100644
--- a/tests/auto/quick/qquickitem/tst_qquickitem.cpp
+++ b/tests/auto/quick/qquickitem/tst_qquickitem.cpp
@@ -34,12 +34,16 @@
#include "private/qquickfocusscope_p.h"
#include "private/qquickitem_p.h"
#include <qpa/qwindowsysteminterface.h>
+#ifdef Q_OS_WIN
+#include <QOpenGLContext>
+#endif
#include <QDebug>
#include <QTimer>
#include <QQmlEngine>
#include "../../shared/util.h"
#include "../shared/viewtestutil.h"
#include <QSignalSpy>
+#include <QTranslator>
#ifdef TEST_QTBUG_60123
#include <QWidget>
@@ -70,6 +74,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 +91,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 +209,7 @@ private slots:
#endif
void setParentCalledInOnWindowChanged();
+ void receivesLanguageChangeEvent();
private:
@@ -2155,6 +2167,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"