Bug 1491269 - Fix failing testTaskView.js; r=Fallen
authorGeoff Lankow <geoff@darktrojan.net>
Wed, 16 Jan 2019 22:46:12 +1300
changeset 33363 1c626f1c70ef
parent 33362 3ca205e21c25
child 33364 8e0c009b6d37
push id2368
push userclokep@gmail.com
push dateMon, 28 Jan 2019 21:12:50 +0000
treeherdercomm-beta@56d23c07d815 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersFallen
bugs1491269
Bug 1491269 - Fix failing testTaskView.js; r=Fallen
calendar/base/content/calendar-task-tree.xml
calendar/test/mozmill/views/testTaskView.js
--- a/calendar/base/content/calendar-task-tree.xml
+++ b/calendar/base/content/calendar-task-tree.xml
@@ -207,29 +207,29 @@
               this.removeAttribute("sort-active");
               this.removeAttribute("sort-direction");
           }
       ]]></destructor>
 
       <field name="mTaskArray">[]</field>
       <field name="mHash2Index"><![CDATA[({})]]></field>
       <field name="mPendingRefreshJobs"><![CDATA[({})]]></field>
-        <field name="mShowCompletedTasks">true</field>
-        <field name="mFilter">null</field>
-        <field name="mStartDate">null</field>
-        <field name="mEndDate">null</field>
-        <field name="mDateRangeFilter">null</field>
-        <field name="mTextFilterField">null</field>
+      <field name="mShowCompletedTasks">true</field>
+      <field name="mFilter">null</field>
+      <field name="mStartDate">null</field>
+      <field name="mEndDate">null</field>
+      <field name="mDateRangeFilter">null</field>
+      <field name="mTextFilterField">null</field>
 
-        <property name="currentIndex">
-          <getter><![CDATA[
-            let tree = document.getAnonymousElementByAttribute(
-                this, "anonid", "calendar-task-tree");
-            return tree.currentIndex;
-        ]]></getter>
+      <property name="currentIndex">
+        <getter><![CDATA[
+          let tree = document.getAnonymousElementByAttribute(
+              this, "anonid", "calendar-task-tree");
+          return tree.currentIndex;
+      ]]></getter>
       </property>
 
       <property name="currentTask">
         <getter><![CDATA[
             let tree = document.getAnonymousElementByAttribute(
                 this, "anonid", "calendar-task-tree");
             let index = tree.currentIndex;
             if (tree.view && tree.view.selection) {
@@ -314,16 +314,17 @@
                         return cal.l10n.getCalString("dueInLessThanOneHour");
                     }
                 }
             }
             // No due date specified
             return null;
         ]]></body>
       </method>
+
       <method name="getTaskAtRow">
         <parameter name="aRow"/>
         <body><![CDATA[
             return (aRow > -1 ? this.mTaskArray[aRow] : null);
         ]]></body>
       </method>
 
       <method name="getTaskFromEvent">
@@ -768,23 +769,24 @@
                 }
             },
 
             /**
              * Private methods and attributes
              */
 
             _getItemFromEvent: function(event, aCol, aRow) {
-                aRow = aRow || {};
-                let childElt = {};
-                this.treebox.getCellAt(event.clientX, event.clientY, aRow, aCol || {}, childElt);
-                if (!childElt.value) {
-                    return false;
+                let { col, row } = this.treebox.getCellAt(event.clientX, event.clientY);
+                if (aCol) {
+                    aCol.value = col;
                 }
-                return aRow && aRow.value > -1 && this.binding.mTaskArray[aRow.value];
+                if (aRow) {
+                    aRow.value = row;
+                }
+                return row > -1 && this.binding.mTaskArray[row];
             },
 
             // Helper function to display datetimes
             _formatDateTime: function(aDateTime) {
                 let dateFormatter = Cc["@mozilla.org/calendar/datetime-formatter;1"]
                                       .getService(Ci.calIDateTimeFormatter);
 
                 // datetime is from todo object, it is not a javascript date
--- a/calendar/test/mozmill/views/testTaskView.js
+++ b/calendar/test/mozmill/views/testTaskView.js
@@ -32,17 +32,16 @@ function setupModule(module) {
     ({ setData } = collector.getModule("item-editing-helpers"));
     collector.getModule("item-editing-helpers").setupModule(module);
 
     createCalendar(controller, CALENDARNAME);
 }
 
 // Mozmill doesn't support trees yet, therefore completed checkbox and line-through style are not
 // checked.
-testTaskView.__force_skip__ = true;
 function testTaskView() {
     // paths
     let treeChildren = `
         ${TASK_VIEW}/[1]/id("calendar-task-tree")/anon({"anonid":"calendar-task-tree"})/
         {"tooltip":"taskTreeTooltip"}
     `;
     let taskTree = TASK_VIEW + '[1]/id("calendar-task-tree")';
     let toolTip = '/id("messengerWindow")/id("calendar-popupset")/id("taskTreeTooltip")';
@@ -60,32 +59,28 @@ function testTaskView() {
 
     for (let i = 0; i < calendarTree.mCalendarList.length; i++) {
         if (calendarTree.mCalendarList[i].name == CALENDARNAME) {
             calendarTree.tree.view.selection.select(i);
         }
     }
 
     let taskTreeNode = lookup(taskTree).getNode();
-    let countBefore = taskTreeNode.mTaskArray.length;
+    controller.assert(() => taskTreeNode.mTaskArray.length == 0);
 
     // Add task.
     let taskInput= lookup(`
         ${TASK_VIEW}/id("task-addition-box")/[0]/id("view-task-edit-field")/
         anon({"anonid":"moz-input-box"})/anon({"anonid":"input"})
     `);
     controller.type(taskInput, TITLE);
     controller.keypress(taskInput, "VK_RETURN", {});
 
     // Verify added.
-    let countAfter;
-    controller.waitFor(() => {
-        countAfter = taskTreeNode.mTaskArray.length;
-        return countAfter == (countBefore + 1);
-    }, "Added Task did not appear; countBefore=" + countBefore + ", countAfter=" + countAfter);
+    controller.waitFor(() => taskTreeNode.mTaskArray.length == 1, "Added Task did not appear");
 
     // Last added task is automatically selected so verify detail window data.
     controller.assertJSProperty(eid("calendar-task-details-title"), "textContent", TITLE);
 
     // Open added task
     // Doubleclick on completion checkbox is ignored as opening action, so don't
     // click at immediate left where the checkbox is located.
     controller.doubleClick(lookup(treeChildren), 50, 0);
@@ -101,16 +96,19 @@ function testTaskView() {
             percent: PERCENTCOMPLETE,
             description: DESCRIPTION
         });
 
         // save
         task.click(taskid("button-saveandclose"));
     });
 
+    controller.assert(() => taskTreeNode.mTaskArray.length < 2, "Task added but should not have been");
+    controller.assert(() => taskTreeNode.mTaskArray.length > 0, "Task removed but should not have been");
+
     // Verify description and status in details pane.
     controller.assertValue(lookup(`
         ${TASK_VIEW}/{"flex":"1"}/id("calendar-task-details-container")/
         id("calendar-task-details-description")/anon({"anonid":"moz-input-box"})/
         anon({"anonid":"input"})
     `), DESCRIPTION);
     controller.assertValue(eid("calendar-task-details-status"), "Needs Action");
 
@@ -153,18 +151,15 @@ function testTaskView() {
     sleep();
 
     toolTipNode.ownerGlobal.showToolTip(toolTipNode, taskTreeNode.getTaskAtRow(0));
     controller.assertJSProperty(toolTipStatus, "textContent", "Completed");
 
     // Delete task and verify.
     countBefore = taskTreeNode.mTaskArray.length;
     controller.click(eid("calendar-delete-task-button"));
-    controller.waitFor(() => {
-        countAfter = taskTreeNode.mTaskArray.length;
-        return countAfter == (countBefore - 1);
-    }, "Task did not delete; countBefore=" + countBefore + ", countAfter=" + countAfter);
+    controller.waitFor(() => taskTreeNode.mTaskArray.length == 0, "Task did not delete");
 }
 
 function teardownTest(module) {
     deleteCalendars(controller, CALENDARNAME);
     closeAllEventDialogs();
 }