This repository has been archived by the owner on Aug 4, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Bug 824717 - Part 7: Modify and Add test cases to check the message i…
…d and message content when failed to send SMS/MMS message. r=vyang
- Loading branch information
Bevis Tseng
committed
Apr 29, 2014
1 parent
0035fce
commit 452ae35
Showing
4 changed files
with
197 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
105 changes: 105 additions & 0 deletions
105
dom/mobilemessage/tests/marionette/test_error_of_sms_send.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
/* Any copyright is dedicated to the Public Domain. | ||
* http://creativecommons.org/publicdomain/zero/1.0/ */ | ||
|
||
MARIONETTE_TIMEOUT = 60000; | ||
MARIONETTE_HEAD_JS = 'head.js'; | ||
|
||
const kPrefRilRadioDisabled = "ril.radio.disabled"; | ||
|
||
let connection; | ||
function ensureMobileConnection() { | ||
let deferred = Promise.defer(); | ||
|
||
let permissions = [{ | ||
"type": "mobileconnection", | ||
"allow": true, | ||
"context": document, | ||
}]; | ||
SpecialPowers.pushPermissions(permissions, function() { | ||
ok(true, "permissions pushed: " + JSON.stringify(permissions)); | ||
|
||
connection = window.navigator.mozMobileConnections[0]; | ||
if (connection) { | ||
log("navigator.mozMobileConnections[0] is instance of " + connection.constructor); | ||
} else { | ||
log("navigator.mozMobileConnections[0] is undefined."); | ||
} | ||
|
||
if (connection instanceof MozMobileConnection) { | ||
deferred.resolve(connection); | ||
} else { | ||
deferred.reject(); | ||
} | ||
}); | ||
|
||
return deferred.promise; | ||
} | ||
|
||
function waitRadioState(state) { | ||
let deferred = Promise.defer(); | ||
|
||
waitFor(function() { | ||
deferred.resolve(); | ||
}, function() { | ||
return connection.radioState == state; | ||
}); | ||
|
||
return deferred.promise; | ||
} | ||
|
||
function setRadioEnabled(enabled) { | ||
log("setRadioEnabled to " + enabled); | ||
|
||
let deferred = Promise.defer(); | ||
|
||
let finalState = (enabled) ? "enabled" : "disabled"; | ||
connection.onradiostatechange = function() { | ||
let state = connection.radioState; | ||
log("Received 'radiostatechange' event, radioState: " + state); | ||
|
||
if (state == finalState) { | ||
deferred.resolve(); | ||
connection.onradiostatechange = null; | ||
} | ||
}; | ||
|
||
let req = connection.setRadioEnabled(enabled); | ||
|
||
req.onsuccess = function() { | ||
log("setRadioEnabled success"); | ||
}; | ||
|
||
req.onerror = function() { | ||
ok(false, "setRadioEnabled should not fail"); | ||
deferred.reject(); | ||
}; | ||
|
||
return deferred.promise; | ||
} | ||
|
||
function testSendFailed(aCause) { | ||
log("testSendFailed, aCause: " + aCause); | ||
|
||
let testReceiver = "+0987654321"; | ||
let testMessage = "quick fox jump over the lazy dog"; | ||
|
||
return sendSmsWithFailure(testReceiver, testMessage) | ||
.then((result) => { | ||
is(result.error.name, aCause, "Checking failure cause."); | ||
|
||
let domMessage = result.error.data; | ||
is(domMessage.id, result.message.id, "Checking message id."); | ||
is(domMessage.receiver, testReceiver, "Checking receiver address."); | ||
is(domMessage.body, testMessage, "Checking message body."); | ||
is(domMessage.delivery, "error", "Checking delivery."); | ||
is(domMessage.deliveryStatus, "error", "Checking deliveryStatus."); | ||
}); | ||
} | ||
|
||
startTestCommon(function testCaseMain() { | ||
return ensureMobileConnection() | ||
.then(() => waitRadioState("enabled")) | ||
.then(() => setRadioEnabled(false)) | ||
.then(() => testSendFailed("RadioDisabledError")) | ||
.then(() => setRadioEnabled(true)); | ||
}); |