openvidu-test-browsers: add "chromeFakeAudio"

pull/748/head
pabloFuente 2022-10-19 12:45:58 +02:00
parent cc8ac8d99d
commit ed82ab1241
4 changed files with 95 additions and 69 deletions

View File

@ -42,11 +42,22 @@ public class ChromeUser extends BrowserUser {
} }
public ChromeUser(String userName, int timeOfWaitInSeconds, Path fakeVideoLocation) { public ChromeUser(String userName, int timeOfWaitInSeconds, Path fakeVideoLocation) {
this(userName, timeOfWaitInSeconds, generateFakeVideoChromeOptions(fakeVideoLocation), true); this(userName, timeOfWaitInSeconds, generateFakeVideoAudioChromeOptions(fakeVideoLocation, null), true);
} }
public ChromeUser(String userName, int timeOfWaitInSeconds, Path fakeVideoLocation, boolean headless) { public ChromeUser(String userName, int timeOfWaitInSeconds, Path fakeVideoLocation, boolean headless) {
this(userName, timeOfWaitInSeconds, generateFakeVideoChromeOptions(fakeVideoLocation), headless); this(userName, timeOfWaitInSeconds, generateFakeVideoAudioChromeOptions(fakeVideoLocation, null), headless);
}
public ChromeUser(String userName, int timeOfWaitInSeconds, Path fakeVideoLocation, Path fakeAudioLocation) {
this(userName, timeOfWaitInSeconds, generateFakeVideoAudioChromeOptions(fakeVideoLocation, fakeAudioLocation),
true);
}
public ChromeUser(String userName, int timeOfWaitInSeconds, Path fakeVideoLocation, Path fakeAudioLocation,
boolean headless) {
this(userName, timeOfWaitInSeconds, generateFakeVideoAudioChromeOptions(fakeVideoLocation, fakeAudioLocation),
headless);
} }
private ChromeUser(String userName, int timeOfWaitInSeconds, ChromeOptions options, boolean headless) { private ChromeUser(String userName, int timeOfWaitInSeconds, ChromeOptions options, boolean headless) {
@ -106,14 +117,18 @@ public class ChromeUser extends BrowserUser {
return options; return options;
} }
private static ChromeOptions generateFakeVideoChromeOptions(Path videoFileLocation) { private static ChromeOptions generateFakeVideoAudioChromeOptions(Path videoFileLocation, Path audioFileLocation) {
ChromeOptions options = new ChromeOptions(); ChromeOptions options = new ChromeOptions();
// This flag avoids to grant the user media // This flag avoids to grant the user media
options.addArguments("--use-fake-ui-for-media-stream"); options.addArguments("--use-fake-ui-for-media-stream");
// This flag fakes user media with synthetic video // This flag fakes user media with synthetic video
options.addArguments("--use-fake-device-for-media-stream"); options.addArguments("--use-fake-device-for-media-stream");
// This flag sets the video input as if (videoFileLocation != null) {
options.addArguments("--use-file-for-fake-video-capture=" + videoFileLocation.toString()); 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; return options;
} }

View File

@ -123,6 +123,11 @@
<artifactId>testcontainers</artifactId> <artifactId>testcontainers</artifactId>
<version>${version.testcontainers}</version> <version>${version.testcontainers}</version>
</dependency> </dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-text</artifactId>
<version>${version.commons-text}</version>
</dependency>
</dependencies> </dependencies>
</project> </project>

View File

@ -335,6 +335,11 @@ public class OpenViduTestE2e {
setupBrowserAux(BrowserNames.CHROME, container, false); setupBrowserAux(BrowserNames.CHROME, container, false);
browserUser = new ChromeUser("TestUser", 50, Paths.get("/opt/openvidu/barcode.y4m")); browserUser = new ChromeUser("TestUser", 50, Paths.get("/opt/openvidu/barcode.y4m"));
break; 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": case "chromeVirtualBackgroundFakeVideo":
container = chromeContainer("selenium/standalone-chrome:" + CHROME_VERSION, 2147483648L, 1, false); container = chromeContainer("selenium/standalone-chrome:" + CHROME_VERSION, 2147483648L, 1, false);
setupBrowserAux(BrowserNames.CHROME, container, false); setupBrowserAux(BrowserNames.CHROME, container, false);

View File

@ -60,6 +60,7 @@
<version.unirest>1.4.9</version.unirest> <version.unirest>1.4.9</version.unirest>
<version.jcodec>0.2.5</version.jcodec> <version.jcodec>0.2.5</version.jcodec>
<version.commons-validator>1.7</version.commons-validator> <version.commons-validator>1.7</version.commons-validator>
<version.commons-text>1.10.0</version.commons-text>
<version.testcontainers>1.16.2</version.testcontainers> <version.testcontainers>1.16.2</version.testcontainers>
<version.appium>7.6.0</version.appium> <version.appium>7.6.0</version.appium>