mirror of
https://github.com/MacPass/MacPass.git
synced 2025-12-14 17:32:17 +00:00
used specialized asserts in test cases
This commit is contained in:
@@ -161,7 +161,7 @@
|
|||||||
MPAutotypeContext *context = [[MPAutotypeContext alloc] initWithEntry:self.entry andSequence:@"{USERNAME}{TAB}{PASSWORD}{ENTER}"];
|
MPAutotypeContext *context = [[MPAutotypeContext alloc] initWithEntry:self.entry andSequence:@"{USERNAME}{TAB}{PASSWORD}{ENTER}"];
|
||||||
NSArray *commands = [MPAutotypeCommand commandsForContext:context];
|
NSArray *commands = [MPAutotypeCommand commandsForContext:context];
|
||||||
|
|
||||||
XCTAssertTrue(commands.count == 4);
|
XCTAssertEqual(commands.count, 4);
|
||||||
XCTAssertTrue([commands[0] isKindOfClass:[MPAutotypePaste class]]);
|
XCTAssertTrue([commands[0] isKindOfClass:[MPAutotypePaste class]]);
|
||||||
XCTAssertTrue([commands[1] isKindOfClass:[MPAutotypeKeyPress class]]);
|
XCTAssertTrue([commands[1] isKindOfClass:[MPAutotypeKeyPress class]]);
|
||||||
XCTAssertTrue([commands[2] isKindOfClass:[MPAutotypePaste class]]);
|
XCTAssertTrue([commands[2] isKindOfClass:[MPAutotypePaste class]]);
|
||||||
@@ -169,7 +169,7 @@
|
|||||||
|
|
||||||
/* {USERNAME} */
|
/* {USERNAME} */
|
||||||
MPAutotypePaste *paste = commands[0];
|
MPAutotypePaste *paste = commands[0];
|
||||||
XCTAssertTrue([paste.pasteData isEqualToString:self.entry.username]);
|
XCTAssertEqualObjects(paste.pasteData, self.entry.username);
|
||||||
|
|
||||||
/* {TAB} */
|
/* {TAB} */
|
||||||
MPAutotypeKeyPress *keyPress = commands[1];
|
MPAutotypeKeyPress *keyPress = commands[1];
|
||||||
@@ -178,7 +178,7 @@
|
|||||||
|
|
||||||
/* {PASSWORD} */
|
/* {PASSWORD} */
|
||||||
paste = commands[2];
|
paste = commands[2];
|
||||||
XCTAssertTrue([self.entry.password isEqualToString:paste.pasteData]);
|
XCTAssertEqualObjects(self.entry.password, paste.pasteData);
|
||||||
|
|
||||||
/* {ENTER} */
|
/* {ENTER} */
|
||||||
keyPress = commands[3];
|
keyPress = commands[3];
|
||||||
@@ -187,7 +187,7 @@
|
|||||||
/* Command 2 */
|
/* Command 2 */
|
||||||
context = [[MPAutotypeContext alloc] initWithEntry:self.entry andSequence:@"^T{USERNAME}%+^{TAB}Whoo{PASSWORD}{ENTER}"];
|
context = [[MPAutotypeContext alloc] initWithEntry:self.entry andSequence:@"^T{USERNAME}%+^{TAB}Whoo{PASSWORD}{ENTER}"];
|
||||||
commands = [MPAutotypeCommand commandsForContext:context];
|
commands = [MPAutotypeCommand commandsForContext:context];
|
||||||
XCTAssertTrue(commands.count == 5);
|
XCTAssertEqual(commands.count, 5);
|
||||||
XCTAssertTrue([commands[0] isKindOfClass:[MPAutotypeKeyPress class]]);
|
XCTAssertTrue([commands[0] isKindOfClass:[MPAutotypeKeyPress class]]);
|
||||||
XCTAssertTrue([commands[1] isKindOfClass:[MPAutotypePaste class]]);
|
XCTAssertTrue([commands[1] isKindOfClass:[MPAutotypePaste class]]);
|
||||||
XCTAssertTrue([commands[2] isKindOfClass:[MPAutotypeKeyPress class]]);
|
XCTAssertTrue([commands[2] isKindOfClass:[MPAutotypeKeyPress class]]);
|
||||||
@@ -208,7 +208,7 @@
|
|||||||
|
|
||||||
/* {USERNAME} */
|
/* {USERNAME} */
|
||||||
paste = commands[1];
|
paste = commands[1];
|
||||||
XCTAssertTrue([paste.pasteData isEqualToString:self.entry.username]);
|
XCTAssertEqualObjects(paste.pasteData, self.entry.username);
|
||||||
|
|
||||||
/* %+^{TAB} */
|
/* %+^{TAB} */
|
||||||
keyPress = commands[2];
|
keyPress = commands[2];
|
||||||
@@ -223,7 +223,7 @@
|
|||||||
/* Whoo{PASSWORD} */
|
/* Whoo{PASSWORD} */
|
||||||
paste = commands[3];
|
paste = commands[3];
|
||||||
NSString *pasteString = [[NSString alloc] initWithFormat:@"%@%@", @"Whoo", self.entry.password];
|
NSString *pasteString = [[NSString alloc] initWithFormat:@"%@%@", @"Whoo", self.entry.password];
|
||||||
XCTAssertTrue([pasteString isEqualToString:paste.pasteData]);
|
XCTAssertEqualObjects(pasteString, paste.pasteData);
|
||||||
|
|
||||||
/* {ENTER} */
|
/* {ENTER} */
|
||||||
keyPress = commands[4];
|
keyPress = commands[4];
|
||||||
@@ -234,20 +234,19 @@
|
|||||||
/* Command 3 */
|
/* Command 3 */
|
||||||
context = [[MPAutotypeContext alloc] initWithEntry:self.entry andSequence:@"^T"];
|
context = [[MPAutotypeContext alloc] initWithEntry:self.entry andSequence:@"^T"];
|
||||||
commands = [MPAutotypeCommand commandsForContext:context];
|
commands = [MPAutotypeCommand commandsForContext:context];
|
||||||
XCTAssertTrue(commands.count == 1);
|
XCTAssertEqual(commands.count, 1);
|
||||||
XCTAssertTrue([commands[0] isKindOfClass:[MPAutotypeKeyPress class]]);
|
XCTAssertTrue([commands.firstObject isKindOfClass:[MPAutotypeKeyPress class]]);
|
||||||
|
|
||||||
/*^T*/
|
/*^T*/
|
||||||
keyPress = commands[0];
|
keyPress = commands.firstObject;
|
||||||
XCTAssertEqualObjects(@"t", [MPKeyMapper stringForModifiedKey:keyPress.key]);
|
XCTAssertEqualObjects(@"t", [MPKeyMapper stringForModifiedKey:keyPress.key]);
|
||||||
/* TODO - Respect user settings? */
|
|
||||||
if(useCommandInsteadOfControl) {
|
if(useCommandInsteadOfControl) {
|
||||||
XCTAssertEqual(keyPress.key.modifier, kCGEventFlagMaskCommand);
|
XCTAssertEqual(keyPress.key.modifier, kCGEventFlagMaskCommand);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
XCTAssertEqual(keyPress.key.modifier, kCGEventFlagMaskControl);
|
XCTAssertEqual(keyPress.key.modifier, kCGEventFlagMaskControl);
|
||||||
}
|
}
|
||||||
/*XCTAssertEqual(keyPress.modifierMask, kCGEventFlagMaskControl);*/
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -36,7 +36,7 @@
|
|||||||
MPAutotypeContext *context = [[MPAutotypeContext alloc] initWithEntry:self.entry andSequence:@"{DELAY 200}"];
|
MPAutotypeContext *context = [[MPAutotypeContext alloc] initWithEntry:self.entry andSequence:@"{DELAY 200}"];
|
||||||
NSArray *commands = [MPAutotypeCommand commandsForContext:context];
|
NSArray *commands = [MPAutotypeCommand commandsForContext:context];
|
||||||
|
|
||||||
XCTAssertTrue(commands.count == 1);
|
XCTAssertEqual(commands.count, 1);
|
||||||
/* {DELAY 200} */
|
/* {DELAY 200} */
|
||||||
XCTAssertTrue([commands.firstObject isKindOfClass:[MPAutotypeDelay class]], @"Command is Delay command");
|
XCTAssertTrue([commands.firstObject isKindOfClass:[MPAutotypeDelay class]], @"Command is Delay command");
|
||||||
MPAutotypeDelay *delay = commands.firstObject;
|
MPAutotypeDelay *delay = commands.firstObject;
|
||||||
|
|||||||
@@ -24,8 +24,6 @@
|
|||||||
We could set certain keyboard layouts to run this test invariantly
|
We could set certain keyboard layouts to run this test invariantly
|
||||||
The simpler aproach is to go full circle to check if the desired character is the actual character we get
|
The simpler aproach is to go full circle to check if the desired character is the actual character we get
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* Ì - has no key for US and DVORAK layout */
|
|
||||||
NSString *test = @"aB(]©®@fl~±»";
|
NSString *test = @"aB(]©®@fl~±»";
|
||||||
|
|
||||||
[test enumerateSubstringsInRange:NSMakeRange(0, test.length) options:NSStringEnumerationByComposedCharacterSequences usingBlock:^(NSString * _Nullable substring, NSRange substringRange, NSRange enclosingRange, BOOL * _Nonnull stop) {
|
[test enumerateSubstringsInRange:NSMakeRange(0, test.length) options:NSStringEnumerationByComposedCharacterSequences usingBlock:^(NSString * _Nullable substring, NSRange substringRange, NSRange enclosingRange, BOOL * _Nonnull stop) {
|
||||||
|
|||||||
Reference in New Issue
Block a user