Publish Vulpes Preview 15 sources for desktop, Android and Tundra
Share Gaia assets and adapters, keep private profiles and development documents local, and update both public READMEs.
This commit is contained in:
parent
93e3a48004
commit
b38dea0597
25901 changed files with 9982925 additions and 369 deletions
|
|
@ -0,0 +1,98 @@
|
|||
/* global assert */
|
||||
'use strict';
|
||||
var FakeSocket = require('../support/socket'),
|
||||
CommandStream = require('../../lib/marionette/command-stream'),
|
||||
ConnectionManger = require('../../lib/node/connection-manager');
|
||||
|
||||
|
||||
suite('connection-manager', function() {
|
||||
var RealSocket, subject, sockets = [];
|
||||
|
||||
suiteSetup(function() {
|
||||
RealSocket = ConnectionManger.Socket;
|
||||
ConnectionManger.Socket = FakeSocket;
|
||||
FakeSocket.sockets = sockets;
|
||||
});
|
||||
|
||||
suiteTeardown(function() {
|
||||
ConnectionManger.Socket = RealSocket;
|
||||
});
|
||||
|
||||
setup(function() {
|
||||
sockets.length = 0;
|
||||
subject = new ConnectionManger();
|
||||
});
|
||||
|
||||
suite('initialization', function() {
|
||||
test('should initialize .connections', function() {
|
||||
assert.deepEqual(subject.connections, {});
|
||||
});
|
||||
});
|
||||
|
||||
suite('.remove', function() {
|
||||
test('should remove connection from list', function() {
|
||||
subject.open();
|
||||
assert.ok(subject.connections[0]);
|
||||
subject.close(0);
|
||||
assert.notOk(subject.connections[0]);
|
||||
});
|
||||
});
|
||||
|
||||
suite('.get', function() {
|
||||
|
||||
test('should return an open connection', function() {
|
||||
var open = subject.open();
|
||||
|
||||
assert.strictEqual(subject.get(open.id), open.connection);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
suite('.open', function() {
|
||||
var result, con;
|
||||
|
||||
setup(function() {
|
||||
result = subject.open();
|
||||
con = subject.connections[0];
|
||||
});
|
||||
|
||||
test('should initialize socket and stream', function() {
|
||||
assert.ok(sockets[0]);
|
||||
assert.strictEqual(con.socket, sockets[0]);
|
||||
assert.strictEqual(sockets[0].port, subject.defaultPort);
|
||||
|
||||
assert.instanceOf(con, CommandStream);
|
||||
});
|
||||
|
||||
test('should increment currentId', function() {
|
||||
assert.strictEqual(subject.currentId, 1);
|
||||
});
|
||||
|
||||
test('should return id and stream', function() {
|
||||
assert.deepEqual(result, {
|
||||
id: 0,
|
||||
connection: subject.connections[0]
|
||||
});
|
||||
});
|
||||
|
||||
function isRemovedOnEvent(event) {
|
||||
suite('on socket ' + event, function() {
|
||||
|
||||
setup(function() {
|
||||
assert.ok(subject.connections[0]);
|
||||
con.socket.emit(event);
|
||||
});
|
||||
|
||||
test('should remove itself from connections', function() {
|
||||
assert.notOk(subject.connections[0]);
|
||||
});
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
isRemovedOnEvent('close');
|
||||
isRemovedOnEvent('end');
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
|
|
@ -0,0 +1,17 @@
|
|||
'use strict';
|
||||
var EventEmitter = require('events').EventEmitter;
|
||||
|
||||
var WSClient = function() {
|
||||
this.sendCalls = [];
|
||||
EventEmitter.call(this);
|
||||
};
|
||||
|
||||
WSClient.prototype = Object.create(EventEmitter.prototype);
|
||||
WSClient.prototype.onsend = function() {};
|
||||
WSClient.prototype.send = function() {
|
||||
this.onsend.apply(this, arguments);
|
||||
this.sendCalls.push(Array.prototype.slice.call(arguments));
|
||||
};
|
||||
|
||||
|
||||
module.exports = exports = WSClient;
|
||||
Loading…
Reference in a new issue