Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions reader/MainWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -292,6 +293,7 @@ void MainWindow::initUI()
handleMainWindowFull();
}
});
// LCOV_EXCL_STOP
#endif

#if _ZPD_
Expand Down
4 changes: 4 additions & 0 deletions reader/load_libs.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,12 @@
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
#include <string.h>

Check warning on line 26 in reader/load_libs.c

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <string.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.

#include <dlfcn.h>

Check warning on line 28 in reader/load_libs.c

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <dlfcn.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
// LCOV_EXCL_START
void PrintError(){
char *error;

Check warning on line 31 in reader/load_libs.c

View workflow job for this annotation

GitHub Actions / cppcheck

Variable 'error' can be declared as pointer to const
if ((error = dlerror()) != NULL) {
fprintf (stderr, "%s ", error);
}
Expand Down Expand Up @@ -71,12 +72,14 @@
assert(pLibs != NULL);
return pLibs;
}
// LCOV_EXCL_STOP

/**
* 饿汉式
* 支持延迟加载,但是为了多线程安全,性能有所降低
* 注意:方法内部要加锁,防止多线程多次创建
* */
// LCOV_EXCL_START
LoadLibs *getLoadLibsInstance()
{
static pthread_mutex_t mutex;
Expand All @@ -102,8 +105,9 @@

return pLibs;
}
// LCOV_EXCL_STOP

void setLibNames(LoadLibNames tmp)

Check warning on line 110 in reader/load_libs.c

View workflow job for this annotation

GitHub Actions / cppcheck

The function 'setLibNames' is never used.
{
fprintf(stderr, "INFO: Setting library names\n");
if(tmp.chDocumentPr == NULL) {
Expand Down
6 changes: 4 additions & 2 deletions reader/logger.cpp
Original file line number Diff line number Diff line change
@@ -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"
Expand Down Expand Up @@ -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
Expand Down
8 changes: 8 additions & 0 deletions tests/ut_application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
49 changes: 49 additions & 0 deletions tests/ut_mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,13 @@
// SPDX-License-Identifier: GPL-3.0-or-later

#include "MainWindow.h"
#include "DocSheet.h"

Check warning on line 7 in tests/ut_mainwindow.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: "DocSheet.h" not found.
#include "Application.h"

Check warning on line 8 in tests/ut_mainwindow.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: "Application.h" not found.
#include "SheetRenderer.h"

Check warning on line 9 in tests/ut_mainwindow.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: "SheetRenderer.h" not found.
#include "Central.h"

Check warning on line 10 in tests/ut_mainwindow.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: "Central.h" not found.
#include "CentralDocPage.h"

Check warning on line 11 in tests/ut_mainwindow.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: "CentralDocPage.h" not found.

#include <DGuiApplicationHelper>

Check warning on line 13 in tests/ut_mainwindow.cpp

View workflow job for this annotation

GitHub Actions / cppcheck

Include file: <DGuiApplicationHelper> not found. Please note: Cppcheck does not need standard library headers to get proper results.

#include <QTimer>
#include <QCloseEvent>
Expand Down Expand Up @@ -217,3 +221,48 @@
{
m_tester->updateOrderWidgets(QList<QWidget *>());
}

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();
}
Loading