From 99baacbe965f4cb96065be5338ba3d3a661a510b Mon Sep 17 00:00:00 2001 From: Markus Greiner Date: Tue, 28 Apr 2026 17:27:45 +0200 Subject: [PATCH 01/23] adding unit tests for Linux mcompile --- linux/mcompile/keymap/converter.cpp | 78 +++++ linux/mcompile/keymap/deadkey.h | 7 + linux/mcompile/keymap/mc_import_rules.cpp | 3 + linux/mcompile/keymap/mc_import_rules.h | 3 + linux/mcompile/keymap/mc_kmxfile.cpp | 29 ++ linux/mcompile/keymap/mc_kmxfile.h | 5 +- linux/mcompile/keymap/mcompile.cpp | 106 +------ linux/mcompile/keymap/mcompile.h | 15 +- linux/mcompile/keymap/meson.build | 24 +- linux/mcompile/keymap/subprojects/.gitignore | 4 + linux/mcompile/keymap/subprojects/gtest.wrap | 16 + linux/mcompile/keymap/test/meson.build | 12 + linux/mcompile/keymap/test/test_mcompile.cpp | 298 +++++++++++++++++++ 13 files changed, 481 insertions(+), 119 deletions(-) create mode 100644 linux/mcompile/keymap/converter.cpp create mode 100644 linux/mcompile/keymap/subprojects/.gitignore create mode 100644 linux/mcompile/keymap/subprojects/gtest.wrap create mode 100644 linux/mcompile/keymap/test/meson.build create mode 100644 linux/mcompile/keymap/test/test_mcompile.cpp diff --git a/linux/mcompile/keymap/converter.cpp b/linux/mcompile/keymap/converter.cpp new file mode 100644 index 00000000000..0f3a0773aed --- /dev/null +++ b/linux/mcompile/keymap/converter.cpp @@ -0,0 +1,78 @@ +#include "mcompile.h" + +/** + * @brief main function for mcompile for Linux + * @param argc number of commandline arguments + * @param argv pointer to commandline arguments: executable, inputfile, outputfile + * @return 0 on success + */ + + int main(int argc, char* argv[]) { + + + int bDeadkeyConversion = 0; + + if (argc > 1) + bDeadkeyConversion = (strcmp(argv[1], "-d") == 0); // I4552 + + int n = (bDeadkeyConversion ? 2 : 1); + + if (argc < 3 || argc > 4 || (argc - n) != 2) { // I4273// I4273 + printf( + "Usage: \tmcompile [-d] infile.kmx outfile.kmx\n" + " \tmcompile converts a Keyman mnemonic layout to\n" + " \ta positional one based on the currently used \n" + " \tLinux keyboard layout\n" + " \t(-d convert deadkeys to plain keys) \n \n"); // I4552 + + return 1; + } + + // -u option is not available for Linux and macOS + + KMX_CHAR* infile = argv[n]; + KMX_CHAR* outfile = argv[n + 1]; + + printf("mcompile%s \"%s\" \"%s\"\n", bDeadkeyConversion ? " -d" : "", infile, outfile); // I4174 + + // 1. Load the keyman keyboard file + + // 2. For each key on the system layout, determine its output character and perform a + // 1-1 replacement on the keyman keyboard of that character with the base VK + shift + // state. This fixup will transform the char to a vk, which will avoid any issues + // with the key. + // + // + // For each deadkey, we need to determine its possible outputs. Then we generate a VK + // rule for that deadkey, e.g. [K_LBRKT] > dk(c101) + // + // Next, update each rule that references the output from that deadkey to add an extra + // context deadkey at the end of the context match, e.g. 'a' dk(c101) + [K_SPACE] > 'b'. + // This will require a memory layout change for the .kmx file, plus fixups on the + // context+output index offsets + // + // --> virtual character keys + // + // [CTRL ' '] : we look at the character, and replace it in the same way, but merely + // switch the shift state from the VIRTUALCHARKEY to VIRTUALKEY, without changing any + // other properties of the key. + // + // 3. Write the new keyman keyboard file + + LPKMX_KEYBOARD kmxfile; + + if (!KMX_LoadKeyboard(infile, &kmxfile)) { + KMX_LogError(L"Failed to load keyboard (%d)\n", errno); + return 3; + } + + if (KMX_DoConvert(kmxfile, bDeadkeyConversion, argc, (gchar**)argv)) { // I4552F + if(!KMX_SaveKeyboard(kmxfile, outfile)) { + KMX_LogError(L"Failed to save keyboard (%d)\n", errno); + return 3; + } + } + + delete kmxfile; + return 0; +} diff --git a/linux/mcompile/keymap/deadkey.h b/linux/mcompile/keymap/deadkey.h index 5c52768ecf1..be0417cbb93 100644 --- a/linux/mcompile/keymap/deadkey.h +++ b/linux/mcompile/keymap/deadkey.h @@ -5,6 +5,13 @@ #include "mc_import_rules.h" #include +#include + +struct KMX_DeadkeyMapping { // I4353 + KMX_WCHAR deadkey, dkid; + KMX_DWORD shift; + KMX_WORD vk; +}; /** @brief create a Vector of DeadKey containing all combinations of deadkey + character for ALL possible Linux keyboards */ std::vector create_deadkeys_by_basechar(); diff --git a/linux/mcompile/keymap/mc_import_rules.cpp b/linux/mcompile/keymap/mc_import_rules.cpp index 9c376dafd6a..7e5c23a72ec 100644 --- a/linux/mcompile/keymap/mc_import_rules.cpp +++ b/linux/mcompile/keymap/mc_import_rules.cpp @@ -10,6 +10,9 @@ #include #include "mc_kmxfile.h" #include "keymap.h" +#include "deadkey.h" + +extern std::vector KMX_FDeadkeys; // I4353 const int KMX_ShiftStateMap[] = { ISVIRTUALKEY, diff --git a/linux/mcompile/keymap/mc_import_rules.h b/linux/mcompile/keymap/mc_import_rules.h index f955830eac3..8a9eb23df49 100644 --- a/linux/mcompile/keymap/mc_import_rules.h +++ b/linux/mcompile/keymap/mc_import_rules.h @@ -3,6 +3,9 @@ #ifndef MC_IMPORT_RULES_H #define MC_IMPORT_RULES_H +#include +#include "km_types.h" + /** @brief Base class for Deadkey*/ class DeadKey { private: diff --git a/linux/mcompile/keymap/mc_kmxfile.cpp b/linux/mcompile/keymap/mc_kmxfile.cpp index 674da61fa1d..93065f0716e 100644 --- a/linux/mcompile/keymap/mc_kmxfile.cpp +++ b/linux/mcompile/keymap/mc_kmxfile.cpp @@ -5,7 +5,11 @@ */ #include "mc_kmxfile.h" +#include #include +#include +#include + #define CERR_None 0x00000000 #define CERR_CannotAllocateMemory 0x00008004 @@ -582,3 +586,28 @@ FILE* Open_File(const KMX_CHAR* filename, const KMX_CHAR* mode) { return fopen(cpath.c_str(), cmode.c_str()); #endif }; + +#define _countof(a) (sizeof(a) / sizeof(*(a))) + +/** + * @brief print (error) messages + * @param fmt text to print + */ +void KMX_LogError(const wchar_t* fmt, ...) { + wchar_t fmtbuf[256]; + const wchar_t* end = L"\0"; + const wchar_t* nl = L"\n"; + va_list vars; + int j = 0; + + va_start(vars, fmt); + vswprintf(fmtbuf, _countof(fmtbuf), fmt, vars); + fmtbuf[255] = 0; + + do { + putwchar(fmtbuf[j]); + j++; + } while (fmtbuf[j] != *end); + putwchar(*nl); +} + diff --git a/linux/mcompile/keymap/mc_kmxfile.h b/linux/mcompile/keymap/mc_kmxfile.h index f89a240a774..03df9c64098 100644 --- a/linux/mcompile/keymap/mc_kmxfile.h +++ b/linux/mcompile/keymap/mc_kmxfile.h @@ -4,7 +4,7 @@ #include "km_types.h" #include -#include "mcompile.h" +#include #ifndef _KMXFILE_H #define _KMXFILE_H @@ -78,6 +78,9 @@ PKMX_WCHAR KMX_incxstr(PKMX_WCHAR p); /** @brief open a file */ FILE* Open_File(const KMX_CHAR* filename, const KMX_CHAR* mode); +/** @brief print (error) messages */ +void KMX_LogError(const wchar_t* fmt, ...); + #endif // _KMXFILE_H #endif /*MC_KMXFILE_H*/ diff --git a/linux/mcompile/keymap/mcompile.cpp b/linux/mcompile/keymap/mcompile.cpp index f8b96685b99..0c0bd7f569c 100644 --- a/linux/mcompile/keymap/mcompile.cpp +++ b/linux/mcompile/keymap/mcompile.cpp @@ -10,13 +10,13 @@ */ #include "mcompile.h" +#include "keymap.h" +#include "deadkey.h" + const int nr_DK_pairs = 1000; static const int size_DK_array = (nr_DK_pairs + 1) *3; -/** @brief convert mnemonic keyboard layout to positional keyboard layout and translate keyboard */ -KMX_BOOL KMX_DoConvert(LPKMX_KEYBOARD kbd, KMX_BOOL bDeadkeyConversion, gint argc, gchar* argv[]); - /** @brief Collect the key data, translate it to kmx and append to the existing keyboard */ bool KMX_ImportRules(LPKMX_KEYBOARD kp, vec_dword_3D& all_vector, GdkKeymap** keymap, std::vector* KMX_FDeadkeys, KMX_BOOL bDeadkeyConversion); // I4353 // I4327 @@ -25,85 +25,6 @@ int KMX_GetDeadkeys(vec_dword_2D& dk_Table, KMX_WORD deadkey, std::vector KMX_FDeadkeys; // I4353 -#define _countof(a) (sizeof(a) / sizeof(*(a))) - -/** - * @brief main function for mcompile for Linux - * @param argc number of commandline arguments - * @param argv pointer to commandline arguments: executable, inputfile, outputfile - * @return 0 on success - */ - - int main(int argc, char* argv[]) { - - - int bDeadkeyConversion = 0; - - if (argc > 1) - bDeadkeyConversion = (strcmp(argv[1], "-d") == 0); // I4552 - - int n = (bDeadkeyConversion ? 2 : 1); - - if (argc < 3 || argc > 4 || (argc - n) != 2) { // I4273// I4273 - printf( - "Usage: \tmcompile [-d] infile.kmx outfile.kmx\n" - " \tmcompile converts a Keyman mnemonic layout to\n" - " \ta positional one based on the currently used \n" - " \tLinux keyboard layout\n" - " \t(-d convert deadkeys to plain keys) \n \n"); // I4552 - - return 1; - } - - // -u option is not available for Linux and macOS - - KMX_CHAR* infile = argv[n]; - KMX_CHAR* outfile = argv[n + 1]; - - printf("mcompile%s \"%s\" \"%s\"\n", bDeadkeyConversion ? " -d" : "", infile, outfile); // I4174 - - // 1. Load the keyman keyboard file - - // 2. For each key on the system layout, determine its output character and perform a - // 1-1 replacement on the keyman keyboard of that character with the base VK + shift - // state. This fixup will transform the char to a vk, which will avoid any issues - // with the key. - // - // - // For each deadkey, we need to determine its possible outputs. Then we generate a VK - // rule for that deadkey, e.g. [K_LBRKT] > dk(c101) - // - // Next, update each rule that references the output from that deadkey to add an extra - // context deadkey at the end of the context match, e.g. 'a' dk(c101) + [K_SPACE] > 'b'. - // This will require a memory layout change for the .kmx file, plus fixups on the - // context+output index offsets - // - // --> virtual character keys - // - // [CTRL ' '] : we look at the character, and replace it in the same way, but merely - // switch the shift state from the VIRTUALCHARKEY to VIRTUALKEY, without changing any - // other properties of the key. - // - // 3. Write the new keyman keyboard file - - LPKMX_KEYBOARD kmxfile; - - if (!KMX_LoadKeyboard(infile, &kmxfile)) { - KMX_LogError(L"Failed to load keyboard (%d)\n", errno); - return 3; - } - - if (KMX_DoConvert(kmxfile, bDeadkeyConversion, argc, (gchar**)argv)) { // I4552F - if(!KMX_SaveKeyboard(kmxfile, outfile)) { - KMX_LogError(L"Failed to save keyboard (%d)\n", errno); - return 3; - } - } - - delete kmxfile; - return 0; -} - // Map of all shift states that we will work with const KMX_DWORD VKShiftState[] = {0, K_SHIFTFLAG, LCTRLFLAG | RALTFLAG, K_SHIFTFLAG | LCTRLFLAG | RALTFLAG, 0xFFFF}; @@ -555,24 +476,3 @@ int KMX_GetDeadkeys(vec_dword_2D& dk_Table, KMX_WORD deadkey, std::vector -#include "keymap.h" -#include "deadkey.h" +#include #include "mc_kmxfile.h" -struct KMX_DeadkeyMapping { // I4353 - KMX_WCHAR deadkey, dkid; - KMX_DWORD shift; - KMX_WORD vk; -}; - -extern std::vector KMX_FDeadkeys; // I4353 - -/** @brief print (error) messages */ -void KMX_LogError(const wchar_t* fmt, ...); +/** @brief convert mnemonic keyboard layout to positional keyboard layout and translate keyboard */ +KMX_BOOL KMX_DoConvert(LPKMX_KEYBOARD kbd, KMX_BOOL bDeadkeyConversion, gint argc, gchar* argv[]); #endif /*MCOMPILE_H*/ diff --git a/linux/mcompile/keymap/meson.build b/linux/mcompile/keymap/meson.build index af9c84017e6..e1f7085e4b6 100644 --- a/linux/mcompile/keymap/meson.build +++ b/linux/mcompile/keymap/meson.build @@ -9,11 +9,15 @@ project( gtk = dependency('gtk+-3.0', version: '>= 2.4') xkb = dependency('xkbcommon') +giomm_dep = dependency('giomm-2.4') +glibmm_dep = dependency('glibmm-2.4') + deps = [gtk, xkb] subdir('resources') cpp_files = files( + 'converter.cpp', 'keymap.cpp', 'deadkey.cpp', 'mcompile.cpp', @@ -23,13 +27,27 @@ cpp_files = files( '../../../common/cpp/utfcodec.cpp', ) -comon_include_dir = [ - include_directories('../../../common/include') +test_files = files( + 'keymap.cpp', + 'deadkey.cpp', + 'mc_kmxfile.cpp', + 'mcompile.cpp', + 'mc_import_rules.cpp', + '../../../common/cpp/km_u16.cpp', + '../../../common/cpp/utfcodec.cpp', +) + +common_include_dir = [ + include_directories('../../../common/include','.'), ] mcompile = executable( 'mcompile', sources: [cpp_files], dependencies: deps, - include_directories : comon_include_dir + include_directories : common_include_dir ) + +gtest = subproject('gtest') + +subdir('test') diff --git a/linux/mcompile/keymap/subprojects/.gitignore b/linux/mcompile/keymap/subprojects/.gitignore new file mode 100644 index 00000000000..88fb1651218 --- /dev/null +++ b/linux/mcompile/keymap/subprojects/.gitignore @@ -0,0 +1,4 @@ +/*.zip +/*.tgz +/packagecache +/googletest-* diff --git a/linux/mcompile/keymap/subprojects/gtest.wrap b/linux/mcompile/keymap/subprojects/gtest.wrap new file mode 100644 index 00000000000..9902a4f7ecd --- /dev/null +++ b/linux/mcompile/keymap/subprojects/gtest.wrap @@ -0,0 +1,16 @@ +[wrap-file] +directory = googletest-1.17.0 +source_url = https://github.com/google/googletest/archive/refs/tags/v1.17.0.tar.gz +source_filename = googletest-1.17.0.tar.gz +source_hash = 65fab701d9829d38cb77c14acdc431d2108bfdbf8979e40eb8ae567edf10b27c +patch_filename = gtest_1.17.0-4_patch.zip +patch_url = https://wrapdb.mesonbuild.com/v2/gtest_1.17.0-4/get_patch +patch_hash = 3abf7662d09db706453a5b064a1e914678c74b9d9b0b19382747ca561d0d8750 +source_fallback_url = https://github.com/mesonbuild/wrapdb/releases/download/gtest_1.17.0-4/googletest-1.17.0.tar.gz +wrapdb_version = 1.17.0-4 + +[provide] +gtest = gtest_dep +gtest_main = gtest_main_dep +gmock = gmock_dep +gmock_main = gmock_main_dep diff --git a/linux/mcompile/keymap/test/meson.build b/linux/mcompile/keymap/test/meson.build new file mode 100644 index 00000000000..633fa998703 --- /dev/null +++ b/linux/mcompile/keymap/test/meson.build @@ -0,0 +1,12 @@ + +gtest_main_dep = gtest.get_variable('gtest_main_dep') + +keysymtest = executable('keysymtest', [ + 'test_mcompile.cpp', test_files, + ], + sources: [test_files], + include_directories: [common_include_dir], + dependencies: [ gtest_main_dep, gtk, xkb, giomm_dep, glibmm_dep ], + ) + +test('keysymtest', keysymtest) diff --git a/linux/mcompile/keymap/test/test_mcompile.cpp b/linux/mcompile/keymap/test/test_mcompile.cpp new file mode 100644 index 00000000000..8c3cb8b3467 --- /dev/null +++ b/linux/mcompile/keymap/test/test_mcompile.cpp @@ -0,0 +1,298 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "mcompile.h" +#include "keymap.h" + +class KeyboardConversionTest : public ::testing::Test { + +public: + +protected: + GdkKeymap* test_keymap; + GdkDisplay* test_display; + gint argc = 0; + char** argv = nullptr; + Glib::ustring default_layout; + +private: + void initialize_keymap() { + gdk_init(&argc, &argv); + test_display = nullptr; + test_keymap = nullptr; + test_display = gdk_display_get_default(); + ASSERT_NE(test_display, nullptr) << "ERROR: can't get display"; + test_keymap = gdk_keymap_get_for_display(test_display); + ASSERT_NE(test_keymap, nullptr) << "ERROR: Can't get keymap"; + } + + + void get_default_layout() { + std::vector> sources; + + Gio::init(); + auto settings = Gio::Settings::create("org.gnome.desktop.input-sources"); + Glib::VariantBase base; + settings->get_value("sources", base); + using SourcesVariant = Glib::Variant>>; + auto variant = Glib::VariantBase::cast_dynamic(base); + sources = variant.get(); + + ASSERT_FALSE(sources.empty()) << "ERROR: No input sources found"; + + const auto& [type, layout] = sources[0]; + + std::cout << "Default input source type: " << type << ", layout: " << layout << std::endl; + ASSERT_EQ(type, "xkb"); + if (layout == "de" || layout == "us") { + default_layout = layout; + } + } + + void SetUp() override { + initialize_keymap(); + get_default_layout(); + } + + void TearDown() override { + default_layout.clear(); + argc = 0; + free(argv); + argv = nullptr; + if (test_display) { + gdk_display_close(test_display); + test_display = nullptr; + } + } + + +}; + +guint keycodes[] = { 38, 56, 54, 40, 26, 41, 42, 43, 31, 44, 45, 46, 58, 57, 32, + 33, 24, 27, 39, 28, 30, 55, 25, 53, 29, 52, 19, 10, 11, 12, + 13, 14, 15, 16, 17, 18, 65, 49, 20, 21, 34, 35, 51, 47, 48, + 59, 60, 61, 123, 94}; + + +TEST_F(KeyboardConversionTest, KMXgetKeyValUnderlyingFromKeyCodeUnderlyingBase) { + + if (default_layout != "us") { + GTEST_SKIP() << "Default layout is not US."; + } + + KMX_DWORD expected_chars[] = {u'a', u'b', u'c', u'd', u'e', u'f', u'g', u'h', u'i', + u'j', u'k', u'l', u'm', u'n', u'o', u'p', u'q', u'r', + u's', u't', u'u', u'v', u'w', u'x', u'y', u'z', u'0', + u'1', u'2', u'3', u'4', u'5', u'6', u'7', u'8', u'9', + u' ', u'`', u'-', u'=', u'[', u']', u'\\', u';', u'\'', + u',', u'.', u'/', u'\000', u'<'}; + + KMX_WCHAR deadkey; + for (uint k = 0; k < sizeof(keycodes)/sizeof(keycodes[0]); k++) { + KMX_WCHAR result = KMX_get_KeyValUnderlying_From_KeyCodeUnderlying( + test_keymap, + keycodes[k], + 0, + &deadkey + ); + EXPECT_EQ(result, expected_chars[k]) << "Failed for keycode: " << keycodes[k]; + } +} + + +TEST_F(KeyboardConversionTest, KMXgetKeyValUnderlyingFromKeyCodeUnderlyingShift) { + // Test with valid key code - should return character or deadkey + + if (default_layout != "us") { + GTEST_SKIP() << "Default layout is not US."; + } + KMX_DWORD expected_chars[] = { u'A', u'B', u'C', u'D', u'E', u'F', u'G', u'H', u'I', + u'J', u'K', u'L', u'M', u'N', u'O', u'P', u'Q', u'R', + u'S', u'T', u'U', u'V', u'W', u'X', u'Y', u'Z', u')', + u'!', u'@', u'#', u'$', u'%', u'^', u'&', u'*', u'(', + u' ', u'~', u'_', u'+', u'{', u'}', u'|', u':', u'"', + u'<', u'>', u'?', u'\000', u'>'}; + + KMX_WCHAR deadkey; + for (uint k = 0; k < sizeof(keycodes)/sizeof(keycodes[0]); k++) { + KMX_WCHAR result = KMX_get_KeyValUnderlying_From_KeyCodeUnderlying( + test_keymap, + keycodes[k], + K_SHIFTFLAG, + &deadkey + ); + EXPECT_EQ(result, expected_chars[k]) << "Failed for keycode: " << keycodes[k] << " with shift state"; + } +} + + +TEST_F(KeyboardConversionTest, KMXgetKeyValUnderlyingFromKeyCodeUnderlyingLCTRLFLAGRALTFLAG) { + // Test with valid key code - should return character or deadkey + + if (default_layout != "us") { + GTEST_SKIP() << "Default layout is not US."; + } + + KMX_DWORD expected_chars[] = {u'a', u'b', u'c', u'd', u'e', u'f', u'g', u'h', u'i', u'j', u'k', + u'l', u'm', u'n', u'o', u'p', u'q', u'r', u's', u't', u'u', u'v', + u'w', u'x', u'y', u'z', u'0', u'1', u'2', u'3', u'4', u'5', u'6', + u'7', u'8', u'9', u'\000', u'`', u'-', u'=', u'[', u']', u'\\', + u';', u'\'', u',', u'.', u'/', u'\000', u'|'}; + KMX_WCHAR deadkey; + + for (uint k = 0; k < sizeof(keycodes)/sizeof(keycodes[0]); k++) { + KMX_WCHAR result = KMX_get_KeyValUnderlying_From_KeyCodeUnderlying( + test_keymap, + keycodes[k], + LCTRLFLAG | RALTFLAG, + &deadkey + ); + EXPECT_EQ(result, expected_chars[k]) << "Failed for keycode: " << keycodes[k]; + } +} + + +TEST_F(KeyboardConversionTest, GetKeySymFromUnderlyingKeyCodeShiftLCTRLFLAGRALTFLAG) { + if (default_layout != "us") { + GTEST_SKIP() << "Default layout is not US."; + } + + KMX_DWORD expected_chars[] = {u'A', u'B', u'C', u'D', u'E', u'F', u'G', u'H', u'I', u'J', u'K', + u'L', u'M', u'N', u'O', u'P', u'Q', u'R', u'S', u'T', u'U', u'V', + u'W', u'X', u'Y', u'Z', u')', u'!', u'@', u'#', u'$', u'%', u'^', + u'&', u'*', u'(', u'\000', u'~', u'_', u'+', u'{', u'}', u'|', + u':', u'"', u'<', u'>', u'?', u'\000', u'¦'}; + + KMX_WCHAR deadkey; + + for (uint k = 0; k < sizeof(keycodes)/sizeof(keycodes[0]); k++) { + KMX_WCHAR result = KMX_get_KeyValUnderlying_From_KeyCodeUnderlying( + test_keymap, + keycodes[k], + K_SHIFTFLAG | LCTRLFLAG | RALTFLAG, + &deadkey + ); + EXPECT_EQ(result, expected_chars[k]) << "Failed for keycode: " << keycodes[k]; + } +} + + +TEST_F(KeyboardConversionTest, DeGetKeySymFromUnderlyingKeyCode) { + if (default_layout != "de") { + GTEST_SKIP() << "Default layout is not US."; + } + + KMX_DWORD expected_chars[] = {u'a', u'b', u'c', u'd', u'e', u'f', u'g', u'h', u'i', u'j', + u'k', u'l', u'm', u'n', u'o', u'p', u'q', u'r', u's', u't', + u'u', u'v', u'w', u'x', u'z', u'y', u'0', u'1', u'2', u'3', + u'4', u'5', u'6', u'7', u'8', u'9', u' ', u'\xffff', u'ß', + u'\xffff', u'ü', u'+', u'#', u'ö', u'ä', u',', u'.', u'-', + u'\000', u'<', }; + + KMX_WCHAR deadkey; + + std::cout << "Testing KMX_get_KeyValUnderlying_From_KeyCodeUnderlying with base shift state" << std::endl; + for (uint k = 0; k < sizeof(keycodes)/sizeof(keycodes[0]); k++) { + KMX_WCHAR result = KMX_get_KeyValUnderlying_From_KeyCodeUnderlying( + test_keymap, + keycodes[k], + 0, // Base shift state + &deadkey + ); + EXPECT_EQ(result, expected_chars[k]) << "Failed for keycode: " << keycodes[k]; + } +} + + +TEST_F(KeyboardConversionTest, DeKMXgetKeyValUnderlyingFromKeyCodeUnderlyingShift) { + if (default_layout != "de") { + GTEST_SKIP() << "Default layout is not US."; + } + + KMX_DWORD expected_chars[] = { u'A', u'B', u'C', u'D', u'E', u'F', u'G', u'H', u'I', + u'J', u'K', u'L', u'M', u'N', u'O', u'P', u'Q', u'R', + u'S', u'T', u'U', u'V', u'W', u'X', u'Z', u'Y', u'=', + u'!', u'"', u'§', u'$', u'%', u'&', u'/', u'(', u')', + u' ', u'°', u'?', u'\xffff', u'Ü', u'*', u'\'', u'Ö', + u'Ä', u';', u':', u'_', u'\000', u'>', }; + + KMX_WCHAR deadkey; + + for (uint k = 0; k < sizeof(keycodes)/sizeof(keycodes[0]); k++) { + KMX_WCHAR result = KMX_get_KeyValUnderlying_From_KeyCodeUnderlying( + test_keymap, + keycodes[k], + K_SHIFTFLAG, + &deadkey + ); + EXPECT_EQ(result, expected_chars[k]) << "Failed for keycode: " << keycodes[k] << " with shift state"; + } +} + + +TEST_F(KeyboardConversionTest, DeKMXgetKeyValUnderlyingFromKeyCodeUnderlyingLCTRLFLAGRALTFLAG) { + // Test with valid key code - should return character or deadkey + if (default_layout != "de") { + GTEST_SKIP() << "Default layout is not US."; + } + + /*KMX_DWORD expected_chars[] = {u'æ', u'\xad2', u'¢', u'ð', u'€', u'ǰ', u'ο', u'ʱ', u'ࣽ', u'\xffff', + u'\x3a2', u'Ƴ', u'µ', u'\xad3', u'ø', u'þ', u'@', u'¶', u'ſ', u'μ', + u'ࣾ', u'૾', u'ſ', u'«', u'ࣻ', u'»', u'}', u'¹', u'²', u'³', u'¼', u'½', + u'¬', u'{', u'[', u']', u'\000', u'′', u'\\', u'\xffff', u'\xffff', + u'~', u'\xad1', u'\xffff', u'\xffff', u'·', u'…', u'પ', u'\000', u'|',}; + */ + KMX_DWORD expected_chars[] = {u'æ', u'\xfffe', u'¢', u'ð', u'\xfffe', u'\xfffe', u'\xfffe', u'\xfffe', + u'\xfffe', u'\xffff', u'\xfffe', u'\xfffe', u'µ', u'\xfffe', u'ø', u'þ', + u'@', u'¶', u'\xfffe', u'\xfffe', u'\xfffe', u'\xfffe', u'\xfffe', u'«', + u'\xfffe', u'»', u'}', u'¹', u'²', u'³', u'¼', u'½', u'¬', u'{', u'[', + u']', u'\000', u'\xfffe', u'\\', u'\xffff', u'\xffff', u'~', u'\xfffe', + u'\xffff', u'\xffff', u'·', u'\xfffe', u'\xfffe', u'\000', u'|', }; + + KMX_WCHAR deadkey; + + for (uint k = 0; k < sizeof(keycodes)/sizeof(keycodes[0]); k++) { + KMX_WCHAR result = KMX_get_KeyValUnderlying_From_KeyCodeUnderlying( + test_keymap, + keycodes[k], + LCTRLFLAG | RALTFLAG, + &deadkey + ); + EXPECT_EQ(result, expected_chars[k]) << "Failed for keycode: " << keycodes[k]; + } +} + + +TEST_F(KeyboardConversionTest, DeGetKeySymFromUnderlyingKeyCodeShiftLCTRLFLAGRALTFLAG) { + if (default_layout != "de") { + GTEST_SKIP() << "Default layout is not US."; + } + + KMX_DWORD expected_chars[] = {u'Æ', u'\xfffe', u'©', u'Ð', u'\xfffe', u'ª', u'\xfffe', + u'\xfffe', u'\xfffe', u'\xffff', u'&', u'\xfffe', u'º', + u'\xfffe', u'Ø', u'Þ', u'\xfffe', u'®', u'\xfffe', u'\xfffe', + u'\xfffe', u'\xfffe', u'§', u'\xfffe', u'¥', u'\xfffe', u'°', + u'¡', u'\xfffe', u'£', u'¤', u'\xfffe', u'\xfffe', u'\xfffe', + u'\xfffe', u'±', u'\000', u'\xfffe', u'¿', u'\xffff', u'\xffff', + u'¯', u'\xffff', u'\xffff', u'\xffff', u'×', u'÷', u'\xfffe', + u'\000', u'\xffff', }; + + KMX_WCHAR deadkey; + + for (uint k = 0; k < sizeof(keycodes)/sizeof(keycodes[0]); k++) { + KMX_WCHAR result = KMX_get_KeyValUnderlying_From_KeyCodeUnderlying( + test_keymap, + keycodes[k], + K_SHIFTFLAG | LCTRLFLAG | RALTFLAG, + &deadkey + ); + EXPECT_EQ(result, expected_chars[k]) << "Failed for keycode: " << keycodes[k]; + } +} From 77acb6f71daedf9424b44539bcc3fa6722c74dc3 Mon Sep 17 00:00:00 2001 From: Markus Greiner Date: Tue, 28 Apr 2026 18:50:42 +0200 Subject: [PATCH 02/23] adding dependency to libglibmm-2.4-dev --- linux/debian/control | 1 + 1 file changed, 1 insertion(+) diff --git a/linux/debian/control b/linux/debian/control index fa4d0b760ed..fa54793b289 100644 --- a/linux/debian/control +++ b/linux/debian/control @@ -13,6 +13,7 @@ Build-Depends: gir1.2-webkit2-4.1, ibus, libevdev-dev, + libglibmm-2.4-dev libgtk-3-dev, libibus-1.0-dev (>= 1.2), libicu-dev, From c0403148662a3eea6e2520f4431ec6ba1dc6c0aa Mon Sep 17 00:00:00 2001 From: Markus Greiner Date: Tue, 28 Apr 2026 18:52:31 +0200 Subject: [PATCH 03/23] adding dependency to libglibmm-2.4-dev typo --- linux/debian/control | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/linux/debian/control b/linux/debian/control index fa54793b289..b939901472a 100644 --- a/linux/debian/control +++ b/linux/debian/control @@ -13,7 +13,7 @@ Build-Depends: gir1.2-webkit2-4.1, ibus, libevdev-dev, - libglibmm-2.4-dev + libglibmm-2.4-dev, libgtk-3-dev, libibus-1.0-dev (>= 1.2), libicu-dev, From 0ed8eb1e12616d124b0d9082513fc9ea6ed6cc07 Mon Sep 17 00:00:00 2001 From: Markus Greiner Date: Tue, 28 Apr 2026 20:04:51 +0200 Subject: [PATCH 04/23] Prevent running unit tests on Wayland This is temporary, when the transition to xkblibcommon is done, wayland will be available. --- linux/mcompile/keymap/test/test_mcompile.cpp | 21 ++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/linux/mcompile/keymap/test/test_mcompile.cpp b/linux/mcompile/keymap/test/test_mcompile.cpp index 8c3cb8b3467..e9229305415 100644 --- a/linux/mcompile/keymap/test/test_mcompile.cpp +++ b/linux/mcompile/keymap/test/test_mcompile.cpp @@ -3,6 +3,7 @@ #include #include #include +#include #include #include #include @@ -21,6 +22,7 @@ class KeyboardConversionTest : public ::testing::Test { gint argc = 0; char** argv = nullptr; Glib::ustring default_layout; + bool onX11 = false; private: void initialize_keymap() { @@ -54,11 +56,15 @@ class KeyboardConversionTest : public ::testing::Test { if (layout == "de" || layout == "us") { default_layout = layout; } + } void SetUp() override { initialize_keymap(); get_default_layout(); + if (!GDK_IS_X11_DISPLAY(test_display)) { + GTEST_SKIP() << "Not running on X11 display, skipping tests that require X11 keymap functionality."; + } } void TearDown() override { @@ -70,6 +76,7 @@ class KeyboardConversionTest : public ::testing::Test { gdk_display_close(test_display); test_display = nullptr; } + onX11 = false; } @@ -186,7 +193,7 @@ TEST_F(KeyboardConversionTest, GetKeySymFromUnderlyingKeyCodeShiftLCTRLFLAGRALTF TEST_F(KeyboardConversionTest, DeGetKeySymFromUnderlyingKeyCode) { if (default_layout != "de") { - GTEST_SKIP() << "Default layout is not US."; + GTEST_SKIP() << "Default layout is not DE."; } KMX_DWORD expected_chars[] = {u'a', u'b', u'c', u'd', u'e', u'f', u'g', u'h', u'i', u'j', @@ -213,7 +220,7 @@ TEST_F(KeyboardConversionTest, DeGetKeySymFromUnderlyingKeyCode) { TEST_F(KeyboardConversionTest, DeKMXgetKeyValUnderlyingFromKeyCodeUnderlyingShift) { if (default_layout != "de") { - GTEST_SKIP() << "Default layout is not US."; + GTEST_SKIP() << "Default layout is not DE."; } KMX_DWORD expected_chars[] = { u'A', u'B', u'C', u'D', u'E', u'F', u'G', u'H', u'I', @@ -240,15 +247,9 @@ TEST_F(KeyboardConversionTest, DeKMXgetKeyValUnderlyingFromKeyCodeUnderlyingShif TEST_F(KeyboardConversionTest, DeKMXgetKeyValUnderlyingFromKeyCodeUnderlyingLCTRLFLAGRALTFLAG) { // Test with valid key code - should return character or deadkey if (default_layout != "de") { - GTEST_SKIP() << "Default layout is not US."; + GTEST_SKIP() << "Default layout is not DE."; } - /*KMX_DWORD expected_chars[] = {u'æ', u'\xad2', u'¢', u'ð', u'€', u'ǰ', u'ο', u'ʱ', u'ࣽ', u'\xffff', - u'\x3a2', u'Ƴ', u'µ', u'\xad3', u'ø', u'þ', u'@', u'¶', u'ſ', u'μ', - u'ࣾ', u'૾', u'ſ', u'«', u'ࣻ', u'»', u'}', u'¹', u'²', u'³', u'¼', u'½', - u'¬', u'{', u'[', u']', u'\000', u'′', u'\\', u'\xffff', u'\xffff', - u'~', u'\xad1', u'\xffff', u'\xffff', u'·', u'…', u'પ', u'\000', u'|',}; - */ KMX_DWORD expected_chars[] = {u'æ', u'\xfffe', u'¢', u'ð', u'\xfffe', u'\xfffe', u'\xfffe', u'\xfffe', u'\xfffe', u'\xffff', u'\xfffe', u'\xfffe', u'µ', u'\xfffe', u'ø', u'þ', u'@', u'¶', u'\xfffe', u'\xfffe', u'\xfffe', u'\xfffe', u'\xfffe', u'«', @@ -272,7 +273,7 @@ TEST_F(KeyboardConversionTest, DeKMXgetKeyValUnderlyingFromKeyCodeUnderlyingLCTR TEST_F(KeyboardConversionTest, DeGetKeySymFromUnderlyingKeyCodeShiftLCTRLFLAGRALTFLAG) { if (default_layout != "de") { - GTEST_SKIP() << "Default layout is not US."; + GTEST_SKIP() << "Default layout is not DE."; } KMX_DWORD expected_chars[] = {u'Æ', u'\xfffe', u'©', u'Ð', u'\xfffe', u'ª', u'\xfffe', From f309d902524b31bc975b1a4a8c1c892be1a1a95f Mon Sep 17 00:00:00 2001 From: Markus Greiner Date: Tue, 5 May 2026 22:54:02 +0200 Subject: [PATCH 05/23] incorporating review results for adding unit tests - adding header files - renaming files and methods - restructuring meson build --- linux/mcompile/keymap/deadkey.h | 5 ++++ linux/mcompile/keymap/keymap.cpp | 2 +- linux/mcompile/keymap/keymap.h | 6 +++++ .../keymap/{converter.cpp => main.cpp} | 25 +++++++++++++------ linux/mcompile/keymap/mc_import_rules.h | 6 +++++ linux/mcompile/keymap/mc_kmxfile.cpp | 2 +- linux/mcompile/keymap/mc_kmxfile.h | 6 +++++ linux/mcompile/keymap/meson.build | 4 +-- .../{test_mcompile.cpp => keymap.test.cpp} | 12 +++++++-- linux/mcompile/keymap/test/meson.build | 7 +++--- 10 files changed, 57 insertions(+), 18 deletions(-) rename linux/mcompile/keymap/{converter.cpp => main.cpp} (82%) rename linux/mcompile/keymap/test/{test_mcompile.cpp => keymap.test.cpp} (97%) diff --git a/linux/mcompile/keymap/deadkey.h b/linux/mcompile/keymap/deadkey.h index be0417cbb93..a6f358eb987 100644 --- a/linux/mcompile/keymap/deadkey.h +++ b/linux/mcompile/keymap/deadkey.h @@ -1,3 +1,8 @@ +/* + * Keyman is copyright (C) 2004 - 2026 SIL International. MIT License. + * + * Mnemonic layout support for Linux + */ #pragma once #ifndef DEADKEY_H diff --git a/linux/mcompile/keymap/keymap.cpp b/linux/mcompile/keymap/keymap.cpp index f052a32a8f6..b9047a334bb 100644 --- a/linux/mcompile/keymap/keymap.cpp +++ b/linux/mcompile/keymap/keymap.cpp @@ -1,5 +1,5 @@ /* - * Keyman is copyright (C) 2004 - 2024 SIL International. MIT License. + * Keyman is copyright (C) 2004 - 2026 SIL International. MIT License. * * Mnemonic layout support for Linux * diff --git a/linux/mcompile/keymap/keymap.h b/linux/mcompile/keymap/keymap.h index 74e67352b0a..959fd53f1d2 100644 --- a/linux/mcompile/keymap/keymap.h +++ b/linux/mcompile/keymap/keymap.h @@ -1,3 +1,9 @@ +/* + * Keyman is copyright (C) 2004 - 2026 SIL International. MIT License. + * + * Mnemonic layout support for Linux + */ + #pragma once #ifndef KEYMAP_H #define KEYMAP_H diff --git a/linux/mcompile/keymap/converter.cpp b/linux/mcompile/keymap/main.cpp similarity index 82% rename from linux/mcompile/keymap/converter.cpp rename to linux/mcompile/keymap/main.cpp index 0f3a0773aed..b5417ada9e7 100644 --- a/linux/mcompile/keymap/converter.cpp +++ b/linux/mcompile/keymap/main.cpp @@ -1,3 +1,11 @@ +/* + * Keyman is copyright (C) 2004 - 2026 SIL International. MIT License. + * + * Created by Markus-SWAG on 2026-05-05 + * + * Mnemonic layout support for Linux + */ + #include "mcompile.h" /** @@ -7,23 +15,23 @@ * @return 0 on success */ - int main(int argc, char* argv[]) { +int main(int argc, char* argv[]) { int bDeadkeyConversion = 0; if (argc > 1) - bDeadkeyConversion = (strcmp(argv[1], "-d") == 0); // I4552 + bDeadkeyConversion = (strcmp(argv[1], "-d") == 0); int n = (bDeadkeyConversion ? 2 : 1); - if (argc < 3 || argc > 4 || (argc - n) != 2) { // I4273// I4273 + if (argc < 3 || argc > 4 || (argc - n) != 2) { printf( "Usage: \tmcompile [-d] infile.kmx outfile.kmx\n" " \tmcompile converts a Keyman mnemonic layout to\n" " \ta positional one based on the currently used \n" " \tLinux keyboard layout\n" - " \t(-d convert deadkeys to plain keys) \n \n"); // I4552 + " \t(-d convert deadkeys to plain keys) \n \n"); return 1; } @@ -33,7 +41,7 @@ KMX_CHAR* infile = argv[n]; KMX_CHAR* outfile = argv[n + 1]; - printf("mcompile%s \"%s\" \"%s\"\n", bDeadkeyConversion ? " -d" : "", infile, outfile); // I4174 + printf("mcompile%s \"%s\" \"%s\"\n", bDeadkeyConversion ? " -d" : "", infile, outfile); // 1. Load the keyman keyboard file @@ -59,20 +67,21 @@ // // 3. Write the new keyman keyboard file - LPKMX_KEYBOARD kmxfile; + LPKMX_KEYBOARD kmxfile = nullptr; if (!KMX_LoadKeyboard(infile, &kmxfile)) { KMX_LogError(L"Failed to load keyboard (%d)\n", errno); + delete kmxfile; return 3; } - if (KMX_DoConvert(kmxfile, bDeadkeyConversion, argc, (gchar**)argv)) { // I4552F + if (KMX_DoConvert(kmxfile, bDeadkeyConversion, argc, (gchar**)argv)) { if(!KMX_SaveKeyboard(kmxfile, outfile)) { KMX_LogError(L"Failed to save keyboard (%d)\n", errno); + delete kmxfile; return 3; } } - delete kmxfile; return 0; } diff --git a/linux/mcompile/keymap/mc_import_rules.h b/linux/mcompile/keymap/mc_import_rules.h index 8a9eb23df49..1a924a7f485 100644 --- a/linux/mcompile/keymap/mc_import_rules.h +++ b/linux/mcompile/keymap/mc_import_rules.h @@ -1,3 +1,9 @@ +/* + * Keyman is copyright (C) 2004 - 2026 SIL International. MIT License. + * + * Mnemonic layout support for Linux + */ + #pragma once #ifndef MC_IMPORT_RULES_H diff --git a/linux/mcompile/keymap/mc_kmxfile.cpp b/linux/mcompile/keymap/mc_kmxfile.cpp index 93065f0716e..f5fcc09f538 100644 --- a/linux/mcompile/keymap/mc_kmxfile.cpp +++ b/linux/mcompile/keymap/mc_kmxfile.cpp @@ -1,5 +1,5 @@ /* - * Keyman is copyright (C) 2004 - 2024 SIL International. MIT License. + * Keyman is copyright (C) 2004 - 2026 SIL International. MIT License. * * Mnemonic layout support for Linux */ diff --git a/linux/mcompile/keymap/mc_kmxfile.h b/linux/mcompile/keymap/mc_kmxfile.h index 03df9c64098..25403162cff 100644 --- a/linux/mcompile/keymap/mc_kmxfile.h +++ b/linux/mcompile/keymap/mc_kmxfile.h @@ -1,3 +1,9 @@ +/* + * Keyman is copyright (C) 2004 - 2026 SIL International. MIT License. + * + * Mnemonic layout support for Linux + */ + #pragma once #ifndef MC_KMXFILE_H #define MC_KMXFILE_H diff --git a/linux/mcompile/keymap/meson.build b/linux/mcompile/keymap/meson.build index e1f7085e4b6..d49dea4adc7 100644 --- a/linux/mcompile/keymap/meson.build +++ b/linux/mcompile/keymap/meson.build @@ -17,7 +17,7 @@ deps = [gtk, xkb] subdir('resources') cpp_files = files( - 'converter.cpp', + 'main.cpp', 'keymap.cpp', 'deadkey.cpp', 'mcompile.cpp', @@ -48,6 +48,4 @@ mcompile = executable( include_directories : common_include_dir ) -gtest = subproject('gtest') - subdir('test') diff --git a/linux/mcompile/keymap/test/test_mcompile.cpp b/linux/mcompile/keymap/test/keymap.test.cpp similarity index 97% rename from linux/mcompile/keymap/test/test_mcompile.cpp rename to linux/mcompile/keymap/test/keymap.test.cpp index e9229305415..59c4f1ee9c1 100644 --- a/linux/mcompile/keymap/test/test_mcompile.cpp +++ b/linux/mcompile/keymap/test/keymap.test.cpp @@ -1,3 +1,11 @@ +/* + * Keyman is copyright (C) 2004 - 2026 SIL International. MIT License. + * + * Created by Markus-SWAG on 2026-05-05 + * + * Mnemonic layout support for Linux + */ + #include #include #include @@ -36,7 +44,7 @@ class KeyboardConversionTest : public ::testing::Test { } - void get_default_layout() { + void retrieve_default_layout() { std::vector> sources; Gio::init(); @@ -61,7 +69,7 @@ class KeyboardConversionTest : public ::testing::Test { void SetUp() override { initialize_keymap(); - get_default_layout(); + retrieve_default_layout(); if (!GDK_IS_X11_DISPLAY(test_display)) { GTEST_SKIP() << "Not running on X11 display, skipping tests that require X11 keymap functionality."; } diff --git a/linux/mcompile/keymap/test/meson.build b/linux/mcompile/keymap/test/meson.build index 633fa998703..7aacdb97946 100644 --- a/linux/mcompile/keymap/test/meson.build +++ b/linux/mcompile/keymap/test/meson.build @@ -1,12 +1,13 @@ +gtest = subproject('gtest') gtest_main_dep = gtest.get_variable('gtest_main_dep') -keysymtest = executable('keysymtest', [ - 'test_mcompile.cpp', test_files, +keymaptest = executable('keymaptest', [ + 'keymap.test.cpp', test_files, ], sources: [test_files], include_directories: [common_include_dir], dependencies: [ gtest_main_dep, gtk, xkb, giomm_dep, glibmm_dep ], ) -test('keysymtest', keysymtest) +test('keymaptest', keymaptest) From 8bd47e4e6372d958debe503820f370842a03cb6b Mon Sep 17 00:00:00 2001 From: Markus Greiner Date: Wed, 6 May 2026 17:48:13 +0200 Subject: [PATCH 06/23] parametrized unit tests for mcompile --- linux/mcompile/keymap/test/keymap.test.cpp | 398 ++++++++++----------- 1 file changed, 187 insertions(+), 211 deletions(-) diff --git a/linux/mcompile/keymap/test/keymap.test.cpp b/linux/mcompile/keymap/test/keymap.test.cpp index 59c4f1ee9c1..f4a8d97e631 100644 --- a/linux/mcompile/keymap/test/keymap.test.cpp +++ b/linux/mcompile/keymap/test/keymap.test.cpp @@ -1,11 +1,3 @@ -/* - * Keyman is copyright (C) 2004 - 2026 SIL International. MIT License. - * - * Created by Markus-SWAG on 2026-05-05 - * - * Mnemonic layout support for Linux - */ - #include #include #include @@ -20,7 +12,74 @@ #include "mcompile.h" #include "keymap.h" -class KeyboardConversionTest : public ::testing::Test { +class TestDataValues { + + private: + guint keycode; + KMX_WCHAR expected_char; + std::string layout; + guint shiftstate; + + + public: + TestDataValues(guint k, KMX_WCHAR e, std::string l, guint s) : keycode(k), expected_char(e), layout(l), shiftstate(s) { + this->keycode = k; + this->expected_char = e; + this->layout = l; + this->shiftstate = s; + } + + guint get_keycode() { + return keycode; + } + + KMX_WCHAR get_expected_char() { + return expected_char; + } + + std::string get_layout() { + return layout; + } + + guint get_shiftstate() { + return shiftstate; + } +}; + +class KeyboardTestParameters { + + public: + + KeyboardTestParameters(std::vector e, std::string l, guint s) : expected_keysyms(e), layout(l), shiftstate(s) { + expected_keysyms = e; + layout = l; + shiftstate = s; + generate_test_data_values(); + } + + std::vector get_test_data() { + return test_data_values; + } + + protected: + std::vector expected_keysyms; + std::vector test_data_values = {}; + std::string layout; + guint shiftstate; + std::vector keycodes = { 38, 56, 54, 40, 26, 41, 42, 43, 31, 44, 45, 46, 58, 57, 32, + 33, 24, 27, 39, 28, 30, 55, 25, 53, 29, 52, 19, 10, 11, 12, + 13, 14, 15, 16, 17, 18, 65, 49, 20, 21, 34, 35, 51, 47, 48, + 59, 60, 61, 123, 94}; + + void generate_test_data_values() { + EXPECT_EQ(keycodes.size(), expected_keysyms.size()) << "Keycodes and expected keysyms vectors must be of the same size."; + for (guint k = 0; k < keycodes.size() && k < expected_keysyms.size(); k++) { + test_data_values.emplace_back(TestDataValues(keycodes[k], expected_keysyms[k], layout, shiftstate)); + } + } +}; + +class KeyboardConversionTest : public ::testing::TestWithParam { public: @@ -29,8 +88,8 @@ class KeyboardConversionTest : public ::testing::Test { GdkDisplay* test_display; gint argc = 0; char** argv = nullptr; - Glib::ustring default_layout; - bool onX11 = false; + std::string default_layout; + private: void initialize_keymap() { @@ -55,16 +114,23 @@ class KeyboardConversionTest : public ::testing::Test { auto variant = Glib::VariantBase::cast_dynamic(base); sources = variant.get(); - ASSERT_FALSE(sources.empty()) << "ERROR: No input sources found"; + if (sources.empty()) { + GTEST_SKIP() << "ERROR: No input sources found"; + } - const auto& [type, layout] = sources[0]; + const auto& [type, system_layout] = sources[0]; - std::cout << "Default input source type: " << type << ", layout: " << layout << std::endl; - ASSERT_EQ(type, "xkb"); - if (layout == "de" || layout == "us") { - default_layout = layout; + if (type == "xkb") { + if (system_layout == "de" || system_layout == "us") { + default_layout = system_layout; + } + else { + GTEST_SKIP() << "Default layout is not DE or US."; + } + } + else { + GTEST_SKIP() << "Default input source type is not xkb."; } - } void SetUp() override { @@ -84,224 +150,134 @@ class KeyboardConversionTest : public ::testing::Test { gdk_display_close(test_display); test_display = nullptr; } - onX11 = false; } - - }; -guint keycodes[] = { 38, 56, 54, 40, 26, 41, 42, 43, 31, 44, 45, 46, 58, 57, 32, - 33, 24, 27, 39, 28, 30, 55, 25, 53, 29, 52, 19, 10, 11, 12, - 13, 14, 15, 16, 17, 18, 65, 49, 20, 21, 34, 35, 51, 47, 48, - 59, 60, 61, 123, 94}; - - -TEST_F(KeyboardConversionTest, KMXgetKeyValUnderlyingFromKeyCodeUnderlyingBase) { - - if (default_layout != "us") { - GTEST_SKIP() << "Default layout is not US."; +TEST_P(KeyboardConversionTest, Base) { + guint keycode; + KMX_WCHAR expected_char; + std::string test_layout; + guint shiftstate; + TestDataValues parameter = GetParam(); + + keycode = parameter.get_keycode(); + expected_char = parameter.get_expected_char(); + test_layout = parameter.get_layout(); + shiftstate = parameter.get_shiftstate(); + + std::cout << "Testing keycode: " << keycode << " expecting char: " << expected_char << " with layout: " << test_layout << " and shiftstate: " << shiftstate << std::endl; + if (test_layout != default_layout) { + GTEST_SKIP() << "Default layout is not " << default_layout << "."; } - KMX_DWORD expected_chars[] = {u'a', u'b', u'c', u'd', u'e', u'f', u'g', u'h', u'i', - u'j', u'k', u'l', u'm', u'n', u'o', u'p', u'q', u'r', - u's', u't', u'u', u'v', u'w', u'x', u'y', u'z', u'0', - u'1', u'2', u'3', u'4', u'5', u'6', u'7', u'8', u'9', - u' ', u'`', u'-', u'=', u'[', u']', u'\\', u';', u'\'', - u',', u'.', u'/', u'\000', u'<'}; - KMX_WCHAR deadkey; - for (uint k = 0; k < sizeof(keycodes)/sizeof(keycodes[0]); k++) { - KMX_WCHAR result = KMX_get_KeyValUnderlying_From_KeyCodeUnderlying( + KMX_WCHAR result = KMX_get_KeyValUnderlying_From_KeyCodeUnderlying( test_keymap, - keycodes[k], - 0, + keycode, + shiftstate, &deadkey - ); - EXPECT_EQ(result, expected_chars[k]) << "Failed for keycode: " << keycodes[k]; - } -} + ); + EXPECT_EQ(result, expected_char) << "Failed for keycode: " << keycode; - -TEST_F(KeyboardConversionTest, KMXgetKeyValUnderlyingFromKeyCodeUnderlyingShift) { - // Test with valid key code - should return character or deadkey - - if (default_layout != "us") { - GTEST_SKIP() << "Default layout is not US."; } - KMX_DWORD expected_chars[] = { u'A', u'B', u'C', u'D', u'E', u'F', u'G', u'H', u'I', - u'J', u'K', u'L', u'M', u'N', u'O', u'P', u'Q', u'R', - u'S', u'T', u'U', u'V', u'W', u'X', u'Y', u'Z', u')', - u'!', u'@', u'#', u'$', u'%', u'^', u'&', u'*', u'(', - u' ', u'~', u'_', u'+', u'{', u'}', u'|', u':', u'"', - u'<', u'>', u'?', u'\000', u'>'}; - KMX_WCHAR deadkey; - for (uint k = 0; k < sizeof(keycodes)/sizeof(keycodes[0]); k++) { - KMX_WCHAR result = KMX_get_KeyValUnderlying_From_KeyCodeUnderlying( - test_keymap, - keycodes[k], - K_SHIFTFLAG, - &deadkey - ); - EXPECT_EQ(result, expected_chars[k]) << "Failed for keycode: " << keycodes[k] << " with shift state"; - } -} - - -TEST_F(KeyboardConversionTest, KMXgetKeyValUnderlyingFromKeyCodeUnderlyingLCTRLFLAGRALTFLAG) { - // Test with valid key code - should return character or deadkey - if (default_layout != "us") { - GTEST_SKIP() << "Default layout is not US."; - } - - KMX_DWORD expected_chars[] = {u'a', u'b', u'c', u'd', u'e', u'f', u'g', u'h', u'i', u'j', u'k', + INSTANTIATE_TEST_SUITE_P(BaseUs, + KeyboardConversionTest, + testing::ValuesIn(KeyboardTestParameters( + {u'a', u'b', u'c', u'd', u'e', u'f', u'g', u'h', u'i', + u'j', u'k', u'l', u'm', u'n', u'o', u'p', u'q', u'r', + u's', u't', u'u', u'v', u'w', u'x', u'y', u'z', u'0', + u'1', u'2', u'3', u'4', u'5', u'6', u'7', u'8', u'9', + u' ', u'`', u'-', u'=', u'[', u']', u'\\', u';', u'\'', + u',', u'.', u'/', u'\000', u'<'}, + "us", + 0).get_test_data())); + + +INSTANTIATE_TEST_SUITE_P(ShiftUs, + KeyboardConversionTest, + testing::ValuesIn(KeyboardTestParameters( + {u'A', u'B', u'C', u'D', u'E', u'F', u'G', u'H', u'I', + u'J', u'K', u'L', u'M', u'N', u'O', u'P', u'Q', u'R', + u'S', u'T', u'U', u'V', u'W', u'X', u'Y', u'Z', u')', + u'!', u'@', u'#', u'$', u'%', u'^', u'&', u'*', u'(', + u' ', u'~', u'_', u'+', u'{', u'}', u'|', u':', u'"', + u'<', u'>', u'?', u'\000', u'>'}, + "us", + K_SHIFTFLAG).get_test_data())); + + +INSTANTIATE_TEST_SUITE_P(AltGrUs, + KeyboardConversionTest, + testing::ValuesIn(KeyboardTestParameters( + {u'a', u'b', u'c', u'd', u'e', u'f', u'g', u'h', u'i', u'j', u'k', u'l', u'm', u'n', u'o', u'p', u'q', u'r', u's', u't', u'u', u'v', u'w', u'x', u'y', u'z', u'0', u'1', u'2', u'3', u'4', u'5', u'6', u'7', u'8', u'9', u'\000', u'`', u'-', u'=', u'[', u']', u'\\', - u';', u'\'', u',', u'.', u'/', u'\000', u'|'}; - KMX_WCHAR deadkey; - - for (uint k = 0; k < sizeof(keycodes)/sizeof(keycodes[0]); k++) { - KMX_WCHAR result = KMX_get_KeyValUnderlying_From_KeyCodeUnderlying( - test_keymap, - keycodes[k], - LCTRLFLAG | RALTFLAG, - &deadkey - ); - EXPECT_EQ(result, expected_chars[k]) << "Failed for keycode: " << keycodes[k]; - } -} - - -TEST_F(KeyboardConversionTest, GetKeySymFromUnderlyingKeyCodeShiftLCTRLFLAGRALTFLAG) { - if (default_layout != "us") { - GTEST_SKIP() << "Default layout is not US."; - } - - KMX_DWORD expected_chars[] = {u'A', u'B', u'C', u'D', u'E', u'F', u'G', u'H', u'I', u'J', u'K', + u';', u'\'', u',', u'.', u'/', u'\000', u'|'}, + "us", + (LCTRLFLAG | RALTFLAG)).get_test_data())); + +INSTANTIATE_TEST_SUITE_P(ShiftAltGrUs, + KeyboardConversionTest, + testing::ValuesIn(KeyboardTestParameters( + {u'A', u'B', u'C', u'D', u'E', u'F', u'G', u'H', u'I', u'J', u'K', u'L', u'M', u'N', u'O', u'P', u'Q', u'R', u'S', u'T', u'U', u'V', u'W', u'X', u'Y', u'Z', u')', u'!', u'@', u'#', u'$', u'%', u'^', u'&', u'*', u'(', u'\000', u'~', u'_', u'+', u'{', u'}', u'|', - u':', u'"', u'<', u'>', u'?', u'\000', u'¦'}; - - KMX_WCHAR deadkey; - - for (uint k = 0; k < sizeof(keycodes)/sizeof(keycodes[0]); k++) { - KMX_WCHAR result = KMX_get_KeyValUnderlying_From_KeyCodeUnderlying( - test_keymap, - keycodes[k], - K_SHIFTFLAG | LCTRLFLAG | RALTFLAG, - &deadkey - ); - EXPECT_EQ(result, expected_chars[k]) << "Failed for keycode: " << keycodes[k]; - } -} - - -TEST_F(KeyboardConversionTest, DeGetKeySymFromUnderlyingKeyCode) { - if (default_layout != "de") { - GTEST_SKIP() << "Default layout is not DE."; - } - - KMX_DWORD expected_chars[] = {u'a', u'b', u'c', u'd', u'e', u'f', u'g', u'h', u'i', u'j', - u'k', u'l', u'm', u'n', u'o', u'p', u'q', u'r', u's', u't', - u'u', u'v', u'w', u'x', u'z', u'y', u'0', u'1', u'2', u'3', - u'4', u'5', u'6', u'7', u'8', u'9', u' ', u'\xffff', u'ß', - u'\xffff', u'ü', u'+', u'#', u'ö', u'ä', u',', u'.', u'-', - u'\000', u'<', }; - - KMX_WCHAR deadkey; - - std::cout << "Testing KMX_get_KeyValUnderlying_From_KeyCodeUnderlying with base shift state" << std::endl; - for (uint k = 0; k < sizeof(keycodes)/sizeof(keycodes[0]); k++) { - KMX_WCHAR result = KMX_get_KeyValUnderlying_From_KeyCodeUnderlying( - test_keymap, - keycodes[k], - 0, // Base shift state - &deadkey - ); - EXPECT_EQ(result, expected_chars[k]) << "Failed for keycode: " << keycodes[k]; - } -} - - -TEST_F(KeyboardConversionTest, DeKMXgetKeyValUnderlyingFromKeyCodeUnderlyingShift) { - if (default_layout != "de") { - GTEST_SKIP() << "Default layout is not DE."; - } - - KMX_DWORD expected_chars[] = { u'A', u'B', u'C', u'D', u'E', u'F', u'G', u'H', u'I', + u':', u'"', u'<', u'>', u'?', u'\000', u'¦'}, + "us", + (K_SHIFTFLAG | LCTRLFLAG | RALTFLAG)).get_test_data())); + +INSTANTIATE_TEST_SUITE_P(BaseDe, + KeyboardConversionTest, + testing::ValuesIn(KeyboardTestParameters( + {u'a', u'b', u'c', u'd', u'e', u'f', u'g', u'h', u'i', u'j', + u'k', u'l', u'm', u'n', u'o', u'p', u'q', u'r', u's', u't', + u'u', u'v', u'w', u'x', u'z', u'y', u'0', u'1', u'2', u'3', + u'4', u'5', u'6', u'7', u'8', u'9', u' ', u'\xffff', u'ß', + u'\xffff', u'ü', u'+', u'#', u'ö', u'ä', u',', u'.', u'-', + u'\000', u'<'}, + "de", + 0).get_test_data())); + + +INSTANTIATE_TEST_SUITE_P(ShiftDe, + KeyboardConversionTest, + testing::ValuesIn(KeyboardTestParameters( + {u'A', u'B', u'C', u'D', u'E', u'F', u'G', u'H', u'I', u'J', u'K', u'L', u'M', u'N', u'O', u'P', u'Q', u'R', u'S', u'T', u'U', u'V', u'W', u'X', u'Z', u'Y', u'=', u'!', u'"', u'§', u'$', u'%', u'&', u'/', u'(', u')', u' ', u'°', u'?', u'\xffff', u'Ü', u'*', u'\'', u'Ö', - u'Ä', u';', u':', u'_', u'\000', u'>', }; - - KMX_WCHAR deadkey; - - for (uint k = 0; k < sizeof(keycodes)/sizeof(keycodes[0]); k++) { - KMX_WCHAR result = KMX_get_KeyValUnderlying_From_KeyCodeUnderlying( - test_keymap, - keycodes[k], - K_SHIFTFLAG, - &deadkey - ); - EXPECT_EQ(result, expected_chars[k]) << "Failed for keycode: " << keycodes[k] << " with shift state"; - } -} - - -TEST_F(KeyboardConversionTest, DeKMXgetKeyValUnderlyingFromKeyCodeUnderlyingLCTRLFLAGRALTFLAG) { - // Test with valid key code - should return character or deadkey - if (default_layout != "de") { - GTEST_SKIP() << "Default layout is not DE."; - } - - KMX_DWORD expected_chars[] = {u'æ', u'\xfffe', u'¢', u'ð', u'\xfffe', u'\xfffe', u'\xfffe', u'\xfffe', - u'\xfffe', u'\xffff', u'\xfffe', u'\xfffe', u'µ', u'\xfffe', u'ø', u'þ', - u'@', u'¶', u'\xfffe', u'\xfffe', u'\xfffe', u'\xfffe', u'\xfffe', u'«', - u'\xfffe', u'»', u'}', u'¹', u'²', u'³', u'¼', u'½', u'¬', u'{', u'[', - u']', u'\000', u'\xfffe', u'\\', u'\xffff', u'\xffff', u'~', u'\xfffe', - u'\xffff', u'\xffff', u'·', u'\xfffe', u'\xfffe', u'\000', u'|', }; - - KMX_WCHAR deadkey; - - for (uint k = 0; k < sizeof(keycodes)/sizeof(keycodes[0]); k++) { - KMX_WCHAR result = KMX_get_KeyValUnderlying_From_KeyCodeUnderlying( - test_keymap, - keycodes[k], - LCTRLFLAG | RALTFLAG, - &deadkey - ); - EXPECT_EQ(result, expected_chars[k]) << "Failed for keycode: " << keycodes[k]; - } -} - - -TEST_F(KeyboardConversionTest, DeGetKeySymFromUnderlyingKeyCodeShiftLCTRLFLAGRALTFLAG) { - if (default_layout != "de") { - GTEST_SKIP() << "Default layout is not DE."; - } - - KMX_DWORD expected_chars[] = {u'Æ', u'\xfffe', u'©', u'Ð', u'\xfffe', u'ª', u'\xfffe', + u'Ä', u';', u':', u'_', u'\000', u'>'}, + "de", + K_SHIFTFLAG).get_test_data())); + + +INSTANTIATE_TEST_SUITE_P(AltGrDe, + KeyboardConversionTest, + testing::ValuesIn(KeyboardTestParameters( + {u'æ', u'\xfffe', u'¢', u'ð', u'\xfffe', u'\xfffe', u'\xfffe', u'\xfffe', + u'\xfffe', u'\xffff', u'\xfffe', u'\xfffe', u'µ', u'\xfffe', u'ø', u'þ', + u'@', u'¶', u'\xfffe', u'\xfffe', u'\xfffe', u'\xfffe', u'\xfffe', u'«', + u'\xfffe', u'»', u'}', u'¹', u'²', u'³', u'¼', u'½', u'¬', u'{', u'[', + u']', u'\000', u'\xfffe', u'\\', u'\xffff', u'\xffff', u'~', u'\xfffe', + u'\xffff', u'\xffff', u'·', u'\xfffe', u'\xfffe', u'\000', u'|'}, + "de", + (LCTRLFLAG | RALTFLAG)).get_test_data())); + +INSTANTIATE_TEST_SUITE_P(ShiftAltGrDe, + KeyboardConversionTest, + testing::ValuesIn(KeyboardTestParameters( + {u'Æ', u'\xfffe', u'©', u'Ð', u'\xfffe', u'ª', u'\xfffe', u'\xfffe', u'\xfffe', u'\xffff', u'&', u'\xfffe', u'º', u'\xfffe', u'Ø', u'Þ', u'\xfffe', u'®', u'\xfffe', u'\xfffe', u'\xfffe', u'\xfffe', u'§', u'\xfffe', u'¥', u'\xfffe', u'°', u'¡', u'\xfffe', u'£', u'¤', u'\xfffe', u'\xfffe', u'\xfffe', u'\xfffe', u'±', u'\000', u'\xfffe', u'¿', u'\xffff', u'\xffff', u'¯', u'\xffff', u'\xffff', u'\xffff', u'×', u'÷', u'\xfffe', - u'\000', u'\xffff', }; - - KMX_WCHAR deadkey; - - for (uint k = 0; k < sizeof(keycodes)/sizeof(keycodes[0]); k++) { - KMX_WCHAR result = KMX_get_KeyValUnderlying_From_KeyCodeUnderlying( - test_keymap, - keycodes[k], - K_SHIFTFLAG | LCTRLFLAG | RALTFLAG, - &deadkey - ); - EXPECT_EQ(result, expected_chars[k]) << "Failed for keycode: " << keycodes[k]; - } -} + u'\000', u'\xffff'}, + "de", + (K_SHIFTFLAG | LCTRLFLAG | RALTFLAG)).get_test_data())); From d5acccaa949239b9c1e3ba0833db5e580be38b7b Mon Sep 17 00:00:00 2001 From: Markus Greiner <90342882+Markus-SWAG@users.noreply.github.com> Date: Wed, 6 May 2026 17:51:03 +0200 Subject: [PATCH 07/23] Update linux/mcompile/keymap/deadkey.h Co-authored-by: Eberhard Beilharz --- linux/mcompile/keymap/deadkey.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/linux/mcompile/keymap/deadkey.h b/linux/mcompile/keymap/deadkey.h index a6f358eb987..ff1677424ef 100644 --- a/linux/mcompile/keymap/deadkey.h +++ b/linux/mcompile/keymap/deadkey.h @@ -1,5 +1,5 @@ /* - * Keyman is copyright (C) 2004 - 2026 SIL International. MIT License. + * Keyman is copyright (C) 2004 - 2026 SIL Global. MIT License. * * Mnemonic layout support for Linux */ From 6e38fc0b2ce1bc1ee17110bb673c515a294c27e4 Mon Sep 17 00:00:00 2001 From: Markus Greiner Date: Wed, 6 May 2026 17:55:55 +0200 Subject: [PATCH 08/23] renamed files according test standards --- .../mcompile/keymap/test/{keymap.test.cpp => keymap.tests.cpp} | 0 linux/mcompile/keymap/test/meson.build | 2 +- 2 files changed, 1 insertion(+), 1 deletion(-) rename linux/mcompile/keymap/test/{keymap.test.cpp => keymap.tests.cpp} (100%) diff --git a/linux/mcompile/keymap/test/keymap.test.cpp b/linux/mcompile/keymap/test/keymap.tests.cpp similarity index 100% rename from linux/mcompile/keymap/test/keymap.test.cpp rename to linux/mcompile/keymap/test/keymap.tests.cpp diff --git a/linux/mcompile/keymap/test/meson.build b/linux/mcompile/keymap/test/meson.build index 7aacdb97946..9cbdadb999a 100644 --- a/linux/mcompile/keymap/test/meson.build +++ b/linux/mcompile/keymap/test/meson.build @@ -3,7 +3,7 @@ gtest = subproject('gtest') gtest_main_dep = gtest.get_variable('gtest_main_dep') keymaptest = executable('keymaptest', [ - 'keymap.test.cpp', test_files, + 'keymap.tests.cpp', test_files, ], sources: [test_files], include_directories: [common_include_dir], From bb87e1d91814787619f3ef3a7a0c4d1402b2b5de Mon Sep 17 00:00:00 2001 From: Markus Greiner Date: Wed, 6 May 2026 18:02:39 +0200 Subject: [PATCH 09/23] substituting SIL International by SIL Global in all file headers --- linux/mcompile/keymap/deadkey.cpp | 2 +- linux/mcompile/keymap/keymap.cpp | 2 +- linux/mcompile/keymap/keymap.h | 2 +- linux/mcompile/keymap/main.cpp | 2 +- linux/mcompile/keymap/mc_import_rules.cpp | 2 +- linux/mcompile/keymap/mc_import_rules.h | 2 +- linux/mcompile/keymap/mc_kmxfile.cpp | 2 +- linux/mcompile/keymap/mc_kmxfile.h | 2 +- linux/mcompile/keymap/mcompile.cpp | 2 +- linux/mcompile/keymap/mcompile.h | 2 +- 10 files changed, 10 insertions(+), 10 deletions(-) diff --git a/linux/mcompile/keymap/deadkey.cpp b/linux/mcompile/keymap/deadkey.cpp index b7b67daa25f..69af0b6d0a0 100644 --- a/linux/mcompile/keymap/deadkey.cpp +++ b/linux/mcompile/keymap/deadkey.cpp @@ -1,5 +1,5 @@ /* - * Keyman is copyright (C) 2004 - 2024 SIL International. MIT License. + * Keyman is copyright (C) 2004 - 2026 SIL Global. MIT License. * * Mnemonic layout support for Linux */ diff --git a/linux/mcompile/keymap/keymap.cpp b/linux/mcompile/keymap/keymap.cpp index b9047a334bb..6abf57f14ca 100644 --- a/linux/mcompile/keymap/keymap.cpp +++ b/linux/mcompile/keymap/keymap.cpp @@ -1,5 +1,5 @@ /* - * Keyman is copyright (C) 2004 - 2026 SIL International. MIT License. + * Keyman is copyright (C) 2004 - 2026 SIL Global. MIT License. * * Mnemonic layout support for Linux * diff --git a/linux/mcompile/keymap/keymap.h b/linux/mcompile/keymap/keymap.h index 959fd53f1d2..d31489ff772 100644 --- a/linux/mcompile/keymap/keymap.h +++ b/linux/mcompile/keymap/keymap.h @@ -1,5 +1,5 @@ /* - * Keyman is copyright (C) 2004 - 2026 SIL International. MIT License. + * Keyman is copyright (C) 2004 - 2026 SIL Global. MIT License. * * Mnemonic layout support for Linux */ diff --git a/linux/mcompile/keymap/main.cpp b/linux/mcompile/keymap/main.cpp index b5417ada9e7..8847724ec33 100644 --- a/linux/mcompile/keymap/main.cpp +++ b/linux/mcompile/keymap/main.cpp @@ -1,5 +1,5 @@ /* - * Keyman is copyright (C) 2004 - 2026 SIL International. MIT License. + * Keyman is copyright (C) 2004 - 2026 SIL Global. MIT License. * * Created by Markus-SWAG on 2026-05-05 * diff --git a/linux/mcompile/keymap/mc_import_rules.cpp b/linux/mcompile/keymap/mc_import_rules.cpp index 7e5c23a72ec..75a3f1c6e33 100644 --- a/linux/mcompile/keymap/mc_import_rules.cpp +++ b/linux/mcompile/keymap/mc_import_rules.cpp @@ -1,5 +1,5 @@ /* - * Keyman is copyright (C) 2004 - 2024 SIL International. MIT License. + * Keyman is copyright (C) 2004 - 2026 SIL Global. MIT License. * * Mnemonic layout support for Linux */ diff --git a/linux/mcompile/keymap/mc_import_rules.h b/linux/mcompile/keymap/mc_import_rules.h index 1a924a7f485..27ae4da6349 100644 --- a/linux/mcompile/keymap/mc_import_rules.h +++ b/linux/mcompile/keymap/mc_import_rules.h @@ -1,5 +1,5 @@ /* - * Keyman is copyright (C) 2004 - 2026 SIL International. MIT License. + * Keyman is copyright (C) 2004 - 2026 SIL Global. MIT License. * * Mnemonic layout support for Linux */ diff --git a/linux/mcompile/keymap/mc_kmxfile.cpp b/linux/mcompile/keymap/mc_kmxfile.cpp index f5fcc09f538..b00a51e6d3e 100644 --- a/linux/mcompile/keymap/mc_kmxfile.cpp +++ b/linux/mcompile/keymap/mc_kmxfile.cpp @@ -1,5 +1,5 @@ /* - * Keyman is copyright (C) 2004 - 2026 SIL International. MIT License. + * Keyman is copyright (C) 2004 - 2026 SIL Global. MIT License. * * Mnemonic layout support for Linux */ diff --git a/linux/mcompile/keymap/mc_kmxfile.h b/linux/mcompile/keymap/mc_kmxfile.h index 25403162cff..31a47645df7 100644 --- a/linux/mcompile/keymap/mc_kmxfile.h +++ b/linux/mcompile/keymap/mc_kmxfile.h @@ -1,5 +1,5 @@ /* - * Keyman is copyright (C) 2004 - 2026 SIL International. MIT License. + * Keyman is copyright (C) 2004 - 2026 SIL Global. MIT License. * * Mnemonic layout support for Linux */ diff --git a/linux/mcompile/keymap/mcompile.cpp b/linux/mcompile/keymap/mcompile.cpp index 0c0bd7f569c..0f7219b5055 100644 --- a/linux/mcompile/keymap/mcompile.cpp +++ b/linux/mcompile/keymap/mcompile.cpp @@ -1,5 +1,5 @@ /* - * Keyman is copyright (C) SIL International. MIT License. + * Keyman is copyright (C) SIL Global. MIT License. * * Mnemonic layout support for linux * diff --git a/linux/mcompile/keymap/mcompile.h b/linux/mcompile/keymap/mcompile.h index b77b7d9cd42..ccb9559b083 100644 --- a/linux/mcompile/keymap/mcompile.h +++ b/linux/mcompile/keymap/mcompile.h @@ -1,5 +1,5 @@ /* - * Keyman is copyright (C) SIL International. MIT License. + * Keyman is copyright (C) SIL Global. MIT License. * * Mnemonic layout support for linux */ From 064680851b68cb07db023d7820a851d3aec00def Mon Sep 17 00:00:00 2001 From: Markus Greiner Date: Wed, 6 May 2026 18:09:52 +0200 Subject: [PATCH 10/23] erasing year from the file headers --- linux/mcompile/keymap/deadkey.cpp | 2 +- linux/mcompile/keymap/deadkey.h | 2 +- linux/mcompile/keymap/keymap.cpp | 2 +- linux/mcompile/keymap/keymap.h | 2 +- linux/mcompile/keymap/main.cpp | 2 +- linux/mcompile/keymap/mc_import_rules.cpp | 2 +- linux/mcompile/keymap/mc_import_rules.h | 2 +- linux/mcompile/keymap/mc_kmxfile.cpp | 2 +- linux/mcompile/keymap/mc_kmxfile.h | 2 +- 9 files changed, 9 insertions(+), 9 deletions(-) diff --git a/linux/mcompile/keymap/deadkey.cpp b/linux/mcompile/keymap/deadkey.cpp index 69af0b6d0a0..6b2e708034d 100644 --- a/linux/mcompile/keymap/deadkey.cpp +++ b/linux/mcompile/keymap/deadkey.cpp @@ -1,5 +1,5 @@ /* - * Keyman is copyright (C) 2004 - 2026 SIL Global. MIT License. + * Keyman is copyright (C) SIL Global. MIT License. * * Mnemonic layout support for Linux */ diff --git a/linux/mcompile/keymap/deadkey.h b/linux/mcompile/keymap/deadkey.h index ff1677424ef..2ff6a794913 100644 --- a/linux/mcompile/keymap/deadkey.h +++ b/linux/mcompile/keymap/deadkey.h @@ -1,5 +1,5 @@ /* - * Keyman is copyright (C) 2004 - 2026 SIL Global. MIT License. + * Keyman is copyright (C) SIL Global. MIT License. * * Mnemonic layout support for Linux */ diff --git a/linux/mcompile/keymap/keymap.cpp b/linux/mcompile/keymap/keymap.cpp index 6abf57f14ca..6a9a3d4e90f 100644 --- a/linux/mcompile/keymap/keymap.cpp +++ b/linux/mcompile/keymap/keymap.cpp @@ -1,5 +1,5 @@ /* - * Keyman is copyright (C) 2004 - 2026 SIL Global. MIT License. + * Keyman is copyright (C) SIL Global. MIT License. * * Mnemonic layout support for Linux * diff --git a/linux/mcompile/keymap/keymap.h b/linux/mcompile/keymap/keymap.h index d31489ff772..1a84b5ac215 100644 --- a/linux/mcompile/keymap/keymap.h +++ b/linux/mcompile/keymap/keymap.h @@ -1,5 +1,5 @@ /* - * Keyman is copyright (C) 2004 - 2026 SIL Global. MIT License. + * Keyman is copyright (C) SIL Global. MIT License. * * Mnemonic layout support for Linux */ diff --git a/linux/mcompile/keymap/main.cpp b/linux/mcompile/keymap/main.cpp index 8847724ec33..4f82a7ec1ad 100644 --- a/linux/mcompile/keymap/main.cpp +++ b/linux/mcompile/keymap/main.cpp @@ -1,5 +1,5 @@ /* - * Keyman is copyright (C) 2004 - 2026 SIL Global. MIT License. + * Keyman is copyright (C) SIL Global. MIT License. * * Created by Markus-SWAG on 2026-05-05 * diff --git a/linux/mcompile/keymap/mc_import_rules.cpp b/linux/mcompile/keymap/mc_import_rules.cpp index 75a3f1c6e33..66aeb937671 100644 --- a/linux/mcompile/keymap/mc_import_rules.cpp +++ b/linux/mcompile/keymap/mc_import_rules.cpp @@ -1,5 +1,5 @@ /* - * Keyman is copyright (C) 2004 - 2026 SIL Global. MIT License. + * Keyman is copyright (C) SIL Global. MIT License. * * Mnemonic layout support for Linux */ diff --git a/linux/mcompile/keymap/mc_import_rules.h b/linux/mcompile/keymap/mc_import_rules.h index 27ae4da6349..c0df57f0dfd 100644 --- a/linux/mcompile/keymap/mc_import_rules.h +++ b/linux/mcompile/keymap/mc_import_rules.h @@ -1,5 +1,5 @@ /* - * Keyman is copyright (C) 2004 - 2026 SIL Global. MIT License. + * Keyman is copyright (C) SIL Global. MIT License. * * Mnemonic layout support for Linux */ diff --git a/linux/mcompile/keymap/mc_kmxfile.cpp b/linux/mcompile/keymap/mc_kmxfile.cpp index b00a51e6d3e..50ea9c8086a 100644 --- a/linux/mcompile/keymap/mc_kmxfile.cpp +++ b/linux/mcompile/keymap/mc_kmxfile.cpp @@ -1,5 +1,5 @@ /* - * Keyman is copyright (C) 2004 - 2026 SIL Global. MIT License. + * Keyman is copyright (C) SIL Global. MIT License. * * Mnemonic layout support for Linux */ diff --git a/linux/mcompile/keymap/mc_kmxfile.h b/linux/mcompile/keymap/mc_kmxfile.h index 31a47645df7..9af264939f1 100644 --- a/linux/mcompile/keymap/mc_kmxfile.h +++ b/linux/mcompile/keymap/mc_kmxfile.h @@ -1,5 +1,5 @@ /* - * Keyman is copyright (C) 2004 - 2026 SIL Global. MIT License. + * Keyman is copyright (C) SIL Global. MIT License. * * Mnemonic layout support for Linux */ From e3dd7f154a1d439db3a63c11bc949fc4f2f8d15c Mon Sep 17 00:00:00 2001 From: Markus Greiner Date: Wed, 6 May 2026 18:17:42 +0200 Subject: [PATCH 11/23] added delete kmxfile as before --- linux/mcompile/keymap/main.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/linux/mcompile/keymap/main.cpp b/linux/mcompile/keymap/main.cpp index 4f82a7ec1ad..1b5323d755e 100644 --- a/linux/mcompile/keymap/main.cpp +++ b/linux/mcompile/keymap/main.cpp @@ -83,5 +83,7 @@ int main(int argc, char* argv[]) { } } + delete kmxfile; + return 0; } From 8ba6a136b434e77145ab99bd29a4a749a89a8798 Mon Sep 17 00:00:00 2001 From: Markus Greiner Date: Wed, 6 May 2026 18:20:52 +0200 Subject: [PATCH 12/23] added 1 more file header --- linux/mcompile/keymap/test/keymap.tests.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/linux/mcompile/keymap/test/keymap.tests.cpp b/linux/mcompile/keymap/test/keymap.tests.cpp index f4a8d97e631..b6538220ba7 100644 --- a/linux/mcompile/keymap/test/keymap.tests.cpp +++ b/linux/mcompile/keymap/test/keymap.tests.cpp @@ -1,3 +1,9 @@ +* + * Keyman is copyright (C) SIL Global. MIT License. + * + * Mnemonic layout support for Linux + */ + #include #include #include From 9cf4e784b2b595e2f7b1e5db59804d5f8806f09e Mon Sep 17 00:00:00 2001 From: Markus Greiner Date: Wed, 6 May 2026 18:25:41 +0200 Subject: [PATCH 13/23] fixing typo --- linux/mcompile/keymap/test/keymap.tests.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/linux/mcompile/keymap/test/keymap.tests.cpp b/linux/mcompile/keymap/test/keymap.tests.cpp index b6538220ba7..1781dbaf956 100644 --- a/linux/mcompile/keymap/test/keymap.tests.cpp +++ b/linux/mcompile/keymap/test/keymap.tests.cpp @@ -1,4 +1,4 @@ -* +/* * Keyman is copyright (C) SIL Global. MIT License. * * Mnemonic layout support for Linux From 471c6c401c33d13732cfe72fa17a74dfabddc2b3 Mon Sep 17 00:00:00 2001 From: Markus Greiner Date: Thu, 7 May 2026 11:59:24 +0200 Subject: [PATCH 14/23] adding test suite for KMX_get_KeyVal_From_KeyCode --- linux/mcompile/keymap/test/keymap.tests.cpp | 233 ++++++++++++++++++-- 1 file changed, 218 insertions(+), 15 deletions(-) diff --git a/linux/mcompile/keymap/test/keymap.tests.cpp b/linux/mcompile/keymap/test/keymap.tests.cpp index 1781dbaf956..1f54f1ef7ab 100644 --- a/linux/mcompile/keymap/test/keymap.tests.cpp +++ b/linux/mcompile/keymap/test/keymap.tests.cpp @@ -20,7 +20,7 @@ class TestDataValues { - private: + protected: guint keycode; KMX_WCHAR expected_char; std::string layout; @@ -85,7 +85,7 @@ class KeyboardTestParameters { } }; -class KeyboardConversionTest : public ::testing::TestWithParam { +class KeyboardConversionTest : public testing::Test { public: @@ -159,7 +159,11 @@ class KeyboardConversionTest : public ::testing::TestWithParam { } }; -TEST_P(KeyboardConversionTest, Base) { +class GetKeyValUnderlyingFromKeyCodeUnderlyingTest : public KeyboardConversionTest, + public testing::WithParamInterface { +}; + +TEST_P(GetKeyValUnderlyingFromKeyCodeUnderlyingTest, KmxGetKeyValUnderlyingFromKeyCodeUnderlying) { guint keycode; KMX_WCHAR expected_char; std::string test_layout; @@ -184,12 +188,10 @@ TEST_P(KeyboardConversionTest, Base) { &deadkey ); EXPECT_EQ(result, expected_char) << "Failed for keycode: " << keycode; +} - } - - - INSTANTIATE_TEST_SUITE_P(BaseUs, - KeyboardConversionTest, +INSTANTIATE_TEST_SUITE_P(BaseUs, + GetKeyValUnderlyingFromKeyCodeUnderlyingTest, testing::ValuesIn(KeyboardTestParameters( {u'a', u'b', u'c', u'd', u'e', u'f', u'g', u'h', u'i', u'j', u'k', u'l', u'm', u'n', u'o', u'p', u'q', u'r', @@ -202,7 +204,7 @@ TEST_P(KeyboardConversionTest, Base) { INSTANTIATE_TEST_SUITE_P(ShiftUs, - KeyboardConversionTest, + GetKeyValUnderlyingFromKeyCodeUnderlyingTest, testing::ValuesIn(KeyboardTestParameters( {u'A', u'B', u'C', u'D', u'E', u'F', u'G', u'H', u'I', u'J', u'K', u'L', u'M', u'N', u'O', u'P', u'Q', u'R', @@ -215,7 +217,7 @@ INSTANTIATE_TEST_SUITE_P(ShiftUs, INSTANTIATE_TEST_SUITE_P(AltGrUs, - KeyboardConversionTest, + GetKeyValUnderlyingFromKeyCodeUnderlyingTest, testing::ValuesIn(KeyboardTestParameters( {u'a', u'b', u'c', u'd', u'e', u'f', u'g', u'h', u'i', u'j', u'k', u'l', u'm', u'n', u'o', u'p', u'q', u'r', u's', u't', u'u', u'v', @@ -226,7 +228,7 @@ INSTANTIATE_TEST_SUITE_P(AltGrUs, (LCTRLFLAG | RALTFLAG)).get_test_data())); INSTANTIATE_TEST_SUITE_P(ShiftAltGrUs, - KeyboardConversionTest, + GetKeyValUnderlyingFromKeyCodeUnderlyingTest, testing::ValuesIn(KeyboardTestParameters( {u'A', u'B', u'C', u'D', u'E', u'F', u'G', u'H', u'I', u'J', u'K', u'L', u'M', u'N', u'O', u'P', u'Q', u'R', u'S', u'T', u'U', u'V', @@ -237,7 +239,7 @@ INSTANTIATE_TEST_SUITE_P(ShiftAltGrUs, (K_SHIFTFLAG | LCTRLFLAG | RALTFLAG)).get_test_data())); INSTANTIATE_TEST_SUITE_P(BaseDe, - KeyboardConversionTest, + GetKeyValUnderlyingFromKeyCodeUnderlyingTest, testing::ValuesIn(KeyboardTestParameters( {u'a', u'b', u'c', u'd', u'e', u'f', u'g', u'h', u'i', u'j', u'k', u'l', u'm', u'n', u'o', u'p', u'q', u'r', u's', u't', @@ -250,7 +252,7 @@ INSTANTIATE_TEST_SUITE_P(BaseDe, INSTANTIATE_TEST_SUITE_P(ShiftDe, - KeyboardConversionTest, + GetKeyValUnderlyingFromKeyCodeUnderlyingTest, testing::ValuesIn(KeyboardTestParameters( {u'A', u'B', u'C', u'D', u'E', u'F', u'G', u'H', u'I', u'J', u'K', u'L', u'M', u'N', u'O', u'P', u'Q', u'R', @@ -263,7 +265,7 @@ INSTANTIATE_TEST_SUITE_P(ShiftDe, INSTANTIATE_TEST_SUITE_P(AltGrDe, - KeyboardConversionTest, + GetKeyValUnderlyingFromKeyCodeUnderlyingTest, testing::ValuesIn(KeyboardTestParameters( {u'æ', u'\xfffe', u'¢', u'ð', u'\xfffe', u'\xfffe', u'\xfffe', u'\xfffe', u'\xfffe', u'\xffff', u'\xfffe', u'\xfffe', u'µ', u'\xfffe', u'ø', u'þ', @@ -275,7 +277,7 @@ INSTANTIATE_TEST_SUITE_P(AltGrDe, (LCTRLFLAG | RALTFLAG)).get_test_data())); INSTANTIATE_TEST_SUITE_P(ShiftAltGrDe, - KeyboardConversionTest, + GetKeyValUnderlyingFromKeyCodeUnderlyingTest, testing::ValuesIn(KeyboardTestParameters( {u'Æ', u'\xfffe', u'©', u'Ð', u'\xfffe', u'ª', u'\xfffe', u'\xfffe', u'\xfffe', u'\xffff', u'&', u'\xfffe', u'º', @@ -287,3 +289,204 @@ INSTANTIATE_TEST_SUITE_P(ShiftAltGrDe, u'\000', u'\xffff'}, "de", (K_SHIFTFLAG | LCTRLFLAG | RALTFLAG)).get_test_data())); + + +class GetKeyValFromKeyCodeTestDataValues : public TestDataValues { + public: + GetKeyValFromKeyCodeTestDataValues(guint k, KMX_WCHAR e, std::string l, guint s, int c) : + TestDataValues(k, e, l, s), caps(c) { + keycode = k; + expected_char = e; + layout = l; + shiftstate = s; + caps = c; + } + + int get_caps() { + return caps; + } + + protected: + int caps; + +}; + +class GetKeyValFromKeyCodeTestParameters { + public: + + GetKeyValFromKeyCodeTestParameters(std::vector e, std::string l, guint s, int c) : expected_keysyms(e), layout(l), shiftstate(s), caps(c) { + expected_keysyms = e; + layout = l; + shiftstate = s; + caps = c; + generate_test_data_values(); + } + + std::vector get_test_data() { + return test_data_values; + } + + + protected: + std::vector expected_keysyms; + std::vector test_data_values = {}; + std::string layout; + guint shiftstate; + int caps; + std::vector keycodes = { 38, 56, 54, 40, 26, 41, 42, 43, 31, 44, 45, 46, 58, 57, 32, + 33, 24, 27, 39, 28, 30, 55, 25, 53, 29, 52, 19, 10, 11, 12, + 13, 14, 15, 16, 17, 18, 65, 49, 20, 21, 34, 35, 51, 47, 48, + 59, 60, 61, 123, 94}; + + + void generate_test_data_values(){ + EXPECT_EQ(keycodes.size(), expected_keysyms.size()) << "Keycodes and expected keysyms vectors must be of the same size."; + for (guint k = 0; k < keycodes.size() && k < expected_keysyms.size(); k++) { + test_data_values.emplace_back(GetKeyValFromKeyCodeTestDataValues(keycodes[k], expected_keysyms[k], layout, shiftstate, caps)); + } + } +}; + +class GetKeyValFromKeyCodeTest : public KeyboardConversionTest, + public testing::WithParamInterface { + +}; + + +TEST_P(GetKeyValFromKeyCodeTest, kmxGetKeyValFromKeyCode) { + guint keycode; + KMX_WCHAR expected_char; + std::string test_layout; + guint shiftstate; + int caps; + + GetKeyValFromKeyCodeTestDataValues parameter = GetParam(); + + keycode = parameter.get_keycode(); + expected_char = parameter.get_expected_char(); + test_layout = parameter.get_layout(); + shiftstate = parameter.get_shiftstate(); + caps = parameter.get_caps(); + + std::cout << "Testing keycode: " << keycode << " expecting char: " << expected_char << " with layout: " << test_layout << " and shiftstate: " << shiftstate << " caps: " << caps << std::endl; + if (test_layout != default_layout) { + GTEST_SKIP() << "Default layout is not " << default_layout << "."; + } + + KMX_DWORD keyV = KMX_get_KeyVal_From_KeyCode( + test_keymap, + keycode, + ShiftState(convert_Shiftstate_to_LinuxShiftstate(shiftstate)), + caps); + EXPECT_EQ(keyV, expected_char) << "Failed for keycode: " << keycode; +} + +INSTANTIATE_TEST_SUITE_P(BaseUs, + GetKeyValFromKeyCodeTest, + testing::ValuesIn(GetKeyValFromKeyCodeTestParameters( + {u'a', u'b', u'c', u'd', u'e', u'f', u'g', u'h', u'i', + u'j', u'k', u'l', u'm', u'n', u'o', u'p', u'q', u'r', + u's', u't', u'u', u'v', u'w', u'x', u'y', u'z', u'0', + u'1', u'2', u'3', u'4', u'5', u'6', u'7', u'8', u'9', + u' ', u'`', u'-', u'=', u'[', u']', u'\\', u';', u'\'', + u',', u'.', u'/', u'\000', u'<'}, + "us", + 0, + 0).get_test_data())); + +INSTANTIATE_TEST_SUITE_P(ShiftUs, + GetKeyValFromKeyCodeTest, + testing::ValuesIn(GetKeyValFromKeyCodeTestParameters( + {u'A', u'B', u'C', u'D', u'E', u'F', u'G', u'H', u'I', + u'J', u'K', u'L', u'M', u'N', u'O', u'P', u'Q', u'R', + u'S', u'T', u'U', u'V', u'W', u'X', u'Y', u'Z', u')', + u'!', u'@', u'#', u'$', u'%', u'^', u'&', u'*', u'(', + u' ', u'~', u'_', u'+', u'{', u'}', u'|', u':', u'"', + u'<', u'>', u'?', u'\000', u'>'}, + "us", + K_SHIFTFLAG, + 0).get_test_data())); + + +INSTANTIATE_TEST_SUITE_P(AltGrUs, + GetKeyValFromKeyCodeTest, + testing::ValuesIn(GetKeyValFromKeyCodeTestParameters( + {u'a', u'b', u'c', u'd', u'e', u'f', u'g', u'h', u'i', u'j', u'k', + u'l', u'm', u'n', u'o', u'p', u'q', u'r', u's', u't', u'u', u'v', + u'w', u'x', u'y', u'z', u'0', u'1', u'2', u'3', u'4', u'5', u'6', + u'7', u'8', u'9', u'\000', u'`', u'-', u'=', u'[', u']', u'\\', + u';', u'\'', u',', u'.', u'/', u'\000', u'|'}, + "us", + (LCTRLFLAG | RALTFLAG) + ,0).get_test_data())); + +INSTANTIATE_TEST_SUITE_P(ShiftAltGrUs, + GetKeyValFromKeyCodeTest, + testing::ValuesIn(GetKeyValFromKeyCodeTestParameters( + {u'A', u'B', u'C', u'D', u'E', u'F', u'G', u'H', u'I', u'J', u'K', + u'L', u'M', u'N', u'O', u'P', u'Q', u'R', u'S', u'T', u'U', u'V', + u'W', u'X', u'Y', u'Z', u')', u'!', u'@', u'#', u'$', u'%', u'^', + u'&', u'*', u'(', u'\000', u'~', u'_', u'+', u'{', u'}', u'|', + u':', u'"', u'<', u'>', u'?', u'\000', u'¦'}, + "us", + (K_SHIFTFLAG | LCTRLFLAG | RALTFLAG) + ,0).get_test_data())); + +INSTANTIATE_TEST_SUITE_P(BaseDe, + GetKeyValFromKeyCodeTest, + testing::ValuesIn(GetKeyValFromKeyCodeTestParameters( + {u'a', u'b', u'c', u'd', u'e', u'f', u'g', u'h', u'i', u'j', + u'k', u'l', u'm', u'n', u'o', u'p', u'q', u'r', u's', u't', + u'u', u'v', u'w', u'x', u'z', u'y', u'0', u'1', u'2', u'3', + u'4', u'5', u'6', u'7', u'8', u'9', u' ', u'\xffff', u'ß', + u'\xffff', u'ü', u'+', u'#', u'ö', u'ä', u',', u'.', u'-', + u'\000', u'<'}, + "de", + 0, + 0).get_test_data())); + + +INSTANTIATE_TEST_SUITE_P(ShiftDe, + GetKeyValFromKeyCodeTest, + testing::ValuesIn(GetKeyValFromKeyCodeTestParameters( + {u'A', u'B', u'C', u'D', u'E', u'F', u'G', u'H', u'I', + u'J', u'K', u'L', u'M', u'N', u'O', u'P', u'Q', u'R', + u'S', u'T', u'U', u'V', u'W', u'X', u'Z', u'Y', u'=', + u'!', u'"', u'§', u'$', u'%', u'&', u'/', u'(', u')', + u' ', u'°', u'?', u'\xffff', u'Ü', u'*', u'\'', u'Ö', + u'Ä', u';', u':', u'_', u'\000', u'>'}, + "de", + K_SHIFTFLAG, + 0).get_test_data())); + + +INSTANTIATE_TEST_SUITE_P(AltGrDe, + GetKeyValFromKeyCodeTest, + testing::ValuesIn(GetKeyValFromKeyCodeTestParameters( + {u'æ', u'\xfffe', u'¢', u'ð', u'\xfffe', u'\xfffe', u'\xfffe', u'\xfffe', + u'\xfffe', u'\xffff', u'\xfffe', u'\xfffe', u'µ', u'\xfffe', u'ø', u'þ', + u'@', u'¶', u'\xfffe', u'\xfffe', u'\xfffe', u'\xfffe', u'\xfffe', u'«', + u'\xfffe', u'»', u'}', u'¹', u'²', u'³', u'¼', u'½', u'¬', u'{', u'[', + u']', u'\000', u'\xfffe', u'\\', u'\xffff', u'\xffff', u'~', u'\xfffe', + u'\xffff', u'\xffff', u'·', u'\xfffe', u'\xfffe', u'\000', u'|'}, + "de", + (LCTRLFLAG | RALTFLAG), + 0).get_test_data())); + +INSTANTIATE_TEST_SUITE_P(ShiftAltGrDe, + GetKeyValFromKeyCodeTest, + testing::ValuesIn(GetKeyValFromKeyCodeTestParameters( + {u'Æ', u'\xfffe', u'©', u'Ð', u'\xfffe', u'ª', u'\xfffe', + u'\xfffe', u'\xfffe', u'\xffff', u'&', u'\xfffe', u'º', + u'\xfffe', u'Ø', u'Þ', u'\xfffe', u'®', u'\xfffe', u'\xfffe', + u'\xfffe', u'\xfffe', u'§', u'\xfffe', u'¥', u'\xfffe', u'°', + u'¡', u'\xfffe', u'£', u'¤', u'\xfffe', u'\xfffe', u'\xfffe', + u'\xfffe', u'±', u'\000', u'\xfffe', u'¿', u'\xffff', u'\xffff', + u'¯', u'\xffff', u'\xffff', u'\xffff', u'×', u'÷', u'\xfffe', + u'\000', u'\xffff'}, + "de", + (K_SHIFTFLAG | LCTRLFLAG | RALTFLAG), + 0).get_test_data())); + + + From 61f1a2b466a71163df5053cd02594addf76e7227 Mon Sep 17 00:00:00 2001 From: Markus Greiner Date: Thu, 7 May 2026 17:37:35 +0200 Subject: [PATCH 15/23] incorporating review results - formatting - improved constructors --- linux/mcompile/keymap/test/keymap.tests.cpp | 656 +++++++++----------- 1 file changed, 310 insertions(+), 346 deletions(-) diff --git a/linux/mcompile/keymap/test/keymap.tests.cpp b/linux/mcompile/keymap/test/keymap.tests.cpp index 1f54f1ef7ab..4a2bd0ab31d 100644 --- a/linux/mcompile/keymap/test/keymap.tests.cpp +++ b/linux/mcompile/keymap/test/keymap.tests.cpp @@ -19,96 +19,80 @@ #include "keymap.h" class TestDataValues { +protected: + guint keycode; + KMX_WCHAR expected_char; + std::string layout; + guint shiftstate; - protected: - guint keycode; - KMX_WCHAR expected_char; - std::string layout; - guint shiftstate; - - - public: - TestDataValues(guint k, KMX_WCHAR e, std::string l, guint s) : keycode(k), expected_char(e), layout(l), shiftstate(s) { - this->keycode = k; - this->expected_char = e; - this->layout = l; - this->shiftstate = s; - } +public: + TestDataValues(guint k, KMX_WCHAR e, std::string l, guint s) : keycode(k), expected_char(e), layout(l), shiftstate(s) { + } - guint get_keycode() { - return keycode; - } + guint get_keycode() { + return keycode; + } - KMX_WCHAR get_expected_char() { - return expected_char; - } + KMX_WCHAR get_expected_char() { + return expected_char; + } - std::string get_layout() { - return layout; - } + std::string get_layout() { + return layout; + } - guint get_shiftstate() { - return shiftstate; - } + guint get_shiftstate() { + return shiftstate; + } }; class KeyboardTestParameters { +public: + KeyboardTestParameters(std::vector e, std::string l, guint s) : expected_keysyms(e), layout(l), shiftstate(s) { + generate_test_data_values(); + } - public: - - KeyboardTestParameters(std::vector e, std::string l, guint s) : expected_keysyms(e), layout(l), shiftstate(s) { - expected_keysyms = e; - layout = l; - shiftstate = s; - generate_test_data_values(); - } - - std::vector get_test_data() { - return test_data_values; - } + std::vector get_test_data() { + return test_data_values; + } - protected: - std::vector expected_keysyms; - std::vector test_data_values = {}; - std::string layout; - guint shiftstate; - std::vector keycodes = { 38, 56, 54, 40, 26, 41, 42, 43, 31, 44, 45, 46, 58, 57, 32, - 33, 24, 27, 39, 28, 30, 55, 25, 53, 29, 52, 19, 10, 11, 12, - 13, 14, 15, 16, 17, 18, 65, 49, 20, 21, 34, 35, 51, 47, 48, - 59, 60, 61, 123, 94}; - - void generate_test_data_values() { - EXPECT_EQ(keycodes.size(), expected_keysyms.size()) << "Keycodes and expected keysyms vectors must be of the same size."; - for (guint k = 0; k < keycodes.size() && k < expected_keysyms.size(); k++) { - test_data_values.emplace_back(TestDataValues(keycodes[k], expected_keysyms[k], layout, shiftstate)); - } +protected: + std::vector expected_keysyms; + std::vector test_data_values = {}; + std::string layout; + guint shiftstate; + std::vector keycodes = {38, 56, 54, 40, 26, 41, 42, 43, 31, 44, 45, 46, 58, 57, 32, 33, 24, + 27, 39, 28, 30, 55, 25, 53, 29, 52, 19, 10, 11, 12, 13, 14, 15, 16, + 17, 18, 65, 49, 20, 21, 34, 35, 51, 47, 48, 59, 60, 61, 123, 94}; + + void generate_test_data_values() { + EXPECT_EQ(keycodes.size(), expected_keysyms.size()) << "Keycodes and expected keysyms vectors must be of the same size."; + for (uint k = 0; k < keycodes.size() && k < expected_keysyms.size(); k++) { + test_data_values.emplace_back(TestDataValues(keycodes[k], expected_keysyms[k], layout, shiftstate)); } + } }; class KeyboardConversionTest : public testing::Test { - public: - protected: GdkKeymap* test_keymap; GdkDisplay* test_display; - gint argc = 0; + gint argc = 0; char** argv = nullptr; std::string default_layout; - private: void initialize_keymap() { gdk_init(&argc, &argv); test_display = nullptr; - test_keymap = nullptr; + test_keymap = nullptr; test_display = gdk_display_get_default(); ASSERT_NE(test_display, nullptr) << "ERROR: can't get display"; test_keymap = gdk_keymap_get_for_display(test_display); ASSERT_NE(test_keymap, nullptr) << "ERROR: Can't get keymap"; } - void retrieve_default_layout() { std::vector> sources; @@ -117,8 +101,8 @@ class KeyboardConversionTest : public testing::Test { Glib::VariantBase base; settings->get_value("sources", base); using SourcesVariant = Glib::Variant>>; - auto variant = Glib::VariantBase::cast_dynamic(base); - sources = variant.get(); + auto variant = Glib::VariantBase::cast_dynamic(base); + sources = variant.get(); if (sources.empty()) { GTEST_SKIP() << "ERROR: No input sources found"; @@ -129,12 +113,10 @@ class KeyboardConversionTest : public testing::Test { if (type == "xkb") { if (system_layout == "de" || system_layout == "us") { default_layout = system_layout; - } - else { + } else { GTEST_SKIP() << "Default layout is not DE or US."; } - } - else { + } else { GTEST_SKIP() << "Default input source type is not xkb."; } } @@ -143,7 +125,7 @@ class KeyboardConversionTest : public testing::Test { initialize_keymap(); retrieve_default_layout(); if (!GDK_IS_X11_DISPLAY(test_display)) { - GTEST_SKIP() << "Not running on X11 display, skipping tests that require X11 keymap functionality."; + GTEST_SKIP() << "Not running on X11 display, skipping tests that require X11 keymap functionality."; } } @@ -160,8 +142,7 @@ class KeyboardConversionTest : public testing::Test { }; class GetKeyValUnderlyingFromKeyCodeUnderlyingTest : public KeyboardConversionTest, - public testing::WithParamInterface { -}; + public testing::WithParamInterface {}; TEST_P(GetKeyValUnderlyingFromKeyCodeUnderlyingTest, KmxGetKeyValUnderlyingFromKeyCodeUnderlying) { guint keycode; @@ -170,188 +151,175 @@ TEST_P(GetKeyValUnderlyingFromKeyCodeUnderlyingTest, KmxGetKeyValUnderlyingFromK guint shiftstate; TestDataValues parameter = GetParam(); - keycode = parameter.get_keycode(); + keycode = parameter.get_keycode(); expected_char = parameter.get_expected_char(); - test_layout = parameter.get_layout(); - shiftstate = parameter.get_shiftstate(); + test_layout = parameter.get_layout(); + shiftstate = parameter.get_shiftstate(); - std::cout << "Testing keycode: " << keycode << " expecting char: " << expected_char << " with layout: " << test_layout << " and shiftstate: " << shiftstate << std::endl; + std::cout << "Testing keycode: " << keycode << " expecting char: " << expected_char << " with layout: " << test_layout + << " and shiftstate: " << shiftstate << std::endl; if (test_layout != default_layout) { GTEST_SKIP() << "Default layout is not " << default_layout << "."; } KMX_WCHAR deadkey; - KMX_WCHAR result = KMX_get_KeyValUnderlying_From_KeyCodeUnderlying( - test_keymap, - keycode, - shiftstate, - &deadkey - ); + KMX_WCHAR result = KMX_get_KeyValUnderlying_From_KeyCodeUnderlying(test_keymap, keycode, shiftstate, &deadkey); EXPECT_EQ(result, expected_char) << "Failed for keycode: " << keycode; } -INSTANTIATE_TEST_SUITE_P(BaseUs, - GetKeyValUnderlyingFromKeyCodeUnderlyingTest, - testing::ValuesIn(KeyboardTestParameters( - {u'a', u'b', u'c', u'd', u'e', u'f', u'g', u'h', u'i', - u'j', u'k', u'l', u'm', u'n', u'o', u'p', u'q', u'r', - u's', u't', u'u', u'v', u'w', u'x', u'y', u'z', u'0', - u'1', u'2', u'3', u'4', u'5', u'6', u'7', u'8', u'9', - u' ', u'`', u'-', u'=', u'[', u']', u'\\', u';', u'\'', - u',', u'.', u'/', u'\000', u'<'}, - "us", - 0).get_test_data())); - - -INSTANTIATE_TEST_SUITE_P(ShiftUs, - GetKeyValUnderlyingFromKeyCodeUnderlyingTest, - testing::ValuesIn(KeyboardTestParameters( - {u'A', u'B', u'C', u'D', u'E', u'F', u'G', u'H', u'I', - u'J', u'K', u'L', u'M', u'N', u'O', u'P', u'Q', u'R', - u'S', u'T', u'U', u'V', u'W', u'X', u'Y', u'Z', u')', - u'!', u'@', u'#', u'$', u'%', u'^', u'&', u'*', u'(', - u' ', u'~', u'_', u'+', u'{', u'}', u'|', u':', u'"', - u'<', u'>', u'?', u'\000', u'>'}, - "us", - K_SHIFTFLAG).get_test_data())); - - -INSTANTIATE_TEST_SUITE_P(AltGrUs, - GetKeyValUnderlyingFromKeyCodeUnderlyingTest, - testing::ValuesIn(KeyboardTestParameters( - {u'a', u'b', u'c', u'd', u'e', u'f', u'g', u'h', u'i', u'j', u'k', - u'l', u'm', u'n', u'o', u'p', u'q', u'r', u's', u't', u'u', u'v', - u'w', u'x', u'y', u'z', u'0', u'1', u'2', u'3', u'4', u'5', u'6', - u'7', u'8', u'9', u'\000', u'`', u'-', u'=', u'[', u']', u'\\', - u';', u'\'', u',', u'.', u'/', u'\000', u'|'}, - "us", - (LCTRLFLAG | RALTFLAG)).get_test_data())); - -INSTANTIATE_TEST_SUITE_P(ShiftAltGrUs, - GetKeyValUnderlyingFromKeyCodeUnderlyingTest, - testing::ValuesIn(KeyboardTestParameters( - {u'A', u'B', u'C', u'D', u'E', u'F', u'G', u'H', u'I', u'J', u'K', - u'L', u'M', u'N', u'O', u'P', u'Q', u'R', u'S', u'T', u'U', u'V', - u'W', u'X', u'Y', u'Z', u')', u'!', u'@', u'#', u'$', u'%', u'^', - u'&', u'*', u'(', u'\000', u'~', u'_', u'+', u'{', u'}', u'|', - u':', u'"', u'<', u'>', u'?', u'\000', u'¦'}, - "us", - (K_SHIFTFLAG | LCTRLFLAG | RALTFLAG)).get_test_data())); - -INSTANTIATE_TEST_SUITE_P(BaseDe, - GetKeyValUnderlyingFromKeyCodeUnderlyingTest, - testing::ValuesIn(KeyboardTestParameters( - {u'a', u'b', u'c', u'd', u'e', u'f', u'g', u'h', u'i', u'j', - u'k', u'l', u'm', u'n', u'o', u'p', u'q', u'r', u's', u't', - u'u', u'v', u'w', u'x', u'z', u'y', u'0', u'1', u'2', u'3', - u'4', u'5', u'6', u'7', u'8', u'9', u' ', u'\xffff', u'ß', - u'\xffff', u'ü', u'+', u'#', u'ö', u'ä', u',', u'.', u'-', - u'\000', u'<'}, - "de", - 0).get_test_data())); - - -INSTANTIATE_TEST_SUITE_P(ShiftDe, - GetKeyValUnderlyingFromKeyCodeUnderlyingTest, - testing::ValuesIn(KeyboardTestParameters( - {u'A', u'B', u'C', u'D', u'E', u'F', u'G', u'H', u'I', - u'J', u'K', u'L', u'M', u'N', u'O', u'P', u'Q', u'R', - u'S', u'T', u'U', u'V', u'W', u'X', u'Z', u'Y', u'=', - u'!', u'"', u'§', u'$', u'%', u'&', u'/', u'(', u')', - u' ', u'°', u'?', u'\xffff', u'Ü', u'*', u'\'', u'Ö', - u'Ä', u';', u':', u'_', u'\000', u'>'}, - "de", - K_SHIFTFLAG).get_test_data())); - - -INSTANTIATE_TEST_SUITE_P(AltGrDe, - GetKeyValUnderlyingFromKeyCodeUnderlyingTest, - testing::ValuesIn(KeyboardTestParameters( - {u'æ', u'\xfffe', u'¢', u'ð', u'\xfffe', u'\xfffe', u'\xfffe', u'\xfffe', - u'\xfffe', u'\xffff', u'\xfffe', u'\xfffe', u'µ', u'\xfffe', u'ø', u'þ', - u'@', u'¶', u'\xfffe', u'\xfffe', u'\xfffe', u'\xfffe', u'\xfffe', u'«', - u'\xfffe', u'»', u'}', u'¹', u'²', u'³', u'¼', u'½', u'¬', u'{', u'[', - u']', u'\000', u'\xfffe', u'\\', u'\xffff', u'\xffff', u'~', u'\xfffe', - u'\xffff', u'\xffff', u'·', u'\xfffe', u'\xfffe', u'\000', u'|'}, - "de", - (LCTRLFLAG | RALTFLAG)).get_test_data())); - -INSTANTIATE_TEST_SUITE_P(ShiftAltGrDe, - GetKeyValUnderlyingFromKeyCodeUnderlyingTest, - testing::ValuesIn(KeyboardTestParameters( - {u'Æ', u'\xfffe', u'©', u'Ð', u'\xfffe', u'ª', u'\xfffe', - u'\xfffe', u'\xfffe', u'\xffff', u'&', u'\xfffe', u'º', - u'\xfffe', u'Ø', u'Þ', u'\xfffe', u'®', u'\xfffe', u'\xfffe', - u'\xfffe', u'\xfffe', u'§', u'\xfffe', u'¥', u'\xfffe', u'°', - u'¡', u'\xfffe', u'£', u'¤', u'\xfffe', u'\xfffe', u'\xfffe', - u'\xfffe', u'±', u'\000', u'\xfffe', u'¿', u'\xffff', u'\xffff', - u'¯', u'\xffff', u'\xffff', u'\xffff', u'×', u'÷', u'\xfffe', - u'\000', u'\xffff'}, - "de", - (K_SHIFTFLAG | LCTRLFLAG | RALTFLAG)).get_test_data())); - +INSTANTIATE_TEST_SUITE_P( + BaseUs, + GetKeyValUnderlyingFromKeyCodeUnderlyingTest, + testing::ValuesIn(KeyboardTestParameters( + {u'a', u'b', u'c', u'd', u'e', u'f', u'g', u'h', u'i', u'j', + u'k', u'l', u'm', u'n', u'o', u'p', u'q', u'r', u's', u't', + u'u', u'v', u'w', u'x', u'y', u'z', u'0', u'1', u'2', u'3', + u'4', u'5', u'6', u'7', u'8', u'9', u' ', u'`', u'-', u'=', + u'[', u']', u'\\', u';', u'\'', u',', u'.', u'/', u'\000', u'<'}, + "us", + 0) + .get_test_data())); + +INSTANTIATE_TEST_SUITE_P( + ShiftUs, + GetKeyValUnderlyingFromKeyCodeUnderlyingTest, + testing::ValuesIn(KeyboardTestParameters( + {u'A', u'B', u'C', u'D', u'E', u'F', u'G', u'H', u'I', u'J', + u'K', u'L', u'M', u'N', u'O', u'P', u'Q', u'R', u'S', u'T', + u'U', u'V', u'W', u'X', u'Y', u'Z', u')', u'!', u'@', u'#', + u'$', u'%', u'^', u'&', u'*', u'(', u' ', u'~', u'_', u'+', + u'{', u'}', u'|', u':', u'"', u'<', u'>', u'?', u'\000', u'>'}, + "us", + K_SHIFTFLAG) + .get_test_data())); + +INSTANTIATE_TEST_SUITE_P( + AltGrUs, + GetKeyValUnderlyingFromKeyCodeUnderlyingTest, + testing::ValuesIn(KeyboardTestParameters( + {u'a', u'b', u'c', u'd', u'e', u'f',u'g', u'h', u'i', u'j', + u'k', u'l', u'm', u'n', u'o', u'p', u'q', u'r', u's', u't', + u'u', u'v', u'w', u'x', u'y', u'z', u'0', u'1', u'2', u'3', + u'4', u'5', u'6', u'7', u'8', u'9', u'\000', u'`', u'-', u'=', + u'[', u']', u'\\', u';', u'\'', u',', u'.', u'/', u'\000', u'|'}, + "us", + (LCTRLFLAG | RALTFLAG)) + .get_test_data())); + +INSTANTIATE_TEST_SUITE_P( + ShiftAltGrUs, + GetKeyValUnderlyingFromKeyCodeUnderlyingTest, + testing::ValuesIn(KeyboardTestParameters( + {u'A', u'B', u'C', u'D', u'E', u'F', u'G', u'H', u'I', u'J', + u'K', u'L', u'M', u'N', u'O', u'P', u'Q', u'R', u'S', u'T', + u'U', u'V', u'W', u'X', u'Y', u'Z', u')', u'!', u'@', u'#', + u'$', u'%', u'^', u'&', u'*', u'(', u'\000', u'~', u'_', u'+', + u'{', u'}', u'|', u':', u'"', u'<', u'>', u'?', u'\000', u'¦'}, + "us", + (K_SHIFTFLAG | LCTRLFLAG | RALTFLAG)) + .get_test_data())); + +INSTANTIATE_TEST_SUITE_P( + BaseDe, + GetKeyValUnderlyingFromKeyCodeUnderlyingTest, + testing::ValuesIn(KeyboardTestParameters( + {u'a', u'b', u'c', u'd', u'e', u'f', u'g', u'h', u'i', u'j', + u'k', u'l', u'm', u'n', u'o', u'p', u'q', u'r', u's', u't', + u'u', u'v', u'w', u'x', u'z', u'y', u'0', u'1', u'2', u'3', + u'4', u'5', u'6', u'7', u'8', u'9', u' ', u'\xffff', u'ß', u'\xffff', + u'ü', u'+', u'#', u'ö', u'ä', u',', u'.', u'-', u'\000', u'<'}, + "de", + 0) + .get_test_data())); + +INSTANTIATE_TEST_SUITE_P( + ShiftDe, + GetKeyValUnderlyingFromKeyCodeUnderlyingTest, + testing::ValuesIn(KeyboardTestParameters( + {u'A', u'B', u'C', u'D', u'E', u'F', u'G', u'H', u'I', u'J', + u'K', u'L', u'M', u'N', u'O', u'P', u'Q', u'R', u'S', u'T', + u'U', u'V', u'W', u'X', u'Z', u'Y', u'=', u'!', u'"', u'§', + u'$', u'%', u'&', u'/', u'(', u')', u' ', u'°', u'?', u'\xffff', + u'Ü', u'*', u'\'', u'Ö', u'Ä', u';', u':', u'_', u'\000', u'>'}, + "de", + K_SHIFTFLAG) + .get_test_data())); + +INSTANTIATE_TEST_SUITE_P( + AltGrDe, + GetKeyValUnderlyingFromKeyCodeUnderlyingTest, + testing::ValuesIn(KeyboardTestParameters( + {u'æ', u'\xfffe', u'¢', u'ð', u'\xfffe', u'\xfffe', u'\xfffe', u'\xfffe', u'\xfffe', u'\xffff', + u'\xfffe', u'\xfffe', u'µ', u'\xfffe', u'ø', u'þ', u'@', u'¶', u'\xfffe', u'\xfffe', + u'\xfffe', u'\xfffe', u'\xfffe', u'«', u'\xfffe', u'»', u'}', u'¹', u'²', u'³', + u'¼', u'½', u'¬', u'{', u'[', u']', u'\000', u'\xfffe', u'\\', u'\xffff', + u'\xffff', u'~', u'\xfffe', u'\xffff', u'\xffff', u'·', u'\xfffe', u'\xfffe', u'\000', u'|'}, + "de", + (LCTRLFLAG | RALTFLAG)) + .get_test_data())); + +INSTANTIATE_TEST_SUITE_P( + ShiftAltGrDe, + GetKeyValUnderlyingFromKeyCodeUnderlyingTest, + testing::ValuesIn(KeyboardTestParameters( + {u'Æ', u'\xfffe', u'©', u'Ð', u'\xfffe', u'ª', u'\xfffe', u'\xfffe', u'\xfffe', u'\xffff', + u'&', u'\xfffe', u'º', u'\xfffe', u'Ø', u'Þ', u'\xfffe', u'®', u'\xfffe', u'\xfffe', + u'\xfffe', u'\xfffe', u'§', u'\xfffe', u'¥', u'\xfffe', u'°', u'¡', u'\xfffe', u'£', + u'¤', u'\xfffe', u'\xfffe', u'\xfffe', u'\xfffe', u'±', u'\000', u'\xfffe', u'¿', u'\xffff', + u'\xffff', u'¯', u'\xffff', u'\xffff', u'\xffff', u'×', u'÷', u'\xfffe', u'\000', u'\xffff'}, + "de", + (K_SHIFTFLAG | LCTRLFLAG | RALTFLAG)) + .get_test_data())); class GetKeyValFromKeyCodeTestDataValues : public TestDataValues { - public: - GetKeyValFromKeyCodeTestDataValues(guint k, KMX_WCHAR e, std::string l, guint s, int c) : - TestDataValues(k, e, l, s), caps(c) { - keycode = k; - expected_char = e; - layout = l; - shiftstate = s; - caps = c; - } - - int get_caps() { - return caps; - } +public: + GetKeyValFromKeyCodeTestDataValues(guint k, KMX_WCHAR e, std::string l, guint s, int c) : TestDataValues(k, e, l, s), caps(c) { + } - protected: - int caps; + int get_caps() { + return caps; + } +protected: + int caps; }; class GetKeyValFromKeyCodeTestParameters { - public: - - GetKeyValFromKeyCodeTestParameters(std::vector e, std::string l, guint s, int c) : expected_keysyms(e), layout(l), shiftstate(s), caps(c) { - expected_keysyms = e; - layout = l; - shiftstate = s; - caps = c; - generate_test_data_values(); - } - - std::vector get_test_data() { - return test_data_values; - } - - - protected: - std::vector expected_keysyms; - std::vector test_data_values = {}; - std::string layout; - guint shiftstate; - int caps; - std::vector keycodes = { 38, 56, 54, 40, 26, 41, 42, 43, 31, 44, 45, 46, 58, 57, 32, - 33, 24, 27, 39, 28, 30, 55, 25, 53, 29, 52, 19, 10, 11, 12, - 13, 14, 15, 16, 17, 18, 65, 49, 20, 21, 34, 35, 51, 47, 48, - 59, 60, 61, 123, 94}; +public: + GetKeyValFromKeyCodeTestParameters(std::vector e, std::string l, guint s, int c) + : expected_keysyms(e), layout(l), shiftstate(s), caps(c) { + expected_keysyms = e; + layout = l; + shiftstate = s; + caps = c; + generate_test_data_values(); + } + std::vector get_test_data() { + return test_data_values; + } - void generate_test_data_values(){ - EXPECT_EQ(keycodes.size(), expected_keysyms.size()) << "Keycodes and expected keysyms vectors must be of the same size."; - for (guint k = 0; k < keycodes.size() && k < expected_keysyms.size(); k++) { - test_data_values.emplace_back(GetKeyValFromKeyCodeTestDataValues(keycodes[k], expected_keysyms[k], layout, shiftstate, caps)); - } +protected: + std::vector expected_keysyms; + std::vector test_data_values = {}; + std::string layout; + guint shiftstate; + int caps; + std::vector keycodes = {38, 56, 54, 40, 26, 41, 42, 43, 31, 44, 45, 46, 58, 57, 32, 33, 24, + 27, 39, 28, 30, 55, 25, 53, 29, 52, 19, 10, 11, 12, 13, 14, 15, 16, + 17, 18, 65, 49, 20, 21, 34, 35, 51, 47, 48, 59, 60, 61, 123, 94}; + + void generate_test_data_values() { + EXPECT_EQ(keycodes.size(), expected_keysyms.size()) << "Keycodes and expected keysyms vectors must be of the same size."; + for (guint k = 0; k < keycodes.size() && k < expected_keysyms.size(); k++) { + test_data_values.emplace_back( + GetKeyValFromKeyCodeTestDataValues(keycodes[k], expected_keysyms[k], layout, shiftstate, caps)); } + } }; class GetKeyValFromKeyCodeTest : public KeyboardConversionTest, - public testing::WithParamInterface { - -}; - + public testing::WithParamInterface {}; TEST_P(GetKeyValFromKeyCodeTest, kmxGetKeyValFromKeyCode) { guint keycode; @@ -362,131 +330,127 @@ TEST_P(GetKeyValFromKeyCodeTest, kmxGetKeyValFromKeyCode) { GetKeyValFromKeyCodeTestDataValues parameter = GetParam(); - keycode = parameter.get_keycode(); + keycode = parameter.get_keycode(); expected_char = parameter.get_expected_char(); - test_layout = parameter.get_layout(); - shiftstate = parameter.get_shiftstate(); - caps = parameter.get_caps(); + test_layout = parameter.get_layout(); + shiftstate = parameter.get_shiftstate(); + caps = parameter.get_caps(); - std::cout << "Testing keycode: " << keycode << " expecting char: " << expected_char << " with layout: " << test_layout << " and shiftstate: " << shiftstate << " caps: " << caps << std::endl; + std::cout << "Testing keycode: " << keycode << " expecting char: " << expected_char << " with layout: " << test_layout + << " and shiftstate: " << shiftstate << " caps: " << caps << std::endl; if (test_layout != default_layout) { GTEST_SKIP() << "Default layout is not " << default_layout << "."; } - KMX_DWORD keyV = KMX_get_KeyVal_From_KeyCode( - test_keymap, - keycode, - ShiftState(convert_Shiftstate_to_LinuxShiftstate(shiftstate)), - caps); + KMX_DWORD keyV = + KMX_get_KeyVal_From_KeyCode(test_keymap, keycode, ShiftState(convert_Shiftstate_to_LinuxShiftstate(shiftstate)), caps); EXPECT_EQ(keyV, expected_char) << "Failed for keycode: " << keycode; } -INSTANTIATE_TEST_SUITE_P(BaseUs, - GetKeyValFromKeyCodeTest, - testing::ValuesIn(GetKeyValFromKeyCodeTestParameters( - {u'a', u'b', u'c', u'd', u'e', u'f', u'g', u'h', u'i', - u'j', u'k', u'l', u'm', u'n', u'o', u'p', u'q', u'r', - u's', u't', u'u', u'v', u'w', u'x', u'y', u'z', u'0', - u'1', u'2', u'3', u'4', u'5', u'6', u'7', u'8', u'9', - u' ', u'`', u'-', u'=', u'[', u']', u'\\', u';', u'\'', - u',', u'.', u'/', u'\000', u'<'}, - "us", - 0, - 0).get_test_data())); - -INSTANTIATE_TEST_SUITE_P(ShiftUs, - GetKeyValFromKeyCodeTest, - testing::ValuesIn(GetKeyValFromKeyCodeTestParameters( - {u'A', u'B', u'C', u'D', u'E', u'F', u'G', u'H', u'I', - u'J', u'K', u'L', u'M', u'N', u'O', u'P', u'Q', u'R', - u'S', u'T', u'U', u'V', u'W', u'X', u'Y', u'Z', u')', - u'!', u'@', u'#', u'$', u'%', u'^', u'&', u'*', u'(', - u' ', u'~', u'_', u'+', u'{', u'}', u'|', u':', u'"', - u'<', u'>', u'?', u'\000', u'>'}, - "us", - K_SHIFTFLAG, - 0).get_test_data())); - - -INSTANTIATE_TEST_SUITE_P(AltGrUs, - GetKeyValFromKeyCodeTest, - testing::ValuesIn(GetKeyValFromKeyCodeTestParameters( - {u'a', u'b', u'c', u'd', u'e', u'f', u'g', u'h', u'i', u'j', u'k', - u'l', u'm', u'n', u'o', u'p', u'q', u'r', u's', u't', u'u', u'v', - u'w', u'x', u'y', u'z', u'0', u'1', u'2', u'3', u'4', u'5', u'6', - u'7', u'8', u'9', u'\000', u'`', u'-', u'=', u'[', u']', u'\\', - u';', u'\'', u',', u'.', u'/', u'\000', u'|'}, - "us", - (LCTRLFLAG | RALTFLAG) - ,0).get_test_data())); - -INSTANTIATE_TEST_SUITE_P(ShiftAltGrUs, - GetKeyValFromKeyCodeTest, - testing::ValuesIn(GetKeyValFromKeyCodeTestParameters( - {u'A', u'B', u'C', u'D', u'E', u'F', u'G', u'H', u'I', u'J', u'K', - u'L', u'M', u'N', u'O', u'P', u'Q', u'R', u'S', u'T', u'U', u'V', - u'W', u'X', u'Y', u'Z', u')', u'!', u'@', u'#', u'$', u'%', u'^', - u'&', u'*', u'(', u'\000', u'~', u'_', u'+', u'{', u'}', u'|', - u':', u'"', u'<', u'>', u'?', u'\000', u'¦'}, - "us", - (K_SHIFTFLAG | LCTRLFLAG | RALTFLAG) - ,0).get_test_data())); - -INSTANTIATE_TEST_SUITE_P(BaseDe, - GetKeyValFromKeyCodeTest, - testing::ValuesIn(GetKeyValFromKeyCodeTestParameters( - {u'a', u'b', u'c', u'd', u'e', u'f', u'g', u'h', u'i', u'j', - u'k', u'l', u'm', u'n', u'o', u'p', u'q', u'r', u's', u't', - u'u', u'v', u'w', u'x', u'z', u'y', u'0', u'1', u'2', u'3', - u'4', u'5', u'6', u'7', u'8', u'9', u' ', u'\xffff', u'ß', - u'\xffff', u'ü', u'+', u'#', u'ö', u'ä', u',', u'.', u'-', - u'\000', u'<'}, - "de", - 0, - 0).get_test_data())); - - -INSTANTIATE_TEST_SUITE_P(ShiftDe, - GetKeyValFromKeyCodeTest, - testing::ValuesIn(GetKeyValFromKeyCodeTestParameters( - {u'A', u'B', u'C', u'D', u'E', u'F', u'G', u'H', u'I', - u'J', u'K', u'L', u'M', u'N', u'O', u'P', u'Q', u'R', - u'S', u'T', u'U', u'V', u'W', u'X', u'Z', u'Y', u'=', - u'!', u'"', u'§', u'$', u'%', u'&', u'/', u'(', u')', - u' ', u'°', u'?', u'\xffff', u'Ü', u'*', u'\'', u'Ö', - u'Ä', u';', u':', u'_', u'\000', u'>'}, - "de", - K_SHIFTFLAG, - 0).get_test_data())); - - -INSTANTIATE_TEST_SUITE_P(AltGrDe, - GetKeyValFromKeyCodeTest, - testing::ValuesIn(GetKeyValFromKeyCodeTestParameters( - {u'æ', u'\xfffe', u'¢', u'ð', u'\xfffe', u'\xfffe', u'\xfffe', u'\xfffe', - u'\xfffe', u'\xffff', u'\xfffe', u'\xfffe', u'µ', u'\xfffe', u'ø', u'þ', - u'@', u'¶', u'\xfffe', u'\xfffe', u'\xfffe', u'\xfffe', u'\xfffe', u'«', - u'\xfffe', u'»', u'}', u'¹', u'²', u'³', u'¼', u'½', u'¬', u'{', u'[', - u']', u'\000', u'\xfffe', u'\\', u'\xffff', u'\xffff', u'~', u'\xfffe', - u'\xffff', u'\xffff', u'·', u'\xfffe', u'\xfffe', u'\000', u'|'}, - "de", - (LCTRLFLAG | RALTFLAG), - 0).get_test_data())); - -INSTANTIATE_TEST_SUITE_P(ShiftAltGrDe, - GetKeyValFromKeyCodeTest, - testing::ValuesIn(GetKeyValFromKeyCodeTestParameters( - {u'Æ', u'\xfffe', u'©', u'Ð', u'\xfffe', u'ª', u'\xfffe', - u'\xfffe', u'\xfffe', u'\xffff', u'&', u'\xfffe', u'º', - u'\xfffe', u'Ø', u'Þ', u'\xfffe', u'®', u'\xfffe', u'\xfffe', - u'\xfffe', u'\xfffe', u'§', u'\xfffe', u'¥', u'\xfffe', u'°', - u'¡', u'\xfffe', u'£', u'¤', u'\xfffe', u'\xfffe', u'\xfffe', - u'\xfffe', u'±', u'\000', u'\xfffe', u'¿', u'\xffff', u'\xffff', - u'¯', u'\xffff', u'\xffff', u'\xffff', u'×', u'÷', u'\xfffe', - u'\000', u'\xffff'}, - "de", - (K_SHIFTFLAG | LCTRLFLAG | RALTFLAG), - 0).get_test_data())); - - - +INSTANTIATE_TEST_SUITE_P( + BaseUs, + GetKeyValFromKeyCodeTest, + testing::ValuesIn(GetKeyValFromKeyCodeTestParameters( + {u'a', u'b', u'c', u'd', u'e', u'f', u'g', u'h', u'i', u'j', u'k', u'l', u'm', + u'n', u'o', u'p', u'q', u'r', u's', u't', u'u', u'v', u'w', u'x', u'y', u'z', + u'0', u'1', u'2', u'3', u'4', u'5', u'6', u'7', u'8', u'9', u' ', u'`', u'-', + u'=', u'[', u']', u'\\', u';', u'\'', u',', u'.', u'/', u'\000', u'<'}, + "us", + 0, + 0) + .get_test_data())); + +INSTANTIATE_TEST_SUITE_P( + ShiftUs, + GetKeyValFromKeyCodeTest, + testing::ValuesIn(GetKeyValFromKeyCodeTestParameters( + {u'A', u'B', u'C', u'D', u'E', u'F', u'G', u'H', u'I', u'J', u'K', u'L', u'M', + u'N', u'O', u'P', u'Q', u'R', u'S', u'T', u'U', u'V', u'W', u'X', u'Y', u'Z', + u')', u'!', u'@', u'#', u'$', u'%', u'^', u'&', u'*', u'(', u' ', u'~', u'_', + u'+', u'{', u'}', u'|', u':', u'"', u'<', u'>', u'?', u'\000', u'>'}, + "us", + K_SHIFTFLAG, + 0) + .get_test_data())); + +INSTANTIATE_TEST_SUITE_P( + AltGrUs, + GetKeyValFromKeyCodeTest, + testing::ValuesIn(GetKeyValFromKeyCodeTestParameters( + {u'a', u'b', u'c', u'd', u'e', u'f', u'g', u'h', u'i', u'j', u'k', u'l', u'm', + u'n', u'o', u'p', u'q', u'r', u's', u't', u'u', u'v', u'w', u'x', u'y', u'z', + u'0', u'1', u'2', u'3', u'4', u'5', u'6', u'7', u'8', u'9', u'\000', u'`', u'-', + u'=', u'[', u']', u'\\', u';', u'\'', u',', u'.', u'/', u'\000', u'|'}, + "us", + (LCTRLFLAG | RALTFLAG), + 0) + .get_test_data())); + +INSTANTIATE_TEST_SUITE_P( + ShiftAltGrUs, + GetKeyValFromKeyCodeTest, + testing::ValuesIn(GetKeyValFromKeyCodeTestParameters( + {u'A', u'B', u'C', u'D', u'E', u'F', u'G', u'H', u'I', u'J', u'K', u'L', u'M', + u'N', u'O', u'P', u'Q', u'R', u'S', u'T', u'U', u'V', u'W', u'X', u'Y', u'Z', + u')', u'!', u'@', u'#', u'$', u'%', u'^', u'&', u'*', u'(', u'\000', u'~', u'_', + u'+', u'{', u'}', u'|', u':', u'"', u'<', u'>', u'?', u'\000', u'¦'}, + "us", + (K_SHIFTFLAG | LCTRLFLAG | RALTFLAG), + 0) + .get_test_data())); + +INSTANTIATE_TEST_SUITE_P( + BaseDe, + GetKeyValFromKeyCodeTest, + testing::ValuesIn(GetKeyValFromKeyCodeTestParameters( + {u'a', u'b', u'c', u'd', u'e', u'f', u'g', u'h', u'i', u'j', u'k', u'l', u'm', + u'n', u'o', u'p', u'q', u'r', u's', u't', u'u', u'v', u'w', u'x', u'z', u'y', + u'0', u'1', u'2', u'3', u'4', u'5', u'6', u'7', u'8', u'9', u' ', u'\xffff', u'ß', + u'\xffff', u'ü', u'+', u'#', u'ö', u'ä', u',', u'.', u'-', u'\000', u'<'}, + "de", + 0, + 0) + .get_test_data())); + +INSTANTIATE_TEST_SUITE_P( + ShiftDe, + GetKeyValFromKeyCodeTest, + testing::ValuesIn(GetKeyValFromKeyCodeTestParameters( + {u'A', u'B', u'C', u'D', u'E', u'F', u'G', u'H', u'I', u'J', u'K', u'L', u'M', + u'N', u'O', u'P', u'Q', u'R', u'S', u'T', u'U', u'V', u'W', u'X', u'Z', u'Y', + u'=', u'!', u'"', u'§', u'$', u'%', u'&', u'/', u'(', u')', u' ', u'°', u'?', + u'\xffff', u'Ü', u'*', u'\'', u'Ö', u'Ä', u';', u':', u'_', u'\000', u'>'}, + "de", + K_SHIFTFLAG, + 0) + .get_test_data())); + +INSTANTIATE_TEST_SUITE_P( + AltGrDe, + GetKeyValFromKeyCodeTest, + testing::ValuesIn(GetKeyValFromKeyCodeTestParameters( + {u'æ', u'\xfffe', u'¢', u'ð', u'\xfffe', u'\xfffe', u'\xfffe', u'\xfffe', u'\xfffe', + u'\xffff', u'\xfffe', u'\xfffe', u'µ', u'\xfffe', u'ø', u'þ', u'@', u'¶', + u'\xfffe', u'\xfffe', u'\xfffe', u'\xfffe', u'\xfffe', u'«', u'\xfffe', u'»', u'}', + u'¹', u'²', u'³', u'¼', u'½', u'¬', u'{', u'[', u']', + u'\000', u'\xfffe', u'\\', u'\xffff', u'\xffff', u'~', u'\xfffe', u'\xffff', u'\xffff', + u'·', u'\xfffe', u'\xfffe', u'\000', u'|'}, + "de", + (LCTRLFLAG | RALTFLAG), + 0) + .get_test_data())); + +INSTANTIATE_TEST_SUITE_P( + ShiftAltGrDe, + GetKeyValFromKeyCodeTest, + testing::ValuesIn(GetKeyValFromKeyCodeTestParameters( + {u'Æ', u'\xfffe', u'©', u'Ð', u'\xfffe', u'ª', u'\xfffe', u'\xfffe', u'\xfffe', + u'\xffff', u'&', u'\xfffe', u'º', u'\xfffe', u'Ø', u'Þ', u'\xfffe', u'®', + u'\xfffe', u'\xfffe', u'\xfffe', u'\xfffe', u'§', u'\xfffe', u'¥', u'\xfffe', u'°', + u'¡', u'\xfffe', u'£', u'¤', u'\xfffe', u'\xfffe', u'\xfffe', u'\xfffe', u'±', + u'\000', u'\xfffe', u'¿', u'\xffff', u'\xffff', u'¯', u'\xffff', u'\xffff', u'\xffff', + u'×', u'÷', u'\xfffe', u'\000', u'\xffff'}, + "de", + (K_SHIFTFLAG | LCTRLFLAG | RALTFLAG), + 0) + .get_test_data())); From 88030893ff3b0d23a6ebc41be911efb208832b14 Mon Sep 17 00:00:00 2001 From: Markus Greiner Date: Thu, 7 May 2026 23:16:36 +0200 Subject: [PATCH 16/23] reformatting test parameters --- linux/mcompile/keymap/test/keymap.tests.cpp | 65 +++++++++++---------- 1 file changed, 35 insertions(+), 30 deletions(-) diff --git a/linux/mcompile/keymap/test/keymap.tests.cpp b/linux/mcompile/keymap/test/keymap.tests.cpp index 4a2bd0ab31d..d993f66e239 100644 --- a/linux/mcompile/keymap/test/keymap.tests.cpp +++ b/linux/mcompile/keymap/test/keymap.tests.cpp @@ -351,10 +351,11 @@ INSTANTIATE_TEST_SUITE_P( BaseUs, GetKeyValFromKeyCodeTest, testing::ValuesIn(GetKeyValFromKeyCodeTestParameters( - {u'a', u'b', u'c', u'd', u'e', u'f', u'g', u'h', u'i', u'j', u'k', u'l', u'm', - u'n', u'o', u'p', u'q', u'r', u's', u't', u'u', u'v', u'w', u'x', u'y', u'z', - u'0', u'1', u'2', u'3', u'4', u'5', u'6', u'7', u'8', u'9', u' ', u'`', u'-', - u'=', u'[', u']', u'\\', u';', u'\'', u',', u'.', u'/', u'\000', u'<'}, + {u'a', u'b', u'c', u'd', u'e', u'f', u'g', u'h', u'i', u'j', + u'k', u'l', u'm', u'n', u'o', u'p', u'q', u'r', u's', u't', + u'u', u'v', u'w', u'x', u'y', u'z', u'0', u'1', u'2', u'3', + u'4', u'5', u'6', u'7', u'8', u'9', u' ', u'`', u'-', u'=', + u'[', u']', u'\\', u';', u'\'', u',', u'.', u'/', u'\000', u'<'}, "us", 0, 0) @@ -364,10 +365,11 @@ INSTANTIATE_TEST_SUITE_P( ShiftUs, GetKeyValFromKeyCodeTest, testing::ValuesIn(GetKeyValFromKeyCodeTestParameters( - {u'A', u'B', u'C', u'D', u'E', u'F', u'G', u'H', u'I', u'J', u'K', u'L', u'M', - u'N', u'O', u'P', u'Q', u'R', u'S', u'T', u'U', u'V', u'W', u'X', u'Y', u'Z', - u')', u'!', u'@', u'#', u'$', u'%', u'^', u'&', u'*', u'(', u' ', u'~', u'_', - u'+', u'{', u'}', u'|', u':', u'"', u'<', u'>', u'?', u'\000', u'>'}, + {u'A', u'B', u'C', u'D', u'E', u'F', u'G', u'H', u'I', u'J', + u'K', u'L', u'M', u'N', u'O', u'P', u'Q', u'R', u'S', u'T', + u'U', u'V', u'W', u'X', u'Y', u'Z', u')', u'!', u'@', u'#', + u'$', u'%', u'^', u'&', u'*', u'(', u' ', u'~', u'_', u'+', + u'{', u'}', u'|', u':', u'"', u'<', u'>', u'?', u'\000', u'>'}, "us", K_SHIFTFLAG, 0) @@ -377,10 +379,11 @@ INSTANTIATE_TEST_SUITE_P( AltGrUs, GetKeyValFromKeyCodeTest, testing::ValuesIn(GetKeyValFromKeyCodeTestParameters( - {u'a', u'b', u'c', u'd', u'e', u'f', u'g', u'h', u'i', u'j', u'k', u'l', u'm', - u'n', u'o', u'p', u'q', u'r', u's', u't', u'u', u'v', u'w', u'x', u'y', u'z', - u'0', u'1', u'2', u'3', u'4', u'5', u'6', u'7', u'8', u'9', u'\000', u'`', u'-', - u'=', u'[', u']', u'\\', u';', u'\'', u',', u'.', u'/', u'\000', u'|'}, + {u'a', u'b', u'c', u'd', u'e', u'f', u'g', u'h', u'i', u'j', + u'k', u'l', u'm', u'n', u'o', u'p', u'q', u'r', u's', u't', + u'u', u'v', u'w', u'x', u'y', u'z', u'0', u'1', u'2', u'3', + u'4', u'5', u'6', u'7', u'8', u'9', u'\000', u'`', u'-', u'=', + u'[', u']', u'\\', u';', u'\'', u',', u'.', u'/', u'\000', u'|'}, "us", (LCTRLFLAG | RALTFLAG), 0) @@ -390,10 +393,11 @@ INSTANTIATE_TEST_SUITE_P( ShiftAltGrUs, GetKeyValFromKeyCodeTest, testing::ValuesIn(GetKeyValFromKeyCodeTestParameters( - {u'A', u'B', u'C', u'D', u'E', u'F', u'G', u'H', u'I', u'J', u'K', u'L', u'M', - u'N', u'O', u'P', u'Q', u'R', u'S', u'T', u'U', u'V', u'W', u'X', u'Y', u'Z', - u')', u'!', u'@', u'#', u'$', u'%', u'^', u'&', u'*', u'(', u'\000', u'~', u'_', - u'+', u'{', u'}', u'|', u':', u'"', u'<', u'>', u'?', u'\000', u'¦'}, + {u'A', u'B', u'C', u'D', u'E', u'F', u'G', u'H', u'I', u'J', + u'K', u'L', u'M', u'N', u'O', u'P', u'Q', u'R', u'S', u'T', + u'U', u'V', u'W', u'X', u'Y', u'Z', u')', u'!', u'@', u'#', + u'$', u'%', u'^', u'&', u'*', u'(', u'\000', u'~', u'_', u'+', + u'{', u'}', u'|', u':', u'"', u'<', u'>', u'?', u'\000', u'¦'}, "us", (K_SHIFTFLAG | LCTRLFLAG | RALTFLAG), 0) @@ -403,10 +407,11 @@ INSTANTIATE_TEST_SUITE_P( BaseDe, GetKeyValFromKeyCodeTest, testing::ValuesIn(GetKeyValFromKeyCodeTestParameters( - {u'a', u'b', u'c', u'd', u'e', u'f', u'g', u'h', u'i', u'j', u'k', u'l', u'm', - u'n', u'o', u'p', u'q', u'r', u's', u't', u'u', u'v', u'w', u'x', u'z', u'y', - u'0', u'1', u'2', u'3', u'4', u'5', u'6', u'7', u'8', u'9', u' ', u'\xffff', u'ß', - u'\xffff', u'ü', u'+', u'#', u'ö', u'ä', u',', u'.', u'-', u'\000', u'<'}, + {u'a', u'b', u'c', u'd', u'e', u'f', u'g', u'h', u'i', u'j', + u'k', u'l', u'm', u'n', u'o', u'p', u'q', u'r', u's', u't', + u'u', u'v', u'w', u'x', u'z', u'y', u'0', u'1', u'2', u'3', + u'4', u'5', u'6', u'7', u'8', u'9', u' ', u'\xffff', u'ß', u'\xffff', + u'ü', u'+', u'#', u'ö', u'ä', u',', u'.', u'-', u'\000', u'<'}, "de", 0, 0) @@ -416,10 +421,11 @@ INSTANTIATE_TEST_SUITE_P( ShiftDe, GetKeyValFromKeyCodeTest, testing::ValuesIn(GetKeyValFromKeyCodeTestParameters( - {u'A', u'B', u'C', u'D', u'E', u'F', u'G', u'H', u'I', u'J', u'K', u'L', u'M', - u'N', u'O', u'P', u'Q', u'R', u'S', u'T', u'U', u'V', u'W', u'X', u'Z', u'Y', - u'=', u'!', u'"', u'§', u'$', u'%', u'&', u'/', u'(', u')', u' ', u'°', u'?', - u'\xffff', u'Ü', u'*', u'\'', u'Ö', u'Ä', u';', u':', u'_', u'\000', u'>'}, + {u'A', u'B', u'C', u'D', u'E', u'F', u'G', u'H', u'I', u'J', + u'K', u'L', u'M', u'N', u'O', u'P', u'Q', u'R', u'S', u'T', + u'U', u'V', u'W', u'X', u'Z', u'Y', u'=', u'!', u'"', u'§', + u'$', u'%', u'&', u'/', u'(', u')', u' ', u'°', u'?', u'\xffff', + u'Ü', u'*', u'\'', u'Ö', u'Ä', u';', u':', u'_', u'\000', u'>'}, "de", K_SHIFTFLAG, 0) @@ -429,12 +435,11 @@ INSTANTIATE_TEST_SUITE_P( AltGrDe, GetKeyValFromKeyCodeTest, testing::ValuesIn(GetKeyValFromKeyCodeTestParameters( - {u'æ', u'\xfffe', u'¢', u'ð', u'\xfffe', u'\xfffe', u'\xfffe', u'\xfffe', u'\xfffe', - u'\xffff', u'\xfffe', u'\xfffe', u'µ', u'\xfffe', u'ø', u'þ', u'@', u'¶', - u'\xfffe', u'\xfffe', u'\xfffe', u'\xfffe', u'\xfffe', u'«', u'\xfffe', u'»', u'}', - u'¹', u'²', u'³', u'¼', u'½', u'¬', u'{', u'[', u']', - u'\000', u'\xfffe', u'\\', u'\xffff', u'\xffff', u'~', u'\xfffe', u'\xffff', u'\xffff', - u'·', u'\xfffe', u'\xfffe', u'\000', u'|'}, + {u'æ', u'\xfffe', u'¢', u'ð', u'\xfffe', u'\xfffe', u'\xfffe', u'\xfffe', u'\xfffe', u'\xffff', + u'\xfffe', u'\xfffe', u'µ', u'\xfffe', u'ø', u'þ', u'@', u'¶', u'\xfffe', u'\xfffe', + u'\xfffe', u'\xfffe', u'\xfffe', u'«', u'\xfffe', u'»', u'}', u'¹', u'²', u'³', + u'¼', u'½', u'¬', u'{', u'[', u']', u'\000', u'\xfffe', u'\\', u'\xffff', + u'\xffff', u'~', u'\xfffe', u'\xffff', u'\xffff', u'·', u'\xfffe', u'\xfffe', u'\000', u'|'}, "de", (LCTRLFLAG | RALTFLAG), 0) From c9c45a05baa53d120af4095d227fa74a8c647911 Mon Sep 17 00:00:00 2001 From: Markus Greiner Date: Mon, 11 May 2026 16:15:00 +0200 Subject: [PATCH 17/23] German Unit test now alos successfully finishing --- linux/mcompile/keymap/test/keymap.tests.cpp | 53 ++++++++++----------- 1 file changed, 26 insertions(+), 27 deletions(-) diff --git a/linux/mcompile/keymap/test/keymap.tests.cpp b/linux/mcompile/keymap/test/keymap.tests.cpp index d993f66e239..42a24cb38e5 100644 --- a/linux/mcompile/keymap/test/keymap.tests.cpp +++ b/linux/mcompile/keymap/test/keymap.tests.cpp @@ -61,9 +61,11 @@ class KeyboardTestParameters { std::vector test_data_values = {}; std::string layout; guint shiftstate; - std::vector keycodes = {38, 56, 54, 40, 26, 41, 42, 43, 31, 44, 45, 46, 58, 57, 32, 33, 24, - 27, 39, 28, 30, 55, 25, 53, 29, 52, 19, 10, 11, 12, 13, 14, 15, 16, - 17, 18, 65, 49, 20, 21, 34, 35, 51, 47, 48, 59, 60, 61, 123, 94}; + std::vector keycodes = {38, 56, 54, 40, 26, 41, 42, 43, 31, 44, + 45, 46, 58, 57, 32, 33, 24, 27, 39, 28, + 30, 55, 25, 53, 29, 52, 19, 10, 11, 12, + 13, 14, 15, 16, 17, 18, 65, 49, 20, 21, + 34, 35, 51, 47, 48, 59, 60, 61, 123, 94}; void generate_test_data_values() { EXPECT_EQ(keycodes.size(), expected_keysyms.size()) << "Keycodes and expected keysyms vectors must be of the same size."; @@ -286,12 +288,8 @@ class GetKeyValFromKeyCodeTestDataValues : public TestDataValues { class GetKeyValFromKeyCodeTestParameters { public: - GetKeyValFromKeyCodeTestParameters(std::vector e, std::string l, guint s, int c) + GetKeyValFromKeyCodeTestParameters(std::vector e, std::string l, guint s, int c) : expected_keysyms(e), layout(l), shiftstate(s), caps(c) { - expected_keysyms = e; - layout = l; - shiftstate = s; - caps = c; generate_test_data_values(); } @@ -300,14 +298,16 @@ class GetKeyValFromKeyCodeTestParameters { } protected: - std::vector expected_keysyms; + std::vector expected_keysyms; std::vector test_data_values = {}; std::string layout; guint shiftstate; int caps; - std::vector keycodes = {38, 56, 54, 40, 26, 41, 42, 43, 31, 44, 45, 46, 58, 57, 32, 33, 24, - 27, 39, 28, 30, 55, 25, 53, 29, 52, 19, 10, 11, 12, 13, 14, 15, 16, - 17, 18, 65, 49, 20, 21, 34, 35, 51, 47, 48, 59, 60, 61, 123, 94}; + std::vector keycodes = {38, 56, 54, 40, 26, 41, 42, 43, 31, 44, + 45, 46, 58, 57, 32, 33, 24, 27, 39, 28, + 30, 55, 25, 53, 29, 52, 19, 10, 11, 12, + 13, 14, 15, 16, 17, 18, 65, 49, 20, 21, + 34, 35, 51, 47, 48, 59, 60, 61, 123, 94}; void generate_test_data_values() { EXPECT_EQ(keycodes.size(), expected_keysyms.size()) << "Keycodes and expected keysyms vectors must be of the same size."; @@ -342,9 +342,9 @@ TEST_P(GetKeyValFromKeyCodeTest, kmxGetKeyValFromKeyCode) { GTEST_SKIP() << "Default layout is not " << default_layout << "."; } - KMX_DWORD keyV = + KMX_WCHAR keyV = KMX_get_KeyVal_From_KeyCode(test_keymap, keycode, ShiftState(convert_Shiftstate_to_LinuxShiftstate(shiftstate)), caps); - EXPECT_EQ(keyV, expected_char) << "Failed for keycode: " << keycode; + EXPECT_EQ(keyV, expected_char) << "Failed for keycode: " << keycode << " keyval: " << ((KMX_WCHAR)keyV) << " expected_char:" << ((int)expected_char); } INSTANTIATE_TEST_SUITE_P( @@ -410,7 +410,7 @@ INSTANTIATE_TEST_SUITE_P( {u'a', u'b', u'c', u'd', u'e', u'f', u'g', u'h', u'i', u'j', u'k', u'l', u'm', u'n', u'o', u'p', u'q', u'r', u's', u't', u'u', u'v', u'w', u'x', u'z', u'y', u'0', u'1', u'2', u'3', - u'4', u'5', u'6', u'7', u'8', u'9', u' ', u'\xffff', u'ß', u'\xffff', + u'4', u'5', u'6', u'7', u'8', u'9', u' ', u'﹒', u'ß', u'﹑', u'ü', u'+', u'#', u'ö', u'ä', u',', u'.', u'-', u'\000', u'<'}, "de", 0, @@ -424,7 +424,7 @@ INSTANTIATE_TEST_SUITE_P( {u'A', u'B', u'C', u'D', u'E', u'F', u'G', u'H', u'I', u'J', u'K', u'L', u'M', u'N', u'O', u'P', u'Q', u'R', u'S', u'T', u'U', u'V', u'W', u'X', u'Z', u'Y', u'=', u'!', u'"', u'§', - u'$', u'%', u'&', u'/', u'(', u')', u' ', u'°', u'?', u'\xffff', + u'$', u'%', u'&', u'/', u'(', u')', u' ', u'°', u'?', u'﹐', u'Ü', u'*', u'\'', u'Ö', u'Ä', u';', u':', u'_', u'\000', u'>'}, "de", K_SHIFTFLAG, @@ -435,11 +435,11 @@ INSTANTIATE_TEST_SUITE_P( AltGrDe, GetKeyValFromKeyCodeTest, testing::ValuesIn(GetKeyValFromKeyCodeTestParameters( - {u'æ', u'\xfffe', u'¢', u'ð', u'\xfffe', u'\xfffe', u'\xfffe', u'\xfffe', u'\xfffe', u'\xffff', - u'\xfffe', u'\xfffe', u'µ', u'\xfffe', u'ø', u'þ', u'@', u'¶', u'\xfffe', u'\xfffe', - u'\xfffe', u'\xfffe', u'\xfffe', u'«', u'\xfffe', u'»', u'}', u'¹', u'²', u'³', - u'¼', u'½', u'¬', u'{', u'[', u']', u'\000', u'\xfffe', u'\\', u'\xffff', - u'\xffff', u'~', u'\xfffe', u'\xffff', u'\xffff', u'·', u'\xfffe', u'\xfffe', u'\000', u'|'}, + {u'æ', u'\xad2', u'¢', u'ð', u'€', u'ǰ', u'ο', u'ʱ', u'ࣽ', u'﹠', + u'\x3a2', u'Ƴ', u'µ', u'\xad3', u'ø', u'þ', u'@', u'¶', u'ſ', u'μ', + u'ࣾ', u'૾', u'ſ', u'«', u'ࣻ', u'»', u'}', u'¹', u'²', u'³', + u'¼', u'½', u'¬', u'{', u'[', u']', u'\000', u'′', u'\\', u'﹛', + u'﹗', u'~', u'\xad1', u'﹙', u'﹒', u'·', u'…', u'પ', u'\000', u'|'}, "de", (LCTRLFLAG | RALTFLAG), 0) @@ -449,12 +449,11 @@ INSTANTIATE_TEST_SUITE_P( ShiftAltGrDe, GetKeyValFromKeyCodeTest, testing::ValuesIn(GetKeyValFromKeyCodeTestParameters( - {u'Æ', u'\xfffe', u'©', u'Ð', u'\xfffe', u'ª', u'\xfffe', u'\xfffe', u'\xfffe', - u'\xffff', u'&', u'\xfffe', u'º', u'\xfffe', u'Ø', u'Þ', u'\xfffe', u'®', - u'\xfffe', u'\xfffe', u'\xfffe', u'\xfffe', u'§', u'\xfffe', u'¥', u'\xfffe', u'°', - u'¡', u'\xfffe', u'£', u'¤', u'\xfffe', u'\xfffe', u'\xfffe', u'\xfffe', u'±', - u'\000', u'\xfffe', u'¿', u'\xffff', u'\xffff', u'¯', u'\xffff', u'\xffff', u'\xffff', - u'×', u'÷', u'\xfffe', u'\000', u'\xffff'}, + {u'Æ', u'ૐ', u'©', u'Ð', u'€', u'ª', u'ν', u'ʡ', u'ʹ', u'﹖', + u'&', u'ƣ', u'º', u'\xad1', u'Ø', u'Þ', u'ߙ', u'®', u'ẞ', u'ά', + u'ࣼ', u'૽', u'§', u'‹', u'¥', u'›', u'°', u'¡', u'ૃ', u'£', + u'¤', u'ૄ', u'ૅ', u'\xac6', u'ૉ', u'±', u'\000', u'″', u'¿', u'﹜', + u'﹘', u'¯', u'﹕', u'﹠', u'﹚', u'×', u'÷', u'\xaa9', u'\000', u'﹨'}, "de", (K_SHIFTFLAG | LCTRLFLAG | RALTFLAG), 0) From 0ccc9af45f3839966c60769bc250757edaa56c64 Mon Sep 17 00:00:00 2001 From: Markus Greiner <90342882+Markus-SWAG@users.noreply.github.com> Date: Mon, 11 May 2026 16:55:45 +0200 Subject: [PATCH 18/23] Update linux/mcompile/keymap/test/meson.build Co-authored-by: Eberhard Beilharz --- linux/mcompile/keymap/test/meson.build | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/linux/mcompile/keymap/test/meson.build b/linux/mcompile/keymap/test/meson.build index 9cbdadb999a..12a1b16e792 100644 --- a/linux/mcompile/keymap/test/meson.build +++ b/linux/mcompile/keymap/test/meson.build @@ -2,10 +2,9 @@ gtest = subproject('gtest') gtest_main_dep = gtest.get_variable('gtest_main_dep') -keymaptest = executable('keymaptest', [ - 'keymap.tests.cpp', test_files, - ], - sources: [test_files], +keymaptest = executable('keymaptest', + sources: ['keymap.tests.cpp', test_files], + include_directories: [common_include_dir], include_directories: [common_include_dir], dependencies: [ gtest_main_dep, gtk, xkb, giomm_dep, glibmm_dep ], ) From 8cf0c4149da83e6734184511a481a16a7d52af4e Mon Sep 17 00:00:00 2001 From: Markus Greiner <90342882+Markus-SWAG@users.noreply.github.com> Date: Mon, 11 May 2026 17:20:55 +0200 Subject: [PATCH 19/23] Update linux/mcompile/keymap/mc_kmxfile.cpp Co-authored-by: Eberhard Beilharz --- linux/mcompile/keymap/mc_kmxfile.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/linux/mcompile/keymap/mc_kmxfile.cpp b/linux/mcompile/keymap/mc_kmxfile.cpp index 50ea9c8086a..8f64052d19e 100644 --- a/linux/mcompile/keymap/mc_kmxfile.cpp +++ b/linux/mcompile/keymap/mc_kmxfile.cpp @@ -609,5 +609,6 @@ void KMX_LogError(const wchar_t* fmt, ...) { j++; } while (fmtbuf[j] != *end); putwchar(*nl); + va_end(vars); } From cc9e0beb7b1837fae2a3eb92d6a7adeda4b284ce Mon Sep 17 00:00:00 2001 From: Markus Greiner <90342882+Markus-SWAG@users.noreply.github.com> Date: Mon, 11 May 2026 17:25:26 +0200 Subject: [PATCH 20/23] Update linux/mcompile/keymap/deadkey.h Co-authored-by: Eberhard Beilharz --- linux/mcompile/keymap/deadkey.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/linux/mcompile/keymap/deadkey.h b/linux/mcompile/keymap/deadkey.h index 2ff6a794913..c125b0b3ab9 100644 --- a/linux/mcompile/keymap/deadkey.h +++ b/linux/mcompile/keymap/deadkey.h @@ -10,7 +10,7 @@ #include "mc_import_rules.h" #include -#include +#include "keymap.h" struct KMX_DeadkeyMapping { // I4353 KMX_WCHAR deadkey, dkid; From 7b367e946a10a453f161cf50b4c8bc2a730cad50 Mon Sep 17 00:00:00 2001 From: Markus Greiner <90342882+Markus-SWAG@users.noreply.github.com> Date: Mon, 11 May 2026 17:25:50 +0200 Subject: [PATCH 21/23] Update linux/mcompile/keymap/main.cpp Co-authored-by: Eberhard Beilharz --- linux/mcompile/keymap/main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/linux/mcompile/keymap/main.cpp b/linux/mcompile/keymap/main.cpp index 1b5323d755e..0394acb6808 100644 --- a/linux/mcompile/keymap/main.cpp +++ b/linux/mcompile/keymap/main.cpp @@ -83,7 +83,7 @@ int main(int argc, char* argv[]) { } } - delete kmxfile; + delete[] kmxfile; return 0; } From 28b0c969c17d671378a880b6ad2444c7f9fd421c Mon Sep 17 00:00:00 2001 From: Markus Greiner Date: Mon, 11 May 2026 17:34:28 +0200 Subject: [PATCH 22/23] changes after review --- linux/mcompile/keymap/main.cpp | 4 ++-- linux/mcompile/keymap/mc_kmxfile.cpp | 4 ---- linux/mcompile/keymap/meson.build | 3 --- linux/mcompile/keymap/test/meson.build | 3 +++ 4 files changed, 5 insertions(+), 9 deletions(-) diff --git a/linux/mcompile/keymap/main.cpp b/linux/mcompile/keymap/main.cpp index 0394acb6808..4ca4be8b957 100644 --- a/linux/mcompile/keymap/main.cpp +++ b/linux/mcompile/keymap/main.cpp @@ -71,14 +71,14 @@ int main(int argc, char* argv[]) { if (!KMX_LoadKeyboard(infile, &kmxfile)) { KMX_LogError(L"Failed to load keyboard (%d)\n", errno); - delete kmxfile; + delete[] kmxfile; return 3; } if (KMX_DoConvert(kmxfile, bDeadkeyConversion, argc, (gchar**)argv)) { if(!KMX_SaveKeyboard(kmxfile, outfile)) { KMX_LogError(L"Failed to save keyboard (%d)\n", errno); - delete kmxfile; + delete[] kmxfile; return 3; } } diff --git a/linux/mcompile/keymap/mc_kmxfile.cpp b/linux/mcompile/keymap/mc_kmxfile.cpp index 8f64052d19e..f045246e49e 100644 --- a/linux/mcompile/keymap/mc_kmxfile.cpp +++ b/linux/mcompile/keymap/mc_kmxfile.cpp @@ -580,10 +580,6 @@ FILE* Open_File(const KMX_CHAR* filename, const KMX_CHAR* mode) { return fopen(cpath.c_str(), (const KMX_CHAR*)mode); #else return fopen(filename, mode); - std::string cpath, cmode; - cpath = (const KMX_CHAR*)filename; - cmode = (const KMX_CHAR*)mode; - return fopen(cpath.c_str(), cmode.c_str()); #endif }; diff --git a/linux/mcompile/keymap/meson.build b/linux/mcompile/keymap/meson.build index d49dea4adc7..9c8fd506964 100644 --- a/linux/mcompile/keymap/meson.build +++ b/linux/mcompile/keymap/meson.build @@ -9,9 +9,6 @@ project( gtk = dependency('gtk+-3.0', version: '>= 2.4') xkb = dependency('xkbcommon') -giomm_dep = dependency('giomm-2.4') -glibmm_dep = dependency('glibmm-2.4') - deps = [gtk, xkb] subdir('resources') diff --git a/linux/mcompile/keymap/test/meson.build b/linux/mcompile/keymap/test/meson.build index 12a1b16e792..ac467b957fc 100644 --- a/linux/mcompile/keymap/test/meson.build +++ b/linux/mcompile/keymap/test/meson.build @@ -1,3 +1,6 @@ +giomm_dep = dependency('giomm-2.4') +glibmm_dep = dependency('glibmm-2.4') + gtest = subproject('gtest') gtest_main_dep = gtest.get_variable('gtest_main_dep') From fcea563e03f37e4e3a68bea02bb8254ec4bdb1f9 Mon Sep 17 00:00:00 2001 From: Markus Greiner Date: Wed, 20 May 2026 18:38:51 +0200 Subject: [PATCH 23/23] improving tests, check on deadkey variable --- linux/mcompile/keymap/test/keymap.tests.cpp | 92 +++++++++++++++++---- 1 file changed, 77 insertions(+), 15 deletions(-) diff --git a/linux/mcompile/keymap/test/keymap.tests.cpp b/linux/mcompile/keymap/test/keymap.tests.cpp index 42a24cb38e5..e1d3175b12b 100644 --- a/linux/mcompile/keymap/test/keymap.tests.cpp +++ b/linux/mcompile/keymap/test/keymap.tests.cpp @@ -24,6 +24,7 @@ class TestDataValues { KMX_WCHAR expected_char; std::string layout; guint shiftstate; + KMX_WCHAR expected_deadkey_value; public: TestDataValues(guint k, KMX_WCHAR e, std::string l, guint s) : keycode(k), expected_char(e), layout(l), shiftstate(s) { @@ -44,23 +45,40 @@ class TestDataValues { guint get_shiftstate() { return shiftstate; } + + +}; + + +class KeyboardTestDataValues : public TestDataValues { +public: + KeyboardTestDataValues(guint k, KMX_WCHAR e, std::string l, guint s, KMX_WCHAR d) : TestDataValues(k, e, l, s), expected_deadkey_value(d) { + } + + KMX_WCHAR get_expected_deadkey_value() { + return expected_deadkey_value; + } + +protected: + KMX_WCHAR expected_deadkey_value; }; class KeyboardTestParameters { public: - KeyboardTestParameters(std::vector e, std::string l, guint s) : expected_keysyms(e), layout(l), shiftstate(s) { + KeyboardTestParameters(std::vector e, std::string l, guint s, std::vector d) : expected_keysyms(e), layout(l), shiftstate(s), expected_deadkey_values(d) { generate_test_data_values(); } - std::vector get_test_data() { + std::vector get_test_data() { return test_data_values; } protected: std::vector expected_keysyms; - std::vector test_data_values = {}; + std::vector test_data_values = {}; std::string layout; guint shiftstate; + std::vector expected_deadkey_values = {}; std::vector keycodes = {38, 56, 54, 40, 26, 41, 42, 43, 31, 44, 45, 46, 58, 57, 32, 33, 24, 27, 39, 28, 30, 55, 25, 53, 29, 52, 19, 10, 11, 12, @@ -69,8 +87,9 @@ class KeyboardTestParameters { void generate_test_data_values() { EXPECT_EQ(keycodes.size(), expected_keysyms.size()) << "Keycodes and expected keysyms vectors must be of the same size."; + EXPECT_EQ(keycodes.size(), expected_deadkey_values.size()) << "Keycodes and expected deadkey values vectors must be of the same size."; for (uint k = 0; k < keycodes.size() && k < expected_keysyms.size(); k++) { - test_data_values.emplace_back(TestDataValues(keycodes[k], expected_keysyms[k], layout, shiftstate)); + test_data_values.emplace_back(KeyboardTestDataValues(keycodes[k], expected_keysyms[k], layout, shiftstate, expected_deadkey_values[k])); } } }; @@ -144,19 +163,21 @@ class KeyboardConversionTest : public testing::Test { }; class GetKeyValUnderlyingFromKeyCodeUnderlyingTest : public KeyboardConversionTest, - public testing::WithParamInterface {}; + public testing::WithParamInterface {}; TEST_P(GetKeyValUnderlyingFromKeyCodeUnderlyingTest, KmxGetKeyValUnderlyingFromKeyCodeUnderlying) { guint keycode; KMX_WCHAR expected_char; std::string test_layout; guint shiftstate; - TestDataValues parameter = GetParam(); + KMX_WCHAR expected_deadkey_value; + KeyboardTestDataValues parameter = GetParam(); keycode = parameter.get_keycode(); expected_char = parameter.get_expected_char(); test_layout = parameter.get_layout(); shiftstate = parameter.get_shiftstate(); + expected_deadkey_value = parameter.get_expected_deadkey_value(); std::cout << "Testing keycode: " << keycode << " expecting char: " << expected_char << " with layout: " << test_layout << " and shiftstate: " << shiftstate << std::endl; @@ -164,9 +185,10 @@ TEST_P(GetKeyValUnderlyingFromKeyCodeUnderlyingTest, KmxGetKeyValUnderlyingFromK GTEST_SKIP() << "Default layout is not " << default_layout << "."; } - KMX_WCHAR deadkey; + KMX_WCHAR deadkey = 0; KMX_WCHAR result = KMX_get_KeyValUnderlying_From_KeyCodeUnderlying(test_keymap, keycode, shiftstate, &deadkey); EXPECT_EQ(result, expected_char) << "Failed for keycode: " << keycode; + EXPECT_EQ(deadkey, expected_deadkey_value) << "Failed for keycode: " << keycode; } INSTANTIATE_TEST_SUITE_P( @@ -179,7 +201,12 @@ INSTANTIATE_TEST_SUITE_P( u'4', u'5', u'6', u'7', u'8', u'9', u' ', u'`', u'-', u'=', u'[', u']', u'\\', u';', u'\'', u',', u'.', u'/', u'\000', u'<'}, "us", - 0) + 0, + {0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0}) .get_test_data())); INSTANTIATE_TEST_SUITE_P( @@ -192,7 +219,12 @@ INSTANTIATE_TEST_SUITE_P( u'$', u'%', u'^', u'&', u'*', u'(', u' ', u'~', u'_', u'+', u'{', u'}', u'|', u':', u'"', u'<', u'>', u'?', u'\000', u'>'}, "us", - K_SHIFTFLAG) + K_SHIFTFLAG, + {0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0}) .get_test_data())); INSTANTIATE_TEST_SUITE_P( @@ -205,7 +237,12 @@ INSTANTIATE_TEST_SUITE_P( u'4', u'5', u'6', u'7', u'8', u'9', u'\000', u'`', u'-', u'=', u'[', u']', u'\\', u';', u'\'', u',', u'.', u'/', u'\000', u'|'}, "us", - (LCTRLFLAG | RALTFLAG)) + (LCTRLFLAG | RALTFLAG), + {0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0}) .get_test_data())); INSTANTIATE_TEST_SUITE_P( @@ -218,7 +255,12 @@ INSTANTIATE_TEST_SUITE_P( u'$', u'%', u'^', u'&', u'*', u'(', u'\000', u'~', u'_', u'+', u'{', u'}', u'|', u':', u'"', u'<', u'>', u'?', u'\000', u'¦'}, "us", - (K_SHIFTFLAG | LCTRLFLAG | RALTFLAG)) + (K_SHIFTFLAG | LCTRLFLAG | RALTFLAG), + {0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0}) .get_test_data())); INSTANTIATE_TEST_SUITE_P( @@ -231,7 +273,12 @@ INSTANTIATE_TEST_SUITE_P( u'4', u'5', u'6', u'7', u'8', u'9', u' ', u'\xffff', u'ß', u'\xffff', u'ü', u'+', u'#', u'ö', u'ä', u',', u'.', u'-', u'\000', u'<'}, "de", - 0) + 0, + {0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,u'^',0,u'´', + 0,0,0,0,0,0,0,0,0,0}) .get_test_data())); INSTANTIATE_TEST_SUITE_P( @@ -244,7 +291,12 @@ INSTANTIATE_TEST_SUITE_P( u'$', u'%', u'&', u'/', u'(', u')', u' ', u'°', u'?', u'\xffff', u'Ü', u'*', u'\'', u'Ö', u'Ä', u';', u':', u'_', u'\000', u'>'}, "de", - K_SHIFTFLAG) + K_SHIFTFLAG, + {0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,u'`', + 0,0,0,0,0,0,0,0,0,0}) .get_test_data())); INSTANTIATE_TEST_SUITE_P( @@ -257,7 +309,12 @@ INSTANTIATE_TEST_SUITE_P( u'¼', u'½', u'¬', u'{', u'[', u']', u'\000', u'\xfffe', u'\\', u'\xffff', u'\xffff', u'~', u'\xfffe', u'\xffff', u'\xffff', u'·', u'\xfffe', u'\xfffe', u'\000', u'|'}, "de", - (LCTRLFLAG | RALTFLAG)) + (LCTRLFLAG | RALTFLAG), + {0,0,0,0,0,0,0,0,0,u'\000', + 0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,u'¸', + u'¨',0,0,u'˝',u'^',0,0,0,0,0}) .get_test_data())); INSTANTIATE_TEST_SUITE_P( @@ -270,7 +327,12 @@ INSTANTIATE_TEST_SUITE_P( u'¤', u'\xfffe', u'\xfffe', u'\xfffe', u'\xfffe', u'±', u'\000', u'\xfffe', u'¿', u'\xffff', u'\xffff', u'¯', u'\xffff', u'\xffff', u'\xffff', u'×', u'÷', u'\xfffe', u'\000', u'\xffff'}, "de", - (K_SHIFTFLAG | LCTRLFLAG | RALTFLAG)) + (K_SHIFTFLAG | LCTRLFLAG | RALTFLAG), + {0,0,0,0,0,0,0,0,0,u'˙', + 0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,0, + 0,0,0,0,0,0,0,0,0,u'˛', + u'˚',0,u'˘',u'\000',u'ˇ',0,0,0,0,u'\000'}) .get_test_data())); class GetKeyValFromKeyCodeTestDataValues : public TestDataValues {