Bug 991883 - [OS.File] Move test_constants from main_test_osfile_async.js to an xpcshell test. r=Yoric

This commit is contained in:
kushagra singh[:kushagra] 2014-05-26 09:52:00 -04:00
parent 3c0791acd1
commit 0999dad2bb
3 changed files with 27 additions and 27 deletions

View File

@ -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
*/

View File

@ -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');
}
});

View File

@ -31,3 +31,4 @@ tail =
[test_osfile_writeAtomic_backupTo_option.js]
[test_osfile_error.js]
[test_queue.js]
[test_constants.js]