diff --git a/pyotherside.pro b/pyotherside.pro index 0ed5262..7b0ef2b 100644 --- a/pyotherside.pro +++ b/pyotherside.pro @@ -1,5 +1,5 @@ TEMPLATE = subdirs -SUBDIRS += src tests +SUBDIRS += src tests qtquicktests tests.depends = src diff --git a/qtquicktests/PythonRectangle.qml b/qtquicktests/PythonRectangle.qml new file mode 100644 index 0000000..bb077d1 --- /dev/null +++ b/qtquicktests/PythonRectangle.qml @@ -0,0 +1,17 @@ +import QtQuick 2.3 + +import io.thp.pyotherside 1.5 + +Rectangle { + property bool ready: false; + property alias py: py; + Python { + id: py + Component.onCompleted: { + addImportPath(Qt.resolvedUrl('.')); + importModule('test_functions', function() { + ready = true; + }); + } + } +} diff --git a/qtquicktests/qtquicktests.cpp b/qtquicktests/qtquicktests.cpp new file mode 100644 index 0000000..d488cd1 --- /dev/null +++ b/qtquicktests/qtquicktests.cpp @@ -0,0 +1,2 @@ +#include +QUICK_TEST_MAIN(qtquicktests) diff --git a/qtquicktests/qtquicktests.pro b/qtquicktests/qtquicktests.pro new file mode 100644 index 0000000..0a005db --- /dev/null +++ b/qtquicktests/qtquicktests.pro @@ -0,0 +1,4 @@ +TEMPLATE = app +TARGET = qtquicktests +CONFIG += warn_on qmltestcase +SOURCES += qtquicktests.cpp diff --git a/qtquicktests/run b/qtquicktests/run new file mode 100755 index 0000000..221c3be --- /dev/null +++ b/qtquicktests/run @@ -0,0 +1,3 @@ +#!/bin/sh + +exec ./qtquicktests -plugins ../src diff --git a/qtquicktests/test_functions.py b/qtquicktests/test_functions.py new file mode 100644 index 0000000..0d641d3 --- /dev/null +++ b/qtquicktests/test_functions.py @@ -0,0 +1,4 @@ +def function_that_takes_one_parameter(parameter): + '''For tst_model_add_one:call_sync_with_parameters''' + assert parameter == 1 + return 1 diff --git a/qtquicktests/tst_call_sync.qml b/qtquicktests/tst_call_sync.qml new file mode 100644 index 0000000..8835234 --- /dev/null +++ b/qtquicktests/tst_call_sync.qml @@ -0,0 +1,13 @@ +import QtTest 1.0 + +PythonRectangle { + TestCase { + name: "call_sync_with_parameters" + when: ready + + function test_call_sync_with_parameters() { + var result = py.call_sync('test_functions.function_that_takes_one_parameter', [1]); + compare(result, 1); + } + } +}