Files
RedBear-OS/local/recipes/kde/kwin/source/autotests/onscreennotificationtest.cpp
T
vasilito 7aeb3bb475 build: capture build script auto-stash changes from 0.2.5 kernel/relibc/base build
The build-redbear.sh script auto-stashes working tree changes
in nested relibc and base source trees before running the
build. These changes were captured by the failed kernel
build attempt that hit the json-target-spec / kernel rust
toolchain mismatch (fixed in 0.2.5 by creating the local
0.2.5 branch).

Captured changes:
- local/recipes/kde/* : KDE Frameworks 6 source CMakeLists
  whitespace changes from the autostash (preserved)
- local/recipes/qt/qtbase/* : qtypes.h whitespace from the
  autostash (preserved)
- local/sources/kernel/Cargo.lock : dependency lock from
  the kernel relibc rebuild attempt
- local/sources/kernel/src/lib.rs : touched (mtime) by the
  build script's touch + make prefix command

This is a bookkeeping commit — the actual code changes
for the threading plan are on the 4 submodule branches
(kernel, relibc, base, libredox) and will be pushed
separately.

0.2.5 branch was created from 0.2.4 (HEAD cd3950072e) to
continue Phase 0 of the multi-threading plan work in a
clean branch.
2026-07-02 13:41:03 +03:00

125 lines
3.9 KiB
C++

/*
SPDX-FileCopyrightText: 2016 Martin Graesslin <mgraesslin@kde.org>
SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
*/
#include "onscreennotificationtest.h"
#include "input.h"
#include "onscreennotification.h"
#include <KConfigGroup>
#include <KSharedConfig>
#include <QQmlEngine>
#include <QSignalSpy>
#include <QTest>
QTEST_MAIN(OnScreenNotificationTest);
namespace KWin
{
void InputRedirection::installInputEventSpy(InputEventSpy *spy)
{
}
void InputRedirection::uninstallInputEventSpy(InputEventSpy *spy)
{
}
InputRedirection *InputRedirection::s_self = nullptr;
}
using KWin::OnScreenNotification;
void OnScreenNotificationTest::show()
{
OnScreenNotification notification;
auto config = KSharedConfig::openConfig(QString(), KSharedConfig::SimpleConfig);
KConfigGroup group = config->group(QStringLiteral("OnScreenNotification"));
group.writeEntry(QStringLiteral("QmlPath"), QString("/does/not/exist.qml"));
group.sync();
notification.setConfig(config);
notification.setEngine(new QQmlEngine(&notification));
notification.setMessage(QStringLiteral("Some text so that we see it in the test"));
QSignalSpy visibleChangedSpy(&notification, &OnScreenNotification::visibleChanged);
QCOMPARE(notification.isVisible(), false);
notification.setVisible(true);
QCOMPARE(notification.isVisible(), true);
QCOMPARE(visibleChangedSpy.count(), 1);
// show again should not trigger
notification.setVisible(true);
QCOMPARE(visibleChangedSpy.count(), 1);
// timer should not have hidden
QTest::qWait(500);
QCOMPARE(notification.isVisible(), true);
// hide again
notification.setVisible(false);
QCOMPARE(notification.isVisible(), false);
QCOMPARE(visibleChangedSpy.count(), 2);
// now show with timer
notification.setTimeout(250);
notification.setVisible(true);
QCOMPARE(notification.isVisible(), true);
QCOMPARE(visibleChangedSpy.count(), 3);
QVERIFY(visibleChangedSpy.wait());
QCOMPARE(notification.isVisible(), false);
QCOMPARE(visibleChangedSpy.count(), 4);
}
void OnScreenNotificationTest::timeout()
{
OnScreenNotification notification;
QSignalSpy timeoutChangedSpy(&notification, &OnScreenNotification::timeoutChanged);
QCOMPARE(notification.timeout(), 0);
notification.setTimeout(1000);
QCOMPARE(notification.timeout(), 1000);
QCOMPARE(timeoutChangedSpy.count(), 1);
notification.setTimeout(1000);
QCOMPARE(timeoutChangedSpy.count(), 1);
notification.setTimeout(0);
QCOMPARE(notification.timeout(), 0);
QCOMPARE(timeoutChangedSpy.count(), 2);
}
void OnScreenNotificationTest::iconName()
{
OnScreenNotification notification;
QSignalSpy iconNameChangedSpy(&notification, &OnScreenNotification::iconNameChanged);
QCOMPARE(notification.iconName(), QString());
notification.setIconName(QStringLiteral("foo"));
QCOMPARE(notification.iconName(), QStringLiteral("foo"));
QCOMPARE(iconNameChangedSpy.count(), 1);
notification.setIconName(QStringLiteral("foo"));
QCOMPARE(iconNameChangedSpy.count(), 1);
notification.setIconName(QStringLiteral("bar"));
QCOMPARE(notification.iconName(), QStringLiteral("bar"));
QCOMPARE(iconNameChangedSpy.count(), 2);
}
void OnScreenNotificationTest::message()
{
OnScreenNotification notification;
QSignalSpy messageChangedSpy(&notification, &OnScreenNotification::messageChanged);
QCOMPARE(notification.message(), QString());
notification.setMessage(QStringLiteral("foo"));
QCOMPARE(notification.message(), QStringLiteral("foo"));
QCOMPARE(messageChangedSpy.count(), 1);
notification.setMessage(QStringLiteral("foo"));
QCOMPARE(messageChangedSpy.count(), 1);
notification.setMessage(QStringLiteral("bar"));
QCOMPARE(notification.message(), QStringLiteral("bar"));
QCOMPARE(messageChangedSpy.count(), 2);
}
#include "moc_onscreennotificationtest.cpp"