blob: 1c3f1fb59c8dc0b76dcd610c5b4260c9b8321978 (
plain)
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
65
66
67
68
69
70
71
72
73
74
75
|
/* 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/. */
const { VirtualFolderHelper } = ChromeUtils.import(
"resource:///modules/VirtualFolderWrapper.jsm"
);
const { MessageGenerator } = ChromeUtils.import(
"resource://testing-common/mailnews/MessageGenerator.jsm"
);
const tabmail = document.getElementById("tabmail");
const about3Pane = tabmail.currentAbout3Pane;
let rootFolder;
let inboxFolder;
add_setup(async function () {
MailServices.accounts.createLocalMailAccount();
const account = MailServices.accounts.accounts[0];
rootFolder = account.incomingServer.rootFolder;
rootFolder.QueryInterface(Ci.nsIMsgLocalMailFolder);
// Set the active modes of the folder pane. In theory we only need the "smart"
// mode to test with, but in practice we also need the "all" mode to generate
// messages in folders.
about3Pane.folderPane.activeModes = ["all", "smart"];
registerCleanupFunction(() => {
MailServices.accounts.removeAccount(account, false);
about3Pane.folderPane.activeModes = ["all"];
});
});
/**
* Test deleting a message from a smart folder using
* gDBView.applyCommandToIndices.
*/
add_task(async function testDeleteViaDBViewCommand() {
// Create an inbox folder.
const inboxFolder = rootFolder
.createLocalSubfolder("testDeleteInbox")
.QueryInterface(Ci.nsIMsgLocalMailFolder);
inboxFolder.setFlag(Ci.nsMsgFolderFlags.Inbox);
// Add a message to the folder.
const generator = new MessageGenerator();
inboxFolder.addMessage(generator.makeMessage().toMboxString());
// Create a smart folder from the inbox.
const smartInboxFolder = getSmartServer().rootFolder.getFolderWithFlags(
Ci.nsMsgFolderFlags.Inbox
);
// Switch the view to the smart folder.
about3Pane.displayFolder(smartInboxFolder.URI);
// Get the DB view and tree view to use to send the command and observe its
// effect.
const dbView = about3Pane.gDBView;
const treeView = dbView.QueryInterface(Ci.nsITreeView);
// Ensure we currently have one message.
Assert.equal(treeView.rowCount, 1, "should have one message before deleting");
// Delete the message using applyCommandToIndices.
dbView.applyCommandToIndices(Ci.nsMsgViewCommandType.deleteMsg, [0]);
// Test that the message has been deleted.
await TestUtils.waitForCondition(
() => treeView.rowCount === 0,
"there should be no remaining message in the tree"
);
});
|