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 c143e10d..25d39c06 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 @@ -32,89 +32,104 @@ import org.openqa.selenium.remote.RemoteWebDriver; public class ChromeUser extends BrowserUser { - public ChromeUser(String userName, int timeOfWaitInSeconds, boolean headless) { - this(userName, timeOfWaitInSeconds, generateDefaultScreenChromeOptions(), headless); - } + public ChromeUser(String userName, int timeOfWaitInSeconds, boolean headless) { + this(userName, timeOfWaitInSeconds, generateDefaultScreenChromeOptions(), headless); + } - public ChromeUser(String userName, int timeOfWaitInSeconds, String screenToCapture) { - this(userName, timeOfWaitInSeconds, - generateCustomScreenChromeOptions(screenToCapture, Paths.get("/opt/openvidu/fakeaudio.wav")), false); - } + public ChromeUser(String userName, int timeOfWaitInSeconds, String screenToCapture) { + this(userName, timeOfWaitInSeconds, + generateCustomScreenChromeOptions(screenToCapture, Paths.get("/opt/openvidu/fakeaudio.wav")), false); + } - public ChromeUser(String userName, int timeOfWaitInSeconds, Path fakeVideoLocation) { - this(userName, timeOfWaitInSeconds, generateFakeVideoChromeOptions(fakeVideoLocation), true); - } + public ChromeUser(String userName, int timeOfWaitInSeconds, Path fakeVideoLocation) { + this(userName, timeOfWaitInSeconds, generateFakeVideoAudioChromeOptions(fakeVideoLocation, null), true); + } - public ChromeUser(String userName, int timeOfWaitInSeconds, Path fakeVideoLocation, boolean headless) { - this(userName, timeOfWaitInSeconds, generateFakeVideoChromeOptions(fakeVideoLocation), headless); - } + public ChromeUser(String userName, int timeOfWaitInSeconds, Path fakeVideoLocation, boolean headless) { + this(userName, timeOfWaitInSeconds, generateFakeVideoAudioChromeOptions(fakeVideoLocation, null), headless); + } - private ChromeUser(String userName, int timeOfWaitInSeconds, ChromeOptions options, boolean headless) { - super(userName, timeOfWaitInSeconds); + public ChromeUser(String userName, int timeOfWaitInSeconds, Path fakeVideoLocation, Path fakeAudioLocation) { + this(userName, timeOfWaitInSeconds, generateFakeVideoAudioChromeOptions(fakeVideoLocation, fakeAudioLocation), + true); + } - String REMOTE_URL = System.getProperty("REMOTE_URL_CHROME"); + public ChromeUser(String userName, int timeOfWaitInSeconds, Path fakeVideoLocation, Path fakeAudioLocation, + boolean headless) { + this(userName, timeOfWaitInSeconds, generateFakeVideoAudioChromeOptions(fakeVideoLocation, fakeAudioLocation), + headless); + } - options.setAcceptInsecureCerts(true); - options.setUnhandledPromptBehaviour(UnexpectedAlertBehaviour.IGNORE); + private ChromeUser(String userName, int timeOfWaitInSeconds, ChromeOptions options, boolean headless) { + super(userName, timeOfWaitInSeconds); - if (REMOTE_URL != null && headless) { - options.setHeadless(true); - } + String REMOTE_URL = System.getProperty("REMOTE_URL_CHROME"); - options.addArguments("--disable-infobars"); - options.setExperimentalOption("excludeSwitches", new String[] { "enable-automation" }); + options.setAcceptInsecureCerts(true); + options.setUnhandledPromptBehaviour(UnexpectedAlertBehaviour.IGNORE); - Map prefs = new HashMap(); - prefs.put("profile.default_content_setting_values.media_stream_mic", 1); - prefs.put("profile.default_content_setting_values.media_stream_camera", 1); - options.setExperimentalOption("prefs", prefs); + if (REMOTE_URL != null && headless) { + options.setHeadless(true); + } - if (REMOTE_URL != null) { - log.info("Using URL {} to connect to remote web driver", REMOTE_URL); - try { - this.driver = new RemoteWebDriver(new URL(REMOTE_URL), options); - } catch (MalformedURLException e) { - e.printStackTrace(); - } - } else { - log.info("Using local web driver"); - this.driver = new ChromeDriver(options); - } + options.addArguments("--disable-infobars"); + options.setExperimentalOption("excludeSwitches", new String[] { "enable-automation" }); - this.driver.manage().timeouts().setScriptTimeout(timeOfWaitInSeconds, TimeUnit.SECONDS); - this.configureDriver(new org.openqa.selenium.Dimension(1920, 1080)); - } + Map prefs = new HashMap(); + prefs.put("profile.default_content_setting_values.media_stream_mic", 1); + prefs.put("profile.default_content_setting_values.media_stream_camera", 1); + options.setExperimentalOption("prefs", prefs); - private static ChromeOptions generateDefaultScreenChromeOptions() { - ChromeOptions options = new ChromeOptions(); - // This flag avoids to grant the user media - options.addArguments("--use-fake-ui-for-media-stream"); - // This flag fakes user media with synthetic video - options.addArguments("--use-fake-device-for-media-stream"); - // This flag selects the entire screen as video source when screen sharing - options.addArguments("--auto-select-desktop-capture-source=Entire screen"); - return options; - } + if (REMOTE_URL != null) { + log.info("Using URL {} to connect to remote web driver", REMOTE_URL); + try { + this.driver = new RemoteWebDriver(new URL(REMOTE_URL), options); + } catch (MalformedURLException e) { + e.printStackTrace(); + } + } else { + log.info("Using local web driver"); + this.driver = new ChromeDriver(options); + } - private static ChromeOptions generateCustomScreenChromeOptions(String screenToCapture, Path audioFileLocation) { - ChromeOptions options = new ChromeOptions(); - // This flag selects the entire screen as video source when screen sharing - options.addArguments("--auto-select-desktop-capture-source=" + screenToCapture); - options.addArguments("--use-fake-device-for-media-stream"); - options.addArguments("--use-file-for-fake-audio-capture=" + audioFileLocation.toString()); + this.driver.manage().timeouts().setScriptTimeout(timeOfWaitInSeconds, TimeUnit.SECONDS); + this.configureDriver(new org.openqa.selenium.Dimension(1920, 1080)); + } - return options; - } + private static ChromeOptions generateDefaultScreenChromeOptions() { + ChromeOptions options = new ChromeOptions(); + // This flag avoids to grant the user media + options.addArguments("--use-fake-ui-for-media-stream"); + // This flag fakes user media with synthetic video + options.addArguments("--use-fake-device-for-media-stream"); + // This flag selects the entire screen as video source when screen sharing + options.addArguments("--auto-select-desktop-capture-source=Entire screen"); + return options; + } - private static ChromeOptions generateFakeVideoChromeOptions(Path videoFileLocation) { - ChromeOptions options = new ChromeOptions(); - // This flag avoids to grant the user media - options.addArguments("--use-fake-ui-for-media-stream"); - // This flag fakes user media with synthetic video - options.addArguments("--use-fake-device-for-media-stream"); - // This flag sets the video input as - options.addArguments("--use-file-for-fake-video-capture=" + videoFileLocation.toString()); - return options; - } + private static ChromeOptions generateCustomScreenChromeOptions(String screenToCapture, Path audioFileLocation) { + ChromeOptions options = new ChromeOptions(); + // This flag selects the entire screen as video source when screen sharing + options.addArguments("--auto-select-desktop-capture-source=" + screenToCapture); + options.addArguments("--use-fake-device-for-media-stream"); + options.addArguments("--use-file-for-fake-audio-capture=" + audioFileLocation.toString()); + + return options; + } + + private static ChromeOptions generateFakeVideoAudioChromeOptions(Path videoFileLocation, Path audioFileLocation) { + ChromeOptions options = new ChromeOptions(); + // This flag avoids to grant the user media + options.addArguments("--use-fake-ui-for-media-stream"); + // This flag fakes user media with synthetic video + options.addArguments("--use-fake-device-for-media-stream"); + if (videoFileLocation != null) { + options.addArguments("--use-file-for-fake-video-capture=" + videoFileLocation.toString()); + } + if (audioFileLocation != null) { + options.addArguments("--use-file-for-fake-audio-capture=" + audioFileLocation.toString()); + } + return options; + } } \ No newline at end of file diff --git a/openvidu-test-e2e/pom.xml b/openvidu-test-e2e/pom.xml index 37263637..e535e3b4 100644 --- a/openvidu-test-e2e/pom.xml +++ b/openvidu-test-e2e/pom.xml @@ -123,6 +123,11 @@ testcontainers ${version.testcontainers} + + org.apache.commons + commons-text + ${version.commons-text} + diff --git a/openvidu-test-e2e/src/main/java/io/openvidu/test/e2e/OpenViduTestE2e.java b/openvidu-test-e2e/src/main/java/io/openvidu/test/e2e/OpenViduTestE2e.java index ccf7eb1e..0ceeffb1 100644 --- a/openvidu-test-e2e/src/main/java/io/openvidu/test/e2e/OpenViduTestE2e.java +++ b/openvidu-test-e2e/src/main/java/io/openvidu/test/e2e/OpenViduTestE2e.java @@ -335,6 +335,11 @@ public class OpenViduTestE2e { setupBrowserAux(BrowserNames.CHROME, container, false); browserUser = new ChromeUser("TestUser", 50, Paths.get("/opt/openvidu/barcode.y4m")); break; + case "chromeFakeAudio": + container = chromeContainer("selenium/standalone-chrome:" + CHROME_VERSION, 2147483648L, 1, true); + setupBrowserAux(BrowserNames.CHROME, container, false); + browserUser = new ChromeUser("TestUser", 50, null, Paths.get("/opt/openvidu/stt-test2.wav")); + break; case "chromeVirtualBackgroundFakeVideo": container = chromeContainer("selenium/standalone-chrome:" + CHROME_VERSION, 2147483648L, 1, false); setupBrowserAux(BrowserNames.CHROME, container, false); diff --git a/pom.xml b/pom.xml index c805d4d4..b41ce668 100644 --- a/pom.xml +++ b/pom.xml @@ -60,6 +60,7 @@ 1.4.9 0.2.5 1.7 + 1.10.0 1.16.2 7.6.0