mirror of
https://github.com/QRouland/UTPass.git
synced 2025-01-24 07:36:39 +00:00
Setup tests
This commit is contained in:
parent
399173b776
commit
46145241fc
@ -35,9 +35,19 @@ set(DATA_DIR /)
|
|||||||
|
|
||||||
set(DESKTOP_FILE_NAME ${PROJECT_NAME}.desktop)
|
set(DESKTOP_FILE_NAME ${PROJECT_NAME}.desktop)
|
||||||
|
|
||||||
add_executable(${PROJECT_NAME} main.cpp
|
if(NOT TESTS_PATH)
|
||||||
qml/pages/settings/ImportGitClone.qml)
|
set(TESTS_PATH "./tests")
|
||||||
qt5_use_modules(${PROJECT_NAME} Gui Qml Quick)
|
endif()
|
||||||
|
|
||||||
|
configure_file(main.in.cpp main.cpp)
|
||||||
|
|
||||||
|
add_executable(${PROJECT_NAME} main.cpp)
|
||||||
|
qt5_use_modules(${PROJECT_NAME} Gui Qml Quick QuickTest)
|
||||||
|
|
||||||
|
if(TESTS_RUNNER)
|
||||||
|
qt5_use_modules(${PROJECT_NAME} QuickTest)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
|
||||||
install(TARGETS ${PROJECT_NAME} RUNTIME DESTINATION ${CMAKE_INSTALL_PREFIX})
|
install(TARGETS ${PROJECT_NAME} RUNTIME DESTINATION ${CMAKE_INSTALL_PREFIX})
|
||||||
|
|
||||||
@ -77,5 +87,9 @@ install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${DESKTOP_FILE_NAME} DESTINATION ${DAT
|
|||||||
|
|
||||||
add_subdirectory(po)
|
add_subdirectory(po)
|
||||||
add_subdirectory(plugins)
|
add_subdirectory(plugins)
|
||||||
|
if(TESTS_RUNNER)
|
||||||
|
add_subdirectory(tests/plugins)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
|
||||||
add_custom_target(${PROJECT_NAME}_FILES ALL SOURCES ${PROJECT_SRC_FILES})
|
add_custom_target(${PROJECT_NAME}_FILES ALL SOURCES ${PROJECT_SRC_FILES})
|
||||||
|
@ -4,7 +4,7 @@ kill: UTPass
|
|||||||
|
|
||||||
scripts:
|
scripts:
|
||||||
style: >-
|
style: >-
|
||||||
echo 'Astyle :' && astyle --options=.astylerc main.cpp && astyle --options=.astylerc --recursive 'plugins/*.cpp,*.h' && echo 'Running QmlFormat' && find . -name "*.qml" -exec qmlformat -i {} \; && echo 'Success'
|
echo 'Running Astyle :' && astyle --options=.astylerc main.cpp && astyle --options=.astylerc --recursive 'plugins/*.cpp,*.h' && echo 'Running QmlFormat' && find . -name "*.qml" -exec qmlformat -i {} \; && echo 'Success'
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -6,6 +6,10 @@
|
|||||||
#include <QtQml>
|
#include <QtQml>
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef TEST_RUNNER
|
||||||
|
#include <QtQuickTest/quicktest.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
qDebug() << "Starting app from main.cpp";
|
qDebug() << "Starting app from main.cpp";
|
||||||
@ -13,6 +17,7 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
QGuiApplication::setApplicationName("utpass.qrouland");
|
QGuiApplication::setApplicationName("utpass.qrouland");
|
||||||
|
|
||||||
|
#ifndef TEST_RUNNER
|
||||||
auto *view = new QQuickView();
|
auto *view = new QQuickView();
|
||||||
view->setSource(QUrl(QStringLiteral("qml/Main.qml")));
|
view->setSource(QUrl(QStringLiteral("qml/Main.qml")));
|
||||||
view->setResizeMode(QQuickView::SizeRootObjectToView);
|
view->setResizeMode(QQuickView::SizeRootObjectToView);
|
||||||
@ -23,4 +28,7 @@ int main(int argc, char *argv[])
|
|||||||
Q_ARG(QVariant, QVariant::fromValue(mainView))
|
Q_ARG(QVariant, QVariant::fromValue(mainView))
|
||||||
);
|
);
|
||||||
return QGuiApplication::exec();
|
return QGuiApplication::exec();
|
||||||
|
#else
|
||||||
|
return quick_test_main(argc, argv, "@TESTS_PATH@", "@TESTS_PATH@");
|
||||||
|
#endif
|
||||||
}
|
}
|
@ -13,7 +13,6 @@ bool Git::clone(QString url, QString destination_dir_path)
|
|||||||
QDir tmp_dir(QStandardPaths::writableLocation(
|
QDir tmp_dir(QStandardPaths::writableLocation(
|
||||||
QStandardPaths::CacheLocation).append("/clone"));
|
QStandardPaths::CacheLocation).append("/clone"));
|
||||||
tmp_dir.removeRecursively();
|
tmp_dir.removeRecursively();
|
||||||
tmp_dir.mkpath(".");
|
|
||||||
qDebug() << "Temp dir path is " << tmp_dir.absolutePath();
|
qDebug() << "Temp dir path is " << tmp_dir.absolutePath();
|
||||||
|
|
||||||
qDebug() << "Cloning " << url << " to tmp dir " << tmp_dir.absolutePath();
|
qDebug() << "Cloning " << url << " to tmp dir " << tmp_dir.absolutePath();
|
||||||
|
@ -33,10 +33,10 @@ int LibGit::credentials_cb(git_cred **out, const char *url, const char *username
|
|||||||
// store_error(error);
|
// store_error(error);
|
||||||
// return GIT_EUSER;
|
// return GIT_EUSER;
|
||||||
// }
|
// }
|
||||||
// user = "user";
|
user = "pass";
|
||||||
// pass = "pass";
|
pass = "pass";
|
||||||
// return git_cred_userpass_plaintext_new(out, user, pass);
|
return git_cred_userpass_plaintext_new(out, user, pass);
|
||||||
return GIT_EUSER;
|
// return GIT_EUSER;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool LibGit::clone(QString url, QString path)
|
bool LibGit::clone(QString url, QString path)
|
||||||
@ -45,8 +45,12 @@ bool LibGit::clone(QString url, QString path)
|
|||||||
git_clone_options opts = GIT_CLONE_OPTIONS_INIT;
|
git_clone_options opts = GIT_CLONE_OPTIONS_INIT;
|
||||||
opts.fetch_opts.callbacks.credentials = *credentials_cb;
|
opts.fetch_opts.callbacks.credentials = *credentials_cb;
|
||||||
int ret = git_clone(&repo, url.toLocal8Bit().data(), path.toLocal8Bit().data(), &opts);
|
int ret = git_clone(&repo, url.toLocal8Bit().data(), path.toLocal8Bit().data(), &opts);
|
||||||
|
if (ret != 0) {
|
||||||
|
qDebug() << git_error_last()->message;
|
||||||
|
}
|
||||||
if (repo) {
|
if (repo) {
|
||||||
git_repository_free(repo);
|
git_repository_free(repo);
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret == 0; // TODO Clean error handling to return specifics errors for the ui
|
return ret == 0; // TODO Clean error handling to return specifics errors for the ui
|
||||||
}
|
}
|
||||||
|
@ -8,7 +8,7 @@ msgid ""
|
|||||||
msgstr ""
|
msgstr ""
|
||||||
"Project-Id-Version: utpass.qrouland\n"
|
"Project-Id-Version: utpass.qrouland\n"
|
||||||
"Report-Msgid-Bugs-To: \n"
|
"Report-Msgid-Bugs-To: \n"
|
||||||
"POT-Creation-Date: 2025-01-10 14:39+0100\n"
|
"POT-Creation-Date: 2025-01-10 21:31+0100\n"
|
||||||
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
||||||
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
||||||
"Language-Team: LANGUAGE <LL@li.org>\n"
|
"Language-Team: LANGUAGE <LL@li.org>\n"
|
||||||
@ -17,7 +17,7 @@ msgstr ""
|
|||||||
"Content-Type: text/plain; charset=CHARSET\n"
|
"Content-Type: text/plain; charset=CHARSET\n"
|
||||||
"Content-Transfer-Encoding: 8bit\n"
|
"Content-Transfer-Encoding: 8bit\n"
|
||||||
|
|
||||||
#: ../qml/components/FileDir.qml:71
|
#: ../qml/components/FileDir.qml:69
|
||||||
msgid "Decryption failed !"
|
msgid "Decryption failed !"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
@ -37,19 +37,19 @@ msgstr ""
|
|||||||
msgid "Error !"
|
msgid "Error !"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: ../qml/dialogs/ErrorDialog.qml:15
|
#: ../qml/dialogs/ErrorDialog.qml:16
|
||||||
msgid "Close"
|
msgid "Close"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: ../qml/dialogs/PassphraseDialog.qml:7
|
#: ../qml/dialogs/PassphraseDialog.qml:15
|
||||||
msgid "Authentication required"
|
msgid "Authentication required"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: ../qml/dialogs/PassphraseDialog.qml:8
|
#: ../qml/dialogs/PassphraseDialog.qml:16
|
||||||
msgid "Enter passphrase:"
|
msgid "Enter passphrase:"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: ../qml/dialogs/PassphraseDialog.qml:20
|
#: ../qml/dialogs/PassphraseDialog.qml:21
|
||||||
msgid "passphrase"
|
msgid "passphrase"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
@ -57,69 +57,65 @@ msgstr ""
|
|||||||
msgid "Success !"
|
msgid "Success !"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: ../qml/dialogs/SuccessDialog.qml:15
|
#: ../qml/dialogs/SuccessDialog.qml:16
|
||||||
msgid "OK"
|
msgid "OK"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: ../qml/pages/Info.qml:11 ../qml/pages/headers/MainHeader.qml:58
|
#: ../qml/pages/Info.qml:58
|
||||||
msgid "Info"
|
|
||||||
msgstr ""
|
|
||||||
|
|
||||||
#: ../qml/pages/Info.qml:50
|
|
||||||
msgid "<b>Version</b>"
|
msgid "<b>Version</b>"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: ../qml/pages/Info.qml:68
|
#: ../qml/pages/Info.qml:77
|
||||||
msgid "<b>Maintainer</>"
|
msgid "<b>Maintainer</>"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: ../qml/pages/Info.qml:90
|
#: ../qml/pages/Info.qml:102
|
||||||
msgid "Suggest improvement(s) or report a bug(s)"
|
msgid "Suggest improvement(s) or report a bug(s)"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: ../qml/pages/Info.qml:94
|
#: ../qml/pages/Info.qml:107
|
||||||
msgid "Access to the source code"
|
msgid "Access to the source code"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: ../qml/pages/Info.qml:101
|
#: ../qml/pages/Info.qml:115
|
||||||
msgid "Released under the terms of the GNU GPL v3"
|
msgid "Released under the terms of the GNU GPL v3"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: ../qml/pages/PasswordList.qml:23
|
#: ../qml/pages/Info.qml:123 ../qml/pages/headers/MainHeader.qml:33
|
||||||
msgid "Back"
|
msgid "Info"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: ../qml/pages/PasswordList.qml:43
|
#: ../qml/pages/PasswordList.qml:26
|
||||||
msgid ""
|
msgid ""
|
||||||
"No password found<br>You can import a password store zip in the settings"
|
"No password found<br>You can import a password store zip in the settings"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: ../qml/pages/headers/MainHeader.qml:8 ../qml/pages/headers/StackHeader.qml:8
|
#: ../qml/pages/PasswordList.qml:65
|
||||||
|
msgid "Back"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: ../qml/pages/headers/MainHeader.qml:9 ../qml/pages/headers/StackHeader.qml:9
|
||||||
#: UTPass.desktop.in.h:1
|
#: UTPass.desktop.in.h:1
|
||||||
msgid "UTPass"
|
msgid "UTPass"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: ../qml/pages/headers/MainHeader.qml:23
|
#: ../qml/pages/headers/MainHeader.qml:26 ../qml/pages/settings/Settings.qml:68
|
||||||
msgid "Search"
|
|
||||||
msgstr ""
|
|
||||||
|
|
||||||
#: ../qml/pages/headers/MainHeader.qml:51 ../qml/pages/settings/Settings.qml:14
|
|
||||||
msgid "Settings"
|
msgid "Settings"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: ../qml/pages/settings/ImportGitClone.qml:15
|
#: ../qml/pages/headers/MainHeader.qml:57
|
||||||
msgid "Git Clone Import"
|
msgid "Search"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: ../qml/pages/settings/ImportGitClone.qml:36
|
#: ../qml/pages/settings/ImportGitClone.qml:36
|
||||||
msgid "Repo Url"
|
msgid "Repo Url"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: ../qml/pages/settings/ImportGitClone.qml:44
|
#: ../qml/pages/settings/ImportGitClone.qml:45
|
||||||
msgid "Git repo url"
|
msgid "Git repo url"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: ../qml/pages/settings/ImportGitClone.qml:50
|
#: ../qml/pages/settings/ImportGitClone.qml:52
|
||||||
msgid "Clone"
|
msgid "Clone"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
@ -129,85 +125,89 @@ msgid ""
|
|||||||
"<br>Continue ?"
|
"<br>Continue ?"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: ../qml/pages/settings/ImportGitClone.qml:78
|
#: ../qml/pages/settings/ImportGitClone.qml:80
|
||||||
msgid "An error occured during git clone !"
|
msgid "An error occured during git clone !"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: ../qml/pages/settings/ImportGitClone.qml:85
|
#: ../qml/pages/settings/ImportGitClone.qml:89
|
||||||
#: ../qml/pages/settings/ImportZip.qml:89
|
#: ../qml/pages/settings/ImportZip.qml:82
|
||||||
msgid "Password store sucessfully imported !"
|
msgid "Password store sucessfully imported !"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: ../qml/pages/settings/ImportKeyFile.qml:17
|
#: ../qml/pages/settings/ImportGitClone.qml:101
|
||||||
msgid "GPG Key Import"
|
msgid "Git Clone Import"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: ../qml/pages/settings/ImportKeyFile.qml:69
|
#: ../qml/pages/settings/ImportKeyFile.qml:57
|
||||||
msgid "Key import failed !"
|
msgid "Key import failed !"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: ../qml/pages/settings/ImportKeyFile.qml:76
|
#: ../qml/pages/settings/ImportKeyFile.qml:66
|
||||||
msgid "Key successfully imported !"
|
msgid "Key successfully imported !"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: ../qml/pages/settings/ImportZip.qml:17
|
#: ../qml/pages/settings/ImportKeyFile.qml:77
|
||||||
msgid "Zip Password Store Import"
|
msgid "GPG Key Import"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: ../qml/pages/settings/ImportZip.qml:72
|
#: ../qml/pages/settings/ImportZip.qml:61
|
||||||
msgid ""
|
msgid ""
|
||||||
"Importing a new zip will delete<br>any existing password store!<br>Continue ?"
|
"Importing a new zip will delete<br>any existing password store!<br>Continue ?"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: ../qml/pages/settings/ImportZip.qml:82
|
#: ../qml/pages/settings/ImportZip.qml:73
|
||||||
msgid "Password store import failed !"
|
msgid "Password store import failed !"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: ../qml/pages/settings/InfoKeys.qml:16
|
#: ../qml/pages/settings/ImportZip.qml:94
|
||||||
msgid "Info Keys"
|
msgid "Zip Password Store Import"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: ../qml/pages/settings/InfoKeys.qml:44
|
#: ../qml/pages/settings/InfoKeys.qml:40
|
||||||
msgid "Key id : %1"
|
msgid "Key id : %1"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: ../qml/pages/settings/InfoKeys.qml:49
|
#: ../qml/pages/settings/InfoKeys.qml:46
|
||||||
msgid "Delete this key"
|
msgid "Delete this key"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: ../qml/pages/settings/InfoKeys.qml:68
|
#: ../qml/pages/settings/InfoKeys.qml:67
|
||||||
msgid "You're are about to delete<br>%1<br>Continue ?"
|
msgid "You're are about to delete<br>%1<br>Continue ?"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: ../qml/pages/settings/InfoKeys.qml:71
|
#: ../qml/pages/settings/InfoKeys.qml:68
|
||||||
msgid "%1<br>will be definitively removed.<br>Continue ?"
|
msgid "%1<br>will be definitively removed.<br>Continue ?"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: ../qml/pages/settings/InfoKeys.qml:87
|
#: ../qml/pages/settings/InfoKeys.qml:84
|
||||||
msgid "Key removal failed !"
|
msgid "Key removal failed !"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: ../qml/pages/settings/InfoKeys.qml:94
|
#: ../qml/pages/settings/InfoKeys.qml:93
|
||||||
msgid "Key successfully deleted !"
|
msgid "Key successfully deleted !"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: ../qml/pages/settings/Settings.qml:28
|
#: ../qml/pages/settings/InfoKeys.qml:104
|
||||||
|
msgid "Info Keys"
|
||||||
|
msgstr ""
|
||||||
|
|
||||||
|
#: ../qml/pages/settings/Settings.qml:23
|
||||||
msgid "GPG"
|
msgid "GPG"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: ../qml/pages/settings/Settings.qml:32
|
#: ../qml/pages/settings/Settings.qml:28
|
||||||
msgid "Import a GPG key file"
|
msgid "Import a GPG key file"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: ../qml/pages/settings/Settings.qml:36
|
#: ../qml/pages/settings/Settings.qml:33
|
||||||
msgid "Show GPG keys"
|
msgid "Show GPG keys"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: ../qml/pages/settings/Settings.qml:43
|
#: ../qml/pages/settings/Settings.qml:41
|
||||||
msgid "Password Store"
|
msgid "Password Store"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: ../qml/pages/settings/Settings.qml:47
|
#: ../qml/pages/settings/Settings.qml:46
|
||||||
msgid "Import a Password Store using Git"
|
msgid "Import a Password Store using Git"
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
|
BIN
tests/assets/archive.zip
Normal file
BIN
tests/assets/archive.zip
Normal file
Binary file not shown.
1
tests/assets/gpg/passphrase.txt
Normal file
1
tests/assets/gpg/passphrase.txt
Normal file
@ -0,0 +1 @@
|
|||||||
|
utpasspassphrase
|
BIN
tests/assets/gpg/test_key.gpg
Normal file
BIN
tests/assets/gpg/test_key.gpg
Normal file
Binary file not shown.
1
tests/assets/password-store/.gitattributes
vendored
Normal file
1
tests/assets/password-store/.gitattributes
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
*.gpg diff=gpg
|
1
tests/assets/password-store/.gpg-id
Normal file
1
tests/assets/password-store/.gpg-id
Normal file
@ -0,0 +1 @@
|
|||||||
|
UTPass Test
|
0
tests/assets/password-store/Test
Normal file
0
tests/assets/password-store/Test
Normal file
1
tests/assets/password-store/test.gpg
Normal file
1
tests/assets/password-store/test.gpg
Normal file
@ -0,0 +1 @@
|
|||||||
|
└^ШзАщн8m@%f#▄≥┌б╧┌пмnW▐[qЬ╜┴Xз&ч>&MO`0жБ@
o▀▓(М≤R▒╖└+-В┌щ╧ 'ZHБ╗╖╤лEЗfКцJ╧Nxаь⌠8РтE ⌠з│W/°<┐-И7л#oJ╛dЭ≥7^т?аыHЫ4²H9└`kОdеwg╨d©╓Р9╣лА·ё▒x╫│╧Ж
|
1
tests/plugins/CMakeLists.txt
Normal file
1
tests/plugins/CMakeLists.txt
Normal file
@ -0,0 +1 @@
|
|||||||
|
add_subdirectory(TestsUtils)
|
29
tests/plugins/TestsUtils/CMakeLists.txt
Normal file
29
tests/plugins/TestsUtils/CMakeLists.txt
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
|
||||||
|
set(PLUGIN "TestsUtils")
|
||||||
|
|
||||||
|
set(
|
||||||
|
SRC
|
||||||
|
plugin.cpp
|
||||||
|
utils.cpp
|
||||||
|
)
|
||||||
|
|
||||||
|
set(CMAKE_AUTOMOC ON)
|
||||||
|
|
||||||
|
execute_process(
|
||||||
|
COMMAND dpkg-architecture -qDEB_HOST_MULTIARCH
|
||||||
|
OUTPUT_VARIABLE ARCH_TRIPLET
|
||||||
|
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||||
|
)
|
||||||
|
|
||||||
|
if(ARCH_TRIPLET STREQUAL "")
|
||||||
|
set(ARCH_TRIPLET x86_64-linux-gnu)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
add_library(${PLUGIN} MODULE ${SRC})
|
||||||
|
set_target_properties(${PLUGIN} PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${PLUGIN})
|
||||||
|
qt5_use_modules(${PLUGIN} Qml Quick DBus)
|
||||||
|
|
||||||
|
set(QT_IMPORTS_DIR "/lib/${ARCH_TRIPLET}")
|
||||||
|
|
||||||
|
install(TARGETS ${PLUGIN} DESTINATION ${QT_IMPORTS_DIR}/${PLUGIN}/)
|
||||||
|
install(FILES qmldir DESTINATION ${QT_IMPORTS_DIR}/${PLUGIN}/)
|
10
tests/plugins/TestsUtils/plugin.cpp
Normal file
10
tests/plugins/TestsUtils/plugin.cpp
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
#include <QtQml>
|
||||||
|
|
||||||
|
#include "plugin.h"
|
||||||
|
#include "utils.h"
|
||||||
|
|
||||||
|
void TestsUtilsPlugin::registerTypes(const char *uri)
|
||||||
|
{
|
||||||
|
//@uri TestUtils
|
||||||
|
qmlRegisterSingletonType<TestsUtilsPlugin>(uri, 1, 0, "TestUtils", [](QQmlEngine *, QJSEngine *) -> QObject * { return new TestsUtils; });
|
||||||
|
}
|
16
tests/plugins/TestsUtils/plugin.h
Normal file
16
tests/plugins/TestsUtils/plugin.h
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
#ifndef TESTSUTILSPLUGIN_H
|
||||||
|
#define TESTSUTILSPLUGIN_H
|
||||||
|
|
||||||
|
#include <QQmlExtensionPlugin>
|
||||||
|
|
||||||
|
class TestsUtilsPlugin : public QQmlExtensionPlugin
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
Q_PLUGIN_METADATA(IID
|
||||||
|
"org.qt-project.Qt.QQmlExtensionInterface")
|
||||||
|
|
||||||
|
public:
|
||||||
|
void registerTypes(const char *uri) override;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
2
tests/plugins/TestsUtils/qmldir
Normal file
2
tests/plugins/TestsUtils/qmldir
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
module TestUtils
|
||||||
|
plugin TestUtils
|
37
tests/plugins/TestsUtils/utils.cpp
Normal file
37
tests/plugins/TestsUtils/utils.cpp
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
#include <QFile>
|
||||||
|
#include <QDir>
|
||||||
|
#include <QUrl>
|
||||||
|
#include <QUuid>
|
||||||
|
#include <QtCore/QStandardPaths>
|
||||||
|
#include <quazip5/JlCompress.h>
|
||||||
|
|
||||||
|
#include "utils.h"
|
||||||
|
|
||||||
|
|
||||||
|
QString TestsUtils::getTempPath() {
|
||||||
|
qFatal("yp");
|
||||||
|
// Get the system's temporary directory
|
||||||
|
QString tempDir = QStandardPaths::writableLocation(QStandardPaths::CacheLocation);
|
||||||
|
qDebug() << "TempDir : " << tempDir;
|
||||||
|
|
||||||
|
// Generate a unique UUID
|
||||||
|
QString uuid = QUuid::createUuid().toString(QUuid::WithoutBraces);
|
||||||
|
|
||||||
|
// Create a new directory using the generated UUID
|
||||||
|
QString newTempDir = tempDir + "/" + uuid;
|
||||||
|
|
||||||
|
QDir dir;
|
||||||
|
if (!dir.exists(newTempDir)) {
|
||||||
|
// Create the directory
|
||||||
|
if (dir.mkpath(newTempDir)) {
|
||||||
|
return newTempDir; // Return the path if successful
|
||||||
|
} else {
|
||||||
|
return "Failed to create directory"; // Return an error message
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return newTempDir; // If the directory already exists, return its path
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
19
tests/plugins/TestsUtils/utils.h
Normal file
19
tests/plugins/TestsUtils/utils.h
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
#ifndef TESTSUTILS_H
|
||||||
|
#define TESTSUTILS_H
|
||||||
|
|
||||||
|
#include <QObject>
|
||||||
|
#include <QUrl>
|
||||||
|
#include <QQuickWindow>
|
||||||
|
|
||||||
|
class TestsUtils : public QObject
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
TestsUtils() = default;
|
||||||
|
~TestsUtils() override = default;
|
||||||
|
|
||||||
|
Q_INVOKABLE QString getTempPath();
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
12
tests/unit/tst_git.qml
Normal file
12
tests/unit/tst_git.qml
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
import QtQuick 2.9
|
||||||
|
import QtTest 1.2
|
||||||
|
import Git 1.0
|
||||||
|
|
||||||
|
TestCase {
|
||||||
|
name: "git"
|
||||||
|
|
||||||
|
function test_git_clone() {
|
||||||
|
|
||||||
|
verify(Git.clone("",""));
|
||||||
|
}
|
||||||
|
}
|
12
tests/unit/tst_pass.qml
Normal file
12
tests/unit/tst_pass.qml
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
import QtQuick 2.9
|
||||||
|
import QtTest 1.2
|
||||||
|
import Git 1.0
|
||||||
|
|
||||||
|
TestCase {
|
||||||
|
name: "git"
|
||||||
|
|
||||||
|
function test_git_clone() {
|
||||||
|
|
||||||
|
verify(Git.clone("",""));
|
||||||
|
}
|
||||||
|
}
|
15
tests/unit/tst_utils.qml
Normal file
15
tests/unit/tst_utils.qml
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
import QtQuick 2.9
|
||||||
|
import QtTest 1.2
|
||||||
|
import TestUtils 1.0
|
||||||
|
import Utils 1.0
|
||||||
|
|
||||||
|
TestCase {
|
||||||
|
name: "utils"
|
||||||
|
|
||||||
|
function test_unzip() {
|
||||||
|
var tempPath = TestUtils.getTempPath() + "/password-store";
|
||||||
|
var zipUrl = Qt.resolvedUrl("../assets/archive.zip");
|
||||||
|
var r = Utils.unzip(zipUrl, tempPath)
|
||||||
|
verify(r, "Unzip return an error %1".arg(zipUrl))
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user