Changeset View
Changeset View
Standalone View
Standalone View
autotests/integration/keyboard_layout_test.cpp
Show First 20 Lines • Show All 54 Lines • ▼ Show 20 Line(s) | 51 | private Q_SLOTS: | |||
---|---|---|---|---|---|
55 | 55 | | |||
56 | void testReconfigure(); | 56 | void testReconfigure(); | ||
57 | void testChangeLayoutThroughDBus(); | 57 | void testChangeLayoutThroughDBus(); | ||
58 | void testPerLayoutShortcut(); | 58 | void testPerLayoutShortcut(); | ||
59 | void testDBusServiceExport(); | 59 | void testDBusServiceExport(); | ||
60 | void testVirtualDesktopPolicy(); | 60 | void testVirtualDesktopPolicy(); | ||
61 | void testWindowPolicy(); | 61 | void testWindowPolicy(); | ||
62 | void testApplicationPolicy(); | 62 | void testApplicationPolicy(); | ||
63 | void testNumLock(); | ||||
63 | 64 | | |||
64 | private: | 65 | private: | ||
65 | void reconfigureLayouts(); | 66 | void reconfigureLayouts(); | ||
66 | }; | 67 | }; | ||
67 | 68 | | |||
68 | void KeyboardLayoutTest::reconfigureLayouts() | 69 | void KeyboardLayoutTest::reconfigureLayouts() | ||
69 | { | 70 | { | ||
70 | // create DBus signal to reload | 71 | // create DBus signal to reload | ||
71 | QDBusMessage message = QDBusMessage::createSignal(QStringLiteral("/Layouts"), QStringLiteral("org.kde.keyboard"), QStringLiteral("reloadConfig")); | 72 | QDBusMessage message = QDBusMessage::createSignal(QStringLiteral("/Layouts"), QStringLiteral("org.kde.keyboard"), QStringLiteral("reloadConfig")); | ||
72 | QDBusConnection::sessionBus().send(message); | 73 | QDBusConnection::sessionBus().send(message); | ||
73 | } | 74 | } | ||
74 | 75 | | |||
75 | void KeyboardLayoutTest::initTestCase() | 76 | void KeyboardLayoutTest::initTestCase() | ||
76 | { | 77 | { | ||
77 | qRegisterMetaType<KWin::ShellClient*>(); | 78 | qRegisterMetaType<KWin::ShellClient*>(); | ||
78 | qRegisterMetaType<KWin::AbstractClient*>(); | 79 | qRegisterMetaType<KWin::AbstractClient*>(); | ||
79 | QSignalSpy workspaceCreatedSpy(kwinApp(), &Application::workspaceCreated); | 80 | QSignalSpy workspaceCreatedSpy(kwinApp(), &Application::workspaceCreated); | ||
80 | QVERIFY(workspaceCreatedSpy.isValid()); | 81 | QVERIFY(workspaceCreatedSpy.isValid()); | ||
81 | kwinApp()->platform()->setInitialWindowSize(QSize(1280, 1024)); | 82 | kwinApp()->platform()->setInitialWindowSize(QSize(1280, 1024)); | ||
82 | QVERIFY(waylandServer()->init(s_socketName.toLocal8Bit())); | 83 | QVERIFY(waylandServer()->init(s_socketName.toLocal8Bit())); | ||
83 | 84 | | |||
84 | kwinApp()->setConfig(KSharedConfig::openConfig(QString(), KConfig::SimpleConfig)); | 85 | kwinApp()->setConfig(KSharedConfig::openConfig(QString(), KConfig::SimpleConfig)); | ||
85 | kwinApp()->setKxkbConfig(KSharedConfig::openConfig(QString(), KConfig::SimpleConfig)); | 86 | kwinApp()->setKxkbConfig(KSharedConfig::openConfig(QString(), KConfig::SimpleConfig)); | ||
87 | kwinApp()->setInputConfig(KSharedConfig::openConfig(QString(), KConfig::SimpleConfig)); | ||||
86 | 88 | | |||
87 | kwinApp()->start(); | 89 | kwinApp()->start(); | ||
88 | QVERIFY(workspaceCreatedSpy.wait()); | 90 | QVERIFY(workspaceCreatedSpy.wait()); | ||
89 | waylandServer()->initWorkspace(); | 91 | waylandServer()->initWorkspace(); | ||
90 | } | 92 | } | ||
91 | 93 | | |||
92 | void KeyboardLayoutTest::init() | 94 | void KeyboardLayoutTest::init() | ||
93 | { | 95 | { | ||
▲ Show 20 Lines • Show All 358 Lines • ▼ Show 20 Line(s) | 401 | { | |||
452 | 454 | | |||
453 | shellSurface2.reset(); | 455 | shellSurface2.reset(); | ||
454 | surface2.reset(); | 456 | surface2.reset(); | ||
455 | QVERIFY(Test::waitForWindowDestroyed(c2)); | 457 | QVERIFY(Test::waitForWindowDestroyed(c2)); | ||
456 | QVERIFY(!layoutChangedSpy.wait()); | 458 | QVERIFY(!layoutChangedSpy.wait()); | ||
457 | QTRY_COMPARE(xkb->layoutName(), QStringLiteral("German (Neo 2)")); | 459 | QTRY_COMPARE(xkb->layoutName(), QStringLiteral("German (Neo 2)")); | ||
458 | } | 460 | } | ||
459 | 461 | | |||
462 | void KeyboardLayoutTest::testNumLock() | ||||
463 | { | ||||
464 | qputenv("KWIN_FORCE_NUM_LOCK_EVALUATION", "1"); | ||||
465 | auto xkb = input()->keyboard()->xkb(); | ||||
466 | // by default not set | ||||
467 | QVERIFY(!xkb->modifiers().testFlag(Qt::KeypadModifier)); | ||||
468 | quint32 timestamp = 0; | ||||
469 | kwinApp()->platform()->keyboardKeyPressed(KEY_NUMLOCK, timestamp++); | ||||
470 | kwinApp()->platform()->keyboardKeyReleased(KEY_NUMLOCK, timestamp++); | ||||
471 | // now it should be on | ||||
472 | QVERIFY(xkb->modifiers().testFlag(Qt::KeypadModifier)); | ||||
473 | // and back to off | ||||
474 | kwinApp()->platform()->keyboardKeyPressed(KEY_NUMLOCK, timestamp++); | ||||
475 | kwinApp()->platform()->keyboardKeyReleased(KEY_NUMLOCK, timestamp++); | ||||
476 | QVERIFY(!xkb->modifiers().testFlag(Qt::KeypadModifier)); | ||||
477 | | ||||
478 | // let's reconfigure to enable through config | ||||
479 | auto group = kwinApp()->inputConfig()->group("Keyboard"); | ||||
480 | group.writeEntry("NumLock", 0); | ||||
481 | group.sync(); | ||||
482 | xkb->reconfigure(); | ||||
483 | // now it should be on | ||||
484 | QVERIFY(xkb->modifiers().testFlag(Qt::KeypadModifier)); | ||||
485 | // pressing should result in it being off | ||||
486 | kwinApp()->platform()->keyboardKeyPressed(KEY_NUMLOCK, timestamp++); | ||||
487 | kwinApp()->platform()->keyboardKeyReleased(KEY_NUMLOCK, timestamp++); | ||||
488 | QVERIFY(!xkb->modifiers().testFlag(Qt::KeypadModifier)); | ||||
489 | | ||||
490 | // pressing again should enable it | ||||
491 | kwinApp()->platform()->keyboardKeyPressed(KEY_NUMLOCK, timestamp++); | ||||
492 | kwinApp()->platform()->keyboardKeyReleased(KEY_NUMLOCK, timestamp++); | ||||
493 | QVERIFY(xkb->modifiers().testFlag(Qt::KeypadModifier)); | ||||
494 | | ||||
495 | // now reconfigure to disable on load | ||||
496 | group.writeEntry("NumLock", 1); | ||||
497 | group.sync(); | ||||
498 | xkb->reconfigure(); | ||||
499 | QVERIFY(!xkb->modifiers().testFlag(Qt::KeypadModifier)); | ||||
500 | } | ||||
501 | | ||||
502 | | ||||
460 | WAYLANDTEST_MAIN(KeyboardLayoutTest) | 503 | WAYLANDTEST_MAIN(KeyboardLayoutTest) | ||
461 | #include "keyboard_layout_test.moc" | 504 | #include "keyboard_layout_test.moc" |