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
"use strict";
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 = {
__resolution: resolution,
__Xvfb: Xvfb,
startXvfb: async function (opts) {
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 () {
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;