Permalink
Browse files

Merge pull request #11 from square/check-for-accessibility-inspector

Helpfully check to ensure that the accessibility inspector is enabled bef
  • Loading branch information...
2 parents d36b928 + 9c42d28 commit 4347541b1c6138ee96337b745ae9220bb178eb2f @mthole mthole committed Jul 14, 2011
Showing with 17 additions and 0 deletions.
  1. +17 −0 Classes/KIFTestController.m
@@ -25,6 +25,7 @@ @interface KIFTestController ()
@property (nonatomic, copy) KIFTestControllerCompletionBlock completionBlock;
- (void)_initializeScenariosIfNeeded;
+- (BOOL)_isAccessibilityInspectorEnabled;
- (void)_scheduleCurrentTestStep;
- (void)_performTestStep:(KIFTestStep *)step;
- (void)_advanceWithResult:(KIFTestStepResult)result error:(NSError*) error;
@@ -142,6 +143,7 @@ - (void)addScenario:(KIFTestScenario *)scenario;
- (void)startTestingWithCompletionBlock:(KIFTestControllerCompletionBlock)inCompletionBlock
{
NSAssert(!self.testing, @"Testing is already in progress");
+ NSAssert([self _isAccessibilityInspectorEnabled], @"The accessibility inspector must be enabled in order to run KIF tests. It can be turned on in the Settings app of the simulator by going to General -> Accessibility.");
self.testing = YES;
self.testSuiteStartDate = [NSDate date];
@@ -183,6 +185,21 @@ - (void)_initializeScenariosIfNeeded
}
}
+- (BOOL)_isAccessibilityInspectorEnabled;
+{
+ // This method for testing if the inspector is enabled was taken from the Frank framework.
+ // https://github.com/moredip/Frank
+ UIWindow *keyWindow = [[UIApplication sharedApplication] keyWindow];
+ NSString *originalAccessibilityLabel = [keyWindow accessibilityLabel];
+
+ [keyWindow setAccessibilityLabel:@"KIF Test Label"];
+ BOOL isInspectorEnabled = [[keyWindow accessibilityLabel] isEqualToString:@"KIF Test Label"];
+
+ [keyWindow setAccessibilityLabel:originalAccessibilityLabel];
+
+ return isInspectorEnabled;
+}
+
- (void)_scheduleCurrentTestStep;
{
[self performSelector:@selector(_delayedScheduleCurrentTestStep) withObject:nil afterDelay:0.01f];

0 comments on commit 4347541

Please sign in to comment.