load persisted options and enable unit test

This commit is contained in:
sgschantz 2023-12-18 15:50:39 +07:00
parent a84e5202d9
commit ccee68cf13
3 changed files with 7 additions and 18 deletions

View file

@ -47,9 +47,6 @@
ReferencedContainer = "container:KeymanEngine4Mac.xcodeproj">
</BuildableReference>
<SkippedTests>
<Test
Identifier = "KMEngineTests/testArmenianMnemonic_triggerPersistOptions_ReturnsOptions">
</Test>
<Test
Identifier = "KMEngineTests/testCheckPlatform_Browsers_ReturnsNo">
</Test>

View file

@ -191,28 +191,18 @@ const int CORE_ENVIRONMENT_ARRAY_LENGTH = 6;
}
-(NSDictionary*)convertOptionsArray:(km_core_option_item*)options {
NSDictionary* optionsDictionary = nil;
unichar const * optionsKey = options->key;
unichar const * optionsValue = options->value;
if ((optionsKey != nil) && (optionsValue != nil)) {
optionsDictionary = [[NSDictionary alloc] init];
NSString *key = [self.coreHelper createNSStringFromUnicharString:optionsKey];
NSString *value = [self.coreHelper createNSStringFromUnicharString:optionsValue];
[optionsDictionary insertValue:value inPropertyWithKey:key];
}
/*
NSMutableDictionary* optionsDictionary = nil;
if (options) {
optionsDictionary = [[NSDictionary alloc] init];
optionsDictionary = [[NSMutableDictionary alloc] init];
for (; options->key != 0; ++options) {
unichar const * optionsKey = options->key;
unichar const * valueKey = options->value;
NSString *key = [self.coreHelper createNSStringFromUnicharString:optionsKey];
NSString *value = [self.coreHelper createNSStringFromUnicharString:valueKey];
[optionsDictionary insertValue:value inPropertyWithKey:key];
[optionsDictionary setObject:value forKey:key];
}
}
*/
return optionsDictionary;
}

View file

@ -542,13 +542,15 @@ NSString * names[nCombinations];
XCTAssert(!output.emitKeystroke, @"expected to emit nothing");
}
// TODO: enable after resolving issue getting options from Keyman Core
- (void)testArmenianMnemonic_triggerPersistOptions_ReturnsOptions {
KMXFile *kmxFile = [KeymanEngineTestsStaticHelperMethods getKmxFileForArmenianMnemonicTests];
KMEngine *engine = [[KMEngine alloc] initWithKMX:kmxFile context:@"√" verboseLogging:YES];
NSEvent *event = [NSEvent keyEventWithType:NSEventTypeKeyDown location:NSMakePoint(0, 0) modifierFlags:0 timestamp:0 windowNumber:0 context:nil characters:@"w" charactersIgnoringModifiers:@"w" isARepeat:NO keyCode:kVK_ANSI_W];
CoreKeyOutput *output = [engine processEvent:event];
XCTAssert(!output.hasCodePointsToDelete, @"expected to delete nothing");
NSString *key = @"option_ligature_ew";
NSDictionary *options = output.optionsToPersist;
NSString *value = options[key];
XCTAssertEqualObjects(value, @"1", @"expected 'option_ligature_ew' with value of '1'");
}
- (void)testCoreProcessEvent_backspaceElNuerEmptyContext_PassesThrough {