This commit is contained in:
mrdoggy
2016-01-05 22:04:13 +03:00
12 changed files with 132 additions and 24 deletions

View File

@@ -7,9 +7,9 @@
//
#import <XCTest/XCTest.h>
#import <KeePassKit/KeePassKit.h>
#import "MPDocument.h"
#import "KeePassKit/KeePassKit.h"
@interface MPDatabaseLoading : XCTestCase

View File

@@ -8,8 +8,7 @@
#import <Cocoa/Cocoa.h>
#import <XCTest/XCTest.h>
#import "KeePassKit/KeePassKit.h"
#import <KeePassKit/KeePassKit.h>
@interface MPDatabaseSearch : XCTestCase

View File

@@ -9,6 +9,7 @@
#import <Cocoa/Cocoa.h>
#import <Carbon/Carbon.h>
#import <XCTest/XCTest.h>
#import <KeePassKit/KeePassKit.h>
#import "MPAutotypeCommand.h"
#import "MPAutotypeContext.h"
@@ -17,7 +18,6 @@
#import "MPKeyMapper.h"
#import "KeePassKit/KeePassKit.h"
@interface MPTestAutotype : XCTestCase
@property (strong) KPKEntry *entry;

View File

@@ -0,0 +1,70 @@
//
// MPTestAutotypeDelay.m
// MacPass
//
// Created by Michael Starke on 28/12/15.
// Copyright © 2015 HicknHack Software GmbH. All rights reserved.
//
#import <XCTest/XCTest.h>
#import <KeePassKit/KeePassKit.h>
#import "MPAutotypeContext.h"
#import "MPAutotypeDelay.h"
@interface MPTestAutotypeDelay : XCTestCase
@property (strong) KPKEntry *entry;
@end
@implementation MPTestAutotypeDelay
- (void)setUp {
[super setUp];
self.entry = [[KPKEntry alloc] init];
self.entry.title = @"Title";
self.entry.url = @"www.myurl.com";
self.entry.username = @"Username";
self.entry.password = @"Password";
}
- (void)tearDown {
[super tearDown];
}
- (void)testValidDelayCommands {
/* Command 1 */
MPAutotypeContext *context = [[MPAutotypeContext alloc] initWithEntry:self.entry andSequence:@"{DELAY 200}"];
NSArray *commands = [MPAutotypeCommand commandsForContext:context];
XCTAssertTrue(commands.count == 1);
/* {DELAY 200} */
XCTAssertTrue([commands.firstObject isKindOfClass:[MPAutotypeDelay class]], @"Command is Delay command");
MPAutotypeDelay *delay = commands.firstObject;
XCTAssertEqual(delay.delay, 200, @"Delay is 200 ms");
}
- (void)testDelayExecution {
MPAutotypeDelay *delay = [[MPAutotypeDelay alloc] initWithDelay:200];
XCTestExpectation *expectation = [self expectationWithDescription:delay.description];
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
[delay execute];
[expectation fulfill];
});
[self waitForExpectationsWithTimeout:(delay.delay/1000.0) handler:^(NSError *error) {
if (error != nil) {
NSLog(@"Error: %@", error.localizedDescription);
}
}];
}
- (void)testDelayLimit {
XCTFail(@"Missing Test");
}
- (void)testMalformedDelay {
XCTFail(@"Missing Test");
}
@end

View File

@@ -7,9 +7,10 @@
//
#import <XCTest/XCTest.h>
#import <KeePassKit/KeePassKit.h>
#import "MPDocument.h"
#import "KeePassKit/KeePassKit.h"
@interface MPTestDocument : XCTestCase
@end