UNPKG

@testwizard/commands-video

Version:

43 lines (33 loc) 1.45 kB
'use strict'; const Commands = require('@testwizard/commands-core'); const Result = require('./WaitForSampleResult'); class WaitForSampleCommand extends Commands.CommandBase { constructor(testObject) { super(testObject, 'WaitForSample'); } async execute(x, y, width, height, minSimilarity, timeout, tolerance, distanceMethod, maxDistance) { 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 (minSimilarity === undefined) throw new Error('minSimilarity is required'); if (timeout === undefined) throw new Error('timeout is required'); const requestObj = [x, y, width, height, minSimilarity, timeout]; if (tolerance !== undefined) requestObj.push(tolerance); if (distanceMethod !== undefined) { requestObj.push(distanceMethod); if (maxDistance !== undefined) requestObj.push(maxDistance); } const json = await this.executeCommand(requestObj); return new Result(json, 'waitForSample was successful', 'waitForSample failed'); } } module.exports = WaitForSampleCommand;