mirror of
https://github.com/danbulant/node-x11
synced 2026-05-24 12:35:39 +00:00
test: fix flaky core-KillKlient test
Wait for the `CreateNotify` before killing the client, otherwise a `BadValue` error could be raised.
This commit is contained in:
parent
8ed37aaa31
commit
f0b0bac336
1 changed files with 22 additions and 24 deletions
|
|
@ -8,43 +8,41 @@ describe('KillKlient request', function() {
|
||||||
var X;
|
var X;
|
||||||
beforeEach(function(done) {
|
beforeEach(function(done) {
|
||||||
var client = x11.createClient(function(err, dpy) {
|
var client = x11.createClient(function(err, dpy) {
|
||||||
if (!err) {
|
should.not.exist(err);
|
||||||
display = dpy;
|
display = dpy;
|
||||||
X = display.client;
|
X = display.client;
|
||||||
}
|
root = display.screen[0].root;
|
||||||
|
var eventMask = x11.eventMask.SubstructureNotify;
|
||||||
|
X.ChangeWindowAttributes(root, { eventMask: eventMask });
|
||||||
|
done();
|
||||||
|
});
|
||||||
|
|
||||||
done(err);
|
client.on('error', done);
|
||||||
});
|
|
||||||
client.on('error', function(err) {
|
|
||||||
done(err);
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
|
|
||||||
afterEach(function(done) {
|
afterEach(function(done) {
|
||||||
X.terminate();
|
|
||||||
X.on('end', done);
|
X.on('end', done);
|
||||||
X = null;
|
X.terminate();
|
||||||
display = null;
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should exist as client member', function(done) {
|
it('should exist as client member', function() {
|
||||||
should.exist(X.KillKlient);
|
should.exist(X.KillKlient);
|
||||||
assert.equal(typeof X.KillKlient, 'function');
|
assert.equal(typeof X.KillKlient, 'function');
|
||||||
done();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should terminate other client connection', function(done) {
|
it('should terminate other client connection', function(done) {
|
||||||
x11.createClient(function(err, dpy) {
|
x11.createClient(function(err, dpy) {
|
||||||
if (!err) {
|
should.not.exist(err);
|
||||||
var otherclient = dpy.client;
|
var otherclient = dpy.client;
|
||||||
var wnd = otherclient.AllocID();
|
var wnd = otherclient.AllocID();
|
||||||
otherclient.CreateWindow(wnd, dpy.screen[0].root, 0, 0, 1, 1);
|
X.once('event', function(ev) {
|
||||||
otherclient.on('end', done);
|
ev.name.should.equal('CreateNotify');
|
||||||
X.KillKlient(wnd);
|
ev.wid.should.equal(wnd);
|
||||||
} else {
|
X.KillKlient(wnd);
|
||||||
done(err);
|
});
|
||||||
}
|
|
||||||
|
otherclient.CreateWindow(wnd, dpy.screen[0].root, 0, 0, 1, 1);
|
||||||
|
otherclient.on('end', done);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue