testing/xpcshell/example/unit/test_get_file.js

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/testing/xpcshell/example/unit/test_get_file.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,33 @@
     1.4 +/* vim:set ts=2 sw=2 sts=2 et: */
     1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this
     1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.8 +
     1.9 +var subscriptLoaded = false;
    1.10 +
    1.11 +function run_test() {
    1.12 +  var lf = do_get_file("file.txt");
    1.13 +  do_check_true(lf.exists());
    1.14 +  do_check_true(lf.isFile());
    1.15 +  // check that allowNonexistent works
    1.16 +  lf = do_get_file("file.txt.notfound", true);
    1.17 +  do_check_false(lf.exists());
    1.18 +  // check that we can get a file from a subdirectory
    1.19 +  lf = do_get_file("subdir/file.txt");
    1.20 +  do_check_true(lf.exists());
    1.21 +  do_check_true(lf.isFile());
    1.22 +  // and that we can get a handle to a directory itself
    1.23 +  lf = do_get_file("subdir/");
    1.24 +  do_check_true(lf.exists());
    1.25 +  do_check_true(lf.isDirectory());
    1.26 +  // check that we can go up a level
    1.27 +  lf = do_get_file("..");
    1.28 +  do_check_true(lf.exists());
    1.29 +  lf.append("unit");
    1.30 +  lf.append("file.txt");
    1.31 +  do_check_true(lf.exists());
    1.32 +  // check that do_get_cwd works
    1.33 +  lf = do_get_cwd();
    1.34 +  do_check_true(lf.exists());
    1.35 +  do_check_true(lf.isDirectory());
    1.36 +}

mercurial