Second bustage fix for bug 495020. Fix a couple of issues, one related to bug 495020 and one related to bug 545221.
authorSiddharth Agarwal <sid.bugzilla@gmail.com>
Thu, 01 Apr 2010 20:06:51 +0530
changeset 5347 f4330a8f5022d0d377d7f8836749bf57ed5af21e
parent 5346 1331ca255dd4851e434869d66cc9cdac368cbdde
child 5348 0d37fec983676b139487b4e53f3f1ff4d139b87c
push idunknown
push userunknown
push dateunknown
bugs495020, 545221
Second bustage fix for bug 495020. Fix a couple of issues, one related to bug 495020 and one related to bug 545221. 1. In test-display-message-with-folder-modes.js, the change in behaviour in bug 495020 means that the message is in the view at the time it is attempted to be displayed, thus the folder the message is in isn't expanded. Fix that by selecting a different folder before changing modes. 2. In messageInjection.js, make sure we use createSubfolder for the inbox and not addSubfolder. This causes an OnItemAdded notification, which the folder tree view gets to know that it needs to update itself. Without the fix, the inbox isn't displayed unless the folder mode is rebuilt. (This used to work earlier because the default used to be smart folders, and we used to switch to all folders after creating the inbox. Bug 545221 changed that.)
mail/test/mozmill/folder-display/test-display-message-with-folder-modes.js
mailnews/test/resources/messageInjection.js
--- a/mail/test/mozmill/folder-display/test-display-message-with-folder-modes.js
+++ b/mail/test/mozmill/folder-display/test-display-message-with-folder-modes.js
@@ -46,29 +46,34 @@
  */
 
 var MODULE_NAME = "test-display-message-with-folder-modes";
 
 var RELATIVE_ROOT = "../shared-modules";
 var MODULE_REQUIRES = ["folder-display-helpers"];
 
 var folder;
+var dummyFolder;
 var smartInboxFolder;
 
 var msgHdr;
 
 function setupModule(module) {
   let fdh = collector.getModule("folder-display-helpers");
   fdh.installInto(module);
 
   // This is a subfolder of the inbox so that
   // test_display_message_in_smart_folder_mode_works is able to test that we
   // don't attempt to expand any inboxes.
   inboxFolder.createSubfolder("DisplayMessageWithFolderModesA", null);
   folder = inboxFolder.getChildNamed("DisplayMessageWithFolderModesA");
+  // This second folder is meant to act as a dummy folder to switch to when we
+  // want to not be in folder.
+  inboxFolder.createSubfolder("DisplayMessageWithFolderModesB", null);
+  dummyFolder = inboxFolder.getChildNamed("DisplayMessageWithFolderModesB");
   make_new_sets_in_folder(folder, [{count: 5}]);
   // The message itself doesn't really matter, as long as there's at least one
   // in the inbox.
   make_new_sets_in_folder(inboxFolder, [{count: 1}]);
 }
 
 /**
  * Test that displaying a message causes a switch to the default folder mode if
@@ -95,39 +100,52 @@ function test_display_message_with_folde
 }
 
 /**
  * Test that displaying a message _does not_ cause a switch to the default
  * folder mode if the folder is present in the current folder mode.
  */
 function test_display_message_with_folder_present_in_current_folder_mode() {
   // Mark the folder as a favorite
-  folder.flags |= Components.interfaces.nsMsgFolderFlags.Favorite;
+  folder.flags |= Ci.nsMsgFolderFlags.Favorite;
+  // Also mark the dummy folder as a favorite, in preparation for
+  // test_display_message_in_smart_folder_mode_works
+  dummyFolder.flags |= Ci.nsMsgFolderFlags.Favorite;
 
   // Make sure the folder doesn't appear in the favorite folder mode just
   // because it was selected last before switching
   be_in_folder(inboxFolder);
 
-  // Switch to favorite folders. Check that the folder is now in the view
+  // Switch to favorite folders. Check that the folder is now in the view, as is
+  // the dummy folder
   mc.folderTreeView.mode = "favorite";
   assert_folder_visible(folder);
+  assert_folder_visible(dummyFolder);
 
   // Try displaying a message
   display_message_in_folder_tab(msgHdr);
 
   assert_folder_mode("favorite");
   assert_folder_selected_and_displayed(folder);
   assert_selected_and_displayed(msgHdr);
 }
 
 /**
  * Test that displaying a message in smart folders mode causes the parent in the
  * view to expand.
  */
 function test_display_message_in_smart_folder_mode_works() {
+  // Clear the message selection, otherwise msgHdr will still be displayed and
+  // display_message_in_folder_tab(msgHdr) will be a no-op.
+  select_none();
+  // Switch to the dummy folder, otherwise msgHdr will be in the view and the
+  // display message in folder tab logic will simply select the message without
+  // bothering to expand any folders.
+  be_in_folder(dummyFolder);
+
   mc.folderTreeView.mode = "smart";
 
   let rootFolder = folder.server.rootFolder;
   // Check that the folder is actually the child of the account root
   assert_folder_child_in_view(folder, rootFolder);
 
   // Collapse everything
   smartInboxFolder = get_smart_folder_named("Inbox");
--- a/mailnews/test/resources/messageInjection.js
+++ b/mailnews/test/resources/messageInjection.js
@@ -110,17 +110,18 @@ function configure_message_injection(aIn
     identity.email = "sender@nul.nul";
     localAccount.addIdentity(identity);
     localAccount.defaultIdentity = identity;
 
     mis.incomingServer = acctMgr.localFoldersServer;
     // Note: Inbox is not created automatically when there is no deferred server,
     // so we need to create it.
     mis.rootFolder = mis.incomingServer.rootMsgFolder;
-    mis.inboxFolder = mis.rootFolder.addSubfolder("Inbox");
+    mis.rootFolder.createSubfolder("Inbox", null);
+    mis.inboxFolder = mis.rootFolder.getChildNamed("Inbox");
     // a local inbox should have a Mail flag!
     mis.inboxFolder.setFlag(Ci.nsMsgFolderFlags.Mail);
     mis.inboxFolder.setFlag(Ci.nsMsgFolderFlags.Inbox);
     _messageInjectionSetup.notifyListeners("onRealFolderCreated",
                                            [mis.inboxFolder]);
 
     // Force an initialization of the Inbox folder database.
     let unused = mis.inboxFolder.prettiestName;