diff --git a/tests/tools/test_qml b/tests/tools/test_qml index 24d8d5cb5..256961ac4 100644 --- a/tests/tools/test_qml +++ b/tests/tools/test_qml @@ -7,6 +7,7 @@ RESOURCES_FILE='resources.qrc' TEST_RUNNER='qmltestrunner-qt5' TEST_FILE_EXTENSION='spec.qml' +MODULES_PATH='./ui/modules' RED='\e[1;31m' GREEN='\e[1;32m' @@ -20,7 +21,7 @@ cd $SCRIPT_DIR/.. printf "${BLUE}Testing scripts lib...${NC}\n" so_far_so_good=0 -$TEST_RUNNER -input './ui/scripts/Utils/utils.spec.qml' +$TEST_RUNNER -import $MODULES_PATH -input './ui/scripts/Utils/utils.spec.qml' if [[ $? == 0 ]]; then printf "${GREEN}Done. No error found in scripts lib.\n" @@ -42,7 +43,7 @@ do if [ -f $spec_qml_file ]; then printf "${BLUE}Running unit qml tests of '${qml_file}'...${NC}\n" - $TEST_RUNNER -import './ui/modules/' -input "$spec_qml_file" + $TEST_RUNNER -import $MODULES_PATH -input "$spec_qml_file" if [[ $? == 0 ]]; then printf "${GREEN}All unit tests have succeeded for '${spec_qml_file}'.\n" diff --git a/tests/ui/scripts/Utils/utils.js b/tests/ui/scripts/Utils/utils.js index c4659d8d7..10100b262 100644 --- a/tests/ui/scripts/Utils/utils.js +++ b/tests/ui/scripts/Utils/utils.js @@ -48,12 +48,14 @@ function openWindow (window, parent, options) { } object.show() + + return object } // Display a simple ConfirmDialog component. // Wrap the openWindow function. function openConfirmDialog (parent, options) { - openWindow( + return openWindow( 'import QtQuick 2.7;' + 'import Common 1.0;' + 'ConfirmDialog {' + diff --git a/tests/ui/scripts/Utils/utils.spec.qml b/tests/ui/scripts/Utils/utils.spec.qml index aa95fe69e..2499423cc 100644 --- a/tests/ui/scripts/Utils/utils.spec.qml +++ b/tests/ui/scripts/Utils/utils.spec.qml @@ -12,6 +12,25 @@ TestCase { name: 'UtilsTests' + // Test only if a confirm dialog can be opened. + // The other tests are launched by `ConfirmDialog.spec.qml`. + function test_openConfirmDialog () { + var dialog + + try { + dialog = Utils.openConfirmDialog(testCase, { + descriptionText: '', + title: '' + }) + } catch (e) { + fail(e) + } + + dialog.close() + } + + // ----------------------------------------------------------------- + function test_snakeToCamel_data () { return [ { input: 'foo_bar', output: 'fooBar' },