Bug 876503 - Some cleanup in mozmill tests + clean up after some test runs. r=mconley, r=mkmelin
authoraceman <acelists@atlas.sk>
Mon, 24 Mar 2014 09:19:37 -0400
changeset 15922 4805e92bc2cbd3f7bdce2b1d3273912c54a468f8
parent 15921 46881f948e10c5bdb2d65be69ef0250a164a5924
child 15923 d6ee8f7c2fee84088600ce6a31f7bf1fad5ac6a3
push id9983
push userryanvm@gmail.com
push dateMon, 24 Mar 2014 13:20:53 +0000
treeherdercomm-central@1ba07b762e2e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmconley, mkmelin
bugs876503
Bug 876503 - Some cleanup in mozmill tests + clean up after some test runs. r=mconley, r=mkmelin
mail/test/mozmill/composition/test-charset-upgrade.js
mail/test/mozmill/composition/test-drafts.js
mail/test/mozmill/composition/test-eml-actions.js
mail/test/mozmill/shared-modules/test-newmailaccount-helpers.js
mail/test/mozmill/shared-modules/test-notificationbox-helpers.js
mail/test/mozmill/shared-modules/test-quick-filter-bar-helper.js
mail/test/mozmill/shared-modules/test-subscribe-window-helper.js
--- a/mail/test/mozmill/composition/test-charset-upgrade.js
+++ b/mail/test/mozmill/composition/test-charset-upgrade.js
@@ -236,10 +236,13 @@ function test_encoding_upgrade_plaintext
     throw new Error("Chinese text not in msg; CHINESE=" + CHINESE +
                     ", outMsgContent=" + outMsgContent);
 
   press_delete(); // Delete the msg from Outbox.
 }
 
 function teardownModule(module) {
   Services.prefs.clearUserPref("mailnews.send_default_charset");
+  MailServices.accounts.localFoldersServer.rootFolder
+              .propagateDelete(draftsFolder, true, null);
+  MailServices.accounts.localFoldersServer.rootFolder
+              .propagateDelete(outboxFolder, true, null);
 }
-
--- a/mail/test/mozmill/composition/test-drafts.js
+++ b/mail/test/mozmill/composition/test-drafts.js
@@ -71,11 +71,15 @@ function test_open_draft_again() {
     cwins2++;
   }
 
   assert_true(cwins2 > 0, "No compose window open!");
   assert_equals(cwins, cwins2, "The number of compose windows changed!");
 
   close_compose_window(cwc); // close compose window
 
-  press_delete(mc); // clean up after our selves
+  press_delete(mc); // clean up after ourselves
 }
 
+function teardownModule() {
+  MailServices.accounts.localFoldersServer.rootFolder
+              .propagateDelete(draftsFolder, true, null);
+}
--- a/mail/test/mozmill/composition/test-eml-actions.js
+++ b/mail/test/mozmill/composition/test-eml-actions.js
@@ -14,17 +14,17 @@ const RELATIVE_ROOT = "../shared-modules
 const MODULE_REQUIRES = ["folder-display-helpers", "window-helpers", "compose-helpers"];
 
 var os = {};
 Cu.import('resource://mozmill/stdlib/os.js', os);
 Cu.import("resource:///modules/mailServices.js");
 var elib = {};
 Cu.import("resource://mozmill/modules/elementslib.js", elib);
 
-var setupModule = function(module) {
+function setupModule(module) {
   collector.getModule("folder-display-helpers").installInto(module);
   collector.getModule("window-helpers").installInto(module);
   collector.getModule("compose-helpers").installInto(module);
 }
 
 /**
  * Test that replying to an opened .eml message works, and that the reply can
  * be saved as a draft.
--- a/mail/test/mozmill/shared-modules/test-newmailaccount-helpers.js
+++ b/mail/test/mozmill/shared-modules/test-newmailaccount-helpers.js
@@ -1,13 +1,14 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 const MODULE_NAME = "newmailaccount-helpers";
+
 const RELATIVE_ROOT = "../shared-modules";
 const MODULE_REQUIRES = ["folder-display-helpers"];
 
 var elib = {};
 Cu.import('resource://mozmill/modules/elementslib.js', elib);
 Cu.import('resource://gre/modules/Services.jsm');
 Cu.import('resource:///modules/iteratorUtils.jsm');
 Cu.import('resource:///modules/mailServices.js');
--- a/mail/test/mozmill/shared-modules/test-notificationbox-helpers.js
+++ b/mail/test/mozmill/shared-modules/test-notificationbox-helpers.js
@@ -1,33 +1,19 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
-var Ci = Components.interfaces;
-var Cc = Components.classes;
-var Cu = Components.utils;
-
-var elib = {};
-Cu.import("resource://mozmill/modules/elementslib.js", elib);
-var mozmill = {};
-Cu.import("resource://mozmill/modules/mozmill.js", mozmill);
-var utils = {};
-Cu.import("resource://mozmill/modules/utils.js", utils);
-Cu.import("resource://gre/modules/Services.jsm");
-Cu.import("resource://gre/modules/XPCOMUtils.jsm");
-
 const MODULE_NAME = "notificationbox-helpers";
 
 const RELATIVE_ROOT = "../shared-modules";
+const MODULE_REQUIRES = [];
 
-// we need this for the main controller
-const MODULE_REQUIRES = ["folder-display-helpers",
-                         "window-helpers",
-                         "mock-object-helpers"];
+Cu.import("resource://gre/modules/Services.jsm");
+Cu.import("resource://gre/modules/XPCOMUtils.jsm");
 
 function installInto(module) {
   module.assert_notification_displayed = assert_notification_displayed;
   module.close_notification = close_notification;
   module.wait_for_notification_to_stop = wait_for_notification_to_stop;
   module.wait_for_notification_to_show = wait_for_notification_to_show;
 }
 
@@ -106,9 +92,8 @@ function wait_for_notification_to_stop(a
 function wait_for_notification_to_show(aController, aBoxId, aValue) {
   let nb = aController.window.document.getElementById(aBoxId);
   if (!nb)
     throw new Error("Couldn't find a notification box for id=" + aBoxId);
   aController.waitFor(function() nb.getNotificationWithValue(aValue) != null,
                       "Timed out waiting for notification with value " +
                       aValue + " to show.");
 }
-
--- a/mail/test/mozmill/shared-modules/test-quick-filter-bar-helper.js
+++ b/mail/test/mozmill/shared-modules/test-quick-filter-bar-helper.js
@@ -2,28 +2,24 @@
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 const MODULE_NAME = "quick-filter-bar-helper";
 
 const RELATIVE_ROOT = "../shared-modules";
 const MODULE_REQUIRES = ["folder-display-helpers"];
 
-var initialized = false;
-function setupModule(module) {
-  if (initialized)
-    return;
+var fdh, mc;
 
-  let fdh = collector.getModule('folder-display-helpers');
-  fdh.installInto(module);
-
-  initialized = true;
+function setupModule() {
+  fdh = collector.getModule('folder-display-helpers');
+  mc = fdh.mc;
 }
 
-var EXPORT = [
+const EXPORT = [
   'assert_quick_filter_button_enabled',
   'assert_quick_filter_bar_visible',
   'toggle_quick_filter_bar',
   'assert_constraints_expressed',
   'toggle_boolean_constraints',
   'toggle_tag_constraints',
   'toggle_tag_mode',
   'assert_tag_constraints_visible',
@@ -34,18 +30,18 @@ var EXPORT = [
   'assert_filter_text',
   'assert_results_label_count',
   'clear_constraints',
 ];
 
 var backstage = this;
 
 function installInto(module) {
-  setupModule(backstage);
-  for each (let [, name] in Iterator(EXPORT)) {
+  setupModule();
+  for (let name of EXPORT) {
     module[name] = backstage[name];
   }
   // disable the deferred search processing!
   mc.window.QuickFilterBarMuxer.deferredUpdateSearch =
     mc.window.QuickFilterBarMuxer.updateSearch;
 
   module.__teardownTest__ = _afterEveryTest;
   _afterEveryTest.__name__ = "teardownTest";
@@ -85,17 +81,17 @@ function assert_quick_filter_bar_visible
   }
 }
 
 /**
  * Toggle the state of the message filter bar as if by a mouse click.
  */
 function toggle_quick_filter_bar() {
   mc.click(mc.eid("qfb-show-filter-bar"));
-  wait_for_all_messages_to_load();
+  fdh.wait_for_all_messages_to_load();
 }
 
 /**
  * Assert that the state of the constraints visually expressed by the bar is
  * consistent with the passed-in constraints.  This method does not verify
  * that the search constraints are in effect.  Check that elsewhere.
  */
 function assert_constraints_expressed(aConstraints) {
@@ -111,46 +107,46 @@ function assert_constraints_expressed(aC
 /**
  * Toggle the given filter buttons by name (from nameToBarDomId); variable
  * argument magic enabled.
  */
 function toggle_boolean_constraints() {
   for (let iArg = 0; iArg < arguments.length; iArg++) {
     mc.click(mc.eid(nameToBarDomId[arguments[iArg]]));
   }
-  wait_for_all_messages_to_load(mc);
+  fdh.wait_for_all_messages_to_load(mc);
 }
 
 /**
  * Toggle the tag faceting buttons by tag key.  Wait for messages after.
  */
 function toggle_tag_constraints() {
   for (let iArg = 0; iArg < arguments.length; iArg++) {
     mc.click(mc.eid("qfb-tag-" + arguments[iArg]));
   }
-  wait_for_all_messages_to_load(mc);
+  fdh.wait_for_all_messages_to_load(mc);
 }
 
 /**
  * Set the tag filtering mode. Wait for messages after.
  */
 function toggle_tag_mode() {
   let qbm = mc.e("qfb-boolean-mode");
   if (qbm.value === "AND") {
     qbm.selectedIndex--; // = move to "OR";
-    assert_equals(qbm.value, "OR", "qfb-boolean-mode has wrong state");
+    fdh.assert_equals(qbm.value, "OR", "qfb-boolean-mode has wrong state");
   }
   else if (qbm.value === "OR") {
     qbm.selectedIndex++; // = move to "AND";
-    assert_equals(qbm.value, "AND", "qfb-boolean-mode has wrong state");
+    fdh.assert_equals(qbm.value, "AND", "qfb-boolean-mode has wrong state");
   }
   else {
     throw new Error("qfb-boolean-mode value=" + qbm.value);
   }
-  wait_for_all_messages_to_load(mc);
+  fdh.wait_for_all_messages_to_load(mc);
 }
 
 /**
  * Verify that tag buttons exist for exactly the given set of tag keys in the
  *  provided variable argument list.  Ordering is significant.
  */
 function assert_tag_constraints_visible() {
   // the stupid bar should be visible if any arguments are specified
@@ -198,17 +194,17 @@ const nameToTextDomId = {
   subject: "qfb-qs-subject",
   body: "qfb-qs-body",
 };
 
 function toggle_text_constraints() {
   for (let iArg = 0; iArg < arguments.length; iArg++) {
     mc.click(mc.eid(nameToTextDomId[arguments[iArg]]));
   }
-  wait_for_all_messages_to_load(mc);
+  fdh.wait_for_all_messages_to_load(mc);
 }
 
 /**
  * Assert that the text constraint buttons are checked.  Variable-argument
  *  support where the arguments are one of sender/recipients/subject/body.
  */
 function assert_text_constraints_checked() {
   let expected = {};
@@ -233,17 +229,17 @@ function assert_text_constraints_checked
  *  wait for all messages to load.
  */
 function set_filter_text(aText) {
   // We're not testing the reliability of the textbox widget; just poke our text
   // in and trigger the command logic.
   let textbox = mc.e("qfb-qs-textbox");
   textbox.value = aText;
   textbox.doCommand();
-  wait_for_all_messages_to_load(mc);
+  fdh.wait_for_all_messages_to_load(mc);
 }
 
 function assert_filter_text(aText) {
   let textbox = mc.e("qfb-qs-textbox");
   if (textbox.value != aText)
     throw new Error("Expected text filter value of '" + aText + "' but got '" +
                     textbox.value);
 }
--- a/mail/test/mozmill/shared-modules/test-subscribe-window-helper.js
+++ b/mail/test/mozmill/shared-modules/test-subscribe-window-helper.js
@@ -72,18 +72,17 @@ function check_searchview(swc) {
  * @param swc A controller for the subscribe window
  * @param name Name of the newsgroup
  * @returns {Boolean} Result of the check
  */
 function check_newsgroup_displayed(swc, name) {
   let tree = swc.eid("searchTree").getNode();
   let treeview = tree.view;
   let nameCol = tree.columns.getColumnFor(swc.eid("nameColumn2").getNode());
-  let i = 0;
-  for ( ; i < treeview.rowCount; ++i ) {
+  for (let i = 0; i < treeview.rowCount; i++) {
     if (treeview.getCellText(i,nameCol)==name)
       return true;
   }
   return false;
 }
 
 /**
  * Close a search window by calling window.close() on the controller.