diff options
| author | Oskari Timperi <oskari.timperi@iki.fi> | 2013-12-07 18:24:15 +0200 |
|---|---|---|
| committer | Oskari Timperi <oskari.timperi@iki.fi> | 2013-12-07 18:24:15 +0200 |
| commit | 43237a8411252f431a9aba1fe86bb3868e4df744 (patch) | |
| tree | 20f2ae073cae70549e0ddbf4963058d4e2bf5ffe | |
| parent | 0450df418933ecbb74a631432c144739a05808ef (diff) | |
| download | unitmaster-43237a8411252f431a9aba1fe86bb3868e4df744.tar.gz unitmaster-43237a8411252f431a9aba1fe86bb3868e4df744.zip | |
add tests for MassModel
| -rw-r--r-- | tests/runTestsOnDevice.sh | 8 | ||||
| -rw-r--r-- | tests/tests.pro | 5 | ||||
| -rw-r--r-- | tests/tst_MassModel.qml | 40 |
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); + } +} |
