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
82
gaia/apps/settings/test/unit/panels/keyboard/enabled_layouts_test.js
Executable file
82
gaia/apps/settings/test/unit/panels/keyboard/enabled_layouts_test.js
Executable file
|
|
@ -0,0 +1,82 @@
|
|||
'use strict';
|
||||
|
||||
suite('KeyboardEnabledLayoutsCore', function() {
|
||||
var map = {
|
||||
'panels/keyboard/enabled_layouts': {
|
||||
'modules/settings_service': 'unit/mock_settings_service',
|
||||
'modules/mvvm/list_view': 'unit/mock_list_view'
|
||||
}
|
||||
};
|
||||
|
||||
suiteSetup(function(done) {
|
||||
// setup mocks
|
||||
this.mockLayoutTemplate = function() {};
|
||||
this.mockEnabledLayouts = [];
|
||||
this.mockElements = { listViewRoot: {} };
|
||||
|
||||
testRequire([
|
||||
'unit/mock_keyboard_context',
|
||||
'unit/mock_list_view',
|
||||
'panels/keyboard/enabled_layouts'
|
||||
], map, function(MockKeyboardContext, MockListView,
|
||||
KeyboardEnabledLayoutsCore) {
|
||||
this.MockKeyboardContext = MockKeyboardContext;
|
||||
this.MockListView = MockListView;
|
||||
this.KeyboardEnabledLayoutsCore = KeyboardEnabledLayoutsCore;
|
||||
done();
|
||||
}.bind(this));
|
||||
});
|
||||
|
||||
setup(function() {
|
||||
this.MockKeyboardContext.mEnabledLayouts = this.mockEnabledLayouts;
|
||||
this.subject = this.KeyboardEnabledLayoutsCore(this.MockKeyboardContext,
|
||||
this.mockLayoutTemplate);
|
||||
});
|
||||
|
||||
teardown(function() {
|
||||
this.MockKeyboardContext.mTeardown();
|
||||
});
|
||||
|
||||
test('init', function() {
|
||||
sinon.spy(this.subject, '_initEnabledLayoutListView');
|
||||
|
||||
this.subject.init(this.mockElements);
|
||||
|
||||
assert.ok(this.subject._initEnabledLayoutListView.calledWith(
|
||||
this.mockElements.listViewRoot, this.mockEnabledLayouts,
|
||||
this.mockLayoutTemplate),
|
||||
'_initEnabledLayoutListView should be called with correct parameters');
|
||||
});
|
||||
|
||||
test('when enabled = true', function() {
|
||||
this.subject._listView = { enabled: false };
|
||||
this.subject.enabled = true;
|
||||
assert.ok(this.subject._listView.enabled,
|
||||
'the list view should be enabled');
|
||||
});
|
||||
|
||||
test('when enabled = false', function() {
|
||||
this.subject._listView = { enabled: true };
|
||||
this.subject.enabled = false;
|
||||
assert.ok(!this.subject._listView.enabled,
|
||||
'the list view should be disabled');
|
||||
});
|
||||
|
||||
test('_initEnabledLayoutListView', function() {
|
||||
this.ListViewStub = sinon.stub().returns({});
|
||||
this.MockListView.mInnerFunction = this.ListViewStub;
|
||||
var listViewRoot = {};
|
||||
var layouts = [{}];
|
||||
var layoutTemplate = function() {};
|
||||
|
||||
this.subject._initEnabledLayoutListView(listViewRoot, layouts,
|
||||
layoutTemplate);
|
||||
|
||||
assert.ok(this.ListViewStub
|
||||
.calledWith(listViewRoot, layouts, layoutTemplate),
|
||||
'the list view should be created with correct arguments');
|
||||
assert.ok(this.subject._listView, 'the list view should be created');
|
||||
|
||||
this.MockListView.mTeardown();
|
||||
});
|
||||
});
|
||||
97
gaia/apps/settings/test/unit/panels/keyboard/installed_keyboards_test.js
Executable file
97
gaia/apps/settings/test/unit/panels/keyboard/installed_keyboards_test.js
Executable file
|
|
@ -0,0 +1,97 @@
|
|||
'use strict';
|
||||
|
||||
suite('KeyboardCore', function() {
|
||||
var map = {
|
||||
'panels/keyboard/installed_keyboards': {
|
||||
'modules/mvvm/list_view': 'unit/mock_list_view'
|
||||
}
|
||||
};
|
||||
|
||||
suiteSetup(function(done) {
|
||||
// setup mocks
|
||||
this.mockKeyboardTemplate = function() {};
|
||||
this.mockKeyboards = [];
|
||||
this.mockElements = { listViewRoot: {} };
|
||||
|
||||
testRequire([
|
||||
'unit/mock_keyboard_context',
|
||||
'unit/mock_list_view',
|
||||
'panels/keyboard/installed_keyboards'
|
||||
], map, function(MockKeyboardContext, MockListView, KeyboardCore) {
|
||||
this.MockKeyboardContext = MockKeyboardContext;
|
||||
this.MockListView = MockListView;
|
||||
this.KeyboardCore = KeyboardCore;
|
||||
done();
|
||||
}.bind(this));
|
||||
});
|
||||
|
||||
setup(function() {
|
||||
this.subject =
|
||||
this.KeyboardCore(this.MockKeyboardContext, this.mockKeyboardTemplate);
|
||||
});
|
||||
|
||||
teardown(function() {
|
||||
this.MockKeyboardContext.mTeardown();
|
||||
});
|
||||
|
||||
test('init', function() {
|
||||
this.MockKeyboardContext.mKeyboards = this.mockKeyboards;
|
||||
sinon.spy(this.subject, '_initAllKeyboardListView');
|
||||
|
||||
this.subject.init(this.mockElements);
|
||||
|
||||
assert.ok(this.subject._initAllKeyboardListView.calledWith(
|
||||
this.mockElements.listViewRoot, this.mockKeyboards,
|
||||
this.mockKeyboardTemplate),
|
||||
'_initAllKeyboardListView should be called with correct parameters');
|
||||
});
|
||||
|
||||
test('when enabled = true', function() {
|
||||
this.subject._listView = { enabled: false };
|
||||
this.subject.enabled = true;
|
||||
assert.ok(this.subject._listView.enabled,
|
||||
'the list view should be enabled');
|
||||
});
|
||||
|
||||
test('when enabled = false' , function() {
|
||||
this.subject._listView = { enabled: true };
|
||||
this.subject.enabled = false;
|
||||
assert.ok(!this.subject._listView.enabled,
|
||||
'the list view should be disabled');
|
||||
});
|
||||
|
||||
suite('_initAllKeyboardListView', function() {
|
||||
setup(function() {
|
||||
this.mockKeyboards = [];
|
||||
this.ListViewStub = sinon.stub().returns({});
|
||||
this.MockListView.mInnerFunction = this.ListViewStub;
|
||||
});
|
||||
|
||||
teardown(function() {
|
||||
this.MockListView.mTeardown();
|
||||
});
|
||||
|
||||
test('when called', function() {
|
||||
this.subject._initAllKeyboardListView(this.mockElements.listViewRoot,
|
||||
this.mockKeyboards, this.mockKeyboardTemplate);
|
||||
|
||||
assert.ok(this.ListViewStub.calledWith(this.mockElements.listViewRoot,
|
||||
this.mockKeyboards, this.mockKeyboardTemplate),
|
||||
'the list view should be created with correct arguments');
|
||||
assert.ok(this.subject._listView, 'the list view should be created');
|
||||
});
|
||||
|
||||
test('when there are no installed keyboards', function() {
|
||||
this.subject._initAllKeyboardListView(this.mockElements.listViewRoot,
|
||||
this.mockKeyboards, this.mockKeyboardTemplate);
|
||||
assert.ok(this.mockElements.listViewRoot.hidden, 'should hide the list');
|
||||
});
|
||||
|
||||
test('when there are installed keyboards', function() {
|
||||
this.mockKeyboards.push({});
|
||||
this.subject._initAllKeyboardListView(this.mockElements.listViewRoot,
|
||||
this.mockKeyboards, this.mockKeyboardTemplate);
|
||||
assert.ok(!this.mockElements.listViewRoot.hidden, 'should show the list');
|
||||
});
|
||||
});
|
||||
});
|
||||
91
gaia/apps/settings/test/unit/panels/keyboard/panel_test.js
Executable file
91
gaia/apps/settings/test/unit/panels/keyboard/panel_test.js
Executable file
|
|
@ -0,0 +1,91 @@
|
|||
'use strict';
|
||||
|
||||
suite('KeyboardPanel', function() {
|
||||
var map = {
|
||||
'*': {
|
||||
'modules/keyboard_context': 'MockKeyboardContext',
|
||||
'modules/settings_panel': 'MockSettingsPanel',
|
||||
'panels/keyboard/installed_keyboards': 'MockInstalledKeyboards',
|
||||
'panels/keyboard/enabled_layouts': 'MockEnabledLayouts'
|
||||
}
|
||||
};
|
||||
|
||||
setup(function(done) {
|
||||
this.fakeRootElement = {
|
||||
querySelector: function() {}
|
||||
};
|
||||
|
||||
// Create a new requirejs context
|
||||
var requireCtx = testRequire([], map, function() {});
|
||||
var that = this;
|
||||
|
||||
// Define MockKeyboardContext
|
||||
define('MockKeyboardContext', function() {
|
||||
return {};
|
||||
});
|
||||
|
||||
// Define MockSettingsPanel
|
||||
define('MockSettingsPanel', function() {
|
||||
return function(options) {
|
||||
return {
|
||||
init: options.onInit,
|
||||
beforeShow: options.onBeforeShow,
|
||||
beforeHide: options.onBeforeHide,
|
||||
hide: options.onHide
|
||||
};
|
||||
};
|
||||
});
|
||||
|
||||
// Define MockInstalledKeyboards
|
||||
this.mockInstalledKeyboards = {
|
||||
enabled: false,
|
||||
init: function() {}
|
||||
};
|
||||
this.MockInstalledKeyboards = function() {
|
||||
return that.mockInstalledKeyboards;
|
||||
};
|
||||
define('MockInstalledKeyboards', function() {
|
||||
return that.MockInstalledKeyboards;
|
||||
});
|
||||
|
||||
// Define MockEnabledLayouts
|
||||
this.mockEnabledLayouts = {
|
||||
enabled: false,
|
||||
init: function() {}
|
||||
};
|
||||
this.MockEnabledLayouts = function() {
|
||||
return that.mockEnabledLayouts;
|
||||
};
|
||||
define('MockEnabledLayouts', function() {
|
||||
return that.MockEnabledLayouts;
|
||||
});
|
||||
|
||||
requireCtx([
|
||||
'panels/keyboard/panel'
|
||||
],
|
||||
function(KeyboardPanel) {
|
||||
that.panel = KeyboardPanel();
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
test('Init MockEnabledLayouts when onInit', function() {
|
||||
sinon.spy(this.mockInstalledKeyboards, 'init');
|
||||
sinon.spy(this.mockEnabledLayouts, 'init');
|
||||
this.panel.init(this.fakeRootElement);
|
||||
sinon.assert.called(this.mockInstalledKeyboards.init);
|
||||
sinon.assert.called(this.mockEnabledLayouts.init);
|
||||
});
|
||||
|
||||
test('Enabled MockEnabledLayouts when onBeforeShow', function() {
|
||||
this.panel.beforeShow();
|
||||
assert.ok(this.mockInstalledKeyboards.enabled);
|
||||
assert.ok(this.mockEnabledLayouts.enabled);
|
||||
});
|
||||
|
||||
test('Disable MockEnabledLayouts when onHide', function() {
|
||||
this.panel.hide();
|
||||
assert.ok(!this.mockInstalledKeyboards.enabled);
|
||||
assert.ok(!this.mockEnabledLayouts.enabled);
|
||||
});
|
||||
});
|
||||
Loading…
Reference in a new issue