ui-auto-monkey
ui-auto-monkey copied to clipboard
Avoid modifying ui-auto-monkey
Currently if we want to do anything beyond auto-running the monkey we need to comment out the
// Release the monkey!
monkey.RELEASE_THE_MONKEY();
And the README.md reminds us to
Make sure you comment out the last line of `UIAutoMonkey.js` if you include it in your project:
I think it is preferable to be able to integrate the monkey without modifying it. It allows us to place modifications in a distinct client layer.
I suggest we let the default behavior stand, but if you want to release the monkey on your own, in your client simply put:
UIAutoMonkeyClientWillReleaseTheMonkey = true;
At the bottom of UIAutoMonkey we can replace
// Release the monkey!
monkey.RELEASE_THE_MONKEY();
with
if (typeof UIAutoMonkeyClientWillReleaseTheMonkey == 'undefined' || !UIAutoMonkeyClientWillReleaseTheMonkey ) {
// the variable is not defined or it's defined and false
UIAutoMonkey.RELEASE_THE_MONKEY();
}
This change preserves the original ui-auto-monkey intent that one can start using it in a simple straightforward way. If you want to use it with any customization to the config, or the new conditionHandler or ANR facilities you can do so without modifying the source code as delivered from the repo. Instead you can simply put UIAutoMonkeyClientWillReleaseTheMonkey = true;
into your client.
Looks good to me! Since no one chimed in, go ahead with a pull request.