aboutsummaryrefslogtreecommitdiffstats
path: root/src/test
diff options
context:
space:
mode:
authorsaturneric <[email protected]>2024-07-26 16:24:34 +0000
committersaturneric <[email protected]>2024-07-26 16:24:34 +0000
commit37a62a8d0b590710b902376ca3320cc05e954b63 (patch)
tree349ecff21e5cf53d8eedbae7886404417ecdad05 /src/test
parentfix: correct urls at appdata.xml (diff)
downloadGpgFrontend-37a62a8d0b590710b902376ca3320cc05e954b63.tar.gz
GpgFrontend-37a62a8d0b590710b902376ca3320cc05e954b63.zip
feat: remove spdlog and clean up log
Diffstat (limited to 'src/test')
-rw-r--r--src/test/CMakeLists.txt11
-rw-r--r--src/test/GpgFrontendTest.cpp11
-rw-r--r--src/test/GpgFrontendTest.h15
3 files changed, 23 insertions, 14 deletions
diff --git a/src/test/CMakeLists.txt b/src/test/CMakeLists.txt
index 221483dc..0ad259bd 100644
--- a/src/test/CMakeLists.txt
+++ b/src/test/CMakeLists.txt
@@ -28,14 +28,23 @@
aux_source_directory(./core TEST_SOURCE)
aux_source_directory(. TEST_SOURCE)
+
+# define test library
add_library(gpgfrontend_test SHARED ${TEST_SOURCE})
+# generate headers
set(_export_file "${CMAKE_CURRENT_SOURCE_DIR}/GpgFrontendTestExport.h")
generate_export_header(gpgfrontend_test EXPORT_FILE_NAME "${_export_file}")
+# compile definitions
+target_compile_definitions(gpgfrontend_test PUBLIC GF_TEST)
+
+
+# link options
+
target_link_libraries(gpgfrontend_test PRIVATE gtest)
+
target_link_libraries(gpgfrontend_test PRIVATE gpgfrontend_core)
-target_link_libraries(gpgfrontend_test PRIVATE spdlog)
if (XCODE_BUILD)
set_target_properties(gpgfrontend_test
diff --git a/src/test/GpgFrontendTest.cpp b/src/test/GpgFrontendTest.cpp
index 95b4179a..2ad7ada7 100644
--- a/src/test/GpgFrontendTest.cpp
+++ b/src/test/GpgFrontendTest.cpp
@@ -29,6 +29,7 @@
#include "GpgFrontendTest.h"
#include <gtest/gtest.h>
+#include <qglobal.h>
#include "core/GpgConstants.h"
#include "core/function/GlobalSettingStation.h"
@@ -37,6 +38,8 @@
#include "core/function/gpg/GpgKeyImportExporter.h"
#include "core/utils/IOUtils.h"
+Q_LOGGING_CATEGORY(test, "test")
+
namespace GpgFrontend::Test {
auto GenerateRandomString(size_t length) -> QString {
@@ -56,8 +59,6 @@ auto GenerateRandomString(size_t length) -> QString {
void ConfigureGpgContext() {
auto db_path = QDir(QDir::tempPath() + "/" + GenerateRandomString(12));
- GF_TEST_LOG_DEBUG("setting up new database path for test case: {}",
- db_path.path());
if (db_path.exists()) db_path.rmdir(".");
db_path.mkpath(".");
@@ -84,7 +85,7 @@ void ImportPrivateKeys(const QString& data_path, QSettings settings) {
GpgKeyImportExporter::GetInstance(kGpgFrontendDefaultChannel)
.ImportKey(gf_buffer);
} else {
- GF_TEST_LOG_ERROR("read from key file failed: {}", key_file);
+ qCWarning(test) << "read from key file failed: " << key_file;
}
}
}
@@ -95,8 +96,8 @@ void SetupGlobalTestEnv() {
auto test_config_path = test_path + "/conf/test.ini";
auto test_data_path = test_path + "/data";
- GF_TEST_LOG_INFO("test config file path: {}", test_config_path);
- GF_TEST_LOG_INFO("test data file path: {}", test_data_path);
+ qCInfo(test) << "test config file path: " << test_config_path;
+ qCInfo(test) << "test data file path: " << test_data_path;
ImportPrivateKeys(test_data_path,
QSettings(test_config_path, QSettings::IniFormat));
diff --git a/src/test/GpgFrontendTest.h b/src/test/GpgFrontendTest.h
index 405eee90..3c1ecbfd 100644
--- a/src/test/GpgFrontendTest.h
+++ b/src/test/GpgFrontendTest.h
@@ -30,8 +30,13 @@
#include "GpgFrontendTestExport.h"
-// Core
-#include "core/utils/LogUtils.h"
+// declare area of test
+#ifdef GF_TEST
+
+// declare logging category
+Q_DECLARE_LOGGING_CATEGORY(test)
+
+#endif
namespace GpgFrontend::Test {
@@ -42,10 +47,4 @@ struct GpgFrontendContext {
auto GPGFRONTEND_TEST_EXPORT ExecuteAllTestCase(GpgFrontendContext args) -> int;
-#define GF_TEST_LOG_TRACE(...) GF_LOG_TRACE("test", __VA_ARGS__)
-#define GF_TEST_LOG_DEBUG(...) GF_LOG_DEBUG("test", __VA_ARGS__)
-#define GF_TEST_LOG_INFO(...) GF_LOG_INFO("test", __VA_ARGS__)
-#define GF_TEST_LOG_WARN(...) GF_LOG_WARN("test", __VA_ARGS__)
-#define GF_TEST_LOG_ERROR(...) GF_LOG_ERROR("test", __VA_ARGS__)
-
} // namespace GpgFrontend::Test