tests-e2e: Added videoElementCreated event test

v2compatibility
Carlos Santos 2025-01-16 16:05:39 +01:00
parent 55da45c391
commit bb7deeb5a4
8 changed files with 454 additions and 356 deletions

View File

@ -72,8 +72,6 @@ import org.openqa.selenium.Dimension;
import org.openqa.selenium.Keys; import org.openqa.selenium.Keys;
import org.openqa.selenium.WebDriver; import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement; import org.openqa.selenium.WebElement;
import org.openqa.selenium.logging.LogEntries;
import org.openqa.selenium.logging.LogType;
import org.openqa.selenium.support.ui.ExpectedCondition; import org.openqa.selenium.support.ui.ExpectedCondition;
import org.openqa.selenium.support.ui.ExpectedConditions; import org.openqa.selenium.support.ui.ExpectedConditions;
import org.springframework.http.HttpMethod; import org.springframework.http.HttpMethod;
@ -89,7 +87,6 @@ import io.openvidu.java.client.Connection;
import io.openvidu.java.client.ConnectionProperties; import io.openvidu.java.client.ConnectionProperties;
import io.openvidu.java.client.ConnectionType; import io.openvidu.java.client.ConnectionType;
import io.openvidu.java.client.IceServerProperties; import io.openvidu.java.client.IceServerProperties;
import io.openvidu.java.client.KurentoOptions;
import io.openvidu.java.client.MediaMode; import io.openvidu.java.client.MediaMode;
import io.openvidu.java.client.OpenVidu; import io.openvidu.java.client.OpenVidu;
import io.openvidu.java.client.OpenViduHttpException; import io.openvidu.java.client.OpenViduHttpException;
@ -728,6 +725,41 @@ public class OpenViduTestAppE2eTest extends AbstractOpenViduTestappE2eTest {
gracefullyLeaveParticipants(user, 2); gracefullyLeaveParticipants(user, 2);
} }
@Test
@DisplayName("Receive VideoElementCreated event when subscriber initializes with target element")
void subscriberVideoElementCreatedTest() throws Exception {
OpenViduTestappUser user = setupBrowserAndConnectToOpenViduTestapp("chrome");
// Add publisher
user.getDriver().findElement(By.id("add-user-btn")).click();
user.getDriver().findElement(By.cssSelector("#openvidu-instance-0 .subscribe-checkbox")).click();
// join
user.getDriver().findElement(By.cssSelector("#openvidu-instance-0 .join-btn")).click();
// events
user.getEventManager().waitUntilEventReaches("connectionCreated", 1);
user.getEventManager().waitUntilEventReaches("accessAllowed", 1);
user.getEventManager().waitUntilEventReaches("streamCreated", 1);
user.getEventManager().waitUntilEventReaches("streamPlaying", 1);
// Add subscriber
user.getDriver().findElement(By.id("add-user-btn")).click();
user.getDriver().findElement(By.cssSelector("#openvidu-instance-1 .publish-checkbox")).click();
user.getDriver().findElement(By.id("session-settings-btn-1")).click();
user.getDriver().findElement(By.id("target-element-checkbox")).click();
user.getDriver().findElement(By.id("save-btn")).click();
user.getDriver().findElement(By.cssSelector("#openvidu-instance-1 .join-btn")).click();
user.getEventManager().waitUntilEventReaches("connectionCreated", 4);
user.getEventManager().waitUntilEventReaches("accessAllowed", 1);
user.getEventManager().waitUntilEventReaches("streamCreated", 2);
user.getEventManager().waitUntilEventReaches("streamPlaying", 2);
user.getEventManager().waitUntilEventReaches("videoElementCreated", 1);
gracefullyLeaveParticipants(user, 2);
}
@Test @Test
@DisplayName("Change publisher dynamically") @DisplayName("Change publisher dynamically")
void changePublisherTest() throws Exception { void changePublisherTest() throws Exception {

File diff suppressed because it is too large Load Diff

View File

@ -14,8 +14,8 @@
"colormap": "2.3.2", "colormap": "2.3.2",
"core-js": "3.26.1", "core-js": "3.26.1",
"json-stringify-safe": "5.0.1", "json-stringify-safe": "5.0.1",
"openvidu-browser-v2compatibility": "3.0.0-beta3", "openvidu-browser-v2compatibility": "3.0.1-beta2",
"openvidu-node-client-v2compatibility": "3.0.0-beta3", "openvidu-node-client-v2compatibility": "3.0.1-beta1",
"rxjs": "7.8.1", "rxjs": "7.8.1",
"tslib": "2.4.1", "tslib": "2.4.1",
"zone.js": "0.12.0" "zone.js": "0.12.0"

View File

@ -122,6 +122,9 @@
<mat-checkbox class="checkbox-form" [(ngModel)]="forcePublishing" id="force-publishing-checkbox">Force <mat-checkbox class="checkbox-form" [(ngModel)]="forcePublishing" id="force-publishing-checkbox">Force
publishing publishing
</mat-checkbox> </mat-checkbox>
<mat-checkbox class="checkbox-form" [(ngModel)]="targetElement" id="target-element-checkbox">Init with target
element
</mat-checkbox>
<mat-checkbox class="checkbox-form" [(ngModel)]="reconnectionOnServerFailure" id="reconnection-on-server-failure-checkbox"> <mat-checkbox class="checkbox-form" [(ngModel)]="reconnectionOnServerFailure" id="reconnection-on-server-failure-checkbox">
Reconnection on server failure Reconnection on server failure
</mat-checkbox> </mat-checkbox>
@ -135,5 +138,5 @@
<mat-dialog-actions> <mat-dialog-actions>
<button id="cancel-btn" mat-button [mat-dialog-close]="undefined">CANCEL</button> <button id="cancel-btn" mat-button [mat-dialog-close]="undefined">CANCEL</button>
<button id="save-btn" mat-button <button id="save-btn" mat-button
[mat-dialog-close]="{sessionProperties: sessionProperties, turnConf: turnConf, manualTurnConf: manualTurnConf, customToken: customToken, forcePublishing: forcePublishing, reconnectionOnServerFailure: reconnectionOnServerFailure, connectionProperties: generateConnectionProperties()}">SAVE</button> [mat-dialog-close]="{sessionProperties: sessionProperties, turnConf: turnConf, manualTurnConf: manualTurnConf, customToken: customToken, forcePublishing: forcePublishing, targetElement: targetElement, reconnectionOnServerFailure: reconnectionOnServerFailure, connectionProperties: generateConnectionProperties()}">SAVE</button>
</mat-dialog-actions> </mat-dialog-actions>

View File

@ -15,6 +15,7 @@ export class SessionPropertiesDialogComponent {
manualTurnConf: RTCIceServer = { urls: [] }; manualTurnConf: RTCIceServer = { urls: [] };
customToken: string; customToken: string;
forcePublishing: boolean; forcePublishing: boolean;
targetElement: boolean;
reconnectionOnServerFailure: boolean; reconnectionOnServerFailure: boolean;
connectionProperties: ConnectionProperties; connectionProperties: ConnectionProperties;
forceVideoCodec = VideoCodec; forceVideoCodec = VideoCodec;
@ -34,6 +35,7 @@ export class SessionPropertiesDialogComponent {
this.manualTurnConf = data.manualTurnConf; this.manualTurnConf = data.manualTurnConf;
this.customToken = data.customToken; this.customToken = data.customToken;
this.forcePublishing = data.forcePublishing; this.forcePublishing = data.forcePublishing;
this.targetElement = data.targetElement;
this.reconnectionOnServerFailure = data.reconnectionOnServerFailure; this.reconnectionOnServerFailure = data.reconnectionOnServerFailure;
this.connectionProperties = data.connectionProperties; this.connectionProperties = data.connectionProperties;
} }

View File

@ -142,6 +142,7 @@ export class OpenviduInstanceComponent implements OnInit, OnChanges, OnDestroy {
manualTurnConf: RTCIceServer = { urls: [] }; manualTurnConf: RTCIceServer = { urls: [] };
customToken: string; customToken: string;
forcePublishing: boolean = false; forcePublishing: boolean = false;
withTargetElement: boolean = false;
reconnectionOnServerFailure: boolean = false; reconnectionOnServerFailure: boolean = false;
connectionProperties: ConnectionProperties = { connectionProperties: ConnectionProperties = {
role: OpenViduRole.PUBLISHER, role: OpenViduRole.PUBLISHER,
@ -576,8 +577,12 @@ export class OpenviduInstanceComponent implements OnInit, OnChanges, OnDestroy {
} }
syncInitPublisher() { syncInitPublisher() {
let targetElement: HTMLElement = undefined;
if(this.withTargetElement){
targetElement = document.getElementsByClassName('video-container')[0] as HTMLElement;
}
this.publisher = this.OV.initPublisher( this.publisher = this.OV.initPublisher(
undefined, targetElement,
this.publisherProperties, this.publisherProperties,
err => { err => {
if (err) { if (err) {
@ -614,7 +619,13 @@ export class OpenviduInstanceComponent implements OnInit, OnChanges, OnDestroy {
} }
syncSubscribe(session: Session, event) { syncSubscribe(session: Session, event) {
this.subscribers.push(session.subscribe(event.stream, undefined)); let targetElement: HTMLElement = undefined;
if(this.withTargetElement){
targetElement = document.getElementsByClassName('video-container')[0] as HTMLElement;
}
const subscriber = session.subscribe(event.stream, targetElement);
this.subscribers.push(subscriber);
} }
openSessionPropertiesDialog() { openSessionPropertiesDialog() {
@ -626,6 +637,7 @@ export class OpenviduInstanceComponent implements OnInit, OnChanges, OnDestroy {
manualTurnConf: this.manualTurnConf, manualTurnConf: this.manualTurnConf,
customToken: this.customToken, customToken: this.customToken,
forcePublishing: this.forcePublishing, forcePublishing: this.forcePublishing,
targetElement: this.withTargetElement,
reconnectionOnServerFailure: this.reconnectionOnServerFailure, reconnectionOnServerFailure: this.reconnectionOnServerFailure,
connectionProperties: this.connectionProperties, connectionProperties: this.connectionProperties,
} }
@ -641,6 +653,7 @@ export class OpenviduInstanceComponent implements OnInit, OnChanges, OnDestroy {
this.manualTurnConf = result.manualTurnConf; this.manualTurnConf = result.manualTurnConf;
this.customToken = result.customToken; this.customToken = result.customToken;
this.forcePublishing = result.forcePublishing; this.forcePublishing = result.forcePublishing;
this.withTargetElement = result.targetElement;
this.reconnectionOnServerFailure = result.reconnectionOnServerFailure; this.reconnectionOnServerFailure = result.reconnectionOnServerFailure;
this.connectionProperties = result.connectionProperties; this.connectionProperties = result.connectionProperties;
} }

View File

@ -58,6 +58,9 @@
<button class="video-btn other-operations-btn" title="Other operations" (click)="otherOperations()"> <button class="video-btn other-operations-btn" title="Other operations" (click)="otherOperations()">
<mat-icon aria-label="Other operations" class="mat-icon material-icons" role="img" aria-hidden="true">settings</mat-icon> <mat-icon aria-label="Other operations" class="mat-icon material-icons" role="img" aria-hidden="true">settings</mat-icon>
</button> </button>
<button class="video-btn add-video-element-btn" *ngIf="!this.unpublished" title="Add Video Element" (click)="addVideoElement()">
<mat-icon aria-label="Add Video Element" class="mat-icon material-icons" role="img" aria-hidden="true">add</mat-icon>
</button>
<button class="video-btn stats-button bottom-left-rounded" title="Peer Connection Stats" (click)="showCodecUsed()"> <button class="video-btn stats-button bottom-left-rounded" title="Peer Connection Stats" (click)="showCodecUsed()">
<mat-icon aria-label="Peer Connection Stats" class="mat-icon material-icons" role="img" aria-hidden="true">info</mat-icon> <mat-icon aria-label="Peer Connection Stats" class="mat-icon material-icons" role="img" aria-hidden="true">info</mat-icon>
</button> </button>

View File

@ -836,6 +836,11 @@ export class VideoComponent implements OnInit, OnDestroy {
}); });
} }
addVideoElement() {
const sub: Subscriber = <Subscriber>this.streamManager;
sub.createVideoElement(document.getElementsByClassName('video-container')[0] as HTMLElement);
}
emitFilterEventToParent(event: FilterEvent) { emitFilterEventToParent(event: FilterEvent) {
this.updateEventListInParent.emit({ this.updateEventListInParent.emit({
eventName: 'filterEvent', eventName: 'filterEvent',