-
-
Notifications
You must be signed in to change notification settings - Fork 142
test(linux): Add unit tests for mcompile #15892
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Markus-SWAG
wants to merge
24
commits into
master
Choose a base branch
from
feat/linux/mnemonic-keyboard-support-unit-tests
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 4 commits
Commits
Show all changes
24 commits
Select commit
Hold shift + click to select a range
99baacb
adding unit tests for Linux mcompile
Markus-SWAG 77acb6f
adding dependency to libglibmm-2.4-dev
Markus-SWAG c040314
adding dependency to libglibmm-2.4-dev typo
Markus-SWAG 0ed8eb1
Prevent running unit tests on Wayland
Markus-SWAG f309d90
incorporating review results for adding unit tests
Markus-SWAG 8bd47e4
parametrized unit tests for mcompile
Markus-SWAG d5accca
Update linux/mcompile/keymap/deadkey.h
Markus-SWAG 6e38fc0
renamed files according test standards
Markus-SWAG c05bba9
Merge remote-tracking branch 'refs/remotes/origin/feat/linux/mnemonic…
Markus-SWAG bb87e1d
substituting SIL International by SIL Global in all file headers
Markus-SWAG 0646808
erasing year from the file headers
Markus-SWAG e3dd7f1
added delete kmxfile as before
Markus-SWAG 8ba6a13
added 1 more file header
Markus-SWAG 9cf4e78
fixing typo
Markus-SWAG 471c6c4
adding test suite for KMX_get_KeyVal_From_KeyCode
Markus-SWAG 61f1a2b
incorporating review results
Markus-SWAG 8803089
reformatting test parameters
Markus-SWAG c9c45a0
German Unit test now alos successfully finishing
Markus-SWAG 0ccc9af
Update linux/mcompile/keymap/test/meson.build
Markus-SWAG 8cf0c41
Update linux/mcompile/keymap/mc_kmxfile.cpp
Markus-SWAG cc9e0be
Update linux/mcompile/keymap/deadkey.h
Markus-SWAG 7b367e9
Update linux/mcompile/keymap/main.cpp
Markus-SWAG 28b0c96
changes after review
Markus-SWAG fcea563
improving tests, check on deadkey variable
Markus-SWAG File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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; | ||
|
ermshiperete marked this conversation as resolved.
Outdated
|
||
|
|
||
| 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 | ||
|
ermshiperete marked this conversation as resolved.
Outdated
|
||
| if(!KMX_SaveKeyboard(kmxfile, outfile)) { | ||
| KMX_LogError(L"Failed to save keyboard (%d)\n", errno); | ||
| return 3; | ||
| } | ||
| } | ||
|
|
||
| delete kmxfile; | ||
| return 0; | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| /*.zip | ||
| /*.tgz | ||
| /packagecache | ||
| /googletest-* |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.