From 3c8b943a025d8def8dc8b47a4a9aae971535478f Mon Sep 17 00:00:00 2001 From: Ashish Date: Fri, 13 Oct 2023 13:10:50 +0530 Subject: [PATCH] added mocap tests --- src/bot/bot-class.ts | 81 +++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 76 insertions(+), 5 deletions(-) mode change 100755 => 100644 src/bot/bot-class.ts diff --git a/src/bot/bot-class.ts b/src/bot/bot-class.ts old mode 100755 new mode 100644 index e200fdd..c9c29f6 --- a/src/bot/bot-class.ts +++ b/src/bot/bot-class.ts @@ -10,6 +10,7 @@ import { BotUserAgent } from '@etherealengine/common/src/constants/BotUserAgent' import { getOS } from './utils/getOS' import { makeAdmin } from './utils/make-user-admin' import { PageUtils } from './utils/pageUtils' +import { Timeout } from '@feathersjs/errors' type BotProps = { verbose?: Boolean @@ -61,6 +62,76 @@ export class EtherealEngineBot { // } } + async enableCameraForMotionCapture() { + const motionCaptureButton = await this.page.waitForSelector('#UserPoseTracking', { timeout: 5000 }).catch(() => null) + if (motionCaptureButton) { + await motionCaptureButton.click(); + await this.delay(3000) + + const pages = await this.browser.pages() + const newPage = pages[pages.length - 1] + await this.delay(5000) + + const captureButton = await newPage.waitForSelector('button[data-tip="Capture"]', { timeout: 5000 }).catch(() => null) + if (captureButton) { + await captureButton.click() + console.log("Clicked Capture button"); + + await this.delay(3000) + + const settingsButton = await newPage.waitForSelector('button[data-tip="Settings"]', { timeout: 5000 }).catch(() => null) + if (settingsButton) { + await settingsButton.click() + await this.delay(2000) + + const debugTabSelector = await newPage.waitForSelector('.tabs-boxed .tab:nth-child(3)', { timeout: 5000 }).catch(() => null) + if (debugTabSelector) { + await debugTabSelector.click() + await this.delay(2000) + + const throttleSendCheckbox = await newPage.waitForSelector('li.cursor-pointer.label input[type="checkbox"]', { timeout: 5000 }).catch(() => null) + if (throttleSendCheckbox) { + await throttleSendCheckbox.click() + await this.delay(2000) + } + + const closeButtonSelector = await newPage.waitForSelector('div.fixed button.btn', { timeout: 5000 }).catch(() => null) + await closeButtonSelector?.click() + await this.delay(2000) + } + + const enableCameraSelector = await newPage.waitForSelector('button.btn[data-tip="Camera"]', { timeout: 5000 }).catch(() => null) + await enableCameraSelector?.click() + await this.delay(1000) + + const poseButton = await newPage.waitForSelector('button.btn[data-tip="pose"]', { timeout: 5000 }).catch(() => null) + await poseButton?.click() + await this.delay(2000) + + return newPage + } + } + } + } + + async enablePlaybackForMotionCapture() { + + let newPage = await this.enableCameraForMotionCapture() + if (newPage) { + const recordButton = await newPage.waitForSelector('button.btn[data-tip="Record"]', { timeout: 5000 }).catch(() => null) + await recordButton?.click() + console.log("Clicked record button") + await this.delay(2000) + + const enablePlaybackSelector = await newPage.waitForSelector('button.btn[data-tip="Playback"]', { timeout: 5000 }).catch(() => null) + await enablePlaybackSelector?.click() + console.log("Clicked Playback button") + await this.delay(2000) + } + + } + + async keyPress(key, numMilliSeconds: number) { console.log('Running with key ' + key) const interval = setInterval(() => { @@ -264,10 +335,10 @@ export class EtherealEngineBot { devtools: !this.headless, ignoreHTTPSErrors: true, defaultViewport: this.windowSize, - ignoreDefaultArgs: ['--mute-audio'], + ignoreDefaultArgs: [], args: [ this.headless ? '--headless' : '--enable-webgl', - this.headless ? '--disable-gpu': undefined, + this.headless ? '--disable-gpu' : undefined, //this.headless ? '--disable-3d-apis':undefined, '--enable-features=NetworkService', '--ignore-certificate-errors', @@ -276,11 +347,11 @@ export class EtherealEngineBot { '--shm-size=4gb', `--window-size=${this.windowSize.width},${this.windowSize.height}`, '--use-fake-ui-for-media-stream=1', - '--use-fake-device-for-media-stream=1', + '--use-fake-device-for-media-stream', '--disable-web-security=1', //'--no-first-run', '--allow-file-access=1', - '--mute-audio' + //'--mute-audio' ].filter(Boolean), ...this.detectOsOption() } as LaunchOptions & BrowserLaunchArgumentOptions & BrowserConnectOptions @@ -328,7 +399,7 @@ export class EtherealEngineBot { context.overridePermissions(parsedUrl.origin, ['microphone', 'camera']) console.log('Going to ' + url) - await this.page.goto(url, { waitUntil: 'domcontentloaded', timeout: 60 * 1000 }) + await this.page.goto(url, { waitUntil: 'domcontentloaded', timeout: 200 * 1000 }) const granted = await this.page.evaluate(async () => { // @ts-ignore