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
29
gaia/apps/callscreen/test/build/integration/callscreen_test.js
Executable file
29
gaia/apps/callscreen/test/build/integration/callscreen_test.js
Executable file
|
|
@ -0,0 +1,29 @@
|
|||
'use strict';
|
||||
|
||||
/* jshint node: true, mocha: true */
|
||||
/* global suiteSetup */
|
||||
|
||||
var helper = require('helper');
|
||||
|
||||
suite('Callscreen tests', function() {
|
||||
suiteSetup(helper.cleanupWorkspace);
|
||||
teardown(helper.cleanupWorkspace);
|
||||
|
||||
// Do not check callscreen
|
||||
// We're going to uncomment this once bug 1093267 is resolved
|
||||
test.skip('APP=callscreen make', function(done) {
|
||||
helper.exec('APP=callscreen make', function(error, stdout, stderr) {
|
||||
helper.checkError(error, stdout, stderr);
|
||||
|
||||
var zipPath = process.cwd() +
|
||||
'/profile/webapps/callscreen.gaiamobile.org/application.zip';
|
||||
var checkList = ['manifest.webapp'];
|
||||
|
||||
checkList.forEach(function(filePath) {
|
||||
helper.checkFilePathInZip(zipPath, filePath);
|
||||
});
|
||||
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
17
gaia/apps/callscreen/test/unit/.jshintrc
Executable file
17
gaia/apps/callscreen/test/unit/.jshintrc
Executable file
|
|
@ -0,0 +1,17 @@
|
|||
{
|
||||
"extends": "../../../../.jshintrc",
|
||||
"predef": [
|
||||
"assert",
|
||||
"suite",
|
||||
"test",
|
||||
"setup",
|
||||
"teardown",
|
||||
"suiteSetup",
|
||||
"suiteTeardown",
|
||||
"require",
|
||||
"requireApp",
|
||||
"sinon",
|
||||
"mocha",
|
||||
"loadBodyHTML"
|
||||
]
|
||||
}
|
||||
1017
gaia/apps/callscreen/test/unit/call_screen_test.js
Executable file
1017
gaia/apps/callscreen/test/unit/call_screen_test.js
Executable file
File diff suppressed because it is too large
Load diff
2634
gaia/apps/callscreen/test/unit/calls_handler_test.js
Executable file
2634
gaia/apps/callscreen/test/unit/calls_handler_test.js
Executable file
File diff suppressed because it is too large
Load diff
455
gaia/apps/callscreen/test/unit/conference_group_handler_test.js
Executable file
455
gaia/apps/callscreen/test/unit/conference_group_handler_test.js
Executable file
|
|
@ -0,0 +1,455 @@
|
|||
/* globals ConferenceGroupHandler, FontSizeManager, l10nAssert, MockCall,
|
||||
MockCallScreen, MockCallsHandler, MockConferenceGroupUI, MockL10n,
|
||||
MockMutationObserver, MockNavigatorMozTelephony, MocksHelper,
|
||||
telephonyAddCall */
|
||||
|
||||
'use strict';
|
||||
|
||||
require('/shared/test/unit/mocks/mock_l10n.js');
|
||||
require('/shared/test/unit/mocks/mock_mutation_observer.js');
|
||||
require('/shared/test/unit/mocks/mock_navigator_moz_telephony.js');
|
||||
require('/shared/test/unit/mocks/dialer/mock_call.js');
|
||||
require('/shared/test/unit/mocks/dialer/mock_handled_call.js');
|
||||
require('/shared/test/unit/mocks/dialer/mock_calls_handler.js');
|
||||
require('/test/unit/mock_call_screen.js');
|
||||
require('/test/unit/mock_conference_group_ui.js');
|
||||
require('/shared/test/unit/mocks/dialer/mock_font_size_manager.js');
|
||||
|
||||
// The ConferenceGroupHandler binds stuff when evaluated so we load it
|
||||
// after the mocks and we don't want it to show up as a leak.
|
||||
var mocksHelperForConferenceGroupHandler = new MocksHelper([
|
||||
'HandledCall',
|
||||
'CallsHandler',
|
||||
'CallScreen',
|
||||
'ConferenceGroupUI',
|
||||
'FontSizeManager',
|
||||
'MutationObserver'
|
||||
]).init();
|
||||
|
||||
suite('conference group handler', function() {
|
||||
var realMozTelephony;
|
||||
var realMozL10n;
|
||||
|
||||
mocksHelperForConferenceGroupHandler.attachTestHelpers();
|
||||
|
||||
var fakeDOM;
|
||||
var fakeGroupLine;
|
||||
var fakeGroupLabel;
|
||||
var fakeGroupDetails;
|
||||
var fakeDurationChildNode;
|
||||
var fakeTotalDurationChildNode;
|
||||
var fakeMutationObserver;
|
||||
|
||||
suiteSetup(function(done) {
|
||||
realMozTelephony = navigator.mozTelephony;
|
||||
navigator.mozTelephony = MockNavigatorMozTelephony;
|
||||
|
||||
realMozL10n = navigator.mozL10n;
|
||||
navigator.mozL10n = MockL10n;
|
||||
|
||||
fakeDOM = document.createElement('div');
|
||||
fakeDOM.innerHTML = `<section id="group-call" hidden>
|
||||
<div class="numberWrapper">
|
||||
<div id="group-show"></div>
|
||||
<div id="group-call-label" +
|
||||
class="number font-light"></div>
|
||||
</div>
|
||||
<div id="group-call-summary" +
|
||||
class="additionalContactInfo font-light"></div>
|
||||
<div class="duration">
|
||||
<span class="font-light"></span>
|
||||
<div class="total-duration"></div>
|
||||
<div class="direction"></div>
|
||||
</div>
|
||||
</section>
|
||||
<form id="group-call-details" role="dialog" +
|
||||
data-type="action" class="overlay">
|
||||
<header></header>
|
||||
<menu>
|
||||
<ul id="group-call-details-list">
|
||||
</ul>
|
||||
<button id="group-hide" data-l10n-id="close">
|
||||
Close
|
||||
</button>
|
||||
</menu>
|
||||
</form>`;
|
||||
|
||||
document.body.appendChild(fakeDOM);
|
||||
fakeGroupLine = document.getElementById('group-call');
|
||||
fakeGroupLabel = document.getElementById('group-call-label');
|
||||
fakeGroupDetails = document.getElementById('group-call-details');
|
||||
fakeDurationChildNode =
|
||||
document.querySelector('#group-call > .duration > span');
|
||||
fakeTotalDurationChildNode =
|
||||
document.querySelector('#group-call > .duration > .total-duration');
|
||||
|
||||
require('/js/conference_group_handler.js', function() {
|
||||
fakeMutationObserver = MockMutationObserver.mLastObserver;
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
suiteTeardown(function() {
|
||||
fakeDOM.parentNode.removeChild(fakeDOM);
|
||||
navigator.moztelephony = realMozTelephony;
|
||||
navigator.mozL10n = realMozL10n;
|
||||
});
|
||||
|
||||
teardown(function() {
|
||||
MockNavigatorMozTelephony.mTeardown();
|
||||
});
|
||||
|
||||
suite('telephony.conferenceGroup.oncallschanged handling', function() {
|
||||
var firstCall, firstHC;
|
||||
var secondCall, secondHC;
|
||||
var thirdCall, thirdHC;
|
||||
|
||||
function flush() {
|
||||
MockNavigatorMozTelephony.mTriggerGroupCallsChanged();
|
||||
MockNavigatorMozTelephony.mTriggerCallsChanged();
|
||||
}
|
||||
|
||||
setup(function() {
|
||||
firstCall = new MockCall('543552', 'incoming');
|
||||
firstHC = telephonyAddCall.call(this, firstCall, {trigger: true});
|
||||
|
||||
secondCall = new MockCall('54212152', 'incoming');
|
||||
secondHC = telephonyAddCall.call(this, secondCall, {trigger: true});
|
||||
});
|
||||
|
||||
suite('when the conference call is created', function() {
|
||||
setup(function() {
|
||||
MockNavigatorMozTelephony.calls = [];
|
||||
MockNavigatorMozTelephony.conferenceGroup.calls =
|
||||
[firstCall, secondCall];
|
||||
});
|
||||
|
||||
test('should update the conference group details header', function() {
|
||||
this.sinon.spy(MockConferenceGroupUI, 'setGroupDetailsHeader');
|
||||
flush();
|
||||
sinon.assert.calledWith(
|
||||
MockConferenceGroupUI.setGroupDetailsHeader,
|
||||
{
|
||||
id: 'conferenceCall',
|
||||
args: { n: 2 }
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
test('should update the group label', function() {
|
||||
flush();
|
||||
// Check the bdi node rather than the element itself
|
||||
l10nAssert(
|
||||
fakeGroupLabel.firstChild, {
|
||||
id: 'conferenceCall',
|
||||
args: { n: 2 }
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
test('should update call screen in CDMA network', function() {
|
||||
MockCallsHandler.mIsFirstCallOnCdmaNetwork = true;
|
||||
this.sinon.spy(MockCallScreen, 'cdmaConferenceCall');
|
||||
|
||||
flush();
|
||||
sinon.assert.calledOnce(MockCallScreen.cdmaConferenceCall);
|
||||
});
|
||||
|
||||
suite('when a new called is merged in the conference', function() {
|
||||
setup(function() {
|
||||
flush();
|
||||
|
||||
thirdCall = new MockCall('54329890', 'incoming');
|
||||
thirdHC = telephonyAddCall.call(this, thirdCall, {trigger: true});
|
||||
|
||||
MockNavigatorMozTelephony.calls = [];
|
||||
MockNavigatorMozTelephony.conferenceGroup.calls =
|
||||
[firstCall, secondCall, thirdCall];
|
||||
});
|
||||
|
||||
test('should update the group label', function() {
|
||||
flush();
|
||||
// Check the bdi node rather than the element itself
|
||||
l10nAssert(
|
||||
fakeGroupLabel.firstChild, {
|
||||
id: 'conferenceCall',
|
||||
args: { n: 3 }
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
test('should update single line status', function() {
|
||||
MockCallScreen.mUpdateSingleLineCalled = false;
|
||||
flush();
|
||||
assert.isTrue(MockCallScreen.mUpdateSingleLineCalled);
|
||||
});
|
||||
|
||||
suite('when a call is unmerged from the conference', function() {
|
||||
setup(function() {
|
||||
flush();
|
||||
|
||||
MockNavigatorMozTelephony.calls = [thirdCall];
|
||||
MockNavigatorMozTelephony.conferenceGroup.calls =
|
||||
[firstCall, secondCall];
|
||||
});
|
||||
|
||||
test('should update the group label', function() {
|
||||
flush();
|
||||
// Check the bdi node rather than the element itself
|
||||
l10nAssert(
|
||||
fakeGroupLabel.firstChild, {
|
||||
id: 'conferenceCall',
|
||||
args: { n: 2 }
|
||||
}
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
suite('when a call is disconnected from the conference', function() {
|
||||
setup(function() {
|
||||
flush();
|
||||
|
||||
MockNavigatorMozTelephony.calls = [];
|
||||
MockNavigatorMozTelephony.conferenceGroup.calls =
|
||||
[firstCall, secondCall];
|
||||
});
|
||||
|
||||
test('should update the group label', function() {
|
||||
flush();
|
||||
// Check the bdi node rather than the element itself
|
||||
l10nAssert(
|
||||
fakeGroupLabel.firstChild, {
|
||||
id: 'conferenceCall',
|
||||
args: { n: 2 }
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
test('should call CallsHandler.checkCalls if two more phones remains',
|
||||
function() {
|
||||
var checkCallsSpy = this.sinon.spy(MockCallsHandler, 'checkCalls');
|
||||
flush();
|
||||
assert.isTrue(checkCallsSpy.calledOnce);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
suite('when there are no more calls in the conference', function() {
|
||||
setup(function() {
|
||||
flush();
|
||||
|
||||
MockNavigatorMozTelephony.calls = [firstCall, secondCall];
|
||||
MockNavigatorMozTelephony.conferenceGroup.calls = [];
|
||||
});
|
||||
|
||||
test('should hide the overlay of group details', function() {
|
||||
this.sinon.spy(MockConferenceGroupUI, 'hideGroupDetails');
|
||||
this.sinon.useFakeTimers();
|
||||
flush();
|
||||
this.sinon.clock.tick();
|
||||
sinon.assert.calledOnce(MockConferenceGroupUI.hideGroupDetails);
|
||||
});
|
||||
|
||||
test('should update the calls display', function() {
|
||||
MockCallScreen.mUpdateSingleLineCalled = false;
|
||||
flush();
|
||||
assert.isTrue(MockCallScreen.mUpdateSingleLineCalled);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
suite('telephony.conferenceGroup.onstatechange handling', function() {
|
||||
var firstCall, firstHC;
|
||||
var secondCall, secondHC;
|
||||
|
||||
setup(function() {
|
||||
firstCall = new MockCall('543552', 'incoming');
|
||||
firstHC = telephonyAddCall.call(this, firstCall, {trigger: true});
|
||||
|
||||
secondCall = new MockCall('54212152', 'incoming');
|
||||
secondHC = telephonyAddCall.call(this, secondCall, {trigger: true});
|
||||
|
||||
MockNavigatorMozTelephony.calls = [];
|
||||
MockNavigatorMozTelephony.conferenceGroup.calls = [firstCall, secondCall];
|
||||
|
||||
MockNavigatorMozTelephony.mTriggerGroupCallsChanged();
|
||||
MockNavigatorMozTelephony.mTriggerCallsChanged();
|
||||
});
|
||||
|
||||
test('should start timer when connected', function() {
|
||||
assert.isFalse(MockCallScreen.mCalledCreateTicker);
|
||||
|
||||
MockNavigatorMozTelephony.conferenceGroup.state = 'connected';
|
||||
MockNavigatorMozTelephony.mTriggerGroupStateChange();
|
||||
|
||||
assert.isTrue(MockCallScreen.mCalledCreateTicker);
|
||||
});
|
||||
|
||||
test('should display the group line when connected to a group', function() {
|
||||
fakeGroupLine.classList.add('held');
|
||||
fakeGroupLine.classList.add('ended');
|
||||
|
||||
MockNavigatorMozTelephony.conferenceGroup.state = 'connected';
|
||||
MockNavigatorMozTelephony.mTriggerGroupStateChange();
|
||||
|
||||
assert.isFalse(fakeGroupLine.classList.contains('held'));
|
||||
assert.isFalse(fakeGroupLine.classList.contains('ended'));
|
||||
assert.isFalse(fakeGroupLine.hidden);
|
||||
});
|
||||
|
||||
test('should set photo when connected', function() {
|
||||
MockNavigatorMozTelephony.conferenceGroup.state = 'connected';
|
||||
MockNavigatorMozTelephony.mTriggerGroupStateChange();
|
||||
|
||||
assert.isTrue(MockCallScreen.mSetCallerContactImageCalled);
|
||||
});
|
||||
|
||||
test('should stop timer when groupcall ends', function() {
|
||||
assert.isFalse(MockCallScreen.mCalledStopTicker);
|
||||
|
||||
MockNavigatorMozTelephony.conferenceGroup.state = '';
|
||||
MockNavigatorMozTelephony.mTriggerGroupStateChange();
|
||||
|
||||
assert.isTrue(MockCallScreen.mCalledStopTicker);
|
||||
});
|
||||
|
||||
test('should add the held class once held', function() {
|
||||
assert.isFalse(fakeGroupLine.classList.contains('held'));
|
||||
|
||||
MockNavigatorMozTelephony.conferenceGroup.state = 'held';
|
||||
MockNavigatorMozTelephony.mTriggerGroupStateChange();
|
||||
|
||||
assert.isTrue(fakeGroupLine.classList.contains('held'));
|
||||
});
|
||||
|
||||
test('should remove the held class when connected', function() {
|
||||
MockNavigatorMozTelephony.conferenceGroup.state = 'held';
|
||||
MockNavigatorMozTelephony.mTriggerGroupStateChange();
|
||||
|
||||
assert.isTrue(fakeGroupLine.classList.contains('held'));
|
||||
|
||||
MockNavigatorMozTelephony.conferenceGroup.state = 'connected';
|
||||
MockNavigatorMozTelephony.mTriggerGroupStateChange();
|
||||
|
||||
assert.isFalse(fakeGroupLine.classList.contains('held'));
|
||||
});
|
||||
|
||||
test('should call CallsHandler.checkCalls when exiting conference call',
|
||||
function() {
|
||||
var checkCallsSpy = this.sinon.spy(MockCallsHandler, 'checkCalls');
|
||||
MockNavigatorMozTelephony.conferenceGroup.state = '';
|
||||
MockNavigatorMozTelephony.mTriggerGroupStateChange();
|
||||
|
||||
assert.isTrue(checkCallsSpy.calledOnce);
|
||||
});
|
||||
|
||||
test('should show call ended when exiting conference call', function() {
|
||||
MockNavigatorMozTelephony.conferenceGroup.state = '';
|
||||
MockNavigatorMozTelephony.mTriggerGroupStateChange();
|
||||
l10nAssert(fakeDurationChildNode, 'callEnded');
|
||||
});
|
||||
|
||||
test('should show call the duration when exiting conference call',
|
||||
function() {
|
||||
var totalCallDuration = '12:34';
|
||||
fakeDurationChildNode.textContent = totalCallDuration;
|
||||
MockNavigatorMozTelephony.conferenceGroup.state = '';
|
||||
MockNavigatorMozTelephony.mTriggerGroupStateChange();
|
||||
assert.deepEqual(fakeTotalDurationChildNode.textContent,
|
||||
totalCallDuration);
|
||||
});
|
||||
|
||||
test('should hide the group line after leaving conference call',
|
||||
function() {
|
||||
fakeGroupLine.hidden = false;
|
||||
this.sinon.useFakeTimers();
|
||||
|
||||
MockNavigatorMozTelephony.conferenceGroup.state = '';
|
||||
MockNavigatorMozTelephony.mTriggerGroupStateChange();
|
||||
|
||||
assert.isFalse(fakeGroupLine.hidden);
|
||||
assert.isTrue(fakeGroupLine.classList.contains('ended'));
|
||||
|
||||
this.sinon.clock.tick(2000);
|
||||
assert.isTrue(fakeGroupLine.hidden);
|
||||
});
|
||||
});
|
||||
|
||||
suite('Resizing the call ended string', function() {
|
||||
suiteSetup(function() {
|
||||
fakeDurationChildNode.removeAttribute('data-l10n-id');
|
||||
});
|
||||
|
||||
setup(function() {
|
||||
this.sinon.spy(fakeMutationObserver, 'disconnect');
|
||||
this.sinon.spy(fakeMutationObserver, 'observe');
|
||||
this.sinon.spy(FontSizeManager, 'adaptToSpace');
|
||||
});
|
||||
|
||||
teardown(function() {
|
||||
fakeDurationChildNode.removeAttribute('data-l10n-id');
|
||||
fakeDurationChildNode.textContent = '';
|
||||
});
|
||||
|
||||
test('Does not resize the string if no l10n attribute is present',
|
||||
function() {
|
||||
fakeDurationChildNode.textContent = 'Call ended';
|
||||
fakeMutationObserver.mTriggerCallback();
|
||||
sinon.assert.notCalled(fakeMutationObserver.disconnect);
|
||||
sinon.assert.notCalled(fakeMutationObserver.observe);
|
||||
sinon.assert.notCalled(FontSizeManager.adaptToSpace);
|
||||
});
|
||||
|
||||
test('Disconnects and reconnects the observer before adjusting the string',
|
||||
function() {
|
||||
MockCallScreen.mScenario = FontSizeManager.SINGLE_CALL;
|
||||
fakeDurationChildNode.setAttribute('data-l10n-id', 'callEnded');
|
||||
fakeMutationObserver.mTriggerCallback();
|
||||
assert.isTrue(
|
||||
fakeMutationObserver.disconnect.calledBefore(
|
||||
FontSizeManager.adaptToSpace
|
||||
)
|
||||
);
|
||||
assert.isTrue(
|
||||
fakeMutationObserver.observe.calledAfter(
|
||||
FontSizeManager.adaptToSpace
|
||||
)
|
||||
);
|
||||
sinon.assert.calledWith(
|
||||
FontSizeManager.adaptToSpace, FontSizeManager.SINGLE_CALL,
|
||||
fakeGroupLabel, false, 'end');
|
||||
});
|
||||
});
|
||||
|
||||
suite('public API', function() {
|
||||
test('currentDuration', function() {
|
||||
fakeDurationChildNode.textContent = '12:34';
|
||||
assert.equal(ConferenceGroupHandler.currentDuration, '12:34');
|
||||
});
|
||||
|
||||
test('addToGroupDetails()', function() {
|
||||
this.sinon.spy(MockConferenceGroupUI ,'addCall');
|
||||
ConferenceGroupHandler.addToGroupDetails(fakeGroupLine);
|
||||
sinon.assert.calledWith(MockConferenceGroupUI.addCall, fakeGroupLine);
|
||||
});
|
||||
|
||||
test('isGroupDetailsShown()', function() {
|
||||
this.sinon.spy(MockConferenceGroupUI ,'isGroupDetailsShown');
|
||||
ConferenceGroupHandler.isGroupDetailsShown();
|
||||
sinon.assert.calledOnce(MockConferenceGroupUI.isGroupDetailsShown);
|
||||
});
|
||||
|
||||
test('removeFromGroupDetails()', function() {
|
||||
this.sinon.spy(MockConferenceGroupUI ,'removeCall');
|
||||
ConferenceGroupHandler.removeFromGroupDetails(fakeGroupLine);
|
||||
sinon.assert.calledWith(MockConferenceGroupUI.removeCall, fakeGroupLine);
|
||||
});
|
||||
|
||||
test('signalConferenceEnded()', function() {
|
||||
this.sinon.spy(MockConferenceGroupUI ,'markCallsAsEnded');
|
||||
ConferenceGroupHandler.signalConferenceEnded();
|
||||
sinon.assert.calledOnce(MockConferenceGroupUI.markCallsAsEnded);
|
||||
});
|
||||
});
|
||||
});
|
||||
133
gaia/apps/callscreen/test/unit/conference_group_ui_test.js
Executable file
133
gaia/apps/callscreen/test/unit/conference_group_ui_test.js
Executable file
|
|
@ -0,0 +1,133 @@
|
|||
/* globals ConferenceGroupUI, LazyLoader, MockCallScreen,
|
||||
MockNavigatorMozTelephony, MocksHelper */
|
||||
/*jshint unused:false*/
|
||||
'use strict';
|
||||
|
||||
require('/shared/test/unit/load_body_html_helper.js');
|
||||
require('/shared/test/unit/mocks/mock_lazy_loader.js');
|
||||
require('/shared/test/unit/mocks/mock_navigator_moz_telephony.js');
|
||||
require('/test/unit/mock_call_screen.js');
|
||||
|
||||
var mocksHelperForCallsHandler = new MocksHelper([
|
||||
'CallScreen',
|
||||
'LazyLoader'
|
||||
]).init();
|
||||
|
||||
suite('conference group ui', function() {
|
||||
var realMozTelephony,
|
||||
container;
|
||||
|
||||
mocksHelperForCallsHandler.attachTestHelpers();
|
||||
|
||||
suiteSetup(function(done) {
|
||||
realMozTelephony = navigator.mozTelephony;
|
||||
navigator.mozTelephony = MockNavigatorMozTelephony;
|
||||
|
||||
loadBodyHTML('/elements/conference_group_details.html');
|
||||
var conferenceGroupDetailsTemplate =
|
||||
document.body.querySelector('template');
|
||||
|
||||
loadBodyHTML('/test/unit/mock_group_call.html');
|
||||
|
||||
var groupCallDetails = document.getElementById('group-call-details');
|
||||
groupCallDetails.innerHTML = '';
|
||||
groupCallDetails.appendChild(
|
||||
conferenceGroupDetailsTemplate.content.cloneNode(true));
|
||||
|
||||
require('/js/conference_group_ui.js', done);
|
||||
});
|
||||
|
||||
suiteTeardown(function() {
|
||||
navigator.mozTelephony = realMozTelephony;
|
||||
});
|
||||
|
||||
suite('group details button listeners', function() {
|
||||
test('showing the group details overlay', function() {
|
||||
assert.isFalse(
|
||||
document.getElementById('group-call-details').classList.
|
||||
contains('display'));
|
||||
document.getElementById('group-show').click();
|
||||
assert.isTrue(
|
||||
document.getElementById('group-call-details').classList.
|
||||
contains('display'));
|
||||
});
|
||||
|
||||
test('hiding the group details overlay', function() {
|
||||
this.sinon.useFakeTimers();
|
||||
// Force the ConferenceGroupUI initialization code to run adding a call
|
||||
// to the group details overlay.
|
||||
var fakeNode = document.createElement('section');
|
||||
ConferenceGroupUI.addCall(fakeNode);
|
||||
ConferenceGroupUI.showGroupDetails();
|
||||
assert.isTrue(
|
||||
document.getElementById('group-call-details').classList.
|
||||
contains('display'));
|
||||
document.getElementById('group-hide').click();
|
||||
this.sinon.clock.tick();
|
||||
assert.isFalse(
|
||||
document.getElementById('group-call-details').classList.
|
||||
contains('display'));
|
||||
});
|
||||
});
|
||||
|
||||
suite('addCall', function() {
|
||||
test('should insert the node in the group calls article', function() {
|
||||
var fakeNode = document.createElement('section');
|
||||
ConferenceGroupUI.addCall(fakeNode);
|
||||
assert.equal(fakeNode.parentNode.id, 'group-call-details-list');
|
||||
});
|
||||
});
|
||||
|
||||
suite('removeCall', function() {
|
||||
var fakeNode = document.createElement('section');
|
||||
test('should remove the node in the groupList', function() {
|
||||
ConferenceGroupUI.addCall(fakeNode);
|
||||
ConferenceGroupUI.removeCall(fakeNode);
|
||||
assert.equal(fakeNode.parentNode, null);
|
||||
});
|
||||
});
|
||||
|
||||
suite('showGroupDetails', function() {
|
||||
test('should show group details', function() {
|
||||
ConferenceGroupUI.showGroupDetails();
|
||||
assert.isTrue(
|
||||
document.getElementById('group-call-details').classList.
|
||||
contains('display'));
|
||||
});
|
||||
});
|
||||
|
||||
suite('hideGroupDetails', function() {
|
||||
test('should hide group details', function() {
|
||||
this.sinon.useFakeTimers();
|
||||
ConferenceGroupUI.showGroupDetails();
|
||||
assert.isTrue(
|
||||
document.getElementById('group-call-details').classList.
|
||||
contains('display'));
|
||||
ConferenceGroupUI.hideGroupDetails();
|
||||
this.sinon.clock.tick(MockCallScreen.callEndPromptTime);
|
||||
assert.isFalse(
|
||||
document.getElementById('group-call-details').classList.
|
||||
contains('display'));
|
||||
});
|
||||
});
|
||||
|
||||
suite('set end conference call', function() {
|
||||
var fakeNode1 = document.createElement('section');
|
||||
var fakeNode2 = document.createElement('section');
|
||||
var fakeNode3 = document.createElement('section');
|
||||
|
||||
setup(function() {
|
||||
ConferenceGroupUI.addCall(fakeNode1);
|
||||
ConferenceGroupUI.addCall(fakeNode2);
|
||||
ConferenceGroupUI.addCall(fakeNode3);
|
||||
});
|
||||
|
||||
test('should set groupHangup to all nodes in group detail lists',
|
||||
function() {
|
||||
ConferenceGroupUI.markCallsAsEnded();
|
||||
assert.equal(fakeNode1.dataset.groupHangup, 'groupHangup');
|
||||
assert.equal(fakeNode2.dataset.groupHangup, 'groupHangup');
|
||||
assert.equal(fakeNode3.dataset.groupHangup, 'groupHangup');
|
||||
});
|
||||
});
|
||||
});
|
||||
1115
gaia/apps/callscreen/test/unit/handled_call_test.js
Executable file
1115
gaia/apps/callscreen/test/unit/handled_call_test.js
Executable file
File diff suppressed because it is too large
Load diff
52
gaia/apps/callscreen/test/unit/index_test.js
Executable file
52
gaia/apps/callscreen/test/unit/index_test.js
Executable file
|
|
@ -0,0 +1,52 @@
|
|||
/* globals onLoadCallScreen, MockKeypadManager,
|
||||
MocksHelper, unloadCallScreen */
|
||||
|
||||
'use strict';
|
||||
|
||||
require('/shared/test/unit/mocks/dialer/mock_calls_handler.js');
|
||||
require('/shared/test/unit/mocks/dialer/mock_keypad.js');
|
||||
|
||||
require('/test/unit/mock_call_screen.js');
|
||||
|
||||
var mocksHelperForIndex = new MocksHelper([
|
||||
'CallScreen',
|
||||
'CallsHandler',
|
||||
'KeypadManager'
|
||||
]).init();
|
||||
|
||||
suite('index.js', function() {
|
||||
mocksHelperForIndex.attachTestHelpers();
|
||||
|
||||
setup(function(done) {
|
||||
this.sinon.spy(window, 'addEventListener');
|
||||
|
||||
require('/js/index.js', done);
|
||||
});
|
||||
|
||||
teardown(function() {
|
||||
window.removeEventListener('load', onLoadCallScreen);
|
||||
window.removeEventListener('unload', unloadCallScreen);
|
||||
});
|
||||
|
||||
suite('loading', function() {
|
||||
test('onload/onunload handlers are properly registered', function() {
|
||||
sinon.assert.calledWith(window.addEventListener, 'load',
|
||||
onLoadCallScreen);
|
||||
sinon.assert.calledWith(window.addEventListener, 'unload',
|
||||
unloadCallScreen);
|
||||
});
|
||||
});
|
||||
|
||||
suite('initialization', function() {
|
||||
setup(function() {
|
||||
this.sinon.spy(MockKeypadManager, 'init');
|
||||
|
||||
onLoadCallScreen();
|
||||
});
|
||||
|
||||
test('all components are initialized with the proper parameters',
|
||||
function() {
|
||||
sinon.assert.calledWith(MockKeypadManager.init, /* oncall */ true);
|
||||
});
|
||||
});
|
||||
});
|
||||
178
gaia/apps/callscreen/test/unit/mock_call_screen.js
Executable file
178
gaia/apps/callscreen/test/unit/mock_call_screen.js
Executable file
|
|
@ -0,0 +1,178 @@
|
|||
/* exported MockCallScreen */
|
||||
|
||||
'use strict';
|
||||
|
||||
var MockCallScreen = {
|
||||
/**
|
||||
* Setting mScenario to a non-valid value taking into consideration the
|
||||
* possible scenario values as declared in FontSizeManager.
|
||||
*/
|
||||
mScenario: -1,
|
||||
callEndPromptTime: 2000,
|
||||
|
||||
init: function() {},
|
||||
insertCall: function() {},
|
||||
enableKeypadButton: function() {},
|
||||
disableKeypadButton: function() {},
|
||||
enablePlaceNewCallButton: function() {
|
||||
this.menablePlaceNewCallButtonCalled = true;
|
||||
},
|
||||
disablePlaceNewCallButton: function() {
|
||||
this.menablePlaceNewCallButtonCalled = false;
|
||||
},
|
||||
enableMuteButton: function() {
|
||||
this.menableMuteButtonCalled = true;
|
||||
},
|
||||
disableMuteButton: function() {
|
||||
this.menableMuteButtonCalled = false;
|
||||
},
|
||||
enableSpeakerButton: function() {
|
||||
this.menableSpeakerButtonCalled = true;
|
||||
},
|
||||
disableSpeakerButton: function() {
|
||||
this.menableSpeakerButtonCalled = false;
|
||||
},
|
||||
showOnHoldButton: function() {
|
||||
this.mshowOnHoldButtonCalled = true;
|
||||
},
|
||||
hideOnHoldButton: function() {
|
||||
this.mhideOnHoldButtonCalled = true;
|
||||
},
|
||||
enableOnHoldButton: function() {
|
||||
this.menableOnHoldButtonCalled = true;
|
||||
},
|
||||
disableOnHoldButton: function() {
|
||||
this.menableOnHoldButtonCalled = false;
|
||||
},
|
||||
showMergeButton: function() {
|
||||
this.mShowMergeButtonCalled = true;
|
||||
},
|
||||
hideMergeButton: function() {
|
||||
this.mhideMergeButtonCalled = true;
|
||||
},
|
||||
showOnHoldAndMergeContainer: function() {},
|
||||
hideOnHoldAndMergeContainer: function() {},
|
||||
syncSpeakerEnabled: function() {
|
||||
this.mSyncSpeakerCalled = true;
|
||||
},
|
||||
setCallerContactImage: function() {
|
||||
this.mSetCallerContactImageCalled = true;
|
||||
},
|
||||
mute: function() {
|
||||
this.mMuteOn = true;
|
||||
},
|
||||
unmute: function() {
|
||||
this.mMuteOn = false;
|
||||
},
|
||||
switchToDefaultOut: function() {
|
||||
this.mSpeakerOn = false;
|
||||
},
|
||||
switchToSpeaker: function() {
|
||||
this.mSpeakerOn = true;
|
||||
},
|
||||
render: function(mode) {
|
||||
this.mLastRenderMode = mode;
|
||||
},
|
||||
showIncoming: function() {
|
||||
this.mShowIncomingCalled = true;
|
||||
},
|
||||
hideIncoming: function() {
|
||||
this.mHideIncomingCalled = true;
|
||||
},
|
||||
showStatusMessage: function(text) {
|
||||
this.mShowStatusMessageCalled = true;
|
||||
},
|
||||
setBTReceiverIcon: function() {},
|
||||
createTicker: function(node) {
|
||||
this.mCalledCreateTicker = true;
|
||||
},
|
||||
stopTicker: function(node) {
|
||||
this.mCalledStopTicker = true;
|
||||
},
|
||||
updateCallsDisplay: function() {
|
||||
this.mUpdateSingleLineCalled = true;
|
||||
},
|
||||
removeCall: function() {
|
||||
this.mRemoveCallCalled = true;
|
||||
},
|
||||
hidePlaceNewCallButton: function() {},
|
||||
showPlaceNewCallButton: function() {},
|
||||
setShowIsHeld: function() {},
|
||||
cdmaConferenceCall: function() {},
|
||||
removeEndedCalls: function() {},
|
||||
set holdAndAnswerOnly(enabled) {
|
||||
this.mHoldAndAnswerOnly = enabled;
|
||||
},
|
||||
mHoldAndAnswerOnly: false,
|
||||
|
||||
set cdmaCallWaiting(enabled) {
|
||||
this.mCdmaCallWaiting = enabled;
|
||||
},
|
||||
mCdmaCallWaiting: false,
|
||||
|
||||
get inStatusBarMode() {
|
||||
return this.mInStatusBarMode;
|
||||
},
|
||||
mInStatusBarMode: false,
|
||||
|
||||
getScenario: function() {
|
||||
this.mGetScenarioCalled = true;
|
||||
return this.mScenario;
|
||||
},
|
||||
|
||||
mGetScenarioCalled: false,
|
||||
|
||||
// Fake dom
|
||||
calls: document.createElement('div'),
|
||||
screen: document.createElement('div'),
|
||||
incomingContainer: document.createElement('div'),
|
||||
incomingInfo: document.createElement('div'),
|
||||
incomingNumber: document.createElement('div'),
|
||||
incomingSim: document.createElement('div'),
|
||||
incomingNumberAdditionalTel: document.createElement('span'),
|
||||
incomingNumberAdditionalTelType: document.createElement('span'),
|
||||
|
||||
menablePlaceNewCallButtonCalled: false,
|
||||
menableMuteButtonCalled: false,
|
||||
menableSpeakerButtonCalled: false,
|
||||
mshowOnHoldButtonCalled: false,
|
||||
mhideOnHoldButtonCalled: false,
|
||||
menableOnHoldButtonCalled: false,
|
||||
mShowMergeButtonCalled: false,
|
||||
mhideMergeButtonCalled: false,
|
||||
mSyncSpeakerCalled: false,
|
||||
mSetCallerContactImageCalled: false,
|
||||
mMuteOn: false,
|
||||
mSpeakerOn: false,
|
||||
mLastRenderMode: null,
|
||||
mTeardown: function teardown() {
|
||||
this.menablePlaceNewCallButtonCalled = false;
|
||||
this.menableMuteButtonCalled = false;
|
||||
this.menableSpeakerButtonCalled = false;
|
||||
this.mshowOnHoldButtonCalled = false,
|
||||
this.mhideOnHoldButtonCalled = false,
|
||||
this.menableOnHoldButtonCalled = false,
|
||||
this.mShowMergeButtonCalled = false,
|
||||
this.mhideMergeButtonCalled = false,
|
||||
this.mSyncSpeakerCalled = false;
|
||||
this.mSetCallerContactImageCalled = false;
|
||||
this.mMuteOn = false;
|
||||
this.mSpeakerOn = false;
|
||||
this.mLastRenderMode = null;
|
||||
this.mShowIncomingCalled = false;
|
||||
this.mHideIncomingCalled = false;
|
||||
this.mShowStatusMessageCalled = false;
|
||||
this.mCalledCreateTicker = false;
|
||||
this.mCalledStopTicker = false;
|
||||
this.mUpdateSingleLineCalled = false;
|
||||
this.calls = document.createElement('div');
|
||||
this.screen = document.createElement('div');
|
||||
this.incomingContainer = document.createElement('div');
|
||||
this.incomingInfo = document.createElement('div');
|
||||
this.incomingNumber = document.createElement('div');
|
||||
this.incomingNumberAdditionalTel = document.createElement('span');
|
||||
this.incomingNumberAdditionalTelType = document.createElement('span');
|
||||
this.mRemoveCallCalled = false;
|
||||
this.mGetScenarioCalled = false;
|
||||
}
|
||||
};
|
||||
15
gaia/apps/callscreen/test/unit/mock_conference_group_handler.js
Executable file
15
gaia/apps/callscreen/test/unit/mock_conference_group_handler.js
Executable file
|
|
@ -0,0 +1,15 @@
|
|||
/* exported MockConferenceGroupHandler */
|
||||
'use strict';
|
||||
|
||||
var MockConferenceGroupHandler = {
|
||||
mCurrentDuration: '12:34',
|
||||
get currentDuration() {
|
||||
return this.mCurrentDuration;
|
||||
},
|
||||
signalConferenceEnded: function() {},
|
||||
addToGroupDetails: function() {},
|
||||
isGroupDetailsShown: function() {},
|
||||
mTeardown: function() {
|
||||
this.mCurrentDuration = '12:34';
|
||||
}
|
||||
};
|
||||
13
gaia/apps/callscreen/test/unit/mock_conference_group_ui.js
Executable file
13
gaia/apps/callscreen/test/unit/mock_conference_group_ui.js
Executable file
|
|
@ -0,0 +1,13 @@
|
|||
/* exported MockConferenceGroupUI */
|
||||
|
||||
'use strict';
|
||||
|
||||
var MockConferenceGroupUI = {
|
||||
addCall: function() {},
|
||||
removeCall: function() {},
|
||||
showGroupDetails: function() {},
|
||||
hideGroupDetails: function() {},
|
||||
isGroupDetailsShown: function() {},
|
||||
markCallsAsEnded: function() {},
|
||||
setGroupDetailsHeader: function() {}
|
||||
};
|
||||
19
gaia/apps/callscreen/test/unit/mock_group_call.html
Executable file
19
gaia/apps/callscreen/test/unit/mock_group_call.html
Executable file
|
|
@ -0,0 +1,19 @@
|
|||
<article id="call-screen" data-layout class="displayed">
|
||||
<article id="calls" data-count="0">
|
||||
<section id="group-call" hidden>
|
||||
<div class="numberWrapper">
|
||||
<div id="group-show"></div>
|
||||
<div id="group-call-label" class="number font-light"></div>
|
||||
</div>
|
||||
<div id="group-call-summary" class="additionalContactInfo font-light"></div>
|
||||
<div class="duration">
|
||||
<span class="font-light"></span>
|
||||
<div class="total-duration"></div>
|
||||
<div class="direction"></div>
|
||||
</div>
|
||||
<button class="merge-button" data-l10n-id="merge">Merge</button>
|
||||
</section>
|
||||
</article>
|
||||
<form is="conference-group-details" id="group-call-details" role="dialog" data-type="action" class="overlay">
|
||||
</form>
|
||||
</article>
|
||||
5
gaia/apps/callscreen/test/unit/setup.js
Executable file
5
gaia/apps/callscreen/test/unit/setup.js
Executable file
|
|
@ -0,0 +1,5 @@
|
|||
'use strict';
|
||||
|
||||
/* global require */
|
||||
|
||||
require('/shared/test/unit/mocks/mocks_helper.js');
|
||||
Loading…
Reference in a new issue