aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorRenato Araujo Oliveira Filho <renato.filho@canonical.com>2012-10-11 16:15:17 -0300
committerRenato Araujo Oliveira Filho <renato.filho@canonical.com>2012-10-11 16:15:17 -0300
commit9bf14725a2333ca9535e734e2d6f3d7168a090d4 (patch)
treeafcccd60f592a703b5da4107c8aae80c7ef81487 /tests
parentf430d60b0a1a458985d41cb964b1a6e569c2e63e (diff)
downloadqmenumodel-9bf14725a2333ca9535e734e2d6f3d7168a090d4.tar.gz
qmenumodel-9bf14725a2333ca9535e734e2d6f3d7168a090d4.tar.bz2
qmenumodel-9bf14725a2333ca9535e734e2d6f3d7168a090d4.zip
Created unit test for crash during model destruction.
Diffstat (limited to 'tests')
-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)