diff --git a/bigbluebutton-html5/imports/ui/components/video-provider/video-list/video-list-item/component.jsx b/bigbluebutton-html5/imports/ui/components/video-provider/video-list/video-list-item/component.jsx index c500f626d21bf933ec5ce68cc68a70d3627dd08a..22e69bca86765410b26a1189c766a7bdf873a6e1 100755 --- a/bigbluebutton-html5/imports/ui/components/video-provider/video-list/video-list-item/component.jsx +++ b/bigbluebutton-html5/imports/ui/components/video-provider/video-list/video-list-item/component.jsx @@ -123,6 +123,7 @@ class VideoListItem extends Component { return ( <FullscreenButtonContainer + data-test="presentationFullscreenButton" fullscreenRef={this.videoContainer} elementName={name} isFullscreen={isFullscreen} diff --git a/bigbluebutton-html5/tests/puppeteer/webcam.test.js b/bigbluebutton-html5/tests/puppeteer/webcam.test.js index 5aa12d60b8864f37769e56fdcb4a91a6595d5d2b..d2497889b742f4e3ba0cf81878413478079732e8 100644 --- a/bigbluebutton-html5/tests/puppeteer/webcam.test.js +++ b/bigbluebutton-html5/tests/puppeteer/webcam.test.js @@ -1,6 +1,8 @@ const Share = require('./webcam/share'); +const Check = require('./webcam/check'); +const LoadingTime = require('./webcam/loadtime'); -describe('Webcam', () => { +describe('Webcams multiplayer', () => { test('Shares webcam', async () => { const test = new Share(); let response; @@ -14,4 +16,32 @@ describe('Webcam', () => { } expect(response).toBe(true); }); + + test('Check Webcam loading time', async () => { + const test = new LoadingTime(); + let response; + try { + await test.init(); + response = await test.test(); + } catch (e) { + console.log(e); + } finally { + await test.close(); + } + expect(response).toBeLessThan(parseInt(process.env.CAMERA_SHARE_FAILED_WAIT_TIME)); + }); + + test('Checks content of webcam', async () => { + const test = new Check(); + let response; + try { + await test.init(); + response = await test.test(); + } catch (e) { + console.log(e); + } finally { + await test.close(); + } + expect(response).toBe(true); + }); }); diff --git a/bigbluebutton-html5/tests/puppeteer/webcam/check.js b/bigbluebutton-html5/tests/puppeteer/webcam/check.js new file mode 100644 index 0000000000000000000000000000000000000000..5518825084fb4134a91690004ec85bf3b979f1f7 --- /dev/null +++ b/bigbluebutton-html5/tests/puppeteer/webcam/check.js @@ -0,0 +1,16 @@ +const Share = require('./share'); +const util = require('./util'); + +class Check extends Share { + constructor() { + super('check-webcam-content'); + } + + async test() { + const response1 = await util.startAndCheckForWebcams(this.page1); + const response2 = await util.startAndCheckForWebcams(this.page2); + const response = response1 && response2; + return response; + } +} +module.exports = exports = Check; diff --git a/bigbluebutton-html5/tests/puppeteer/webcam/elements.js b/bigbluebutton-html5/tests/puppeteer/webcam/elements.js index 26c23a44b938ae7c4620482c632c28417b3b0fd4..2f5ecf643175fc17914143b6ba256f8c896a8a99 100644 --- a/bigbluebutton-html5/tests/puppeteer/webcam/elements.js +++ b/bigbluebutton-html5/tests/puppeteer/webcam/elements.js @@ -2,3 +2,5 @@ exports.joinVideo = 'button[data-test="joinVideo"]'; exports.videoPreview = 'video[data-test="videoPreview"]'; exports.startSharingWebcam = 'button[data-test="startSharingWebcam"]'; exports.videoContainer = 'video[data-test="videoContainer"]'; +exports.webcamConnectingStatus = '[data-test="webcamConnectingStatus"]'; +exports.presentationFullscreenButton = '[data-test="presentationFullscreenButton"]'; diff --git a/bigbluebutton-html5/tests/puppeteer/webcam/loadtime.js b/bigbluebutton-html5/tests/puppeteer/webcam/loadtime.js new file mode 100644 index 0000000000000000000000000000000000000000..42ea167f41e1b2b15ade8e6731d40b5e22559ae9 --- /dev/null +++ b/bigbluebutton-html5/tests/puppeteer/webcam/loadtime.js @@ -0,0 +1,21 @@ +const Share = require('./share'); +const util = require('./util'); + +class LoadingTime extends Share { + constructor() { + super('check-webcam-loading-time'); + } + + async test() { + await util.enableWebcam(this.page1); + await util.enableWebcam(this.page2); + const now = new Date().getMilliseconds(); + await util.waitForWebcamsLoading(this.page1); + await util.waitForWebcamsLoading(this.page2); + const end = new Date().getMilliseconds(); + + const response = end - now; + return response; + } +} +module.exports = exports = LoadingTime; diff --git a/bigbluebutton-html5/tests/puppeteer/webcam/share.js b/bigbluebutton-html5/tests/puppeteer/webcam/share.js index 81cde5ebbe0e994a999899dab10f467e776e71f5..9b5a8e33b7f564f05219d764dd724c4d953c5ea0 100644 --- a/bigbluebutton-html5/tests/puppeteer/webcam/share.js +++ b/bigbluebutton-html5/tests/puppeteer/webcam/share.js @@ -14,9 +14,11 @@ class Share { } async test() { - await util.enableWebcam(this.page1, this.page2); - const response = await util.evaluateCheck(this.page1, this.page2); - return response; + await util.enableWebcam(this.page1); + await util.enableWebcam(this.page2); + const response1 = await util.evaluateCheck(this.page1); + const response2 = await util.evaluateCheck(this.page2); + return response1 && response2; } async close() { diff --git a/bigbluebutton-html5/tests/puppeteer/webcam/util.js b/bigbluebutton-html5/tests/puppeteer/webcam/util.js index a1fd33b24333c5554964eaaa6c8bc53b0658bfde..b1f49379028664c3379750220f060b3c223f93fc 100644 --- a/bigbluebutton-html5/tests/puppeteer/webcam/util.js +++ b/bigbluebutton-html5/tests/puppeteer/webcam/util.js @@ -3,10 +3,10 @@ const we = require('./elements'); async function enableWebcam(test) { // Enabling webcam await test.waitForSelector(we.joinVideo); - await test.click(we.joinVideo); + await test.click(we.joinVideo, true); await test.waitForSelector(we.videoPreview); await test.waitForSelector(we.startSharingWebcam); - await test.click(we.startSharingWebcam); + await test.click(we.startSharingWebcam, true); } async function getTestElement(element) { @@ -14,12 +14,58 @@ async function getTestElement(element) { } async function evaluateCheck(test) { - await test.waitForSelector(we.videoContainer); - const videoContainer = await test.page.evaluate(getTestElement, we.videoContainer); + const videoContainer = await test.page.evaluate(getTestElement, we.presentationFullscreenButton); const response = videoContainer !== null; return response; } +async function waitForWebcamsLoading(test) { + await test.waitForSelector(we.videoContainer); + await test.waitForSelector(we.webcamConnectingStatus); + await test.waitForSelector(we.presentationFullscreenButton); +} + +async function startAndCheckForWebcams(test) { + await enableWebcam(test); + await waitForWebcamsLoading(test); + const response = await evaluateCheck(test); + return response; +} + +async function webcamContentCheck(test) { + await waitForWebcamsLoading(test); + const repeats = 5; + let check; + for (let i = repeats; i >= 0; i--) { + const checkCameras = function (i) { + const videos = document.querySelectorAll('video'); + const lastVideoColor = document.lastVideoColor || {}; + document.lastVideoColor = lastVideoColor; + + for (let v = 0; v < videos.length; v++) { + const video = videos[v]; + const canvas = document.createElement('canvas'); + const context = canvas.getContext('2d'); + context.drawImage(video, 0, 0, video.videoWidth, video.videoHeight); + const pixel = context.getImageData(50, 50, 1, 1).data; + const pixelString = new Array(pixel).join(' ').toString(); + + if (lastVideoColor[v]) { + if (lastVideoColor[v] == pixelString) { + return false; + } + } + lastVideoColor[v] = pixelString; + } + return true; + }; + return check = await test.page.evaluate(checkCameras, i); + } +} + +exports.startAndCheckForWebcams = startAndCheckForWebcams; +exports.waitForWebcamsLoading = waitForWebcamsLoading; +exports.webcamContentCheck = webcamContentCheck; exports.evaluateCheck = evaluateCheck; exports.getTestElement = getTestElement; exports.enableWebcam = enableWebcam;