[autotests/libinput] Add test case for Device::isAlphaNumericKeyboard
parent
abe582c27d
commit
27523b6ecb
|
@ -22,6 +22,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
#include <QtTest/QtTest>
|
#include <QtTest/QtTest>
|
||||||
|
|
||||||
|
#include <linux/input.h>
|
||||||
|
|
||||||
using namespace KWin::LibInput;
|
using namespace KWin::LibInput;
|
||||||
|
|
||||||
class TestLibinputDevice : public QObject
|
class TestLibinputDevice : public QObject
|
||||||
|
@ -60,6 +62,8 @@ private Q_SLOTS:
|
||||||
void testLeftHanded();
|
void testLeftHanded();
|
||||||
void testSupportedButtons_data();
|
void testSupportedButtons_data();
|
||||||
void testSupportedButtons();
|
void testSupportedButtons();
|
||||||
|
void testAlphaNumericKeyboard_data();
|
||||||
|
void testAlphaNumericKeyboard();
|
||||||
};
|
};
|
||||||
|
|
||||||
void TestLibinputDevice::testStaticGetter()
|
void TestLibinputDevice::testStaticGetter()
|
||||||
|
@ -503,5 +507,57 @@ void TestLibinputDevice::testSupportedButtons()
|
||||||
QTEST(d.supportedButtons(), "expectedButtons");
|
QTEST(d.supportedButtons(), "expectedButtons");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void TestLibinputDevice::testAlphaNumericKeyboard_data()
|
||||||
|
{
|
||||||
|
QTest::addColumn<QVector<quint32>>("supportedKeys");
|
||||||
|
QTest::addColumn<bool>("isAlpha");
|
||||||
|
|
||||||
|
QVector<quint32> keys;
|
||||||
|
|
||||||
|
for (int i = KEY_1; i <= KEY_0; i++) {
|
||||||
|
keys << i;
|
||||||
|
QByteArray row = QByteArrayLiteral("number");
|
||||||
|
row.append(QByteArray::number(i));
|
||||||
|
QTest::newRow(row.constData()) << keys << false;
|
||||||
|
}
|
||||||
|
for (int i = KEY_Q; i <= KEY_P; i++) {
|
||||||
|
keys << i;
|
||||||
|
QByteArray row = QByteArrayLiteral("alpha");
|
||||||
|
row.append(QByteArray::number(i));
|
||||||
|
QTest::newRow(row.constData()) << keys << false;
|
||||||
|
}
|
||||||
|
for (int i = KEY_A; i <= KEY_L; i++) {
|
||||||
|
keys << i;
|
||||||
|
QByteArray row = QByteArrayLiteral("alpha");
|
||||||
|
row.append(QByteArray::number(i));
|
||||||
|
QTest::newRow(row.constData()) << keys << false;
|
||||||
|
}
|
||||||
|
for (int i = KEY_Z; i < KEY_M; i++) {
|
||||||
|
keys << i;
|
||||||
|
QByteArray row = QByteArrayLiteral("alpha");
|
||||||
|
row.append(QByteArray::number(i));
|
||||||
|
QTest::newRow(row.constData()) << keys << false;
|
||||||
|
}
|
||||||
|
// adding a different key should not result in it becoming alphanumeric keyboard
|
||||||
|
keys << KEY_SEMICOLON;
|
||||||
|
QTest::newRow("semicolon") << keys << false;
|
||||||
|
|
||||||
|
// last but not least the M which should turn everything on
|
||||||
|
keys << KEY_M;
|
||||||
|
QTest::newRow("alphanumeric") << keys << true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void TestLibinputDevice::testAlphaNumericKeyboard()
|
||||||
|
{
|
||||||
|
QFETCH(QVector<quint32>, supportedKeys);
|
||||||
|
libinput_device device;
|
||||||
|
device.keyboard = true;
|
||||||
|
device.keys = supportedKeys;
|
||||||
|
|
||||||
|
Device d(&device);
|
||||||
|
QCOMPARE(d.isKeyboard(), true);
|
||||||
|
QTEST(d.isAlphaNumericKeyboard(), "isAlpha");
|
||||||
|
}
|
||||||
|
|
||||||
QTEST_GUILESS_MAIN(TestLibinputDevice)
|
QTEST_GUILESS_MAIN(TestLibinputDevice)
|
||||||
#include "device_test.moc"
|
#include "device_test.moc"
|
||||||
|
|
|
@ -24,7 +24,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
int libinput_device_keyboard_has_key(struct libinput_device *device, uint32_t code)
|
int libinput_device_keyboard_has_key(struct libinput_device *device, uint32_t code)
|
||||||
{
|
{
|
||||||
return 0;
|
return device->keys.contains(code);
|
||||||
}
|
}
|
||||||
|
|
||||||
int libinput_device_has_capability(struct libinput_device *device, enum libinput_device_capability capability)
|
int libinput_device_has_capability(struct libinput_device *device, enum libinput_device_capability capability)
|
||||||
|
|
|
@ -22,6 +22,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
#include <QByteArray>
|
#include <QByteArray>
|
||||||
#include <QSizeF>
|
#include <QSizeF>
|
||||||
|
#include <QVector>
|
||||||
|
|
||||||
struct libinput_device {
|
struct libinput_device {
|
||||||
bool keyboard = false;
|
bool keyboard = false;
|
||||||
|
@ -48,6 +49,7 @@ struct libinput_device {
|
||||||
bool leftHanded = false;
|
bool leftHanded = false;
|
||||||
int setLeftHandedReturnValue = 0;
|
int setLeftHandedReturnValue = 0;
|
||||||
Qt::MouseButtons supportedButtons;
|
Qt::MouseButtons supportedButtons;
|
||||||
|
QVector<quint32> keys;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue