test(frame): add GTest unit tests for core framework classes (100 tests) - #1703
test(frame): add GTest unit tests for core framework classes (100 tests)#1703MyLeeJiEun wants to merge 2 commits into
Conversation
1. Add 74 GTest unit tests covering 6 frame/ core classes 2. Cover DPluginMetaData, DAppletData, DAppletItemModel 3. Cover KExtraColumnsProxyModel, ListToTableProxyModel, DAppletFactory 4. Use OBJECT lib frame_test_objects linked into 5 test executables 5. Add FRAME_BUILD_COVERAGE option and frame_coverage target 6. Gate tests behind BUILD_TESTING following taskmanager pattern 7. frame/ core framework had zero test coverage before this change Influence: 1. Run ctest -R '^frame_' to execute all 74 unit tests 2. Enable FRAME_BUILD_COVERAGE=ON and build frame_coverage target 3. Verify coverage report at build/frame_coverage/html/index.html test(frame): 为6个核心类添加GTest单元测试 1. 为 frame/ 6 个核心类添加 74 个 GTest 单元测试 2. 覆盖 DPluginMetaData、DAppletData、DAppletItemModel 3. 覆盖 KExtraColumnsProxyModel、ListToTableProxyModel、DAppletFactory 4. 通过 OBJECT 库 frame_test_objects 链入 5 个测试可执行 5. 新增 FRAME_BUILD_COVERAGE 选项与 frame_coverage target 6. 以 BUILD_TESTING 门控,沿用 taskmanager 的 gtest_discover_tests 模式 7. frame/ 核心框架此前测试覆盖为零 Influence: 1. 通过 ctest -R '^frame_' 运行全部 74 个单元测试 2. 启用 FRAME_BUILD_COVERAGE=ON 并构建 frame_coverage target 3. 在 build/frame_coverage/html/index.html 查看覆盖率报告
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: MyLeeJiEun The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
|
Hi @MyLeeJiEun. Thanks for your PR. I'm waiting for a linuxdeepin member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
Reviewer's GuideAdds a new GTest-based unit test suite for dde-shell's frame/ core framework (6 core classes, 74 tests), wired via a new tests/frame CMake subtree that builds a shared OBJECT library for the frame sources, defines five test executables, and optionally provides an lcov/genhtml-based coverage target. File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
1. Add 26 GTest unit tests for 4 more frame/ core classes 2. Cover dstypes, applet, appletproxy, dsutility (Batch N+1) 3. Extend OBJECT lib with 4 sources + link Dtk6::Core and Qt6::Gui 4. Add 4 test executables types/applet/appletproxy/utility tests 5. Force-include qguiapplication.h for dsutility.cpp workaround 6. Brings frame/ coverage to 100 tests across 10 core classes Influence: 1. Run ctest -R '^frame_' to execute all 100 unit tests 2. Build requires DTK6 Core + Qt6 Gui (dsutility uses QGuiApplication) 3. utility_tests runs offscreen QGuiApplication via global environment test(frame): 为4个核心类新增GTest单元测试 1. 为 4 个 frame/ 核心类新增 26 个 GTest 单元测试 2. 覆盖 dstypes、applet、appletproxy、dsutility(Batch N+1) 3. OBJECT 库追加 4 源并链接 Dtk6::Core 与 Qt6::Gui 4. 新增 4 个测试可执行 types/applet/appletproxy/utility tests 5. 为 dsutility.cpp 强制包含 qguiapplication.h 规避编译 6. frame/ 覆盖增至 100 测试,覆盖 10 个核心类 Influence: 1. 通过 ctest -R '^frame_' 运行全部 100 个单元测试 2. 构建需 DTK6 Core 与 Qt6 Gui(dsutility 使用 QGuiApplication) 3. utility_tests 经全局测试环境运行 offscreen QGuiApplication
Summary
Adds 100 GTest unit tests for the
frame/core framework of dde-shell, which previously had zero test coverage. Delivered in two batches on this single branch.Test scope (10 core classes, 100 tests)
Batch 1 (74 tests):
DPluginMetaDataframe/pluginmetadata.cppDAppletDataframe/appletdata.cppDAppletItemModelframe/appletitemmodel.cppKExtraColumnsProxyModelframe/models/kextracolumnsproxymodel.cppListToTableProxyModelframe/models/listtotableproxymodel.cppDAppletFactoryframe/pluginfactory.cppBatch N+1 (26 tests):
Typesframe/dstypes.cppDAppletframe/applet.cppDAppletMetaProxyframe/appletproxy.cppUtilityframe/dsutility.cpp(base, non-X11)All 100 tests pass (0 failed / 0 skipped / 0 crash) on Qt 6.8 + GTest 1.12.1 + GCC 12.3 + DTK6 Core. The remaining 17
frame/.cpp files were assessed as not unit-testable without a mock framework or a Wayland/X11 runtime (globalDPluginLoadersingleton, QML engine, or Qt/Wayland private APIs) and are out of scope for this PR.Build
Sources under test are compiled once into a single OBJECT library
frame_test_objects, linked into the 9 test executables.utility_testsspins up an offscreenQGuiApplicationvia a GTest global test environment (QT_QPA_PLATFORM=offscreen), so no X11/Wayland runtime is required.Coverage
Enable coverage through the build-system target:
cmake -B build -DBUILD_TESTING=ON -DFRAME_BUILD_COVERAGE=ON -DCMAKE_BUILD_TYPE=Debug cmake --build build --target frame_coverage # report: build/frame_coverage/html/index.htmllcov results (generated code excluded):
Every covered source file has line coverage ≥ 80% (e.g. applet 84.7% / appletproxy 89.5% / dstypes 100% / dsutility 90.6%, plus Batch 1 files). Branch coverage is below 70% exclusively due to structurally unreachable branches; all reachable branches are essentially fully covered:
fromJsonStringdead code inframe/pluginmetadata.cpp— a src defect:QJsonParseErroris declared but never passed toQJsonDocument::fromJson, soif(error.error)is always false. Tracked for the maintainers in DDE-132.dsutility.cppmissing direct#include <QGuiApplication>robustness gap → DDE-141 (test-side forced-include workaround applied here; removable once src is fixed).Q_ASSERTabort branches (~9 sites inkextracolumnsproxymodel.cpp) — triggering aborts the process, unreachable on normal paths.QExplicitlySharedDataPointer::operator=/detachif(d)template false branches —dis always non-null after construction.DAppletItemModel::data/DAppletdefensive dead code (row >= size,if(m_rootObject)destructor false branch).Utility#ifdef BUILD_WITH_X11compile-excluded block (X11Utility path).KExtraColumnsProxyModelcombination-unreachable branches, plus lambda /metaObject()macro-expansion branch inflation.This PR does not modify
src/,debian/, or the top-levelCMakeLists.txt— tests only. Both src defects are tracked separately for the maintainers and are out of scope here.Notes
tests/panels/dock/taskmanagerpattern (BUILD_TESTINGgate +gtest_discover_tests), registered with aframe_ctest prefix soctest -R '^frame_'runs only this batch.Tracking issue: DDE-107 补充 dde-shell 项目测试代码