From e96e6b7751403a1b7ebee4bce9b82bdd282bdd89 Mon Sep 17 00:00:00 2001 From: evgeny Date: Wed, 7 Oct 2026 16:43:52 +0200 Subject: [PATCH] Make desktop scope test independent of current workspace changes --- .../chatgui/tests/test_message_notification_x11.cpp | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/tools/chatgui/tests/test_message_notification_x11.cpp b/tools/chatgui/tests/test_message_notification_x11.cpp index 36443cb9..a4a6a037 100644 --- a/tools/chatgui/tests/test_message_notification_x11.cpp +++ b/tools/chatgui/tests/test_message_notification_x11.cpp @@ -37,25 +37,28 @@ private slots: MessageNotification notification; notification.showMessage("42", "Alice", "Desktop test", {}); const Window window = Window(notification.winId()); + QTest::qWait(200); // Проверяем состояние после обработки MapRequest оконным менеджером. + DEBUG_INFO(DEBUG_CATEGORY_DEBUG, "notification desktop test: mapped desktop=%lld root_current=%lld root_count=%lld", + (long long)desktop(window), (long long)desktop(DefaultRootWindow(m_display), "_NET_CURRENT_DESKTOP"), + (long long)desktop(DefaultRootWindow(m_display), "_NET_NUMBER_OF_DESKTOPS")); QTRY_COMPARE_WITH_TIMEOUT(desktop(window), qint64(0xffffffffUL), 2000); QVERIFY(!notification.parentWidget()); QVERIFY(notification.windowFlags() & Qt::WindowDoesNotAcceptFocus); DEBUG_INFO(DEBUG_CATEGORY_DEBUG, "notification desktop test: first show window=0x%lx desktop=all", window); - // Переносим только собственное тестовое окно на текущий стол, затем проверяем повторный запрос all. - const qint64 current = desktop(DefaultRootWindow(m_display), "_NET_CURRENT_DESKTOP"); - QVERIFY(current >= 0); + // Переносим только своё окно на стол 0; активный стол пользователя может изменяться во время проверки. + const qint64 singleDesktop = 0; XEvent event{}; event.xclient.type = ClientMessage; event.xclient.window = window; event.xclient.message_type = XInternAtom(m_display, "_NET_WM_DESKTOP", False); event.xclient.format = 32; - event.xclient.data.l[0] = long(current); + event.xclient.data.l[0] = long(singleDesktop); event.xclient.data.l[1] = 1; QVERIFY(XSendEvent(m_display, DefaultRootWindow(m_display), False, SubstructureRedirectMask | SubstructureNotifyMask, &event)); XFlush(m_display); - QTRY_COMPARE_WITH_TIMEOUT(desktop(window), current, 2000); + QTRY_COMPARE_WITH_TIMEOUT(desktop(window), singleDesktop, 2000); notification.showMessage("dm:7", "Bob", "Desktop test", {}); QTRY_COMPARE_WITH_TIMEOUT(desktop(window), qint64(0xffffffffUL), 2000); DEBUG_INFO(DEBUG_CATEGORY_DEBUG, "notification desktop test: updated visible window desktop=all");