Hi everyone, I guess everyone knows how to run Monkey, but we all know that Google documentation is mediocre. All we have is this page: http://developer.android.com/guide/developing/tools/index.html
We have found the need to run our own script to manually test our application. For that, we would require the Monkey to send touch events to specific points on the screen. Since there has been ZERO support from Google, I decided to sift though the source code for Monkey. Here are my findings: The source of monkey is located in: development\cmds\monkey If you take a look at the directory, there is a file called "example_script.txt" and following is the contents: # Touch the android touch down 160 200 touch up 160 200 sleep 1000 # Hit Next touch down 300 450 touch up 300 450 sleep 1000 # Hit Next touch down 300 450 touch up 300 450 sleep 1000 # Hit Next touch down 300 450 touch up 300 450 sleep 1000 # Go down and select the account username key down dpad_down key up dpad_down key down dpad_down key up dpad_down key down dpad_center key up dpad_center # account name: bill key down b key up b key down i key up i key down l key up l key down l key up l # Go down to the password field key down dpad_down key up dpad_down # password: bill key down b key up b key down i key up i key down l key up l key down l key up l # Select next touch down 300 450 touch up 300 450 # quit quit Looking at the source code, the command to use a script is: adb shell monkey -f script.txt 1 But you will notice that adb exited with code: -5. And looking at the one of the source code that handles the parsing of the script file, MonkeySourceScript.java, the script simply doesn't work because those are not the actual commands that the MonkeySourceScript is looking for. Now, lets take a look at the MonkeySourceScript.java's comment header: /** * monkey event queue. It takes a script to produce events sample script format: * * <pre> * type= raw events * count= 10 * speed= 1.0 * start data >> * captureDispatchPointer(5109520,5109520,0,230.75429,458.1814,0.20784314,0.06666667,0,0.0,0.0,65539,0) * captureDispatchKey(5113146,5113146,0,20,0,0,0,0) * captureDispatchFlip(true) * ... * </pre> */ You might think this is the actual formation with headers and the explicit command to start the commands. WRONG. There is a function called readHeader() which it validates the source script and it only scans for "count", "speed", and "start data >>". But having the type definition there shouldn't stop you. Whats more interesting is the commands, they are totally different: the names and the parameter definitions are totally different. By looking into more code, following are the accepted commands: DispatchPointer(long downTime, long eventTime, int action, float x, float y, float pressure, float size, int metaState, float xPrecision, float yPrecision, int device, int edgeFlags) DispatchTrackball (same as DispatchPointer) DispatchKey(long downTime, long eventTime, int action, int code, int repeat, int metaState, int device, int scanCode) DispatchFlip(boolean keyboardOpen) DispatchPress(int keyCode) LaunchActivity(String packageName, String className) LaunchInstrumentation(String testName, String runnerName) UserWait(long sleepTime) LongPress() //it sends ACTION_DOWN on KEYCODE_DPAD_CENTER for 2 seconds and then sends ACTION_UP for KEYCODE_DPAD_CENTER PowerLog //not important for this topic WriteLog //not important for this topic With all of this new information, I am still unable to get this working. Does anybody have ideas? Or any engineer from Google? Thanks! -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/android-developers?hl=en

