diff --git a/openvidu-test-browsers/src/main/java/io/openvidu/test/browsers/ChromeUser.java b/openvidu-test-browsers/src/main/java/io/openvidu/test/browsers/ChromeUser.java index b6fe64e1..3ffca920 100644 --- a/openvidu-test-browsers/src/main/java/io/openvidu/test/browsers/ChromeUser.java +++ b/openvidu-test-browsers/src/main/java/io/openvidu/test/browsers/ChromeUser.java @@ -51,7 +51,7 @@ public class ChromeUser extends BrowserUser { options.setUnhandledPromptBehaviour(UnexpectedAlertBehaviour.IGNORE); options.addArguments("--disable-infobars"); - options.setExperimentalOption("excludeSwitches", new String[]{"enable-automation"}); + options.setExperimentalOption("excludeSwitches", new String[] { "enable-automation" }); Map prefs = new HashMap(); prefs.put("profile.default_content_setting_values.media_stream_mic", 1); @@ -84,6 +84,9 @@ public class ChromeUser extends BrowserUser { // This flag selects the entire screen as video source when screen sharing options.addArguments("--auto-select-desktop-capture-source=Entire screen"); + // Background Chrome + // options.addArguments("--headless"); + if (runningAsRoot) { options.addArguments("--no-sandbox"); } diff --git a/openvidu-test-e2e/src/test/java/io/openvidu/test/e2e/OpenViduEventManager.java b/openvidu-test-e2e/src/test/java/io/openvidu/test/e2e/OpenViduEventManager.java index 63d453b4..4105fdab 100644 --- a/openvidu-test-e2e/src/test/java/io/openvidu/test/e2e/OpenViduEventManager.java +++ b/openvidu-test-e2e/src/test/java/io/openvidu/test/e2e/OpenViduEventManager.java @@ -83,6 +83,7 @@ public class OpenViduEventManager { private Map eventNumbers; private Map eventCountdowns; private AtomicBoolean isInterrupted = new AtomicBoolean(false); + private CountDownLatch pollingLatch = new CountDownLatch(1); private int timeOfWaitInSeconds; public OpenViduEventManager(WebDriver driver, int timeOfWaitInSeconds) { @@ -130,20 +131,21 @@ public class OpenViduEventManager { e.printStackTrace(); } } + log.info("Polling thread is now interrupted!"); + this.pollingLatch.countDown(); }); this.pollingThread.setUncaughtExceptionHandler(h); this.pollingThread.start(); } public void stopPolling(boolean stopThread) { - this.eventCallbacks.clear(); - this.eventCountdowns.clear(); - this.eventNumbers.clear(); - if (stopThread) { this.isInterrupted.set(true); this.pollingThread.interrupt(); } + this.eventCallbacks.clear(); + this.eventCountdowns.clear(); + this.eventNumbers.clear(); } public void on(String eventName, Consumer callback) { @@ -186,6 +188,26 @@ public class OpenViduEventManager { this.setCountDown(eventName, new CountDownLatch(0)); } + public synchronized void clearAllCurrentEvents() { + this.eventNumbers.keySet().forEach(eventName -> { + this.clearCurrentEvents(eventName); + }); + } + + public void resetEventThread() throws InterruptedException { + this.stopPolling(true); + this.pollingLatch.await(); + this.execService.shutdownNow(); + this.execService.awaitTermination(10, TimeUnit.SECONDS); + this.execService = Executors.newCachedThreadPool(); + this.stopPolling(false); + this.clearAllCurrentEvents(); + this.isInterrupted.set(false); + this.pollingLatch = new CountDownLatch(1); + this.eventQueue.clear(); + this.startPolling(); + } + public boolean assertMediaTracks(WebElement videoElement, boolean audioTransmission, boolean videoTransmission, String parentSelector) { return this.assertMediaTracks(Collections.singleton(videoElement), audioTransmission, videoTransmission, diff --git a/openvidu-test-e2e/src/test/java/io/openvidu/test/e2e/OpenViduTestAppE2eTest.java b/openvidu-test-e2e/src/test/java/io/openvidu/test/e2e/OpenViduTestAppE2eTest.java index 3980b7ad..dc47cd32 100644 --- a/openvidu-test-e2e/src/test/java/io/openvidu/test/e2e/OpenViduTestAppE2eTest.java +++ b/openvidu-test-e2e/src/test/java/io/openvidu/test/e2e/OpenViduTestAppE2eTest.java @@ -3068,13 +3068,14 @@ public class OpenViduTestAppE2eTest { } Thread.sleep(500); + user.getEventManager().resetEventThread(); user.getDriver().findElement(By.cssSelector("#openvidu-instance-1 .join-btn")).sendKeys(Keys.ENTER); - user.getEventManager().waitUntilEventReaches("connectionCreated", 5); - user.getEventManager().waitUntilEventReaches("accessAllowed", 3); - user.getEventManager().waitUntilEventReaches("streamCreated", 5); - user.getEventManager().waitUntilEventReaches("streamPlaying", 5); + user.getEventManager().waitUntilEventReaches("connectionCreated", 1); + user.getEventManager().waitUntilEventReaches("accessAllowed", 1); + user.getEventManager().waitUntilEventReaches("streamCreated", 1); + user.getEventManager().waitUntilEventReaches("streamPlaying", 1); // connectionId should be equal to the one brought by the token Assert.assertEquals("Wrong connectionId", tokenBConnectionId,