Merge pull request #41 from santigimeno/improve_change_property_test

Improve change-property test (added check for PropertyNotify being sent)
This commit is contained in:
Andrey Sidorov 2013-11-05 13:52:39 -08:00
commit 77461403e8

View file

@ -15,6 +15,7 @@ describe('ChangeProperty', function() {
self.X.QueryTree(dpy.screen[0].root, function(err, list) { self.X.QueryTree(dpy.screen[0].root, function(err, list) {
should.not.exist(err); should.not.exist(err);
list.children.indexOf(self.wid).should.not.equal(-1); list.children.indexOf(self.wid).should.not.equal(-1);
self.X.ChangeWindowAttributes(self.wid, { eventMask: x11.eventMask.PropertyChange });
done(); done();
}); });
}); });
@ -29,6 +30,10 @@ describe('ChangeProperty', function() {
var raw = new Buffer(4); var raw = new Buffer(4);
raw.writeUInt32LE(self.wid, 0); raw.writeUInt32LE(self.wid, 0);
self.X.ChangeProperty(0, self.wid, atom, self.X.atoms.WINDOW, 32, raw); self.X.ChangeProperty(0, self.wid, atom, self.X.atoms.WINDOW, 32, raw);
self.X.once('event', function(ev) {
ev.type.should.equal(28);
ev.atom.should.equal(atom);
ev.window.should.equal(self.wid);
self.X.GetProperty(0, self.wid, atom, self.X.atoms.WINDOW, 0, 1000000000, function(err, prop) { self.X.GetProperty(0, self.wid, atom, self.X.atoms.WINDOW, 0, 1000000000, function(err, prop) {
should.not.exist(err); should.not.exist(err);
prop.data.readUInt32LE(0).should.equal(self.wid); prop.data.readUInt32LE(0).should.equal(self.wid);
@ -36,6 +41,7 @@ describe('ChangeProperty', function() {
}); });
}); });
}); });
});
it('should add a new WINDOW property with length 2', function(done) { it('should add a new WINDOW property with length 2', function(done) {
var self = this; var self = this;
@ -45,6 +51,10 @@ describe('ChangeProperty', function() {
raw.writeUInt32LE(self.wid, 0); raw.writeUInt32LE(self.wid, 0);
raw.writeUInt32LE(self.wid_helper, 4); raw.writeUInt32LE(self.wid_helper, 4);
self.X.ChangeProperty(0, self.wid, atom, self.X.atoms.ATOM, 32, raw); self.X.ChangeProperty(0, self.wid, atom, self.X.atoms.ATOM, 32, raw);
self.X.once('event', function(ev) {
ev.type.should.equal(28);
ev.atom.should.equal(atom);
ev.window.should.equal(self.wid);
self.X.GetProperty(0, self.wid, atom, self.X.atoms.ATOM, 0, 1000000000, function(err, prop) { self.X.GetProperty(0, self.wid, atom, self.X.atoms.ATOM, 0, 1000000000, function(err, prop) {
should.not.exist(err); should.not.exist(err);
prop.data.readUInt32LE(0).should.equal(self.wid); prop.data.readUInt32LE(0).should.equal(self.wid);
@ -53,6 +63,7 @@ describe('ChangeProperty', function() {
}); });
}); });
}); });
});
it('should replace a the WINDOW property with length 0', function(done) { it('should replace a the WINDOW property with length 0', function(done) {
var self = this; var self = this;
@ -60,6 +71,10 @@ describe('ChangeProperty', function() {
should.not.exist(err); should.not.exist(err);
var raw = new Buffer(0); var raw = new Buffer(0);
self.X.ChangeProperty(0, self.wid, atom, self.X.atoms.WINDOW, 32, raw); self.X.ChangeProperty(0, self.wid, atom, self.X.atoms.WINDOW, 32, raw);
self.X.once('event', function(ev) {
ev.type.should.equal(28);
ev.atom.should.equal(atom);
ev.window.should.equal(self.wid);
self.X.GetProperty(0, self.wid, atom, self.X.atoms.WINDOW, 0, 1000000000, function(err, prop) { self.X.GetProperty(0, self.wid, atom, self.X.atoms.WINDOW, 0, 1000000000, function(err, prop) {
should.not.exist(err); should.not.exist(err);
prop.data.length.should.equal(0); prop.data.length.should.equal(0);
@ -67,6 +82,7 @@ describe('ChangeProperty', function() {
}); });
}); });
}); });
});
after(function(done) { after(function(done) {
this.X.DestroyWindow(this.wid); this.X.DestroyWindow(this.wid);