From 0999dad2bba07774071bcb4652fb6a3423a94385 Mon Sep 17 00:00:00 2001 From: "kushagra singh[:kushagra]" Date: Mon, 26 May 2014 09:52:00 -0400 Subject: [PATCH] Bug 991883 - [OS.File] Move test_constants from main_test_osfile_async.js to an xpcshell test. r=Yoric --- .../tests/mochi/main_test_osfile_async.js | 27 ------------------- .../osfile/tests/xpcshell/test_constants.js | 26 ++++++++++++++++++ .../osfile/tests/xpcshell/xpcshell.ini | 1 + 3 files changed, 27 insertions(+), 27 deletions(-) create mode 100644 toolkit/components/osfile/tests/xpcshell/test_constants.js diff --git a/toolkit/components/osfile/tests/mochi/main_test_osfile_async.js b/toolkit/components/osfile/tests/mochi/main_test_osfile_async.js index 062d2d57e829..326e30d94910 100644 --- a/toolkit/components/osfile/tests/mochi/main_test_osfile_async.js +++ b/toolkit/components/osfile/tests/mochi/main_test_osfile_async.js @@ -149,8 +149,6 @@ function toggleDebugTest (pref, consoleListener) { let test = maketest("Main", function main(test) { return Task.spawn(function() { SimpleTest.waitForExplicitFinish(); - yield test_constants(); - yield test_path(); yield test_stat(); yield test_debug(); yield test_info_features_detect(); @@ -170,31 +168,6 @@ let test = maketest("Main", function main(test) { let EXISTING_FILE = OS.Path.join("chrome", "toolkit", "components", "osfile", "tests", "mochi", "main_test_osfile_async.js"); -/** - * Test that OS.Constants is defined correctly. - */ -let test_constants = maketest("constants", function constants(test) { - return Task.spawn(function() { - test.isnot(OS.Constants, null, "OS.Constants exists"); - test.ok(OS.Constants.Win || OS.Constants.libc, "OS.Constants.Win exists or OS.Constants.Unix exists"); - test.isnot(OS.Constants.Path, null, "OS.Constants.Path exists"); - test.isnot(OS.Constants.Sys, null, "OS.Constants.Sys exists"); - }); -}); - -/** - * Test that OS.Constants.Path paths are consistent. - */ -let test_path = maketest("path", function path(test) { - return Task.spawn(function() { - test.ok(OS.Path, "OS.Path exists"); - test.ok(OS.Constants.Path, "OS.Constants.Path exists"); - test.is(OS.Constants.Path.tmpDir, Services.dirsvc.get("TmpD", Components.interfaces.nsIFile).path, "OS.Constants.Path.tmpDir is correct"); - test.is(OS.Constants.Path.profileDir, Services.dirsvc.get("ProfD", Components.interfaces.nsIFile).path, "OS.Constants.Path.profileDir is correct"); - test.is(OS.Constants.Path.localProfileDir, Services.dirsvc.get("ProfLD", Components.interfaces.nsIFile).path, "OS.Constants.Path.localProfileDir is correct"); - }); -}); - /** * Test OS.File.stat and OS.File.prototype.stat */ diff --git a/toolkit/components/osfile/tests/xpcshell/test_constants.js b/toolkit/components/osfile/tests/xpcshell/test_constants.js new file mode 100644 index 000000000000..129a131fa19c --- /dev/null +++ b/toolkit/components/osfile/tests/xpcshell/test_constants.js @@ -0,0 +1,26 @@ +"use strict"; + +Components.utils.import("resource://gre/modules/osfile.jsm"); +Components.utils.import("resource://gre/modules/Services.jsm"); +Components.utils.import("resource://gre/modules/Services.jsm", this); + +function run_test() { + run_next_test(); +} + +// Test that OS.Constants is defined correctly. +add_task(function* check_definition() { + do_check_true(OS.Constants!=null); + do_check_true(!!OS.Constants.Win || !!OS.Constants.libc); + do_check_true(OS.Constants.Path!=null); + do_check_true(OS.Constants.Sys!=null); + //check system name + do_check_eq(OS.Constants.Sys.Name, Services.appinfo.OS); + + //check if using DEBUG build + if (Components.classes["@mozilla.org/xpcom/debug;1"].getService(Components.interfaces.nsIDebug2).isDebugBuild == true) { + do_check_true(OS.Constants.Sys.DEBUG); + } else { + do_check_true(typeof(OS.Constants.Sys.DEBUG) == 'undefined'); + } +}); \ No newline at end of file diff --git a/toolkit/components/osfile/tests/xpcshell/xpcshell.ini b/toolkit/components/osfile/tests/xpcshell/xpcshell.ini index e6b89e5f8aee..32f56fea6184 100644 --- a/toolkit/components/osfile/tests/xpcshell/xpcshell.ini +++ b/toolkit/components/osfile/tests/xpcshell/xpcshell.ini @@ -31,3 +31,4 @@ tail = [test_osfile_writeAtomic_backupTo_option.js] [test_osfile_error.js] [test_queue.js] +[test_constants.js] \ No newline at end of file