Bug 900881 Make localAccountUtils.js into a testing module - Part 1. Move its functions into an object. r=jcranmer

This commit is contained in:
Mark Banner 2013-08-02 18:10:30 +01:00
Родитель d5b5edb3cf
Коммит 0f1a54ee96
93 изменённых файлов: 195 добавлений и 193 удалений

Просмотреть файл

@ -71,21 +71,22 @@ let gSensitiveData = [];
*/
function setup_accounts() {
// First make sure the local folders account is set up.
loadLocalMailAccount();
localAccountUtils.loadLocalMailAccount();
// Now run through the details and set up accounts accordingly.
for (let [, details] in Iterator(gAccountList)) {
let server = create_incoming_server(details.type, details.port,
details.user, details.password);
let server = localAccountUtils.create_incoming_server(details.type, details.port,
details.user, details.password);
server.socketType = details.socketType;
server.authMethod = details.authMethod;
gSensitiveData.push(details.password);
for (let [, smtpDetails] in Iterator(details.smtpServers)) {
let outgoing = create_outgoing_server(smtpDetails.port, smtpDetails.user,
smtpDetails.password);
let outgoing = localAccountUtils.create_outgoing_server(smtpDetails.port,
smtpDetails.user,
smtpDetails.password);
outgoing.socketType = smtpDetails.socketType;
outgoing.authMethod = smtpDetails.authMethod;
associate_servers(server, outgoing, smtpDetails.isDefault);
localAccountUtils.associate_servers(server, outgoing, smtpDetails.isDefault);
gSensitiveData.push(smtpDetails.password);
// Add the SMTP server to our server name -> server map

Просмотреть файл

@ -12,7 +12,7 @@ var hdr;
function run_test()
{
loadLocalMailAccount();
localAccountUtils.loadLocalMailAccount();
var copyListener =
{

Просмотреть файл

@ -43,7 +43,7 @@ var emails =
// main test
function run_test()
{
loadLocalMailAccount();
localAccountUtils.loadLocalMailAccount();
do_test_pending();
doTestingListener.onMessageClassified(null, null, null);
return true;

Просмотреть файл

@ -58,7 +58,7 @@ var Tests =
function run_test()
{
loadLocalMailAccount();
localAccountUtils.loadLocalMailAccount();
// add the custom headers into the preferences file, ":" delimited

Просмотреть файл

@ -23,8 +23,7 @@ var tag1 = "istag";
function run_test()
{
loadLocalMailAccount();
localAccountUtils.loadLocalMailAccount();
// Get messageCount messages into the local filestore.
do_test_pending();

Просмотреть файл

@ -8,7 +8,7 @@ Components.utils.import("resource://gre/modules/Services.jsm");
function run_test()
{
loadLocalMailAccount();
localAccountUtils.loadLocalMailAccount();
var rootFolder = gLocalIncomingServer.rootFolder;

Просмотреть файл

@ -39,8 +39,7 @@ var Tests =
function run_test()
{
// Setup local mail accounts.
loadLocalMailAccount();
localAccountUtils.loadLocalMailAccount();
// Get a message into the local filestore. function testBodySearch() continues the testing after the copy.
do_test_pending();

Просмотреть файл

@ -13,7 +13,7 @@ Components.utils.import("resource:///modules/mailServices.js");
const bugmail1 = do_get_file("../../../data/bugmail1");
var gHdr; // header of test message in local folder
loadLocalMailAccount();
localAccountUtils.loadLocalMailAccount();
// create a subfolder as a target for copies
var gSubfolder = gLocalInboxFolder.createLocalSubfolder("subfolder");

Просмотреть файл

@ -146,7 +146,7 @@ const gTestArray =
function run_test()
{
loadLocalMailAccount();
localAccountUtils.loadLocalMailAccount();
// Load up some messages so that we can copy them in later.
gMsgFile1 = do_get_file("../../../data/bugmail10");
gMsgFile2 = do_get_file("../../../data/bugmail11");

Просмотреть файл

@ -50,8 +50,7 @@ function CopyNextMessage()
function run_test()
{
loadLocalMailAccount();
localAccountUtils.loadLocalMailAccount();
let messageGenerator = new MessageGenerator();
let scenarioFactory = new MessageScenarioFactory(messageGenerator);

Просмотреть файл

@ -106,7 +106,7 @@ function folderCount(folder)
function run_test()
{
if (!gLocalInboxFolder)
loadLocalMailAccount();
localAccountUtils.loadLocalMailAccount();
gCopyFolder = gLocalIncomingServer.rootFolder.createLocalSubfolder("CopyFolder");
gMoveFolder = gLocalIncomingServer.rootFolder.createLocalSubfolder("MoveFolder");

Просмотреть файл

@ -92,7 +92,7 @@ let gCallbackObject = new SaveAttachmentCallback();
function run_test()
{
if (!gLocalInboxFolder)
loadLocalMailAccount();
localAccountUtils.loadLocalMailAccount();
async_run_tests(tests);
}

Просмотреть файл

@ -131,7 +131,7 @@ gMFListener.prototype =
function run_test()
{
loadLocalMailAccount();
localAccountUtils.loadLocalMailAccount();
// Load up a message so that we can copy it in later.
gMsgFile1 = do_get_file("../../../data/bugmail10");
// our front end code clears the msg db when it gets told the folder for

Просмотреть файл

@ -202,7 +202,7 @@ const gTestArray =
function run_test()
{
loadLocalMailAccount();
localAccountUtils.loadLocalMailAccount();
// Load up some messages so that we can copy them in later.
gMsgFile1 = do_get_file("../../../data/bugmail10");
gMsgFile2 = do_get_file("../../../data/bugmail11");

Просмотреть файл

@ -53,7 +53,7 @@ const gTestFiles =
function run_test()
{
loadLocalMailAccount();
localAccountUtils.loadLocalMailAccount();
var folder = gLocalIncomingServer.rootMsgFolder;
gTestFiles.forEach(function (test)

Просмотреть файл

@ -8,7 +8,7 @@
function run_test()
{
loadLocalMailAccount();
localAccountUtils.loadLocalMailAccount();
var rootFolder = gLocalIncomingServer.rootMsgFolder;
// add subfolders to the inbox

Просмотреть файл

@ -18,7 +18,7 @@ function run_test()
let vfdat = do_get_file("../../../data/test_virtualFolders.dat");
vfdat.copyTo(gProfileDir, "virtualFolders.dat");
loadLocalMailAccount();
localAccountUtils.loadLocalMailAccount();
let localMailDir = gProfileDir.clone();
localMailDir.append("Mail");
localMailDir.append("Local Folders");

Просмотреть файл

@ -96,7 +96,7 @@ let gCallbackObject = new SaveAttachmentCallback();
function run_test()
{
if (!gLocalInboxFolder)
loadLocalMailAccount();
localAccountUtils.loadLocalMailAccount();
async_run_tests(tests);
}

Просмотреть файл

@ -282,7 +282,7 @@ function run_test()
// Add a listener.
gMFNService.addListener(gMFListener, allTestedEvents);
loadLocalMailAccount();
localAccountUtils.loadLocalMailAccount();
// Load up some messages so that we can copy them in later.
gMsgFile1 = do_get_file("../../../data/bugmail10");

Просмотреть файл

@ -113,7 +113,7 @@ function run_test()
// quarantine messages
Services.prefs.setBoolPref("mailnews.downloadToTempFile", true);
if (!gLocalInboxFolder)
loadLocalMailAccount();
localAccountUtils.loadLocalMailAccount();
gMoveFolder = gLocalIncomingServer.rootMsgFolder
.createLocalSubfolder("MoveFolder");

Просмотреть файл

@ -232,7 +232,7 @@ var Tests =
function run_test()
{
loadLocalMailAccount();
localAccountUtils.loadLocalMailAccount();
var copyListener =
{

Просмотреть файл

@ -116,8 +116,7 @@ var messageKey, hdr;
function run_test()
{
// Setup local mail accounts.
loadLocalMailAccount();
localAccountUtils.loadLocalMailAccount();
// Test setup - copy the data file into place
var testAB = do_get_file("../../../addrbook/test/unit/data/cardForEmail.mab");

Просмотреть файл

@ -113,7 +113,7 @@ var copyListener =
function run_test()
{
loadLocalMailAccount();
localAccountUtils.loadLocalMailAccount();
// test that validity table terms are valid

Просмотреть файл

@ -110,7 +110,7 @@ var searchListener =
function run_test()
{
loadLocalMailAccount();
localAccountUtils.loadLocalMailAccount();
/*
* I want to create and test a search term that uses this expression:

Просмотреть файл

@ -20,7 +20,7 @@ function run_test()
// Pull in the IMAP fake server code
load("../../../imap/test/unit/head_server.js");
loadLocalMailAccount();
localAccountUtils.loadLocalMailAccount();
/*
* Set up an IMAP server.

Просмотреть файл

@ -59,7 +59,7 @@ var customTerm =
function run_test()
{
loadLocalMailAccount();
localAccountUtils.loadLocalMailAccount();
MailServices.filters.addCustomTerm(customTerm);
var copyListener =

Просмотреть файл

@ -211,7 +211,7 @@ var Tests =
function run_test()
{
loadLocalMailAccount();
localAccountUtils.loadLocalMailAccount();
// test that validity table terms are valid

Просмотреть файл

@ -280,7 +280,7 @@ var hdr;
function run_test()
{
loadLocalMailAccount();
localAccountUtils.loadLocalMailAccount();
// test that validity table terms are valid

Просмотреть файл

@ -73,7 +73,7 @@ var Tests =
function run_test()
{
loadLocalMailAccount();
localAccountUtils.loadLocalMailAccount();
var copyListener =
{

Просмотреть файл

@ -36,7 +36,7 @@ function setupServerDaemon(handler) {
}
function getBasicSmtpServer() {
let server = create_outgoing_server(SMTP_PORT, "user", "password");
let server = localAccountUtils.create_outgoing_server(SMTP_PORT, "user", "password");
// Override the default greeting so we get something predicitable
// in the ELHO message

Просмотреть файл

@ -131,6 +131,6 @@ var tests = [
]
function run_test() {
loadLocalMailAccount();
localAccountUtils.loadLocalMailAccount();
async_run_tests(tests);
}

Просмотреть файл

@ -57,7 +57,7 @@ function run_test() {
var testFile = do_get_file("data/message1.eml");
// Ensure we have at least one mail account
loadLocalMailAccount();
localAccountUtils.loadLocalMailAccount();
var smtpServer = getBasicSmtpServer();
var identity = getSmtpIdentity(kSender, smtpServer);

Просмотреть файл

@ -58,7 +58,7 @@ function copyFileMessageInLocalFolder(aMessageFile,
aMessageWindow,
aCallback) {
// Set up local folders
loadLocalMailAccount();
localAccountUtils.loadLocalMailAccount();
gCopyListener.callbackFunction = aCallback;
// Copy a message into the local folder

Просмотреть файл

@ -173,7 +173,7 @@ function run_test() {
// Ensure we have a local mail account, an normal account and appropriate
// servers and identities.
loadLocalMailAccount();
localAccountUtils.loadLocalMailAccount();
MailServices.accounts.setSpecialFolders();

Просмотреть файл

@ -54,7 +54,7 @@ var tests = [
function run_test() {
// Ensure we have at least one mail account
loadLocalMailAccount();
localAccountUtils.loadLocalMailAccount();
Services.prefs.setIntPref("mail.strictly_mime.parm_folding", 0);
async_run_tests(tests);

Просмотреть файл

@ -18,7 +18,7 @@ function actually_run_test() {
}
function run_test() {
loadLocalMailAccount();
localAccountUtils.loadLocalMailAccount();
do_test_pending();

Просмотреть файл

@ -87,7 +87,7 @@ function run_test() {
// Ensure we have a local mail account, an normal account and appropriate
// servers and identities.
loadLocalMailAccount();
localAccountUtils.loadLocalMailAccount();
// Now load (and internally initialize) the send later service
gMsgSendLater = Cc["@mozilla.org/messengercompose/sendlater;1"]

Просмотреть файл

@ -178,7 +178,7 @@ function run_test()
.replace("%s", kToInvalid);
// Ensure we have at least one mail account
loadLocalMailAccount();
localAccountUtils.loadLocalMailAccount();
MailServices.accounts.setSpecialFolders();
sentFolder = gLocalIncomingServer.rootMsgFolder.createLocalSubfolder("Sent");

Просмотреть файл

@ -22,7 +22,7 @@ function test_RFC2821() {
var testFile = do_get_file("data/message1.eml");
// Ensure we have at least one mail account
loadLocalMailAccount();
localAccountUtils.loadLocalMailAccount();
var smtpServer = getBasicSmtpServer();
var identity = getSmtpIdentity(kSender, smtpServer);

Просмотреть файл

@ -112,7 +112,7 @@ function run_test() {
originalData = IOUtils.loadFileToString(testFile);
// Ensure we have at least one mail account
loadLocalMailAccount();
localAccountUtils.loadLocalMailAccount();
MailServices.accounts.setSpecialFolders();

Просмотреть файл

@ -177,7 +177,7 @@ function run_test() {
// Ensure we have a local mail account, an normal account and appropriate
// servers and identities.
loadLocalMailAccount();
localAccountUtils.loadLocalMailAccount();
// Check that the send later service thinks we don't have messages to send
do_check_eq(msgSendLater.hasUnsentMessages(identity), false);

Просмотреть файл

@ -220,7 +220,7 @@ function run_test() {
// Ensure we have a local mail account, an normal account and appropriate
// servers and identities.
loadLocalMailAccount();
localAccountUtils.loadLocalMailAccount();
// Check that the send later service thinks we don't have messages to send.
do_check_eq(msgSendLater.hasUnsentMessages(identity), false);

Просмотреть файл

@ -124,7 +124,7 @@ function run_test() {
// Ensure we have a local mail account, an normal account and appropriate
// servers and identities.
loadLocalMailAccount();
localAccountUtils.loadLocalMailAccount();
// Check that the send later service thinks we don't have messages to send.
do_check_eq(msgSendLater.hasUnsentMessages(identity), false);

Просмотреть файл

@ -100,7 +100,7 @@ function run_test() {
dump("AUTH PLAIN = " + AUTHPLAIN + "\n");
server.start(SMTP_PORT);
loadLocalMailAccount();
localAccountUtils.loadLocalMailAccount();
smtpServer = getBasicSmtpServer();
smtpServer.socketType = Ci.nsMsgSocketType.plain;
smtpServer.username = kUsername;

Просмотреть файл

@ -34,7 +34,7 @@ function run_test() {
var testFile = do_get_file("data/message1.eml");
// Ensure we have at least one mail account
loadLocalMailAccount();
localAccountUtils.loadLocalMailAccount();
var smtpServer = getBasicSmtpServer();
var identity = getSmtpIdentity(kSender, smtpServer);

Просмотреть файл

@ -20,7 +20,7 @@ function run_test()
signons.copyTo(gProfileDir, "signons.txt");
// Set up the basic accounts and folders.
loadLocalMailAccount();
localAccountUtils.loadLocalMailAccount();
var smtpServer1 = getBasicSmtpServer();
var smtpServer2 = getBasicSmtpServer();

Просмотреть файл

@ -76,7 +76,7 @@ function run_test() {
var testFile = do_get_file("data/message1.eml");
// Ensure we have at least one mail account
loadLocalMailAccount();
localAccountUtils.loadLocalMailAccount();
var smtpServer = getBasicSmtpServer();
var identity = getSmtpIdentity(kSender, smtpServer);

Просмотреть файл

@ -87,7 +87,7 @@ function run_test() {
var testFile = do_get_file("data/message1.eml");
// Ensure we have at least one mail account
loadLocalMailAccount();
localAccountUtils.loadLocalMailAccount();
var smtpServer = getBasicSmtpServer();
var identity = getSmtpIdentity(kSender, smtpServer);

Просмотреть файл

@ -86,7 +86,7 @@ function run_test() {
var testFile = do_get_file("data/message1.eml");
// Ensure we have at least one mail account
loadLocalMailAccount();
localAccountUtils.loadLocalMailAccount();
var smtpServer = getBasicSmtpServer();
var identity = getSmtpIdentity(kSender, smtpServer);

Просмотреть файл

@ -49,7 +49,7 @@ function run_test() {
});
// Ensure we have at least one mail account
loadLocalMailAccount();
localAccountUtils.loadLocalMailAccount();
let composeService = MailServices.compose;
do_test_pending();
check_files_not_exist(gExpectedFiles);

Просмотреть файл

@ -75,7 +75,7 @@ function run_test() {
});
// Ensure we have at least one mail account
loadLocalMailAccount();
localAccountUtils.loadLocalMailAccount();
gMsgCompose = Cc["@mozilla.org/messengercompose/compose;1"]
.createInstance(Ci.nsIMsgCompose);

Просмотреть файл

@ -28,7 +28,7 @@ function test_enumerator_cleanup() {
*/
function run_test() {
loadLocalMailAccount();
localAccountUtils.loadLocalMailAccount();
do_test_pending();
MailServices.copy.CopyFileMessage(anyOldMessage, gLocalInboxFolder, null, false, 0,
"", messageHeaderGetterListener, null);

Просмотреть файл

@ -12,7 +12,7 @@ const kNumExpectedMatches = 10;
function setupGlobals()
{
loadLocalMailAccount();
localAccountUtils.loadLocalMailAccount();
// Create a message generator
let messageGenerator = new MessageGenerator();
let localInbox = gLocalInboxFolder.QueryInterface(Ci.nsIMsgLocalMailFolder);

Просмотреть файл

@ -86,7 +86,7 @@ function doTest(test)
function run_test() {
loadLocalMailAccount();
localAccountUtils.loadLocalMailAccount();
do_test_pending();
doTest(1);
}

Просмотреть файл

@ -9,7 +9,7 @@ Components.utils.import("resource:///modules/mailServices.js");
var gHdr;
function run_test() {
loadLocalMailAccount();
localAccountUtils.loadLocalMailAccount();
// Get a message into the local filestore.
// Function continue_test() continues the testing after the copy.
var bugmail1 = do_get_file("../../../../data/bugmail1");

Просмотреть файл

@ -85,7 +85,7 @@ function test_references_header_parsing(aMsgHdr) {
*/
function run_test() {
loadLocalMailAccount();
localAccountUtils.loadLocalMailAccount();
do_test_pending();
MailServices.copy.CopyFileMessage(anyOldMessage, gLocalInboxFolder, null, false, 0,
"", messageHeaderGetterListener, null);

Просмотреть файл

@ -27,7 +27,7 @@ var trainingData;
// main test
function run_test()
{
loadLocalMailAccount();
localAccountUtils.loadLocalMailAccount();
MailServices.junk.resetTrainingData();
do_test_pending();

Просмотреть файл

@ -83,7 +83,7 @@ var tests =
// main test
function run_test()
{
loadLocalMailAccount();
localAccountUtils.loadLocalMailAccount();
do_test_pending();
startCommand();

Просмотреть файл

@ -272,7 +272,7 @@ var tests =
// main test
function run_test()
{
loadLocalMailAccount();
localAccountUtils.loadLocalMailAccount();
do_test_pending();
// setup pro/anti arrays as junk/good

Просмотреть файл

@ -93,7 +93,7 @@ var tests =
// main test
function run_test()
{
loadLocalMailAccount();
localAccountUtils.loadLocalMailAccount();
// load in the aliases trait testing file
MailServices.junk.QueryInterface(Ci.nsIMsgCorpus)

Просмотреть файл

@ -104,7 +104,7 @@ var tests =
// main test
function run_test()
{
loadLocalMailAccount();
localAccountUtils.loadLocalMailAccount();
do_test_pending();
startCommand();

Просмотреть файл

@ -1,7 +1,7 @@
var gMessenger = Cc["@mozilla.org/messenger;1"].
createInstance(Ci.nsIMessenger);
loadLocalMailAccount();
localAccountUtils.loadLocalMailAccount();
let localAccount = MailServices.accounts.FindAccountForServer(gLocalIncomingServer);
let identity = MailServices.accounts.createIdentity();

Просмотреть файл

@ -6,7 +6,7 @@
var gMessenger = Cc["@mozilla.org/messenger;1"].
createInstance(Ci.nsIMessenger);
loadLocalMailAccount();
localAccountUtils.loadLocalMailAccount();
let localAccount = MailServices.accounts.FindAccountForServer(gLocalIncomingServer);
let identity = MailServices.accounts.createIdentity();

Просмотреть файл

@ -52,7 +52,8 @@ function makeServer(daemon, infoString, otherProps) {
}
function createLocalIMAPServer() {
let server = create_incoming_server("imap", IMAP_PORT, "user", "password");
let server = localAccountUtils.create_incoming_server("imap", IMAP_PORT,
"user", "password");
server.QueryInterface(Ci.nsIImapIncomingServer);
return server;
}

Просмотреть файл

@ -32,7 +32,7 @@ function run_test() {
gImapServer = createLocalIMAPServer();
gImapServer.maximumConnectionsNumber = 1;
loadLocalMailAccount();
localAccountUtils.loadLocalMailAccount();
// We need an identity so that updateFolder doesn't fail
let localAccount = MailServices.accounts.createAccount();

Просмотреть файл

@ -330,7 +330,7 @@ function run_test()
gIMAPIncomingServer = createLocalIMAPServer();
if (!gLocalInboxFolder)
loadLocalMailAccount();
localAccountUtils.loadLocalMailAccount();
// We need an identity so that updateFolder doesn't fail
let localAccount = MailServices.accounts.createAccount();

Просмотреть файл

@ -32,7 +32,7 @@ function addMessagesToServer(messages, mailbox)
function run_test()
{
loadLocalMailAccount();
localAccountUtils.loadLocalMailAccount();
/*
* Set up an IMAP server.

Просмотреть файл

@ -206,7 +206,7 @@ function run_test()
// Also make sure a local folders server is created, as that's what is used
// for sent items
loadLocalMailAccount();
localAccountUtils.loadLocalMailAccount();
// We need an identity so that updateFolder doesn't fail
let localAccount = MailServices.accounts.createAccount();

Просмотреть файл

@ -32,7 +32,7 @@ function setup() {
gIMAPIncomingServer.socketType = Ci.nsMsgSocketType.alwaysSTARTTLS;
// we need a local account for the IMAP server to have its sent messages in
loadLocalMailAccount();
localAccountUtils.loadLocalMailAccount();
// We need an identity so that updateFolder doesn't fail
let imapAccount = MailServices.accounts.createAccount();

Просмотреть файл

@ -44,8 +44,9 @@ function setupServerDaemon(debugOption) {
}
function createPop3ServerAndLocalFolders() {
loadLocalMailAccount();
let server = create_incoming_server("pop3", POP3_PORT, "fred", "wilma");
localAccountUtils.loadLocalMailAccount();
let server = localAccountUtils.create_incoming_server("pop3", POP3_PORT,
"fred", "wilma");
return server;
}
@ -92,7 +93,7 @@ function copyFileMessageInLocalFolder(aMessageFile,
aMessageWindow,
aCallback) {
// Set up local folders
loadLocalMailAccount();
localAccountUtils.loadLocalMailAccount();
gCopyListener.callbackFunction = aCallback;
// Copy a message into the local folder

Просмотреть файл

@ -30,7 +30,7 @@ var tests = [
});
if (typeof gLocalInboxFolder == 'undefined')
loadLocalMailAccount();
localAccountUtils.loadLocalMailAccount();
gLocalRootFolder.createSubfolder("target", null);
gTargetFolder = gLocalRootFolder.getChildNamed("target");

Просмотреть файл

@ -23,7 +23,7 @@ var gMoveMailInbox;
function run_test()
{
loadLocalMailAccount();
localAccountUtils.loadLocalMailAccount();
let incoming = MailServices.accounts.createIncomingServer("", "", "movemail");
let workingDir = Services.dirsvc.get("CurWorkD", Ci.nsIFile);

Просмотреть файл

@ -8,7 +8,7 @@ Components.utils.import("resource:///modules/mailServices.js");
var gMessenger = Cc["@mozilla.org/messenger;1"].
createInstance(Ci.nsIMessenger);
loadLocalMailAccount();
localAccountUtils.loadLocalMailAccount();
let localAccount = MailServices.accounts.FindAccountForServer(gLocalIncomingServer);
let identity = MailServices.accounts.createIdentity();

Просмотреть файл

@ -7,7 +7,7 @@ Components.utils.import("resource:///modules/IOUtils.js");
const MSG_LINEBREAK = "\r\n";
function run_test() {
loadLocalMailAccount();
localAccountUtils.loadLocalMailAccount();
test_parse_headers_without_crash("./data/mailformed_recipients.eml");
test_parse_headers_without_crash("./data/mailformed_subject.eml");

Просмотреть файл

@ -13,7 +13,7 @@ var gLocalTrashFolder;
function run_test()
{
loadLocalMailAccount();
localAccountUtils.loadLocalMailAccount();
// "Master" do_test_pending(), paired with a do_test_finished() at the end of
// all the operations.

Просмотреть файл

@ -99,7 +99,7 @@ function growInbox(aWantedSize) {
function run_test()
{
loadLocalMailAccount();
localAccountUtils.loadLocalMailAccount();
// "Master" do_test_pending(), paired with a do_test_finished() at the end of
// all the operations.

Просмотреть файл

@ -173,7 +173,7 @@ function run_test() {
server.start(POP3_PORT);
//incomingServer = createPop3ServerAndLocalFolders();
loadLocalMailAccount();
localAccountUtils.loadLocalMailAccount();
do_test_pending();

Просмотреть файл

@ -121,7 +121,7 @@ function run_test()
// Make sure we're not quarantining messages
Services.prefs.setBoolPref("mailnews.downloadToTempFile", false);
if (!gLocalInboxFolder)
loadLocalMailAccount();
localAccountUtils.loadLocalMailAccount();
gMoveFolder = gLocalIncomingServer.rootFolder.createLocalSubfolder("MoveFolder");

Просмотреть файл

@ -206,7 +206,7 @@ function run_test() {
server.start(POP3_PORT);
//incomingServer = createPop3ServerAndLocalFolders();
loadLocalMailAccount();
localAccountUtils.loadLocalMailAccount();
do_test_pending();

Просмотреть файл

@ -113,7 +113,7 @@ function run_test()
// Make sure we're not quarantining messages
Services.prefs.setBoolPref("mailnews.downloadToTempFile", false);
if (!gLocalInboxFolder)
loadLocalMailAccount();
localAccountUtils.loadLocalMailAccount();
gMoveFolder = gLocalIncomingServer.rootFolder.createLocalSubfolder("MoveFolder");

Просмотреть файл

@ -102,7 +102,7 @@ function run_test()
// Make sure we're not quarantining messages
Services.prefs.setBoolPref("mailnews.downloadToTempFile", false);
if (!gLocalInboxFolder)
loadLocalMailAccount();
localAccountUtils.loadLocalMailAccount();
gMoveFolder = gLocalIncomingServer.rootFolder.createLocalSubfolder("MoveFolder");

Просмотреть файл

@ -137,7 +137,7 @@ function run_test() {
// We would use createPop3ServerAndLocalFolders() however we want to have
// a different username and NO password for this test (as we expect to load
// it from signons.txt).
loadLocalMailAccount();
localAccountUtils.loadLocalMailAccount();
incomingServer = MailServices.accounts.createIncomingServer("testpop3", "localhost", "pop3");

Просмотреть файл

@ -24,7 +24,7 @@ function run_test()
// We would use createPop3ServerAndLocalFolders() however we want to have
// a different username and NO password for this test (as we expect to load
// it from signons.txt).
loadLocalMailAccount();
localAccountUtils.loadLocalMailAccount();
let incomingServer1 = MailServices.accounts.createIncomingServer(kUser1, kHostname,
kProtocol);

Просмотреть файл

@ -179,7 +179,7 @@ function run_test()
// We would use createPop3ServerAndLocalFolders() however we want to have
// a different username and NO password for this test (as we expect to load
// it from signons.txt).
loadLocalMailAccount();
localAccountUtils.loadLocalMailAccount();
incomingServer = MailServices.accounts.createIncomingServer(kUserName, "localhost", "pop3");

Просмотреть файл

@ -197,7 +197,7 @@ function run_test()
// We would use createPop3ServerAndLocalFolders() however we want to have
// a different username and NO password for this test (as we expect to load
// it from signons.txt).
loadLocalMailAccount();
localAccountUtils.loadLocalMailAccount();
incomingServer = MailServices.accounts
.createIncomingServer(kUserName, "localhost", "pop3");

Просмотреть файл

@ -199,7 +199,7 @@ function run_test()
// We would use createPop3ServerAndLocalFolders() however we want to have
// a different username and NO password for this test (as we expect to load
// it from signons.txt).
loadLocalMailAccount();
localAccountUtils.loadLocalMailAccount();
incomingServer = MailServices.accounts
.createIncomingServer(kUserName, "localhost", "pop3");

Просмотреть файл

@ -86,7 +86,7 @@ function run_test()
// We would use createPop3ServerAndLocalFolders() however we want to have
// a different username and NO password for this test (as we expect to load
// it from signons.txt).
loadLocalMailAccount();
localAccountUtils.loadLocalMailAccount();
incomingServer = MailServices.accounts

Просмотреть файл

@ -28,7 +28,7 @@ let gUrlListener = {
};
loadLocalMailAccount();
localAccountUtils.loadLocalMailAccount();
function run_test()
{

Просмотреть файл

@ -113,7 +113,8 @@ function subscribeServer(incomingServer) {
function setupLocalServer(port) {
if (_server != null)
return _server;
let server = create_incoming_server("nntp", port, null, null);
let server = localAccountUtils.create_incoming_server("nntp", port,
null, null);
subscribeServer(server);
_server = server;

Просмотреть файл

@ -21,7 +21,7 @@ function run_test()
signons.copyTo(gProfileDir, "signons.txt");
// Set up the basic accounts and folders.
loadLocalMailAccount();
localAccountUtils.loadLocalMailAccount();
var incomingServer = MailServices.accounts.createIncomingServer(null, kHostname,
kProtocol);

Просмотреть файл

@ -69,7 +69,8 @@ function setupIMAPPump(extensions)
}
function createLocalIMAPServer() {
let server = create_incoming_server("imap", IMAP_PORT, "user", "password");
let server = localAccountUtils.create_incoming_server("imap", IMAP_PORT,
"user", "password");
server.QueryInterface(Ci.nsIImapIncomingServer);
return server;
}
@ -82,7 +83,7 @@ function setupIMAPPump(extensions)
gIMAPIncomingServer = createLocalIMAPServer();
if (!this.gLocalInboxFolder)
loadLocalMailAccount();
localAccountUtils.loadLocalMailAccount();
// We need an identity so that updateFolder doesn't fail
let localAccount = MailServices.accounts.createAccount();

Просмотреть файл

@ -89,11 +89,11 @@ POP3Pump.prototype._createPop3ServerAndLocalFolders =
function _createPop3ServerAndLocalFolders()
{
if (typeof gLocalInboxFolder == 'undefined')
loadLocalMailAccount();
localAccountUtils.loadLocalMailAccount();
if (!this.fakeServer)
this.fakeServer = create_incoming_server("pop3", this.kPOP3_PORT,
"fred", "wilma");
this.fakeServer = localAccountUtils.create_incoming_server("pop3", this.kPOP3_PORT,
"fred", "wilma");
return this.fakeServer;
};

Просмотреть файл

@ -15,102 +15,103 @@ var gLocalMsgAccount;
var gLocalInboxFolder;
var _localAccountInitialized = false;
function loadLocalMailAccount()
{
// This function is idempotent
if (_localAccountInitialized)
return;
var localAccountUtils = {
loadLocalMailAccount: function() {
// This function is idempotent
if (_localAccountInitialized)
return;
MailServices.accounts.createLocalMailAccount();
MailServices.accounts.createLocalMailAccount();
gLocalIncomingServer = MailServices.accounts.localFoldersServer;
gLocalMsgAccount = MailServices.accounts.FindAccountForServer(
gLocalIncomingServer);
gLocalIncomingServer = MailServices.accounts.localFoldersServer;
gLocalMsgAccount = MailServices.accounts.FindAccountForServer(
gLocalIncomingServer);
gLocalRootFolder = gLocalIncomingServer.rootMsgFolder
.QueryInterface(Ci.nsIMsgLocalMailFolder);
// Note: Inbox is not created automatically when there is no deferred server,
// so we need to create it.
gLocalInboxFolder = gLocalRootFolder.createLocalSubfolder("Inbox")
gLocalRootFolder = gLocalIncomingServer.rootMsgFolder
.QueryInterface(Ci.nsIMsgLocalMailFolder);
// a local inbox should have a Mail flag!
gLocalInboxFolder.setFlag(Ci.nsMsgFolderFlags.Mail);
// Force an initialization of the Inbox folder database.
var folderName = gLocalInboxFolder.prettiestName;
// Note: Inbox is not created automatically when there is no deferred server,
// so we need to create it.
gLocalInboxFolder = gLocalRootFolder.createLocalSubfolder("Inbox")
.QueryInterface(Ci.nsIMsgLocalMailFolder);
// a local inbox should have a Mail flag!
gLocalInboxFolder.setFlag(Ci.nsMsgFolderFlags.Mail);
_localAccountInitialized = true;
}
// Force an initialization of the Inbox folder database.
var folderName = gLocalInboxFolder.prettiestName;
/**
* Create an nsIMsgIncomingServer and an nsIMsgAccount to go with it.
*
* @param aType The type of the server (pop3, imap etc).
* @param aPort The port the server is on.
* @param aUsername The username for the server.
* @param aPassword The password for the server.
* @return The newly-created nsIMsgIncomingServer.
*/
function create_incoming_server(aType, aPort, aUsername, aPassword) {
let server = MailServices.accounts.createIncomingServer(aUsername, "localhost",
aType);
server.port = aPort;
if (aUsername != null)
server.username = aUsername;
if (aPassword != null)
server.password = aPassword;
_localAccountInitialized = true;
},
server.valid = false;
/**
* Create an nsIMsgIncomingServer and an nsIMsgAccount to go with it.
*
* @param aType The type of the server (pop3, imap etc).
* @param aPort The port the server is on.
* @param aUsername The username for the server.
* @param aPassword The password for the server.
* @return The newly-created nsIMsgIncomingServer.
*/
create_incoming_server: function(aType, aPort, aUsername, aPassword) {
let server = MailServices.accounts.createIncomingServer(aUsername, "localhost",
aType);
server.port = aPort;
if (aUsername != null)
server.username = aUsername;
if (aPassword != null)
server.password = aPassword;
let account = MailServices.accounts.createAccount();
account.incomingServer = server;
if (aType == "pop3") {
// Several tests expect that mail is deferred to the local folders account,
// so do that.
loadLocalMailAccount();
server.QueryInterface(Ci.nsIPop3IncomingServer);
server.deferredToAccount = gLocalMsgAccount.key;
server.valid = false;
let account = MailServices.accounts.createAccount();
account.incomingServer = server;
if (aType == "pop3") {
// Several tests expect that mail is deferred to the local folders account,
// so do that.
this.loadLocalMailAccount();
server.QueryInterface(Ci.nsIPop3IncomingServer);
server.deferredToAccount = gLocalMsgAccount.key;
}
server.valid = true;
return server;
},
/**
* Create an outgoing nsISmtpServer with the given parameters.
*
* @param aPort The port the server is on.
* @param aUsername The username for the server
* @param aPassword The password for the server
* @return The newly-created nsISmtpServer.
*/
create_outgoing_server: function(aPort, aUsername, aPassword) {
let server = MailServices.smtp.createServer();
server.hostname = "localhost";
server.port = aPort;
server.authMethod = Ci.nsMsgAuthMethod.none;
return server;
},
/**
* Associate the given outgoing server with the given incoming server's account.
*
* @param aIncoming The incoming server (nsIMsgIncomingServer) or account
* (nsIMsgAccount) to associate.
* @param aOutgoingServer The outgoing server (nsISmtpServer) to associate.
* @param aSetAsDefault Whether to set the outgoing server as the default for
* the incoming server's account.
*/
associate_servers: function(aIncoming, aOutgoingServer, aSetAsDefault) {
let identity = MailServices.accounts.createIdentity();
identity.smtpServerKey = aOutgoingServer.key;
if (aIncoming instanceof Ci.nsIMsgIncomingServer)
aIncoming = MailServices.accounts.FindAccountForServer(aIncoming);
aIncoming.addIdentity(identity);
if (aSetAsDefault)
aIncoming.defaultIdentity = identity;
}
server.valid = true;
return server;
}
/**
* Create an outgoing nsISmtpServer with the given parameters.
*
* @param aPort The port the server is on.
* @param aUsername The username for the server
* @param aPassword The password for the server
* @return The newly-created nsISmtpServer.
*/
function create_outgoing_server(aPort, aUsername, aPassword) {
let server = MailServices.smtp.createServer();
server.hostname = "localhost";
server.port = aPort;
server.authMethod = Ci.nsMsgAuthMethod.none;
return server;
}
/**
* Associate the given outgoing server with the given incoming server's account.
*
* @param aIncoming The incoming server (nsIMsgIncomingServer) or account
* (nsIMsgAccount) to associate.
* @param aOutgoingServer The outgoing server (nsISmtpServer) to associate.
* @param aSetAsDefault Whether to set the outgoing server as the default for
* the incoming server's account.
*/
function associate_servers(aIncoming, aOutgoingServer, aSetAsDefault) {
let identity = MailServices.accounts.createIdentity();
identity.smtpServerKey = aOutgoingServer.key;
if (aIncoming instanceof Ci.nsIMsgIncomingServer)
aIncoming = MailServices.accounts.FindAccountForServer(aIncoming);
aIncoming.addIdentity(identity);
if (aSetAsDefault)
aIncoming.defaultIdentity = identity;
}
};
}; // gLocalAccountUtils_js__