mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
a57f8f8b90
--HG-- rename : dom/sms/interfaces/nsIDOMMozSmsEvent.idl => dom/mobilemessage/interfaces/nsIDOMMozSmsEvent.idl rename : dom/sms/interfaces/nsIDOMMozSmsMessage.idl => dom/mobilemessage/interfaces/nsIDOMMozSmsMessage.idl rename : dom/sms/interfaces/nsIDOMNavigatorSms.idl => dom/mobilemessage/interfaces/nsIDOMNavigatorSms.idl rename : dom/sms/interfaces/nsIDOMSmsCursor.idl => dom/mobilemessage/interfaces/nsIDOMSmsCursor.idl rename : dom/sms/interfaces/nsIDOMSmsFilter.idl => dom/mobilemessage/interfaces/nsIDOMSmsFilter.idl rename : dom/sms/interfaces/nsIDOMSmsManager.idl => dom/mobilemessage/interfaces/nsIDOMSmsManager.idl rename : dom/sms/interfaces/nsIDOMSmsRequest.idl => dom/mobilemessage/interfaces/nsIDOMSmsRequest.idl rename : dom/sms/interfaces/nsIDOMSmsSegmentInfo.idl => dom/mobilemessage/interfaces/nsIDOMSmsSegmentInfo.idl rename : dom/sms/interfaces/nsISmsRequest.idl => dom/mobilemessage/interfaces/nsISmsRequest.idl rename : dom/sms/interfaces/nsISmsService.idl => dom/mobilemessage/interfaces/nsISmsService.idl rename : dom/sms/src/Constants.cpp => dom/mobilemessage/src/Constants.cpp rename : dom/sms/src/Constants.h => dom/mobilemessage/src/Constants.h rename : dom/sms/src/SmsCursor.cpp => dom/mobilemessage/src/SmsCursor.cpp rename : dom/sms/src/SmsCursor.h => dom/mobilemessage/src/SmsCursor.h rename : dom/sms/src/SmsFilter.cpp => dom/mobilemessage/src/SmsFilter.cpp rename : dom/sms/src/SmsFilter.h => dom/mobilemessage/src/SmsFilter.h rename : dom/sms/src/SmsManager.cpp => dom/mobilemessage/src/SmsManager.cpp rename : dom/sms/src/SmsManager.h => dom/mobilemessage/src/SmsManager.h rename : dom/sms/src/SmsMessage.cpp => dom/mobilemessage/src/SmsMessage.cpp rename : dom/sms/src/SmsMessage.h => dom/mobilemessage/src/SmsMessage.h rename : dom/sms/src/SmsRequest.cpp => dom/mobilemessage/src/SmsRequest.cpp rename : dom/sms/src/SmsRequest.h => dom/mobilemessage/src/SmsRequest.h rename : dom/sms/src/SmsSegmentInfo.cpp => dom/mobilemessage/src/SmsSegmentInfo.cpp rename : dom/sms/src/SmsSegmentInfo.h => dom/mobilemessage/src/SmsSegmentInfo.h rename : dom/sms/src/SmsServicesFactory.cpp => dom/mobilemessage/src/SmsServicesFactory.cpp rename : dom/sms/src/SmsServicesFactory.h => dom/mobilemessage/src/SmsServicesFactory.h rename : dom/sms/src/Types.h => dom/mobilemessage/src/Types.h rename : dom/sms/src/android/SmsService.cpp => dom/mobilemessage/src/android/SmsService.cpp rename : dom/sms/src/android/SmsService.h => dom/mobilemessage/src/android/SmsService.h rename : dom/sms/src/fallback/SmsService.cpp => dom/mobilemessage/src/fallback/SmsService.cpp rename : dom/sms/src/fallback/SmsService.h => dom/mobilemessage/src/fallback/SmsService.h rename : dom/sms/src/ipc/PSms.ipdl => dom/mobilemessage/src/ipc/PSms.ipdl rename : dom/sms/src/ipc/PSmsRequest.ipdl => dom/mobilemessage/src/ipc/PSmsRequest.ipdl rename : dom/sms/src/ipc/SmsChild.cpp => dom/mobilemessage/src/ipc/SmsChild.cpp rename : dom/sms/src/ipc/SmsChild.h => dom/mobilemessage/src/ipc/SmsChild.h rename : dom/sms/src/ipc/SmsIPCService.cpp => dom/mobilemessage/src/ipc/SmsIPCService.cpp rename : dom/sms/src/ipc/SmsIPCService.h => dom/mobilemessage/src/ipc/SmsIPCService.h rename : dom/sms/src/ipc/SmsParent.cpp => dom/mobilemessage/src/ipc/SmsParent.cpp rename : dom/sms/src/ipc/SmsParent.h => dom/mobilemessage/src/ipc/SmsParent.h rename : dom/sms/src/ipc/SmsTypes.ipdlh => dom/mobilemessage/src/ipc/SmsTypes.ipdlh rename : dom/sms/src/ipc/ipdl.mk => dom/mobilemessage/src/ipc/ipdl.mk rename : dom/sms/src/ril/SmsService.cpp => dom/mobilemessage/src/ril/SmsService.cpp rename : dom/sms/src/ril/SmsService.h => dom/mobilemessage/src/ril/SmsService.h rename : dom/sms/tests/Makefile.in => dom/mobilemessage/tests/Makefile.in rename : dom/sms/tests/marionette/manifest.ini => dom/mobilemessage/tests/marionette/manifest.ini rename : dom/sms/tests/marionette/test_between_emulators.py => dom/mobilemessage/tests/marionette/test_between_emulators.py rename : dom/sms/tests/marionette/test_bug814761.js => dom/mobilemessage/tests/marionette/test_bug814761.js rename : dom/sms/tests/marionette/test_emulator_loopback.js => dom/mobilemessage/tests/marionette/test_emulator_loopback.js rename : dom/sms/tests/marionette/test_filter_date.js => dom/mobilemessage/tests/marionette/test_filter_date.js rename : dom/sms/tests/marionette/test_filter_date_notfound.js => dom/mobilemessage/tests/marionette/test_filter_date_notfound.js rename : dom/sms/tests/marionette/test_filter_mixed.js => dom/mobilemessage/tests/marionette/test_filter_mixed.js rename : dom/sms/tests/marionette/test_filter_number_multiple.js => dom/mobilemessage/tests/marionette/test_filter_number_multiple.js rename : dom/sms/tests/marionette/test_filter_number_single.js => dom/mobilemessage/tests/marionette/test_filter_number_single.js rename : dom/sms/tests/marionette/test_filter_read.js => dom/mobilemessage/tests/marionette/test_filter_read.js rename : dom/sms/tests/marionette/test_filter_received.js => dom/mobilemessage/tests/marionette/test_filter_received.js rename : dom/sms/tests/marionette/test_filter_sent.js => dom/mobilemessage/tests/marionette/test_filter_sent.js rename : dom/sms/tests/marionette/test_filter_unread.js => dom/mobilemessage/tests/marionette/test_filter_unread.js rename : dom/sms/tests/marionette/test_getmessage.js => dom/mobilemessage/tests/marionette/test_getmessage.js rename : dom/sms/tests/marionette/test_getmessage_notfound.js => dom/mobilemessage/tests/marionette/test_getmessage_notfound.js rename : dom/sms/tests/marionette/test_getmessages.js => dom/mobilemessage/tests/marionette/test_getmessages.js rename : dom/sms/tests/marionette/test_incoming.js => dom/mobilemessage/tests/marionette/test_incoming.js rename : dom/sms/tests/marionette/test_incoming_delete.js => dom/mobilemessage/tests/marionette/test_incoming_delete.js rename : dom/sms/tests/marionette/test_incoming_max_segments.js => dom/mobilemessage/tests/marionette/test_incoming_max_segments.js rename : dom/sms/tests/marionette/test_incoming_multipart.js => dom/mobilemessage/tests/marionette/test_incoming_multipart.js rename : dom/sms/tests/marionette/test_mark_msg_read.js => dom/mobilemessage/tests/marionette/test_mark_msg_read.js rename : dom/sms/tests/marionette/test_mark_msg_read_error.js => dom/mobilemessage/tests/marionette/test_mark_msg_read_error.js rename : dom/sms/tests/marionette/test_message_classes.js => dom/mobilemessage/tests/marionette/test_message_classes.js rename : dom/sms/tests/marionette/test_outgoing.js => dom/mobilemessage/tests/marionette/test_outgoing.js rename : dom/sms/tests/marionette/test_outgoing_delete.js => dom/mobilemessage/tests/marionette/test_outgoing_delete.js rename : dom/sms/tests/marionette/test_outgoing_max_segments.js => dom/mobilemessage/tests/marionette/test_outgoing_max_segments.js rename : dom/sms/tests/marionette/test_segment_info.js => dom/mobilemessage/tests/marionette/test_segment_info.js rename : dom/sms/tests/marionette/test_strict_7bit_encoding.js => dom/mobilemessage/tests/marionette/test_strict_7bit_encoding.js rename : dom/sms/tests/moz.build => dom/mobilemessage/tests/moz.build rename : dom/sms/tests/test_sms_basics.html => dom/mobilemessage/tests/test_sms_basics.html rename : dom/sms/tests/test_smsdatabaseservice.xul => dom/mobilemessage/tests/test_smsdatabaseservice.xul rename : dom/sms/tests/test_smsfilter.html => dom/mobilemessage/tests/test_smsfilter.html rename : dom/sms/tests/test_smsservice_createsmsmessage.js => dom/mobilemessage/tests/test_smsservice_createsmsmessage.js rename : dom/sms/tests/xpcshell.ini => dom/mobilemessage/tests/xpcshell.ini
882 lines
30 KiB
XML
882 lines
30 KiB
XML
<?xml version="1.0"?>
|
|
<?xml-stylesheet href="chrome://global/skin" type="text/css"?>
|
|
<?xml-stylesheet href="chrome://mochikit/content/tests/SimpleTest/test.css"
|
|
type="text/css"?>
|
|
|
|
<window xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
|
|
title="Test MobileMessageDatabaseService by SMS"
|
|
onload="run_test();">
|
|
<title>Test MobileMessageDatabaseService by SMS</title>
|
|
<script type="application/javascript"
|
|
src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"/>
|
|
<script type="application/javascript"><![CDATA[
|
|
|
|
function run_test() {
|
|
SimpleTest.waitForExplicitFinish();
|
|
run_next_test();
|
|
}
|
|
|
|
let gTests = [];
|
|
|
|
function add_test(func) {
|
|
gTests.push(func);
|
|
}
|
|
|
|
function run_next_test() {
|
|
let func = gTests.shift();
|
|
if (!func) {
|
|
SimpleTest.finish();
|
|
return;
|
|
}
|
|
SimpleTest.executeSoon(func);
|
|
}
|
|
|
|
|
|
const {classes: Cc, interfaces: Ci, utils: Cu, results: Cr} = Components;
|
|
|
|
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
|
|
Cu.import("resource://gre/modules/Services.jsm");
|
|
|
|
let gIDBManager = Cc["@mozilla.org/dom/indexeddb/manager;1"]
|
|
.getService(Ci.nsIIndexedDatabaseManager);
|
|
|
|
let gMobileMessageDatabaseService = Cc["@mozilla.org/mobilemessage/rilmobilemessagedatabaseservice;1"]
|
|
.getService(Ci.nsIMobileMessageDatabaseService);
|
|
|
|
let gRegistrar = Components.manager.QueryInterface(Ci.nsIComponentRegistrar);
|
|
|
|
|
|
let SmsRequestManagerImpl = {
|
|
notifySmsSent: function notifySmsSent(requestId, message) {
|
|
ok(false, "Unexpected notifySmsSent.");
|
|
},
|
|
notifySmsSendFailed: function notifySmsSendFailed(requestId, error) {
|
|
ok(false, "Unexpected notifySmsSendFailed.");
|
|
},
|
|
notifyGotSms: function notifyGotSms(requestId, message) {
|
|
ok(false, "Unexpected notifyGotSms.");
|
|
},
|
|
notifyGetSmsFailed: function notifyGetSmsFailed(requestId, error) {
|
|
ok(false, "Unexpected notifyGetSmsFailed." + k);
|
|
},
|
|
notifySmsDeleted: function notifySmsDeleted(requestId, message) {
|
|
ok(false, "Unexpected notifySmsSent.");
|
|
},
|
|
notifySmsDeleteFailed: function notifySmsDeleteFailed(requestId, error) {
|
|
ok(false, "Unexpected notifySmsDeleteFailed.");
|
|
},
|
|
notifyNoMessageInList: function notifyNoMessageInList(requestId) {
|
|
ok(false, "Unexpected notifyNoMessageInList.");
|
|
},
|
|
noitfyCreateMessageList: function notifyCreateMessageList(requestId,
|
|
listId,
|
|
message) {
|
|
ok(false, "Unexpected notifyCreateMessageList.");
|
|
},
|
|
notifyGotNextMessage: function notifyGotNextMessage(requestId, message) {
|
|
ok(false, "Unexpected notifyGotNextMessage.");
|
|
},
|
|
notifyReadMessageListFailed: function notifyReadMessageListFailed(requestId, error) {
|
|
ok(false, "Unexpected notifyReadMessageListFailed.");
|
|
}
|
|
};
|
|
|
|
let FakeSmsRequestManagerService = {
|
|
contractID: "@mozilla.org/sms/smsrequestmanager;1",
|
|
//get CID() { return gRegistrar.contractIDToCID(this.contractID); },
|
|
CID: Components.ID("{a97a3129-1e0b-45da-a385-cfe5b0b1c48f}"),
|
|
QueryInterface: XPCOMUtils.generateQI([Ci.nsISmsRequestManager,
|
|
Ci.nsIFactory]),
|
|
createInstance: function createInstance(outer, iid) {
|
|
if (outer != null) {
|
|
throw Cr.NS_ERROR_NO_AGGREGATION;
|
|
}
|
|
return this;
|
|
},
|
|
__proto__: SmsRequestManagerImpl
|
|
};
|
|
|
|
/**
|
|
* Create and register a new fake nsISmsRequestManager service.
|
|
*
|
|
* Example:
|
|
*
|
|
* fakeSmsRequestManager({
|
|
* notifySmsSent: function notifySmsSent() {
|
|
* ...
|
|
* }
|
|
* });
|
|
*/
|
|
function fakeSmsRequestManager(obj) {
|
|
let service = FakeSmsRequestManagerService;
|
|
|
|
// Clean previous methods from the service, then copy new ones onto it.
|
|
for (let name in SmsRequestManagerImpl) {
|
|
delete service[name];
|
|
}
|
|
for (let name in obj) {
|
|
service[name] = obj[name];
|
|
}
|
|
|
|
// Register service
|
|
let oldFactory = Components.manager.getClassObject(Cc[service.contractID],
|
|
Ci.nsIFactory);
|
|
gRegistrar.unregisterFactory(service.CID, oldFactory);
|
|
gRegistrar.registerFactory(service.CID,
|
|
"Fake SmsRequestManager",
|
|
service.contractID,
|
|
service);
|
|
}
|
|
|
|
const DB_NAME = "sms";
|
|
const DB_VERSION = 2;
|
|
const STORE_NAME = "sms";
|
|
const MAX_SMS = 3;
|
|
const LONG_MAX = 2147483647;
|
|
|
|
gIDBManager.initWindowless(this);
|
|
|
|
let _db;
|
|
function ensureDB(callback) {
|
|
if (_db) {
|
|
callback(_db);
|
|
return;
|
|
}
|
|
let request;
|
|
try {
|
|
request = indexedDB.open(DB_NAME, DB_VERSION);
|
|
} catch (ex) {
|
|
ok(false, ex);
|
|
}
|
|
request.onsuccess = function onsuccess(event) {
|
|
_db = request.result;
|
|
callback(_db);
|
|
};
|
|
request.onerror =
|
|
request.onupgradeneeded =
|
|
request.onblocked = function onerror(event) {
|
|
ok(false, "Opening DB failed: " + request.errorCode);
|
|
};
|
|
};
|
|
|
|
function checkDB(callback) {
|
|
ensureDB(function (db) {
|
|
let txn = db.transaction([STORE_NAME], "readwrite");
|
|
let store = txn.objectStore(STORE_NAME);
|
|
txn.oncomplete = run_next_test;
|
|
txn.onerror = function onerror(event) {
|
|
ok(false, "Transaction failed: " + event.target.errorCode);
|
|
};
|
|
callback(store);
|
|
});
|
|
}
|
|
|
|
function newRandomId() {
|
|
return Math.floor(Math.random() * LONG_MAX);
|
|
};
|
|
|
|
let sms = [
|
|
{
|
|
type: "sms",
|
|
sender: "+34666000000",
|
|
receiver: "+34666111000",
|
|
body: "message 0",
|
|
messageClass: "normal",
|
|
timestamp: 1329999861762
|
|
},
|
|
{
|
|
type: "sms",
|
|
sender: "+34666000111",
|
|
receiver: "+34666111111",
|
|
body: "message 1",
|
|
messageClass: "normal",
|
|
timestamp: 1329999861763
|
|
},
|
|
{
|
|
type: "sms",
|
|
sender: "+34666000222",
|
|
receiver: "+34666111222",
|
|
body: "message 2",
|
|
messageClass: "normal",
|
|
timestamp: 1329999861764
|
|
},
|
|
];
|
|
|
|
/**
|
|
* nsIMobileMessageDatabaseService.saveReceivedMessage
|
|
*/
|
|
add_test(function test_saveReceivedMessage() {
|
|
info("test_saveReceivedMessage");
|
|
let messageId = gMobileMessageDatabaseService.saveReceivedMessage(sms[0]);
|
|
checkDB(function (store) {
|
|
let request = store.get(messageId);
|
|
request.onsuccess = function onsuccess() {
|
|
let data = request.result;
|
|
isnot(data, null);
|
|
is(data.id, messageId);
|
|
is(data.sender, sms[0].sender);
|
|
is(data.receiver, null);
|
|
is(data.body, sms[0].body);
|
|
is(data.timestamp, sms[0].timestamp);
|
|
is(data.read, false);
|
|
};
|
|
});
|
|
});
|
|
|
|
/**
|
|
* nsIMobileMessageDatabaseService.saveSentMessage
|
|
*/
|
|
add_test(function test_saveSentMessage() {
|
|
info("test_saveSentMessage");
|
|
let messageId = gMobileMessageDatabaseService.saveSentMessage(sms[1].receiver,
|
|
sms[1].body,
|
|
sms[1].timestamp);
|
|
|
|
checkDB(function (store) {
|
|
let request = store.get(messageId);
|
|
request.onsuccess = function onsuccess() {
|
|
let data = request.result;
|
|
isnot(data, null);
|
|
is(data.id, messageId);
|
|
is(data.sender, null);
|
|
is(data.receiver, sms[1].receiver);
|
|
is(data.body, sms[1].body);
|
|
is(data.timestamp, sms[1].timestamp);
|
|
is(data.read, true);
|
|
};
|
|
});
|
|
});
|
|
|
|
/**
|
|
* nsIMobileMessageDatabaseService.getMessage
|
|
*/
|
|
add_test(function test_getMessage_success() {
|
|
info("test_getMessage_success");
|
|
let fakeRequestId = newRandomId();
|
|
fakeSmsRequestManager({
|
|
notifyGotSms: function notifyGotSms(requestId, message) {
|
|
is(requestId, fakeRequestId);
|
|
ok(message instanceof Ci.nsIDOMMozSmsMessage);
|
|
is(message.id, messageId);
|
|
is(message.delivery, "received");
|
|
is(message.sender, sms[2].sender);
|
|
is(message.receiver, null);
|
|
is(message.body, sms[2].body);
|
|
is(message.read, false);
|
|
run_next_test();
|
|
}
|
|
});
|
|
let messageId = gMobileMessageDatabaseService.saveReceivedMessage(sms[2]);
|
|
SimpleTest.executeSoon(function () {
|
|
gMobileMessageDatabaseService.getMessage(messageId, fakeRequestId);
|
|
});
|
|
});
|
|
|
|
add_test(function test_getMessage_failed() {
|
|
info("test_getMessage_failed");
|
|
let fakeRequestId = newRandomId();
|
|
fakeSmsRequestManager({
|
|
notifyGetSmsFailed: function notifyGetSmsFailed(requestId, error) {
|
|
is(requestId, fakeRequestId);
|
|
is(error, Ci.nsISmsRequestManager.NOT_FOUND_ERROR);
|
|
run_next_test();
|
|
}
|
|
});
|
|
gMobileMessageDatabaseService.getMessage(-1, fakeRequestId);
|
|
});
|
|
|
|
/**
|
|
* nsIMobileMessageDatabaseService.createMessageList
|
|
*/
|
|
function checkReceivedSms(message, i) {
|
|
ok(message instanceof Ci.nsIDOMMozSmsMessage);
|
|
is(message.sender, sms[i].sender);
|
|
is(message.receiver, null);
|
|
is(message.body, sms[i].body);
|
|
is(message.timestamp.getTime(), sms[i].timestamp);
|
|
is(message.read, false);
|
|
}
|
|
|
|
function checkSentSms(message, i) {
|
|
ok(message instanceof Ci.nsIDOMMozSmsMessage);
|
|
is(message.sender, null);
|
|
is(message.receiver, sms[i].receiver);
|
|
is(message.body, sms[i].body);
|
|
is(message.timestamp.getTime(), sms[i].timestamp);
|
|
is(message.read, true);
|
|
}
|
|
|
|
add_test(function test_createMessageList_empty_filter() {
|
|
info("test_createMessageList_empty_filter");
|
|
let fakeRequestId = newRandomId();
|
|
let auxListId;
|
|
let i = 0;
|
|
fakeSmsRequestManager({
|
|
notifyCreateMessageList: function notifyCreateMessageList(requestId,
|
|
listId,
|
|
message) {
|
|
is(requestId, fakeRequestId);
|
|
checkReceivedSms(message, i);
|
|
auxListId = listId;
|
|
i += 1;
|
|
gMobileMessageDatabaseService.getNextMessageInList(listId, requestId);
|
|
},
|
|
notifyGotNextMessage: function notifyGotNextMessage(requestId,
|
|
message) {
|
|
is(requestId, fakeRequestId);
|
|
ok(message instanceof Ci.nsIDOMMozSmsMessage);
|
|
i % 2 ? checkSentSms(message, i) : checkReceivedSms(message, i);
|
|
i += 1;
|
|
gMobileMessageDatabaseService.getNextMessageInList(auxListId, requestId);
|
|
},
|
|
notifyNoMessageInList: function notifyNoMessageInList(requestId) {
|
|
is(requestId, fakeRequestId);
|
|
is(i, MAX_SMS);
|
|
run_next_test();
|
|
}
|
|
});
|
|
let filter = new MozSmsFilter();
|
|
gMobileMessageDatabaseService.createMessageList(filter, false, fakeRequestId);
|
|
});
|
|
|
|
add_test(function test_createMessageList_empty_filter_reverse() {
|
|
info("test_createMessageList_empty_filter_reverse");
|
|
let fakeRequestId = newRandomId();
|
|
let auxListId;
|
|
let i = 2;
|
|
fakeSmsRequestManager({
|
|
notifyCreateMessageList: function notifyCreateMessageList(requestId,
|
|
listId,
|
|
message) {
|
|
is(requestId, fakeRequestId);
|
|
checkReceivedSms(message, i);
|
|
auxListId = listId;
|
|
i -= 1;
|
|
gMobileMessageDatabaseService.getNextMessageInList(listId, requestId);
|
|
},
|
|
notifyGotNextMessage: function notifyGotNextMessage(requestId,
|
|
message) {
|
|
is(requestId, fakeRequestId);
|
|
ok(message instanceof Ci.nsIDOMMozSmsMessage);
|
|
i % 2 ? checkSentSms(message, i) : checkReceivedSms(message, i);
|
|
i -= 1;
|
|
gMobileMessageDatabaseService.getNextMessageInList(auxListId, requestId);
|
|
},
|
|
notifyNoMessageInList: function notifyNoMessageInList(requestId) {
|
|
is(requestId, fakeRequestId);
|
|
is(i, -1);
|
|
run_next_test();
|
|
}
|
|
});
|
|
let filter = new MozSmsFilter();
|
|
gMobileMessageDatabaseService.createMessageList(filter, true, fakeRequestId);
|
|
});
|
|
|
|
add_test(function test_createMessageList_complete_filter_one_result() {
|
|
info("test_createMessageList_complete_filter_one_result");
|
|
let fakeRequestId = newRandomId();
|
|
fakeSmsRequestManager({
|
|
notifyCreateMessageList: function notifyCreateMessageList(requestId,
|
|
listId,
|
|
message) {
|
|
is(requestId, fakeRequestId);
|
|
checkReceivedSms(message, 0);
|
|
gMobileMessageDatabaseService.getNextMessageInList(listId, requestId);
|
|
},
|
|
notifyGotNextMessage: function notifyGotNextMessage(requestId,
|
|
message) {
|
|
is(requestId, fakeRequestId);
|
|
ok(false, "No more messages expected");
|
|
},
|
|
notifyNoMessageInList: function notifyNoMessageInList(requestId) {
|
|
is(requestId, fakeRequestId);
|
|
run_next_test();
|
|
}
|
|
});
|
|
let filter = new MozSmsFilter();
|
|
filter.startDate = new Date(sms[0].timestamp);
|
|
filter.endDate = new Date(sms[0].timestamp);
|
|
filter.numbers = [sms[0].sender];
|
|
filter.delivery = "received";
|
|
gMobileMessageDatabaseService.createMessageList(filter, false, fakeRequestId);
|
|
});
|
|
|
|
add_test(function test_createMessageList_complete_filter_multi_result() {
|
|
info("test_createMessageList_complete_filter_multi_result");
|
|
let fakeRequestId = newRandomId();
|
|
let auxListId;
|
|
let secondMessage = false;
|
|
fakeSmsRequestManager({
|
|
notifyCreateMessageList: function notifyCreateMessageList(requestId,
|
|
listId,
|
|
message) {
|
|
is(requestId, fakeRequestId);
|
|
checkReceivedSms(message, 0);
|
|
auxListId = listId;
|
|
gMobileMessageDatabaseService.getNextMessageInList(listId, requestId);
|
|
},
|
|
notifyGotNextMessage: function notifyGotNextMessage(requestId, message) {
|
|
ok(!secondMessage);
|
|
is(requestId, fakeRequestId);
|
|
checkReceivedSms(message, 2);
|
|
secondMessage = true;
|
|
gMobileMessageDatabaseService.getNextMessageInList(auxListId, requestId);
|
|
},
|
|
notifyNoMessageInList: function notifyNoMessageInList(requestId) {
|
|
ok(secondMessage);
|
|
is(requestId, fakeRequestId);
|
|
run_next_test();
|
|
}
|
|
});
|
|
let filter = new MozSmsFilter();
|
|
filter.startDate = new Date(sms[0].timestamp);
|
|
filter.endDate = new Date(sms[2].timestamp);
|
|
filter.numbers = [sms[0].sender, sms[2].sender];
|
|
filter.delivery = "received";
|
|
gMobileMessageDatabaseService.createMessageList(filter, false, fakeRequestId);
|
|
});
|
|
|
|
add_test(function test_createMessageList_complete_filter_no_result() {
|
|
info("test_createMessageList_complete_filter_no_result");
|
|
let fakeRequestId = newRandomId();
|
|
fakeSmsRequestManager({
|
|
notifyNoMessageInList: function notifyNoMessageInList(requestId) {
|
|
is(requestId, fakeRequestId);
|
|
run_next_test();
|
|
},
|
|
});
|
|
let filter = new MozSmsFilter();
|
|
filter.startDate = new Date(sms[0].timestamp);
|
|
filter.endDate = new Date(sms[0].timestamp);
|
|
filter.numbers = [sms[0].sender];
|
|
filter.delivery = "sent";
|
|
gMobileMessageDatabaseService.createMessageList(filter, false, fakeRequestId);
|
|
});
|
|
|
|
add_test(function test_createMessageList_delivery_sent_filter_success() {
|
|
info("test_createMessageList_delivery_sent_filter_success");
|
|
let fakeRequestId = newRandomId();
|
|
fakeSmsRequestManager({
|
|
notifyCreateMessageList: function notifyCreateMessageList(requestId,
|
|
listId,
|
|
message) {
|
|
is(requestId, fakeRequestId);
|
|
checkSentSms(message, 1);
|
|
gMobileMessageDatabaseService.getNextMessageInList(listId, requestId);
|
|
},
|
|
notifyNoMessageInList: function notifyNoMessageInList(requestId) {
|
|
is(requestId, fakeRequestId);
|
|
run_next_test();
|
|
}
|
|
});
|
|
let filter = new MozSmsFilter();
|
|
filter.delivery = "sent";
|
|
gMobileMessageDatabaseService.createMessageList(filter, false, fakeRequestId);
|
|
});
|
|
|
|
add_test(function test_createMessageList_delivery_received_filter_success() {
|
|
info("test_createMessageList_delivery_received_filter_success");
|
|
let fakeRequestId = newRandomId();
|
|
let auxListId;
|
|
let secondMessage = false;
|
|
fakeSmsRequestManager({
|
|
notifyCreateMessageList: function notifyCreateMessageList(requestId,
|
|
listId,
|
|
message) {
|
|
is(requestId, fakeRequestId);
|
|
checkReceivedSms(message, 0);
|
|
auxListId = listId;
|
|
gMobileMessageDatabaseService.getNextMessageInList(listId, requestId);
|
|
},
|
|
notifyGotNextMessage: function notifyGotNextMessage(requestId, message) {
|
|
ok(!secondMessage);
|
|
is(requestId, fakeRequestId);
|
|
checkReceivedSms(message, 2);
|
|
secondMessage = true;
|
|
gMobileMessageDatabaseService.getNextMessageInList(auxListId, requestId);
|
|
},
|
|
notifyNoMessageInList: function notifyNoMessageInList(requestId) {
|
|
ok(secondMessage);
|
|
is(requestId, fakeRequestId);
|
|
run_next_test();
|
|
}
|
|
});
|
|
let filter = new MozSmsFilter();
|
|
filter.delivery = "received";
|
|
gMobileMessageDatabaseService.createMessageList(filter, false, fakeRequestId);
|
|
});
|
|
|
|
add_test(function test_createMessageList_startDate_filter_success() {
|
|
info("test_createMessageList_startDate_filter_success");
|
|
let fakeRequestId = newRandomId();
|
|
let auxListId;
|
|
let i = 0;
|
|
fakeSmsRequestManager({
|
|
notifyCreateMessageList: function notifyCreateMessageList(requestId,
|
|
listId,
|
|
message) {
|
|
is(requestId, fakeRequestId);
|
|
checkReceivedSms(message, i);
|
|
auxListId = listId;
|
|
i += 1;
|
|
gMobileMessageDatabaseService.getNextMessageInList(listId, requestId);
|
|
},
|
|
notifyGotNextMessage: function notifyGotNextMessage(requestId,
|
|
message) {
|
|
is(requestId, fakeRequestId);
|
|
i % 2 ? checkSentSms(message, i) : checkReceivedSms(message, i);
|
|
i += 1;
|
|
gMobileMessageDatabaseService.getNextMessageInList(auxListId, requestId);
|
|
},
|
|
notifyNoMessageInList: function notifyNoMessageInList(requestId) {
|
|
is(requestId, fakeRequestId);
|
|
is(i, MAX_SMS);
|
|
run_next_test();
|
|
}
|
|
});
|
|
let filter = new MozSmsFilter();
|
|
filter.startDate = new Date(sms[0].timestamp);
|
|
gMobileMessageDatabaseService.createMessageList(filter, false, fakeRequestId);
|
|
});
|
|
|
|
add_test(function test_createMessageList_startDate_filter_failed() {
|
|
info("test_createMessageList_startDate_filter_failed");
|
|
let fakeRequestId = newRandomId();
|
|
fakeSmsRequestManager({
|
|
notifyNoMessageInList: function notifyNoMessageInList(requestId) {
|
|
is(requestId, fakeRequestId);
|
|
run_next_test();
|
|
},
|
|
});
|
|
let filter = new MozSmsFilter();
|
|
filter.startDate = new Date(sms[2].timestamp + 1);
|
|
gMobileMessageDatabaseService.createMessageList(filter, false, fakeRequestId);
|
|
});
|
|
|
|
add_test(function test_createMessageList_endDate_filter_success() {
|
|
info("test_createMessageList_endDate_filter_success");
|
|
let fakeRequestId = newRandomId();
|
|
let auxListId;
|
|
let i = 0;
|
|
fakeSmsRequestManager({
|
|
notifyCreateMessageList: function notifyCreateMessageList(requestId,
|
|
listId,
|
|
message) {
|
|
is(requestId, fakeRequestId);
|
|
checkReceivedSms(message, i);
|
|
auxListId = listId;
|
|
i += 1;
|
|
gMobileMessageDatabaseService.getNextMessageInList(listId, requestId);
|
|
},
|
|
notifyGotNextMessage: function notifyGotNextMessage(requestId,
|
|
message) {
|
|
is(requestId, fakeRequestId);
|
|
i % 2 ? checkSentSms(message, i) : checkReceivedSms(message, i);
|
|
i += 1;
|
|
gMobileMessageDatabaseService.getNextMessageInList(auxListId, requestId);
|
|
},
|
|
notifyNoMessageInList: function notifyNoMessageInList(requestId) {
|
|
is(requestId, fakeRequestId);
|
|
is(i, MAX_SMS);
|
|
run_next_test();
|
|
}
|
|
});
|
|
let filter = new MozSmsFilter();
|
|
filter.endDate = new Date(sms[2].timestamp);
|
|
gMobileMessageDatabaseService.createMessageList(filter, false, fakeRequestId);
|
|
});
|
|
|
|
add_test(function test_createMessageList_endDate_filter_failed() {
|
|
info("test_createMessageList_endDate_filter_failed");
|
|
let fakeRequestId = newRandomId();
|
|
fakeSmsRequestManager({
|
|
notifyNoMessageInList: function notifyNoMessageInList(requestId) {
|
|
is(requestId, fakeRequestId);
|
|
run_next_test();
|
|
}
|
|
});
|
|
let filter = new MozSmsFilter();
|
|
filter.endDate = new Date(sms[0].timestamp - 1);
|
|
gMobileMessageDatabaseService.createMessageList(filter, false, fakeRequestId);
|
|
});
|
|
|
|
add_test(function test_createMessageList_fullDate_filter_success() {
|
|
info("test_createMessageList_fullDate_filter_success");
|
|
let fakeRequestId = newRandomId();
|
|
let auxListId;
|
|
let i = 0;
|
|
fakeSmsRequestManager({
|
|
notifyCreateMessageList: function notifyCreateMessageList(requestId,
|
|
listId,
|
|
message) {
|
|
is(requestId, fakeRequestId);
|
|
checkReceivedSms(message, i);
|
|
auxListId = listId;
|
|
i += 1;
|
|
gMobileMessageDatabaseService.getNextMessageInList(listId, requestId);
|
|
},
|
|
notifyGotNextMessage: function notifyGotNextMessage(requestId,
|
|
message) {
|
|
is(requestId, fakeRequestId);
|
|
i % 2 ? checkSentSms(message, i) : checkReceivedSms(message, i);
|
|
i += 1;
|
|
gMobileMessageDatabaseService.getNextMessageInList(auxListId, requestId);
|
|
},
|
|
notifyNoMessageInList: function notifyNoMessageInList(requestId) {
|
|
is(requestId, fakeRequestId);
|
|
is(i, MAX_SMS);
|
|
run_next_test();
|
|
}
|
|
});
|
|
let filter = new MozSmsFilter();
|
|
filter.startDate = new Date(sms[0].timestamp);
|
|
filter.endDate = new Date(sms[MAX_SMS - 1].timestamp);
|
|
gMobileMessageDatabaseService.createMessageList(filter, false, fakeRequestId);
|
|
});
|
|
|
|
add_test(function test_createMessageList_fullDate_filter_failed() {
|
|
info("test_createMessageList_fullDate_filter_failed");
|
|
let fakeRequestId = newRandomId();
|
|
fakeSmsRequestManager({
|
|
notifyNoMessageInList: function notifyNoMessageInList(requestId) {
|
|
is(requestId, fakeRequestId);
|
|
run_next_test();
|
|
}
|
|
});
|
|
let filter = new MozSmsFilter();
|
|
filter.startDate = new Date(sms[MAX_SMS - 1] + 1);
|
|
filter.endDate = new Date(sms[MAX_SMS - 1] + 1);
|
|
gMobileMessageDatabaseService.createMessageList(filter, false, fakeRequestId);
|
|
});
|
|
|
|
add_test(function test_createMessageList_single_number_success() {
|
|
info("test_createMessageList_single_number_success");
|
|
let fakeRequestId = newRandomId();
|
|
let firstMessage = false;
|
|
fakeSmsRequestManager({
|
|
notifyCreateMessageList: function notifyCreateMessageList(requestId,
|
|
listId,
|
|
message) {
|
|
is(firstMessage, false);
|
|
is(requestId, fakeRequestId);
|
|
checkReceivedSms(message, 0);
|
|
firstMessage = true;
|
|
gMobileMessageDatabaseService.getNextMessageInList(listId, requestId);
|
|
},
|
|
notifyNoMessageInList: function notifyNoMessageInList(requestId) {
|
|
ok(firstMessage);
|
|
is(requestId, fakeRequestId);
|
|
run_next_test();
|
|
}
|
|
});
|
|
let filter = new MozSmsFilter();
|
|
filter.numbers = [sms[0].sender];
|
|
gMobileMessageDatabaseService.createMessageList(filter, false, fakeRequestId);
|
|
});
|
|
|
|
add_test(function test_createMessageList_single_number_failed() {
|
|
info("test_createMessageList_single_number_failed");
|
|
let fakeRequestId = newRandomId();
|
|
fakeSmsRequestManager({
|
|
notifyNoMessageInList: function notifyNoMessageInList(requestId) {
|
|
is(requestId, fakeRequestId);
|
|
run_next_test();
|
|
}
|
|
});
|
|
let filter = new MozSmsFilter();
|
|
filter.numbers = ["00000000000"];
|
|
gMobileMessageDatabaseService.createMessageList(filter, false, fakeRequestId);
|
|
});
|
|
|
|
add_test(function test_createMessageList_multi_number_success() {
|
|
info("test_createMessageList_multi_number_success");
|
|
let fakeRequestId = newRandomId();
|
|
let auxListId;
|
|
let secondMessage = false;
|
|
fakeSmsRequestManager({
|
|
notifyCreateMessageList: function notifyCreateMessageList(requestId,
|
|
listId,
|
|
message) {
|
|
is(requestId, fakeRequestId);
|
|
checkReceivedSms(message, 0);
|
|
auxListId = listId;
|
|
gMobileMessageDatabaseService.getNextMessageInList(listId, requestId);
|
|
},
|
|
notifyGotNextMessage: function notifyGotNextMessage(requestId, message) {
|
|
ok(!secondMessage);
|
|
is(requestId, fakeRequestId);
|
|
checkSentSms(message, 1);
|
|
secondMessage = true;
|
|
gMobileMessageDatabaseService.getNextMessageInList(auxListId, requestId);
|
|
},
|
|
notifyNoMessageInList: function notifyNoMessageInList(requestId) {
|
|
ok(secondMessage);
|
|
is(requestId, fakeRequestId);
|
|
run_next_test();
|
|
}
|
|
});
|
|
let filter = new MozSmsFilter();
|
|
filter.numbers = [sms[0].sender, sms[1].receiver];
|
|
gMobileMessageDatabaseService.createMessageList(filter, false, fakeRequestId);
|
|
});
|
|
|
|
add_test(function test_createMessageList_multi_number_wrong_number_success() {
|
|
info("test_createMessageList_multi_number_wrong_number_success");
|
|
let fakeRequestId = newRandomId();
|
|
let firstMessage = false;
|
|
fakeSmsRequestManager({
|
|
notifyCreateMessageList: function notifyCreateMessageList(requestId,
|
|
listId,
|
|
message) {
|
|
is(firstMessage, false);
|
|
is(requestId, fakeRequestId);
|
|
checkReceivedSms(message, 0);
|
|
firstMessage = true;
|
|
gMobileMessageDatabaseService.getNextMessageInList(listId, requestId);
|
|
},
|
|
notifyNoMessageInList: function notifyNoMessageInList(requestId) {
|
|
ok(firstMessage);
|
|
is(requestId, fakeRequestId);
|
|
run_next_test();
|
|
}
|
|
});
|
|
let filter = new MozSmsFilter();
|
|
filter.numbers = ["00000000000", sms[0].sender];
|
|
gMobileMessageDatabaseService.createMessageList(filter, false, fakeRequestId);
|
|
});
|
|
|
|
add_test(function test_createMessageList_multi_number_failed() {
|
|
info("test_createMessageList_multi_number_failed");
|
|
let fakeRequestId = newRandomId();
|
|
fakeSmsRequestManager({
|
|
notifyNoMessageInList: function notifyNoMessageInList(requestId) {
|
|
is(requestId, fakeRequestId);
|
|
run_next_test();
|
|
}
|
|
});
|
|
let filter = new MozSmsFilter();
|
|
filter.numbers = ["00000000000", "11111111111"];
|
|
gMobileMessageDatabaseService.createMessageList(filter, false, fakeRequestId);
|
|
});
|
|
|
|
|
|
add_test(function test_createMessageList_read_filter_success() {
|
|
info("test_createMessageList_read_filter_success");
|
|
let fakeRequestId = newRandomId();
|
|
let lId;
|
|
let secondMessage = false;
|
|
fakeSmsRequestManager({
|
|
notifyCreateMessageList: function notifyCreateMessageList(requestId,
|
|
listId,
|
|
message) {
|
|
is(requestId, fakeRequestId);
|
|
checkReceivedSms(message, 0);
|
|
lId = listId;
|
|
gMobileMessageDatabaseService.getNextMessageInList(listId, requestId);
|
|
},
|
|
notifyGotNextMessage: function notifyGotNextMessage(requestId, message) {
|
|
ok(!secondMessage);
|
|
is(requestId, fakeRequestId);
|
|
checkReceivedSms(message, 2);
|
|
secondMessage = true;
|
|
gMobileMessageDatabaseService.getNextMessageInList(lId, requestId);
|
|
},
|
|
notifyNoMessageInList: function notifyNoMessageInList(requestId) {
|
|
ok(secondMessage);
|
|
is(requestId, fakeRequestId);
|
|
run_next_test();
|
|
}
|
|
});
|
|
SimpleTest.executeSoon(function () {
|
|
let filter = new MozSmsFilter();
|
|
filter.read = false;
|
|
gMobileMessageDatabaseService.createMessageList(filter, false, fakeRequestId);
|
|
});
|
|
});
|
|
|
|
/**
|
|
* nsIMobileMessageDatabaseService.getNextMessageInList
|
|
*/
|
|
add_test(function test_getNextMessageInList_unknown_list() {
|
|
info("test_getNextMessageInList_unknown_list");
|
|
let fakeRequestId = newRandomId();
|
|
fakeSmsRequestManager({
|
|
notifyReadMessageListFailed:
|
|
function notifyReadMessageListFailed(requestId) {
|
|
is(requestId, fakeRequestId);
|
|
run_next_test();
|
|
}
|
|
});
|
|
gMobileMessageDatabaseService.getNextMessageInList(-1, fakeRequestId);
|
|
});
|
|
|
|
/**
|
|
* nsIMobileMessageDatabaseService.deleteMessage
|
|
*/
|
|
add_test(function test_deleteMessage_success() {
|
|
info("test_deleteMessage_success");
|
|
let fakeRequestId = newRandomId();
|
|
fakeSmsRequestManager({
|
|
notifySmsDeleted: function notifySmsDeleted(requestId, deleted) {
|
|
is(requestId, fakeRequestId);
|
|
ok(deleted);
|
|
run_next_test();
|
|
}
|
|
});
|
|
let messageId = gMobileMessageDatabaseService.saveReceivedMessage(sms[0]);
|
|
SimpleTest.executeSoon(function () {
|
|
gMobileMessageDatabaseService.deleteMessage(messageId, fakeRequestId);
|
|
});
|
|
});
|
|
|
|
add_test(function test_deleteMessage_failed() {
|
|
info("test_deleteMessage_failed");
|
|
let fakeRequestId = newRandomId();
|
|
fakeSmsRequestManager({
|
|
notifySmsDeleted: function notifySmsDeleted(requestId, deleted) {
|
|
is(requestId, fakeRequestId);
|
|
is(deleted, false);
|
|
run_next_test();
|
|
}
|
|
});
|
|
gMobileMessageDatabaseService.deleteMessage(-1, fakeRequestId);
|
|
});
|
|
|
|
add_test(function test_markMessageRead_success() {
|
|
info("test_markMessageRead_success");
|
|
let fakeRequestId = newRandomId();
|
|
fakeSmsRequestManager({
|
|
notifyMarkedMessageRead: function notifyMarkedMessageRead(requestId, read) {
|
|
is(requestId, fakeRequestId);
|
|
is(read, true);
|
|
run_next_test();
|
|
}
|
|
});
|
|
let messageId = gMobileMessageDatabaseService.saveReceivedMessage(sms[2]);
|
|
SimpleTest.executeSoon(function () {
|
|
gMobileMessageDatabaseService.markMessageRead(messageId, true, fakeRequestId);
|
|
});
|
|
});
|
|
|
|
add_test(function test_markMessageRead_failed() {
|
|
info("test_markMessageRead_failed");
|
|
let fakeRequestId = newRandomId();
|
|
fakeSmsRequestManager({
|
|
notifyMarkMessageReadFailed: function notifyMarkMessageReadFailed(requestId, error) {
|
|
is(requestId, fakeRequestId);
|
|
run_next_test();
|
|
}
|
|
});
|
|
SimpleTest.executeSoon(function () {
|
|
gMobileMessageDatabaseService.markMessageRead(-1, true, fakeRequestId);
|
|
});
|
|
});
|
|
|
|
]]></script>
|
|
<body xmlns="http://www.w3.org/1999/xhtml">
|
|
<p id="display"></p>
|
|
<div id="content" style="display: none"></div>
|
|
<pre id="test"></pre>
|
|
</body>
|
|
</window>
|