Added KeePassKit dependency to MacPassTest

This commit is contained in:
michael starke
2016-01-05 10:42:20 +01:00
parent 06d24f4870
commit a51ddbbe1b
9 changed files with 60 additions and 25 deletions

View File

@@ -108,6 +108,7 @@
4C4B7EEE17A467E1000234C7 /* MPGroupInspectorViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 4C4B7EEC17A467E1000234C7 /* MPGroupInspectorViewController.m */; };
4C4B7EF317A467FC000234C7 /* MPEntryInspectorViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 4C4B7EF117A467FC000234C7 /* MPEntryInspectorViewController.m */; };
4C4B7EF817A4B335000234C7 /* MPUniqueCharactersFormatter.m in Sources */ = {isa = PBXBuildFile; fileRef = 4C4B7EF717A4B335000234C7 /* MPUniqueCharactersFormatter.m */; };
4C4DC0A61C3AD17500DE9DCF /* KeePassKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 4C7B63791C0CB55600D7038C /* KeePassKit.framework */; };
4C4F72D118DF704400E8D378 /* DDHotKeyTextField.m in Sources */ = {isa = PBXBuildFile; fileRef = 4C4F72CF18DF704400E8D378 /* DDHotKeyTextField.m */; };
4C4FCE15177CFE6B00BBF7AE /* MPCustomFieldTableCellView.m in Sources */ = {isa = PBXBuildFile; fileRef = 4C4FCE14177CFE6B00BBF7AE /* MPCustomFieldTableCellView.m */; };
4C52A88E1788628B00868229 /* 06_BlockDeviceTemplate.pdf in Resources */ = {isa = PBXBuildFile; fileRef = 4C52A88B1788628B00868229 /* 06_BlockDeviceTemplate.pdf */; };
@@ -721,6 +722,7 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
4C4DC0A61C3AD17500DE9DCF /* KeePassKit.framework in Frameworks */,
4C473A8718AFD85B0073FD2E /* XCTest.framework in Frameworks */,
4C45FB1D178E09ED0010007D /* Cocoa.framework in Frameworks */,
);
@@ -2010,6 +2012,7 @@
FRAMEWORK_SEARCH_PATHS = (
"$(inherited)",
"$(DEVELOPER_FRAMEWORKS_DIR)",
"$(PROJECT_DIR)/Carthage/Build/Mac",
);
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = "MacPassTests/MacPassTests-Prefix.pch";
@@ -2034,6 +2037,7 @@
FRAMEWORK_SEARCH_PATHS = (
"$(inherited)",
"$(DEVELOPER_FRAMEWORKS_DIR)",
"$(PROJECT_DIR)/Carthage/Build/Mac",
);
GCC_PRECOMPILE_PREFIX_HEADER = YES;
GCC_PREFIX_HEADER = "MacPassTests/MacPassTests-Prefix.pch";

View File

@@ -9,6 +9,8 @@
#import "MPAutotypeCommand.h"
@interface MPAutotypeDelay : MPAutotypeCommand
@property (readonly) NSUInteger delay;
/**
* Creates an DelayCommand that delays the execution for n milliseconds
*

View File

@@ -8,10 +8,8 @@
#import "MPAutotypeDelay.h"
@interface MPAutotypeDelay () {
@private
NSUInteger _delay;
}
@interface MPAutotypeDelay ()
@property (readwrite) NSUInteger delay;
@end
@implementation MPAutotypeDelay
@@ -22,7 +20,7 @@
}
- (NSString *)description {
return [[NSString alloc] initWithFormat:@"%@ delay: %ld ms", self.class, _delay];
return [[NSString alloc] initWithFormat:@"%@ delay: %ld ms", self.class, self.delay];
}
- (instancetype)initWithDelay:(NSUInteger)delay {
@@ -36,7 +34,7 @@
- (void)execute {
/* milliseconds * 10000 = microseconds */
usleep((useconds_t)(_delay*1000));
usleep((useconds_t)(self.delay*1000));
}
@end

View File

@@ -21,7 +21,7 @@
//
#import <Cocoa/Cocoa.h>
#import "KeePassKit/KeePassKit.h"
#import <KeePassKit/KeePassKit.h>
#import "MPEntrySearchContext.h"
#import "MPTargetNodeResolving.h"

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

@@ -7,33 +7,64 @@
//
#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];
// Put setup code here. This method is called before the invocation of each test method in the class.
[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 {
// Put teardown code here. This method is called after the invocation of each test method in the class.
[super tearDown];
[super tearDown];
}
- (void)testExample {
// This is an example of a functional test case.
// Use XCTAssert and related functions to verify your tests produce the correct results.
- (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)testPerformanceExample {
// This is an example of a performance test case.
[self measureBlock:^{
// Put the code you want to measure the time of here.
}];
- (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