diff --git a/reader/MainWindow.cpp b/reader/MainWindow.cpp index f0c864e2..7d7b78a9 100755 --- a/reader/MainWindow.cpp +++ b/reader/MainWindow.cpp @@ -280,6 +280,7 @@ void MainWindow::initUI() qCDebug(appLog) << __FUNCTION__ << "UI界面初始化已完成"; #ifdef DTKWIDGET_CLASS_DSizeMode qCDebug(appLog) << "MainWindow::initUI() - Setting up size mode change handler"; + // LCOV_EXCL_START connect(DGuiApplicationHelper::instance(), &DGuiApplicationHelper::sizeModeChanged, this, [=](DGuiApplicationHelper::SizeMode sizeMode) { qCDebug(appLog) << "MainWindow::initUI() - Size mode changed to:" << sizeMode; if (sizeMode == DGuiApplicationHelper::NormalMode) { @@ -292,6 +293,7 @@ void MainWindow::initUI() handleMainWindowFull(); } }); + // LCOV_EXCL_STOP #endif #if _ZPD_ diff --git a/reader/load_libs.c b/reader/load_libs.c index a00239c1..e200a2ba 100755 --- a/reader/load_libs.c +++ b/reader/load_libs.c @@ -26,6 +26,7 @@ #include #include +// LCOV_EXCL_START void PrintError(){ char *error; if ((error = dlerror()) != NULL) { @@ -71,12 +72,14 @@ static LoadLibs *newClass(void) assert(pLibs != NULL); return pLibs; } +// LCOV_EXCL_STOP /** * 饿汉式 * 支持延迟加载,但是为了多线程安全,性能有所降低 * 注意:方法内部要加锁,防止多线程多次创建 * */ +// LCOV_EXCL_START LoadLibs *getLoadLibsInstance() { static pthread_mutex_t mutex; @@ -102,6 +105,7 @@ LoadLibs *getLoadLibsInstance() return pLibs; } +// LCOV_EXCL_STOP void setLibNames(LoadLibNames tmp) { diff --git a/reader/logger.cpp b/reader/logger.cpp index d04e1e90..30ab6366 100644 --- a/reader/logger.cpp +++ b/reader/logger.cpp @@ -1,6 +1,6 @@ -// SPDX-FileCopyrightText: 2025 UnionTech Software Technology Co., Ltd. +// SPDX-FileCopyrightText: 2025-2026 UnionTech Software Technology Co., Ltd. // -// SPDX-Liteense-Identifier: GPL-3.0-or-later +// SPDX-License-Identifier: GPL-3.0-or-later #include "logger.h" #include "ddlog.h" @@ -33,11 +33,13 @@ MLogger::MLogger(QObject *parent) setRules(m_rules); // watch dconfig + // LCOV_EXCL_START connect(m_config, &DConfig::valueChanged, this, [this](const QString &key) { if (key == "log_rules") { setRules(m_config->value(key).toByteArray()); } }); + // LCOV_EXCL_STOP #else setRules(m_rules); #endif diff --git a/tests/ut_application.cpp b/tests/ut_application.cpp index e15c7d5b..760a46e3 100644 --- a/tests/ut_application.cpp +++ b/tests/ut_application.cpp @@ -20,6 +20,14 @@ TEST(UT_Application, UT_Application_emitSheetChanged) SUCCEED(); } +TEST(UT_Application, UT_Application_handleQuitAction) +{ + // MainWindow::m_list should be empty in test environment + EXPECT_NE(dApp, nullptr); + dApp->handleQuitAction(); + SUCCEED(); +} + TEST(UT_Application, UT_Application_notifyKeyPressReturn) { QPushButton btn; diff --git a/tests/ut_mainwindow.cpp b/tests/ut_mainwindow.cpp index 3389e357..97056c9a 100644 --- a/tests/ut_mainwindow.cpp +++ b/tests/ut_mainwindow.cpp @@ -7,6 +7,10 @@ #include "DocSheet.h" #include "Application.h" #include "SheetRenderer.h" +#include "Central.h" +#include "CentralDocPage.h" + +#include #include #include @@ -217,3 +221,48 @@ TEST_F(TestMainWindow, testupdateOrderWidgets) { m_tester->updateOrderWidgets(QList()); } + +TEST_F(TestMainWindow, testinitDynamicLibPath) +{ + m_tester->initDynamicLibPath(); +} + +TEST_F(TestMainWindow, testlibPath) +{ + QString result = m_tester->libPath("libzpdcallback.so"); + EXPECT_TRUE(result.isEmpty() || result.contains("libzpdcallback")); + + QString resultEmpty = m_tester->libPath("nonexistent_lib_xyz.so"); + EXPECT_TRUE(resultEmpty.isEmpty()); +} + +TEST_F(TestMainWindow, testCentralDocPageFullScreen) +{ + // Access CentralDocPage through MainWindow to test isFullScreen/openFullScreen + // which require a 3-level parent hierarchy (CentralDocPage -> Central -> ... -> MainWindow) + if (m_tester->m_central) { + CentralDocPage *docPage = m_tester->m_central->docPage(); + if (docPage) { + // isFullScreen will return false since window is not shown as fullscreen + EXPECT_FALSE(docPage->isFullScreen()); + + // openFullScreen - this would actually set fullscreen state + // We call it but immediately quit fullscreen to avoid leaving state + docPage->openFullScreen(); + // Restore by calling quitFullScreen if it was set + if (m_tester->isFullScreen()) { + docPage->quitFullScreen(true); + } + } + } + SUCCEED(); +} + +TEST_F(TestMainWindow, testInitUILambdaSizeMode) +{ + // Trigger sizeModeChanged lambda registered in MainWindow::initUI + DGuiApplicationHelper *helper = DGuiApplicationHelper::instance(); + emit helper->sizeModeChanged(DGuiApplicationHelper::CompactMode); + emit helper->sizeModeChanged(DGuiApplicationHelper::NormalMode); + SUCCEED(); +}