forked from atljeremy/JFMinimalNotifications
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
179 changed files
with
17,345 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
Oops, something went wrong.