mirror of https://github.com/OpenVidu/openvidu.git
openvidu-test-e2e: improved e2e tests
parent
71598c2d7d
commit
e307af24e3
|
@ -130,7 +130,7 @@ public class OpenViduEventManager {
|
|||
this.getEventsFromBrowser();
|
||||
this.emitEvents();
|
||||
try {
|
||||
Thread.sleep(25);
|
||||
Thread.sleep(75);
|
||||
} catch (InterruptedException e) {
|
||||
}
|
||||
}
|
||||
|
@ -197,7 +197,7 @@ public class OpenViduEventManager {
|
|||
CountDownLatch eventSignal = new CountDownLatch(eventNumber);
|
||||
this.setCountDown(eventType + "-" + eventCategory, eventSignal);
|
||||
try {
|
||||
if (!eventSignal.await(secondsOfWait * 1000, TimeUnit.MILLISECONDS)) {
|
||||
if (!eventSignal.await(secondsOfWait, TimeUnit.SECONDS)) {
|
||||
if (printTimeoutError) {
|
||||
String screenshot = "data:image/png;base64," + ((TakesScreenshot) driver).getScreenshotAs(BASE64);
|
||||
System.out.println("TIMEOUT SCREENSHOT");
|
||||
|
@ -218,7 +218,7 @@ public class OpenViduEventManager {
|
|||
CountDownLatch eventSignal = new CountDownLatch(eventNumber);
|
||||
this.setCountDown(numberOfUser, eventType + "-" + eventCategory, eventSignal);
|
||||
try {
|
||||
if (!eventSignal.await(secondsOfWait * 1000, TimeUnit.MILLISECONDS)) {
|
||||
if (!eventSignal.await(secondsOfWait, TimeUnit.SECONDS)) {
|
||||
if (printTimeoutError) {
|
||||
String screenshot = "data:image/png;base64," + ((TakesScreenshot) driver).getScreenshotAs(BASE64);
|
||||
System.out.println("TIMEOUT SCREENSHOT");
|
||||
|
|
|
@ -37,6 +37,8 @@ import io.openvidu.test.browsers.EdgeUser;
|
|||
import io.openvidu.test.browsers.FirefoxUser;
|
||||
import io.openvidu.test.browsers.utils.BrowserNames;
|
||||
import io.openvidu.test.browsers.utils.CommandLineExecutor;
|
||||
import livekit.LivekitModels.Room;
|
||||
import retrofit2.Response;
|
||||
|
||||
public class OpenViduTestE2e {
|
||||
|
||||
|
@ -383,8 +385,23 @@ public class OpenViduTestE2e {
|
|||
|
||||
protected void closeAllRooms(RoomServiceClient client) {
|
||||
try {
|
||||
client.listRooms().execute().body().forEach(r -> client.deleteRoom(r.getName()));
|
||||
} catch (IOException e) {
|
||||
Response<List<Room>> response = client.listRooms().execute();
|
||||
if (response.isSuccessful()) {
|
||||
List<Room> roomList = response.body();
|
||||
if (roomList != null) {
|
||||
client.listRooms().execute().body().forEach(r -> {
|
||||
log.info("Closing existing room " + r.getName());
|
||||
try {
|
||||
log.info("Response: " + client.deleteRoom(r.getName()).execute().code());
|
||||
} catch (IOException e) {
|
||||
log.error("Error closing room " + r.getName(), e);
|
||||
}
|
||||
});
|
||||
}
|
||||
} else {
|
||||
log.error("Error listing rooms: " + response.errorBody());
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("Error closing rooms: {}", e.getMessage());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -40,7 +40,7 @@ public class AbstractOpenViduTestappE2eTest extends OpenViduTestE2e {
|
|||
protected void gracefullyLeaveParticipants(OpenViduTestappUser user, int numberOfParticipants) throws Exception {
|
||||
int accumulatedDisconnected = 0;
|
||||
for (int j = 1; j <= numberOfParticipants; j++) {
|
||||
user.getDriver().findElement(By.id("remove-user-btn")).sendKeys(Keys.ENTER);
|
||||
user.getDriver().findElement(By.className("disconnect-btn")).sendKeys(Keys.ENTER);
|
||||
user.getEventManager().waitUntilEventReaches("disconnected", "RoomEvent", j);
|
||||
accumulatedDisconnected = (j != numberOfParticipants) ? (accumulatedDisconnected + numberOfParticipants - j)
|
||||
: (accumulatedDisconnected);
|
||||
|
|
|
@ -21,6 +21,7 @@ import java.util.concurrent.CountDownLatch;
|
|||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.function.BiFunction;
|
||||
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
|
@ -57,6 +58,11 @@ public class OpenViduTestAppE2eTest extends AbstractOpenViduTestappE2eTest {
|
|||
this.closeAllRooms(LK);
|
||||
}
|
||||
|
||||
@AfterEach()
|
||||
protected void finishEach() {
|
||||
this.closeAllRooms(LK);
|
||||
}
|
||||
|
||||
@Test
|
||||
@DisplayName("One2One Chrome")
|
||||
void oneToOneChrome() throws Exception {
|
||||
|
@ -86,13 +92,18 @@ public class OpenViduTestAppE2eTest extends AbstractOpenViduTestappE2eTest {
|
|||
user.getDriver().findElement(By.id("one2one-btn")).click();
|
||||
user.getEventManager().waitUntilEventReaches("signalConnected", "RoomEvent", 2);
|
||||
user.getEventManager().waitUntilEventReaches("connected", "RoomEvent", 2);
|
||||
user.getEventManager().waitUntilEventReaches("connectionStateChanged", "RoomEvent", 2);
|
||||
user.getEventManager().waitUntilEventReaches("localTrackPublished", "RoomEvent", 4);
|
||||
user.getEventManager().waitUntilEventReaches("localTrackPublished", "ParticipantEvent", 4);
|
||||
user.getEventManager().waitUntilEventReaches("localTrackSubscribed", "RoomEvent", 4);
|
||||
user.getEventManager().waitUntilEventReaches("localTrackSubscribed", "ParticipantEvent", 4);
|
||||
user.getEventManager().waitUntilEventReaches("trackSubscribed", "RoomEvent", 4);
|
||||
user.getEventManager().waitUntilEventReaches("trackSubscribed", "ParticipantEvent", 4);
|
||||
user.getEventManager().waitUntilEventReaches("trackSubscriptionStatusChanged", "RoomEvent", 8);
|
||||
user.getEventManager().waitUntilEventReaches("trackStreamStateChanged", "RoomEvent", 2);
|
||||
user.getEventManager().waitUntilEventReaches("trackStreamStateChanged", "ParticipantEvent", 2);
|
||||
// user.getEventManager().waitUntilEventReaches("trackStreamStateChanged",
|
||||
// "RoomEvent", 2);
|
||||
// user.getEventManager().waitUntilEventReaches("trackStreamStateChanged",
|
||||
// "ParticipantEvent", 2);
|
||||
|
||||
user.getWaiter().until(ExpectedConditions.numberOfElementsToBe(By.tagName("video"), 4));
|
||||
user.getWaiter().until(ExpectedConditions.numberOfElementsToBe(By.tagName("audio"), 4));
|
||||
|
@ -130,6 +141,7 @@ public class OpenViduTestAppE2eTest extends AbstractOpenViduTestappE2eTest {
|
|||
|
||||
user.getEventManager().waitUntilEventReaches("connected", "RoomEvent", 2);
|
||||
user.getEventManager().waitUntilEventReaches("localTrackPublished", "RoomEvent", 2);
|
||||
user.getEventManager().waitUntilEventReaches("localTrackSubscribed", "RoomEvent", 2);
|
||||
user.getEventManager().waitUntilEventReaches("trackSubscribed", "RoomEvent", 2);
|
||||
|
||||
final int numberOfVideos = user.getDriver().findElements(By.tagName("video")).size();
|
||||
|
@ -165,6 +177,7 @@ public class OpenViduTestAppE2eTest extends AbstractOpenViduTestappE2eTest {
|
|||
|
||||
user.getEventManager().waitUntilEventReaches("connected", "RoomEvent", 2);
|
||||
user.getEventManager().waitUntilEventReaches("localTrackPublished", "RoomEvent", 2);
|
||||
user.getEventManager().waitUntilEventReaches("localTrackSubscribed", "RoomEvent", 2);
|
||||
user.getEventManager().waitUntilEventReaches("trackSubscribed", "RoomEvent", 2);
|
||||
|
||||
final int numberOfAudios = user.getDriver().findElements(By.tagName("audio")).size();
|
||||
|
@ -198,6 +211,7 @@ public class OpenViduTestAppE2eTest extends AbstractOpenViduTestappE2eTest {
|
|||
user.getEventManager().waitUntilEventReaches("signalConnected", "RoomEvent", USERS);
|
||||
user.getEventManager().waitUntilEventReaches("connected", "RoomEvent", USERS);
|
||||
user.getEventManager().waitUntilEventReaches("localTrackPublished", "RoomEvent", 2);
|
||||
user.getEventManager().waitUntilEventReaches("localTrackSubscribed", "RoomEvent", 2);
|
||||
user.getEventManager().waitUntilEventReaches("trackSubscribed", "RoomEvent", (SUBSCRIBERS) * 2);
|
||||
|
||||
user.getWaiter().until(ExpectedConditions.numberOfElementsToBe(By.tagName("video"), USERS));
|
||||
|
@ -233,6 +247,7 @@ public class OpenViduTestAppE2eTest extends AbstractOpenViduTestappE2eTest {
|
|||
user.getEventManager().waitUntilEventReaches("signalConnected", "RoomEvent", 4);
|
||||
user.getEventManager().waitUntilEventReaches("connected", "RoomEvent", 4);
|
||||
user.getEventManager().waitUntilEventReaches("localTrackPublished", "RoomEvent", 8);
|
||||
user.getEventManager().waitUntilEventReaches("localTrackSubscribed", "RoomEvent", 8);
|
||||
user.getEventManager().waitUntilEventReaches("trackSubscribed", "RoomEvent", 24);
|
||||
|
||||
user.getWaiter().until(ExpectedConditions.numberOfElementsToBe(By.tagName("video"), 16));
|
||||
|
@ -271,8 +286,7 @@ public class OpenViduTestAppE2eTest extends AbstractOpenViduTestappE2eTest {
|
|||
user.getEventManager().waitUntilEventReaches("signalConnected", "RoomEvent", NUMBER_OF_USERS);
|
||||
user.getEventManager().waitUntilEventReaches("connected", "RoomEvent", NUMBER_OF_USERS);
|
||||
user.getEventManager().waitUntilEventReaches("localTrackPublished", "RoomEvent", NUMBER_OF_USERS * 2);
|
||||
user.getEventManager().waitUntilEventReaches("trackPublished", "RoomEvent",
|
||||
(NUMBER_OF_USERS) * (NUMBER_OF_USERS - 1) * 2);
|
||||
user.getEventManager().waitUntilEventReaches("localTrackSubscribed", "RoomEvent", NUMBER_OF_USERS * 2);
|
||||
user.getEventManager().waitUntilEventReaches("trackSubscribed", "RoomEvent",
|
||||
(NUMBER_OF_USERS) * (NUMBER_OF_USERS - 1) * 2);
|
||||
|
||||
|
@ -315,8 +329,10 @@ public class OpenViduTestAppE2eTest extends AbstractOpenViduTestappE2eTest {
|
|||
user.getEventManager().waitUntilEventReaches("signalConnected", "RoomEvent", 1, 100, true);
|
||||
user.getEventManager().waitUntilEventReaches("connected", "RoomEvent", 1);
|
||||
user.getEventManager().waitUntilEventReaches("localTrackPublished", "RoomEvent", 2);
|
||||
user.getEventManager().waitUntilEventReaches("localTrackSubscribed", "RoomEvent", 2);
|
||||
user.getEventManager().waitUntilEventReaches("trackSubscribed", "RoomEvent", 4);
|
||||
user.getEventManager().waitUntilEventReaches("trackStreamStateChanged", "RoomEvent", 2);
|
||||
// user.getEventManager().waitUntilEventReaches("trackStreamStateChanged",
|
||||
// "RoomEvent", 2);
|
||||
|
||||
user.getWaiter().until(ExpectedConditions.numberOfElementsToBe(By.tagName("video"), 3));
|
||||
user.getWaiter().until(ExpectedConditions.numberOfElementsToBe(By.tagName("audio"), 3));
|
||||
|
|
|
@ -982,6 +982,29 @@ export class OpenviduInstanceComponent {
|
|||
);
|
||||
}
|
||||
}
|
||||
|
||||
if (
|
||||
firstTime ||
|
||||
this.roomEvents.get(RoomEvent.LocalTrackSubscribed) !==
|
||||
oldValues.get(RoomEvent.LocalTrackSubscribed)
|
||||
) {
|
||||
this.room?.removeAllListeners(RoomEvent.LocalTrackSubscribed);
|
||||
if (this.roomEvents.get(RoomEvent.LocalTrackSubscribed)) {
|
||||
this.room!.on(
|
||||
RoomEvent.LocalTrackSubscribed,
|
||||
(
|
||||
publication: LocalTrackPublication,
|
||||
participant: LocalParticipant
|
||||
) => {
|
||||
this.updateEventList(
|
||||
RoomEvent.LocalTrackSubscribed,
|
||||
{ publication, participant },
|
||||
`${publication.source}`
|
||||
);
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
updateEventList(
|
||||
|
|
|
@ -335,7 +335,12 @@ export class ParticipantComponent {
|
|||
)
|
||||
|
||||
.on(ParticipantEvent.IsSpeakingChanged, (speaking: boolean) => {
|
||||
// this.updateEventList(ParticipantEvent.IsSpeakingChanged, 'ParticipantEvent', { speaking }, `${speaking}`);
|
||||
this.updateEventList(
|
||||
ParticipantEvent.IsSpeakingChanged,
|
||||
'ParticipantEvent',
|
||||
{ speaking },
|
||||
`${speaking}`
|
||||
);
|
||||
})
|
||||
|
||||
.on(
|
||||
|
@ -416,6 +421,18 @@ export class ParticipantComponent {
|
|||
`${publication.source}: ${status}`
|
||||
);
|
||||
}
|
||||
)
|
||||
|
||||
.on(
|
||||
ParticipantEvent.LocalTrackSubscribed,
|
||||
(trackPublication: LocalTrackPublication) => {
|
||||
this.updateEventList(
|
||||
ParticipantEvent.LocalTrackSubscribed,
|
||||
'ParticipantEvent',
|
||||
{ trackPublication },
|
||||
trackPublication.source
|
||||
);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -233,6 +233,10 @@ export class TestScenariosComponent implements OnInit, OnDestroy {
|
|||
this.updateEventList(RoomEvent.LocalTrackPublished);
|
||||
});
|
||||
|
||||
room.on(RoomEvent.LocalTrackSubscribed, () => {
|
||||
this.updateEventList(RoomEvent.LocalTrackSubscribed);
|
||||
});
|
||||
|
||||
room.on(RoomEvent.TrackSubscribed, () => {
|
||||
this.updateEventList(RoomEvent.TrackSubscribed);
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue