1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
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)"
);
}
|