diff --git a/.gitignore b/.gitignore index 082e8a8..91dbac8 100644 --- a/.gitignore +++ b/.gitignore @@ -9,3 +9,5 @@ rpm/harbour-tasklist.spec *.o localization *.qm +build/ +.directory diff --git a/.gitmodules b/.gitmodules index 7588979..8dc9880 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +1,3 @@ -[submodule "third_party/QtDropbox"] - path = third_party/QtDropbox +[submodule "src/third_party/QtDropbox"] + path = src/third_party/QtDropbox url = https://github.com/lycis/QtDropbox.git diff --git a/README.md b/README.md index 5911464..b1575b2 100755 --- a/README.md +++ b/README.md @@ -6,6 +6,17 @@ Developing ================ Have a look here to prepare your build environment for TaskList: https://github.com/Armadill0/harbour-tasklist/wiki +### Running tests +* Option 1: In the emulator console, just run `/usr/share/tst-harbour-tasklist/runTestsOnDevice.sh` Here are instructions on connecting to the emulator's console - https://sailfishos.org/develop-faq.html + +* Option 2: Inside SailfishOS IDE + + 1. Toolbar -> Projects -> i486 -> Run -> Run Settings -> Run -> Run configuration -> "src (on Mer Device)" -> "Use this command instead" + + 2. Set "Alternate executable on device:" to `/usr/share/tst-harbour-tasklist/runTestsOnDevice.sh` + + 3. Run the project again, see test results in the console + Pull-Requests ================ Pull-Requests are always welcome. But please respect the following rules to make the life of the collaborators easier. ;-) diff --git a/harbour-tasklist.pro b/harbour-tasklist.pro index 771620b..c74f3f0 100644 --- a/harbour-tasklist.pro +++ b/harbour-tasklist.pro @@ -1,62 +1,6 @@ -# The name of your app. -# NOTICE: name defined in TARGET has a corresponding QML filename. -# If name defined in TARGET is changed, following needs to be -# done to match new name: -# - corresponding QML filename must be changed -# - desktop icon filename must be changed -# - desktop filename must be changed -# - icon definition filename in desktop file must be changed -TARGET = harbour-tasklist +TEMPLATE = subdirs +SUBDIRS = src tests -CONFIG += sailfishapp c++11 -QT += dbus - -SOURCES += src/harbour-tasklist.cpp \ - src/tasksexport.cpp - -OTHER_FILES += qml/harbour-tasklist.qml \ - qml/pages/CoverPage.qml \ - rpm/harbour-tasklist.yaml \ - harbour-tasklist.desktop \ - qml/localdb.js \ - qml/pages/AboutPage.qml \ - qml/pages/EditPage.qml \ - qml/pages/TaskPage.qml \ - qml/pages/ListPage.qml \ - qml/pages/SettingsPage.qml \ - qml/pages/TaskListItem.qml \ - qml/pages/ExportPage.qml \ - qml/pages/TagPage.qml \ - qml/pages/TagDialog.qml \ - qml/pages/sync/DropboxAuth.qml \ - qml/pages/sync/DropboxSync.qml \ - qml/pages/HelpPage.qml - -include(third_party/QtDropbox/qtdropbox.pri) - -!defined(TASKLIST_DROPBOX_APPKEY, var) { - error("Please provide Dropbox appkey as argument of qmake, e.g. 'qmake TASKLIST_DROPBOX_APPKEY='") -} -!defined(TASKLIST_DROPBOX_SHAREDSECRET, var) { - error("Please provide Dropbox shared secret as argument of qmake, e.g. 'qmake TASKLIST_DROPBOX_SHAREDSECRET='") -} - -DEFINES += TASKLIST_DROPBOX_APPKEY=$$TASKLIST_DROPBOX_APPKEY TASKLIST_DROPBOX_SHAREDSECRET=$$TASKLIST_DROPBOX_SHAREDSECRET - -localization.files = localization -localization.path = /usr/share/$${TARGET} - -INSTALLS += localization - -CONFIG += sailfishapp_i18n_idbased - -lupdate_only { - SOURCES = qml/*.qml \ - qml/*.js \ - qml/pages/*.qml \ - qml/pages/sync/*.qml - TRANSLATIONS = localization-sources/*.ts -} - -HEADERS += \ - src/tasksexport.h +# ordered makes sure projects are built in the order specified in SUBDIRS. +# Usually it makes sense to build tests only if main component can be built +CONFIG += ordered diff --git a/rpm/harbour-tasklist.yaml b/rpm/harbour-tasklist.yaml index bc9f767..c73f6a8 100644 --- a/rpm/harbour-tasklist.yaml +++ b/rpm/harbour-tasklist.yaml @@ -17,6 +17,9 @@ Configure: none # The qtc5 builder inserts macros to allow QtCreator to have fine # control over qmake/make execution Builder: qtc5 +QMakeOptions: +- VERSION=%{version} +- RELEASE=%{release} # This section specifies build dependencies that are resolved using pkgconfig. # This is the preferred way of specifying build dependencies for your package. @@ -36,10 +39,30 @@ Requires: # All installed files Files: - - '%{_bindir}' +# Do not include whole %{_datadir}/applications as that would include tests too + - '%defattr(0644,root,root,0755)' - '%{_datadir}/%{name}' - '%{_datadir}/applications/%{name}.desktop' - '%{_datadir}/icons/hicolor/86x86/apps/%{name}.png' + - '%attr(0755,-,-) %{_bindir}/%{name}' + +SubPackages: + - Name: harbour-tasklist-test + Summary: harbour-tasklist tests + Group: Qt/Qt + Description: |- + Tests for the harbour-tasklist package + AutoDepend: true + PkgConfigBR: + - Qt5QuickTest + Requires: + - qt5-qtdeclarative-import-qttest + Files: + - '%{_bindir}/tst-harbour-tasklist' + - '%{_datadir}/tst-harbour-tasklist/*.qml' + # Script for starting tests on emulator and device + - '%attr(0755,-,-) %{_datadir}/tst-harbour-tasklist/*.sh' + # For more information about yaml and what's supported in Sailfish OS # build system, please see https://wiki.merproject.org/wiki/Spectacle diff --git a/gen-qm.sh b/src/gen-qm.sh similarity index 100% rename from gen-qm.sh rename to src/gen-qm.sh diff --git a/gen-ts.sh b/src/gen-ts.sh similarity index 100% rename from gen-ts.sh rename to src/gen-ts.sh diff --git a/harbour-tasklist.desktop b/src/harbour-tasklist.desktop similarity index 100% rename from harbour-tasklist.desktop rename to src/harbour-tasklist.desktop diff --git a/harbour-tasklist.png b/src/harbour-tasklist.png similarity index 100% rename from harbour-tasklist.png rename to src/harbour-tasklist.png diff --git a/localization-sources/harbour-tasklist_ca.ts b/src/localization-sources/harbour-tasklist_ca.ts similarity index 100% rename from localization-sources/harbour-tasklist_ca.ts rename to src/localization-sources/harbour-tasklist_ca.ts diff --git a/localization-sources/harbour-tasklist_cs_CZ.ts b/src/localization-sources/harbour-tasklist_cs_CZ.ts similarity index 100% rename from localization-sources/harbour-tasklist_cs_CZ.ts rename to src/localization-sources/harbour-tasklist_cs_CZ.ts diff --git a/localization-sources/harbour-tasklist_da_DK.ts b/src/localization-sources/harbour-tasklist_da_DK.ts similarity index 100% rename from localization-sources/harbour-tasklist_da_DK.ts rename to src/localization-sources/harbour-tasklist_da_DK.ts diff --git a/localization-sources/harbour-tasklist_de_DE.ts b/src/localization-sources/harbour-tasklist_de_DE.ts similarity index 100% rename from localization-sources/harbour-tasklist_de_DE.ts rename to src/localization-sources/harbour-tasklist_de_DE.ts diff --git a/localization-sources/harbour-tasklist_en_US.ts b/src/localization-sources/harbour-tasklist_en_US.ts similarity index 100% rename from localization-sources/harbour-tasklist_en_US.ts rename to src/localization-sources/harbour-tasklist_en_US.ts diff --git a/localization-sources/harbour-tasklist_es_ES.ts b/src/localization-sources/harbour-tasklist_es_ES.ts similarity index 100% rename from localization-sources/harbour-tasklist_es_ES.ts rename to src/localization-sources/harbour-tasklist_es_ES.ts diff --git a/localization-sources/harbour-tasklist_fi_FI.ts b/src/localization-sources/harbour-tasklist_fi_FI.ts similarity index 100% rename from localization-sources/harbour-tasklist_fi_FI.ts rename to src/localization-sources/harbour-tasklist_fi_FI.ts diff --git a/localization-sources/harbour-tasklist_fr_FR.ts b/src/localization-sources/harbour-tasklist_fr_FR.ts similarity index 100% rename from localization-sources/harbour-tasklist_fr_FR.ts rename to src/localization-sources/harbour-tasklist_fr_FR.ts diff --git a/localization-sources/harbour-tasklist_hu.ts b/src/localization-sources/harbour-tasklist_hu.ts similarity index 100% rename from localization-sources/harbour-tasklist_hu.ts rename to src/localization-sources/harbour-tasklist_hu.ts diff --git a/localization-sources/harbour-tasklist_it_IT.ts b/src/localization-sources/harbour-tasklist_it_IT.ts similarity index 100% rename from localization-sources/harbour-tasklist_it_IT.ts rename to src/localization-sources/harbour-tasklist_it_IT.ts diff --git a/localization-sources/harbour-tasklist_ku_IQ.ts b/src/localization-sources/harbour-tasklist_ku_IQ.ts similarity index 100% rename from localization-sources/harbour-tasklist_ku_IQ.ts rename to src/localization-sources/harbour-tasklist_ku_IQ.ts diff --git a/localization-sources/harbour-tasklist_lt.ts b/src/localization-sources/harbour-tasklist_lt.ts similarity index 100% rename from localization-sources/harbour-tasklist_lt.ts rename to src/localization-sources/harbour-tasklist_lt.ts diff --git a/localization-sources/harbour-tasklist_nl_NL.ts b/src/localization-sources/harbour-tasklist_nl_NL.ts similarity index 100% rename from localization-sources/harbour-tasklist_nl_NL.ts rename to src/localization-sources/harbour-tasklist_nl_NL.ts diff --git a/localization-sources/harbour-tasklist_pl_PL.ts b/src/localization-sources/harbour-tasklist_pl_PL.ts similarity index 100% rename from localization-sources/harbour-tasklist_pl_PL.ts rename to src/localization-sources/harbour-tasklist_pl_PL.ts diff --git a/localization-sources/harbour-tasklist_ru_RU.ts b/src/localization-sources/harbour-tasklist_ru_RU.ts similarity index 100% rename from localization-sources/harbour-tasklist_ru_RU.ts rename to src/localization-sources/harbour-tasklist_ru_RU.ts diff --git a/localization-sources/harbour-tasklist_sv_SE.ts b/src/localization-sources/harbour-tasklist_sv_SE.ts similarity index 100% rename from localization-sources/harbour-tasklist_sv_SE.ts rename to src/localization-sources/harbour-tasklist_sv_SE.ts diff --git a/localization-sources/harbour-tasklist_tr_TR.ts b/src/localization-sources/harbour-tasklist_tr_TR.ts similarity index 100% rename from localization-sources/harbour-tasklist_tr_TR.ts rename to src/localization-sources/harbour-tasklist_tr_TR.ts diff --git a/localization-sources/harbour-tasklist_zh_CN.ts b/src/localization-sources/harbour-tasklist_zh_CN.ts similarity index 100% rename from localization-sources/harbour-tasklist_zh_CN.ts rename to src/localization-sources/harbour-tasklist_zh_CN.ts diff --git a/src/qml/TestCases.qml b/src/qml/TestCases.qml new file mode 100644 index 0000000..9c36e13 --- /dev/null +++ b/src/qml/TestCases.qml @@ -0,0 +1,5 @@ +import QtQuick 2.0 + +Item { + +} diff --git a/src/qml/common.js b/src/qml/common.js new file mode 100644 index 0000000..3d93837 --- /dev/null +++ b/src/qml/common.js @@ -0,0 +1,7 @@ + +//trim objects if they provide a trim() function (e. g. strings), else just the original object +function trimmed(obj) { + if(obj.trim) + return obj.trim() + return obj +} diff --git a/qml/harbour-tasklist.qml b/src/qml/harbour-tasklist.qml similarity index 100% rename from qml/harbour-tasklist.qml rename to src/qml/harbour-tasklist.qml diff --git a/qml/images/coverbg.png b/src/qml/images/coverbg.png similarity index 100% rename from qml/images/coverbg.png rename to src/qml/images/coverbg.png diff --git a/qml/images/harbour-tasklist.png b/src/qml/images/harbour-tasklist.png similarity index 100% rename from qml/images/harbour-tasklist.png rename to src/qml/images/harbour-tasklist.png diff --git a/qml/localdb.js b/src/qml/localdb.js similarity index 100% rename from qml/localdb.js rename to src/qml/localdb.js diff --git a/qml/pages/AboutPage.qml b/src/qml/pages/AboutPage.qml similarity index 100% rename from qml/pages/AboutPage.qml rename to src/qml/pages/AboutPage.qml diff --git a/qml/pages/CoverPage.qml b/src/qml/pages/CoverPage.qml similarity index 100% rename from qml/pages/CoverPage.qml rename to src/qml/pages/CoverPage.qml diff --git a/qml/pages/EditPage.qml b/src/qml/pages/EditPage.qml similarity index 98% rename from qml/pages/EditPage.qml rename to src/qml/pages/EditPage.qml index 881f394..1ca2f53 100644 --- a/qml/pages/EditPage.qml +++ b/src/qml/pages/EditPage.qml @@ -20,6 +20,7 @@ import QtQuick 2.1 import Sailfish.Silica 1.0 import "../localdb.js" as DB +import "../common.js" as Common import "." Dialog { @@ -59,7 +60,7 @@ Dialog { function checkContent() { var ok = true var listId = listModel.get(list.currentIndex).id - var name = task.text + var name = Common.trimmed(task.text) var count = DB.checkTask(listId, name) // if task already exists in target list, display warning @@ -115,7 +116,7 @@ Dialog { onAccepted: { var ok = DB.updateTask(params.taskid, listModel.get(list.currentIndex).id, - task.text, taskListWindow.statusOpen(status.checked) ? 1 : 0, + Common.trimmed(task.text), taskListWindow.statusOpen(status.checked) ? 1 : 0, params.dueDate, 0, priorityBox.selectedPriority(), notes.text, DB.REPETITION_VARIANTS[repeat.currentIndex].key) if (ok) diff --git a/qml/pages/ExportPage.qml b/src/qml/pages/ExportPage.qml similarity index 100% rename from qml/pages/ExportPage.qml rename to src/qml/pages/ExportPage.qml diff --git a/qml/pages/HelpPage.qml b/src/qml/pages/HelpPage.qml similarity index 100% rename from qml/pages/HelpPage.qml rename to src/qml/pages/HelpPage.qml diff --git a/qml/pages/ListPage.qml b/src/qml/pages/ListPage.qml similarity index 100% rename from qml/pages/ListPage.qml rename to src/qml/pages/ListPage.qml diff --git a/qml/pages/SettingsPage.qml b/src/qml/pages/SettingsPage.qml similarity index 100% rename from qml/pages/SettingsPage.qml rename to src/qml/pages/SettingsPage.qml diff --git a/qml/pages/TagDialog.qml b/src/qml/pages/TagDialog.qml similarity index 100% rename from qml/pages/TagDialog.qml rename to src/qml/pages/TagDialog.qml diff --git a/qml/pages/TagPage.qml b/src/qml/pages/TagPage.qml similarity index 100% rename from qml/pages/TagPage.qml rename to src/qml/pages/TagPage.qml diff --git a/qml/pages/TaskListItem.qml b/src/qml/pages/TaskListItem.qml similarity index 100% rename from qml/pages/TaskListItem.qml rename to src/qml/pages/TaskListItem.qml diff --git a/qml/pages/TaskPage.qml b/src/qml/pages/TaskPage.qml similarity index 99% rename from qml/pages/TaskPage.qml rename to src/qml/pages/TaskPage.qml index d8b0193..1e0bd91 100644 --- a/qml/pages/TaskPage.qml +++ b/src/qml/pages/TaskPage.qml @@ -20,6 +20,7 @@ import QtQuick 2.1 import Sailfish.Silica 1.0 import "../localdb.js" as DB +import "../common.js" as Common import "." Page { @@ -310,7 +311,7 @@ Page { EnterKey.enabled: text.length > 0 function addTask(newTask) { - var taskNew = (typeof newTask !== 'undefined') ? newTask : taskAdd.text + var taskNew = Common.trimmed((typeof newTask !== 'undefined') ? newTask : taskAdd.text) if (taskNew.length > 0) { // add task to db and tasklist var result = DB.writeTask(listid, taskNew, 1, 0, 0, DB.PRIORITY_DEFAULT, "") diff --git a/qml/pages/sync/DropboxAuth.qml b/src/qml/pages/sync/DropboxAuth.qml similarity index 100% rename from qml/pages/sync/DropboxAuth.qml rename to src/qml/pages/sync/DropboxAuth.qml diff --git a/qml/pages/sync/DropboxSync.qml b/src/qml/pages/sync/DropboxSync.qml similarity index 100% rename from qml/pages/sync/DropboxSync.qml rename to src/qml/pages/sync/DropboxSync.qml diff --git a/src/src.pro b/src/src.pro new file mode 100644 index 0000000..a318051 --- /dev/null +++ b/src/src.pro @@ -0,0 +1,69 @@ +# The name of your app. +# NOTICE: name defined in TARGET has a corresponding QML filename. +# If name defined in TARGET is changed, following needs to be +# done to match new name: +# - corresponding QML filename must be changed +# - desktop icon filename must be changed +# - desktop filename must be changed +# - icon definition filename in desktop file must be changed +TARGET = harbour-tasklist + +CONFIG += sailfishapp c++11 +QT += dbus + +DEFINES += APP_VERSION=\\\"$$VERSION\\\" +DEFINES += APP_BUILDNUM=\\\"$$RELEASE\\\" + +SOURCES += harbour-tasklist.cpp \ + tasksexport.cpp + +OTHER_FILES += qml/harbour-tasklist.qml \ + qml/pages/CoverPage.qml \ + harbour-tasklist.desktop \ + qml/localdb.js \ + qml/pages/AboutPage.qml \ + qml/pages/EditPage.qml \ + qml/pages/TaskPage.qml \ + qml/pages/ListPage.qml \ + qml/pages/SettingsPage.qml \ + qml/pages/TaskListItem.qml \ + qml/pages/ExportPage.qml \ + qml/pages/TagPage.qml \ + qml/pages/TagDialog.qml \ + qml/pages/sync/DropboxAuth.qml \ + qml/pages/sync/DropboxSync.qml \ + qml/pages/HelpPage.qml +# You DO NOT want .yaml be listed here as Qt Creator's editor is completely not ready for multi package .yaml's +# +# Also Qt Creator as of Nov 2013 will anyway try to rewrite your .yaml whenever you change your .pro +# Well, you will just have to restore .yaml from version control again and again unless you figure out +# how to kill this particular Creator's plugin + +include(third_party/QtDropbox/qtdropbox.pri) + +!defined(TASKLIST_DROPBOX_APPKEY, var) { + error("Please provide Dropbox appkey as argument of qmake, e.g. 'qmake TASKLIST_DROPBOX_APPKEY='") +} +!defined(TASKLIST_DROPBOX_SHAREDSECRET, var) { + error("Please provide Dropbox shared secret as argument of qmake, e.g. 'qmake TASKLIST_DROPBOX_SHAREDSECRET='") +} + +DEFINES += TASKLIST_DROPBOX_APPKEY=$$TASKLIST_DROPBOX_APPKEY TASKLIST_DROPBOX_SHAREDSECRET=$$TASKLIST_DROPBOX_SHAREDSECRET + +localization.files = localization +localization.path = /usr/share/$${TARGET} + +INSTALLS += localization + +CONFIG += sailfishapp_i18n_idbased + +lupdate_only { + SOURCES = qml/*.qml \ + qml/*.js \ + qml/pages/*.qml \ + qml/pages/sync/*.qml + TRANSLATIONS = localization-sources/*.ts +} + +HEADERS += \ + tasksexport.h diff --git a/src/third_party/QtDropbox b/src/third_party/QtDropbox new file mode 160000 index 0000000..17ad007 --- /dev/null +++ b/src/third_party/QtDropbox @@ -0,0 +1 @@ +Subproject commit 17ad0070e8157fc973a3f3c47c676e73728c26d0 diff --git a/tests/main.cpp b/tests/main.cpp new file mode 100644 index 0000000..1043e1d --- /dev/null +++ b/tests/main.cpp @@ -0,0 +1,4 @@ +#include + +// SailCalcTestSet is just a convenient name for reports - not linked to any of the main project entities +QUICK_TEST_MAIN(TasklistTestSet) diff --git a/tests/runTestsOnDevice.sh b/tests/runTestsOnDevice.sh new file mode 100644 index 0000000..4ebc943 --- /dev/null +++ b/tests/runTestsOnDevice.sh @@ -0,0 +1,7 @@ +#!/bin/bash + +# Script for running tests. That's for specifying just one argument in QtCreator's configuration +/usr/bin/tst-harbour-tasklist -input /usr/share/tst-harbour-tasklist + +# When you'll get some QML components in the main app, you'll need to import them to the test run +# /usr/bin/tst-harbour-tasklist -input /usr/share/tst-harbour-tasklist -import /usr/share/harbour-tasklist/qml/components \ No newline at end of file diff --git a/tests/tests.pro b/tests/tests.pro new file mode 100644 index 0000000..c14feb0 --- /dev/null +++ b/tests/tests.pro @@ -0,0 +1,37 @@ +TEMPLATE = app + +# The name of your app +TARGET = tst-harbour-tasklist + +CONFIG += qmltestcase + +TARGETPATH = /usr/bin +target.path = $$TARGETPATH + +DEPLOYMENT_PATH = /usr/share/$$TARGET +qml.path = $$DEPLOYMENT_PATH + +extra.path = $$DEPLOYMENT_PATH +extra.files = runTestsOnDevice.sh + +# defining QUICK_TEST_SOURCE_DIR here doesn't work QtCreator keeps injecting another definition to command line (from CONFIG += qmltestcase ?) +#DEFINES += QUICK_TEST_SOURCE_DIR=\"\\\"\"$${DEPLOYMENT_PATH}/\"\\\"\" +DEFINES += DEPLOYMENT_PATH=\"\\\"\"$${DEPLOYMENT_PATH}/\"\\\"\" + +# C++ sources +SOURCES += main.cpp + +# C++ headers +HEADERS += + +INSTALLS += target qml extra + +# QML files and folders +qml.files = *.qml + +OTHER_FILES += \ + tst_RealUiTest.qml \ + tst_NonUiTests.qml + + + diff --git a/tests/tst_NonUiTests.qml b/tests/tst_NonUiTests.qml new file mode 100644 index 0000000..3fa48b0 --- /dev/null +++ b/tests/tst_NonUiTests.qml @@ -0,0 +1,29 @@ +/** + * Tests that operate with instantiated QML components, yet don't really need Application Window to be created + * That will produce a lot of warnings, UI utilities such as mouseClick won't work, but the test code becomes simpler + * and runs faster + * And if you do want to operate on the muse level, you can get almost there via e.g. triggering clicked(null) signal handler + * + */ + +import QtQuick 2.0 +import QtTest 1.0 + +// At runtime proper folder to import is "../harbour-tasklist/qml/pages" +// You can check the main app deployment folder from it's DEPLOYMENT_PATH qmake var in .pro +// Faster to check from .spec file, however + +// At design-time I uncomment import "../src/qml/pages" so that QtCreator auto-completion would work + +//import "../src/qml/pages" +import "../harbour-tasklist/qml/pages" + +TestCase { + name: "footest" + + function test_fail() { + fail() + } +} + + diff --git a/third_party/QtDropbox b/third_party/QtDropbox deleted file mode 160000 index 8f09551..0000000 --- a/third_party/QtDropbox +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 8f09551f335a0961f10b95cf43a879c486479622