Also handle TimeoutException in ADT test runner.
Change-Id: I585c2818f1c77ec80222bad282ae10b3ee8f5e1c
package com.android.ddmlib.testrunner;
+import com.android.ddmlib.IDevice;
import com.android.ddmlib.TimeoutException;
import java.io.IOException;
public void setCoverage(boolean coverage);
/**
+ * Sets the timeout to use for the adb shell command issued.
+ * <p/>
+ * By default no timeout will be specified.
+ *
+ * @see {@link IDevice#executeShellCommand(String, com.android.ddmlib.IShellOutputReceiver, int)}
+ */
+ public void setTimeout(int timeout);
+
+ /**
* Execute this test run.
* <p/>
* Convenience method for {@link #run(Collection)}.
private final String mPackageName;
private final String mRunnerName;
private IDevice mRemoteDevice;
+ // default to no timeout
+ private int mAdbTimeout = 0;
+
/** map of name-value instrumentation argument pairs */
private Map<String, String> mArgMap;
private InstrumentationResultParser mParser;
/**
* {@inheritDoc}
*/
+ public void setTimeout(int timeout) {
+ mAdbTimeout = timeout;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
public void run(ITestRunListener... listeners) throws IOException, TimeoutException {
run(Arrays.asList(listeners));
}
mRemoteDevice.getSerialNumber()));
mParser = new InstrumentationResultParser(listeners);
- mRemoteDevice.executeShellCommand(runCaseCommandStr, mParser);
+ mRemoteDevice.executeShellCommand(runCaseCommandStr, mParser, mAdbTimeout);
}
/**
public static String RemoteAdtTestRunner_RunFailedMsg_s;
public static String RemoteAdtTestRunner_RunIOException_s;
+ public static String RemoteAdtTestRunner_RunTimeoutException;
public static String RemoteAdtTestRunner_RunStoppedMsg;
static {
package com.android.ide.eclipse.adt.internal.launch.junit.runtime;
+import com.android.ddmlib.TimeoutException;
import com.android.ddmlib.testrunner.ITestRunListener;
import com.android.ddmlib.testrunner.RemoteAndroidTestRunner;
import com.android.ddmlib.testrunner.TestIdentifier;
}
AdtPlugin.printToConsole(mLaunchInfo.getProject(), "Running tests...");
runner.run(new TestRunListener());
+ } catch (TimeoutException e) {
+ reportError(LaunchMessages.RemoteAdtTestRunner_RunTimeoutException);
} catch (IOException e) {
reportError(String.format(LaunchMessages.RemoteAdtTestRunner_RunIOException_s,
e.getMessage()));
InstrValidator_WrongRunnerTypeMsg_s=The instrumentation runner must be of type %1$s
RemoteAdtTestRunner_RunCompleteMsg=Test run complete
RemoteAdtTestRunner_RunFailedMsg_s=Test run failed: %1$s
-RemoteAdtTestRunner_RunIOException_s=Test run failed. Lost connection with device: %s
+RemoteAdtTestRunner_RunTimeoutException=Connection with device timed out.
+RemoteAdtTestRunner_RunIOException_s=Lost connection with device: %s
RemoteAdtTestRunner_RunStoppedMsg=Test run stopped