michael@0: /* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ michael@0: /* vim:set ts=2 sw=2 sts=2 et: */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: const Cr = Components.results; michael@0: const Ci = Components.interfaces; michael@0: michael@0: const CC = Components.Constructor; michael@0: var LocalFile = CC("@mozilla.org/file/local;1", "nsILocalFile", "initWithPath"); michael@0: michael@0: function run_test() michael@0: { michael@0: test_normalized_vs_non_normalized(); michael@0: } michael@0: michael@0: function test_normalized_vs_non_normalized() michael@0: { michael@0: // get a directory that exists on all platforms michael@0: var dirProvider = Components.classes["@mozilla.org/file/directory_service;1"].getService(Ci.nsIProperties); michael@0: var tmp1 = dirProvider.get("TmpD", Ci.nsILocalFile); michael@0: var exists = tmp1.exists(); michael@0: do_check_true(exists); michael@0: if (!exists) michael@0: return; michael@0: michael@0: // this has the same exact path as tmp1, it should equal tmp1 michael@0: var tmp2 = new LocalFile(tmp1.path); michael@0: do_check_true(tmp1.equals(tmp2)); michael@0: michael@0: // this is a non-normalized version of tmp1, it should not equal tmp1 michael@0: tmp2.appendRelativePath("."); michael@0: do_check_false(tmp1.equals(tmp2)); michael@0: michael@0: // normalize and make sure they are equivalent again michael@0: tmp2.normalize(); michael@0: do_check_true(tmp1.equals(tmp2)); michael@0: }