UNPKG

@testwizard/commands-video

Version:

47 lines (37 loc) 1.63 kB
'use strict'; const Commands = require('@testwizard/commands-core'); const Result = require('./DetectMotionResult'); class DetectMotionCommand extends Commands.CommandBase { constructor(testObject) { super(testObject, 'DetectMotion'); } async execute(x, y, width, height, minDifference, timeout, motionDuration, tolerance, distanceMethod, minDistance) { if (x === undefined) throw new Error('x is required'); if (y === undefined) throw new Error('y is required'); if (width === undefined) throw new Error('width is required'); if (height === undefined) throw new Error('height is required'); if (minDifference === undefined) throw new Error('minDifference is required'); if (timeout === undefined) throw new Error('timeout is required'); const requestObj = [x, y, width, height, minDifference, timeout] if (motionDuration !== undefined) { requestObj.push(motionDuration); if (tolerance !== undefined) { requestObj.push(tolerance); if (distanceMethod !== undefined) { requestObj.push(distanceMethod); if (minDistance !== undefined) requestObj.push(minDistance); } } } const json = await this.executeCommand(requestObj); return new Result(json, 'detectMotion was successful', 'detectMotion failed'); } } module.exports = DetectMotionCommand;