Bug 589905 - Remote preferences test cases. r=dwitte, a=blocking-fennec

--HG--
extra : rebase_source : 54bf57ab0fadd2adf7b4b5cacbde8be3c6260e61
This commit is contained in:
Doug Turner 2010-09-27 14:23:35 -07:00
Родитель 5cde12d946
Коммит 628d890ec6
2 изменённых файлов: 65 добавлений и 0 удалений

Просмотреть файл

@ -48,4 +48,11 @@ MODULE = test_libpref
XPCSHELL_TESTS = unit
ifdef MOZ_IPC
# FIXME/bug 575918: out-of-process xpcshell is broken on OS X
ifneq ($(OS_ARCH),Darwin)
XPCSHELL_TESTS += unit_ipc
endif
endif
include $(topsrcdir)/config/rules.mk

Просмотреть файл

@ -0,0 +1,58 @@
const Ci = Components.interfaces;
const Cc = Components.classes;
const Cr = Components.results;
function isParentProcess() {
let appInfo = Cc["@mozilla.org/xre/app-info;1"];
return (!appInfo || appInfo.getService(Ci.nsIXULRuntime).processType == Ci.nsIXULRuntime.PROCESS_TYPE_DEFAULT);
}
function verify_existing_prefs() {
const Ci = Components.interfaces;
const Cc = Components.classes;
var pb = Cc["@mozilla.org/preferences-service;1"].getService(Ci.nsIPrefBranch);
do_check_eq(pb.getBoolPref("Test.IPC.bool"), true);
do_check_eq(pb.getIntPref("Test.IPC.int"), 23);
do_check_eq(pb.getCharPref("Test.IPC.char"), "hey");
do_test_finished();
_do_main();
}
function verify_observed_prefs() {
const Ci = Components.interfaces;
const Cc = Components.classes;
var pb = Cc["@mozilla.org/preferences-service;1"].getService(Ci.nsIPrefBranch);
do_test_pending();
do_check_eq(pb.getBoolPref("Test.IPC.bool.new"), true);
do_check_eq(pb.getIntPref("Test.IPC.int.new"), 23);
do_check_eq(pb.getCharPref("Test.IPC.char.new"), "hey");
do_test_finished();
_do_main();
}
function run_test() {
if (isParentProcess()) {
var pb = Cc["@mozilla.org/preferences-service;1"].getService(Ci.nsIPrefBranch);
pb.setBoolPref("Test.IPC.bool", true);
pb.setIntPref("Test.IPC.int", 23);
pb.setCharPref("Test.IPC.char", "hey");
do_load_child_test_harness();
do_test_pending();
sendCommand(verify_existing_prefs.toString(), do_test_finished);
// these prefs are set after the child has been created.
pb.setBoolPref("Test.IPC.bool.new", true);
pb.setIntPref("Test.IPC.int.new", 23);
pb.setCharPref("Test.IPC.char.new", "hey");
do_test_pending();
sendCommand(verify_existing_prefs.toString(), do_test_finished);
}
else {
}
}