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
44
gaia/apps/system/test/unit/remote/app_test.js
Executable file
44
gaia/apps/system/test/unit/remote/app_test.js
Executable file
|
|
@ -0,0 +1,44 @@
|
|||
/* global MocksHelper, BaseModule */
|
||||
'use strict';
|
||||
|
||||
require('/shared/test/unit/mocks/mock_lazy_loader.js');
|
||||
requireApp('system/js/service.js');
|
||||
requireApp('system/js/base_module.js');
|
||||
requireApp('system/js/remote/app.js');
|
||||
|
||||
var mocksForMultiScreenController = new MocksHelper([
|
||||
'LazyLoader'
|
||||
]).init();
|
||||
|
||||
suite('system/remote/App', function() {
|
||||
mocksForMultiScreenController.attachTestHelpers();
|
||||
|
||||
var subject;
|
||||
|
||||
setup(function() {
|
||||
window.location.hash = '#123';
|
||||
subject = BaseModule.instantiate('App');
|
||||
subject.start();
|
||||
});
|
||||
|
||||
teardown(function() {
|
||||
subject.stop();
|
||||
});
|
||||
|
||||
suite('displayId', function() {
|
||||
test('should get the displayId from location.hash', function() {
|
||||
assert.equal(subject._displayId, 123);
|
||||
});
|
||||
|
||||
test('should return displayId', function() {
|
||||
assert.equal(subject.displayId(), subject._displayId);
|
||||
});
|
||||
|
||||
test('displayId should be -1 if location.hash is omitted', function() {
|
||||
window.location.hash = '';
|
||||
subject.stop();
|
||||
subject.start();
|
||||
assert.equal(subject._displayId, -1);
|
||||
});
|
||||
});
|
||||
});
|
||||
127
gaia/apps/system/test/unit/remote/message_controller_test.js
Executable file
127
gaia/apps/system/test/unit/remote/message_controller_test.js
Executable file
|
|
@ -0,0 +1,127 @@
|
|||
/* global MocksHelper, BaseModule, BroadcastChannel, Service */
|
||||
'use strict';
|
||||
|
||||
require('/shared/test/unit/mocks/mock_lazy_loader.js');
|
||||
requireApp('system/js/service.js');
|
||||
requireApp('system/js/base_module.js');
|
||||
requireApp('system/js/remote/message_controller.js');
|
||||
|
||||
var mocksForMultiScreenController = new MocksHelper([
|
||||
'LazyLoader'
|
||||
]).init();
|
||||
|
||||
suite('system/remote/MessageController', function() {
|
||||
mocksForMultiScreenController.attachTestHelpers();
|
||||
|
||||
var subject;
|
||||
var fakeDisplayId = 123;
|
||||
|
||||
setup(function() {
|
||||
this.sinon.stub(Service, 'query', function(state) {
|
||||
if (state == 'displayId') {
|
||||
return fakeDisplayId;
|
||||
}
|
||||
});
|
||||
|
||||
subject = BaseModule.instantiate('MessageController');
|
||||
subject.start();
|
||||
});
|
||||
|
||||
teardown(function() {
|
||||
subject.stop();
|
||||
});
|
||||
|
||||
suite('start', function() {
|
||||
test('should cache the displayId', function() {
|
||||
assert.equal(subject.displayId, fakeDisplayId);
|
||||
});
|
||||
|
||||
test('should establish a broadcast channel', function() {
|
||||
assert.isNotNull(subject.broadcastChannel);
|
||||
assert.equal(subject.broadcastChannel.name, 'multiscreen');
|
||||
});
|
||||
});
|
||||
|
||||
suite('post messages', function() {
|
||||
test('should post the message well-formedly', function(done) {
|
||||
var fakeType = 'type';
|
||||
var fakeDetail = {
|
||||
data1: '1',
|
||||
data2: 2
|
||||
};
|
||||
this.sinon.stub(subject.broadcastChannel, 'postMessage', function(data) {
|
||||
done(function() {
|
||||
assert.equal(data.source, subject.displayId);
|
||||
assert.equal(data.type, fakeType);
|
||||
assert.equal(data.detail, fakeDetail);
|
||||
assert.isUndefined(data.target);
|
||||
});
|
||||
});
|
||||
subject.postMessage(fakeType, fakeDetail);
|
||||
});
|
||||
});
|
||||
|
||||
suite('receive messages', function() {
|
||||
var broadcastChannel;
|
||||
var launchAppSuccess;
|
||||
var fakeConfig = {
|
||||
url: 'test.html'
|
||||
};
|
||||
|
||||
function broadcastMessage(target, type, detail) {
|
||||
broadcastChannel.postMessage({
|
||||
target: target,
|
||||
type: type,
|
||||
detail: detail
|
||||
});
|
||||
}
|
||||
|
||||
setup(function() {
|
||||
broadcastChannel = new BroadcastChannel('multiscreen');
|
||||
|
||||
launchAppSuccess = true;
|
||||
this.sinon.stub(Service, 'request', function(service, config) {
|
||||
return (service == 'launchApp' && launchAppSuccess) ?
|
||||
Promise.resolve() : Promise.reject('test');
|
||||
});
|
||||
});
|
||||
|
||||
teardown(function() {
|
||||
broadcastChannel.close();
|
||||
});
|
||||
|
||||
test('should post "launch-app-success" when resolving from "launchApp"',
|
||||
function(done) {
|
||||
this.sinon.stub(subject, 'postMessage', function(type, detail) {
|
||||
done(function() {
|
||||
assert.equal(type, 'launch-app-success');
|
||||
assert.equal(detail.config.url, fakeConfig.url);
|
||||
});
|
||||
});
|
||||
broadcastMessage(subject.displayId, 'launch-app', fakeConfig);
|
||||
});
|
||||
|
||||
test('should post "launch-app-error" when rejecting from "launchApp"',
|
||||
function(done) {
|
||||
launchAppSuccess = false;
|
||||
this.sinon.stub(subject, 'postMessage', function(type, detail) {
|
||||
done(function() {
|
||||
assert.equal(type, 'launch-app-error');
|
||||
assert.equal(detail.config.url, fakeConfig.url);
|
||||
assert.equal(detail.reason, 'test');
|
||||
});
|
||||
});
|
||||
broadcastMessage(subject.displayId, 'launch-app', fakeConfig);
|
||||
});
|
||||
|
||||
test('should ignore message if data.target isn\'t current displayId',
|
||||
function(done) {
|
||||
this.sinon.stub(subject, '_post_handleEvent', function() {
|
||||
done(function() {
|
||||
assert.isFalse(Service.request.called);
|
||||
});
|
||||
});
|
||||
broadcastMessage(subject.displayId + 1, 'launch-app', fakeConfig);
|
||||
});
|
||||
});
|
||||
});
|
||||
155
gaia/apps/system/test/unit/remote/remote_app_window_manager_test.js
Executable file
155
gaia/apps/system/test/unit/remote/remote_app_window_manager_test.js
Executable file
|
|
@ -0,0 +1,155 @@
|
|||
/* global MocksHelper, BaseModule */
|
||||
'use strict';
|
||||
|
||||
require('/shared/test/unit/mocks/mock_lazy_loader.js');
|
||||
requireApp('system/js/service.js');
|
||||
requireApp('system/js/base_module.js');
|
||||
requireApp('system/js/browser_frame.js');
|
||||
requireApp('system/js/remote/remote_app_window_manager.js');
|
||||
|
||||
var mocksForMultiScreenController = new MocksHelper([
|
||||
'LazyLoader'
|
||||
]).init();
|
||||
|
||||
suite('system/remote/RemoteAppWindowManager', function() {
|
||||
mocksForMultiScreenController.attachTestHelpers();
|
||||
|
||||
var subject;
|
||||
var container;
|
||||
|
||||
setup(function() {
|
||||
container = document.createElement('div');
|
||||
container.id = 'windows';
|
||||
document.body.appendChild(container);
|
||||
|
||||
subject = BaseModule.instantiate('RemoteAppWindowManager');
|
||||
subject.start();
|
||||
});
|
||||
|
||||
teardown(function() {
|
||||
subject.stop();
|
||||
document.body.removeChild(container);
|
||||
});
|
||||
|
||||
suite('start', function() {
|
||||
test('should set the container', function() {
|
||||
assert.isNotNull(subject.container);
|
||||
});
|
||||
});
|
||||
|
||||
suite('stop', function() {
|
||||
test('should clear the container', function() {
|
||||
subject.stop();
|
||||
assert.isNull(subject.container);
|
||||
});
|
||||
});
|
||||
|
||||
suite('launchApp', function() {
|
||||
var fakeElement;
|
||||
var fakeConfig = {
|
||||
url: 'test.html'
|
||||
};
|
||||
|
||||
setup(function() {
|
||||
fakeElement = document.createElement('iframe');
|
||||
this.sinon.stub(window, 'BrowserFrame', function(config) {
|
||||
this.element = fakeElement;
|
||||
});
|
||||
});
|
||||
|
||||
teardown(function() {
|
||||
fakeElement = null;
|
||||
});
|
||||
|
||||
test('should pass untouched config to BrowserFrame', function() {
|
||||
subject.launchApp(fakeConfig);
|
||||
assert.isTrue(window.BrowserFrame.calledWith(fakeConfig));
|
||||
assert.isNotNull(subject.currentApp);
|
||||
});
|
||||
|
||||
test('should create a container for browserFrame', function() {
|
||||
subject.launchApp(fakeConfig);
|
||||
|
||||
var appWindow = document.querySelector('.appWindow');
|
||||
assert.isNotNull(appWindow);
|
||||
assert.equal(subject.currentApp.container, appWindow);
|
||||
});
|
||||
|
||||
test('should resolve after receiving "animationend"', function(done) {
|
||||
subject.launchApp(fakeConfig).then(function(config) {
|
||||
done(function() {
|
||||
assert.equal(config, fakeConfig);
|
||||
});
|
||||
});
|
||||
|
||||
var appWindow = document.querySelector('.appWindow');
|
||||
appWindow.dispatchEvent(new CustomEvent('animationend'));
|
||||
});
|
||||
|
||||
test('should resolve immediately', function(done) {
|
||||
subject.launchApp(fakeConfig, true).then(function(config) {
|
||||
done(function() {
|
||||
assert.equal(config, fakeConfig);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
test('should reject if previous app is during animation', function(done) {
|
||||
subject.launchApp(fakeConfig);
|
||||
subject.launchApp(fakeConfig).catch(function(reason) {
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
suite('killCurrentApp', function() {
|
||||
var fakeElement;
|
||||
|
||||
setup(function() {
|
||||
fakeElement = document.createElement('iframe');
|
||||
this.sinon.stub(window, 'BrowserFrame', function(config) {
|
||||
this.element = fakeElement;
|
||||
});
|
||||
subject.launchApp({});
|
||||
subject.killCurrentApp();
|
||||
});
|
||||
|
||||
teardown(function() {
|
||||
fakeElement = null;
|
||||
});
|
||||
|
||||
test('should remove element from container', function() {
|
||||
var appWindow = document.querySelector('.appWindow');
|
||||
assert.isNull(appWindow);
|
||||
assert.isNull(subject.currentApp);
|
||||
});
|
||||
});
|
||||
|
||||
suite('event handlers', function() {
|
||||
var fakeElement;
|
||||
|
||||
setup(function() {
|
||||
fakeElement = document.createElement('iframe');
|
||||
this.sinon.stub(window, 'BrowserFrame', function(config) {
|
||||
this.element = fakeElement;
|
||||
});
|
||||
subject.launchApp({});
|
||||
});
|
||||
|
||||
teardown(function() {
|
||||
fakeElement = null;
|
||||
});
|
||||
|
||||
test('should kill current app when mozbrowsererror', function() {
|
||||
this.sinon.stub(subject, 'killCurrentApp');
|
||||
fakeElement.dispatchEvent(new CustomEvent('mozbrowsererror'));
|
||||
assert.isTrue(subject.killCurrentApp.called);
|
||||
});
|
||||
|
||||
test('should kill current app when mozbrowserclose', function() {
|
||||
this.sinon.stub(subject, 'killCurrentApp');
|
||||
fakeElement.dispatchEvent(new CustomEvent('mozbrowserclose'));
|
||||
assert.isTrue(subject.killCurrentApp.called);
|
||||
});
|
||||
});
|
||||
});
|
||||
Loading…
Reference in a new issue