node-x11/test/sequence-overflow.js
Santiago Gimeno 4508f9e93d Change createClient signature
- The new signature is:

  createClient(options, initCB), where
     - options is an optional object that defines different parameters such as
               display, etc.
     - initCB is an optional callback with the signature: function(err, display)
- The initCB is going to be called with an error ONLY if the connection to the X
  server fails. Further errors in the server connection will be 'emitted'.
- Update tests and test-runner.js accordingly.
- Update README.
2012-12-19 09:34:19 +01:00

45 lines
1.2 KiB
JavaScript

var x11 = require('../lib/x11');
var should = require('should');
var assert = require('assert');
describe('Client', function() {
var display;
beforeEach(function(done) {
var client = x11.createClient(function(err, dpy) {
if (!err) {
display = dpy;
done();
client.removeListener('error', done);
} else {
done(err);
}
});
client.on('error', done);
});
it('should handle more than 65535 requests in one connection', function(done) {
should.exist(display);
should.exist(display.screen);
var total = 70000;
var left = total;
var start = Date.now();
function test(err, str) {
if (err)
return done(err);
if (left == 0) {
var end = Date.now();
var dur = end - start;
console.log(total + ' requests finished in ' + dur + ' ms, ' + 1000*total/dur + ' req/sec');
return done();
}
left--;
display.client.GetAtomName(1, test);
}
left++;
test(); // first call starts sequens and not a callback from GetAtomName, thus left++
});
});