~ubuntu-branches/ubuntu/oneiric/thunderbird/oneiric-proposed

« back to all changes in this revision

Viewing changes to debian/messagingmenu/tests/test-messaging-menu.js

  • Committer: Bazaar Package Importer
  • Author(s): Chris Coulson
  • Date: 2011-06-30 18:16:13 UTC
  • Revision ID: james.westby@ubuntu.com-20110630181613-uew2ekdaemy4v7es
Tags: 5.0+build1+nobinonly-0ubuntu2
* Ship the messagingmenu extension (0.7.2)
  - add debian/messagingmenu/*
  - update debian/rules
  - update debian/control{.in}
  - update debian/thunderbird.dirs.in
* Add static launcher items to the messaging menu and quicklist items to the
  Unity launcher
  - update debian/thunderbird.desktop.in
  - update debian/rules

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* ***** BEGIN LICENSE BLOCK *****
 
2
 *   Version: MPL 1.1/GPL 2.0/LGPL 2.1
 
3
 *
 
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/
 
8
 *
 
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
 
12
 * License.
 
13
 *
 
14
 * The Original Code is Messaging Menu Extension.
 
15
 *
 
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.
 
20
 *
 
21
 * Contributor(s):
 
22
 *   Mike Conley <mconley@mozillamessaging.com>
 
23
 *
 
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.
 
35
 *
 
36
 * ***** END LICENSE BLOCK ***** */
 
37
 
 
38
/*
 
39
 * Test that message reloads happen properly when the message pane is hidden,
 
40
 * and then made visible again.
 
41
 */
 
42
var MODULE_NAME = "test-messaging-menu";
 
43
 
 
44
var RELATIVE_ROOT = "../shared-modules";
 
45
var MODULE_REQUIRES = ["folder-display-helpers"];
 
46
 
 
47
var Indicator = null;
 
48
var msg = null;
 
49
var folder = null;
 
50
var msgSets = [];
 
51
 
 
52
var IndicatorMock = function()
 
53
{
 
54
  this.doIndications = [];
 
55
  this.stopIndications = [];
 
56
};
 
57
 
 
58
var doIndication = function(folderURL, label, messageURL, count,
 
59
                            dateInSeconds)
 
60
{
 
61
  Indicator.doIndications.push({folderURL: folderURL,
 
62
                                label: label,
 
63
                                count: count,
 
64
                                messageURL: messageURL,
 
65
                                dateInSeconds: dateInSeconds});
 
66
};
 
67
 
 
68
var stopIndication = function(folderURL)
 
69
{
 
70
  Indicator.stopIndications.push({folderURL: folderURL});
 
71
}
 
72
 
 
73
 
 
74
function setupModule(module)
 
75
{
 
76
  let fdh = collector.getModule('folder-display-helpers');
 
77
  fdh.installInto(module);
 
78
  folder = create_folder("Test folder");
 
79
}
 
80
 
 
81
function setupTest(test)
 
82
{
 
83
  if(Indicator)
 
84
    delete Indicator;
 
85
  Indicator = new IndicatorMock();
 
86
  mc.window.uMessagingMenu._doIndicationHook = doIndication;
 
87
  mc.window.uMessagingMenu._stopIndicationHook = stopIndication;
 
88
  be_in_folder(inboxFolder);
 
89
}
 
90
 
 
91
function teardownTest(test)
 
92
{
 
93
  for each (let msgSet in msgSets) {
 
94
    delete_message_set(msgSet);
 
95
  }
 
96
  msgSets = [];
 
97
}
 
98
 
 
99
function add_message_set_to_folder(aFolder, aNumToAdd)
 
100
{
 
101
  let [msgSet] = make_new_sets_in_folder(aFolder, [{count:aNumToAdd}]);
 
102
  msgSets.push(msgSet);
 
103
  return msgSet;
 
104
}
 
105
 
 
106
function test_new_inbox_mail_causes_indicate()
 
107
{
 
108
  add_message_set_to_folder(inboxFolder, 1);
 
109
  assert_equals(1, Indicator.doIndications.length);
 
110
}
 
111
 
 
112
function test_uninteresting_folders_do_not_indicate()
 
113
{
 
114
  let uninteresting = [Ci.nsMsgFolderFlags.Trash, Ci.nsMsgFolderFlags.Junk,
 
115
                       Ci.nsMsgFolderFlags.SentMail, Ci.nsMsgFolderFlags.Drafts,
 
116
                       Ci.nsMsgFolderFlags.Templates, Ci.nsMsgFolderFlags.Queue];
 
117
 
 
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);
 
123
  }
 
124
 
 
125
}
 
126
 
 
127
function test_clicking_new_message_hides_indicator()
 
128
{
 
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);
 
134
}
 
135
 
 
136
function test_show_oldest_new_unread_message()
 
137
{
 
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);
 
143
}
 
144
 
 
145
function test_indicates_new_unread_after_previous_indication()
 
146
{
 
147
  add_message_set_to_folder(inboxFolder, 1);
 
148
  select_click_row(0);
 
149
  let secondMsgSet = add_message_set_to_folder(inboxFolder, 1);
 
150
  let secondMsgURL = secondMsgSet.getMsgURI(0);
 
151
 
 
152
  assert_equals(2, Indicator.doIndications.length);
 
153
  assert_equals(1, Indicator.stopIndications.length);
 
154
  assert_equals(secondMsgURL, Indicator.doIndications[1].messageURL);
 
155
}
 
156
 
 
157