Commit ec31a507 authored by Aleix Pol Gonzalez's avatar Aleix Pol Gonzalez 🐧

Add a test that adds a notification and closes it

Test Plan: Adds a test

Reviewers: #plasma, broulik, davidedmundson

Reviewed By: #plasma, davidedmundson

Subscribers: mart, mck182, plasma-devel

Tags: #plasma

Differential Revision: https://phabricator.kde.org/D6059
parent 966e91a8
import QtQuick 2.0
import org.kde.plasma.core 2.0 as PlasmaCore
import org.kde.plasma.plasmoid 2.0
Item {
id: root
property QtObject plasmoidItem: null
onPlasmoidItemChanged: {
if (plasmoidItem && !root.plasmoidItem.rootItem) {
discardTimer.running = true
return
}
showNotification("testing test")
console.log("sent notification", root.plasmoidItem, root.plasmoidItem.rootItem)
}
Timer {
id: discardTimer
interval: 0
running: false
onTriggered: {
notificationShown = notificationClosed = true
root.done();
}
}
PlasmaCore.DataSource {
id: notificationSource
engine: "notifications"
connectedSources: "org.freedesktop.Notifications"
}
function showNotification(summary, icon, appname, body, timeout) {
if(!icon) icon = "debug-run"
if(!appname) appname="test"
if(!body) body=""
if(!timeout) timeout=2000
var service = notificationSource.serviceForSource("notification");
var operation = service.operationDescription("createNotification");
operation["appName"] = appname;
operation["appIcon"] = icon;
operation["summary"] = summary;
operation["body"] = body;
operation["timeout"] = timeout;
service.startOperationCall(operation);
}
Connections {
target: root.plasmoidItem.rootItem ? root.plasmoidItem.rootItem.notifications : null
onPopupShown: {
root.notificationShown = true
popupConnections.target = popup
}
}
Connections {
id: popupConnections
onVisibleChanged: {
if (target.visible) {
popupConnections.target.mainItem.close()
} else {
root.notificationClosed = true
root.done()
}
}
}
property bool notificationShown: false
property bool notificationClosed: false
signal done()
readonly property bool failed: !notificationShown || !notificationClosed
}
......@@ -31,8 +31,8 @@ Column {
right: parent.right
}
property QtObject notificationPopup
property alias count: notificationsRepeater.count
signal popupShown(var popup)
Component.onCompleted: {
// Create the popup components and pass them to the C++ plugin
......@@ -214,6 +214,7 @@ Column {
Component.onCompleted: {
notificationPositioner.setPlasmoidScreenGeometry(plasmoid.nativeInterface.availableScreenRect);
}
onPopupShown: notificationsRoot.popupShown(popup)
}
Repeater {
......
......@@ -149,6 +149,7 @@ void NotificationsHelper::processShow()
// Populate the popup with data, this is the component's own QML method
QMetaObject::invokeMethod(popup, "populatePopup", Qt::DirectConnection, Q_ARG(QVariant, notificationData));
Q_EMIT popupShown(popup);
QTimer::singleShot(300, popup, &QWindow::show);
......
......@@ -67,6 +67,7 @@ public:
Q_SIGNALS:
void popupLocationChanged();
void popupShown(QQuickWindow* popup);
// void plasmoidScreenChanged();
private Q_SLOTS:
......
......@@ -77,11 +77,11 @@ void CoronaTestHelper::testFinished()
{
QObject* testObject = sender();
const bool result = testObject->property("failed").toBool();
m_exitcode += !result;
const bool failed = testObject->property("failed").toBool();
m_exitcode += failed;
m_tests.remove(testObject);
qCWarning(PLASMASHELL) << "test finished" << testObject << result << "remaining" << m_tests;
qCWarning(PLASMASHELL) << "test finished" << testObject << failed << "remaining" << m_tests;
if (m_tests.isEmpty()) {
qGuiApp->exit(m_exitcode);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment