Bug 589905 - Remote preferences test cases. r=dwitte, a=blocking-fennec
authorDoug Turner <dougt@dougt.org>
Mon, 27 Sep 2010 14:23:35 -0700
changeset 54678 a7300f9d11ae8351341dffb1f69d715a76e2d0af
parent 54677 f584b2db2a7e80eedd5b61bee54562678f6b2856
child 54679 faf497893b2816ee72b1416690c4f9d449815497
push idunknown
push userunknown
push dateunknown
reviewersdwitte, blocking-fennec
bugs589905
milestone2.0b7pre
Bug 589905 - Remote preferences test cases. r=dwitte, a=blocking-fennec
modules/libpref/test/Makefile.in
modules/libpref/test/unit_ipc/test_simpleIPC.js
--- a/modules/libpref/test/Makefile.in
+++ b/modules/libpref/test/Makefile.in
@@ -43,9 +43,16 @@ VPATH		= @srcdir@
 relativesrcdir = modules/libpref/test
 
 include $(DEPTH)/config/autoconf.mk
 
 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
new file mode 100644
--- /dev/null
+++ b/modules/libpref/test/unit_ipc/test_simpleIPC.js
@@ -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 {
+  }
+}
\ No newline at end of file