Skip to content

Commit

Permalink
Merge pull request mozilla-b2g#8107 from ferjm/bug838622
Browse files Browse the repository at this point in the history
Bug 838622 - [Dialer] USSD unit tests are failing; r=arcturus(cherry picked from commit 362518d)
  • Loading branch information
ferjm authored and jhford committed Feb 16, 2013
1 parent e93c90b commit 5e064fb
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 35 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ var MockMozMobileConnection = {
ICC_SERVICE_CLASS_DATA_ASYNC: (1 << 5),
ICC_SERVICE_CLASS_PACKET: (1 << 6),
ICC_SERVICE_CLASS_PAD: (1 << 7),
ICC_SERVICE_CLASS_MAX: (1 << 7),

addEventListener: function mmmc_addEventListener(event_name, listener) {
},
Expand Down
4 changes: 4 additions & 0 deletions apps/communications/dialer/test/unit/mock_ussd_ui.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ var MockUssdUI = {
UssdManager.handleEvent(evt);
},

close: function muui_close() {
this.ready = false;
},

teardown: function mmui_mTeardown() {
this._messageReceived = null;
}
Expand Down
15 changes: 15 additions & 0 deletions apps/communications/dialer/test/unit/mock_utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,21 @@ var MockUtils = {
this.mCalledHeaderDate = false;
this.mCalledGetDayDate = false;
this.mCalledGetPhoneNumberAdditionalInfo = false;
},

getPhoneNumberPrimaryInfo: function ut_getPhoneNumberPrimaryInfo(matchingTel,
contact) {
if (contact) {
if (contact.name && String(contact.name) !== '') {
return contact.name;
} else if (contact.org && String(contact.org) !== '') {
return contact.org;
}
}
if (matchingTel) {
return matchingTel.value;
}
return null;
}
};

42 changes: 7 additions & 35 deletions apps/communications/dialer/test/unit/ussd_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,39 +6,19 @@ requireApp('communications/dialer/test/unit/mock_mozMobileConnection.js');
const TINY_TIMEOUT = 5;

suite('dialer/ussd', function() {
var realL10n = navigator.mozL10n;
navigator.mozL10n = (function() {
var keys = {};

function reset() {
keys = {};
}

function get(key, params) {
keys[key] = params;
return key;
}

function getKeys() {
return keys;
}

return {
get: get,
reset: reset,
keys: getKeys
};
})();
var keys = {};

suiteSetup(function() {
navigator.mozL10n.reset();
UssdManager._conn = MockMozMobileConnection;
UssdManager.init();
UssdManager._popup = MockUssdUI;
UssdManager._ = function get(key, params) {
keys[key] = params;
return key;
}
UssdManager.ready = true;
});

suiteTeardown(function() {
navigator.mozL10n = realL10n;
UssdManager._popup = null;
});

Expand Down Expand Up @@ -193,7 +173,6 @@ suite('dialer/ussd', function() {
test('Check call forwarding rules', function(done) {
UssdManager.send(MMI_CF_MSG_ACTIVE_VOICE);
setTimeout(function() {
var keys = navigator.mozL10n.keys();
assert.equal(keys['cf-voice'].voice, EXPECTED_PHONE);
assert.equal(keys['cf-data'].data, 'cf-inactive');
assert.equal(keys['cf-fax'].fax, 'cf-inactive');
Expand All @@ -215,7 +194,6 @@ suite('dialer/ussd', function() {
test('Check call forwarding rules', function(done) {
UssdManager.send(MMI_CF_MSG_ACTIVE_DATA);
setTimeout(function() {
var keys = navigator.mozL10n.keys();
assert.equal(keys['cf-data'].data, EXPECTED_PHONE);
assert.equal(keys['cf-voice'].voice, 'cf-inactive');
assert.equal(keys['cf-fax'].fax, 'cf-inactive');
Expand All @@ -237,7 +215,6 @@ suite('dialer/ussd', function() {
test('Check call forwarding rules', function(done) {
UssdManager.send(MMI_CF_MSG_ACTIVE_DATA_SYNC);
setTimeout(function() {
var keys = navigator.mozL10n.keys();
assert.equal(keys['cf-sync'].sync, EXPECTED_PHONE);
assert.equal(keys['cf-data'].data, 'cf-inactive');
assert.equal(keys['cf-voice'].voice, 'cf-inactive');
Expand All @@ -259,7 +236,6 @@ suite('dialer/ussd', function() {
test('Check call forwarding rules', function(done) {
UssdManager.send(MMI_CF_MSG_ACTIVE_DATA_ASYNC);
setTimeout(function() {
var keys = navigator.mozL10n.keys();
assert.equal(keys['cf-async'].async, EXPECTED_PHONE);
assert.equal(keys['cf-sync'].sync, 'cf-inactive');
assert.equal(keys['cf-data'].data, 'cf-inactive');
Expand All @@ -281,7 +257,6 @@ suite('dialer/ussd', function() {
test('Check call forwarding rules', function(done) {
UssdManager.send(MMI_CF_MSG_ACTIVE_PACKET);
setTimeout(function() {
var keys = navigator.mozL10n.keys();
assert.equal(keys['cf-packet'].packet, EXPECTED_PHONE);
assert.equal(keys['cf-async'].async, 'cf-inactive');
assert.equal(keys['cf-sync'].sync, 'cf-inactive');
Expand All @@ -303,7 +278,6 @@ suite('dialer/ussd', function() {
test('Check call forwarding rules', function(done) {
UssdManager.send(MMI_CF_MSG_ACTIVE_PAD);
setTimeout(function() {
var keys = navigator.mozL10n.keys();
assert.equal(keys['cf-pad'].pad, EXPECTED_PHONE);
assert.equal(keys['cf-packet'].packet, 'cf-inactive');
assert.equal(keys['cf-async'].async, 'cf-inactive');
Expand All @@ -325,7 +299,6 @@ suite('dialer/ussd', function() {
test('Check call forwarding rules', function(done) {
UssdManager.send(MMI_CF_MSG_ALL_INACTIVE);
setTimeout(function() {
var keys = navigator.mozL10n.keys();
assert.equal(keys['cf-voice'].voice, 'cf-inactive');
assert.equal(keys['cf-data'].data, 'cf-inactive');
assert.equal(keys['cf-fax'].fax, 'cf-inactive');
Expand All @@ -347,7 +320,6 @@ suite('dialer/ussd', function() {
test('Check call forwarding rules', function(done) {
UssdManager.send(MMI_CF_MSG_TWO_RULES);
setTimeout(function() {
var keys = navigator.mozL10n.keys();
assert.equal(keys['cf-voice'].voice, EXPECTED_PHONE);
assert.equal(keys['cf-data'].data, EXPECTED_PHONE);
assert.equal(keys['cf-fax'].fax, 'cf-inactive');
Expand All @@ -368,7 +340,7 @@ suite('dialer/ussd', function() {
});

test('Check call forwarding rules', function() {
assert.equal(UssdManager._popup._messageReceived, 'cf-error');
assert.equal(UssdManager._popup._messageReceived, null);
});
});
});

0 comments on commit 5e064fb

Please sign in to comment.