Skip to content
This repository has been archived by the owner on Nov 3, 2021. It is now read-only.

Commit

Permalink
Merge pull request #19153 from frsela/STK/Bug999235_v1.4
Browse files Browse the repository at this point in the history
Bug 999235 - STK: Gaia is sending random Terminal Response in response to proactive commands form the STK app.
  • Loading branch information
rvandermeulen committed May 21, 2014
2 parents 5cf90f2 + 00802a8 commit 496953d
Show file tree
Hide file tree
Showing 3 changed files with 117 additions and 82 deletions.
16 changes: 10 additions & 6 deletions apps/settings/js/icc.js
Expand Up @@ -68,8 +68,14 @@
};
}

function returnToSettingsMainMenu() {
if (Settings) {
Settings.currentPanel = '#root';
}
}

function stkResTerminate(message) {
Settings.currentPanel = '#root';
returnToSettingsMainMenu();
responseSTKCommand(message, {
resultCode: iccManager.STK_RESULT_UICC_SESSION_TERM_BY_USER
}, true);
Expand All @@ -85,9 +91,7 @@
reqTimerGoBack.onsuccess = function icc_getTimerGoBackSuccess() {
goBackTimer.timeout = reqTimerGoBack.result['icc.goBackTimeout'];
goBackTimer.timer = setTimeout(function() {
if (Settings) {
Settings.currentPanel = '#root';
}
returnToSettingsMainMenu();
}, goBackTimer.timeout);
};
};
Expand All @@ -99,9 +103,9 @@
selectTimer.timeout = reqTimerSelect.result['icc.selectTimeout'];
selectTimer.timer = setTimeout(function() {
responseSTKCommand(message, {
resultCode: iccManager.STK_RESULT_NO_RESPONSE_FROM_USER
resultCode: iccManager.STK_RESULT_NO_RESPONSE_FROM_USER
}, true);
stkResGoBack(message);
returnToSettingsMainMenu();
}, selectTimer.timeout);
};
};
Expand Down
179 changes: 105 additions & 74 deletions apps/settings/test/unit/icc_test.js
Expand Up @@ -40,9 +40,36 @@ if (!window.reopenSettings) {
}

suite('STK (App menu) >', function() {
setup(function() {
mocksHelper.setup();
suiteSetup(function(done) {
// Load markup of settings APP
loadBodyHTML('/index.html');
// Inject the panel of downloads
var importHook = document.createElement('link');
importHook.setAttribute('rel', 'import');
importHook.setAttribute('href', '/elements/icc.html');
document.head.appendChild(importHook);

realL10n = navigator.mozL10n;
navigator.mozL10n = MockL10n;
realMozSettings = navigator.mozSettings;
navigator.mozSettings = MockNavigatorSettings;
realMozIccManager = navigator.mozIccManager;
navigator.mozIccManager = MockNavigatorMozIccManager;
realDUMP = window.DUMP;
window.DUMP = MockDump.disable();
realReopenSettings = window.reopenSettings;
window.reopenSettings = function mockReopenSettings() {};
mocksHelper = new MocksHelper(mocksForIccApp);
mocksHelper.suiteSetup();

HtmlImports.populate(function() {
window.addEventListener('iccPageLoaded', function onLoaded(event) {
done();
});
requireApp('settings/js/icc.js');
});

// Test commands
this.items = [{
'identifier': 2,
'text': 'Item stkItemsNaiSetUpCall',
Expand Down Expand Up @@ -129,96 +156,100 @@ suite('STK (App menu) >', function() {
}
}
}}});
window.dispatchEvent(this.StkCommandEvent);
});

teardown(function() {
mocksHelper.teardown();
suiteTeardown(function() {
mocksHelper.suiteTeardown();
navigator.mozL10n = realL10n;
navigator.mozSettings = realMozSettings;
navigator.mozIccManager = realMozIccManager;
window.DUMP = realDUMP;
window.reopenSettings = realReopenSettings;
});

suiteSetup(function(done) {
// Load markup of settings APP
loadBodyHTML('/index.html');
// Inject the panel of downloads
var importHook = document.createElement('link');
importHook.setAttribute('rel', 'import');
importHook.setAttribute('href', '/elements/icc.html');
document.head.appendChild(importHook);
suite('UI checks >', function() {
setup(function() {
mocksHelper.setup();
window.dispatchEvent(this.StkCommandEvent);
});

realL10n = navigator.mozL10n;
navigator.mozL10n = MockL10n;
realMozSettings = navigator.mozSettings;
navigator.mozSettings = MockNavigatorSettings;
realMozIccManager = navigator.mozIccManager;
navigator.mozIccManager = MockNavigatorMozIccManager;
realDUMP = window.DUMP;
window.DUMP = MockDump.disable();
realReopenSettings = window.reopenSettings;
window.reopenSettings = function mockReopenSettings() {};
mocksHelper = new MocksHelper(mocksForIccApp);
mocksHelper.suiteSetup();
teardown(function() {
mocksHelper.teardown();
});

HtmlImports.populate(function() {
window.addEventListener('iccPageLoaded', function onLoaded(event) {
done();
});
requireApp('settings/js/icc.js');
test('Check initialization', function() {
assert.ok(document.getElementById('icc-stk-app-back'));
assert.ok(document.getElementById('icc-stk-help-exit'));
assert.ok(document.getElementById('icc-stk-exit'));
assert.ok(document.getElementById('icc-stk-header'));
assert.ok(document.getElementById('icc-stk-subheader'));
assert.ok(document.getElementById('icc-stk-list'));
});
});

test('Check initialization', function() {
assert.ok(document.getElementById('icc-stk-app-back'));
assert.ok(document.getElementById('icc-stk-help-exit'));
assert.ok(document.getElementById('icc-stk-exit'));
assert.ok(document.getElementById('icc-stk-header'));
assert.ok(document.getElementById('icc-stk-subheader'));
assert.ok(document.getElementById('icc-stk-list'));
});
test('Correct number of entries into the STK options list', function() {
// The list contains all the items plus the help entry
assert.equal(document.getElementById('icc-stk-list').childElementCount,
this.items.length + 1);
});

test('All items with correct data', function() {
this.items.forEach(function(item, index) {
assert.equal(document.querySelector('#icc-stk-list li:nth-child(' +
(index + 1) + ') a').textContent, item.text);
});
});

test('Help entry showed (isHelpAvailable)', function() {
assert.equal(document.querySelector('#icc-stk-list li:nth-child(' +
(this.items.length + 1) + ') a').textContent,
'operatorServices-helpmenu');
});

test('Correct number of entries into the STK options list', function() {
// The list contains all the items plus the help entry
assert.equal(document.getElementById('icc-stk-list').childElementCount,
this.items.length + 1);
});
test('STK Header', function() {
assert.equal(document.getElementById('icc-stk-header').textContent,
'Dummy Test Menu');
});

test('All items with correct data', function() {
this.items.forEach(function(item, index) {
assert.equal(document.querySelector('#icc-stk-list li:nth-child(' +
(index + 1) + ') a').textContent, item.text);
test('All items with correct NAI data', function() {
this.items.forEach(function(item, index) {
assert.equal(document.querySelector('#icc-stk-list li:nth-child(' +
(index + 1) + ') small').textContent, item.nai);
});
});
});

test('Help entry showed (isHelpAvailable)', function() {
assert.equal(document.querySelector('#icc-stk-list li:nth-child(' +
(this.items.length + 1) + ') a').textContent,
'operatorServices-helpmenu');
test('All items with correct data', function() {
this.items.forEach(function(item, index) {
assert.equal(document.querySelector('#icc-stk-list li:nth-child(' +
(index + 1) + ') a').textContent, item.text);
});
});
});

test('STK Header', function() {
assert.equal(document.getElementById('icc-stk-header').textContent,
'Dummy Test Menu');
});
suite('Check timeouts >', function() {
var fakeClock = null;

test('All items with correct NAI data', function() {
this.items.forEach(function(item, index) {
assert.equal(document.querySelector('#icc-stk-list li:nth-child(' +
(index + 1) + ') small').textContent, item.nai);
setup(function() {
fakeClock = this.sinon.useFakeTimers();
mocksHelper.setup();
});
});

test('All items with correct data', function() {
this.items.forEach(function(item, index) {
assert.equal(document.querySelector('#icc-stk-list li:nth-child(' +
(index + 1) + ') a').textContent, item.text);
teardown(function() {
fakeClock.restore();
mocksHelper.teardown();
});
});

suiteTeardown(function() {
mocksHelper.suiteTeardown();
navigator.mozL10n = realL10n;
navigator.mozSettings = realMozSettings;
navigator.mozIccManager = realMozIccManager;
window.DUMP = realDUMP;
window.reopenSettings = realReopenSettings;
test('Wait for timeout (1 sec)', function(done) {
var testTimeout = 1000;
navigator.mozIccManager.getIccById('12345').sendStkResponse =
function(msg, res) {
assert.equal(res.resultCode,
navigator.mozIccManager.STK_RESULT_NO_RESPONSE_FROM_USER);
done();
};

MockNavigatorSettings.mSettings['icc.selectTimeout'] = testTimeout;
window.dispatchEvent(this.StkCommandEvent);
fakeClock.tick(testTimeout);
});
});
});
4 changes: 2 additions & 2 deletions apps/settings/test/unit/mock_navigator_settings.js
Expand Up @@ -21,9 +21,9 @@
return settingsRequest;
}

function mns_mLockGet() {
function mns_mLockGet(name) {
var settingsRequest = {
result: {}
result: settings
};

setTimeout(function() {
Expand Down

0 comments on commit 496953d

Please sign in to comment.