diff options
author | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
---|---|---|
committer | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
commit | 5f8de423f190bbb79a62f804151bc24824fa32d8 (patch) | |
tree | 10027f336435511475e392454359edea8e25895d /toolkit/components/filepicker/test/unit/test_filecomplete.js | |
parent | 49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff) | |
download | UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip |
Add m-esr52 at 52.6.0
Diffstat (limited to 'toolkit/components/filepicker/test/unit/test_filecomplete.js')
-rw-r--r-- | toolkit/components/filepicker/test/unit/test_filecomplete.js | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/toolkit/components/filepicker/test/unit/test_filecomplete.js b/toolkit/components/filepicker/test/unit/test_filecomplete.js new file mode 100644 index 000000000..d1e18d533 --- /dev/null +++ b/toolkit/components/filepicker/test/unit/test_filecomplete.js @@ -0,0 +1,45 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +// Start by getting an empty directory. +var dir = do_get_profile(); +dir.append("temp"); +dir.create(dir.DIRECTORY_TYPE, -1); +var path = dir.path + "/"; + +// Now create some sample entries. +var file = dir.clone(); +file.append("test_file"); +file.create(file.NORMAL_FILE_TYPE, -1); +file = dir.clone(); +file.append("other_file"); +file.create(file.NORMAL_FILE_TYPE, -1); +dir.append("test_dir"); +dir.create(dir.DIRECTORY_TYPE, -1); + +var gListener = { + onSearchResult: function(aSearch, aResult) { + // Check that we got same search string back. + do_check_eq(aResult.searchString, "test"); + // Check that the search succeeded. + do_check_eq(aResult.searchResult, aResult.RESULT_SUCCESS); + // Check that we got two results. + do_check_eq(aResult.matchCount, 2); + // Check that the first result is the directory we created. + do_check_eq(aResult.getValueAt(0), "test_dir"); + // Check that the first result has directory style. + do_check_eq(aResult.getStyleAt(0), "directory"); + // Check that the second result is the file we created. + do_check_eq(aResult.getValueAt(1), "test_file"); + // Check that the second result has file style. + do_check_eq(aResult.getStyleAt(1), "file"); + } +}; + +function run_test() +{ + Components.classes["@mozilla.org/autocomplete/search;1?name=file"] + .getService(Components.interfaces.nsIAutoCompleteSearch) + .startSearch("test", path, null, gListener); +} |