From d7b45f7dc1d5f28ecdb022c5a4c7673bc55257c8 Mon Sep 17 00:00:00 2001 From: Sami Nurmenniemi Date: Mon, 29 May 2017 10:21:38 +0300 Subject: Add Qt.platform.pluginName property This exposes QGuiApplication::platformName() for qml. It is required at least for tests that are run on the "offscreen" platform (armv7 tests on qemu). [ChangeLog][QtQuick] Added Qt.platform.pluginName property. Task-number: QTBUG-60268 Change-Id: Ie55a282485d4d76ffe7ed8e77359ad7183f579c2 Reviewed-by: Simon Hausmann --- .../quick/qquickapplication/tst_qquickapplication.cpp | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'tests/auto/quick/qquickapplication/tst_qquickapplication.cpp') diff --git a/tests/auto/quick/qquickapplication/tst_qquickapplication.cpp b/tests/auto/quick/qquickapplication/tst_qquickapplication.cpp index d780b91260..e428a1fc6e 100644 --- a/tests/auto/quick/qquickapplication/tst_qquickapplication.cpp +++ b/tests/auto/quick/qquickapplication/tst_qquickapplication.cpp @@ -53,6 +53,7 @@ private slots: void styleHints(); void cleanup(); void displayName(); + void platformName(); private: QQmlEngine engine; @@ -264,6 +265,24 @@ void tst_qquickapplication::displayName() QCOMPARE(QGuiApplication::applicationDisplayName(), name[2]); } +void tst_qquickapplication::platformName() +{ + // Set up QML component + QQmlComponent component(&engine, testFileUrl("tst_platformname.qml")); + QQuickItem *item = qobject_cast(component.create()); + QVERIFY(item); + QQuickView view; + item->setParentItem(view.rootObject()); + + // Get native platform name + QString guiApplicationPlatformName = QGuiApplication::platformName(); + QVERIFY(!guiApplicationPlatformName.isEmpty()); + + // Get platform name from QML component and verify it's same + QString qmlPlatformName = qvariant_cast(item->property("platformName")); + QCOMPARE(qmlPlatformName, guiApplicationPlatformName); +} + QTEST_MAIN(tst_qquickapplication) #include "tst_qquickapplication.moc" -- cgit v1.2.3