Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,23 @@ public String stopScreenRecorder(@NotNull TestRunDevice testRunDevice, @NotNull
}
}

public void releaseScreenRecorder(@NotNull TestRunDevice testRunDevice, @Nullable Logger logger) {
if (testRunDevice.getScreenRecorder() == null) {
return;
}

if (logger != null) {
logger.info("Releasing screen recorder");
}
if (testRunDevice instanceof TestRunDeviceCombo) {
((TestRunDeviceCombo) testRunDevice).getDevices().forEach(testRunDevice1 -> {
testRunDevice1.getScreenRecorder().finishRecording();
});
} else {
testRunDevice.getScreenRecorder().finishRecording();
}
}

public void startLogCollector(@NotNull TestRunDevice testRunDevice, @NotNull String pkgName, @NotNull TestRun testRun, @NotNull Logger logger) {
if (testRunDevice instanceof TestRunDeviceCombo) {
((TestRunDeviceCombo) testRunDevice).getDevices().forEach(testRunDevice1 -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,14 @@ protected void tearDown(TestRunDevice testRunDevice, TestTask testTask, TestRun
testRun.getLogger().error("Execute actions failed when tearDown!", exceptions.get(0));
}
}

try {
//TODO: if the other test run resources are not released, release them here
testRunDeviceOrchestrator.releaseScreenRecorder(testRunDevice, testRun.getLogger());
} catch (Exception e) {
testRun.getLogger().error("Error in release Screen Recorder", e);
}

testRunDeviceOrchestrator.testDeviceUnset(testRunDevice, testRun.getLogger());

//generate xml report and upload files
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ public class WindowsScreenRecorder implements ScreenRecorder {
private final File baseFolder;
private final Logger logger;
private WindowsDriver windowsDriver;
private boolean started = false;

public WindowsScreenRecorder(DeviceDriver deviceDriver, DeviceInfo deviceInfo, File baseFolder, Logger logger) {
this.deviceDriver = deviceDriver;
Expand All @@ -36,7 +37,7 @@ public void startRecord(int maxTime) {
logger.info("Start phone record screen");
logger.info("Start PC record screen");
windowsDriver.startRecordingScreen(new WindowsStartScreenRecordingOptions().withTimeLimit(Duration.ofSeconds(maxTime)));

started = true;
}

@Override
Expand All @@ -46,6 +47,10 @@ public void setupDevice() {

@Override
public String finishRecording() {
if (!started) {
return null;
}

File PCVideoFile = null;
try {
String base64String = windowsDriver.stopRecordingScreen();
Expand All @@ -59,6 +64,8 @@ public String finishRecording() {
System.out.println("-------------------------------------------------------Ignore End--------------------------------------------------------------");
}

started = false;

if (PCVideoFile == null || !PCVideoFile.exists()) {
return null;
}
Expand Down