mirror of
https://github.com/keymanapp/keyman.git
synced 2026-09-21 07:07:39 +00:00
Merge pull request #10184 from keymanapp/feat/update-windows-engine-tests
feat(windows): update windows engine unit tests to match removal of engine cached context
This commit is contained in:
commit
043090f8a4
5 changed files with 26 additions and 167 deletions
|
|
@ -54,7 +54,7 @@
|
|||
<CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" />
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<LibraryPath>$(ProjectDir)..\..\..\..\core\build\x86\$(Configuration)\src;$(ProjectDir)..\..\..\..\core\build\rust\x86\$(Configuration);$(LibraryPath)</LibraryPath>
|
||||
<LibraryPath>$(ProjectDir)..\..\..\..\core\build\x86\$(Configuration)\src;$(ProjectDir)..\..\..\..\core\build\x86\$(Configuration)\subprojects\icu\source\common;$(ProjectDir)..\..\..\..\core\build\x86\$(Configuration)\subprojects\icu\source\i18n;$(ProjectDir)..\..\..\..\core\build\rust\x86\$(Configuration);$(LibraryPath)</LibraryPath>
|
||||
<IncludePath>$(ProjectDir)..\..\..\..\common\include;$(ProjectDir)..\..\..\..\core\build\x86\$(Configuration)\include;$(ProjectDir)..\..\..\..\core\include;$(IncludePath)</IncludePath>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
|
|
@ -98,7 +98,7 @@
|
|||
</ResourceCompile>
|
||||
<Link>
|
||||
<AdditionalOptions>/verbose:lib /section:.SHARDATA,rws %(AdditionalOptions)</AdditionalOptions>
|
||||
<AdditionalDependencies>keymancore.lib;psapi.lib;rpcrt4.lib;version.lib;setupapi.lib;iphlpapi.lib;imm32.lib;crypt32.lib;wintrust.lib;imagehlp.lib;ws2_32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<AdditionalDependencies>keymancore.lib;libicuuc.a;libicuin.a;psapi.lib;rpcrt4.lib;version.lib;setupapi.lib;iphlpapi.lib;imm32.lib;crypt32.lib;wintrust.lib;imagehlp.lib;ws2_32.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<OutputFile>./Keyman32.dll</OutputFile>
|
||||
<SuppressStartupBanner>true</SuppressStartupBanner>
|
||||
<ModuleDefinitionFile>keyman32.def</ModuleDefinitionFile>
|
||||
|
|
@ -186,6 +186,7 @@
|
|||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="$(KEYMAN_ROOT)\common\windows\cpp\src\xstring.cpp" />
|
||||
<ClCompile Include="appcontext.cpp" />
|
||||
<ClCompile Include="appint\aiTIP.cpp">
|
||||
<AdditionalIncludeDirectories Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
|
|
@ -364,6 +365,7 @@
|
|||
</ResourceCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="appcontext.h" />
|
||||
<ClInclude Include="keymanengine.h" />
|
||||
<ClInclude Include="addins.h" />
|
||||
<ClInclude Include="appint\aiTIP.h" />
|
||||
|
|
@ -397,4 +399,4 @@
|
|||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
||||
</Project>
|
||||
|
|
@ -135,6 +135,9 @@
|
|||
<ClCompile Include="CoreEnvironment.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="appcontext.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="KEYMAN32.DEF">
|
||||
|
|
@ -243,6 +246,9 @@
|
|||
<ClInclude Include="kmprocessactions.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="appcontext.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<CustomBuild Include="keyman-debug-etw.man" />
|
||||
|
|
|
|||
|
|
@ -43,12 +43,10 @@ TEST(AppContext, Get_split_surrogate) {
|
|||
|
||||
// Test Calling BufMax
|
||||
TEST(AppContext, BufMax_LastChar) {
|
||||
WCHAR callbuff[MAXCONTEXT];
|
||||
const uint32_t ExpectedMarker = 0x0002;
|
||||
AppContext testContext;
|
||||
WCHAR testString[] = {0x0042, 0xD800, 0xDC00, UC_SENTINEL, CODE_DEADKEY, ExpectedMarker, 0x0000};
|
||||
WCHAR expectedString[] = {UC_SENTINEL, CODE_DEADKEY, 0x0002, 0x0000};
|
||||
|
||||
testContext.Set(testString);
|
||||
WCHAR *contextBuf = testContext.BufMax(3);
|
||||
EXPECT_STREQ((expectedString), contextBuf);
|
||||
|
|
@ -60,7 +58,6 @@ TEST(AppContext, BufMax_LastChar) {
|
|||
|
||||
// Test AppContext::Delete()
|
||||
TEST(AppContext, AppContext_Delete) {
|
||||
WCHAR callbuff[MAXCONTEXT];
|
||||
const uint32_t ExpectedMarker = 0x0002;
|
||||
AppContext testContext;
|
||||
WCHAR testString[] = {0x0042, 0xD800, 0xDC00, UC_SENTINEL, CODE_DEADKEY, ExpectedMarker, 0x0000};
|
||||
|
|
|
|||
|
|
@ -34,24 +34,24 @@
|
|||
<ImportGroup Label="PropertySheets" />
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<IncludePath>$(ProjectDir)..\..\..\..\..\..\common\include;$(ProjectDir)..\..\..\..\..\..\core\include;$(ProjectDir)..\..\..\..\..\..\core\build\x86\$(Configuration)\include;$(ProjectDir)..\..\..\..\global\inc;$(ProjectDir)..\..;$(IncludePath)</IncludePath>
|
||||
<IncludePath>$(ProjectDir)..\..\..\..\..\..\common\include;$(ProjectDir)..\..\..\..\..\..\core\include;$(ProjectDir)..\..\..\..\..\..\core\build\x86\$(Configuration)\include;$(ProjectDir)..\..\..\..\..\..\core\build\x86\$(Configuration)\subprojects\icu\source\common;$(ProjectDir)..\..\..\..\..\..\core\build\x86\$(Configuration)\subprojects\icu\source\i18n;$(ProjectDir)..\..\..\..\global\inc;$(ProjectDir)..\..;$(IncludePath)</IncludePath>
|
||||
<OutDir>$(ProjectDir)bin\$(Platform)\$(Configuration)\</OutDir>
|
||||
<IntDir>$(ProjectDir)obj\$(Platform)\$(Configuration)\</IntDir>
|
||||
<LibraryPath>$(ProjectDir)..\..\..\..\..\..\core\build\x86\$(Configuration)\src;$(ProjectDir)..\..\..\..\..\..\core\build\rust\x86\$(Configuration);$(ProjectDir)..\..\..\kmtip\bin\Win32\$(Configuration);$(LibraryPath)</LibraryPath>
|
||||
<LibraryPath>$(ProjectDir)..\..\..\..\..\..\core\build\x86\$(Configuration)\src;$(ProjectDir)..\..\..\..\kmtip\bin\Win32\$(Configuration);$(ProjectDir)..\..\..\..\..\..\core\build\x86\$(Configuration)\subprojects\icu\source\common;$(ProjectDir)..\..\..\..\..\..\core\build\x86\$(Configuration)\subprojects\icu\source\i18n;$(LibraryPath)</LibraryPath>
|
||||
<Microsoft-googletest-v140-windesktop-msvcstl-static-rt-static-Disable-gtest_main>true</Microsoft-googletest-v140-windesktop-msvcstl-static-rt-static-Disable-gtest_main>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<IncludePath>$(ProjectDir)..\..\..\..\global\inc;$(ProjectDir)..\..;$(IncludePath)</IncludePath>
|
||||
<IncludePath>$(ProjectDir)..\..\..\..\..\..\common\include;$(ProjectDir)..\..\..\..\..\..\core\include;$(ProjectDir)..\..\..\..\..\..\core\build\x86\$(Configuration)\include;$(ProjectDir)..\..\..\..\core\build\x86\$(Configuration)\subprojects\icu\source\common;$(ProjectDir)..\..\..\..\core\build\x86\$(Configuration)\subprojects\icu\source\i18n;$(ProjectDir)..\..\..\..\global\inc;$(ProjectDir)..\..;$(IncludePath)</IncludePath>
|
||||
<OutDir>$(ProjectDir)bin\$(Platform)\$(Configuration)\</OutDir>
|
||||
<IntDir>$(ProjectDir)obj\$(Platform)\$(Configuration)\</IntDir>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<IncludePath>$(ProjectDir)..\..\..\..\..\..\common\include;$(ProjectDir)..\..\..\..\..\..\core\build\x86\$(Configuration)\include;$(ProjectDir)..\..\..\..\..\..\core\include;$(ProjectDir)..\..\..\..\global\inc;$(ProjectDir)..\..;$(IncludePath)</IncludePath>
|
||||
<IncludePath>$(ProjectDir)..\..\..\..\..\..\common\include;$(ProjectDir)..\..\..\..\..\..\core\build\x64\$(Configuration)\include;$(ProjectDir)..\..\..\..\..\..\core\include;$(ProjectDir)..\..\..\..\..\..\core\build\x64\$(Configuration)\subprojects\icu\source\common;$(ProjectDir)..\..\..\..\..\..\core\build\x64\$(Configuration)\subprojects\icu\source\i18n;$(ProjectDir)..\..\..\..\global\inc;$(ProjectDir)..\..;$(IncludePath)</IncludePath>
|
||||
<OutDir>$(ProjectDir)bin\$(Platform)\$(Configuration)\</OutDir>
|
||||
<IntDir>$(ProjectDir)obj\$(Platform)\$(Configuration)\</IntDir>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<IncludePath>$(ProjectDir)..\..\..\..\global\inc;$(ProjectDir)..\..;$(IncludePath)</IncludePath>
|
||||
<IncludePath>$(ProjectDir)..\..\..\..\..\..\common\include;$(ProjectDir)..\..\..\..\..\..\core\build\x64\$(Configuration)\include;$(ProjectDir)..\..\..\..\..\..\core\include;$(ProjectDir)..\..\..\..\..\..\core\build\x64\$(Configuration)\subprojects\icu\source\common;$(ProjectDir)..\..\..\..\..\..\core\build\x64\$(Configuration)\subprojects\icu\source\i18n;$(ProjectDir)..\..\..\..\global\inc;$(ProjectDir)..\..;$(IncludePath)</IncludePath>
|
||||
<OutDir>$(ProjectDir)bin\$(Platform)\$(Configuration)\</OutDir>
|
||||
<IntDir>$(ProjectDir)obj\$(Platform)\$(Configuration)\</IntDir>
|
||||
</PropertyGroup>
|
||||
|
|
@ -98,7 +98,7 @@
|
|||
<Link>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<AdditionalDependencies>version.lib;psapi.lib;imm32.lib;libkeymancore.a;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
<AdditionalDependencies>version.lib;psapi.lib;imm32.lib;libkeymancore.a;libicuuc.a;libicuin.a;%(AdditionalDependencies)</AdditionalDependencies>
|
||||
</Link>
|
||||
<ProjectReference>
|
||||
<UseLibraryDependencyInputs>false</UseLibraryDependencyInputs>
|
||||
|
|
|
|||
|
|
@ -24,163 +24,17 @@ public:
|
|||
};
|
||||
|
||||
// KM_CORE_IT_CHAR - processUnicodeChar
|
||||
// Now that the AITIP no longer contains a context
|
||||
// this test is just reduced to checking the size of the
|
||||
// action queue
|
||||
TEST_F(KMPROCESSACTIONS, processUnicodeChartest) {
|
||||
|
||||
// just check something has been added to the que
|
||||
WCHAR callbuf[MAXCONTEXT];
|
||||
AITIP testApp;
|
||||
WCHAR *expectedContext = L"A";
|
||||
km_core_action_item itemAddChar = { KM_CORE_IT_CHAR, {0,}, {'A'}};
|
||||
|
||||
processUnicodeChar(&testApp, &itemAddChar);
|
||||
WCHAR *contextBuf = testApp.ContextBufMax(MAXCONTEXT);
|
||||
EXPECT_STREQ(contextBuf, expectedContext);
|
||||
|
||||
km_core_usv testSurrogateChar = Uni_SurrogateToUTF32(0xD801, 0xDC37); //𐐷';
|
||||
km_core_action_item itemAddChar2 = {KM_CORE_IT_CHAR, {0,}, {testSurrogateChar}};
|
||||
WCHAR expectedStringSurrogate[] = {'A', 0xD801, 0xDC37, 0};
|
||||
processUnicodeChar(&testApp, &itemAddChar2);
|
||||
contextBuf = testApp.ContextBufMax(MAXCONTEXT);
|
||||
EXPECT_STREQ(contextBuf, &expectedStringSurrogate[0]);
|
||||
int expectedQueueSize = 3; // 1 + surrogate pair
|
||||
km_core_usv output_string[] = {0x0041, 0x010000, 0};
|
||||
processUnicodeChar(&testApp, &output_string[0]);
|
||||
int queueSize = testApp.GetQueueSize();
|
||||
EXPECT_EQ(queueSize, expectedQueueSize);
|
||||
}
|
||||
|
||||
// KM_CORE_IT_MARKER - processMarker Deadkey
|
||||
TEST_F(KMPROCESSACTIONS, processMarkertest) {
|
||||
|
||||
WCHAR callbuf[MAXCONTEXT];
|
||||
AITIP testApp;
|
||||
WCHAR expectedContext[] = {UC_SENTINEL, CODE_DEADKEY, 2, 0};
|
||||
uint32_t marker = 2;
|
||||
km_core_action_item itemAddMarker = {KM_CORE_IT_MARKER, {0,}, {marker}};
|
||||
|
||||
processMarker(&testApp, &itemAddMarker);
|
||||
WCHAR *contextBuf = testApp.ContextBufMax(MAXCONTEXT);
|
||||
EXPECT_STREQ(contextBuf, expectedContext);
|
||||
}
|
||||
|
||||
// KM_CORE_IT_BACK - processBack
|
||||
// First test processing a backspace for a deadkey
|
||||
TEST_F(KMPROCESSACTIONS, processBackDeadkeytest) {
|
||||
|
||||
WCHAR callbuf[MAXCONTEXT];
|
||||
AITIP testApp;
|
||||
WCHAR expectedContext[] = {'A', 0};
|
||||
km_core_action_item itemAddChar = {KM_CORE_IT_CHAR, {0,}, {'A'}};
|
||||
|
||||
processUnicodeChar(&testApp, &itemAddChar);
|
||||
uint32_t marker = 2;
|
||||
km_core_action_item itemAddMarker = {KM_CORE_IT_MARKER, {0,}, {marker}};
|
||||
processMarker(&testApp, &itemAddMarker);
|
||||
km_core_action_item itemBackSpace = {KM_CORE_IT_BACK};
|
||||
itemBackSpace.backspace.expected_type = KM_CORE_IT_MARKER;
|
||||
itemBackSpace.backspace.expected_value = marker;
|
||||
processBack(&testApp, &itemBackSpace);
|
||||
WCHAR *contextBuf = testApp.ContextBufMax(MAXCONTEXT);
|
||||
EXPECT_STREQ(contextBuf, expectedContext);
|
||||
}
|
||||
|
||||
// KM_CORE_IT_BACK - processBack
|
||||
// Press Backspace for a normal character
|
||||
// Also test for Unknown Character
|
||||
TEST_F(KMPROCESSACTIONS, processBackCharactertest) {
|
||||
|
||||
WCHAR callbuf[MAXCONTEXT];
|
||||
AITIP testApp;
|
||||
WCHAR expectedContext[] = {'A', 0};
|
||||
WCHAR expectedContextFinal[] = {0};
|
||||
km_core_action_item itemAddChar = {KM_CORE_IT_CHAR, {0,}, {'A'}};
|
||||
|
||||
processUnicodeChar(&testApp, &itemAddChar);
|
||||
itemAddChar.character = 'B';
|
||||
processUnicodeChar(&testApp, &itemAddChar);
|
||||
km_core_action_item itemBackSpace = {KM_CORE_IT_BACK};
|
||||
itemBackSpace.backspace.expected_type = KM_CORE_IT_CHAR;
|
||||
itemBackSpace.backspace.expected_value = 'B';
|
||||
// backspace
|
||||
processBack(&testApp, &itemBackSpace);
|
||||
WCHAR *contextBuf = testApp.ContextBufMax(MAXCONTEXT);
|
||||
EXPECT_STREQ(contextBuf, expectedContext);
|
||||
// backspace for unknown it should backspace a character
|
||||
itemBackSpace.type = KM_CORE_BT_UNKNOWN;
|
||||
processBack(&testApp, &itemBackSpace);
|
||||
contextBuf = testApp.ContextBufMax(MAXCONTEXT);
|
||||
EXPECT_STREQ(contextBuf, expectedContextFinal);
|
||||
}
|
||||
|
||||
|
||||
// KM_CORE_IT_BACK - processBack
|
||||
// Press Backspace for a surrogate character.
|
||||
// TODO: This test doesn't test for the PostKey handling
|
||||
// of TSF and two backspaces being sent to the App.
|
||||
TEST_F(KMPROCESSACTIONS, processBackSurrogateTSFtest) {
|
||||
WCHAR callbuf[MAXCONTEXT];
|
||||
AITIP testApp;
|
||||
WCHAR expectedContext[] = { 0 };
|
||||
WCHAR expectedStringSurrogate[] = {0xD801, 0xDC37, 0};
|
||||
|
||||
km_core_usv testSurrogateChar = Uni_SurrogateToUTF32(0xD801, 0xDC37); //𐐷';
|
||||
km_core_action_item itemAddChar = {KM_CORE_IT_CHAR, {0,}, {testSurrogateChar}};
|
||||
processUnicodeChar(&testApp, &itemAddChar);
|
||||
|
||||
km_core_action_item itemBackSpace = {KM_CORE_IT_BACK};
|
||||
itemBackSpace.backspace.expected_type = KM_CORE_IT_CHAR;
|
||||
itemBackSpace.backspace.expected_value = testSurrogateChar;
|
||||
WCHAR *contextBuf = testApp.ContextBufMax(MAXCONTEXT);
|
||||
EXPECT_STREQ(contextBuf, expectedStringSurrogate);
|
||||
// backspace
|
||||
processBack(&testApp, &itemBackSpace);
|
||||
contextBuf = testApp.ContextBufMax(MAXCONTEXT);
|
||||
EXPECT_STREQ(contextBuf, expectedContext);
|
||||
}
|
||||
|
||||
// KM_CORE_IT_BACK - processBack
|
||||
// Press Backspace for a character doesn't match expected character
|
||||
// Note currently we don't check for a character match this should be updated
|
||||
|
||||
TEST_F(KMPROCESSACTIONS, processBackUnexpectedChartest) {
|
||||
|
||||
WCHAR callbuf[MAXCONTEXT];
|
||||
AITIP testApp;
|
||||
WCHAR expectedContext[] = {'A', 0};
|
||||
km_core_action_item itemAddChar = {KM_CORE_IT_CHAR, {0,}, {'A'}};
|
||||
|
||||
processUnicodeChar(&testApp, &itemAddChar);
|
||||
itemAddChar.character = 'C';
|
||||
processUnicodeChar(&testApp, &itemAddChar);
|
||||
km_core_action_item itemBackSpace = {KM_CORE_IT_BACK};
|
||||
itemBackSpace.backspace.expected_type = KM_CORE_IT_CHAR;
|
||||
itemBackSpace.backspace.expected_value = 'B';
|
||||
// backspace
|
||||
processBack(&testApp, &itemBackSpace);
|
||||
WCHAR *contextBuf = testApp.ContextBufMax(MAXCONTEXT);
|
||||
EXPECT_STREQ(contextBuf, expectedContext);
|
||||
}
|
||||
|
||||
// KM_CORE_IT_INVALIDATE_CONTEXT - processInvalidateContext
|
||||
TEST_F(KMPROCESSACTIONS, processInvalidateContextTest) {
|
||||
|
||||
WCHAR callbuf[MAXCONTEXT];
|
||||
AITIP testApp;
|
||||
WCHAR expectedContext[] = {0};
|
||||
km_core_action_item itemAddChar = {KM_CORE_IT_CHAR, {0,}, {'A'}};
|
||||
|
||||
processUnicodeChar(&testApp, &itemAddChar);
|
||||
itemAddChar.character = 'B';
|
||||
processUnicodeChar(&testApp, &itemAddChar);
|
||||
|
||||
// A keyboard a state is need to test processInvalidateContext
|
||||
km_core_option_item test_env_opts[] = {{u"hello", u"world", KM_CORE_OPT_KEYBOARD}, KM_CORE_OPTIONS_END};
|
||||
km_core_keyboard *testKB = nullptr;
|
||||
km_core_state *testState = nullptr;
|
||||
km_core_path_name dummyPath = L"dummyActions.mock";
|
||||
EXPECT_EQ(km_core_keyboard_load(dummyPath, &testKB), KM_CORE_STATUS_OK);
|
||||
EXPECT_EQ(km_core_state_create(testKB, test_env_opts, &testState), KM_CORE_STATUS_OK);
|
||||
|
||||
processInvalidateContext(&testApp,testState);
|
||||
WCHAR *contextBuf = testApp.ContextBufMax(MAXCONTEXT);
|
||||
EXPECT_STREQ(contextBuf, expectedContext);
|
||||
|
||||
// dispose keyboard
|
||||
km_core_state_dispose(testState);
|
||||
km_core_keyboard_dispose(testKB);
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue