diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 17:32:43 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 17:32:43 +0000 |
commit | 6bf0a5cb5034a7e684dcc3500e841785237ce2dd (patch) | |
tree | a68f146d7fa01f0134297619fbe7e33db084e0aa /comm/mailnews/base/test/unit/test_loadVirtualFolders.js | |
parent | Initial commit. (diff) | |
download | thunderbird-upstream.tar.xz thunderbird-upstream.zip |
Adding upstream version 1:115.7.0.upstream/1%115.7.0upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'comm/mailnews/base/test/unit/test_loadVirtualFolders.js')
-rw-r--r-- | comm/mailnews/base/test/unit/test_loadVirtualFolders.js | 64 |
1 files changed, 64 insertions, 0 deletions
diff --git a/comm/mailnews/base/test/unit/test_loadVirtualFolders.js b/comm/mailnews/base/test/unit/test_loadVirtualFolders.js new file mode 100644 index 0000000000..13afd3f03b --- /dev/null +++ b/comm/mailnews/base/test/unit/test_loadVirtualFolders.js @@ -0,0 +1,64 @@ +/* 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/. */ + +// Test loading of virtualFolders.dat, including verification of the search +// scopes, i.e., folder uri's. + +var { MailServices } = ChromeUtils.import( + "resource:///modules/MailServices.jsm" +); + +// As currently written, this test will only work with Berkeley store. +Services.prefs.setCharPref( + "mail.serverDefaultStoreContractID", + "@mozilla.org/msgstore/berkeleystore;1" +); + +// main test + +function run_test() { + let vfdat = do_get_file("../../../data/test_virtualFolders.dat"); + + vfdat.copyTo(do_get_profile(), "virtualFolders.dat"); + localAccountUtils.loadLocalMailAccount(); + let localMailDir = do_get_profile().clone(); + localMailDir.append("Mail"); + localMailDir.append("Local Folders"); + localMailDir.append("unread-local"); + localMailDir.create(Ci.nsIFile.NORMAL_FILE_TYPE, 0o644); + localMailDir.leafName = "invalidserver-local"; + localMailDir.create(Ci.nsIFile.NORMAL_FILE_TYPE, 0o644); + localMailDir.leafName = "$label1"; + localMailDir.create(Ci.nsIFile.NORMAL_FILE_TYPE, 0o644); + + MailServices.accounts.loadVirtualFolders(); + let unreadLocal = + localAccountUtils.incomingServer.rootMsgFolder.getChildNamed( + "unread-local" + ); + let searchScope = + unreadLocal.msgDatabase.dBFolderInfo.getCharProperty("searchFolderUri"); + Assert.equal( + searchScope, + "mailbox://nobody@Local%20Folders/Inbox|mailbox://nobody@Local%20Folders/Trash" + ); + let invalidServer = + localAccountUtils.incomingServer.rootMsgFolder.getChildNamed( + "invalidserver-local" + ); + searchScope = + invalidServer.msgDatabase.dBFolderInfo.getCharProperty("searchFolderUri"); + Assert.equal(searchScope, "mailbox://nobody@Local%20Folders/Inbox"); + + let tagsFolder = + localAccountUtils.incomingServer.rootMsgFolder.getChildNamed("$label1"); + Assert.equal( + tagsFolder.msgDatabase.dBFolderInfo.getCharProperty("searchFolderUri"), + "*" + ); + Assert.equal( + tagsFolder.msgDatabase.dBFolderInfo.getCharProperty("searchStr"), + "AND (tag,contains,$label1)" + ); +} |