-
Notifications
You must be signed in to change notification settings - Fork 914
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #794 from RoyalPineapple/kifuiviewtestactor
Add a new test actor, KIFUIViewTestActor.
- Loading branch information
Showing
41 changed files
with
2,655 additions
and
113 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 @@ | ||
// | ||
// NSPredicate+KIFAdditions.h | ||
// KIF | ||
// | ||
// Created by Alex Odawa on 2/3/15. | ||
// | ||
// | ||
|
||
#import <Foundation/Foundation.h> | ||
|
||
@interface NSPredicate (KIFAdditions) | ||
|
||
@property NSString *kifPredicateDescription; | ||
|
||
- (NSArray *)flatten; | ||
- (NSCompoundPredicate *)minusSubpredicatesFrom:(NSPredicate *)otherPredicate; | ||
|
||
@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,71 @@ | ||
// | ||
// NSPredicate+KIFAdditions.m | ||
// KIF | ||
// | ||
// Created by Alex Odawa on 2/3/15. | ||
// | ||
// | ||
|
||
#import <objc/runtime.h> | ||
#import "NSPredicate+KIFAdditions.h" | ||
|
||
@implementation NSPredicate (KIFAdditions) | ||
|
||
- (NSArray *)flatten | ||
{ | ||
NSMutableArray *result = [[NSMutableArray alloc] init]; | ||
|
||
if ([self isKindOfClass:[NSCompoundPredicate class]]) { | ||
for (NSPredicate *predicate in ((NSCompoundPredicate *)self).subpredicates) { | ||
[result addObjectsFromArray:[predicate flatten]]; | ||
} | ||
} else { | ||
[result addObject:self]; | ||
} | ||
|
||
return result; | ||
} | ||
|
||
- (NSCompoundPredicate *)minusSubpredicatesFrom:(NSPredicate *)otherPredicate; | ||
{ | ||
if (self == otherPredicate) { | ||
return nil; | ||
} | ||
NSMutableSet *subpredicates = [NSMutableSet setWithArray:[self flatten]]; | ||
NSMutableSet *otherSubpredicates = [NSMutableSet setWithArray:[otherPredicate flatten]]; | ||
[subpredicates minusSet:otherSubpredicates]; | ||
return [[NSCompoundPredicate alloc] initWithType:NSAndPredicateType | ||
subpredicates:[subpredicates allObjects]]; | ||
} | ||
|
||
- (void)setKifPredicateDescription:(NSString *)description; | ||
{ | ||
NSString *desc = description.copy; | ||
objc_setAssociatedObject(self, @selector(kifPredicateDescription), desc, OBJC_ASSOCIATION_RETAIN_NONATOMIC); | ||
} | ||
|
||
- (NSString *)kifPredicateDescription; | ||
{ | ||
id object = objc_getAssociatedObject(self, @selector(kifPredicateDescription)); | ||
if (object) { | ||
return object; | ||
} | ||
// Compound predicates containing subpredicates with the kifPredicateDescription set should still get our pretty formatting. | ||
if ([self isKindOfClass:[NSCompoundPredicate class]]) { | ||
NSArray *subpredicates = [self flatten]; | ||
NSString *description = @""; | ||
|
||
for (NSPredicate *predicate in subpredicates) { | ||
if (description.length > 0) { | ||
description = [description stringByAppendingString:@", "]; | ||
} | ||
description = [description stringByAppendingString:predicate.kifPredicateDescription]; | ||
} | ||
|
||
return description; | ||
} | ||
|
||
return self.description; | ||
} | ||
|
||
@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 @@ | ||
// | ||
// NSString+KIFAdditions.h | ||
// KIF | ||
// | ||
// Created by Alex Odawa on 1/28/16. | ||
// | ||
// | ||
|
||
#import <Foundation/Foundation.h> | ||
|
||
#pragma mark - NSString | ||
@interface NSString (KIFAdditions) | ||
|
||
- (BOOL)KIF_isEqualToStringOrAttributedString:(id)aString; | ||
|
||
@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,24 @@ | ||
// | ||
// NSString+KIFAdditions.m | ||
// KIF | ||
// | ||
// Created by Alex Odawa on 1/28/16. | ||
// | ||
// | ||
|
||
#import "NSString+KIFAdditions.h" | ||
|
||
#pragma mark - NSString | ||
@implementation NSString (KIFAdditions) | ||
|
||
- (BOOL)KIF_isEqualToStringOrAttributedString:(id)aString; | ||
{ | ||
// Somtimes Accessibility Elements will return an AXAttributedString. | ||
// This compares the raw backing string against a vanilla NSString, ignoring any attributes. | ||
if ([aString respondsToSelector:@selector(string)]) { | ||
return [self isEqualToString:[(id)aString string]]; | ||
} | ||
return [self isEqualToString:aString]; | ||
} | ||
|
||
@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
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
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
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
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 @@ | ||
// | ||
// KIFUIObject.h | ||
// KIF | ||
// | ||
// Created by Alex Odawa on 1/26/15. | ||
// | ||
// | ||
|
||
#import <UIKit/UIKit.h> | ||
|
||
@interface KIFUIObject : NSObject | ||
|
||
@property (nonatomic, weak, readonly) UIView *view; | ||
@property (nonatomic, weak, readonly) UIAccessibilityElement *element; | ||
|
||
- (instancetype)initWithElement:(UIAccessibilityElement *)element view:(UIView *)view; | ||
|
||
@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 @@ | ||
// | ||
// KIFUIObject.m | ||
// KIF | ||
// | ||
// Created by Alex Odawa on 1/26/15. | ||
// | ||
// | ||
|
||
#import "KIFUIObject.h" | ||
|
||
|
||
@implementation KIFUIObject | ||
|
||
- (instancetype)initWithElement:(UIAccessibilityElement *)element view:(UIView *)view; | ||
{ | ||
self = [super init]; | ||
if (self) { | ||
_element = element; | ||
_view = view; | ||
} | ||
return self; | ||
} | ||
|
||
- (NSString *)description; | ||
{ | ||
return [NSString stringWithFormat:@"<%@;\n| element=%@;\n| | view=%@>", [super description], self.element, self.view]; | ||
} | ||
@end |
Oops, something went wrong.