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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/*
* Test suite for increasing the popularity of contacts via
* expandMailingLists.
*/
var { MailServices } = ChromeUtils.import(
"resource:///modules/MailServices.jsm"
);
var TESTS = [
{
email: "em@test.invalid",
// TB 2 stored popularity as hex, so we need to check correct handling.
prePopularity: "a",
postPopularity: "11",
},
{
email: "e@test.invalid",
prePopularity: "0",
postPopularity: "1",
},
{
email: "e@test.invalid",
prePopularity: "1",
postPopularity: "2",
},
{
email: "em@test.invalid",
prePopularity: "11",
postPopularity: "12",
},
];
function checkPopulate(aTo, aCheckTo) {
let msgCompose = Cc["@mozilla.org/messengercompose/compose;1"].createInstance(
Ci.nsIMsgCompose
);
// Set up some basic fields for compose.
let fields = Cc[
"@mozilla.org/messengercompose/composefields;1"
].createInstance(Ci.nsIMsgCompFields);
fields.to = aTo;
// Set up some params
let params = Cc[
"@mozilla.org/messengercompose/composeparams;1"
].createInstance(Ci.nsIMsgComposeParams);
params.composeFields = fields;
msgCompose.initialize(params);
Assert.ok(!msgCompose.expandMailingLists());
Assert.equal(fields.to, aCheckTo);
}
function run_test() {
loadABFile("../../../data/tb2hexpopularity", kPABData.fileName);
// Check the popularity index on a couple of cards.
let AB = MailServices.ab.getDirectory(kPABData.URI);
for (let i = 0; i < TESTS.length; ++i) {
let card = AB.cardForEmailAddress(TESTS[i].email);
Assert.ok(!!card);
// Thunderbird 2 stored its popularityIndexes as hex, hence when we read it
// now we're going to get a hex value. The AB has a value of "a".
Assert.equal(
card.getProperty("PopularityIndex", -1),
TESTS[i].prePopularity
);
// Call the check populate function.
checkPopulate(TESTS[i].email, TESTS[i].email);
// Now we've run check populate, check the popularityIndex has increased.
card = AB.cardForEmailAddress(TESTS[i].email);
Assert.ok(!!card);
// Thunderbird 2 stored its popularityIndexes as hex, hence when we read it
// now we're going to get a hex value. The AB has a value of "a".
Assert.equal(
card.getProperty("PopularityIndex", -1),
TESTS[i].postPopularity
);
}
}
|