aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--tests/client/loadmodel2.qml22
-rw-r--r--tests/client/qmlfiles.h.in1
-rw-r--r--tests/client/qmltest.cpp29
3 files changed, 52 insertions, 0 deletions
diff --git a/tests/client/loadmodel2.qml b/tests/client/loadmodel2.qml
new file mode 100644
index 0000000..dfe265d
--- /dev/null
+++ b/tests/client/loadmodel2.qml
@@ -0,0 +1,22 @@
+import QtQuick 2.0
+import QMenuModel 0.1
+
+Item {
+ width: 100
+ height: 100
+
+ QDBusMenuModel {
+ id: menuModel
+ busType: globalBusType
+ busName: globalBusName
+ objectPath: globalObjectPath
+ }
+
+ ListView {
+ model: menuModel
+ delegate: Item {}
+ }
+
+ Component.onCompleted: menuModel.start()
+}
+
diff --git a/tests/client/qmlfiles.h.in b/tests/client/qmlfiles.h.in
index ebb534c..876b78f 100644
--- a/tests/client/qmlfiles.h.in
+++ b/tests/client/qmlfiles.h.in
@@ -1,2 +1,3 @@
const char* QML_BASE_DIR = "@libqmenumodel_BINARY_DIR@";
const char* LOADMODEL_QML = "@CMAKE_CURRENT_SOURCE_DIR@/loadmodel.qml";
+const char* LOADMODEL2_QML = "@CMAKE_CURRENT_SOURCE_DIR@/loadmodel2.qml";
diff --git a/tests/client/qmltest.cpp b/tests/client/qmltest.cpp
index e9db4ac..4e6f288 100644
--- a/tests/client/qmltest.cpp
+++ b/tests/client/qmltest.cpp
@@ -84,6 +84,35 @@ private Q_SLOTS:
QTest::qWait(500);
}
+ /*
+ * Test the menu model disappearing from the bus and reappearing
+ * while the QML application is running.
+ */
+ void testServiceDisappear()
+ {
+ m_script.publishMenu();
+ m_script.run();
+ QTest::qWait(500);
+
+ QQuickView *view = new QQuickView;
+ view->engine()->addImportPath(QML_BASE_DIR);
+ view->engine()->rootContext()->setContextProperty("globalBusType", DBusEnums::SessionBus);
+ view->engine()->rootContext()->setContextProperty("globalBusName", MENU_SERVICE_NAME);
+ view->engine()->rootContext()->setContextProperty("globalObjectPath", MENU_OBJECT_PATH);
+ view->setSource(QUrl::fromLocalFile(LOADMODEL2_QML));
+ view->show();
+ QTest::qWait(500);
+
+ m_script.unpublishMenu();
+ QTest::qWait(500);
+
+ m_script.publishMenu();
+ m_script.run();
+ QTest::qWait(500);
+
+ delete view;
+ QTest::qWait(1000);
+ }
};
QTEST_MAIN(QMLTest)