mirror of https://github.com/OpenVidu/openvidu.git
openvidu-test-e2e remote recording testing
parent
5840675637
commit
59b2f2e6c5
|
@ -22,10 +22,13 @@ import static org.slf4j.LoggerFactory.getLogger;
|
||||||
import static org.openqa.selenium.OutputType.BASE64;
|
import static org.openqa.selenium.OutputType.BASE64;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Queue;
|
||||||
|
import java.util.concurrent.ConcurrentLinkedQueue;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
import org.junit.jupiter.api.*;
|
import org.junit.jupiter.api.*;
|
||||||
|
@ -170,7 +173,7 @@ public class OpenViduTestAppE2eTest {
|
||||||
|
|
||||||
List<WebElement> l2 = user.getDriver().findElements(By.className("join-btn"));
|
List<WebElement> l2 = user.getDriver().findElements(By.className("join-btn"));
|
||||||
for (WebElement el : l2) {
|
for (WebElement el : l2) {
|
||||||
el.click();
|
el.sendKeys(Keys.ENTER);
|
||||||
}
|
}
|
||||||
|
|
||||||
user.getEventManager().waitUntilEventReaches("connectionCreated", 4);
|
user.getEventManager().waitUntilEventReaches("connectionCreated", 4);
|
||||||
|
@ -208,7 +211,7 @@ public class OpenViduTestAppE2eTest {
|
||||||
|
|
||||||
List<WebElement> l2 = user.getDriver().findElements(By.className("join-btn"));
|
List<WebElement> l2 = user.getDriver().findElements(By.className("join-btn"));
|
||||||
for (WebElement el : l2) {
|
for (WebElement el : l2) {
|
||||||
el.click();
|
el.sendKeys(Keys.ENTER);
|
||||||
}
|
}
|
||||||
|
|
||||||
user.getEventManager().waitUntilEventReaches("connectionCreated", 4);
|
user.getEventManager().waitUntilEventReaches("connectionCreated", 4);
|
||||||
|
@ -374,56 +377,6 @@ public class OpenViduTestAppE2eTest {
|
||||||
gracefullyLeaveParticipants(4);
|
gracefullyLeaveParticipants(4);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
|
||||||
@DisplayName("Secure Test")
|
|
||||||
void secureTest() throws Exception {
|
|
||||||
|
|
||||||
setupBrowser("chrome");
|
|
||||||
|
|
||||||
log.info("Secure Test");
|
|
||||||
|
|
||||||
WebElement addUser = user.getDriver().findElement(By.id("add-user-btn"));
|
|
||||||
for (int i = 0; i < 4; i++) {
|
|
||||||
addUser.click();
|
|
||||||
}
|
|
||||||
|
|
||||||
OpenVidu OV = new OpenVidu(OPENVIDU_URL, OPENVIDU_SECRET);
|
|
||||||
Session session = OV.createSession();
|
|
||||||
|
|
||||||
List<WebElement> l1 = user.getDriver().findElements(By.className("secure-session-checkbox"));
|
|
||||||
for (WebElement el : l1) {
|
|
||||||
el.click();
|
|
||||||
}
|
|
||||||
|
|
||||||
List<WebElement> l2 = user.getDriver().findElements(By.className("tokenInput"));
|
|
||||||
for (WebElement el : l2) {
|
|
||||||
String token = session.generateToken();
|
|
||||||
el.sendKeys(token);
|
|
||||||
}
|
|
||||||
|
|
||||||
List<WebElement> l3 = user.getDriver().findElements(By.className("join-btn"));
|
|
||||||
for (WebElement el : l3) {
|
|
||||||
el.sendKeys(Keys.ENTER);
|
|
||||||
}
|
|
||||||
|
|
||||||
user.getEventManager().waitUntilEventReaches("connectionCreated", 16);
|
|
||||||
user.getEventManager().waitUntilEventReaches("accessAllowed", 4);
|
|
||||||
user.getEventManager().waitUntilEventReaches("videoElementCreated", 16);
|
|
||||||
user.getEventManager().waitUntilEventReaches("streamCreated", 6);
|
|
||||||
user.getEventManager().waitUntilEventReaches("videoPlaying", 16);
|
|
||||||
|
|
||||||
try {
|
|
||||||
System.out.println(getBase64Screenshot(user));
|
|
||||||
} catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
|
|
||||||
Assert.assertTrue(user.getEventManager().assertMediaTracks(user.getDriver().findElements(By.tagName("video")),
|
|
||||||
true, true));
|
|
||||||
|
|
||||||
gracefullyLeaveParticipants(4);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@DisplayName("One2One Firefox [Video + Audio]")
|
@DisplayName("One2One Firefox [Video + Audio]")
|
||||||
void oneToOneVideoAudioSessionFirefox() throws Exception {
|
void oneToOneVideoAudioSessionFirefox() throws Exception {
|
||||||
|
@ -652,7 +605,7 @@ public class OpenViduTestAppE2eTest {
|
||||||
@DisplayName("Change publisher dynamically")
|
@DisplayName("Change publisher dynamically")
|
||||||
void changePublisherTest() throws Exception {
|
void changePublisherTest() throws Exception {
|
||||||
|
|
||||||
List<Boolean> listOfThreadAssertions = new ArrayList<>();
|
Queue<Boolean> threadAssertions = new ConcurrentLinkedQueue<Boolean>();
|
||||||
|
|
||||||
setupBrowser("chrome");
|
setupBrowser("chrome");
|
||||||
|
|
||||||
|
@ -666,12 +619,12 @@ public class OpenViduTestAppE2eTest {
|
||||||
|
|
||||||
// First publication (audio + video [CAMERA])
|
// First publication (audio + video [CAMERA])
|
||||||
user.getEventManager().on("videoPlaying", (event) -> {
|
user.getEventManager().on("videoPlaying", (event) -> {
|
||||||
listOfThreadAssertions.add(((String) event.get("eventContent")).contains("CAMERA"));
|
threadAssertions.add(((String) event.get("eventContent")).contains("CAMERA"));
|
||||||
});
|
});
|
||||||
user.getDriver().findElement(By.id("one2many-btn")).click();
|
user.getDriver().findElement(By.id("one2many-btn")).click();
|
||||||
user.getEventManager().waitUntilEventReaches("videoPlaying", 2);
|
user.getEventManager().waitUntilEventReaches("videoPlaying", 2);
|
||||||
user.getEventManager().off("videoPlaying");
|
user.getEventManager().off("videoPlaying");
|
||||||
for (Iterator<Boolean> iter = listOfThreadAssertions.iterator(); iter.hasNext();) {
|
for (Iterator<Boolean> iter = threadAssertions.iterator(); iter.hasNext();) {
|
||||||
Assert.assertTrue(iter.next());
|
Assert.assertTrue(iter.next());
|
||||||
iter.remove();
|
iter.remove();
|
||||||
}
|
}
|
||||||
|
@ -681,12 +634,12 @@ public class OpenViduTestAppE2eTest {
|
||||||
|
|
||||||
// Second publication (only video (SCREEN))
|
// Second publication (only video (SCREEN))
|
||||||
user.getEventManager().on("videoPlaying", (event) -> {
|
user.getEventManager().on("videoPlaying", (event) -> {
|
||||||
listOfThreadAssertions.add(((String) event.get("eventContent")).contains("SCREEN"));
|
threadAssertions.add(((String) event.get("eventContent")).contains("SCREEN"));
|
||||||
});
|
});
|
||||||
user.getDriver().findElements(By.className("change-publisher-btn")).get(0).click();
|
user.getDriver().findElements(By.className("change-publisher-btn")).get(0).click();
|
||||||
user.getEventManager().waitUntilEventReaches("videoPlaying", 4);
|
user.getEventManager().waitUntilEventReaches("videoPlaying", 4);
|
||||||
user.getEventManager().off("videoPlaying");
|
user.getEventManager().off("videoPlaying");
|
||||||
for (Iterator<Boolean> iter = listOfThreadAssertions.iterator(); iter.hasNext();) {
|
for (Iterator<Boolean> iter = threadAssertions.iterator(); iter.hasNext();) {
|
||||||
Assert.assertTrue(iter.next());
|
Assert.assertTrue(iter.next());
|
||||||
iter.remove();
|
iter.remove();
|
||||||
}
|
}
|
||||||
|
@ -696,12 +649,12 @@ public class OpenViduTestAppE2eTest {
|
||||||
|
|
||||||
// Third publication (audio + video [CAMERA])
|
// Third publication (audio + video [CAMERA])
|
||||||
user.getEventManager().on("videoPlaying", (event) -> {
|
user.getEventManager().on("videoPlaying", (event) -> {
|
||||||
listOfThreadAssertions.add(((String) event.get("eventContent")).contains("CAMERA"));
|
threadAssertions.add(((String) event.get("eventContent")).contains("CAMERA"));
|
||||||
});
|
});
|
||||||
user.getDriver().findElements(By.className("change-publisher-btn")).get(0).click();
|
user.getDriver().findElements(By.className("change-publisher-btn")).get(0).click();
|
||||||
user.getEventManager().waitUntilEventReaches("videoPlaying", 6);
|
user.getEventManager().waitUntilEventReaches("videoPlaying", 6);
|
||||||
user.getEventManager().off("videoPlaying");
|
user.getEventManager().off("videoPlaying");
|
||||||
for (Iterator<Boolean> iter = listOfThreadAssertions.iterator(); iter.hasNext();) {
|
for (Iterator<Boolean> iter = threadAssertions.iterator(); iter.hasNext();) {
|
||||||
Assert.assertTrue(iter.next());
|
Assert.assertTrue(iter.next());
|
||||||
iter.remove();
|
iter.remove();
|
||||||
}
|
}
|
||||||
|
@ -761,13 +714,78 @@ public class OpenViduTestAppE2eTest {
|
||||||
gracefullyLeaveParticipants(1);
|
gracefullyLeaveParticipants(1);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@DisplayName("Remote record")
|
||||||
|
void remoteRecordTest() throws Exception {
|
||||||
|
setupBrowser("chrome");
|
||||||
|
|
||||||
|
log.info("Remote record");
|
||||||
|
|
||||||
|
final String sessionName = "RECORDED_SESSION";
|
||||||
|
|
||||||
|
user.getDriver().findElement(By.id("add-user-btn")).click();
|
||||||
|
user.getDriver().findElement(By.id("session-name-input")).clear();
|
||||||
|
user.getDriver().findElement(By.id("session-name-input")).sendKeys(sessionName);
|
||||||
|
|
||||||
|
// Try to record a non-existing session
|
||||||
|
user.getDriver().findElement(By.id("session-api-btn")).click();
|
||||||
|
Thread.sleep(1000);
|
||||||
|
user.getDriver().findElement(By.id("start-recording-btn")).click();
|
||||||
|
user.getWaiter().until(ExpectedConditions.attributeToBe(By.id("api-response-text-area"), "value", "Error [404]"));
|
||||||
|
user.getDriver().findElement(By.id("close-dialog-btn")).click();
|
||||||
|
Thread.sleep(1000);
|
||||||
|
|
||||||
|
// Join the user to the session
|
||||||
|
user.getDriver().findElement(By.className("join-btn")).click();
|
||||||
|
|
||||||
|
user.getEventManager().waitUntilEventReaches("connectionCreated", 1);
|
||||||
|
user.getEventManager().waitUntilEventReaches("accessAllowed", 1);
|
||||||
|
user.getEventManager().waitUntilEventReaches("videoElementCreated", 1);
|
||||||
|
user.getEventManager().waitUntilEventReaches("videoPlaying", 1);
|
||||||
|
|
||||||
|
Assert.assertTrue(user.getEventManager().assertMediaTracks(user.getDriver().findElements(By.tagName("video")),
|
||||||
|
true, true));
|
||||||
|
|
||||||
|
user.getDriver().findElement(By.id("session-api-btn")).click();
|
||||||
|
Thread.sleep(1000);
|
||||||
|
user.getDriver().findElement(By.id("start-recording-btn")).click();
|
||||||
|
user.getWaiter().until(ExpectedConditions.attributeToBe(By.id("api-response-text-area"), "value", "Recording started [" + sessionName + "]"));
|
||||||
|
|
||||||
|
user.getEventManager().waitUntilEventReaches("recordingStarted", 1);
|
||||||
|
|
||||||
|
user.getDriver().findElement(By.id("recording-id-field")).clear();
|
||||||
|
user.getDriver().findElement(By.id("recording-id-field")).sendKeys(sessionName);
|
||||||
|
user.getDriver().findElement(By.id("stop-recording-btn")).click();
|
||||||
|
user.getWaiter().until(ExpectedConditions.attributeToBe(By.id("api-response-text-area"), "value", "Recording stopped [" + sessionName + "]"));
|
||||||
|
|
||||||
|
user.getEventManager().waitUntilEventReaches("recordingStopped", 1);
|
||||||
|
|
||||||
|
File file1 = new File("/opt/openvidu/recordings/" + sessionName + ".mp4");
|
||||||
|
File file2 = new File("/opt/openvidu/recordings/.recording." + sessionName);
|
||||||
|
File file3 = new File("/opt/openvidu/recordings/" + sessionName + ".info");
|
||||||
|
|
||||||
|
Assert.assertFalse(!file1.exists() || file1.length() == 0);
|
||||||
|
Assert.assertFalse(!file2.exists() || file2.length() == 0);
|
||||||
|
Assert.assertFalse(!file3.exists() || file3.length() == 0);
|
||||||
|
|
||||||
|
user.getDriver().findElement(By.id("delete-recording-btn")).click();
|
||||||
|
user.getWaiter().until(ExpectedConditions.attributeToBe(By.id("api-response-text-area"), "value", "Recording deleted"));
|
||||||
|
|
||||||
|
Assert.assertFalse(file1.exists());
|
||||||
|
Assert.assertFalse(file2.exists());
|
||||||
|
Assert.assertFalse(file3.exists());
|
||||||
|
|
||||||
|
user.getDriver().findElement(By.id("close-dialog-btn")).click();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
private ExpectedCondition<Boolean> waitForVideoDuration(WebElement element, int durationInSeconds) {
|
private ExpectedCondition<Boolean> waitForVideoDuration(WebElement element, int durationInSeconds) {
|
||||||
return new ExpectedCondition<Boolean>() {
|
return new ExpectedCondition<Boolean>() {
|
||||||
@Override
|
@Override
|
||||||
public Boolean apply(WebDriver input) {
|
public Boolean apply(WebDriver input) {
|
||||||
return element.getAttribute("duration")
|
return element.getAttribute("duration")
|
||||||
.matches(durationInSeconds - 1 + "\\.9[0-9]{0,5}|" + durationInSeconds + "\\.[0-1][0-9]{0,5}");
|
.matches(durationInSeconds - 1 + "\\.[8-9][0-9]{0,5}|" + durationInSeconds + "\\.[0-2][0-9]{0,5}");
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,21 +10,21 @@ import { OpenVidu as OpenViduAPI } from 'openvidu-node-client';
|
||||||
<div>
|
<div>
|
||||||
<h2 mat-dialog-title>API REST</h2>
|
<h2 mat-dialog-title>API REST</h2>
|
||||||
<mat-dialog-content>
|
<mat-dialog-content>
|
||||||
<button mat-button (click)="startRecording()">Start recording</button>
|
<button mat-button id="start-recording-btn" (click)="startRecording()">Start recording</button>
|
||||||
<button mat-button (click)="listRecordings()">List recordings</button>
|
<button mat-button id="list-recording-btn" (click)="listRecordings()">List recordings</button>
|
||||||
<mat-divider></mat-divider>
|
<mat-divider></mat-divider>
|
||||||
<mat-form-field>
|
<mat-form-field>
|
||||||
<input matInput placeholder="recordingId" [(ngModel)]="recordingId">
|
<input matInput id="recording-id-field" placeholder="recordingId" [(ngModel)]="recordingId">
|
||||||
</mat-form-field>
|
</mat-form-field>
|
||||||
<button mat-button (click)="stopRecording()" [disabled]="!recordingId">Stop recording</button>
|
<button mat-button id="stop-recording-btn" (click)="stopRecording()" [disabled]="!recordingId">Stop recording</button>
|
||||||
<button mat-button (click)="getRecording()" [disabled]="!recordingId">Get recording</button>
|
<button mat-button id="get-recording-btn" (click)="getRecording()" [disabled]="!recordingId">Get recording</button>
|
||||||
<button mat-button (click)="deleteRecording()" [disabled]="!recordingId">Delete recording</button>
|
<button mat-button id="delete-recording-btn" (click)="deleteRecording()" [disabled]="!recordingId">Delete recording</button>
|
||||||
<mat-form-field *ngIf="!!response" id="response-text-area">
|
<mat-form-field *ngIf="!!response" id="response-text-area">
|
||||||
<textarea [(ngModel)]="response" matInput readonly></textarea>
|
<textarea id="api-response-text-area" [(ngModel)]="response" matInput readonly></textarea>
|
||||||
</mat-form-field>
|
</mat-form-field>
|
||||||
</mat-dialog-content>
|
</mat-dialog-content>
|
||||||
<mat-dialog-actions>
|
<mat-dialog-actions>
|
||||||
<button mat-button [mat-dialog-close]="undefined">CLOSE</button>
|
<button mat-button id="close-dialog-btn" [mat-dialog-close]="undefined">CLOSE</button>
|
||||||
</mat-dialog-actions>
|
</mat-dialog-actions>
|
||||||
</div>
|
</div>
|
||||||
`,
|
`,
|
||||||
|
|
|
@ -8,11 +8,11 @@
|
||||||
|
|
||||||
<div fxLayout="row">
|
<div fxLayout="row">
|
||||||
<mat-form-field style="margin-right: 10px">
|
<mat-form-field style="margin-right: 10px">
|
||||||
<input matInput placeholder="Session name" name="sessionName" [(ngModel)]="sessionName" [disabled]="session">
|
<input matInput placeholder="Session name" id="session-name-input" name="sessionName" [(ngModel)]="sessionName" [disabled]="session">
|
||||||
</mat-form-field>
|
</mat-form-field>
|
||||||
|
|
||||||
<mat-form-field>
|
<mat-form-field>
|
||||||
<input matInput placeholder="Client data" name="clientData" [(ngModel)]="clientData" [disabled]="session">
|
<input matInput placeholder="Client data" id="client-data-input" name="clientData" [(ngModel)]="clientData" [disabled]="session">
|
||||||
</mat-form-field>
|
</mat-form-field>
|
||||||
|
|
||||||
<div fxLayout="column" class="session-btns-div">
|
<div fxLayout="column" class="session-btns-div">
|
||||||
|
|
Loading…
Reference in New Issue