spiegel-keyman/linux/keyman-system-service/tests/KeyboardDeviceMock.cpp
Eberhard Beilharz ab25157364
feat(linux): Refactor to benefit from C++ RAII
Also apply changes from code review comments.
2023-05-22 19:51:45 +02:00

45 lines
757 B
C++

// A KeyboardDevice mock.
#include <dirent.h>
#include <fcntl.h>
#include <iostream>
#include <string.h>
#include <string>
#include <unistd.h>
#ifndef KeyboardDevice
#define KeyboardDevice KeyboardDeviceMock
#endif
#include "KeyboardDevice.h"
using namespace std;
KeyboardDeviceMock::KeyboardDeviceMock() {
dev = nullptr;
fd = -1;
hasCapsLockLed = 1;
debug = false;
}
KeyboardDeviceMock::~KeyboardDeviceMock() {
}
bool
KeyboardDeviceMock::Initialize(const char* name) {
return true;
}
bool
KeyboardDeviceMock::HasCapsLockLed() {
return true;
}
void
KeyboardDeviceMock::SetCapsLockLed(bool on) {
hasCapsLockLed = on ? 1 : 0;
}
bool
KeyboardDeviceMock::GetCapsLockLed() {
return hasCapsLockLed == 1;
}