← Back to team overview

ubuntu-touch-coreapps-reviewers team mailing list archive

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

 

Michael Zanetti has proposed merging lp:~mzanetti/reminders-app/qmltest2 into lp:reminders-app.

Commit message:
Add some qmltests

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

For more details, see:
https://code.launchpad.net/~mzanetti/reminders-app/qmltest2/+merge/253598
-- 
Your team Ubuntu Reminders app developers is requested to review the proposed merge of lp:~mzanetti/reminders-app/qmltest2 into lp:reminders-app.
=== modified file 'CMakeLists.txt'
--- CMakeLists.txt	2015-02-16 22:01:20 +0000
+++ CMakeLists.txt	2015-03-19 23:03:10 +0000
@@ -12,6 +12,9 @@
 
 option(INSTALL_TESTS "Install the tests on make install" on)
 option(CLICK_MODE "Installs to a contained location" on)
+option(USE_XVFB "Use XVFB to run qml tests" on)
+
+enable_testing()
 
 set(APP_NAME reminders)
 set(DESKTOP_FILE "${PROJECT_NAME}.desktop")
@@ -110,9 +113,6 @@
 
 configure_file(${APPLICATION_FILE}.in ${CMAKE_CURRENT_BINARY_DIR}/${APPLICATION_FILE})
 install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${APPLICATION_FILE} DESTINATION ${APPLICATION_DIR})
- 
-# Tests
-enable_testing()
 
 add_subdirectory(po)
 add_subdirectory(tests)

=== modified file 'debian/control'
--- debian/control	2014-12-16 22:35:59 +0000
+++ debian/control	2015-03-19 23:03:10 +0000
@@ -10,9 +10,14 @@
                libssl-dev,
                pkg-config,
                python3-all,
+               qml-module-qttest,
                qt5-default,
                qtdeclarative5-dev,
-               qtpim5-dev
+               qtdeclarative5-dev-tools,
+               qtdeclarative5-quicklayouts-plugin,
+               qtdeclarative5-ubuntu-ui-toolkit-plugin,
+               xvfb,
+               qtpim5-dev,
 Standards-Version: 3.9.5
 Section: misc
 Homepage: https://launchpad.net/reminders-app

=== modified file 'src/app/CMakeLists.txt'
--- src/app/CMakeLists.txt	2014-11-10 00:54:16 +0000
+++ src/app/CMakeLists.txt	2015-03-19 23:03:10 +0000
@@ -2,7 +2,6 @@
 
 set(reminders_SRCS
     main.cpp
-    formattinghelper.cpp
     preferences.cpp
     ${QML_SRCS}
 )

=== modified file 'src/app/main.cpp'
--- src/app/main.cpp	2015-03-08 18:52:46 +0000
+++ src/app/main.cpp	2015-03-19 23:03:10 +0000
@@ -21,7 +21,6 @@
  */
 
 #include "preferences.h"
-#include "formattinghelper.h"
 
 #include <QtGui/QGuiApplication>
 #include <QtQuick/QQuickView>
@@ -156,11 +155,8 @@
     Preferences preferences;
     view.engine()->rootContext()->setContextProperty("preferences", &preferences);
 
-    // Register FormattingHelper
-    qmlRegisterType<FormattingHelper>("reminders", 1, 0, "FormattingHelper");
-
     QString qmlfile;
-    const QString filePath = QLatin1String("qml/reminders.qml");
+    const QString filePath = QLatin1String("qml/Reminders.qml");
     QStringList paths = QStandardPaths::standardLocations(QStandardPaths::DataLocation);
     paths.prepend(QDir::currentPath());
     paths.prepend(QCoreApplication::applicationDirPath());

=== renamed file 'src/app/qml/reminders.qml' => 'src/app/qml/Reminders.qml'
--- src/app/qml/reminders.qml	2015-03-08 18:47:51 +0000
+++ src/app/qml/Reminders.qml	2015-03-19 23:03:10 +0000
@@ -135,7 +135,11 @@
             }
             var component = Qt.createComponent(Qt.resolvedUrl("ui/EditNotePage.qml"));
             var page = component.createObject();
-            page.exitEditMode.connect(function() {Qt.inputMethod.hide(); pagestack.pop()});
+            page.exitEditMode.connect(function() {
+                    Qt.inputMethod.hide();
+                    pagestack.pop();
+                    page.destroy();
+                });
             pagestack.push(page, {note: note});
         } else {
             sideViewLoader.clear();
@@ -410,7 +414,7 @@
             if (root.narrowMode) {
                 var component = Qt.createComponent(Qt.resolvedUrl("ui/EditNotePage.qml"));
                 var page = component.createObject();
-                page.exitEditMode.connect(function() {Qt.inputMethod.hide(); pagestack.pop();});
+                page.exitEditMode.connect(function() {Qt.inputMethod.hide(); pagestack.pop(); page.destroy()});
                 pagestack.push(page, {note: note});
             } else {
                 notesPage.selectedNote = note;

=== modified file 'src/app/qml/components/SortingDialog.qml'
--- src/app/qml/components/SortingDialog.qml	2015-03-17 23:32:45 +0000
+++ src/app/qml/components/SortingDialog.qml	2015-03-19 23:03:10 +0000
@@ -2,7 +2,6 @@
 import Ubuntu.Components 1.0
 import Ubuntu.Components.Popups 1.0
 import Ubuntu.Components.ListItems 1.0
-import reminders 1.0
 
 Item {
     id: root
@@ -33,9 +32,24 @@
                     i18n.tr("Title (ascending)"),
                     i18n.tr("Title (descending)")
                 ]
+<<<<<<< TREE
+=======
+                delegate: OptionSelectorDelegate {
+                    objectName: "sortingOption" + index
+                }
+            }
+>>>>>>> MERGE-SOURCE
 
+<<<<<<< TREE
                 onDelegateClicked: {
                     root.sortOrder = index
+=======
+            Button {
+                text: i18n.tr("Close")
+                objectName: "sortingCloseButton"
+                onClicked: {
+                    root.sortOrder = optionSelector.selectedIndex
+>>>>>>> MERGE-SOURCE
                     root.accepted();
                     PopupUtils.close(dialog);
                 }

=== modified file 'src/app/qml/ui/EditNoteView.qml'
--- src/app/qml/ui/EditNoteView.qml	2015-03-05 18:23:25 +0000
+++ src/app/qml/ui/EditNoteView.qml	2015-03-19 23:03:10 +0000
@@ -24,7 +24,6 @@
 import Ubuntu.Content 0.1
 import Ubuntu.Components.Themes.Ambiance 1.1
 import Evernote 0.1
-import reminders 1.0
 import "../components"
 
 Item {
@@ -111,6 +110,7 @@
 
             TextField {
                 id: titleTextField
+                objectName: root.isBottomEdge ? "bottomEdgeTitleTextField" : "titleTextField"
                 text: root.note ? root.note.title : ""
                 placeholderText: i18n.tr("Untitled")
                 height: units.gu(4)
@@ -118,6 +118,7 @@
                 anchors.verticalCenter: parent.verticalCenter
             }
             AbstractButton {
+                objectName: isBottomEdge ? "bottomEdgeSaveButton" : "saveButton"
                 height: units.gu(3)
                 width: height
                 anchors.verticalCenter: parent.verticalCenter
@@ -127,6 +128,7 @@
                 }
                 onClicked: {
                     saveNote();
+                    print("closing editview")
                     root.exitEditMode(root.note);
                 }
             }
@@ -176,6 +178,7 @@
 
                      TextEdit {
                          id: noteTextArea
+                         objectName: isBottomEdge ? "bottomEdgeNoteTextArea" : "noteTextArea"
                          width: flick.width
                          height: Math.max(flick.height - notebookSelector.height, paintedHeight)
                          focus: true

=== modified file 'src/app/qml/ui/NotesPage.qml'
--- src/app/qml/ui/NotesPage.qml	2015-03-08 18:47:51 +0000
+++ src/app/qml/ui/NotesPage.qml	2015-03-19 23:03:10 +0000
@@ -27,6 +27,7 @@
 
 PageWithBottomEdge {
     id: root
+    objectName: "notesPage"
 
     property var selectedNote: null
     property bool narrowMode
@@ -156,6 +157,7 @@
         }
 
         delegate: NotesDelegate {
+            objectName: "notesDelegate" + index
             title: model.title
             date: notes.sortOrder == Notes.SortOrderUpdatedOldest || notes.sortOrder == Notes.SortOrderUpdatedNewest ?
                       model.updated : model.created

=== modified file 'src/libqtevernote/notes.cpp'
--- src/libqtevernote/notes.cpp	2015-03-08 18:51:50 +0000
+++ src/libqtevernote/notes.cpp	2015-03-19 23:03:10 +0000
@@ -229,12 +229,24 @@
 
 bool Notes::lessThan(const QModelIndex &left, const QModelIndex &right) const
 {
-    QVariant leftValue = sourceModel()->data(left, sortRole()).toString();
-    QVariant rightValue = sourceModel()->data(right, sortRole()).toString();
+    QVariant leftValue = sourceModel()->data(left, sortRole());
+    QVariant rightValue = sourceModel()->data(right, sortRole());
 
-    if (leftValue == rightValue) {
-        return sourceModel()->data(left, NotesStore::RoleTitle).toString() < sourceModel()->data(right, NotesStore::RoleTitle).toString();
+    switch (m_sortOrder) {
+    case SortOrderDateCreatedNewest:
+    case SortOrderDateCreatedOldest:
+    case SortOrderDateUpdatedNewest:
+    case SortOrderDateUpdatedOldest:
+        if (leftValue.toDateTime().toMSecsSinceEpoch() < rightValue.toDateTime().toMSecsSinceEpoch()) {
+            return true;
+        } else if (leftValue.toDateTime().toMSecsSinceEpoch() > rightValue.toDateTime().toMSecsSinceEpoch()) {
+            return false;
+        }
+        break;
+    case SortOrderTitleAscending:
+    case SortOrderTitleDescending:
+        // fall trough
+        break;
     }
-
-    return leftValue < rightValue;
+    return leftValue.toString() < rightValue.toString();
 }

=== modified file 'src/libqtevernote/notesstore.cpp'
--- src/libqtevernote/notesstore.cpp	2015-03-09 09:57:36 +0000
+++ src/libqtevernote/notesstore.cpp	2015-03-19 23:03:10 +0000
@@ -256,6 +256,11 @@
     return m_notes;
 }
 
+Note *NotesStore::note(int index) const
+{
+    return m_notes.at(index);
+}
+
 Note *NotesStore::note(const QString &guid)
 {
     return m_notesHash.value(guid);
@@ -266,6 +271,11 @@
     return m_notebooks;
 }
 
+Notebook *NotesStore::notebook(int index) const
+{
+    return m_notebooks.at(index);
+}
+
 Notebook *NotesStore::notebook(const QString &guid)
 {
     return m_notebooksHash.value(guid);

=== modified file 'src/libqtevernote/notesstore.h'
--- src/libqtevernote/notesstore.h	2015-03-04 00:23:45 +0000
+++ src/libqtevernote/notesstore.h	2015-03-19 23:03:10 +0000
@@ -113,6 +113,7 @@
     QHash<int, QByteArray> roleNames() const;
 
     QList<Note*> notes() const;
+    Q_INVOKABLE Note* note(int index) const;
 
     Q_INVOKABLE Note* note(const QString &guid);
     Q_INVOKABLE Note* createNote(const QString &title, const QString &notebookGuid = QString(), const QString &richTextContent = QString());
@@ -123,6 +124,7 @@
     Q_INVOKABLE void clearSearchResults();
 
     QList<Notebook*> notebooks() const;
+    Q_INVOKABLE Notebook* notebook(int index) const;
     Q_INVOKABLE Notebook* notebook(const QString &guid);
     Q_INVOKABLE void createNotebook(const QString &name);
     Q_INVOKABLE void saveNotebook(const QString &guid);

=== modified file 'src/plugin/CMakeLists.txt'
--- src/plugin/CMakeLists.txt	2014-10-23 21:27:46 +0000
+++ src/plugin/CMakeLists.txt	2015-03-19 23:03:10 +0000
@@ -1,1 +1,3 @@
+project(plugin)
+
 add_subdirectory(Evernote)

=== modified file 'src/plugin/Evernote/CMakeLists.txt'
--- src/plugin/Evernote/CMakeLists.txt	2014-10-23 21:27:46 +0000
+++ src/plugin/Evernote/CMakeLists.txt	2015-03-19 23:03:10 +0000
@@ -9,6 +9,7 @@
 
 set(evernoteplugin_SRCS
     evernoteplugin.cpp
+    formattinghelper.cpp
 )
 
 add_library(evernoteplugin MODULE
@@ -30,4 +31,3 @@
 # Install plugin file
 install(TARGETS evernoteplugin DESTINATION ${QT_IMPORTS_DIR}/Evernote/)
 install(FILES qmldir DESTINATION ${QT_IMPORTS_DIR}/Evernote/)
-

=== modified file 'src/plugin/Evernote/evernoteplugin.cpp'
--- src/plugin/Evernote/evernoteplugin.cpp	2015-03-06 00:42:42 +0000
+++ src/plugin/Evernote/evernoteplugin.cpp	2015-03-19 23:03:10 +0000
@@ -19,6 +19,7 @@
  */
 
 #include "evernoteplugin.h"
+#include "formattinghelper.h"
 
 #include "evernoteconnection.h"
 #include "userstore.h"
@@ -62,6 +63,10 @@
     qmlRegisterUncreatableType<Notebook>(uri, 0, 1, "Notebook", "Cannot create Notes in QML. Use NotesStore.createNotebook() instead.");
     qmlRegisterUncreatableType<Tag>(uri, 0, 1, "Tag", "Cannot create Tags in QML. Use NotesStore.createTag() instead.");
     qmlRegisterUncreatableType<Resource>(uri, 0, 1, "Resource", "Cannot create Resources. Use Note.attachFile() instead.");
+
+    // Register FormattingHelper
+    qmlRegisterType<FormattingHelper>(uri, 0, 1, "FormattingHelper");
+
 }
 
 void EvernotePlugin::initializeEngine(QQmlEngine *engine, const char *uri)

=== renamed file 'src/app/formattinghelper.cpp' => 'src/plugin/Evernote/formattinghelper.cpp'
=== renamed file 'src/app/formattinghelper.h' => 'src/plugin/Evernote/formattinghelper.h'
=== modified file 'tests/CMakeLists.txt'
--- tests/CMakeLists.txt	2014-01-19 13:59:12 +0000
+++ tests/CMakeLists.txt	2015-03-19 23:03:10 +0000
@@ -1,1 +1,3 @@
+add_subdirectory(qml)
+
 add_subdirectory(autopilot)

=== added directory 'tests/qml'
=== added file 'tests/qml/CMakeLists.txt'
--- tests/qml/CMakeLists.txt	1970-01-01 00:00:00 +0000
+++ tests/qml/CMakeLists.txt	2015-03-19 23:03:10 +0000
@@ -0,0 +1,48 @@
+find_program(QMLTESTRUNNER_BIN
+    NAMES qmltestrunner
+    PATHS /usr/lib/*/qt5/bin
+    NO_DEFAULT_PATH
+)
+
+find_program(XVFB_RUN_BIN
+    NAMES xvfb-run
+)
+
+set(QML_TST_FILES "")
+
+macro(DECLARE_QML_TEST TST_NAME TST_QML_FILE)
+    set(qmltest_command
+        ${QMLTESTRUNNER_BIN} -import ${CMAKE_BINARY_DIR}/src/plugin -input ${CMAKE_CURRENT_SOURCE_DIR}/${TST_QML_FILE}
+    )
+
+    if(USE_XVFB)
+        set(COMMAND_PREFIX ${XVFB_RUN_BIN} -a -s "-screen 0 1024x768x24")
+        add_custom_target(xvfbTest${TST_NAME} ${COMMAND_PREFIX} ${qmltest_command})
+    else()
+        set(COMMAND_PREFIX "")
+    endif()
+    add_custom_target(test${TST_NAME} ${qmltest_command})
+
+    add_test(NAME ${TST_NAME}
+        WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
+        COMMAND ${COMMAND_PREFIX} ${qmltest_command}
+    )
+
+    set(QML_TST_FILES ${QML_TST_FILES} ${TST_QML_FILE})
+endmacro()
+
+if(QMLTESTRUNNER_BIN AND XVFB_RUN_BIN)
+
+    # Add new tests here
+    declare_qml_test("NotebooksDelegate" tst_NotebooksDelegate.qml)
+    declare_qml_test("NotesPage" tst_NotesPage.qml)
+
+else()
+    if (NOT QMLTESTRUNNER_BIN)
+        message(WARNING "Qml tests disabled: qmltestrunner not found")
+    else()
+        message(WARNING "Qml tests disabled: xvfb-run not found")
+    endif()
+endif()
+
+add_custom_target(tst_QmlFiles ALL SOURCES ${QML_TST_FILES})

=== added file 'tests/qml/tst_NotebooksDelegate.qml'
--- tests/qml/tst_NotebooksDelegate.qml	1970-01-01 00:00:00 +0000
+++ tests/qml/tst_NotebooksDelegate.qml	2015-03-19 23:03:10 +0000
@@ -0,0 +1,95 @@
+/*
+ * Copyright: 2014 Canonical, Ltd
+ *
+ * This file is part of reminders
+ *
+ * reminders is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 3.
+ *
+ * reminders is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+import QtQuick 2.2
+import QtTest 1.0
+import Ubuntu.Components 1.1
+import Ubuntu.Test 0.1
+
+import '../../src/app/qml/components'
+
+Item {
+    id: root
+
+    width: units.gu(40)
+    height: units.gu(60)
+
+    ListModel {
+        id: notebooks
+
+       ListElement {
+            objectName: 'privateNote'
+            guid: 'dummy'
+            name: 'dummy'
+            lastUpdatedString: 'dummy'
+            published: false
+            noteCount: 'dummy'
+        }
+
+        ListElement {
+            objectName: 'sharedNote'
+            guid: 'dummy'
+            name: 'dummy'
+            lastUpdatedString: 'dummy'
+            published: true
+            noteCount: 'dummy'
+        }
+    }
+
+    ListView {
+        id: notebooksListView
+        anchors.fill: parent
+
+        model: notebooks
+
+        delegate: NotebooksDelegate {
+            objectName: model.objectName
+        }
+    }
+
+    UbuntuTestCase {
+        id: notebooksDelegateTestCase
+        name: 'notebooksDelegateTestCase'
+
+        when: windowShown
+
+        function init() {
+        }
+
+        function test_unpublishedNotebookMustDisplayPrivateLabel() {
+            var privateNote = findChild(notebooksListView, 'privateNote')
+            var publishedLabel = findChild(
+                privateNote, 'notebookPublishedLabel')
+
+            compare(publishedLabel.text, 'Private')
+            compare(publishedLabel.color, '#b3b3b3')
+            compare(publishedLabel.font.bold, false)
+        }
+
+        function test_publishedNotebookMustDisplaySharedLabel() {
+            var privateNote = findChild(notebooksListView, 'sharedNote')
+            var publishedLabel = findChild(
+                privateNote, 'notebookPublishedLabel')
+
+            compare(publishedLabel.text, 'Shared')
+            compare(publishedLabel.color, '#000000')
+            compare(publishedLabel.font.bold, true)
+        }
+    }
+
+}

=== added file 'tests/qml/tst_NotesPage.qml'
--- tests/qml/tst_NotesPage.qml	1970-01-01 00:00:00 +0000
+++ tests/qml/tst_NotesPage.qml	2015-03-19 23:03:10 +0000
@@ -0,0 +1,183 @@
+/*
+ * Copyright: 2014 Canonical, Ltd
+ *
+ * This file is part of reminders
+ *
+ * reminders is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 3.
+ *
+ * reminders is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+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/components'
+import '../../src/app/qml/'
+
+Item {
+    id: root
+
+    width: units.gu(40)
+    height: units.gu(60)
+
+    QtObject {
+        id: preferences
+
+        property string accountName: "@local"
+        property int sortOrder: 0
+
+        function colorForNotebook(notebookguid) {
+            return "black";
+        }
+    }
+
+    Reminders {
+        id: mainView
+        anchors.fill: parent
+
+        applicationName: "com.ubuntu.reminders_test"
+
+        property bool useSandbox: false
+        property bool tablet: false
+        property bool phone: true
+    }
+
+    UbuntuTestCase {
+        id: notebooksDelegateTestCase
+        name: 'notebooksDelegateTestCase'
+        when: windowShown
+
+        function init() {
+            tryCompare(NotesStore, "username", "@local")
+            while (NotesStore.count > 0) {
+                NotesStore.deleteNote(NotesStore.note(0).guid)
+            }
+        }
+
+        function cleanupTestCase() {
+            while (NotesStore.count > 0) {
+                NotesStore.deleteNote(NotesStore.note(0).guid)
+            }
+            //wait(500)
+            waitForRendering(mainView)
+        }
+
+        function initTestCase() {
+            wait(500)
+            //waitForRendering(mainView)
+        }
+
+        function createNote(title) {
+            var note = NotesStore.createNote(title);
+            waitForRendering(mainView);
+            var saveButton = findChild(mainView, "saveButton");
+            mouseClick(saveButton, 1, 1);
+            waitForRendering(mainView);
+            return note;
+        }
+
+        function test_createNoteFromBottomEdge() {
+
+            var x = mainView.width / 2;
+            var startY = mainView.height - 1;
+            var dY = -mainView.height * 3 / 4;
+            mousePress(mainView, x, startY)
+            mouseMoveSlowly(mainView, x, startY, 0, dY, 10, 10)
+            mouseRelease(mainView, x, startY + dY)
+
+            tryCompare(NotesStore, "count", 1);
+            waitForRendering(mainView);
+
+            var noteTextArea = findChild(mainView, "noteTextArea");
+            var titleTextField = findChild(mainView, "titleTextField");
+
+            mouseClick(titleTextField, 1, 1);
+            // clear the textField
+            mouseClick(titleTextField, titleTextField.width - units.gu(1), titleTextField.height / 2);
+            compare(titleTextField.text, "");
+
+            typeString("testnote1");
+
+            mouseClick(noteTextArea, 1, 1)
+
+            typeString("This is a note for testing");
+
+            var saveButton = findChild(mainView, "saveButton");
+            mouseClick(saveButton, 1, 1);
+
+            // Wait for bottom edge to close
+            var notesPage = findChild(mainView, "notesPage")
+            tryCompare(notesPage, "bottomEdgeContentShown", false);
+            waitForRendering(mainView)
+
+            var newNote = NotesStore.note(0);
+            compare(newNote.title, "testnote1");
+            compare(newNote.plaintextContent, "This is a note for testing");
+        }
+
+        function test_deleteNoteFromListItemAction() {
+            createNote("testNote1")
+            waitForRendering(mainView);
+
+            var delegate = findChild(mainView, "notesDelegate0");
+
+            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);
+        }
+
+        function test_sorting_data() {
+            return [
+                { tag: "Date created (newest first)", sortingOption: 0, sortOrder: [3, 2, 1] },
+                { tag: "Date created (oldest first)", sortingOption: 1, sortOrder: [1, 2, 3] },
+                { tag: "Date updated (newest first)", sortingOption: 2, sortOrder: [2, 3, 1] },
+                { tag: "Date updated (oldest first)", sortingOption: 3, sortOrder: [1, 3, 2] },
+                { tag: "Title (ascending)", sortingOption: 4, sortOrder: [1, 2, 3] },
+                { tag: "Title (descending)", sortingOption: 5, sortOrder: [3, 2, 1] }
+            ];
+        }
+
+        function test_sorting(data) {
+            var note1 = createNote("testNote1");
+            var note2 = createNote("testNote2");
+            var note3 = createNote("testNote3");
+
+            note2.reminder = true;
+            NotesStore.saveNote(note2.guid);
+
+            // TODO: Is there a better way to click on toolbar actions?
+            mouseClick(mainView, mainView.width - units.gu(10), units.gu(4))
+
+            waitForRendering(mainView);
+
+            var sortOption = findChild(root, "sortingOption" + data.sortingOption);
+            mouseClick(sortOption, 1, 1);
+            var closeButton = findChild(root, "sortingCloseButton");
+            mouseClick(closeButton, 1, 1);
+
+            waitForRendering(root);
+
+            for (var i = 0; i < data.sortOrder.length; i++) {
+                var delegate = findChild(mainView, "notesDelegate" + i);
+                compare(delegate.title, "testNote" + data.sortOrder[i]);
+            }
+        }
+    }
+}


Follow ups