mirror of
https://github.com/danbulant/node-x11
synced 2026-05-19 20:39:03 +00:00
Merge pull request #36 from santigimeno/fix_get_atom_name
Fix GetAtomName
This commit is contained in:
commit
78673cbb94
2 changed files with 48 additions and 22 deletions
|
|
@ -365,10 +365,18 @@ module.exports = {
|
|||
|
||||
GetAtomName: [
|
||||
[ 'CxSL', [17, 2] ],
|
||||
function(buf) {
|
||||
function(buf, seq_num) {
|
||||
var nameLen = buf.unpack('S')[0];
|
||||
// Atom value starting from 24th byte in the buffer
|
||||
return buf.unpackString(nameLen, 24);
|
||||
var name = buf.unpackString(nameLen, 24);
|
||||
var pending_atom = this.pending_atoms[seq_num];
|
||||
if (!this.atoms[pending_atom]) {
|
||||
this.atom_names[pending_atom] = name;
|
||||
this.atoms[name] = pending_atom;
|
||||
}
|
||||
|
||||
delete this.pending_atoms[seq_num];
|
||||
return name;
|
||||
}
|
||||
],
|
||||
|
||||
|
|
|
|||
|
|
@ -65,27 +65,45 @@ describe('Atoms and atom names cache', function() {
|
|||
|
||||
it('should be used after the first request for non-std atom_names', function(done) {
|
||||
var self = this;
|
||||
this.X.InternAtom(false, 'My testing atom', function(err, atom) {
|
||||
should.not.exist(err);
|
||||
sinon.assert.calledOnce(self.spy);
|
||||
async.parallel(
|
||||
[
|
||||
function(cb) {
|
||||
self.X.InternAtom(true, 'My testing atom', cb);
|
||||
},
|
||||
function(cb) {
|
||||
self.X.GetAtomName(atom, cb);
|
||||
}
|
||||
],
|
||||
function(err, results) {
|
||||
should.not.exist(err);
|
||||
results[0].should.equal(atom);
|
||||
results[1].should.equal('My testing atom');
|
||||
sinon.assert.calledOnce(self.spy);
|
||||
done();
|
||||
var my_name;
|
||||
/*
|
||||
* First get an atom defined in the server greater than 68 (WM_TRANSIENT_FOR) and less than 100
|
||||
* and not already cached
|
||||
*/
|
||||
var my_atom = 69;
|
||||
async.until(
|
||||
function() {
|
||||
return (my_name || my_atom > 99);
|
||||
},
|
||||
function(cb) {
|
||||
if (self.X.atom_names[my_atom]) {
|
||||
return cb();
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
self.X.GetAtomName(my_atom, function(err, name) {
|
||||
should.not.exist(err);
|
||||
if (name && name !== '') {
|
||||
my_name = name;
|
||||
} else {
|
||||
++ my_atom;
|
||||
}
|
||||
|
||||
cb();
|
||||
});
|
||||
},
|
||||
function(err) {
|
||||
should.not.exist(err);
|
||||
should.exist(my_name);
|
||||
self.spy.reset();
|
||||
self.X.InternAtom(true, my_name, function(err, atom) {
|
||||
should.not.exist(err);
|
||||
my_atom.should.equal(atom);
|
||||
sinon.assert.notCalled(self.spy);
|
||||
Object.keys(self.X.pending_atoms).should.be.empty;
|
||||
done();
|
||||
});
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
after(function(done) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue