openvidu-test-e2e: configure fake audio in ChromeUser

pull/255/head
pabloFuente 2019-02-25 15:20:30 +01:00
parent b3f61dfe9d
commit a5e22ad92a
1 changed files with 9 additions and 2 deletions

View File

@ -20,6 +20,7 @@ package io.openvidu.test.e2e.browser;
import java.net.MalformedURLException; import java.net.MalformedURLException;
import java.net.URL; import java.net.URL;
import java.nio.file.Path; import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
@ -35,7 +36,8 @@ public class ChromeUser extends BrowserUser {
} }
public ChromeUser(String userName, int timeOfWaitInSeconds, String screenToCapture, boolean runningAsRoot) { public ChromeUser(String userName, int timeOfWaitInSeconds, String screenToCapture, boolean runningAsRoot) {
this(userName, timeOfWaitInSeconds, generateCustomScreenChromeOptions(screenToCapture, runningAsRoot)); this(userName, timeOfWaitInSeconds, generateCustomScreenChromeOptions(screenToCapture, runningAsRoot,
Paths.get("/opt/openvidu/fakeaudio.wav")));
} }
public ChromeUser(String userName, int timeOfWaitInSeconds, Path fakeVideoLocation) { public ChromeUser(String userName, int timeOfWaitInSeconds, Path fakeVideoLocation) {
@ -45,6 +47,8 @@ public class ChromeUser extends BrowserUser {
private ChromeUser(String userName, int timeOfWaitInSeconds, ChromeOptions options) { private ChromeUser(String userName, int timeOfWaitInSeconds, ChromeOptions options) {
super(userName, timeOfWaitInSeconds); super(userName, timeOfWaitInSeconds);
options.setAcceptInsecureCerts(true); options.setAcceptInsecureCerts(true);
options.addArguments("--disable-infobars");
Map<String, Object> prefs = new HashMap<String, Object>(); Map<String, Object> prefs = new HashMap<String, Object>();
prefs.put("profile.default_content_setting_values.media_stream_mic", 1); prefs.put("profile.default_content_setting_values.media_stream_mic", 1);
@ -84,10 +88,13 @@ public class ChromeUser extends BrowserUser {
return options; return options;
} }
private static ChromeOptions generateCustomScreenChromeOptions(String screenToCapture, boolean runningAsRoot) { private static ChromeOptions generateCustomScreenChromeOptions(String screenToCapture, boolean runningAsRoot,
Path audioFileLocation) {
ChromeOptions options = new ChromeOptions(); ChromeOptions options = new ChromeOptions();
// This flag selects the entire screen as video source when screen sharing // This flag selects the entire screen as video source when screen sharing
options.addArguments("--auto-select-desktop-capture-source=" + screenToCapture); 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());
if (runningAsRoot) { if (runningAsRoot) {
options.addArguments("--no-sandbox"); options.addArguments("--no-sandbox");