← Back to team overview

ubuntu-touch-coreapps-reviewers team mailing list archive

[Merge] lp:~mzanetti/reminders-app/qmltest3 into lp:reminders-app

 

Michael Zanetti has proposed merging lp:~mzanetti/reminders-app/qmltest3 into lp:reminders-app with lp:~mzanetti/reminders-app/qmltest2 as a prerequisite.

Commit message:
add more tests for the NotePage

* setting/unsetting a reminder
* tagging/untagging a note


Requested reviews:
  Ubuntu Reminders app developers (reminders-app-dev)

For more details, see:
https://code.launchpad.net/~mzanetti/reminders-app/qmltest3/+merge/253753
-- 
Your team Ubuntu Reminders app developers is requested to review the proposed merge of lp:~mzanetti/reminders-app/qmltest3 into lp:reminders-app.
=== modified file 'src/app/qml/components/EditTagsDialog.qml'
--- src/app/qml/components/EditTagsDialog.qml	2015-02-27 22:43:12 +0000
+++ src/app/qml/components/EditTagsDialog.qml	2015-03-21 04:19:08 +0000
@@ -41,6 +41,7 @@
 
         TextField {
             id: textField
+            objectName: "newTagTextField"
             Layout.fillWidth: true
             placeholderText: i18n.tr("Create a new tag")
 
@@ -70,6 +71,7 @@
         }
 
         Button {
+            objectName: "createTagButton"
             text: i18n.tr("Create tag")
             color: UbuntuColors.orange
             enabled: textField.text.replace(/\s+/g, '') !== ''; // Not only whitespaces!
@@ -91,6 +93,7 @@
         model: tags
 
         delegate: OptionSelectorDelegate {
+            objectName: "tagDelegate" + index
             text: model.name
             selected: root.note ? root.note.tagGuids.indexOf(model.guid) !== -1 : false
 
@@ -112,6 +115,7 @@
 
     Button {
         id: closeButton
+        objectName: "tagsDialogCloseButton"
         Layout.preferredWidth: parent.width - units.gu(2)
         Layout.alignment: Qt.AlignHCenter
 

=== modified file 'src/app/qml/components/ListItemWithActions.qml'
--- src/app/qml/components/ListItemWithActions.qml	2015-02-13 01:02:58 +0000
+++ src/app/qml/components/ListItemWithActions.qml	2015-03-21 04:19:08 +0000
@@ -196,6 +196,7 @@
         color: UbuntuColors.red
 
         Icon {
+            objectName: "leftAction"
             anchors {
                 centerIn: parent
                 horizontalCenterOffset: actionThreshold / 2
@@ -233,6 +234,7 @@
 
                model: _showActions ? _visibleRightSideActions : []
                Item {
+                   objectName: "rightAction" + index
                    property alias image: img
 
                    height: rightActionsView.height

=== modified file 'src/app/qml/components/NotebooksDelegate.qml'
--- src/app/qml/components/NotebooksDelegate.qml	2015-03-04 00:23:45 +0000
+++ src/app/qml/components/NotebooksDelegate.qml	2015-03-21 04:19:08 +0000
@@ -133,12 +133,13 @@
                 horizontalAlignment: Text.AlignRight
             }
             Icon {
-                anchors { left: parent.left; verticalCenter: parent.verticalCenter; right: parent.right }
                 height: width
+                width: parent.width
+
                 name: "go-next"
             }
             Icon {
-                anchors { left: parent.left; bottom: parent.bottom; right: parent.right }
+                width: parent.width
                 height: width
                 name: model.loading ? "sync-updating" : model.syncError ? "sync-error" : model.synced ? "sync-idle" : "sync-offline"
                 visible: NotesStore.username !== "@local" && (!model.synced || model.syncError || model.loading)

=== modified file 'src/app/qml/components/NotesDelegate.qml'
--- src/app/qml/components/NotesDelegate.qml	2015-02-23 18:44:26 +0000
+++ src/app/qml/components/NotesDelegate.qml	2015-03-21 04:19:08 +0000
@@ -129,6 +129,7 @@
                             }
 
                             Label {
+                                objectName: "tagsLabel"
                                 Layout.fillWidth: true
                                 text: root.tags
                                 wrapMode: Text.WordWrap
@@ -143,6 +144,7 @@
                             width: units.gu(2)
 
                             Icon {
+                                objectName: "reminderIcon"
                                 anchors { left: parent.left; top: parent.top; right: parent.right }
                                 height: width
                                 name: root.reminder ? "alarm-clock" : ""

=== modified file 'src/app/qml/ui/SetReminderPage.qml'
--- src/app/qml/ui/SetReminderPage.qml	2014-09-23 12:39:27 +0000
+++ src/app/qml/ui/SetReminderPage.qml	2015-03-21 04:19:08 +0000
@@ -23,6 +23,7 @@
 
 Page {
     id: root
+    objectName: "setReminderPage"
     title: setReminderView.title
     property alias note: setReminderView.note
 

=== modified file 'src/app/qml/ui/SetReminderView.qml'
--- src/app/qml/ui/SetReminderView.qml	2014-12-08 10:25:48 +0000
+++ src/app/qml/ui/SetReminderView.qml	2015-03-21 04:19:08 +0000
@@ -25,6 +25,7 @@
 
 Item {
     id: root
+    objectName: "setReminderView"
     property string title: note.title
     property var note
 
@@ -72,6 +73,7 @@
         RowLayout {
             Layout.fillWidth: true
             Button {
+                objectName: "deleteButton"
                 // TRANSLATORS: Button that deletes a reminder
                 text: i18n.tr("Delete")
                 Layout.fillWidth: true
@@ -83,6 +85,7 @@
                 }
             }
             Button {
+                objectName: "saveButton"
                 Layout.fillWidth: true
                 // TRANSLATORS: Button that saves a reminder
                 text: i18n.tr("Save")

=== added file 'tests/qml/RemindersTestCase.qml'
--- tests/qml/RemindersTestCase.qml	1970-01-01 00:00:00 +0000
+++ tests/qml/RemindersTestCase.qml	2015-03-21 04:19:08 +0000
@@ -0,0 +1,53 @@
+import QtQuick 2.2
+import QtTest 1.0
+import Ubuntu.Components 1.1
+import Ubuntu.Test 0.1
+import Evernote 0.1
+
+import '../../src/app/qml/'
+
+
+UbuntuTestCase {
+
+    // toIndex: 1, 2, 3 for rightActions, -1 for leftAction, defaults to 1
+    function dragListItemWithAction(delegate, actionIndex) {
+        if (actionIndex == undefined) {
+            actionIndex = 1;
+        }
+        tryCompare(delegate, "_showActions", false);
+        waitForRendering(delegate);
+
+        var x = delegate.width / 2;
+        var y = delegate.height / 2;
+        var dx = units.gu(30) * -actionIndex;
+        mousePress(delegate, 1, 1);
+        mouseMoveSlowly(delegate, x, y, dx, 0, 10, 20);
+        mouseRelease(delegate, x + dx, y);
+        waitForRendering(delegate);
+        tryCompare(delegate, "swipping", false);
+
+        var action;
+        if (actionIndex == -1) {
+            action = findChildWaiting(delegate, "leftAction");
+        } else {
+            print("FAIL searching for rightaction","rightAction" + (actionIndex - 1))
+            action = findChildWaiting(delegate, "rightAction" + (actionIndex - 1));
+        }
+        print("#### found action", action)
+        mouseClick(action, 1, 1)
+        if (actionIndex >= 0) {
+            tryCompare(delegate, "_showActions", false);
+        }
+        waitForRendering(delegate)
+    }
+
+    function findChildWaiting(root, objectName, timeout) {
+        if (timeout == undefined) {
+            timeout = 2000;
+        }
+
+        tryCompareFunction(function() {return findChild(root, objectName) != null}, true, timeout);
+        return findChild(root, objectName);
+    }
+}
+

=== modified file 'tests/qml/tst_NotesPage.qml'
--- tests/qml/tst_NotesPage.qml	2015-03-21 04:19:08 +0000
+++ tests/qml/tst_NotesPage.qml	2015-03-21 04:19:08 +0000
@@ -28,8 +28,25 @@
 Item {
     id: root
 
-    width: units.gu(40)
-    height: units.gu(60)
+    width: units.gu(46)
+    height: units.gu(64)
+
+
+    Rectangle {
+        id: loading
+        anchors { left: parent.left; bottom: parent.bottom }
+        height: units.gu(1)
+        width: height
+        color: "black"
+        z: 2
+        NumberAnimation on rotation {
+            from: 0
+            to: 360
+            running: loading.visible == true
+            loops: Animation.Infinite
+            duration: 900
+        }
+    }
 
     QtObject {
         id: preferences
@@ -53,8 +70,8 @@
         property bool phone: true
     }
 
-    UbuntuTestCase {
-        id: notebooksDelegateTestCase
+    RemindersTestCase {
+        id: notesPageTestCase
         name: 'notebooksDelegateTestCase'
         when: windowShown
 
@@ -131,15 +148,8 @@
             waitForRendering(mainView);
 
             var delegate = findChild(mainView, "notesDelegate0");
+            dragListItemWithAction(delegate, -1);
 
-            var x = delegate.width / 2
-            var y = delegate.height / 2
-            var dx = delegate.width / 2
-            mousePress(delegate, 1, 1)
-            mouseMoveSlowly(delegate, x, y, dx, 0, 10, 20)
-            mouseRelease(delegate, x + dx, y)
-            waitForRendering(mainView)
-            mouseClick(delegate, units.gu(3), y)
             tryCompare(NotesStore, "count", 0);
         }
 
@@ -177,5 +187,71 @@
                 compare(delegate.title, "testNote" + data.sortOrder[i]);
             }
         }
+
+        function test_setReminder() {
+            var note = createNote("testNote1");
+
+            var noteDelegate = findChild(mainView, "notesDelegate0");
+            var reminderIcon = findChild(noteDelegate, "reminderIcon");
+
+            // Make sure no reminder set yet.
+            tryCompare(reminderIcon, "visible", false);
+
+            dragListItemWithAction(noteDelegate, 1);
+
+            var setReminderView = findChildWaiting(root, "setReminderView");
+            var saveButton = findChild(setReminderView, "saveButton");
+
+            waitForRendering(setReminderView);
+            mouseClick(saveButton, 1, 1)
+
+            tryCompare(reminderIcon, "visible", true);
+
+            waitForRendering(mainView)
+            dragListItemWithAction(noteDelegate, 1);
+
+            setReminderView = findChildWaiting(root, "setReminderView");
+            var deleteButton = findChild(setReminderView, "deleteButton");
+
+            waitForRendering(setReminderView);
+            mouseClick(deleteButton, 1, 1);
+
+            tryCompare(reminderIcon, "visible", false)
+
+        }
+
+        function test_tag() {
+            var note = createNote("testNote1");
+            var noteDelegate = findChild(mainView, "notesDelegate0");
+
+            dragListItemWithAction(noteDelegate, 2)
+
+            var newTagTextField = findChildWaiting(root, "newTagTextField");
+            mouseClick(newTagTextField, 1, 1);
+
+            typeString("testTag1");
+
+            var createTagButton = findChild(root, "createTagButton");
+            mouseClick(createTagButton, 1, 1);
+
+            var closeButton = findChild(root, "tagsDialogCloseButton");
+            mouseClick(closeButton, 1, 1);
+
+            tryCompareFunction(function() {return findChild(root, "createTagButton") == null}, true);
+
+            var tagsLabel = findChild(noteDelegate, "tagsLabel");
+            tryCompare(tagsLabel, "text", "testTag1")
+
+            dragListItemWithAction(noteDelegate, 2);
+
+
+            var testTagDelegate = findChildWaiting(root, "tagDelegate0");
+            mouseClick(testTagDelegate, 1, 1);
+
+            closeButton = findChild(root, "tagsDialogCloseButton");
+            mouseClick(closeButton, 1, 1);
+
+            tryCompare(tagsLabel, "text", "")
+        }
     }
 }


Follow ups