I currently have a number of function tests written in javascript using Apple's UIAutomation API. The tests are written for iPhone, but the application also supports the iPad.
To extend my tests to run on an iPad I need to make some adjustments in the code, but first I need to find out what device is running the tests.
How do I detect what device/simulator is running the tests? when I'm running the javascript tests from the Automation tool.
UIATarget.localTarget().model() holds the information about which device the tests are running on.
I have discovered Alex Vollmer's tuneup_js library. It allows for device independent code to some extent as least.
e.g.)
test("my test", function(target, app) {
assertWindow({
"navigationBar~iphone": {
leftButton: { name: "Back" },
rightButton: { name: "Done" }
},
"navigationBar~ipad": {
leftButton: null,
rightButton: { name: "Cancel" }
},
});
});
edit
Found the following in tuneup_js:
/**
* A convenience method for detecting that you're running on an iPad
*/
isDeviceiPad: function() {
return this.model().match(/^iPad/) !== null;
},
/**
* A convenience method for detecting that you're running on an
* iPhone or iPod touch
*/
isDeviceiPhone: function() {
return this.model().match(/^iPhone/) !== null;
}
With these I'll be able to write device specific code.