Skip to content

Commit

Permalink
Adding KIF
Browse files Browse the repository at this point in the history
  • Loading branch information
atljeremy committed Apr 23, 2015
1 parent b6133cf commit 115e706
Show file tree
Hide file tree
Showing 179 changed files with 17,345 additions and 0 deletions.
18 changes: 18 additions & 0 deletions Example/Vendor/KIF/Additions/CGGeometry-KIFAdditions.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
//
// CGGeometry-KIFAdditions.h
// KIF
//
// Created by Eric Firestone on 5/22/11.
// Licensed to Square, Inc. under one or more contributor license agreements.
// See the LICENSE file distributed with this work for the terms under
// which Square, Inc. licenses this file to you.

#import <CoreGraphics/CGGeometry.h>

CG_INLINE CGPoint CGPointCenteredInRect(CGRect bounds) {
return CGPointMake(bounds.origin.x + bounds.size.width * 0.5f, bounds.origin.y + bounds.size.height * 0.5f);
}

CG_INLINE CGPoint CGPointMidPoint(CGPoint point1, CGPoint point2) {
return CGPointMake((point1.x + point2.x) / 2.0, (point1.y + point2.y) / 2.0);
}
11 changes: 11 additions & 0 deletions Example/Vendor/KIF/Additions/CGGeometry-KIFAdditions.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
//
// CGGeometry-KIFAdditions.m
// KIF
//
// Created by Eric Firestone on 5/22/11.
// Licensed to Square, Inc. under one or more contributor license agreements.
// See the LICENSE file distributed with this work for the terms under
// which Square, Inc. licenses this file to you.

#import "CGGeometry-KIFAdditions.h"

18 changes: 18 additions & 0 deletions Example/Vendor/KIF/Additions/LoadableCategory.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
//
// LoadableCategory.h
// KIF
//
// Created by Karl Stenerud on 7/16/11.
// Licensed to Square, Inc. under one or more contributor license agreements.
// See the LICENSE file distributed with this work for the terms under
// which Square, Inc. licenses this file to you.

/** Make all categories in the current file loadable without using -load-all.
*
* Normally, compilers will skip linking files that contain only categories.
* Adding a call to this macro adds a dummy class, which causes the linker
* to add the file.
*
* @param UNIQUE_NAME A globally unique name.
*/
#define MAKE_CATEGORIES_LOADABLE(UNIQUE_NAME) @interface FORCELOAD_##UNIQUE_NAME : NSObject @end @implementation FORCELOAD_##UNIQUE_NAME @end
15 changes: 15 additions & 0 deletions Example/Vendor/KIF/Additions/NSBundle-KIFAdditions.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
//
// NSBundle+KIFAdditions.h
// KIF
//
// Created by Brian Nickel on 7/27/13.
//
//

#import <Foundation/Foundation.h>

@interface NSBundle (KIFAdditions)

+ (NSBundle *)KIFTestBundle;

@end
27 changes: 27 additions & 0 deletions Example/Vendor/KIF/Additions/NSBundle-KIFAdditions.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
//
// NSBundle+KIFAdditions.m
// KIF
//
// Created by Brian Nickel on 7/27/13.
//
//

#import "NSBundle-KIFAdditions.h"
#import "KIFTestCase.h"
#import "LoadableCategory.h"

MAKE_CATEGORIES_LOADABLE(NSBundle_KIFAdditions)

@implementation NSBundle (KIFAdditions)

+ (NSBundle *)KIFTestBundle
{
static NSBundle *bundle;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
bundle = [self bundleForClass:[KIFTestCase class]];
});
return bundle;
}

@end
16 changes: 16 additions & 0 deletions Example/Vendor/KIF/Additions/NSError-KIFAdditions.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
//
// NSError+KIFAdditions.h
// KIF
//
// Created by Brian Nickel on 7/27/13.
//
//

#import <Foundation/Foundation.h>

@interface NSError (KIFAdditions)

+ (instancetype)KIFErrorWithUnderlyingError:(NSError *)underlyingError format:(NSString *)format, ... NS_FORMAT_FUNCTION(2,3);
+ (instancetype)KIFErrorWithFormat:(NSString *)format, ... NS_FORMAT_FUNCTION(1,2);

@end
39 changes: 39 additions & 0 deletions Example/Vendor/KIF/Additions/NSError-KIFAdditions.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
//
// NSError+KIFAdditions.m
// KIF
//
// Created by Brian Nickel on 7/27/13.
//
//

#import "NSError-KIFAdditions.h"
#import "LoadableCategory.h"
#import "KIFTestActor.h"

MAKE_CATEGORIES_LOADABLE(NSError_KIFAdditions)

@implementation NSError (KIFAdditions)

+ (instancetype)KIFErrorWithFormat:(NSString *)format, ...
{
va_list args;
va_start(args, format);
NSString *description = [[NSString alloc] initWithFormat:format arguments:args];
va_end(args);

return [self errorWithDomain:@"KIFTest" code:KIFTestStepResultFailure userInfo:@{NSLocalizedDescriptionKey: description}];
}

+ (instancetype)KIFErrorWithUnderlyingError:(NSError *)underlyingError format:(NSString *)format, ...
{
va_list args;
va_start(args, format);
NSString *description = [[NSString alloc] initWithFormat:format arguments:args];
va_end(args);

NSDictionary *userInfo = [[NSDictionary alloc] initWithObjectsAndKeys:description, NSLocalizedDescriptionKey, underlyingError, NSUnderlyingErrorKey, nil];

return [self errorWithDomain:@"KIFTest" code:KIFTestStepResultFailure userInfo:userInfo];
}

@end
15 changes: 15 additions & 0 deletions Example/Vendor/KIF/Additions/NSException-KIFAdditions.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
//
// NSException-KIFAdditions.h
// KIF
//
// Created by Tony DiPasquale on 12/20/13.
//
//

#import <Foundation/Foundation.h>

@interface NSException (KIFAdditions)

+ (NSException *)failureInFile:(NSString *)file atLine:(NSInteger)line withDescription:(NSString *)formatString, ...;

@end
28 changes: 28 additions & 0 deletions Example/Vendor/KIF/Additions/NSException-KIFAdditions.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
//
// NSException-KIFAdditions.m
// KIF
//
// Created by Tony DiPasquale on 12/20/13.
//
//

#import "NSException-KIFAdditions.h"

@implementation NSException (KIFAdditions)

+ (NSException *)failureInFile:(NSString *)file atLine:(NSInteger)line withDescription:(NSString *)formatString, ...
{
va_list argumentList;
va_start(argumentList, formatString);

NSString *reason = [[NSString alloc] initWithFormat:formatString arguments:argumentList];

va_end(argumentList);

return [NSException exceptionWithName:@"KIFFailureException"
reason: reason
userInfo:@{@"SenTestFilenameKey": file,
@"SenTestLineNumberKey": @(line)}];
}

@end
18 changes: 18 additions & 0 deletions Example/Vendor/KIF/Additions/NSFileManager-KIFAdditions.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
//
// NSFileManager-KIFAdditions.h
// KIF
//
// Created by Michael Thole on 6/1/11.
// Licensed to Square, Inc. under one or more contributor license agreements.
// See the LICENSE file distributed with this work for the terms under
// which Square, Inc. licenses this file to you.

#import <Foundation/Foundation.h>


@interface NSFileManager (KIFAdditions)

- (NSString *)createUserDirectory:(NSSearchPathDirectory)searchPath;
- (BOOL)recursivelyCreateDirectory:(NSString *)path;

@end
67 changes: 67 additions & 0 deletions Example/Vendor/KIF/Additions/NSFileManager-KIFAdditions.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
//
// NSFileManager-KIFAdditions.m
// KIF
//
// Created by Michael Thole on 6/1/11.
// Licensed to Square, Inc. under one or more contributor license agreements.
// See the LICENSE file distributed with this work for the terms under
// which Square, Inc. licenses this file to you.

#import "NSFileManager-KIFAdditions.h"
#import "LoadableCategory.h"


MAKE_CATEGORIES_LOADABLE(NSFileManager_KIFAdditions)


@implementation NSFileManager (KIFAdditions)

#pragma mark Public Methods

- (NSString *)createUserDirectory:(NSSearchPathDirectory)searchPath;
{
NSArray *paths = NSSearchPathForDirectoriesInDomains(searchPath, NSUserDomainMask, YES);
if (!paths.count) {
return nil;
}

NSString *rootDirectory = paths[0];

BOOL isDir;
BOOL created = NO;
if ([self fileExistsAtPath:rootDirectory isDirectory:&isDir] && isDir) {
created = YES;
} else {
created = [self recursivelyCreateDirectory:rootDirectory];
}

return created ? rootDirectory : nil;
}

- (BOOL)recursivelyCreateDirectory:(NSString *)path;
{
BOOL isDir = NO;
BOOL isParentADir = NO;
NSString *parentDir = nil;

if (![self fileExistsAtPath:path isDirectory:&isDir]) {
// if file doesn't exist, first create parent
parentDir = [path stringByDeletingLastPathComponent];

if (!parentDir.length || [parentDir isEqualToString:@"/"]) {
isParentADir = YES;
} else {
isParentADir = [self recursivelyCreateDirectory:parentDir];
}

if (isParentADir) {
isDir = [self createDirectoryAtPath:path withIntermediateDirectories:NO attributes:nil error:nil];
} else {
return NO;
}
}

return isDir;
}

@end
14 changes: 14 additions & 0 deletions Example/Vendor/KIF/Additions/SenTestCase-KIFAdditions.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
//
// SenTestCase-KIFAdditions.h
// KIF
//
// Created by Brian Nickel on 8/23/13.
//
//

#import <SenTestingKit/SenTestingKit.h>
#import "KIFTestActor.h"

@interface SenTestCase (KIFAdditions) <KIFTestActorDelegate>

@end
33 changes: 33 additions & 0 deletions Example/Vendor/KIF/Additions/SenTestCase-KIFAdditions.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
//
// SenTestCase-KIFAdditions.m
// KIF
//
// Created by Brian Nickel on 8/23/13.
//
//

#import "SenTestCase-KIFAdditions.h"
#import "LoadableCategory.h"

MAKE_CATEGORIES_LOADABLE(SenTestCase_KIFAdditions)

@implementation SenTestCase (KIFAdditions)

- (void)failWithException:(NSException *)exception stopTest:(BOOL)stop
{
if (stop) {
[self raiseAfterFailure];
}
[self failWithException:exception];
[self continueAfterFailure];
}

- (void)failWithExceptions:(NSArray *)exceptions stopTest:(BOOL)stop
{
NSException *lastException = exceptions.lastObject;
for (NSException *exception in exceptions) {
[self failWithException:exception stopTest:(exception == lastException ? stop : NO)];
}
}

@end
Loading

0 comments on commit 115e706

Please sign in to comment.