Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 | 1x 1x 1x 1x 1x 1x 1x 5x 1x 1x 4x 4x 4x 4x 4x 4x 4x 4x 1x 1x 1x 4x 4x 4x 4x 4x 4x 2x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x | "use strict";
/**
* Steps for virtual display.
*
* @mixin XvfbSteps
* @prop {Xvfb} xvfb - Xvfb instance.
*/
var U = require("glace-utils");
var LOG = U.logger;
var resolution = require("screen-resolution");
var Xvfb = require("xvfb");
require("./fixtures");
var CONF = require("./config");
var XvfbSteps = {
/* modules */
__resolution: resolution,
__Xvfb: Xvfb,
startXvfb: async function (opts) {
/**
* Step to start virtual display. Step recall will be skipped if virtual
* display wasn't stopped before.
*
* @async
* @memberOf XvfbSteps
* @method startXvfb
* @instance
* @arg {object} [opts] - Step options.
* @arg {number} [opts.width] - Virtual display width. Default is active
* display width.
* @arg {number} [opts.height] - Virtual display height. Default is active
* display height.
* @arg {number} [opts.depth=24] - Virtual display color depth.
* @arg {number} [opts.timeout=1] - Time to wait for virtual display
* will be started, sec.
* @return {Promise<boolean>} - `true` if step was executed, `false` if
* was skipped.
*/
if (this._isXvfbStarted) {
LOG.warn("Step to start Xvfb was passed already");
return false;
};
opts = U.defVal(opts, {});
var width = U.defVal(opts.width, CONF.xvfb.width);
var height = U.defVal(opts.height, CONF.xvfb.height);
var depth = U.defVal(opts.depth, 24);
var timeout = U.defVal(opts.timeout, 1) * 1000;
allure.step("Start Xvfb");
LOG.info("Starting Xvfb...");
if (!((width && height) || this.xvfb)) {
var screen = await this.__resolution.get();
width = width || screen.width;
height = height || screen.height;
};
this.xvfb = this.xvfb || new this.__Xvfb(
{ timeout: timeout,
xvfb_args: [ "-screen", 0,
`${width}x${height}x${depth}`,
"-noreset", "-ac"] });
this.xvfb.startSync();
this._isXvfbStarted = true;
LOG.info("Xvfb is started");
allure.pass();
return true;
},
stopXvfb: function () {
/**
* Step to stop virtual display. Step call will be skipped if virtual
* display wasn't started before.
*
* @memberOf XvfbSteps
* @method stopXvfb
* @instance
* @return {boolean} - `true` if step was executed, `false` if was skipped.
*/
if (!this._isXvfbStarted) {
LOG.warn("Step to start Xvfb wasn't passed yet");
return false;
};
allure.step("Stop Xvfb");
LOG.info("Stopping Xvfb...");
this.xvfb.stopSync();
this._isXvfbStarted = false;
LOG.info("Xvfb is stopped");
allure.pass();
return true;
},
};
module.exports = XvfbSteps;
|