Update the monkeyrunner to use the new DDMlib API.

Change-Id: I0c1e17b450e264ca1e7d98523bde4ddfe1d97252
This commit is contained in:
Xavier Ducrohet
2010-07-21 16:50:22 -07:00
parent ecd4a4d09c
commit 235a95ae49

View File

@@ -16,11 +16,14 @@
package com.android.monkeyrunner; package com.android.monkeyrunner;
import com.android.ddmlib.AdbCommandRejectedException;
import com.android.ddmlib.AndroidDebugBridge; import com.android.ddmlib.AndroidDebugBridge;
import com.android.ddmlib.IDevice; import com.android.ddmlib.IDevice;
import com.android.ddmlib.Log; import com.android.ddmlib.Log;
import com.android.ddmlib.NullOutputReceiver; import com.android.ddmlib.NullOutputReceiver;
import com.android.ddmlib.RawImage; import com.android.ddmlib.RawImage;
import com.android.ddmlib.ShellCommandUnresponsiveException;
import com.android.ddmlib.TimeoutException;
import com.android.ddmlib.Log.ILogOutput; import com.android.ddmlib.Log.ILogOutput;
import com.android.ddmlib.Log.LogLevel; import com.android.ddmlib.Log.LogLevel;
@@ -176,6 +179,12 @@ public class MonkeyRunner {
String command = "monkey --port " + monkeyPort; String command = "monkey --port " + monkeyPort;
monkeyDevice.executeShellCommand(command, new NullOutputReceiver()); monkeyDevice.executeShellCommand(command, new NullOutputReceiver());
} catch(TimeoutException e) {
e.printStackTrace();
} catch (AdbCommandRejectedException e) {
e.printStackTrace();
} catch (ShellCommandUnresponsiveException e) {
e.printStackTrace();
} catch(IOException e) { } catch(IOException e) {
e.printStackTrace(); e.printStackTrace();
} }
@@ -245,7 +254,8 @@ public class MonkeyRunner {
* *
* @param name The name of the activity to launch * @param name The name of the activity to launch
*/ */
public static void launch_activity(String name) throws IOException { public static void launch_activity(String name) throws IOException,
TimeoutException, AdbCommandRejectedException, ShellCommandUnresponsiveException {
System.out.println("Launching: " + name); System.out.println("Launching: " + name);
recordCommand("Launching: " + name); recordCommand("Launching: " + name);
monkeyDevice.executeShellCommand("am start -a android.intent.action.MAIN -n " monkeyDevice.executeShellCommand("am start -a android.intent.action.MAIN -n "
@@ -565,6 +575,14 @@ public class MonkeyRunner {
recordResponse("No frame buffer", ""); recordResponse("No frame buffer", "");
printAndExit("Unable to get frame buffer: " + ioe.getMessage(), true /* terminate */); printAndExit("Unable to get frame buffer: " + ioe.getMessage(), true /* terminate */);
return; return;
} catch (TimeoutException toe) {
recordResponse("No frame buffer", "");
printAndExit("Unable to get frame buffer: timeout", true /* terminate */);
return;
} catch (AdbCommandRejectedException acre) {
recordResponse("No frame buffer", "");
printAndExit("Unable to get frame buffer: " + acre.getMessage(), true /* terminate */);
return;
} }
// device/adb not available? // device/adb not available?