Android tests: finish all processes

This commit is contained in:
Natalia.Ukhorskaya
2012-12-17 17:04:07 +04:00
parent 1824879dd0
commit fcc3a4d0ab
3 changed files with 30 additions and 20 deletions
@@ -190,23 +190,29 @@ public class CodegenTestsOnAndroidRunner {
antRunner.packLibraries(); antRunner.packLibraries();
emulator.createEmulator();
emulator.startEmulator();
try { try {
emulator.waitEmulatorStart(); emulator.createEmulator();
antRunner.cleanOutput(); emulator.startEmulator();
antRunner.compileSources();
antRunner.installApplicationOnEmulator(); try {
return antRunner.runTestsOnEmulator(); emulator.waitEmulatorStart();
antRunner.cleanOutput();
antRunner.compileSources();
antRunner.installApplicationOnEmulator();
return antRunner.runTestsOnEmulator();
}
finally {
try {
emulator.stopEmulator();
}
catch (Throwable t) {
System.err.println("Exception during stopping emulator:");
t.printStackTrace();
}
}
} }
finally { finally {
try { emulator.finishEmulatorProcesses();
emulator.stopEmulator();
}
catch (Throwable t) {
System.err.println("Exception during stopping emulator:");
t.printStackTrace();
}
} }
} }
@@ -110,7 +110,6 @@ public class Emulator {
public void startEmulator() { public void startEmulator() {
System.out.println("Starting emulator..."); System.out.println("Starting emulator...");
stopRedundantEmulators(pathManager);
OutputUtils.checkResult(RunUtils.executeOnSeparateThread(getStartCommand(), false)); OutputUtils.checkResult(RunUtils.executeOnSeparateThread(getStartCommand(), false));
} }
@@ -123,12 +122,8 @@ public class Emulator {
public void stopEmulator() { public void stopEmulator() {
System.out.println("Stopping emulator..."); System.out.println("Stopping emulator...");
OutputUtils.checkResult(RunUtils.execute(getStopCommand())); OutputUtils.checkResult(RunUtils.execute(getStopCommand()));
System.out.println("Stopping adb...");
OutputUtils.checkResult(RunUtils.execute(getStopCommandForAdb()));
if (SystemInfo.isUnix) { if (SystemInfo.isUnix) {
finishProcess("emulator-arm"); finishProcess("emulator-arm");
finishProcess("adb");
stopDdmsProcess();
} }
} }
@@ -149,6 +144,15 @@ public class Emulator {
} }
} }
public void finishEmulatorProcesses() {
System.out.println("Stopping adb...");
OutputUtils.checkResult(RunUtils.execute(getStopCommandForAdb()));
if (SystemInfo.isUnix) {
finishProcess("adb");
stopDdmsProcess();
}
}
//Only for Unix //Only for Unix
private void finishProcess(String processName) { private void finishProcess(String processName) {
GeneralCommandLine pidOfProcess = new GeneralCommandLine(); GeneralCommandLine pidOfProcess = new GeneralCommandLine();
@@ -70,7 +70,7 @@ public class RunUtils {
if (waitForEnd) { if (waitForEnd) {
try { try {
t.wait(300000); t.wait(600000);
return resultRef.get(); return resultRef.get();
} }
catch (InterruptedException e) { catch (InterruptedException e) {