From 4dce9ac5d46293835aa373716e903635b1d7ad03 Mon Sep 17 00:00:00 2001 From: michael starke Date: Mon, 18 Sep 2017 11:19:11 +0200 Subject: [PATCH] used specialized asserts in test cases --- MacPassTests/MPTestAutotype.m | 21 ++++++++++----------- MacPassTests/MPTestAutotypeDelay.m | 2 +- MacPassTests/MPTestKeyMapper.m | 2 -- 3 files changed, 11 insertions(+), 14 deletions(-) diff --git a/MacPassTests/MPTestAutotype.m b/MacPassTests/MPTestAutotype.m index 94a8afbe..c6a8e793 100644 --- a/MacPassTests/MPTestAutotype.m +++ b/MacPassTests/MPTestAutotype.m @@ -161,7 +161,7 @@ MPAutotypeContext *context = [[MPAutotypeContext alloc] initWithEntry:self.entry andSequence:@"{USERNAME}{TAB}{PASSWORD}{ENTER}"]; NSArray *commands = [MPAutotypeCommand commandsForContext:context]; - XCTAssertTrue(commands.count == 4); + XCTAssertEqual(commands.count, 4); XCTAssertTrue([commands[0] isKindOfClass:[MPAutotypePaste class]]); XCTAssertTrue([commands[1] isKindOfClass:[MPAutotypeKeyPress class]]); XCTAssertTrue([commands[2] isKindOfClass:[MPAutotypePaste class]]); @@ -169,7 +169,7 @@ /* {USERNAME} */ MPAutotypePaste *paste = commands[0]; - XCTAssertTrue([paste.pasteData isEqualToString:self.entry.username]); + XCTAssertEqualObjects(paste.pasteData, self.entry.username); /* {TAB} */ MPAutotypeKeyPress *keyPress = commands[1]; @@ -178,7 +178,7 @@ /* {PASSWORD} */ paste = commands[2]; - XCTAssertTrue([self.entry.password isEqualToString:paste.pasteData]); + XCTAssertEqualObjects(self.entry.password, paste.pasteData); /* {ENTER} */ keyPress = commands[3]; @@ -187,7 +187,7 @@ /* Command 2 */ context = [[MPAutotypeContext alloc] initWithEntry:self.entry andSequence:@"^T{USERNAME}%+^{TAB}Whoo{PASSWORD}{ENTER}"]; commands = [MPAutotypeCommand commandsForContext:context]; - XCTAssertTrue(commands.count == 5); + XCTAssertEqual(commands.count, 5); XCTAssertTrue([commands[0] isKindOfClass:[MPAutotypeKeyPress class]]); XCTAssertTrue([commands[1] isKindOfClass:[MPAutotypePaste class]]); XCTAssertTrue([commands[2] isKindOfClass:[MPAutotypeKeyPress class]]); @@ -208,7 +208,7 @@ /* {USERNAME} */ paste = commands[1]; - XCTAssertTrue([paste.pasteData isEqualToString:self.entry.username]); + XCTAssertEqualObjects(paste.pasteData, self.entry.username); /* %+^{TAB} */ keyPress = commands[2]; @@ -223,7 +223,7 @@ /* Whoo{PASSWORD} */ paste = commands[3]; NSString *pasteString = [[NSString alloc] initWithFormat:@"%@%@", @"Whoo", self.entry.password]; - XCTAssertTrue([pasteString isEqualToString:paste.pasteData]); + XCTAssertEqualObjects(pasteString, paste.pasteData); /* {ENTER} */ keyPress = commands[4]; @@ -234,20 +234,19 @@ /* Command 3 */ context = [[MPAutotypeContext alloc] initWithEntry:self.entry andSequence:@"^T"]; commands = [MPAutotypeCommand commandsForContext:context]; - XCTAssertTrue(commands.count == 1); - XCTAssertTrue([commands[0] isKindOfClass:[MPAutotypeKeyPress class]]); + XCTAssertEqual(commands.count, 1); + XCTAssertTrue([commands.firstObject isKindOfClass:[MPAutotypeKeyPress class]]); /*^T*/ - keyPress = commands[0]; + keyPress = commands.firstObject; XCTAssertEqualObjects(@"t", [MPKeyMapper stringForModifiedKey:keyPress.key]); - /* TODO - Respect user settings? */ + if(useCommandInsteadOfControl) { XCTAssertEqual(keyPress.key.modifier, kCGEventFlagMaskCommand); } else { XCTAssertEqual(keyPress.key.modifier, kCGEventFlagMaskControl); } - /*XCTAssertEqual(keyPress.modifierMask, kCGEventFlagMaskControl);*/ } diff --git a/MacPassTests/MPTestAutotypeDelay.m b/MacPassTests/MPTestAutotypeDelay.m index c02c077f..e2238fd8 100644 --- a/MacPassTests/MPTestAutotypeDelay.m +++ b/MacPassTests/MPTestAutotypeDelay.m @@ -36,7 +36,7 @@ MPAutotypeContext *context = [[MPAutotypeContext alloc] initWithEntry:self.entry andSequence:@"{DELAY 200}"]; NSArray *commands = [MPAutotypeCommand commandsForContext:context]; - XCTAssertTrue(commands.count == 1); + XCTAssertEqual(commands.count, 1); /* {DELAY 200} */ XCTAssertTrue([commands.firstObject isKindOfClass:[MPAutotypeDelay class]], @"Command is Delay command"); MPAutotypeDelay *delay = commands.firstObject; diff --git a/MacPassTests/MPTestKeyMapper.m b/MacPassTests/MPTestKeyMapper.m index 573ff53c..349cbff2 100644 --- a/MacPassTests/MPTestKeyMapper.m +++ b/MacPassTests/MPTestKeyMapper.m @@ -24,8 +24,6 @@ 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 */ - - /* Ì - has no key for US and DVORAK layout */ NSString *test = @"aB(]©®@fl~±»"; [test enumerateSubstringsInRange:NSMakeRange(0, test.length) options:NSStringEnumerationByComposedCharacterSequences usingBlock:^(NSString * _Nullable substring, NSRange substringRange, NSRange enclosingRange, BOOL * _Nonnull stop) {