Skip to content

Commit c9c6e36

Browse files
author
Simon Booth
committed
Add a dimmingViewWindow property to UIApplication and use that when dismissing the popover
1 parent 79db32c commit c9c6e36

3 files changed

Lines changed: 16 additions & 3 deletions

File tree

Additions/UIApplication-KIFAdditions.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919

2020
- (UIWindow *)keyboardWindow;
2121
- (UIWindow *)pickerViewWindow;
22+
- (UIWindow *)dimmingViewWindow;
2223
- (NSArray *)windowsWithKeyWindow;
2324

2425
@end

Additions/UIApplication-KIFAdditions.m

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,18 @@ - (UIWindow *)pickerViewWindow;
7676
return nil;
7777
}
7878

79+
- (UIWindow *)dimmingViewWindow;
80+
{
81+
for (UIWindow *window in self.windowsWithKeyWindow) {
82+
NSArray *dimmingViews = [window subviewsWithClassNameOrSuperClassNamePrefix:@"UIDimmingView"];
83+
if (dimmingViews.count > 0) {
84+
return window;
85+
}
86+
}
87+
88+
return nil;
89+
}
90+
7991
- (NSArray *)windowsWithKeyWindow
8092
{
8193
NSMutableArray *windows = self.windows.mutableCopy;

Classes/KIFTestStep.m

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -585,9 +585,9 @@ + (id)stepToDismissPopover;
585585
{
586586
return [self stepWithDescription:@"Dismiss the popover" executionBlock:^(KIFTestStep *step, NSError **error) {
587587
const NSTimeInterval tapDelay = 0.05;
588-
NSArray *windows = [[UIApplication sharedApplication] windowsWithKeyWindow];
589-
KIFTestCondition(windows.count, error, @"Failed to find any windows in the application");
590-
UIView *dimmingView = [[[windows objectAtIndex:0] subviewsWithClassNamePrefix:@"UIDimmingView"] lastObject];
588+
UIWindow *window = [[UIApplication sharedApplication] dimmingViewWindow];
589+
KIFTestCondition(window, error, @"Failed to find any dimming views in the application");
590+
UIView *dimmingView = [[window subviewsWithClassNamePrefix:@"UIDimmingView"] lastObject];
591591
[dimmingView tapAtPoint:CGPointMake(50.0f, 50.0f)];
592592
CFRunLoopRunInMode(kCFRunLoopDefaultMode, tapDelay, false);
593593
return KIFTestStepResultSuccess;

0 commit comments

Comments
 (0)