Added test for case senstivie custom attribute lookup

This commit is contained in:
michael starke
2014-12-08 22:15:45 +01:00
parent e16cda11eb
commit 195f533940

View File

@@ -18,6 +18,9 @@
#import "MPKeyMapper.h"
#import "KPKEntry.h"
#import "KPKAttribute.h"
#import "KPKAutotype.h"
#import "KPKWindowAssociation.h"
@interface KPKTestAutotype : XCTestCase
@@ -44,6 +47,42 @@
XCTAssertTrue([@"{}{}{}{}{}{ }ThisIsValid{}{STOP}" validateCommmand]);
}
- (void)testCaseInsenstivieKeyPress {
KPKEntry *entry = [[KPKEntry alloc] init];
entry.title = @"Title";
entry.url = @"www.myurl.com";
entry.username = @"Username";
entry.password = @"Password";
/* Command 1 */
MPAutotypeContext *context = [[MPAutotypeContext alloc] initWithEntry:entry andSequence:@"{TAB}{ENTER}~{tAb}{ShIfT}"];
NSArray *commands = [MPAutotypeCommand commandsForContext:context];
XCTAssert(nil);
}
- (void)testCaseSensitiveCustomAttributeLookup {
KPKEntry *entry = [[KPKEntry alloc] init];
entry.title = @"Title";
entry.url = @"www.myurl.com";
entry.username = @"Username";
entry.password = @"Password";
KPKAttribute *lowerCaseAttribute = [[KPKAttribute alloc] initWithKey:@"custom" value:@"value"];
KPKAttribute *upperCaseAttribute = [[KPKAttribute alloc] initWithKey:@"CUSTOM" value:@"VALUE"];
KPKAttribute *mixedCaseAttribute = [[KPKAttribute alloc] initWithKey:@"CuStOm" value:@"VaLuE"];
[entry addCustomAttribute:lowerCaseAttribute];
[entry addCustomAttribute:upperCaseAttribute];
[entry addCustomAttribute:mixedCaseAttribute];
entry.autotype.defaultKeystrokeSequence = [[NSString alloc] initWithFormat:@"{USERNAME}{s:%@}{S:%@}{s:%@}", lowerCaseAttribute.key, mixedCaseAttribute.key, upperCaseAttribute.key];
MPAutotypeContext *context = [[MPAutotypeContext alloc] initWithDefaultSequenceForEntry:entry];
NSString *result = [[NSString alloc] initWithFormat:@"%@%@%@%@", entry.username, lowerCaseAttribute.value, mixedCaseAttribute.value, upperCaseAttribute.value];
XCTAssertTrue([[context evaluatedCommand] isEqualToString:result]);
}
- (void)testCommandCreation {
KPKEntry *entry = [[KPKEntry alloc] init];
entry.title = @"Title";