|
|
|
|
@ -43,8 +43,9 @@ public slots:
|
|
|
|
|
requests, (unsigned long long)idle, delayMs, int(calledFromDBus())); |
|
|
|
|
if (delayMs) { |
|
|
|
|
const QDBusMessage reply = message().createReply(QVariant::fromValue(idle)); |
|
|
|
|
const QDBusConnection bus = connection(); |
|
|
|
|
setDelayedReply(true); |
|
|
|
|
QTimer::singleShot(delayMs, this, [reply] { QDBusConnection::sessionBus().send(reply); }); |
|
|
|
|
QTimer::singleShot(delayMs, this, [reply, bus] { bus.send(reply); }); |
|
|
|
|
} |
|
|
|
|
return idle; |
|
|
|
|
} |
|
|
|
|
@ -60,6 +61,13 @@ private slots:
|
|
|
|
|
qunsetenv("XDG_SESSION_TYPE"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void cleanup() { |
|
|
|
|
qunsetenv("XDG_SESSION_TYPE"); |
|
|
|
|
#ifdef UTUN_TEST_ACTIVITY_DBUS |
|
|
|
|
QDBusConnection::disconnectFromBus("notification-test-service"); |
|
|
|
|
#endif |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void firstSystemActivityAndCancellation() { |
|
|
|
|
FakeSystemActivity activity; |
|
|
|
|
QSignalSpy spy(&activity, &UserActivityMonitor::activity); |
|
|
|
|
@ -98,11 +106,15 @@ private slots:
|
|
|
|
|
QWidget hiddenParent; |
|
|
|
|
QLineEdit otherWindow; |
|
|
|
|
otherWindow.show(); |
|
|
|
|
QApplication::setActiveWindow(&otherWindow); |
|
|
|
|
MessageNotification notification(&hiddenParent); |
|
|
|
|
otherWindow.activateWindow(); |
|
|
|
|
QTRY_COMPARE(QApplication::activeWindow(), &otherWindow); |
|
|
|
|
MessageNotification notification; |
|
|
|
|
notification.showMessage("42", "Alice", "Test channel", {}); |
|
|
|
|
QVERIFY(notification.isVisible()); |
|
|
|
|
QVERIFY(!notification.parentWidget()); // ОС не должна скрывать уведомление вместе с главным окном.
|
|
|
|
|
QCOMPARE(QApplication::activeWindow(), &otherWindow); |
|
|
|
|
hiddenParent.showMinimized(); |
|
|
|
|
QVERIFY(notification.isVisible()); |
|
|
|
|
QTest::qWait(10200); |
|
|
|
|
QVERIFY(notification.isVisible()); // Без активности автоматического таймера нет.
|
|
|
|
|
QElapsedTimer elapsed; |
|
|
|
|
@ -144,7 +156,8 @@ private slots:
|
|
|
|
|
|
|
|
|
|
#ifdef UTUN_TEST_ACTIVITY_DBUS |
|
|
|
|
void gnomeIdleAndStaleReplies() { |
|
|
|
|
auto bus = QDBusConnection::sessionBus(); |
|
|
|
|
// Разные соединения исключают прямой вызов внутри Qt, чтобы задержка действительно прошла через D-Bus.
|
|
|
|
|
auto bus = QDBusConnection::connectToBus(QDBusConnection::SessionBus, "notification-test-service"); |
|
|
|
|
QVERIFY(bus.registerService("org.gnome.Mutter.IdleMonitor")); |
|
|
|
|
FakeGnomeIdle idle; |
|
|
|
|
QVERIFY(bus.registerObject("/org/gnome/Mutter/IdleMonitor/Core", &idle, QDBusConnection::ExportAllSlots)); |
|
|
|
|
|