Reset the simulator and re-enable usability settings?

170 views
Skip to first unread message

Rodney Degracia

unread,
Sep 27, 2011, 1:07:42 PM9/27/11
to frank-...@googlegroups.com

Is there a way to 'reset' the simulator and re-enable the usability settings, via command-line?

There are some instances where I would like to make sure the simulator is 'clean' before running the Frank cucumber tests, but I'd rather have it do automatically rather than manually.


Rodney Degracia
rdeg...@gmail.com

http://www.elitefrontier.org


Pete Hodgson

unread,
Sep 27, 2011, 1:41:09 PM9/27/11
to frank-...@googlegroups.com
Can you use applescript to invoke the "Reset Content and Settings" menu item, in the same way that we invoke the rotation and memory warnings in the simulator?

Stewart Gleadow

unread,
Oct 5, 2011, 9:01:37 PM10/5/11
to frank-...@googlegroups.com
I posted this on the KIF list, so some of you may have already seen it, but you can turn on accessibility programmatically either by editing the plist file in a Ruby/shell script before you run the tests. I find the easiest way is to enable accessibility on application launch using the following code (called from the app delegate for #ifdef FRANK)

#ifdef FRANK
#import <dlfcn.h>
#endif

...


#ifdef FRANK
        NSString *simulatorRoot = [[[NSProcessInfo processInfo] 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");
if (copySharedResourcesPreferencesDomainForDomain)
{
CFStringRef accessibilityDomain = copySharedResourcesPreferencesDomainForDomain(CFSTR("com.apple.Accessibility"));
if (accessibilityDomain)
{
CFPreferencesSetValue(CFSTR("ApplicationAccessibilityEnabled"), kCFBooleanTrue, accessibilityDomain, kCFPreferencesAnyUser, kCFPreferencesAnyHost);
CFRelease(accessibilityDomain);
}
}
}
#endif

cheers,
Stew

Pete Hodgson

unread,
Oct 6, 2011, 9:58:47 PM10/6/11
to frank-...@googlegroups.com
This is great Stew - not turning on accessibility is a common stumbling block when first getting started with iOS automation. Thanks for sharing. Mind if I put this code into the Frank server?

Oh, and do you know if this approach also shows the annoying Accessibility Inspector? I would be happy to stop having to drag that thing out of the way!

Stewart Gleadow

unread,
Oct 6, 2011, 10:48:32 PM10/6/11
to frank-...@googlegroups.com
Go right ahead. Sorry I've been so lazy with pull requests to not have integrated it already! I haven't used it in a while, but from memory, it does _not_ show the accessibility inspector - which is usually great.

Occasionally, I turn on the accessibility inspector to actually inspect elements on the screen, in which case you still need to enable in the settings app - but Symbiote is usually better for that kind of thing anway.

- Stew

Stewart Gleadow

unread,
Oct 7, 2011, 2:03:16 AM10/7/11
to frank-...@googlegroups.com
Pete,

I added this same functionality to KIF, so you can probably grab the code straight from there...https://github.com/square/KIF/pull/78 or https://github.com/sgleadow/KIF

Having used KIF for the first time today, it seems robust and fast... but the tests have very verbose syntax compared with Cucumber, and would be unreadable to non-Objective C folks. I guess I can't have my cake and eat it too.

cheers,
Stew

Heath Borders

unread,
Dec 12, 2011, 2:51:32 PM12/12/11
to frank-...@googlegroups.com
I've just added stew's code to my main method, and it works great.  Without it, my tests don't pass on a freshly reset simulator.  Are there plans to incorporate this feature?

Peter Hodgson

unread,
Dec 12, 2011, 2:55:27 PM12/12/11
to frank-...@googlegroups.com
Hi Heath,

I took a quick run at adding this, but for some reason it didn't work straight away. I then immediately got distracted by something shiny, and forgot to come back to it and figure it out. I'm confident that I was just making some kind of dumb mistake and didn't take the time to figure out what.

If someone sends me a pull request I would be very happy to accept it :)

Cheers,
Pete

Heath Borders

unread,
Dec 12, 2011, 4:21:59 PM12/12/11
to frank-...@googlegroups.com
I just issued a pull request.

I didn't see any directions for checking out the project and getting everything to build, so I just had to guess (it wasn't that hard).  Do you have plans to write up some directions for building the project after cloning?

I had to make a bunch of changes to the project in order for it to compile.  Mostly, UISpec has changed its layout (source is now under UISpec/src) and removed some files (UISwizzle.h, .m).  Also, the update_from_github.rb and update_from_svn.rb scripts no longer exist.  Is it possible that those scripts were erroneously included in a submodule?

Thanks!

Peter Hodgson

unread,
Dec 13, 2011, 12:48:02 PM12/13/11
to frank-...@googlegroups.com

Thanks a lot for this Heath. I've pulled in your commit. If I get a chance I might pull the code you added into a seperate method and remove the now redundant accessibility checking code.

Regarding the procedure for checking out and building, a 'git submodule update --init' followed by 'rake' should do the trick, but that's obviously not clear. I will add something to the README. The update_from_* scripts aren't needed any more now that we're using git submodules to pull in 3rd party code. Where did you find reference to those scripts?

Cheers,
Pete

--
Typed on a teeny tiny keyboard

Heath Borders

unread,
Dec 13, 2011, 1:02:03 PM12/13/11
to frank-...@googlegroups.com

They were still referenced in Frank.xcodeproj and FrankFramework.xcodeproj. I can issue another pull request if you want.

Peter Hodgson

unread,
Dec 13, 2011, 2:22:47 PM12/13/11
to frank-...@googlegroups.com

Sure, always happy to get pull requests.

Cheers,
Pete
--
Typed on a teeny tiny keyboard

Reply all
Reply to author
Forward
0 new messages