aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--tests/runTestsOnDevice.sh8
-rw-r--r--tests/tests.pro5
-rw-r--r--tests/tst_MassModel.qml40
3 files changed, 51 insertions, 2 deletions
diff --git a/tests/runTestsOnDevice.sh b/tests/runTestsOnDevice.sh
new file mode 100644
index 0000000..c2a65e0
--- /dev/null
+++ b/tests/runTestsOnDevice.sh
@@ -0,0 +1,8 @@
+#!/bin/bash
+
+# Script for running tests. That's for specifying just one argument in QtCreator's configuration
+/usr/bin/tst-harbour-unitmaster -input /usr/share/tst-harbour-unitmaster
+
+# 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-helloworld-pro-sailfish -input /usr/share/tst-harbour-helloworld-pro-sailfish -import /usr/share/harbour-helloworld-pro-sailfish/qml/components
+
diff --git a/tests/tests.pro b/tests/tests.pro
index 6be9b6d..8bf47f1 100644
--- a/tests/tests.pro
+++ b/tests/tests.pro
@@ -10,6 +10,7 @@ target.path = $$TARGETPATH
DEPLOYMENT_PATH = /usr/share/$$TARGET
qml.path = $$DEPLOYMENT_PATH
+qml.files = *.qml
extra.path = $$DEPLOYMENT_PATH
extra.files = runTestsOnDevice.sh
@@ -23,5 +24,5 @@ SOURCES += main.cpp
INSTALLS += target qml extra
-# QML files and folders
-qml.files = *.qml
+OTHER_FILES += \
+ tst_MassModel.qml
diff --git a/tests/tst_MassModel.qml b/tests/tst_MassModel.qml
new file mode 100644
index 0000000..3a87132
--- /dev/null
+++ b/tests/tst_MassModel.qml
@@ -0,0 +1,40 @@
+import QtQuick 2.0
+import QtTest 1.0
+
+import "../harbour-unitmaster/qml/pages"
+
+TestCase {
+ name: "MassModelTest"
+
+ MassModel {
+ id: model
+ }
+
+ function test_to_data() {
+ return [
+ { to: 'pound', value: 1, res: 2.2046226 },
+ { to: 'ounce', value: 1, res: 35.273961 },
+ { to: 'tonne', value: 1000, res: 1 },
+ { to: 'gram', value: 1, res: 1000 }
+ ];
+ }
+
+ function test_to(data) {
+ var result = model.to(data.to, data.value);
+ compare(result, data.res);
+ }
+
+ function test_from_data() {
+ return [
+ { from: 'pound', value: 1, res: 0.4536 },
+ { from: 'ounce', value: 1, res: 0.02835 },
+ { from: 'tonne', value: 1, res: 1000 },
+ { from: 'gram', value: 1, res: 0.001 }
+ ];
+ }
+
+ function test_from(data) {
+ var result = model.from(data.from, data.value);
+ compare(result, data.res);
+ }
+}