1
/* ***** BEGIN LICENSE BLOCK *****
2
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
4
* The contents of this file are subject to the Mozilla Public License Version
5
* 1.1 (the "License"); you may not use this file except in compliance with
6
* the License. You may obtain a copy of the License at
7
* http://www.mozilla.org/MPL/
9
* Software distributed under the License is distributed on an "AS IS" basis,
10
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
11
* for the specific language governing rights and limitations under the
14
* The Original Code is Messaging Menu Extension.
16
* The Initial Developer of the Original Code is
17
* the Mozilla Foundation.
18
* Portions created by the Initial Developer are Copyright (C) 2010
19
* the Initial Developer. All Rights Reserved.
22
* Mike Conley <mconley@mozillamessaging.com>
24
* Alternatively, the contents of this file may be used under the terms of
25
* either the GNU General Public License Version 2 or later (the "GPL"), or
26
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
27
* in which case the provisions of the GPL or the LGPL are applicable instead
28
* of those above. If you wish to allow use of your version of this file only
29
* under the terms of either the GPL or the LGPL, and not to allow others to
30
* use your version of this file under the terms of the MPL, indicate your
31
* decision by deleting the provisions above and replace them with the notice
32
* and other provisions required by the GPL or the LGPL. If you do not delete
33
* the provisions above, a recipient may use your version of this file under
34
* the terms of any one of the MPL, the GPL or the LGPL.
36
* ***** END LICENSE BLOCK ***** */
39
* Test that message reloads happen properly when the message pane is hidden,
40
* and then made visible again.
42
var MODULE_NAME = "test-messaging-menu";
44
var RELATIVE_ROOT = "../shared-modules";
45
var MODULE_REQUIRES = ["folder-display-helpers"];
52
var IndicatorMock = function()
54
this.doIndications = [];
55
this.stopIndications = [];
58
var doIndication = function(folderURL, label, messageURL, count,
61
Indicator.doIndications.push({folderURL: folderURL,
64
messageURL: messageURL,
65
dateInSeconds: dateInSeconds});
68
var stopIndication = function(folderURL)
70
Indicator.stopIndications.push({folderURL: folderURL});
74
function setupModule(module)
76
let fdh = collector.getModule('folder-display-helpers');
77
fdh.installInto(module);
78
folder = create_folder("Test folder");
81
function setupTest(test)
85
Indicator = new IndicatorMock();
86
mc.window.uMessagingMenu._doIndicationHook = doIndication;
87
mc.window.uMessagingMenu._stopIndicationHook = stopIndication;
88
be_in_folder(inboxFolder);
91
function teardownTest(test)
93
for each (let msgSet in msgSets) {
94
delete_message_set(msgSet);
99
function add_message_set_to_folder(aFolder, aNumToAdd)
101
let [msgSet] = make_new_sets_in_folder(aFolder, [{count:aNumToAdd}]);
102
msgSets.push(msgSet);
106
function test_new_inbox_mail_causes_indicate()
108
add_message_set_to_folder(inboxFolder, 1);
109
assert_equals(1, Indicator.doIndications.length);
112
function test_uninteresting_folders_do_not_indicate()
114
let uninteresting = [Ci.nsMsgFolderFlags.Trash, Ci.nsMsgFolderFlags.Junk,
115
Ci.nsMsgFolderFlags.SentMail, Ci.nsMsgFolderFlags.Drafts,
116
Ci.nsMsgFolderFlags.Templates, Ci.nsMsgFolderFlags.Queue];
118
for each (let folder_type in uninteresting) {
119
folder.setFlag(folder_type);
120
add_message_set_to_folder(folder, 1);
121
assert_equals(0, Indicator.doIndications.length);
122
folder.clearFlag(folder_type);
127
function test_clicking_new_message_hides_indicator()
129
add_message_set_to_folder(inboxFolder, 1);
130
let msgHdr = select_click_row(0);
131
open_selected_message();
132
wait_for_message_display_completion(mc);
133
assert_equals(1, Indicator.stopIndications.length);
136
function test_show_oldest_new_unread_message()
138
let firstMsgSet = add_message_set_to_folder(inboxFolder, 1);
139
let firstMsgURL = firstMsgSet.getMsgURI(0);
140
add_message_set_to_folder(inboxFolder, 2);
141
assert_equals(3, Indicator.doIndications.length);
142
assert_equals(firstMsgURL, Indicator.doIndications[2].messageURL);
145
function test_indicates_new_unread_after_previous_indication()
147
add_message_set_to_folder(inboxFolder, 1);
149
let secondMsgSet = add_message_set_to_folder(inboxFolder, 1);
150
let secondMsgURL = secondMsgSet.getMsgURI(0);
152
assert_equals(2, Indicator.doIndications.length);
153
assert_equals(1, Indicator.stopIndications.length);
154
assert_equals(secondMsgURL, Indicator.doIndications[1].messageURL);