Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Automatically enable accessibility on the device also #93

Merged
merged 2 commits into from

2 participants

@sgleadow

My previous pull request for enabling accessibility on the device. After some comments on my blog post about it, I modified the code to also run on the device. I wrote up my findings on another blog post

Without this code, when I run KIF on a device without VoiceOver on, the accessibility values are not available to KIF and the test fails. With this code, the values become available automatically and the tests can run on the device.

@puls
Owner

Awesome, but I'd change the name of the method from _enableAccessibilityInSimulator to something more general.

@sgleadow

Good catch, I missed that completely. I have renamed the method to be general

@puls puls merged commit 87b535b into from
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Nov 15, 2011
  1. Automatically enable accessibility on the device also

    Stewart Gleadow authored
  2. Renaming method to not be simulator specific

    Stewart Gleadow authored
This page is out of date. Refresh to see the latest.
Showing with 18 additions and 13 deletions.
  1. +18 −13 Classes/KIFTestController.m
View
31 Classes/KIFTestController.m
@@ -30,7 +30,7 @@ @interface KIFTestController ()
@property (nonatomic, retain) NSDate *currentStepStartDate;
@property (nonatomic, copy) KIFTestControllerCompletionBlock completionBlock;
-+ (void)_enableAccessibilityInSimulator;
++ (void)_enableAccessibility;
- (void)_initializeScenariosIfNeeded;
- (BOOL)_isAccessibilityInspectorEnabled;
@@ -68,25 +68,30 @@ @implementation KIFTestController
+ (void)load
{
- [KIFTestController _enableAccessibilityInSimulator];
+ [KIFTestController _enableAccessibility];
}
-+ (void)_enableAccessibilityInSimulator;
++ (void)_enableAccessibility;
{
NSAutoreleasePool *autoreleasePool = [[NSAutoreleasePool alloc] init];
+ NSString *appSupportLocation = @"/System/Library/PrivateFrameworks/AppSupport.framework/AppSupport";
- NSString *simulatorRoot = [[[NSProcessInfo processInfo] environment] objectForKey:@"IPHONE_SIMULATOR_ROOT"];
+ NSDictionary *environment = [[NSProcessInfo processInfo] environment];
+ NSString *simulatorRoot = [environment objectForKey:@"IPHONE_SIMULATOR_ROOT"];
if (simulatorRoot) {
- void *appSupportLibrary = dlopen([[simulatorRoot stringByAppendingPathComponent:@"/System/Library/PrivateFrameworks/AppSupport.framework/AppSupport"] fileSystemRepresentation], RTLD_LAZY);
- CFStringRef (*copySharedResourcesPreferencesDomainForDomain)(CFStringRef domain) = dlsym(appSupportLibrary, "CPCopySharedResourcesPreferencesDomainForDomain");
+ appSupportLocation = [simulatorRoot stringByAppendingString:appSupportLocation];
+ }
+
+ void *appSupportLibrary = dlopen([appSupportLocation fileSystemRepresentation], RTLD_LAZY);
+
+ CFStringRef (*copySharedResourcesPreferencesDomainForDomain)(CFStringRef domain) = dlsym(appSupportLibrary, "CPCopySharedResourcesPreferencesDomainForDomain");
+
+ if (copySharedResourcesPreferencesDomainForDomain) {
+ CFStringRef accessibilityDomain = copySharedResourcesPreferencesDomainForDomain(CFSTR("com.apple.Accessibility"));
- if (copySharedResourcesPreferencesDomainForDomain) {
- CFStringRef accessibilityDomain = copySharedResourcesPreferencesDomainForDomain(CFSTR("com.apple.Accessibility"));
-
- if (accessibilityDomain) {
- CFPreferencesSetValue(CFSTR("ApplicationAccessibilityEnabled"), kCFBooleanTrue, accessibilityDomain, kCFPreferencesAnyUser, kCFPreferencesAnyHost);
- CFRelease(accessibilityDomain);
- }
+ if (accessibilityDomain) {
+ CFPreferencesSetValue(CFSTR("ApplicationAccessibilityEnabled"), kCFBooleanTrue, accessibilityDomain, kCFPreferencesAnyUser, kCFPreferencesAnyHost);
+ CFRelease(accessibilityDomain);
}
}
Something went wrong with that request. Please try again.