toolkit/components/filepicker/test/unit/test_filecomplete.js

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

     1 /* This Source Code Form is subject to the terms of the Mozilla Public
     2  * License, v. 2.0. If a copy of the MPL was not distributed with this
     3  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     5 // Start by getting an empty directory.
     6 var dir = do_get_profile();
     7 dir.append("temp");
     8 dir.create(dir.DIRECTORY_TYPE, -1);
     9 var path = dir.path + "/";
    11 // Now create some sample entries.
    12 var file = dir.clone();
    13 file.append("test_file");
    14 file.create(file.NORMAL_FILE_TYPE, -1);
    15 file = dir.clone();
    16 file.append("other_file");
    17 file.create(file.NORMAL_FILE_TYPE, -1);
    18 dir.append("test_dir");
    19 dir.create(dir.DIRECTORY_TYPE, -1);
    21 var gListener = {
    22   onSearchResult: function(aSearch, aResult) {
    23     // Check that we got same search string back.
    24     do_check_eq(aResult.searchString, "test");
    25     // Check that the search succeeded.
    26     do_check_eq(aResult.searchResult, aResult.RESULT_SUCCESS);
    27     // Check that we got two results.
    28     do_check_eq(aResult.matchCount, 2);
    29     // Check that the first result is the directory we created.
    30     do_check_eq(aResult.getValueAt(0), "test_dir");
    31     // Check that the first result has directory style.
    32     do_check_eq(aResult.getStyleAt(0), "directory");
    33     // Check that the second result is the file we created.
    34     do_check_eq(aResult.getValueAt(1), "test_file");
    35     // Check that the second result has file style.
    36     do_check_eq(aResult.getStyleAt(1), "file");
    37   }
    38 };
    40 function run_test()
    41 {
    42   Components.classes["@mozilla.org/autocomplete/search;1?name=file"]
    43             .getService(Components.interfaces.nsIAutoCompleteSearch)
    44             .startSearch("test", path, null, gListener);
    45 }

mercurial