[autotests] Add test case for effects key handling during screen lock
Verifies that no key events are forwarded to the Effects during a locked screen.
This commit is contained in:
parent
dfd0664fd6
commit
037b3ba66e
1 changed files with 49 additions and 0 deletions
|
@ -60,6 +60,7 @@ private Q_SLOTS:
|
||||||
void testPointerAxis();
|
void testPointerAxis();
|
||||||
void testScreenEdge();
|
void testScreenEdge();
|
||||||
void testEffects();
|
void testEffects();
|
||||||
|
void testEffectsKeyboard();
|
||||||
void testMoveWindow();
|
void testMoveWindow();
|
||||||
void testPointerShortcut();
|
void testPointerShortcut();
|
||||||
void testAxisShortcut_data();
|
void testAxisShortcut_data();
|
||||||
|
@ -87,9 +88,13 @@ public:
|
||||||
void windowInputMouseEvent(QEvent*) override {
|
void windowInputMouseEvent(QEvent*) override {
|
||||||
emit inputEvent();
|
emit inputEvent();
|
||||||
}
|
}
|
||||||
|
void grabbedKeyboardEvent(QKeyEvent *e) override {
|
||||||
|
emit keyEvent(e->text());
|
||||||
|
}
|
||||||
|
|
||||||
Q_SIGNALS:
|
Q_SIGNALS:
|
||||||
void inputEvent();
|
void inputEvent();
|
||||||
|
void keyEvent(const QString&);
|
||||||
};
|
};
|
||||||
|
|
||||||
#define LOCK \
|
#define LOCK \
|
||||||
|
@ -118,6 +123,12 @@ Q_SIGNALS:
|
||||||
#define RELEASE \
|
#define RELEASE \
|
||||||
waylandServer()->backend()->pointerButtonReleased(BTN_LEFT, timestamp++)
|
waylandServer()->backend()->pointerButtonReleased(BTN_LEFT, timestamp++)
|
||||||
|
|
||||||
|
#define KEYPRESS( key ) \
|
||||||
|
waylandServer()->backend()->keyboardKeyPressed(key, timestamp++)
|
||||||
|
|
||||||
|
#define KEYRELEASE( key ) \
|
||||||
|
waylandServer()->backend()->keyboardKeyReleased(key, timestamp++)
|
||||||
|
|
||||||
void LockScreenTest::unlock()
|
void LockScreenTest::unlock()
|
||||||
{
|
{
|
||||||
using namespace ScreenLocker;
|
using namespace ScreenLocker;
|
||||||
|
@ -454,6 +465,44 @@ void LockScreenTest::testEffects()
|
||||||
effects->stopMouseInterception(effect.data());
|
effects->stopMouseInterception(effect.data());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void LockScreenTest::testEffectsKeyboard()
|
||||||
|
{
|
||||||
|
QScopedPointer<HelperEffect> effect(new HelperEffect);
|
||||||
|
QSignalSpy inputSpy(effect.data(), &HelperEffect::keyEvent);
|
||||||
|
QVERIFY(inputSpy.isValid());
|
||||||
|
effects->grabKeyboard(effect.data());
|
||||||
|
|
||||||
|
quint32 timestamp = 1;
|
||||||
|
KEYPRESS(KEY_A);
|
||||||
|
QCOMPARE(inputSpy.count(), 1);
|
||||||
|
QCOMPARE(inputSpy.first().first().toString(), QStringLiteral("a"));
|
||||||
|
KEYRELEASE(KEY_A);
|
||||||
|
QCOMPARE(inputSpy.count(), 2);
|
||||||
|
QCOMPARE(inputSpy.first().first().toString(), QStringLiteral("a"));
|
||||||
|
QCOMPARE(inputSpy.at(1).first().toString(), QStringLiteral("a"));
|
||||||
|
|
||||||
|
LOCK
|
||||||
|
KEYPRESS(KEY_B);
|
||||||
|
QCOMPARE(inputSpy.count(), 2);
|
||||||
|
KEYRELEASE(KEY_B);
|
||||||
|
QCOMPARE(inputSpy.count(), 2);
|
||||||
|
|
||||||
|
UNLOCK
|
||||||
|
KEYPRESS(KEY_C);
|
||||||
|
QCOMPARE(inputSpy.count(), 3);
|
||||||
|
QCOMPARE(inputSpy.first().first().toString(), QStringLiteral("a"));
|
||||||
|
QCOMPARE(inputSpy.at(1).first().toString(), QStringLiteral("a"));
|
||||||
|
QCOMPARE(inputSpy.at(2).first().toString(), QStringLiteral("c"));
|
||||||
|
KEYRELEASE(KEY_C);
|
||||||
|
QCOMPARE(inputSpy.count(), 4);
|
||||||
|
QCOMPARE(inputSpy.first().first().toString(), QStringLiteral("a"));
|
||||||
|
QCOMPARE(inputSpy.at(1).first().toString(), QStringLiteral("a"));
|
||||||
|
QCOMPARE(inputSpy.at(2).first().toString(), QStringLiteral("c"));
|
||||||
|
QCOMPARE(inputSpy.at(3).first().toString(), QStringLiteral("c"));
|
||||||
|
|
||||||
|
effects->ungrabKeyboard();
|
||||||
|
}
|
||||||
|
|
||||||
void LockScreenTest::testMoveWindow()
|
void LockScreenTest::testMoveWindow()
|
||||||
{
|
{
|
||||||
using namespace KWayland::Client;
|
using namespace KWayland::Client;
|
||||||
|
|
Loading…
Reference in a new issue