Skip to content

Commit 63d673d

Browse files
committed
Merge pull request #447 from xing/overrelease_fix
Fixes issue with overreleased objects
2 parents fcb79a7 + 35f1f8e commit 63d673d

2 files changed

Lines changed: 28 additions & 25 deletions

File tree

Classes/KIFTestActor.m

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -84,21 +84,19 @@ - (BOOL)tryRunningBlock:(KIFTestExecutionBlock)executionBlock complete:(KIFTestC
8484
KIFTestStepResult result;
8585
NSError *internalError;
8686

87-
@autoreleasepool {
88-
while ((result = executionBlock(&internalError)) == KIFTestStepResultWait && -[startDate timeIntervalSinceNow] < timeout) {
89-
CFRunLoopRunInMode([[UIApplication sharedApplication] currentRunLoopMode] ?: kCFRunLoopDefaultMode, KIFTestStepDelay, false);
90-
}
91-
92-
if (result == KIFTestStepResultWait) {
93-
internalError = [NSError KIFErrorWithUnderlyingError:internalError format:@"The step timed out after %.2f seconds: %@", timeout, internalError.localizedDescription];
94-
result = KIFTestStepResultFailure;
95-
}
96-
97-
if (completionBlock) {
98-
completionBlock(result, internalError);
99-
}
87+
while ((result = executionBlock(&internalError)) == KIFTestStepResultWait && -[startDate timeIntervalSinceNow] < timeout) {
88+
CFRunLoopRunInMode([[UIApplication sharedApplication] currentRunLoopMode] ?: kCFRunLoopDefaultMode, KIFTestStepDelay, false);
10089
}
101-
90+
91+
if (result == KIFTestStepResultWait) {
92+
internalError = [NSError KIFErrorWithUnderlyingError:internalError format:@"The step timed out after %.2f seconds: %@", timeout, internalError.localizedDescription];
93+
result = KIFTestStepResultFailure;
94+
}
95+
96+
if (completionBlock) {
97+
completionBlock(result, internalError);
98+
}
99+
102100
if (error) {
103101
*error = internalError;
104102
}

Classes/KIFUITestActor.m

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,10 @@ - (UIView *)waitForTappableViewWithAccessibilityLabel:(NSString *)label value:(N
5959
- (UIView *)waitForViewWithAccessibilityLabel:(NSString *)label value:(NSString *)value traits:(UIAccessibilityTraits)traits tappable:(BOOL)mustBeTappable
6060
{
6161
UIView *view = nil;
62-
[self waitForAccessibilityElement:NULL view:&view withLabel:label value:value traits:traits tappable:mustBeTappable];
62+
@autoreleasepool {
63+
[self waitForAccessibilityElement:NULL view:&view withLabel:label value:value traits:traits tappable:mustBeTappable];
64+
}
65+
6366
return view;
6467
}
6568

@@ -132,11 +135,12 @@ - (void)tapViewWithAccessibilityLabel:(NSString *)label traits:(UIAccessibilityT
132135

133136
- (void)tapViewWithAccessibilityLabel:(NSString *)label value:(NSString *)value traits:(UIAccessibilityTraits)traits
134137
{
135-
UIView *view = nil;
136-
UIAccessibilityElement *element = nil;
137-
138-
[self waitForAccessibilityElement:&element view:&view withLabel:label value:value traits:traits tappable:YES];
139-
[self tapAccessibilityElement:element inView:view];
138+
@autoreleasepool {
139+
UIView *view = nil;
140+
UIAccessibilityElement *element = nil;
141+
[self waitForAccessibilityElement:&element view:&view withLabel:label value:value traits:traits tappable:YES];
142+
[self tapAccessibilityElement:element inView:view];
143+
}
140144
}
141145

142146
- (void)tapAccessibilityElement:(UIAccessibilityElement *)element inView:(UIView *)view
@@ -206,11 +210,12 @@ - (void)longPressViewWithAccessibilityLabel:(NSString *)label value:(NSString *)
206210

207211
- (void)longPressViewWithAccessibilityLabel:(NSString *)label value:(NSString *)value traits:(UIAccessibilityTraits)traits duration:(NSTimeInterval)duration;
208212
{
209-
UIView *view = nil;
210-
UIAccessibilityElement *element = nil;
211-
212-
[self waitForAccessibilityElement:&element view:&view withLabel:label value:value traits:traits tappable:YES];
213-
[self longPressAccessibilityElement:element inView:view duration:duration];
213+
@autoreleasepool {
214+
UIView *view = nil;
215+
UIAccessibilityElement *element = nil;
216+
[self waitForAccessibilityElement:&element view:&view withLabel:label value:value traits:traits tappable:YES];
217+
[self longPressAccessibilityElement:element inView:view duration:duration];
218+
}
214219
}
215220

216221
- (void)longPressAccessibilityElement:(UIAccessibilityElement *)element inView:(UIView *)view duration:(NSTimeInterval)duration;

0 commit comments

Comments
 (0)