mirror of https://github.com/OpenVidu/openvidu.git
openvidu-test-e2e: assertions failure messages improved
parent
85204cb743
commit
c332612b7d
|
@ -532,7 +532,14 @@ export class Session implements EventDispatcher {
|
|||
}
|
||||
|
||||
signalMessage['data'] = signal.data ? signal.data : '';
|
||||
signalMessage['type'] = signal.type ? signal.type : '';
|
||||
|
||||
let typeAux: string = signal.type ? signal.type : 'signal';
|
||||
if (!!typeAux) {
|
||||
if (typeAux.substring(0, 7) !== 'signal:') {
|
||||
typeAux = 'signal:' + typeAux;
|
||||
}
|
||||
}
|
||||
signalMessage['type'] = typeAux;
|
||||
|
||||
this.openvidu.sendRequest('sendMessage', {
|
||||
message: JSON.stringify(signalMessage)
|
||||
|
@ -776,7 +783,9 @@ export class Session implements EventDispatcher {
|
|||
|
||||
.then(connection => {
|
||||
this.ee.emitEvent('signal', [new SignalEvent(this, msg.type, msg.data, connection)]);
|
||||
this.ee.emitEvent('signal:' + msg.type, [new SignalEvent(this, msg.type, msg.data, connection)]);
|
||||
if (msg.type !== 'signal') {
|
||||
this.ee.emitEvent(msg.type, [new SignalEvent(this, msg.type, msg.data, connection)]);
|
||||
}
|
||||
})
|
||||
.catch(openViduError => {
|
||||
console.error(openViduError);
|
||||
|
|
|
@ -37,7 +37,10 @@ export abstract class Event {
|
|||
*/
|
||||
type: string;
|
||||
|
||||
private hasBeenPrevented = false;
|
||||
/**
|
||||
* @hidden
|
||||
*/
|
||||
hasBeenPrevented = false;
|
||||
|
||||
/**
|
||||
* @hidden
|
||||
|
@ -75,6 +78,9 @@ export abstract class Event {
|
|||
this.hasBeenPrevented = true;
|
||||
}
|
||||
|
||||
protected abstract callDefaultBehavior();
|
||||
/**
|
||||
* @hidden
|
||||
*/
|
||||
abstract callDefaultBehavior();
|
||||
|
||||
}
|
|
@ -18,6 +18,7 @@
|
|||
package io.openvidu.test.e2e;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Queue;
|
||||
|
@ -32,15 +33,15 @@ import java.util.concurrent.atomic.AtomicBoolean;
|
|||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
import org.json.simple.JSONObject;
|
||||
import org.json.simple.parser.JSONParser;
|
||||
import org.json.simple.parser.ParseException;
|
||||
import org.openqa.selenium.JavascriptExecutor;
|
||||
import org.openqa.selenium.WebDriver;
|
||||
import org.openqa.selenium.WebElement;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.JsonParser;
|
||||
|
||||
/**
|
||||
* Manager event class for BrowserUser. Collects, cleans and stores events from
|
||||
* openvidu-testapp
|
||||
|
@ -49,19 +50,19 @@ import org.slf4j.LoggerFactory;
|
|||
* @since 1.1.1
|
||||
*/
|
||||
public class OpenViduEventManager {
|
||||
|
||||
|
||||
private static final Logger log = LoggerFactory.getLogger(OpenViduEventManager.class);
|
||||
|
||||
private static class RunnableCallback implements Runnable {
|
||||
|
||||
private final Consumer<JSONObject> callback;
|
||||
private JSONObject eventResult;
|
||||
private final Consumer<JsonObject> callback;
|
||||
private JsonObject eventResult;
|
||||
|
||||
public RunnableCallback(Consumer<JSONObject> callback) {
|
||||
public RunnableCallback(Consumer<JsonObject> callback) {
|
||||
this.callback = callback;
|
||||
}
|
||||
|
||||
public void setEventResult(JSONObject json) {
|
||||
public void setEventResult(JsonObject json) {
|
||||
this.eventResult = json;
|
||||
}
|
||||
|
||||
|
@ -74,7 +75,7 @@ public class OpenViduEventManager {
|
|||
private Thread pollingThread;
|
||||
private ExecutorService execService = Executors.newCachedThreadPool();
|
||||
private WebDriver driver;
|
||||
private Queue<JSONObject> eventQueue;
|
||||
private Queue<JsonObject> eventQueue;
|
||||
private Map<String, Collection<RunnableCallback>> eventCallbacks;
|
||||
private Map<String, AtomicInteger> eventNumbers;
|
||||
private Map<String, CountDownLatch> eventCountdowns;
|
||||
|
@ -83,7 +84,7 @@ public class OpenViduEventManager {
|
|||
|
||||
public OpenViduEventManager(WebDriver driver, int timeOfWaitInSeconds) {
|
||||
this.driver = driver;
|
||||
this.eventQueue = new ConcurrentLinkedQueue<JSONObject>();
|
||||
this.eventQueue = new ConcurrentLinkedQueue<JsonObject>();
|
||||
this.eventCallbacks = new ConcurrentHashMap<>();
|
||||
this.eventNumbers = new ConcurrentHashMap<>();
|
||||
this.eventCountdowns = new ConcurrentHashMap<>();
|
||||
|
@ -104,6 +105,11 @@ public class OpenViduEventManager {
|
|||
while (!this.isInterrupted.get()) {
|
||||
this.getEventsFromBrowser();
|
||||
this.emitEvents();
|
||||
try {
|
||||
Thread.sleep(25);
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
});
|
||||
this.pollingThread.setUncaughtExceptionHandler(h);
|
||||
|
@ -118,7 +124,7 @@ public class OpenViduEventManager {
|
|||
this.pollingThread.interrupt();
|
||||
}
|
||||
|
||||
public void on(String eventName, Consumer<JSONObject> callback) {
|
||||
public void on(String eventName, Consumer<JsonObject> callback) {
|
||||
this.eventCallbacks.putIfAbsent(eventName, new HashSet<>());
|
||||
this.eventCallbacks.get(eventName).add(new RunnableCallback(callback));
|
||||
}
|
||||
|
@ -149,12 +155,30 @@ public class OpenViduEventManager {
|
|||
}
|
||||
}
|
||||
|
||||
public boolean assertMediaTracks(WebElement videoElement, boolean audioTransmission, boolean videoTransmission,
|
||||
String parentSelector) {
|
||||
return this.assertMediaTracks(Collections.singleton(videoElement), audioTransmission, videoTransmission,
|
||||
parentSelector);
|
||||
}
|
||||
|
||||
public boolean assertMediaTracks(Iterable<WebElement> videoElements, boolean audioTransmission,
|
||||
boolean videoTransmission) {
|
||||
boolean success = true;
|
||||
for (WebElement video : videoElements) {
|
||||
success = success && (audioTransmission == this.hasAudioTracks(video))
|
||||
&& (videoTransmission == this.hasVideoTracks(video));
|
||||
success = success && (audioTransmission == this.hasAudioTracks(video, ""))
|
||||
&& (videoTransmission == this.hasVideoTracks(video, ""));
|
||||
if (!success)
|
||||
break;
|
||||
}
|
||||
return success;
|
||||
}
|
||||
|
||||
public boolean assertMediaTracks(Iterable<WebElement> videoElements, boolean audioTransmission,
|
||||
boolean videoTransmission, String parentSelector) {
|
||||
boolean success = true;
|
||||
for (WebElement video : videoElements) {
|
||||
success = success && (audioTransmission == this.hasAudioTracks(video, parentSelector))
|
||||
&& (videoTransmission == this.hasVideoTracks(video, parentSelector));
|
||||
if (!success)
|
||||
break;
|
||||
}
|
||||
|
@ -174,12 +198,13 @@ public class OpenViduEventManager {
|
|||
|
||||
private void emitEvents() {
|
||||
while (!this.eventQueue.isEmpty()) {
|
||||
JSONObject event = this.eventQueue.poll();
|
||||
JsonObject event = this.eventQueue.poll();
|
||||
final String eventType = event.get("type").getAsString();
|
||||
|
||||
log.info(event.get("event") + ": " + event);
|
||||
log.info(eventType + ": " + event);
|
||||
|
||||
if (this.eventCallbacks.containsKey(event.get("event"))) {
|
||||
for (RunnableCallback callback : this.eventCallbacks.get(event.get("event"))) {
|
||||
if (this.eventCallbacks.containsKey(eventType)) {
|
||||
for (RunnableCallback callback : this.eventCallbacks.get(eventType)) {
|
||||
callback.setEventResult(event);
|
||||
execService.submit(callback);
|
||||
}
|
||||
|
@ -195,20 +220,16 @@ public class OpenViduEventManager {
|
|||
}
|
||||
|
||||
String[] events = rawEvents.replaceFirst("^<br>", "").split("<br>");
|
||||
JSONParser parser = new JSONParser();
|
||||
JsonParser parser = new JsonParser();
|
||||
for (String e : events) {
|
||||
try {
|
||||
JSONObject event = (JSONObject) parser.parse(e);
|
||||
String eventName = (String) event.get("event");
|
||||
JsonObject event = (JsonObject) parser.parse(e);
|
||||
final String eventType = event.get("type").getAsString();
|
||||
|
||||
this.eventQueue.add(event);
|
||||
getNumEvents(eventName).incrementAndGet();
|
||||
this.eventQueue.add(event);
|
||||
getNumEvents(eventType).incrementAndGet();
|
||||
|
||||
if (this.eventCountdowns.get(eventName) != null) {
|
||||
this.eventCountdowns.get(eventName).countDown();
|
||||
}
|
||||
} catch (ParseException exc) {
|
||||
exc.printStackTrace();
|
||||
if (this.eventCountdowns.get(eventType) != null) {
|
||||
this.eventCountdowns.get(eventType).countDown();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -219,62 +240,40 @@ public class OpenViduEventManager {
|
|||
return events;
|
||||
}
|
||||
|
||||
public boolean hasMediaStream(WebElement videoElement) {
|
||||
public boolean hasMediaStream(WebElement videoElement, String parentSelector) {
|
||||
boolean hasMediaStream = (boolean) ((JavascriptExecutor) driver).executeScript(
|
||||
"return (!!(document.getElementById('" + videoElement.getAttribute("id") + "').srcObject))");
|
||||
"return (!!(document.querySelector('" + parentSelector + (parentSelector.isEmpty() ? "" : " ") + "#"
|
||||
+ videoElement.getAttribute("id") + "').srcObject))");
|
||||
return hasMediaStream;
|
||||
}
|
||||
|
||||
public Map<String, Long> getAverageRgbFromVideo(WebElement videoElement) {
|
||||
String script = "var callback = arguments[arguments.length - 1];" +
|
||||
"var video = document.getElementById('" + videoElement.getAttribute("id") + "');" +
|
||||
"var canvas = document.createElement('canvas');" +
|
||||
"canvas.height = video.videoHeight;" +
|
||||
"canvas.width = video.videoWidth;" +
|
||||
"var context = canvas.getContext('2d');" +
|
||||
"context.drawImage(video, 0, 0, canvas.width, canvas.height);" +
|
||||
"var imgEl = document.createElement('img');" +
|
||||
"imgEl.src = canvas.toDataURL();" +
|
||||
"var blockSize = 5;" +
|
||||
"var defaultRGB = { r: 0, g: 0, b: 0 };" +
|
||||
"context.drawImage(video, 0, 0, 220, 150);" +
|
||||
"var dataURL = canvas.toDataURL();" +
|
||||
"imgEl.onload = function () {" +
|
||||
"let i = -4;" +
|
||||
"var rgb = { r: 0, g: 0, b: 0 };" +
|
||||
"let count = 0;" +
|
||||
"if (!context) {" +
|
||||
" return defaultRGB;" +
|
||||
"}" +
|
||||
String script = "var callback = arguments[arguments.length - 1];" + "var video = document.getElementById('"
|
||||
+ videoElement.getAttribute("id") + "');" + "var canvas = document.createElement('canvas');"
|
||||
+ "canvas.height = video.videoHeight;" + "canvas.width = video.videoWidth;"
|
||||
+ "var context = canvas.getContext('2d');"
|
||||
+ "context.drawImage(video, 0, 0, canvas.width, canvas.height);"
|
||||
+ "var imgEl = document.createElement('img');" + "imgEl.src = canvas.toDataURL();"
|
||||
+ "var blockSize = 5;" + "var defaultRGB = { r: 0, g: 0, b: 0 };"
|
||||
+ "context.drawImage(video, 0, 0, 220, 150);" + "var dataURL = canvas.toDataURL();"
|
||||
+ "imgEl.onload = function () {" + "let i = -4;" + "var rgb = { r: 0, g: 0, b: 0 };" + "let count = 0;"
|
||||
+ "if (!context) {" + " return defaultRGB;" + "}" +
|
||||
|
||||
"var height = canvas.height = imgEl.naturalHeight || imgEl.offsetHeight || imgEl.height;" +
|
||||
"var width = canvas.width = imgEl.naturalWidth || imgEl.offsetWidth || imgEl.width;" +
|
||||
"let data;" +
|
||||
"context.drawImage(imgEl, 0, 0);" +
|
||||
"var height = canvas.height = imgEl.naturalHeight || imgEl.offsetHeight || imgEl.height;"
|
||||
+ "var width = canvas.width = imgEl.naturalWidth || imgEl.offsetWidth || imgEl.width;" + "let data;"
|
||||
+ "context.drawImage(imgEl, 0, 0);" +
|
||||
|
||||
"try {" +
|
||||
"data = context.getImageData(0, 0, width, height);" +
|
||||
"} catch (e) {" +
|
||||
"return defaultRGB;" +
|
||||
"}" +
|
||||
"try {" + "data = context.getImageData(0, 0, width, height);" + "} catch (e) {" + "return defaultRGB;"
|
||||
+ "}" +
|
||||
|
||||
"length = data.data.length;" +
|
||||
"while ((i += blockSize * 4) < length) {" +
|
||||
"++count;" +
|
||||
"rgb.r += data.data[i];" +
|
||||
"rgb.g += data.data[i + 1];" +
|
||||
"rgb.b += data.data[i + 2];" +
|
||||
"}" +
|
||||
"length = data.data.length;" + "while ((i += blockSize * 4) < length) {" + "++count;"
|
||||
+ "rgb.r += data.data[i];" + "rgb.g += data.data[i + 1];" + "rgb.b += data.data[i + 2];" + "}" +
|
||||
|
||||
"rgb.r = ~~(rgb.r / count);" +
|
||||
"rgb.g = ~~(rgb.g / count);" +
|
||||
"rgb.b = ~~(rgb.b / count);" +
|
||||
"rgb.r = ~~(rgb.r / count);" + "rgb.g = ~~(rgb.g / count);" + "rgb.b = ~~(rgb.b / count);" +
|
||||
|
||||
"console.warn(rgb);" +
|
||||
"callback(rgb);" +
|
||||
"};";
|
||||
"console.warn(rgb);" + "callback(rgb);" + "};";
|
||||
Object averageRgb = ((JavascriptExecutor) driver).executeAsyncScript(script);
|
||||
return (Map<String, Long>)averageRgb;
|
||||
return (Map<String, Long>) averageRgb;
|
||||
}
|
||||
|
||||
public String getDimensionOfViewport() {
|
||||
|
@ -283,18 +282,20 @@ public class OpenViduEventManager {
|
|||
return dimension;
|
||||
}
|
||||
|
||||
private boolean hasAudioTracks(WebElement videoElement) {
|
||||
boolean audioTracks = (boolean) ((JavascriptExecutor) driver)
|
||||
.executeScript("return ((document.getElementById('" + videoElement.getAttribute("id")
|
||||
+ "').srcObject.getAudioTracks().length > 0)" + "&& (document.getElementById('"
|
||||
private boolean hasAudioTracks(WebElement videoElement, String parentSelector) {
|
||||
boolean audioTracks = (boolean) ((JavascriptExecutor) driver).executeScript(
|
||||
"return ((document.querySelector('" + parentSelector + (parentSelector.isEmpty() ? "" : " ") + "#"
|
||||
+ videoElement.getAttribute("id") + "').srcObject.getAudioTracks().length > 0)"
|
||||
+ "&& (document.querySelector('" + parentSelector + (parentSelector.isEmpty() ? "" : " ") + "#"
|
||||
+ videoElement.getAttribute("id") + "').srcObject.getAudioTracks()[0].enabled))");
|
||||
return audioTracks;
|
||||
}
|
||||
|
||||
private boolean hasVideoTracks(WebElement videoElement) {
|
||||
boolean videoTracks = (boolean) ((JavascriptExecutor) driver)
|
||||
.executeScript("return ((document.getElementById('" + videoElement.getAttribute("id")
|
||||
+ "').srcObject.getVideoTracks().length > 0)" + "&& (document.getElementById('"
|
||||
private boolean hasVideoTracks(WebElement videoElement, String parentSelector) {
|
||||
boolean videoTracks = (boolean) ((JavascriptExecutor) driver).executeScript(
|
||||
"return ((document.querySelector('" + parentSelector + (parentSelector.isEmpty() ? "" : " ") + "#"
|
||||
+ videoElement.getAttribute("id") + "').srcObject.getVideoTracks().length > 0)"
|
||||
+ "&& (document.querySelector('" + parentSelector + (parentSelector.isEmpty() ? "" : " ") + "#"
|
||||
+ videoElement.getAttribute("id") + "').srcObject.getVideoTracks()[0].enabled))");
|
||||
return videoTracks;
|
||||
}
|
||||
|
|
|
@ -254,9 +254,10 @@ public class OpenViduTestAppE2eTest {
|
|||
user.getEventManager().waitUntilEventReaches("streamCreated", 4);
|
||||
user.getEventManager().waitUntilEventReaches("streamPlaying", 4);
|
||||
|
||||
Assert.assertEquals(user.getDriver().findElements(By.tagName("video")).size(), 4);
|
||||
Assert.assertTrue(user.getEventManager().assertMediaTracks(user.getDriver().findElements(By.tagName("video")),
|
||||
true, true));
|
||||
final int numberOfVideos = user.getDriver().findElements(By.tagName("video")).size();
|
||||
Assert.assertEquals("Expected 4 videos but found " + numberOfVideos, numberOfVideos, 4);
|
||||
Assert.assertTrue("Videos were expected to have audio and video tracks", user.getEventManager()
|
||||
.assertMediaTracks(user.getDriver().findElements(By.tagName("video")), true, true));
|
||||
|
||||
gracefullyLeaveParticipants(2);
|
||||
}
|
||||
|
@ -281,9 +282,10 @@ public class OpenViduTestAppE2eTest {
|
|||
|
||||
System.out.println(this.getBase64Screenshot(user));
|
||||
|
||||
Assert.assertEquals(user.getDriver().findElements(By.tagName("video")).size(), 4);
|
||||
Assert.assertTrue(user.getEventManager().assertMediaTracks(user.getDriver().findElements(By.tagName("video")),
|
||||
true, false));
|
||||
final int numberOfVideos = user.getDriver().findElements(By.tagName("video")).size();
|
||||
Assert.assertEquals("Expected 4 videos but found " + numberOfVideos, numberOfVideos, 4);
|
||||
Assert.assertTrue("Videos were expected to only have audio tracks", user.getEventManager()
|
||||
.assertMediaTracks(user.getDriver().findElements(By.tagName("video")), true, false));
|
||||
|
||||
gracefullyLeaveParticipants(2);
|
||||
}
|
||||
|
@ -306,9 +308,10 @@ public class OpenViduTestAppE2eTest {
|
|||
user.getEventManager().waitUntilEventReaches("streamCreated", 4);
|
||||
user.getEventManager().waitUntilEventReaches("streamPlaying", 4);
|
||||
|
||||
Assert.assertEquals(user.getDriver().findElements(By.tagName("video")).size(), 4);
|
||||
Assert.assertTrue(user.getEventManager().assertMediaTracks(user.getDriver().findElements(By.tagName("video")),
|
||||
false, true));
|
||||
final int numberOfVideos = user.getDriver().findElements(By.tagName("video")).size();
|
||||
Assert.assertEquals("Expected 4 videos but found " + numberOfVideos, numberOfVideos, 4);
|
||||
Assert.assertTrue("Videos were expected to only have video tracks", user.getEventManager()
|
||||
.assertMediaTracks(user.getDriver().findElements(By.tagName("video")), false, true));
|
||||
|
||||
gracefullyLeaveParticipants(2);
|
||||
}
|
||||
|
@ -329,8 +332,10 @@ public class OpenViduTestAppE2eTest {
|
|||
user.getEventManager().waitUntilEventReaches("streamCreated", 4);
|
||||
user.getEventManager().waitUntilEventReaches("streamPlaying", 4);
|
||||
|
||||
Assert.assertEquals(user.getDriver().findElements(By.tagName("video")).size(), 4);
|
||||
user.getEventManager().assertMediaTracks(user.getDriver().findElements(By.tagName("video")), true, true);
|
||||
final int numberOfVideos = user.getDriver().findElements(By.tagName("video")).size();
|
||||
Assert.assertEquals("Expected 4 videos but found " + numberOfVideos, numberOfVideos, 4);
|
||||
Assert.assertTrue("Videos were expected to have audio and video tracks", user.getEventManager()
|
||||
.assertMediaTracks(user.getDriver().findElements(By.tagName("video")), true, true));
|
||||
|
||||
gracefullyLeaveParticipants(4);
|
||||
}
|
||||
|
@ -352,9 +357,10 @@ public class OpenViduTestAppE2eTest {
|
|||
user.getEventManager().waitUntilEventReaches("streamCreated", 1);
|
||||
user.getEventManager().waitUntilEventReaches("streamPlaying", 1);
|
||||
|
||||
Assert.assertEquals(user.getDriver().findElements(By.tagName("video")).size(), 1);
|
||||
Assert.assertTrue(user.getEventManager().assertMediaTracks(user.getDriver().findElements(By.tagName("video")),
|
||||
true, true));
|
||||
final int numberOfVideos = user.getDriver().findElements(By.tagName("video")).size();
|
||||
Assert.assertEquals("Expected 1 video but found " + numberOfVideos, numberOfVideos, 1);
|
||||
Assert.assertTrue("Video was expected to have audio and video tracks", user.getEventManager()
|
||||
.assertMediaTracks(user.getDriver().findElements(By.tagName("video")), true, true));
|
||||
|
||||
gracefullyLeaveParticipants(1);
|
||||
}
|
||||
|
@ -373,8 +379,13 @@ public class OpenViduTestAppE2eTest {
|
|||
|
||||
user.getEventManager().waitUntilEventReaches("connectionCreated", 1);
|
||||
user.getEventManager().waitUntilEventReaches("accessAllowed", 1);
|
||||
user.getEventManager().waitUntilEventReaches("streamCreated", 1);
|
||||
user.getEventManager().waitUntilEventReaches("streamPlaying", 1);
|
||||
|
||||
Thread.sleep(3000);
|
||||
final int numberOfVideos = user.getDriver().findElements(By.tagName("video")).size();
|
||||
Assert.assertEquals("Expected 1 video but found " + numberOfVideos, numberOfVideos, 1);
|
||||
Assert.assertTrue("Video was expected to have audio and video tracks", user.getEventManager()
|
||||
.assertMediaTracks(user.getDriver().findElements(By.tagName("video")), true, true));
|
||||
|
||||
gracefullyLeaveParticipants(1);
|
||||
}
|
||||
|
@ -397,9 +408,10 @@ public class OpenViduTestAppE2eTest {
|
|||
user.getEventManager().waitUntilEventReaches("streamCreated", 1);
|
||||
user.getEventManager().waitUntilEventReaches("streamPlaying", 1);
|
||||
|
||||
Assert.assertEquals(user.getDriver().findElements(By.tagName("video")).size(), 1);
|
||||
Assert.assertTrue(user.getEventManager().assertMediaTracks(user.getDriver().findElements(By.tagName("video")),
|
||||
true, true));
|
||||
final int numberOfVideos = user.getDriver().findElements(By.tagName("video")).size();
|
||||
Assert.assertEquals("Expected 1 video but found " + numberOfVideos, numberOfVideos, 1);
|
||||
Assert.assertTrue("Video was expected to have audio and video tracks", user.getEventManager()
|
||||
.assertMediaTracks(user.getDriver().findElements(By.tagName("video")), true, true));
|
||||
|
||||
gracefullyLeaveParticipants(1);
|
||||
}
|
||||
|
@ -424,9 +436,10 @@ public class OpenViduTestAppE2eTest {
|
|||
user.getEventManager().waitUntilEventReaches("streamCreated", 16);
|
||||
user.getEventManager().waitUntilEventReaches("streamPlaying", 16);
|
||||
|
||||
Assert.assertEquals(user.getDriver().findElements(By.tagName("video")).size(), 16);
|
||||
Assert.assertTrue(user.getEventManager().assertMediaTracks(user.getDriver().findElements(By.tagName("video")),
|
||||
true, true));
|
||||
final int numberOfVideos = user.getDriver().findElements(By.tagName("video")).size();
|
||||
Assert.assertEquals("Expected 16 videos but found " + numberOfVideos, numberOfVideos, 16);
|
||||
Assert.assertTrue("Videos were expected to have audio and video tracks", user.getEventManager()
|
||||
.assertMediaTracks(user.getDriver().findElements(By.tagName("video")), true, true));
|
||||
|
||||
gracefullyLeaveParticipants(4);
|
||||
}
|
||||
|
@ -447,9 +460,10 @@ public class OpenViduTestAppE2eTest {
|
|||
user.getEventManager().waitUntilEventReaches("streamCreated", 4);
|
||||
user.getEventManager().waitUntilEventReaches("streamPlaying", 4);
|
||||
|
||||
Assert.assertEquals(user.getDriver().findElements(By.tagName("video")).size(), 4);
|
||||
Assert.assertTrue(user.getEventManager().assertMediaTracks(user.getDriver().findElements(By.tagName("video")),
|
||||
true, true));
|
||||
final int numberOfVideos = user.getDriver().findElements(By.tagName("video")).size();
|
||||
Assert.assertEquals("Expected 4 videos but found " + numberOfVideos, numberOfVideos, 4);
|
||||
Assert.assertTrue("Videos were expected to have audio and video tracks", user.getEventManager()
|
||||
.assertMediaTracks(user.getDriver().findElements(By.tagName("video")), true, true));
|
||||
|
||||
gracefullyLeaveParticipants(2);
|
||||
}
|
||||
|
@ -492,9 +506,10 @@ public class OpenViduTestAppE2eTest {
|
|||
user2.getEventManager().waitUntilEventReaches("streamCreated", 2);
|
||||
user2.getEventManager().waitUntilEventReaches("streamPlaying", 2);
|
||||
|
||||
Assert.assertEquals(user2.getDriver().findElements(By.tagName("video")).size(), 2);
|
||||
Assert.assertTrue(user2.getEventManager()
|
||||
.assertMediaTracks(user2.getDriver().findElements(By.tagName("video")), true, true));
|
||||
final int numberOfVideos = user.getDriver().findElements(By.tagName("video")).size();
|
||||
Assert.assertEquals("Expected 2 videos but found " + numberOfVideos, numberOfVideos, 2);
|
||||
Assert.assertTrue("Videos were expected to have audio and video tracks", user.getEventManager()
|
||||
.assertMediaTracks(user.getDriver().findElements(By.tagName("video")), true, true));
|
||||
|
||||
user2.getEventManager().waitUntilEventReaches("streamDestroyed", 1);
|
||||
user2.getEventManager().waitUntilEventReaches("connectionDestroyed", 1);
|
||||
|
@ -518,9 +533,10 @@ public class OpenViduTestAppE2eTest {
|
|||
user.getEventManager().waitUntilEventReaches("streamCreated", 2);
|
||||
user.getEventManager().waitUntilEventReaches("streamPlaying", 2);
|
||||
|
||||
Assert.assertEquals(user.getDriver().findElements(By.tagName("video")).size(), 2);
|
||||
Assert.assertTrue(user.getEventManager().assertMediaTracks(user.getDriver().findElements(By.tagName("video")),
|
||||
true, true));
|
||||
final int numberOfVideos = user.getDriver().findElements(By.tagName("video")).size();
|
||||
Assert.assertEquals("Expected 2 videos but found " + numberOfVideos, numberOfVideos, 2);
|
||||
Assert.assertTrue("Videos were expected to have audio and video tracks", user.getEventManager()
|
||||
.assertMediaTracks(user.getDriver().findElements(By.tagName("video")), true, true));
|
||||
|
||||
gracefullyLeaveParticipants(1);
|
||||
|
||||
|
@ -551,10 +567,9 @@ public class OpenViduTestAppE2eTest {
|
|||
|
||||
user.getEventManager().waitUntilEventReaches("connectionCreated", 16);
|
||||
user.getDriver().findElements(By.className(("message-btn"))).get(0).click();
|
||||
user.getEventManager().waitUntilEventReaches("signal", 4);
|
||||
user.getEventManager().waitUntilEventReaches("signal:chat", 4);
|
||||
|
||||
gracefullyLeaveParticipants(4);
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -575,9 +590,10 @@ public class OpenViduTestAppE2eTest {
|
|||
user.getEventManager().waitUntilEventReaches("streamCreated", 2);
|
||||
user.getEventManager().waitUntilEventReaches("streamPlaying", 2);
|
||||
|
||||
Assert.assertEquals(user.getDriver().findElements(By.tagName("video")).size(), 2);
|
||||
Assert.assertTrue(user.getEventManager().assertMediaTracks(user.getDriver().findElements(By.tagName("video")),
|
||||
true, true));
|
||||
int numberOfVideos = user.getDriver().findElements(By.tagName("video")).size();
|
||||
Assert.assertEquals("Expected 2 videos but found " + numberOfVideos, numberOfVideos, 2);
|
||||
Assert.assertTrue("Videos were expected to have audio and video tracks", user.getEventManager()
|
||||
.assertMediaTracks(user.getDriver().findElements(By.tagName("video")), true, true));
|
||||
|
||||
// Global unsubscribe-subscribe
|
||||
WebElement subscriberVideo = user.getDriver().findElement(By.cssSelector("#openvidu-instance-0 video"));
|
||||
|
@ -586,39 +602,42 @@ public class OpenViduTestAppE2eTest {
|
|||
|
||||
user.getWaiter()
|
||||
.until(ExpectedConditions.not(ExpectedConditions.attributeToBeNotEmpty(subscriberVideo, "srcObject")));
|
||||
Assert.assertFalse(user.getEventManager().hasMediaStream(subscriberVideo));
|
||||
Assert.assertFalse("Subscriber video should not have srcObject defined after unsubscribe",
|
||||
user.getEventManager().hasMediaStream(subscriberVideo, "#openvidu-instance-0"));
|
||||
|
||||
subBtn.click();
|
||||
user.getEventManager().waitUntilEventReaches("streamPlaying", 3);
|
||||
|
||||
Assert.assertEquals(user.getDriver().findElements(By.tagName("video")).size(), 2);
|
||||
Assert.assertTrue(user.getEventManager().assertMediaTracks(user.getDriver().findElements(By.tagName("video")),
|
||||
true, true));
|
||||
numberOfVideos = user.getDriver().findElements(By.tagName("video")).size();
|
||||
Assert.assertEquals("Expected 2 videos but found " + numberOfVideos, numberOfVideos, 2);
|
||||
Assert.assertTrue("Videos were expected to have audio and video tracks", user.getEventManager()
|
||||
.assertMediaTracks(user.getDriver().findElements(By.tagName("video")), true, true));
|
||||
|
||||
// Video unsubscribe
|
||||
subscriberVideo = user.getDriver().findElement(By.cssSelector("#openvidu-instance-0 video"));
|
||||
Iterable<WebElement> firstVideo = Arrays.asList(subscriberVideo);
|
||||
user.getDriver().findElement(By.cssSelector(("#openvidu-instance-0 .sub-video-btn"))).click();
|
||||
Thread.sleep(1000);
|
||||
Assert.assertTrue(user.getEventManager().assertMediaTracks(firstVideo, true, false));
|
||||
Assert.assertTrue("Subscriber video was expected to only have audio track",
|
||||
user.getEventManager().assertMediaTracks(firstVideo, true, false));
|
||||
|
||||
// Audio unsubscribe
|
||||
|
||||
user.getDriver().findElement(By.cssSelector(("#openvidu-instance-0 .sub-audio-btn"))).click();
|
||||
Thread.sleep(1000);
|
||||
Assert.assertTrue(user.getEventManager().assertMediaTracks(firstVideo, false, false));
|
||||
Assert.assertTrue("Subscriber video was expected to not have video or audio tracks",
|
||||
user.getEventManager().assertMediaTracks(firstVideo, false, false));
|
||||
|
||||
// Video and audio subscribe
|
||||
|
||||
user.getDriver().findElement(By.cssSelector(("#openvidu-instance-0 .sub-video-btn"))).click();
|
||||
Thread.sleep(1000);
|
||||
Assert.assertTrue(user.getEventManager().assertMediaTracks(firstVideo, false, true));
|
||||
Assert.assertTrue("Subscriber video was expected to only have video track",
|
||||
user.getEventManager().assertMediaTracks(firstVideo, false, true));
|
||||
user.getDriver().findElement(By.cssSelector(("#openvidu-instance-0 .sub-audio-btn"))).click();
|
||||
Thread.sleep(1000);
|
||||
Assert.assertTrue(user.getEventManager().assertMediaTracks(firstVideo, true, true));
|
||||
Assert.assertTrue("Subscriber video was expected to have audio and video tracks",
|
||||
user.getEventManager().assertMediaTracks(firstVideo, true, true));
|
||||
|
||||
gracefullyLeaveParticipants(2);
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -637,11 +656,10 @@ public class OpenViduTestAppE2eTest {
|
|||
user.getEventManager().waitUntilEventReaches("streamCreated", 4);
|
||||
user.getEventManager().waitUntilEventReaches("streamPlaying", 4);
|
||||
|
||||
user.getWaiter().until(ExpectedConditions.numberOfElementsToBe(By.tagName("video"), 4));
|
||||
Assert.assertTrue(user.getEventManager().assertMediaTracks(user.getDriver().findElements(By.tagName("video")),
|
||||
true, true));
|
||||
|
||||
Thread.sleep(2000);
|
||||
int numberOfVideos = user.getDriver().findElements(By.tagName("video")).size();
|
||||
Assert.assertEquals("Expected 4 videos but found " + numberOfVideos, numberOfVideos, 4);
|
||||
Assert.assertTrue("Videos were expected to have audio and video tracks", user.getEventManager()
|
||||
.assertMediaTracks(user.getDriver().findElements(By.tagName("video")), true, true));
|
||||
|
||||
List<WebElement> publishButtons = user.getDriver().findElements(By.className("pub-btn"));
|
||||
for (WebElement el : publishButtons) {
|
||||
|
@ -652,7 +670,8 @@ public class OpenViduTestAppE2eTest {
|
|||
for (WebElement video : user.getDriver().findElements(By.tagName("video"))) {
|
||||
user.getWaiter()
|
||||
.until(ExpectedConditions.not(ExpectedConditions.attributeToBeNotEmpty(video, "srcObject")));
|
||||
Assert.assertFalse(user.getEventManager().hasMediaStream(video));
|
||||
Assert.assertFalse("Videos were expected to lack srcObject property",
|
||||
user.getEventManager().hasMediaStream(video, ""));
|
||||
}
|
||||
|
||||
for (WebElement el : publishButtons) {
|
||||
|
@ -662,11 +681,10 @@ public class OpenViduTestAppE2eTest {
|
|||
|
||||
user.getEventManager().waitUntilEventReaches("streamCreated", 8);
|
||||
user.getEventManager().waitUntilEventReaches("streamPlaying", 8);
|
||||
Assert.assertTrue(user.getEventManager().assertMediaTracks(user.getDriver().findElements(By.tagName("video")),
|
||||
true, true));
|
||||
Assert.assertTrue("Videos were expected to have audio and video tracks", user.getEventManager()
|
||||
.assertMediaTracks(user.getDriver().findElements(By.tagName("video")), true, true));
|
||||
|
||||
gracefullyLeaveParticipants(2);
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -689,77 +707,78 @@ public class OpenViduTestAppE2eTest {
|
|||
|
||||
// First publication (audio + video [CAMERA])
|
||||
user.getEventManager().on("streamPlaying", (event) -> {
|
||||
if (event.get("eventContent") != null) {
|
||||
threadAssertions.add(((String) event.get("eventContent")).contains("CAMERA"));
|
||||
}
|
||||
JsonObject stream = event.get("target").getAsJsonObject().get("stream").getAsJsonObject();
|
||||
threadAssertions.add("CAMERA".equals(stream.get("typeOfVideo").getAsString()));
|
||||
threadAssertions.add(stream.get("hasAudio").getAsBoolean());
|
||||
|
||||
latch1.countDown();
|
||||
});
|
||||
user.getDriver().findElement(By.id("one2many-btn")).click();
|
||||
|
||||
Thread.sleep(2000);
|
||||
|
||||
user.getEventManager().waitUntilEventReaches("connectionCreated", 4);
|
||||
user.getEventManager().waitUntilEventReaches("accessAllowed", 1);
|
||||
user.getEventManager().waitUntilEventReaches("streamCreated", 2);
|
||||
user.getEventManager().waitUntilEventReaches("streamPlaying", 2);
|
||||
|
||||
if (!latch1.await(8000, TimeUnit.MILLISECONDS)) {
|
||||
if (!latch1.await(5000, TimeUnit.MILLISECONDS)) {
|
||||
gracefullyLeaveParticipants(2);
|
||||
fail();
|
||||
fail("Waiting for 2 streamPlaying events to happen in total");
|
||||
return;
|
||||
}
|
||||
|
||||
user.getEventManager().off("streamPlaying");
|
||||
log.info("Thread assertions: {}", threadAssertions.toString());
|
||||
for (Iterator<Boolean> iter = threadAssertions.iterator(); iter.hasNext();) {
|
||||
Assert.assertTrue(iter.next());
|
||||
Assert.assertTrue("Some Event property was wrong", iter.next());
|
||||
iter.remove();
|
||||
}
|
||||
|
||||
user.getWaiter().until(ExpectedConditions.numberOfElementsToBe(By.tagName("video"), 2));
|
||||
Assert.assertTrue(user.getEventManager().assertMediaTracks(user.getDriver().findElements(By.tagName("video")),
|
||||
true, true));
|
||||
|
||||
Thread.sleep(2000);
|
||||
int numberOfVideos = user.getDriver().findElements(By.tagName("video")).size();
|
||||
Assert.assertEquals("Expected 2 videos but found " + numberOfVideos, numberOfVideos, 2);
|
||||
Assert.assertTrue("Videos were expected to have audio and video tracks", user.getEventManager()
|
||||
.assertMediaTracks(user.getDriver().findElements(By.tagName("video")), true, true));
|
||||
|
||||
final CountDownLatch latch2 = new CountDownLatch(2);
|
||||
|
||||
// Second publication (only video (SCREEN))
|
||||
user.getEventManager().on("streamPlaying", (event) -> {
|
||||
if (event.get("eventContent") != null) {
|
||||
threadAssertions.add(((String) event.get("eventContent")).contains("SCREEN"));
|
||||
}
|
||||
JsonObject stream = event.get("target").getAsJsonObject().get("stream").getAsJsonObject();
|
||||
threadAssertions.add("SCREEN".equals(stream.get("typeOfVideo").getAsString()));
|
||||
threadAssertions.add(!stream.get("hasAudio").getAsBoolean());
|
||||
latch2.countDown();
|
||||
});
|
||||
user.getDriver().findElement(By.cssSelector("#openvidu-instance-0 .change-publisher-btn")).click();
|
||||
|
||||
user.getEventManager().waitUntilEventReaches("streamDestroyed", 2);
|
||||
user.getEventManager().waitUntilEventReaches("accessAllowed", 2);
|
||||
user.getEventManager().waitUntilEventReaches("streamCreated", 4);
|
||||
user.getEventManager().waitUntilEventReaches("streamPlaying", 4);
|
||||
|
||||
if (!latch2.await(8000, TimeUnit.MILLISECONDS)) {
|
||||
if (!latch2.await(5000, TimeUnit.MILLISECONDS)) {
|
||||
gracefullyLeaveParticipants(2);
|
||||
fail();
|
||||
fail("Waiting for 4 streamPlaying events to happen in total");
|
||||
return;
|
||||
}
|
||||
|
||||
user.getEventManager().off("streamPlaying");
|
||||
log.info("Thread assertions: {}", threadAssertions.toString());
|
||||
for (Iterator<Boolean> iter = threadAssertions.iterator(); iter.hasNext();) {
|
||||
Assert.assertTrue(iter.next());
|
||||
Assert.assertTrue("Some Event property was wrong", iter.next());
|
||||
iter.remove();
|
||||
}
|
||||
|
||||
Assert.assertTrue(user.getEventManager().assertMediaTracks(user.getDriver().findElements(By.tagName("video")),
|
||||
false, true));
|
||||
|
||||
Thread.sleep(2000);
|
||||
numberOfVideos = user.getDriver().findElements(By.tagName("video")).size();
|
||||
Assert.assertEquals("Expected 2 videos but found " + numberOfVideos, numberOfVideos, 2);
|
||||
Assert.assertTrue("Videos were expected to only have audio tracks", user.getEventManager()
|
||||
.assertMediaTracks(user.getDriver().findElements(By.tagName("video")), false, true));
|
||||
|
||||
final CountDownLatch latch3 = new CountDownLatch(2);
|
||||
|
||||
// Third publication (audio + video [CAMERA])
|
||||
user.getEventManager().on("streamPlaying", (event) -> {
|
||||
if (event.get("eventContent") != null) {
|
||||
threadAssertions.add(((String) event.get("eventContent")).contains("CAMERA"));
|
||||
}
|
||||
JsonObject stream = event.get("target").getAsJsonObject().get("stream").getAsJsonObject();
|
||||
threadAssertions.add("CAMERA".equals(stream.get("typeOfVideo").getAsString()));
|
||||
threadAssertions.add(stream.get("hasAudio").getAsBoolean());
|
||||
latch3.countDown();
|
||||
});
|
||||
user.getDriver().findElement(By.cssSelector("#openvidu-instance-0 .change-publisher-btn")).click();
|
||||
|
@ -770,21 +789,23 @@ public class OpenViduTestAppE2eTest {
|
|||
|
||||
if (!latch3.await(8000, TimeUnit.MILLISECONDS)) {
|
||||
gracefullyLeaveParticipants(2);
|
||||
fail();
|
||||
fail("Waiting for 6 streamPlaying events to happen in total");
|
||||
return;
|
||||
}
|
||||
|
||||
user.getEventManager().off("streamPlaying");
|
||||
log.info("Thread assertions: {}", threadAssertions.toString());
|
||||
for (Iterator<Boolean> iter = threadAssertions.iterator(); iter.hasNext();) {
|
||||
Assert.assertTrue(iter.next());
|
||||
Assert.assertTrue("Some Event property was wrong", iter.next());
|
||||
iter.remove();
|
||||
}
|
||||
|
||||
Assert.assertTrue(user.getEventManager().assertMediaTracks(user.getDriver().findElements(By.tagName("video")),
|
||||
true, true));
|
||||
numberOfVideos = user.getDriver().findElements(By.tagName("video")).size();
|
||||
Assert.assertEquals("Expected 2 videos but found " + numberOfVideos, numberOfVideos, 2);
|
||||
Assert.assertTrue("Videos were expected to have audio and video tracks", user.getEventManager()
|
||||
.assertMediaTracks(user.getDriver().findElements(By.tagName("video")), true, true));
|
||||
|
||||
gracefullyLeaveParticipants(2);
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -819,23 +840,30 @@ public class OpenViduTestAppE2eTest {
|
|||
user.getEventManager().waitUntilEventReaches("streamCreated", 3);
|
||||
user.getEventManager().waitUntilEventReaches("streamPlaying", 3);
|
||||
|
||||
user.getWaiter().until(ExpectedConditions.numberOfElementsToBe(By.tagName("video"), 3));
|
||||
Assert.assertTrue(user.getEventManager().assertMediaTracks(user.getDriver().findElements(By.tagName("video")),
|
||||
true, true));
|
||||
int numberOfVideos = user.getDriver().findElements(By.tagName("video")).size();
|
||||
Assert.assertEquals("Expected 3 videos but found " + numberOfVideos, numberOfVideos, 3);
|
||||
Assert.assertTrue("Videos were expected to have audio and video tracks", user.getEventManager()
|
||||
.assertMediaTracks(user.getDriver().findElements(By.tagName("video")), true, true));
|
||||
|
||||
// Moderator forces unpublish
|
||||
user.getDriver().findElement(By.cssSelector("#openvidu-instance-2 .force-unpub-btn")).click();
|
||||
user.getEventManager().waitUntilEventReaches("streamDestroyed", 3);
|
||||
user.getWaiter().until(ExpectedConditions.numberOfElementsToBe(By.tagName("video"), 1));
|
||||
|
||||
List<WebElement> videos = user.getDriver().findElements(By.tagName("video"));
|
||||
numberOfVideos = videos.size();
|
||||
Assert.assertEquals("Expected 1 video but found " + numberOfVideos, numberOfVideos, 1);
|
||||
Assert.assertFalse("Publisher video should not have srcObject defined after force unpublish",
|
||||
user.getEventManager().hasMediaStream(videos.get(0), ""));
|
||||
|
||||
// Publisher publishes again
|
||||
user.getDriver().findElement(By.cssSelector("#openvidu-instance-0 .pub-btn")).click();
|
||||
user.getEventManager().waitUntilEventReaches("streamCreated", 6);
|
||||
user.getEventManager().waitUntilEventReaches("streamPlaying", 6);
|
||||
|
||||
user.getWaiter().until(ExpectedConditions.numberOfElementsToBe(By.tagName("video"), 3));
|
||||
Assert.assertTrue(user.getEventManager().assertMediaTracks(user.getDriver().findElements(By.tagName("video")),
|
||||
true, true));
|
||||
numberOfVideos = user.getDriver().findElements(By.tagName("video")).size();
|
||||
Assert.assertEquals("Expected 3 videos but found " + numberOfVideos, numberOfVideos, 3);
|
||||
Assert.assertTrue("Videos were expected to have audio and video tracks", user.getEventManager()
|
||||
.assertMediaTracks(user.getDriver().findElements(By.tagName("video")), true, true));
|
||||
|
||||
// Moderator forces disconnect of publisher
|
||||
user.getDriver().findElement(By.cssSelector("#openvidu-instance-2 .force-disconnect-btn")).click();
|
||||
|
@ -845,7 +873,6 @@ public class OpenViduTestAppE2eTest {
|
|||
user.getWaiter().until(ExpectedConditions.numberOfElementsToBe(By.tagName("video"), 0));
|
||||
|
||||
gracefullyLeaveParticipants(3);
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -878,7 +905,8 @@ public class OpenViduTestAppE2eTest {
|
|||
// Unpublish video
|
||||
final CountDownLatch latch1 = new CountDownLatch(2);
|
||||
user.getEventManager().on("streamPropertyChanged", (event) -> {
|
||||
threadAssertions.add(((String) event.get("eventContent")).contains("videoActive [false]"));
|
||||
threadAssertions.add("videoActive".equals(event.get("changedProperty").getAsString()));
|
||||
threadAssertions.add(!event.get("newValue").getAsBoolean());
|
||||
latch1.countDown();
|
||||
});
|
||||
user.getDriver().findElement(By.cssSelector("#openvidu-instance-0 .pub-video-btn")).click();
|
||||
|
@ -891,15 +919,17 @@ public class OpenViduTestAppE2eTest {
|
|||
}
|
||||
|
||||
user.getEventManager().off("streamPropertyChanged");
|
||||
log.info("Thread assertions: {}", threadAssertions.toString());
|
||||
for (Iterator<Boolean> iter = threadAssertions.iterator(); iter.hasNext();) {
|
||||
Assert.assertTrue(iter.next());
|
||||
Assert.assertTrue("Some Event property was wrong", iter.next());
|
||||
iter.remove();
|
||||
}
|
||||
|
||||
// Unpublish audio
|
||||
final CountDownLatch latch2 = new CountDownLatch(2);
|
||||
user.getEventManager().on("streamPropertyChanged", (event) -> {
|
||||
threadAssertions.add(((String) event.get("eventContent")).contains("audioActive [false]"));
|
||||
threadAssertions.add("audioActive".equals(event.get("changedProperty").getAsString()));
|
||||
threadAssertions.add(!event.get("newValue").getAsBoolean());
|
||||
latch2.countDown();
|
||||
});
|
||||
user.getDriver().findElement(By.cssSelector("#openvidu-instance-0 .pub-audio-btn")).click();
|
||||
|
@ -912,8 +942,9 @@ public class OpenViduTestAppE2eTest {
|
|||
}
|
||||
|
||||
user.getEventManager().off("streamPropertyChanged");
|
||||
log.info("Thread assertions: {}", threadAssertions.toString());
|
||||
for (Iterator<Boolean> iter = threadAssertions.iterator(); iter.hasNext();) {
|
||||
Assert.assertTrue(iter.next());
|
||||
Assert.assertTrue("Some Event property was wrong", iter.next());
|
||||
iter.remove();
|
||||
}
|
||||
|
||||
|
@ -925,8 +956,10 @@ public class OpenViduTestAppE2eTest {
|
|||
final long[] expectedWidthHeight = new long[2];
|
||||
|
||||
user.getEventManager().on("streamPropertyChanged", (event) -> {
|
||||
threadAssertions.add(((String) event.get("eventContent")).contains("videoDimensions [{\"width\":"
|
||||
+ expectedWidthHeight[0] + ",\"height\":" + expectedWidthHeight[1] + "}]"));
|
||||
String expectedDimensions = "{\"width\":" + expectedWidthHeight[0] + ",\"height\":" + expectedWidthHeight[1]
|
||||
+ "}";
|
||||
threadAssertions.add("videoDimensions".equals(event.get("changedProperty").getAsString()));
|
||||
threadAssertions.add(expectedDimensions.equals(event.get("newValue").getAsJsonObject().toString()));
|
||||
latch3.countDown();
|
||||
});
|
||||
|
||||
|
@ -949,8 +982,9 @@ public class OpenViduTestAppE2eTest {
|
|||
}
|
||||
|
||||
user.getEventManager().off("streamPropertyChanged");
|
||||
log.info("Thread assertions: {}", threadAssertions.toString());
|
||||
for (Iterator<Boolean> iter = threadAssertions.iterator(); iter.hasNext();) {
|
||||
Assert.assertTrue(iter.next());
|
||||
Assert.assertTrue("Some Event property was wrong", iter.next());
|
||||
iter.remove();
|
||||
}
|
||||
|
||||
|
@ -973,8 +1007,10 @@ public class OpenViduTestAppE2eTest {
|
|||
user.getEventManager().waitUntilEventReaches("streamCreated", 1);
|
||||
user.getEventManager().waitUntilEventReaches("streamPlaying", 1);
|
||||
|
||||
Assert.assertTrue(user.getEventManager().assertMediaTracks(user.getDriver().findElements(By.tagName("video")),
|
||||
true, true));
|
||||
int numberOfVideos = user.getDriver().findElements(By.tagName("video")).size();
|
||||
Assert.assertEquals("Expected 1 video but found " + numberOfVideos, numberOfVideos, 1);
|
||||
Assert.assertTrue("Video was expected to have audio and video tracks", user.getEventManager()
|
||||
.assertMediaTracks(user.getDriver().findElements(By.tagName("video")), true, true));
|
||||
|
||||
WebElement recordBtn = user.getDriver().findElement(By.cssSelector("#openvidu-instance-0 .publisher-rec-btn"));
|
||||
recordBtn.click();
|
||||
|
@ -1063,8 +1099,10 @@ public class OpenViduTestAppE2eTest {
|
|||
user.getEventManager().waitUntilEventReaches("streamCreated", 1);
|
||||
user.getEventManager().waitUntilEventReaches("streamPlaying", 1);
|
||||
|
||||
Assert.assertTrue(user.getEventManager().assertMediaTracks(user.getDriver().findElements(By.tagName("video")),
|
||||
true, true));
|
||||
int numberOfVideos = user.getDriver().findElements(By.tagName("video")).size();
|
||||
Assert.assertEquals("Expected 1 video but found " + numberOfVideos, numberOfVideos, 1);
|
||||
Assert.assertTrue("Video was expected to have audio and video tracks", user.getEventManager()
|
||||
.assertMediaTracks(user.getDriver().findElements(By.tagName("video")), true, true));
|
||||
|
||||
user.getDriver().findElement(By.id("session-api-btn-0")).click();
|
||||
Thread.sleep(1000);
|
||||
|
@ -1118,13 +1156,16 @@ public class OpenViduTestAppE2eTest {
|
|||
File file2 = new File(recordingsPath + sessionName + "/" + ".recording." + sessionName);
|
||||
File file3 = new File(recordingsPath + sessionName + "/" + sessionName + ".jpg");
|
||||
|
||||
Assert.assertTrue(file1.exists() && file1.length() > 0);
|
||||
Assert.assertTrue(file2.exists() && file2.length() > 0);
|
||||
Assert.assertTrue(file3.exists() && file3.length() > 0);
|
||||
Assert.assertTrue("File " + file1.getAbsolutePath() + " does not exist or is empty",
|
||||
file1.exists() && file1.length() > 0);
|
||||
Assert.assertTrue("File " + file2.getAbsolutePath() + " does not exist or is empty",
|
||||
file2.exists() && file2.length() > 0);
|
||||
Assert.assertTrue("File " + file3.getAbsolutePath() + " does not exist or is empty",
|
||||
file3.exists() && file3.length() > 0);
|
||||
|
||||
Assert.assertTrue(
|
||||
Assert.assertTrue("Recorded file " + file1.getAbsolutePath() + " is not fine",
|
||||
this.recordedFileFine(file1, new OpenVidu(OPENVIDU_URL, OPENVIDU_SECRET).getRecording(sessionName)));
|
||||
Assert.assertTrue(this.thumbnailIsFine(file3));
|
||||
Assert.assertTrue("Thumbnail " + file3.getAbsolutePath() + " is not fine", this.thumbnailIsFine(file3));
|
||||
|
||||
// Try to get the stopped recording
|
||||
user.getDriver().findElement(By.id("get-recording-btn")).click();
|
||||
|
@ -1141,9 +1182,9 @@ public class OpenViduTestAppE2eTest {
|
|||
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());
|
||||
Assert.assertFalse("File " + file1.getAbsolutePath() + " shouldn't exist", file1.exists());
|
||||
Assert.assertFalse("File " + file2.getAbsolutePath() + " shouldn't exist", file2.exists());
|
||||
Assert.assertFalse("File " + file3.getAbsolutePath() + " shouldn't exist", file3.exists());
|
||||
|
||||
user.getDriver().findElement(By.id("close-dialog-btn")).click();
|
||||
Thread.sleep(500);
|
||||
|
@ -1175,8 +1216,10 @@ public class OpenViduTestAppE2eTest {
|
|||
user.getEventManager().waitUntilEventReaches("streamCreated", 4);
|
||||
user.getEventManager().waitUntilEventReaches("streamPlaying", 4);
|
||||
|
||||
Assert.assertTrue(user.getEventManager().assertMediaTracks(user.getDriver().findElements(By.tagName("video")),
|
||||
true, true));
|
||||
int numberOfVideos = user.getDriver().findElements(By.tagName("video")).size();
|
||||
Assert.assertEquals("Expected 4 videos but found " + numberOfVideos, numberOfVideos, 4);
|
||||
Assert.assertTrue("Videos were expected to have audio and video tracks", user.getEventManager()
|
||||
.assertMediaTracks(user.getDriver().findElements(By.tagName("video")), true, true));
|
||||
|
||||
user.getDriver().findElement(By.id("session-api-btn-0")).click();
|
||||
Thread.sleep(1000);
|
||||
|
@ -1251,7 +1294,7 @@ public class OpenViduTestAppE2eTest {
|
|||
user.getWaiter()
|
||||
.until(ExpectedConditions.attributeToBe(By.id("api-response-text-area"), "value", "Recording deleted"));
|
||||
|
||||
Assert.assertFalse(new File(recPath).exists());
|
||||
Assert.assertFalse("Recording folder " + recPath + " shouldn't exist", new File(recPath).exists());
|
||||
|
||||
user.getDriver().findElement(By.id("close-dialog-btn")).click();
|
||||
Thread.sleep(500);
|
||||
|
@ -1359,7 +1402,8 @@ public class OpenViduTestAppE2eTest {
|
|||
user.getEventManager().waitUntilEventReaches("streamCreated", 8);
|
||||
user.getEventManager().waitUntilEventReaches("streamPlaying", 8);
|
||||
|
||||
Assert.assertEquals(user.getDriver().findElements(By.tagName("video")).size(), 8);
|
||||
int numberOfVideos = user.getDriver().findElements(By.tagName("video")).size();
|
||||
Assert.assertEquals("Expected 8 videos but found " + numberOfVideos, numberOfVideos, 8);
|
||||
|
||||
user.getDriver().findElement(By.id("session-api-btn-0")).click();
|
||||
Thread.sleep(1000);
|
||||
|
@ -1529,8 +1573,10 @@ public class OpenViduTestAppE2eTest {
|
|||
user.getEventManager().waitUntilEventReaches("streamCreated", 4);
|
||||
user.getEventManager().waitUntilEventReaches("streamPlaying", 4);
|
||||
|
||||
Assert.assertTrue(user.getEventManager().assertMediaTracks(user.getDriver().findElements(By.tagName("video")),
|
||||
true, true));
|
||||
int numberOfVideos = user.getDriver().findElements(By.tagName("video")).size();
|
||||
Assert.assertEquals("Expected 4 videos but found " + numberOfVideos, numberOfVideos, 4);
|
||||
Assert.assertTrue("Videos were expected to have audio and video tracks", user.getEventManager()
|
||||
.assertMediaTracks(user.getDriver().findElements(By.tagName("video")), true, true));
|
||||
|
||||
// Fetch existing session (change)
|
||||
user.getDriver().findElement(By.id("session-api-btn-0")).click();
|
||||
|
@ -1565,6 +1611,15 @@ public class OpenViduTestAppE2eTest {
|
|||
ExpectedConditions.attributeToBe(By.id("api-response-text-area"), "value", "Stream unpublished"));
|
||||
user.getEventManager().waitUntilEventReaches("streamDestroyed", 2);
|
||||
|
||||
numberOfVideos = user.getDriver().findElements(By.tagName("video")).size();
|
||||
Assert.assertEquals("Expected 3 videos but found " + numberOfVideos, numberOfVideos, 3);
|
||||
WebElement v = user.getDriver().findElements(By.cssSelector("#openvidu-instance-1 video")).get(0);
|
||||
Assert.assertFalse("Publisher video should not have srcObject defined after force unpublish",
|
||||
user.getEventManager().hasMediaStream(v, "#openvidu-instance-1"));
|
||||
Iterable<WebElement> vs = user.getDriver().findElements(By.cssSelector("#openvidu-instance-0 video"));
|
||||
Assert.assertTrue("Videos were expected to have audio and video tracks",
|
||||
user.getEventManager().assertMediaTracks(vs, true, true));
|
||||
|
||||
// Force disconnect wrong
|
||||
user.getDriver().findElement(By.id("resource-id-field")).clear();
|
||||
user.getDriver().findElement(By.id("resource-id-field")).sendKeys("FAIL");
|
||||
|
@ -1623,16 +1678,17 @@ public class OpenViduTestAppE2eTest {
|
|||
user.getEventManager().waitUntilEventReaches("streamCreated", 2);
|
||||
user.getEventManager().waitUntilEventReaches("streamPlaying", 2);
|
||||
|
||||
Assert.assertEquals(user.getDriver().findElements(By.tagName("video")).size(), 2);
|
||||
Assert.assertTrue(user.getEventManager().assertMediaTracks(user.getDriver().findElements(By.tagName("video")),
|
||||
false, true));
|
||||
int numberOfVideos = user.getDriver().findElements(By.tagName("video")).size();
|
||||
Assert.assertEquals("Expected 2 videos but found " + numberOfVideos, numberOfVideos, 2);
|
||||
Assert.assertTrue("Videos were expected to have a video only track", user.getEventManager()
|
||||
.assertMediaTracks(user.getDriver().findElements(By.tagName("video")), false, true));
|
||||
|
||||
WebElement subscriberVideo = user.getDriver().findElement(By.cssSelector("#openvidu-instance-1 video"));
|
||||
|
||||
// Analyze Chrome fake video stream without gray filter (GREEN color)
|
||||
Map<String, Long> rgb = user.getEventManager().getAverageRgbFromVideo(subscriberVideo);
|
||||
System.out.println(rgb.toString());
|
||||
Assert.assertTrue(checkVideoAverageRgbGreen(rgb));
|
||||
Assert.assertTrue("Video is not average green", checkVideoAverageRgbGreen(rgb));
|
||||
|
||||
// Try to apply none allowed filter
|
||||
user.getDriver().findElement(By.cssSelector(".filter-btn")).click();
|
||||
|
@ -1668,7 +1724,7 @@ public class OpenViduTestAppE2eTest {
|
|||
Thread.sleep(500);
|
||||
rgb = user.getEventManager().getAverageRgbFromVideo(subscriberVideo);
|
||||
System.out.println(rgb.toString());
|
||||
Assert.assertTrue(checkVideoAverageRgbGray(rgb));
|
||||
Assert.assertTrue("Video is not average gray", checkVideoAverageRgbGray(rgb));
|
||||
|
||||
// Execute filter method
|
||||
WebElement filterMethodInput = user.getDriver().findElement(By.id("filter-method-field"));
|
||||
|
@ -1686,7 +1742,7 @@ public class OpenViduTestAppE2eTest {
|
|||
Thread.sleep(500);
|
||||
rgb = user.getEventManager().getAverageRgbFromVideo(subscriberVideo);
|
||||
System.out.println(rgb.toString());
|
||||
Assert.assertTrue(checkVideoAverageRgbGreen(rgb));
|
||||
Assert.assertTrue("Video is not average green", checkVideoAverageRgbGreen(rgb));
|
||||
|
||||
user.getDriver().findElement(By.id("close-dialog-btn")).click();
|
||||
Thread.sleep(500);
|
||||
|
@ -1711,7 +1767,7 @@ public class OpenViduTestAppE2eTest {
|
|||
subscriberVideo = user.getDriver().findElement(By.cssSelector("#openvidu-instance-1 video"));
|
||||
rgb = user.getEventManager().getAverageRgbFromVideo(subscriberVideo);
|
||||
System.out.println(rgb.toString());
|
||||
Assert.assertTrue(checkVideoAverageRgbGray(rgb));
|
||||
Assert.assertTrue("Video is not average gray", checkVideoAverageRgbGray(rgb));
|
||||
|
||||
// Remove filter
|
||||
user.getDriver().findElement(By.cssSelector(".filter-btn")).click();
|
||||
|
@ -1725,7 +1781,7 @@ public class OpenViduTestAppE2eTest {
|
|||
// Analyze Chrome fake video stream with gray filter (GREEN color)
|
||||
rgb = user.getEventManager().getAverageRgbFromVideo(subscriberVideo);
|
||||
System.out.println(rgb.toString());
|
||||
Assert.assertTrue(checkVideoAverageRgbGreen(rgb));
|
||||
Assert.assertTrue("Video is not average green", checkVideoAverageRgbGreen(rgb));
|
||||
|
||||
user.getDriver().findElement(By.id("close-dialog-btn")).click();
|
||||
Thread.sleep(500);
|
||||
|
@ -1773,10 +1829,10 @@ public class OpenViduTestAppE2eTest {
|
|||
user.getEventManager().waitUntilEventReaches("streamCreated", 2);
|
||||
user.getEventManager().waitUntilEventReaches("streamPlaying", 2);
|
||||
|
||||
Assert.assertEquals(user.getDriver().findElements(By.tagName("video")).size(), 2);
|
||||
// Assert no audio track only for the moderator incoming video
|
||||
Assert.assertTrue(user.getEventManager().assertMediaTracks(
|
||||
user.getDriver().findElements(By.cssSelector("#openvidu-instance-1 video")), false, true));
|
||||
int numberOfVideos = user.getDriver().findElements(By.tagName("video")).size();
|
||||
Assert.assertEquals("Expected 2 videos but found " + numberOfVideos, numberOfVideos, 2);
|
||||
Assert.assertTrue("Videos were expected to have only a video track", user.getEventManager()
|
||||
.assertMediaTracks(user.getDriver().findElements(By.tagName("video")), false, true));
|
||||
|
||||
// Publisher applies ZBarCode filter to itself
|
||||
user.getDriver().findElement(By.cssSelector("#openvidu-instance-0 .filter-btn")).click();
|
||||
|
@ -1801,7 +1857,7 @@ public class OpenViduTestAppE2eTest {
|
|||
user.getWaiter().until(ExpectedConditions.attributeContains(By.id("filter-response-text-area"), "value",
|
||||
"Filter event listener added"));
|
||||
|
||||
user.getEventManager().waitUntilEventReaches("filterEvent", 2);
|
||||
user.getEventManager().waitUntilEventReaches("CodeFound", 2);
|
||||
|
||||
// Publisher unsubscribes from "CodeFound" filter event
|
||||
user.getDriver().findElement(By.id("unsub-filter-event-btn")).click();
|
||||
|
@ -1809,7 +1865,7 @@ public class OpenViduTestAppE2eTest {
|
|||
try {
|
||||
// If this active wait finishes successfully, then the removal of the event
|
||||
// listener has not worked fine
|
||||
user.getEventManager().waitUntilEventReaches("filterEvent", 3, 3, false);
|
||||
user.getEventManager().waitUntilEventReaches("CodeFound", 3, 3, false);
|
||||
Assert.fail("'filterEvent' was received. Filter.removeEventListener() failed");
|
||||
} catch (Exception e) {
|
||||
System.out.println("Filter event removal worked fine");
|
||||
|
@ -1828,7 +1884,7 @@ public class OpenViduTestAppE2eTest {
|
|||
user.getWaiter().until(ExpectedConditions.attributeContains(By.id("filter-response-text-area"), "value",
|
||||
"Filter event listener added"));
|
||||
|
||||
user.getEventManager().waitUntilEventReaches("filterEvent", 4);
|
||||
user.getEventManager().waitUntilEventReaches("CodeFound", 4);
|
||||
|
||||
// Moderator removes the Publisher's filter
|
||||
user.getDriver().findElement(By.id("remove-filter-btn")).click();
|
||||
|
@ -1839,7 +1895,7 @@ public class OpenViduTestAppE2eTest {
|
|||
try {
|
||||
// If this active wait finishes successfully, then the removal of the filter has
|
||||
// not worked fine
|
||||
user.getEventManager().waitUntilEventReaches("filterEvent", 5, 3, false);
|
||||
user.getEventManager().waitUntilEventReaches("CodeFound", 5, 3, false);
|
||||
Assert.fail("'filterEvent' was received. Stream.removeFilter() failed");
|
||||
} catch (Exception e) {
|
||||
System.out.println("Filter removal worked fine");
|
||||
|
@ -1906,7 +1962,11 @@ public class OpenViduTestAppE2eTest {
|
|||
BufferedImage image = AWTUtil.toBufferedImage(frame);
|
||||
Map<String, Long> colorMap = this.averageColor(image);
|
||||
|
||||
Assert.assertEquals(image.getWidth() + "x" + image.getHeight(), recording.getResolution());
|
||||
String realResolution = image.getWidth() + "x" + image.getHeight();
|
||||
Assert.assertEquals(
|
||||
"Resolution (" + recording.getResolution()
|
||||
+ ") of recording entity is not equal to real video resolution (" + realResolution + ")",
|
||||
realResolution, recording.getResolution());
|
||||
|
||||
log.info("Recording map color: {}", colorMap.toString());
|
||||
isFine = this.checkVideoAverageRgbGreen(colorMap);
|
||||
|
@ -1922,21 +1982,27 @@ public class OpenViduTestAppE2eTest {
|
|||
|
||||
// Should be only 2 files: zip and metadata
|
||||
File folder = new File(recPath);
|
||||
Assert.assertEquals(folder.listFiles().length, 2);
|
||||
Assert.assertEquals(
|
||||
"There are more than 2 files (ZIP and metadata) inside individual recording folder " + recPath,
|
||||
folder.listFiles().length, 2);
|
||||
|
||||
File file1 = new File(recPath + recording.getName() + ".zip");
|
||||
File file2 = new File(recPath + ".recording." + recording.getId());
|
||||
|
||||
Assert.assertTrue(file1.exists() && file1.length() > 0);
|
||||
Assert.assertTrue(file2.exists() && file2.length() > 0);
|
||||
Assert.assertTrue("File " + file1.getAbsolutePath() + " does not exist or is empty",
|
||||
file1.exists() && file1.length() > 0);
|
||||
Assert.assertTrue("File " + file2.getAbsolutePath() + " does not exist or is empty",
|
||||
file2.exists() && file2.length() > 0);
|
||||
|
||||
List<File> unzippedWebmFiles = new Unzipper().unzipFile(recPath, recording.getName() + ".zip");
|
||||
|
||||
log.info("Expected {} video files and ZIP file has {}", numberOfVideoFiles, unzippedWebmFiles.size());
|
||||
Assert.assertEquals(numberOfVideoFiles, unzippedWebmFiles.size());
|
||||
Assert.assertEquals("Expecting " + numberOfVideoFiles + " inside ZIP file but " + unzippedWebmFiles.size()
|
||||
+ " found: " + unzippedWebmFiles.toString(), numberOfVideoFiles, unzippedWebmFiles.size());
|
||||
|
||||
File jsonSyncFile = new File(recPath + recording.getName() + ".json");
|
||||
Assert.assertTrue(jsonSyncFile.exists() && jsonSyncFile.length() > 0);
|
||||
Assert.assertTrue("JSON sync file " + jsonSyncFile.getAbsolutePath() + "does not exist or is empty",
|
||||
jsonSyncFile.exists() && jsonSyncFile.length() > 0);
|
||||
|
||||
JsonObject jsonSyncMetadata;
|
||||
try {
|
||||
Gson gson = new Gson();
|
||||
|
@ -1945,7 +2011,7 @@ public class OpenViduTestAppE2eTest {
|
|||
} catch (Exception e) {
|
||||
log.error("Cannot read JSON sync metadata file from {}. Error: {}", jsonSyncFile.getAbsolutePath(),
|
||||
e.getMessage());
|
||||
Assert.fail();
|
||||
Assert.fail("Cannot read JSON sync metadata file from " + jsonSyncFile.getAbsolutePath());
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -1953,7 +2019,10 @@ public class OpenViduTestAppE2eTest {
|
|||
JsonArray syncArray = jsonSyncMetadata.get("files").getAsJsonArray();
|
||||
for (File webmFile : unzippedWebmFiles) {
|
||||
totalFileSize += webmFile.length();
|
||||
Assert.assertTrue(webmFile.exists() && webmFile.length() > 0);
|
||||
|
||||
Assert.assertTrue("WEBM file " + webmFile.getAbsolutePath() + " does not exist or is empty",
|
||||
webmFile.exists() && webmFile.length() > 0);
|
||||
|
||||
double durationInSeconds = 0;
|
||||
boolean found = false;
|
||||
for (int i = 0; i < syncArray.size(); i++) {
|
||||
|
@ -1965,14 +2034,19 @@ public class OpenViduTestAppE2eTest {
|
|||
break;
|
||||
}
|
||||
}
|
||||
Assert.assertTrue(found);
|
||||
|
||||
Assert.assertTrue("Couldn't find in JSON sync object information for webm file " + webmFile.getName(),
|
||||
found);
|
||||
|
||||
log.info("Duration of {} according to sync metadata json file: {} s", webmFile.getName(),
|
||||
durationInSeconds);
|
||||
this.checkMultimediaFile(webmFile, recording.hasAudio(), recording.hasVideo(), durationInSeconds,
|
||||
recording.getResolution(), audioDecoder, videoDecoder);
|
||||
webmFile.delete();
|
||||
}
|
||||
Assert.assertEquals(recording.getSize(), totalFileSize);
|
||||
|
||||
Assert.assertEquals("Size of recording entity (" + recording.getSessionId()
|
||||
+ ") is not equal to real file size (" + totalFileSize + ")", recording.getSize(), totalFileSize);
|
||||
|
||||
jsonSyncFile.delete();
|
||||
}
|
||||
|
@ -2007,7 +2081,11 @@ public class OpenViduTestAppE2eTest {
|
|||
log.info("Duration of {} according to ffmpeg: {} s", file.getName(), metadata.getDuration());
|
||||
log.info("Duration of {} according to 'duration' property: {} s", file.getName(), duration);
|
||||
log.info("Difference in s duration: {}", Math.abs(metadata.getDuration() - duration));
|
||||
Assert.assertTrue(Math.abs((metadata.getDuration() - duration)) < 0.3);
|
||||
final double difference = 0.3;
|
||||
Assert.assertTrue(
|
||||
"Difference between recording entity duration (" + duration + ") and real video duration ("
|
||||
+ metadata.getDuration() + ") is greater than " + difference,
|
||||
Math.abs((metadata.getDuration() - duration)) < difference);
|
||||
}
|
||||
|
||||
private boolean thumbnailIsFine(File file) {
|
||||
|
|
|
@ -8,23 +8,26 @@
|
|||
|
||||
<div fxLayout="row">
|
||||
<mat-form-field style="margin-right: 10px">
|
||||
<input matInput placeholder="Session name" [id]="'session-name-input-' + index" name="sessionName" [(ngModel)]="sessionName"
|
||||
[disabled]="session">
|
||||
<input matInput placeholder="Session name" [id]="'session-name-input-' + index" name="sessionName"
|
||||
[(ngModel)]="sessionName" [disabled]="session">
|
||||
</mat-form-field>
|
||||
|
||||
<mat-form-field>
|
||||
<input matInput placeholder="Client data" [id]="'client-data-input-'+ index" name="clientData" [(ngModel)]="clientData" [disabled]="session">
|
||||
<input matInput placeholder="Client data" [id]="'client-data-input-'+ index" name="clientData"
|
||||
[(ngModel)]="clientData" [disabled]="session">
|
||||
</mat-form-field>
|
||||
|
||||
<div fxLayout="column" class="session-btns-div">
|
||||
<button mat-icon-button title="Session properties" [id]="'session-settings-btn-' + index" class="mat-icon-custom" (click)="openSessionPropertiesDialog()"
|
||||
[disabled]="session">
|
||||
<button mat-icon-button title="Session properties" [id]="'session-settings-btn-' + index" class="mat-icon-custom"
|
||||
(click)="openSessionPropertiesDialog()" [disabled]="session">
|
||||
<mat-icon class="mat-icon-custom-ic" aria-label="Session properties button">settings</mat-icon>
|
||||
</button>
|
||||
<button mat-icon-button title="Session API" [id]="'session-api-btn-' + index" class="mat-icon-custom" (click)="openSessionApiDialog()">
|
||||
<button mat-icon-button title="Session API" [id]="'session-api-btn-' + index" class="mat-icon-custom"
|
||||
(click)="openSessionApiDialog()">
|
||||
<mat-icon class="mat-icon-custom-ic" aria-label="Session API button">cloud_circle</mat-icon>
|
||||
</button>
|
||||
<button mat-icon-button title="Session events" [id]="'session-events-btn-' + index" class="mat-icon-custom" (click)="openSessionEventsDialog()">
|
||||
<button mat-icon-button title="Session events" [id]="'session-events-btn-' + index" class="mat-icon-custom"
|
||||
(click)="openSessionEventsDialog()">
|
||||
<mat-icon class="mat-icon-custom-ic" aria-label="Session events button">notifications</mat-icon>
|
||||
</button>
|
||||
</div>
|
||||
|
@ -33,8 +36,10 @@
|
|||
|
||||
<div class="join-publish-div">
|
||||
<button class="join-btn" mat-button (click)="joinSession()" [disabled]="session">JOIN</button>
|
||||
<mat-checkbox class="subscribe-checkbox" name="subscribeTo" (click)="toggleSubscribeTo()" [checked]="subscribeTo" [disabled]="session">Subscribe</mat-checkbox>
|
||||
<mat-checkbox class="publish-checkbox" name="publishTo" (click)="togglePublishTo()" [checked]="publishTo" [disabled]="session">Publish</mat-checkbox>
|
||||
<mat-checkbox class="subscribe-checkbox" name="subscribeTo" (click)="toggleSubscribeTo()" [checked]="subscribeTo"
|
||||
[disabled]="session">Subscribe</mat-checkbox>
|
||||
<mat-checkbox class="publish-checkbox" name="publishTo" (click)="togglePublishTo()" [checked]="publishTo"
|
||||
[disabled]="session">Publish</mat-checkbox>
|
||||
</div>
|
||||
|
||||
<div class="inner-card" fxLayout="row" fxLayoutAlign="start start">
|
||||
|
@ -52,16 +57,17 @@
|
|||
<div style="padding-top: 5px;">
|
||||
<h4>Enter active</h4>
|
||||
<div>
|
||||
<mat-checkbox class="active-audio-checkbox" name="activeAudio" [(ngModel)]="publisherProperties.publishAudio" (click)="publisherProperties.publishAudio = !publisherProperties.publishAudio"
|
||||
[disabled]="session || !publishTo">Audio</mat-checkbox>
|
||||
<mat-checkbox class="active-video-checkbox" name="activeVideo" [(ngModel)]="publisherProperties.publishVideo" (click)="publisherProperties.publishVideo = !publisherProperties.publishVideo"
|
||||
[disabled]="session || !publishTo">Video</mat-checkbox>
|
||||
<mat-checkbox class="active-audio-checkbox" name="activeAudio" [(ngModel)]="publisherProperties.publishAudio"
|
||||
(click)="publisherProperties.publishAudio = !publisherProperties.publishAudio" [disabled]="session || !publishTo">Audio</mat-checkbox>
|
||||
<mat-checkbox class="active-video-checkbox" name="activeVideo" [(ngModel)]="publisherProperties.publishVideo"
|
||||
(click)="publisherProperties.publishVideo = !publisherProperties.publishVideo" [disabled]="session || !publishTo">Video</mat-checkbox>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div fxFlex="35">
|
||||
<mat-radio-group [(ngModel)]="optionsVideo" (change)="updateOptionsVideo($event)" [disabled]="session || !publishTo" [ngModelOptions]="{standalone: true}">
|
||||
<mat-radio-group [(ngModel)]="optionsVideo" (change)="updateOptionsVideo($event)" [disabled]="session || !publishTo"
|
||||
[ngModelOptions]="{standalone: true}">
|
||||
<div>
|
||||
<mat-radio-button class="video-radio" value="video">Video</mat-radio-button>
|
||||
</div>
|
||||
|
@ -69,19 +75,19 @@
|
|||
<mat-radio-button class="screen-radio" value="screen">Screen</mat-radio-button>
|
||||
</div>
|
||||
</mat-radio-group>
|
||||
<mat-checkbox class="subscribe-remote-check" name="subscribeToRemote" (click)="subscribeToRemote = !subscribeToRemote" [disabled]="!publishTo || session"
|
||||
[checked]="publishTo && subscribeToRemote">Subscribe
|
||||
<mat-checkbox class="subscribe-remote-check" name="subscribeToRemote" (click)="subscribeToRemote = !subscribeToRemote"
|
||||
[disabled]="!publishTo || session" [checked]="publishTo && subscribeToRemote">Subscribe
|
||||
<br>to remote</mat-checkbox>
|
||||
</div>
|
||||
|
||||
<div fxFlex="10">
|
||||
<div fxLayout="column" class="publisher-btns-div">
|
||||
<button mat-icon-button title="Publisher properties" [id]="'publisher-settings-btn-' + index" class="mat-icon-custom" (click)="openPublisherPropertiesDialog()"
|
||||
[disabled]="!publishTo">
|
||||
<button mat-icon-button title="Publisher properties" [id]="'publisher-settings-btn-' + index" class="mat-icon-custom"
|
||||
(click)="openPublisherPropertiesDialog()" [disabled]="!publishTo">
|
||||
<mat-icon class="mat-icon-custom-ic" aria-label="Publisher properties button">settings</mat-icon>
|
||||
</button>
|
||||
<button mat-icon-button title="Add new publisher to running session" [id]="'session-api-btn-' + index" class="mat-icon-custom"
|
||||
[disabled]="!session || !publishTo">
|
||||
<button mat-icon-button title="Add new publisher to running session" [id]="'session-api-btn-' + index"
|
||||
class="mat-icon-custom" [disabled]="!session || !publishTo">
|
||||
<mat-icon class="mat-icon-custom-ic" aria-label="Session API button">add_circle</mat-icon>
|
||||
</button>
|
||||
</div>
|
||||
|
@ -116,25 +122,26 @@
|
|||
<div class="event-list-div scroll-custom">
|
||||
<mat-accordion [attr.id]="'events-' + session.connection.connectionId" class="event-list">
|
||||
<mat-expansion-panel *ngFor="let event of events" class="event-item">
|
||||
<mat-expansion-panel-header [attr.id]="event.name + '-' + session.connection.connectionId" [collapsedHeight]="'20px'" [expandedHeight]="'20px'"
|
||||
class="event-name">
|
||||
{{event.name}}
|
||||
<mat-expansion-panel-header [attr.id]="event.eventName + '-' + session.connection.connectionId"
|
||||
[collapsedHeight]="'20px'" [expandedHeight]="'20px'" class="event-name">
|
||||
{{event.eventName}}
|
||||
</mat-expansion-panel-header>
|
||||
<div class="event-content">{{event.content}}</div>
|
||||
<div class="event-content">{{event.eventContent}}</div>
|
||||
</mat-expansion-panel>
|
||||
</mat-accordion>
|
||||
</div>
|
||||
</div>
|
||||
<div [attr.id]="'remote-vid-' + session.connection.connectionId" fxFlex="240px" class="video-container">
|
||||
<div [attr.id]="'local-vid-' + session.connection.connectionId"></div>
|
||||
<app-video *ngIf="this.publisher" [streamManager]="this.publisher" [OV]="OV" [properties]="publisherProperties" (updateEventListInParent)="updateEventFromChild($event)">
|
||||
<app-video *ngIf="this.publisher" [streamManager]="this.publisher" [OV]="OV" [properties]="publisherProperties"
|
||||
(updateEventListInParent)="updateEventFromChild($event)">
|
||||
</app-video>
|
||||
<app-video *ngFor="let subscriber of this.subscribers" [streamManager]="subscriber" [OV]="OV" (updateEventListInParent)="updateEventFromChild($event)"
|
||||
(reSubbed)="updateSubscriberFromChild($event)">
|
||||
<app-video *ngFor="let subscriber of this.subscribers" [streamManager]="subscriber" [OV]="OV"
|
||||
(updateEventListInParent)="updateEventFromChild($event)" (reSubbed)="updateSubscriberFromChild($event)">
|
||||
</app-video>
|
||||
</div>
|
||||
</div>
|
||||
</mat-card>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -4,7 +4,7 @@ import {
|
|||
} from '@angular/core';
|
||||
|
||||
import {
|
||||
OpenVidu, Session, Subscriber, Publisher, VideoInsertMode, StreamEvent, ConnectionEvent,
|
||||
OpenVidu, Session, Subscriber, Publisher, Event, VideoInsertMode, StreamEvent, ConnectionEvent,
|
||||
SessionDisconnectedEvent, SignalEvent, RecordingEvent,
|
||||
PublisherSpeakingEvent, PublisherProperties, StreamPropertyChangedEvent, OpenViduError
|
||||
} from 'openvidu-browser';
|
||||
|
@ -36,8 +36,9 @@ export interface SessionConf {
|
|||
}
|
||||
|
||||
export interface OpenViduEvent {
|
||||
name: string;
|
||||
content: string;
|
||||
eventName: string;
|
||||
eventContent: string;
|
||||
event: Event;
|
||||
}
|
||||
|
||||
@Component({
|
||||
|
@ -249,9 +250,10 @@ export class OpenviduInstanceComponent implements OnInit, OnChanges, OnDestroy {
|
|||
this.subscribers = [];
|
||||
}
|
||||
|
||||
updateEventList(event: string, content: string) {
|
||||
this.events.push({ name: event, content: content });
|
||||
this.testFeedService.pushNewEvent(this.sessionName, this.session.connection.connectionId, event, content);
|
||||
updateEventList(eventName: string, eventContent: string, event: Event) {
|
||||
const eventInterface: OpenViduEvent = { eventName, eventContent, event };
|
||||
this.events.push(eventInterface);
|
||||
this.testFeedService.pushNewEvent(this.sessionName, this.session.connection.connectionId, event);
|
||||
}
|
||||
|
||||
toggleSubscribeTo(): void {
|
||||
|
@ -330,7 +332,7 @@ export class OpenviduInstanceComponent implements OnInit, OnChanges, OnDestroy {
|
|||
if (this.subscribeTo) {
|
||||
this.syncSubscribe(this.session, event);
|
||||
}
|
||||
this.updateEventList('streamCreated', event.stream.streamId);
|
||||
this.updateEventList('streamCreated', event.stream.streamId, event);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -343,7 +345,7 @@ export class OpenviduInstanceComponent implements OnInit, OnChanges, OnDestroy {
|
|||
if (index > -1) {
|
||||
this.subscribers.splice(index, 1);
|
||||
}
|
||||
this.updateEventList('streamDestroyed', event.stream.streamId);
|
||||
this.updateEventList('streamDestroyed', event.stream.streamId, event);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -358,7 +360,7 @@ export class OpenviduInstanceComponent implements OnInit, OnChanges, OnDestroy {
|
|||
} else {
|
||||
newValue = event.changedProperty === 'videoDimensions' ? JSON.stringify(event.newValue) : event.newValue.toString();
|
||||
}
|
||||
this.updateEventList('streamPropertyChanged', event.changedProperty + ' [' + newValue + ']');
|
||||
this.updateEventList('streamPropertyChanged', event.changedProperty + ' [' + newValue + ']', event);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -367,7 +369,7 @@ export class OpenviduInstanceComponent implements OnInit, OnChanges, OnDestroy {
|
|||
this.session.off('connectionCreated');
|
||||
if (this.sessionEvents.connectionCreated) {
|
||||
this.session.on('connectionCreated', (event: ConnectionEvent) => {
|
||||
this.updateEventList('connectionCreated', event.connection.connectionId);
|
||||
this.updateEventList('connectionCreated', event.connection.connectionId, event);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -377,7 +379,7 @@ export class OpenviduInstanceComponent implements OnInit, OnChanges, OnDestroy {
|
|||
if (this.sessionEvents.connectionDestroyed) {
|
||||
this.session.on('connectionDestroyed', (event: ConnectionEvent) => {
|
||||
delete this.subscribers[event.connection.connectionId];
|
||||
this.updateEventList('connectionDestroyed', event.connection.connectionId);
|
||||
this.updateEventList('connectionDestroyed', event.connection.connectionId, event);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -386,7 +388,7 @@ export class OpenviduInstanceComponent implements OnInit, OnChanges, OnDestroy {
|
|||
this.session.off('sessionDisconnected');
|
||||
if (this.sessionEvents.sessionDisconnected) {
|
||||
this.session.on('sessionDisconnected', (event: SessionDisconnectedEvent) => {
|
||||
this.updateEventList('sessionDisconnected', 'No data');
|
||||
this.updateEventList('sessionDisconnected', '', event);
|
||||
this.subscribers = [];
|
||||
delete this.publisher;
|
||||
delete this.session;
|
||||
|
@ -399,7 +401,7 @@ export class OpenviduInstanceComponent implements OnInit, OnChanges, OnDestroy {
|
|||
this.session.off('signal');
|
||||
if (this.sessionEvents.signal) {
|
||||
this.session.on('signal', (event: SignalEvent) => {
|
||||
this.updateEventList('signal', event.from.connectionId + '-' + event.data);
|
||||
this.updateEventList('signal', event.from.connectionId + '-' + event.data, event);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -408,7 +410,7 @@ export class OpenviduInstanceComponent implements OnInit, OnChanges, OnDestroy {
|
|||
this.session.off('recordingStarted');
|
||||
if (this.sessionEvents.recordingStarted) {
|
||||
this.session.on('recordingStarted', (event: RecordingEvent) => {
|
||||
this.updateEventList('recordingStarted', event.id);
|
||||
this.updateEventList('recordingStarted', event.id, event);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -417,7 +419,7 @@ export class OpenviduInstanceComponent implements OnInit, OnChanges, OnDestroy {
|
|||
this.session.off('recordingStopped');
|
||||
if (this.sessionEvents.recordingStopped) {
|
||||
this.session.on('recordingStopped', (event: RecordingEvent) => {
|
||||
this.updateEventList('recordingStopped', event.id);
|
||||
this.updateEventList('recordingStopped', event.id, event);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -426,7 +428,7 @@ export class OpenviduInstanceComponent implements OnInit, OnChanges, OnDestroy {
|
|||
this.session.off('publisherStartSpeaking');
|
||||
if (this.sessionEvents.publisherStartSpeaking) {
|
||||
this.session.on('publisherStartSpeaking', (event: PublisherSpeakingEvent) => {
|
||||
this.updateEventList('publisherStartSpeaking', event.connection.connectionId);
|
||||
this.updateEventList('publisherStartSpeaking', event.connection.connectionId, event);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -437,7 +439,7 @@ export class OpenviduInstanceComponent implements OnInit, OnChanges, OnDestroy {
|
|||
}
|
||||
if (this.sessionEvents.publisherStopSpeaking) {
|
||||
this.session.on('publisherStopSpeaking', (event: PublisherSpeakingEvent) => {
|
||||
this.updateEventList('publisherStopSpeaking', event.connection.connectionId);
|
||||
this.updateEventList('publisherStopSpeaking', event.connection.connectionId, event);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -656,8 +658,8 @@ export class OpenviduInstanceComponent implements OnInit, OnChanges, OnDestroy {
|
|||
});
|
||||
}
|
||||
|
||||
updateEventFromChild(event) {
|
||||
this.updateEventList(event.event, event.content);
|
||||
updateEventFromChild(event: OpenViduEvent) {
|
||||
this.updateEventList(event.eventName, event.eventContent, event.event);
|
||||
}
|
||||
|
||||
updateSubscriberFromChild(newSubscriber: Subscriber) {
|
||||
|
|
|
@ -38,7 +38,7 @@ export class TestSessionsComponent implements OnInit, OnDestroy {
|
|||
|
||||
this.eventsInfoSubscription = this.testFeedService.newLastEvent$.subscribe(
|
||||
newEvent => {
|
||||
(window as any).myEvents += ('<br>' + JSON.stringify(newEvent));
|
||||
(window as any).myEvents += ('<br>' + this.stringifyEventNoCircularDependencies(newEvent));
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -100,4 +100,28 @@ export class TestSessionsComponent implements OnInit, OnDestroy {
|
|||
this.loadSubs(subs);
|
||||
}
|
||||
|
||||
stringifyEventNoCircularDependencies(event: Event): string {
|
||||
const cache = [];
|
||||
return JSON.stringify(event, function (key, value) {
|
||||
if (key !== 'ee' && key !== 'openvidu') {
|
||||
if (typeof value === 'object' && value !== null) {
|
||||
if (cache.indexOf(value) !== -1) {
|
||||
// Duplicate reference found
|
||||
try {
|
||||
// If this value does not reference a parent
|
||||
return JSON.parse(JSON.stringify(value));
|
||||
} catch (error) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
// Store value in our collection
|
||||
cache.push(value);
|
||||
}
|
||||
return value;
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -10,7 +10,8 @@ import {
|
|||
OpenVidu,
|
||||
Publisher,
|
||||
StreamEvent,
|
||||
VideoInsertMode
|
||||
VideoInsertMode,
|
||||
FilterEvent
|
||||
} from 'openvidu-browser';
|
||||
|
||||
import { EventsDialogComponent } from '../dialogs/events-dialog/events-dialog.component';
|
||||
|
@ -19,6 +20,7 @@ import { Subscription } from 'rxjs';
|
|||
import { LocalRecordingDialogComponent } from '../dialogs/local-recording-dialog/local-recording-dialog.component';
|
||||
import { ExtensionDialogComponent } from '../dialogs/extension-dialog/extension-dialog.component';
|
||||
import { FilterDialogComponent } from '../dialogs/filter-dialog/filter-dialog.component';
|
||||
import { OpenViduEvent } from '../openvidu-instance/openvidu-instance.component';
|
||||
|
||||
@Component({
|
||||
selector: 'app-video',
|
||||
|
@ -32,7 +34,7 @@ export class VideoComponent implements OnInit, OnDestroy {
|
|||
@Input() OV: OpenVidu;
|
||||
@Input() eventCollection: any;
|
||||
|
||||
@Output() updateEventListInParent = new EventEmitter();
|
||||
@Output() updateEventListInParent = new EventEmitter<OpenViduEvent>();
|
||||
@Output() reSubbed = new EventEmitter();
|
||||
|
||||
subbed = true;
|
||||
|
@ -312,8 +314,9 @@ export class VideoComponent implements OnInit, OnDestroy {
|
|||
if (!oldValues.videoElementCreated) {
|
||||
sub.on('videoElementCreated', (event: VideoElementEvent) => {
|
||||
this.updateEventListInParent.emit({
|
||||
event: 'videoElementCreated',
|
||||
content: event.element.id
|
||||
eventName: 'videoElementCreated',
|
||||
eventContent: event.element.id,
|
||||
event
|
||||
});
|
||||
});
|
||||
}
|
||||
|
@ -326,8 +329,9 @@ export class VideoComponent implements OnInit, OnDestroy {
|
|||
sub.on('videoElementDestroyed', (event: VideoElementEvent) => {
|
||||
this.showButtons = false;
|
||||
this.updateEventListInParent.emit({
|
||||
event: 'videoElementDestroyed',
|
||||
content: event.element.id
|
||||
eventName: 'videoElementDestroyed',
|
||||
eventContent: event.element.id,
|
||||
event
|
||||
});
|
||||
});
|
||||
}
|
||||
|
@ -347,8 +351,9 @@ export class VideoComponent implements OnInit, OnDestroy {
|
|||
}
|
||||
this.showButtons = true;
|
||||
this.updateEventListInParent.emit({
|
||||
event: 'streamPlaying',
|
||||
content: this.streamManager.stream.streamId
|
||||
eventName: 'streamPlaying',
|
||||
eventContent: this.streamManager.stream.streamId,
|
||||
event
|
||||
});
|
||||
});
|
||||
}
|
||||
|
@ -360,8 +365,9 @@ export class VideoComponent implements OnInit, OnDestroy {
|
|||
if (!oldValues.streamAudioVolumeChange) {
|
||||
sub.on('streamAudioVolumeChange', (event: StreamManagerEvent) => {
|
||||
this.updateEventListInParent.emit({
|
||||
event: 'streamAudioVolumeChange',
|
||||
content: event.value['newValue']
|
||||
eventName: 'streamAudioVolumeChange',
|
||||
eventContent: event.value['newValue'],
|
||||
event
|
||||
});
|
||||
});
|
||||
}
|
||||
|
@ -371,11 +377,13 @@ export class VideoComponent implements OnInit, OnDestroy {
|
|||
|
||||
if (this.eventCollection.streamPropertyChanged) {
|
||||
if (!oldValues.streamPropertyChanged) {
|
||||
sub.on('streamPropertyChanged', (e: StreamPropertyChangedEvent) => {
|
||||
const newValue = e.changedProperty === 'videoDimensions' ? JSON.stringify(e.newValue) : e.newValue.toString();
|
||||
sub.on('streamPropertyChanged', (event: StreamPropertyChangedEvent) => {
|
||||
const newValue = event.changedProperty === 'videoDimensions' ?
|
||||
JSON.stringify(event.newValue) : event.newValue.toString();
|
||||
this.updateEventListInParent.emit({
|
||||
event: 'streamPropertyChanged',
|
||||
content: e.changedProperty + ' [' + newValue + ']'
|
||||
eventName: 'streamPropertyChanged',
|
||||
eventContent: event.changedProperty + ' [' + newValue + ']',
|
||||
event
|
||||
});
|
||||
});
|
||||
}
|
||||
|
@ -389,8 +397,9 @@ export class VideoComponent implements OnInit, OnDestroy {
|
|||
if (!oldValues.videoElementCreated) {
|
||||
pub.on('videoElementCreated', (event: VideoElementEvent) => {
|
||||
this.updateEventListInParent.emit({
|
||||
event: 'videoElementCreated',
|
||||
content: event.element.id
|
||||
eventName: 'videoElementCreated',
|
||||
eventContent: event.element.id,
|
||||
event
|
||||
});
|
||||
});
|
||||
}
|
||||
|
@ -400,10 +409,19 @@ export class VideoComponent implements OnInit, OnDestroy {
|
|||
|
||||
if (this.eventCollection.accessAllowed) {
|
||||
if (!oldValues.accessAllowed) {
|
||||
pub.on('accessAllowed', (e) => {
|
||||
pub.on('accessAllowed', () => {
|
||||
this.updateEventListInParent.emit({
|
||||
event: 'accessAllowed',
|
||||
content: ''
|
||||
eventName: 'accessAllowed',
|
||||
eventContent: '',
|
||||
event: {
|
||||
type: 'accessAllowed',
|
||||
target: pub,
|
||||
cancelable: false,
|
||||
hasBeenPrevented: false,
|
||||
isDefaultPrevented: () => false,
|
||||
preventDefault: () => { },
|
||||
callDefaultBehavior: () => { }
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
@ -413,10 +431,19 @@ export class VideoComponent implements OnInit, OnDestroy {
|
|||
|
||||
if (this.eventCollection.accessDenied) {
|
||||
if (!oldValues.accessDenied) {
|
||||
pub.on('accessDenied', (e) => {
|
||||
pub.on('accessDenied', (error) => {
|
||||
this.updateEventListInParent.emit({
|
||||
event: 'accessDenied',
|
||||
content: ''
|
||||
eventName: 'accessDenied',
|
||||
eventContent: JSON.stringify(error),
|
||||
event: {
|
||||
type: 'accessDenied',
|
||||
target: pub,
|
||||
cancelable: false,
|
||||
hasBeenPrevented: false,
|
||||
isDefaultPrevented: () => false,
|
||||
preventDefault: () => { },
|
||||
callDefaultBehavior: () => { }
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
@ -428,8 +455,17 @@ export class VideoComponent implements OnInit, OnDestroy {
|
|||
if (!oldValues.accessDialogOpened) {
|
||||
pub.on('accessDialogOpened', (e) => {
|
||||
this.updateEventListInParent.emit({
|
||||
event: 'accessDialogOpened',
|
||||
content: ''
|
||||
eventName: 'accessDialogOpened',
|
||||
eventContent: '',
|
||||
event: {
|
||||
type: 'accessDialogOpened',
|
||||
target: pub,
|
||||
cancelable: false,
|
||||
hasBeenPrevented: false,
|
||||
isDefaultPrevented: () => false,
|
||||
preventDefault: () => { },
|
||||
callDefaultBehavior: () => { }
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
@ -441,8 +477,17 @@ export class VideoComponent implements OnInit, OnDestroy {
|
|||
if (!oldValues.accessDialogClosed) {
|
||||
pub.on('accessDialogClosed', (e) => {
|
||||
this.updateEventListInParent.emit({
|
||||
event: 'accessDialogClosed',
|
||||
content: ''
|
||||
eventName: 'accessDialogClosed',
|
||||
eventContent: '',
|
||||
event: {
|
||||
type: 'accessDialogClosed',
|
||||
target: pub,
|
||||
cancelable: false,
|
||||
hasBeenPrevented: false,
|
||||
isDefaultPrevented: () => false,
|
||||
preventDefault: () => { },
|
||||
callDefaultBehavior: () => { }
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
@ -452,10 +497,11 @@ export class VideoComponent implements OnInit, OnDestroy {
|
|||
|
||||
if (this.eventCollection.streamCreated) {
|
||||
if (!oldValues.streamCreated) {
|
||||
pub.on('streamCreated', (e: StreamEvent) => {
|
||||
pub.on('streamCreated', (event: StreamEvent) => {
|
||||
this.updateEventListInParent.emit({
|
||||
event: 'streamCreated',
|
||||
content: e.stream.streamId
|
||||
eventName: 'streamCreated',
|
||||
eventContent: event.stream.streamId,
|
||||
event
|
||||
});
|
||||
});
|
||||
}
|
||||
|
@ -465,12 +511,13 @@ export class VideoComponent implements OnInit, OnDestroy {
|
|||
|
||||
if (this.eventCollection.streamDestroyed) {
|
||||
if (!oldValues.streamDestroyed) {
|
||||
pub.on('streamDestroyed', (e: StreamEvent) => {
|
||||
pub.on('streamDestroyed', (event: StreamEvent) => {
|
||||
this.updateEventListInParent.emit({
|
||||
event: 'streamDestroyed',
|
||||
content: e.stream.streamId
|
||||
eventName: 'streamDestroyed',
|
||||
eventContent: event.stream.streamId,
|
||||
event
|
||||
});
|
||||
if (e.reason.indexOf('forceUnpublish') !== -1) {
|
||||
if (event.reason.indexOf('forceUnpublish') !== -1) {
|
||||
this.unpublished = !this.unpublished;
|
||||
this.unpublished ? this.pubSubIcon = 'play_arrow' : this.pubSubIcon = 'stop';
|
||||
}
|
||||
|
@ -482,11 +529,13 @@ export class VideoComponent implements OnInit, OnDestroy {
|
|||
|
||||
if (this.eventCollection.streamPropertyChanged) {
|
||||
if (!oldValues.streamPropertyChanged) {
|
||||
pub.on('streamPropertyChanged', (e: StreamPropertyChangedEvent) => {
|
||||
const newValue = e.changedProperty === 'videoDimensions' ? JSON.stringify(e.newValue) : e.newValue.toString();
|
||||
pub.on('streamPropertyChanged', (event: StreamPropertyChangedEvent) => {
|
||||
const newValue = event.changedProperty === 'videoDimensions' ?
|
||||
JSON.stringify(event.newValue) : event.newValue.toString();
|
||||
this.updateEventListInParent.emit({
|
||||
event: 'streamPropertyChanged',
|
||||
content: e.changedProperty + ' [' + newValue + ']'
|
||||
eventName: 'streamPropertyChanged',
|
||||
eventContent: event.changedProperty + ' [' + newValue + ']',
|
||||
event
|
||||
});
|
||||
});
|
||||
}
|
||||
|
@ -496,10 +545,11 @@ export class VideoComponent implements OnInit, OnDestroy {
|
|||
|
||||
if (this.eventCollection.videoElementDestroyed) {
|
||||
if (!oldValues.videoElementDestroyed) {
|
||||
pub.on('videoElementDestroyed', (e: VideoElementEvent) => {
|
||||
pub.on('videoElementDestroyed', (event: VideoElementEvent) => {
|
||||
this.updateEventListInParent.emit({
|
||||
event: 'videoElementDestroyed',
|
||||
content: '(Publisher)'
|
||||
eventName: 'videoElementDestroyed',
|
||||
eventContent: '(Publisher)',
|
||||
event
|
||||
});
|
||||
});
|
||||
}
|
||||
|
@ -519,8 +569,9 @@ export class VideoComponent implements OnInit, OnDestroy {
|
|||
}
|
||||
this.showButtons = true;
|
||||
this.updateEventListInParent.emit({
|
||||
event: 'streamPlaying',
|
||||
content: pub.stream.streamId
|
||||
eventName: 'streamPlaying',
|
||||
eventContent: pub.stream.streamId,
|
||||
event
|
||||
});
|
||||
});
|
||||
}
|
||||
|
@ -532,8 +583,9 @@ export class VideoComponent implements OnInit, OnDestroy {
|
|||
if (!oldValues.streamAudioVolumeChange) {
|
||||
pub.on('streamAudioVolumeChange', (event: StreamManagerEvent) => {
|
||||
this.updateEventListInParent.emit({
|
||||
event: 'streamAudioVolumeChange',
|
||||
content: event.value['newValue']
|
||||
eventName: 'streamAudioVolumeChange',
|
||||
eventContent: event.value['newValue'],
|
||||
event
|
||||
});
|
||||
});
|
||||
}
|
||||
|
@ -667,10 +719,11 @@ export class VideoComponent implements OnInit, OnDestroy {
|
|||
});
|
||||
}
|
||||
|
||||
emitFilterEventToParent(event) {
|
||||
emitFilterEventToParent(event: FilterEvent) {
|
||||
this.updateEventListInParent.emit({
|
||||
event: 'filterEvent',
|
||||
content: event.data
|
||||
eventName: 'filterEvent',
|
||||
eventContent: JSON.stringify(event.data),
|
||||
event
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -1,10 +1,12 @@
|
|||
import { Injectable } from '@angular/core';
|
||||
import { Subject } from 'rxjs';
|
||||
|
||||
import { Event } from 'openvidu-browser';
|
||||
|
||||
@Injectable()
|
||||
export class TestFeedService {
|
||||
|
||||
lastEvent;
|
||||
lastEvent: Event;
|
||||
newLastEvent$ = new Subject<any>();
|
||||
|
||||
constructor() { }
|
||||
|
@ -13,8 +15,8 @@ export class TestFeedService {
|
|||
return this.lastEvent;
|
||||
}
|
||||
|
||||
pushNewEvent(session: string, connection: string, event: string, eventContent: string) {
|
||||
this.lastEvent = ({ session: session, connection: connection, event: event, eventContent: eventContent });
|
||||
pushNewEvent(session: string, connection: string, event: Event) {
|
||||
this.lastEvent = event;
|
||||
this.newLastEvent$.next(this.lastEvent);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue