Bug 925871 - Add a helper function to click a row of a XUL tree element for the TB mozmill tests. r=mconley
☠☠ backed out by 6ec8a0de0567 ☠ ☠
authoraceman <acelists@atlas.sk>
Tue, 26 Nov 2013 13:12:10 -0500
changeset 16931 42a96b98eeeccbb60e6b7311bcd31ff01ec2c33b
parent 16930 aae6a4e00030783fdd483bb6278f37eb5778ec7a
child 16932 115b4d5ecf6b806cedf2a1f5e63d5c3c05e67547
push id1074
push userbugzilla@standard8.plus.com
push dateMon, 03 Feb 2014 22:47:23 +0000
treeherdercomm-beta@6b791b5369ed [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmconley
bugs925871
Bug 925871 - Add a helper function to click a row of a XUL tree element for the TB mozmill tests. r=mconley
mail/test/mozmill/composition/test-send-button.js
mail/test/mozmill/shared-modules/test-account-manager-helpers.js
mail/test/mozmill/shared-modules/test-folder-display-helpers.js
--- a/mail/test/mozmill/composition/test-send-button.js
+++ b/mail/test/mozmill/composition/test-send-button.js
@@ -156,17 +156,19 @@ function test_send_enabled_address_conta
   check_send_commands_state(cwc, false);
 
   // Open Contacts sidebar and use our contact.
   cwc.window.toggleAddressPicker();
 
   let sidebar = cwc.e("sidebar");
   wait_for_frame_load(sidebar,
     "chrome://messenger/content/addressbook/abContactsPanel.xul");
-  let abView = sidebar.contentDocument.getElementById("abResultsTree").treeBoxObject.view;
-  abView.selection.select(0);
+
+  let abTree = sidebar.contentDocument.getElementById("abResultsTree");
+  click_tree_row(abTree, 0, cwc);
+
   sidebar.contentDocument.getElementById("ccButton").click();
 
   // The recipient is filled in, Send must be enabled.
   check_send_commands_state(cwc, true);
 
   close_compose_window(cwc);
 }
--- a/mail/test/mozmill/shared-modules/test-account-manager-helpers.js
+++ b/mail/test/mozmill/shared-modules/test-account-manager-helpers.js
@@ -69,33 +69,17 @@ function open_advanced_settings_from_acc
  * @param rowIndex the row to click
  */
 function click_account_tree_row(controller, rowIndex) {
   utils.waitFor(function () controller.window.currentAccount != null,
                 "Timeout waiting for currentAccount to become non-null");
 
   let tree = controller.window.document.getElementById("accounttree");
 
-  if (rowIndex < 0 || rowIndex >= tree.view.rowCount)
-    throw new Error("Row " + rowIndex + " does not exist in the account tree!");
-
-  let selection = tree.view.selection;
-  selection.select(rowIndex);
-  tree.treeBoxObject.ensureRowIsVisible(rowIndex);
-
-  // get cell coordinates
-  var x = {}, y = {}, width = {}, height = {};
-  var column = tree.columns[0];
-  tree.treeBoxObject.getCoordsForCellItem(rowIndex, column, "text",
-                                           x, y, width, height);
-
-  controller.sleep(0);
-  EventUtils.synthesizeMouse(tree.body, x.value + 4, y.value + 4,
-                             {}, tree.ownerDocument.defaultView);
-  controller.sleep(0);
+  fdh.click_tree_row(tree, rowIndex, controller);
 
   utils.waitFor(function () controller.window.pendingAccount == null,
                 "Timeout waiting for pendingAccount to become null");
 
   // Ensure the page is fully loaded (e.g. onInit functions).
   wh.wait_for_frame_load(controller.e("contentFrame"),
     controller.window.pageURL(tree.contentView.getItemAtIndex(rowIndex)
                                               .getAttribute("PageTag")));
--- a/mail/test/mozmill/shared-modules/test-folder-display-helpers.js
+++ b/mail/test/mozmill/shared-modules/test-folder-display-helpers.js
@@ -896,16 +896,43 @@ function _normalize_view_index(aViewInde
 
   if (aViewIndex < 0)
     return aController.dbView.QueryInterface(Ci.nsITreeView).rowCount +
       aViewIndex;
   return aViewIndex;
 }
 
 /**
+ * Generic method to simulate a left click on a row in a <tree> element.
+ *
+ * @param aTree        The the element.
+ * @param aRowIndex    Index of a row in the tree to click on.
+ * @param aController  Controller object
+ */
+function click_tree_row(aTree, aRowIndex, aController) {
+  if (aRowIndex < 0 || aRowIndex >= aTree.view.rowCount)
+    throw new Error("Row " + aRowIndex + " does not exist in the tree " + aTree.id + "!");
+
+  let selection = aTree.view.selection;
+  selection.select(aRowIndex);
+  aTree.treeBoxObject.ensureRowIsVisible(aRowIndex);
+
+  // get cell coordinates
+  let x = {}, y = {}, width = {}, height = {};
+  let column = aTree.columns[0];
+  aTree.treeBoxObject.getCoordsForCellItem(aRowIndex, column, "text",
+                                           x, y, width, height);
+
+  aController.sleep(0);
+  EventUtils.synthesizeMouse(aTree.body, x.value + 4, y.value + 4,
+                             {}, aTree.ownerDocument.defaultView);
+  aController.sleep(0);
+}
+
+/**
  * Pretend we are clicking on a row with our mouse.
  *
  * @param aViewIndex If >= 0, the view index provided, if < 0, a reference to
  *     a view index counting from the last row in the tree.  -1 indicates the
  *     last message in the tree, -2 the second to last, etc.
  * @param aController The controller in whose context to do this, defaults to
  *     |mc| if omitted.
  *