mirror of
https://github.com/linuxdeepin/dde-dock.git
synced 2025-06-04 17:33:05 +00:00
test: 添加任务栏配置插件部分的单元测试代码
添加任务栏配置插件部分的单元测试代码 Log: Task: https://pms.uniontech.com/zentao/task-view-86362.html Change-Id: Ia3b52a70e53a01e085bbab6ae142244949758aaa
This commit is contained in:
parent
bd244e8f3d
commit
95243706b4
@ -221,5 +221,7 @@ void ModuleWidget::updateSliderValue(int displayMode)
|
||||
m_sizeSlider->setValueLiteral(QString::number(m_daemonDockInter->windowSizeFashion()));
|
||||
} else if (displayMode == DisplayMode::Efficient) {
|
||||
m_sizeSlider->setValueLiteral(QString::number(m_daemonDockInter->windowSizeEfficient()));
|
||||
} else {
|
||||
Q_ASSERT_X(false, __FILE__, "not supported");
|
||||
}
|
||||
}
|
||||
|
@ -20,9 +20,14 @@ file(GLOB_RECURSE PLUGIN_SRCS
|
||||
"../plugins/bluetooth/*.cpp"
|
||||
"../plugins/bluetooth/componments/*.h"
|
||||
"../plugins/bluetooth/componments/*.cpp"
|
||||
"../plugins/dcc-dock-settings-plugin/*.h"
|
||||
"../plugins/dcc-dock-settings-plugin/*.cpp"
|
||||
"../frame/util/horizontalseperator.h"
|
||||
"../frame/util/horizontalseperator.cpp")
|
||||
|
||||
# 其包含的"interface/moduleinterface.h"文件中定义了ModuleInterface_iid,任务栏插件框架的interface文件中也有定义
|
||||
list(FILTER PLUGIN_SRCS EXCLUDE REGEX "../plugins/dcc-dock-settings-plugin/settings_module.*")
|
||||
|
||||
# 用于测试覆盖率的编译条件
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fprofile-arcs -ftest-coverage -lgcov")
|
||||
|
||||
@ -43,6 +48,7 @@ find_package(Qt5DBus REQUIRED)
|
||||
find_package(DtkWidget REQUIRED)
|
||||
find_package(Qt5Svg REQUIRED)
|
||||
find_package(Qt5 COMPONENTS Test REQUIRED)
|
||||
find_package(DdeControlCenter REQUIRED)
|
||||
find_package(GTest REQUIRED)
|
||||
find_package(GMock REQUIRED)
|
||||
|
||||
@ -66,10 +72,12 @@ target_include_directories(${BIN_NAME} PUBLIC
|
||||
${DFrameworkDBus_INCLUDE_DIRS}
|
||||
${Qt5Gui_PRIVATE_INCLUDE_DIRS}
|
||||
${QGSettings_INCLUDE_DIRS}
|
||||
${DdeControlCenter_INCLUDE_DIR}
|
||||
../interfaces
|
||||
fakedbus
|
||||
../plugins/bluetooth
|
||||
../plugins/bluetooth/componments
|
||||
../plugins/dcc-dock-settings-plugin
|
||||
)
|
||||
|
||||
# 链接库
|
||||
@ -84,6 +92,7 @@ target_link_libraries(${BIN_NAME} PRIVATE
|
||||
${Qt5DBus_LIBRARIES}
|
||||
${QGSettings_LIBRARIES}
|
||||
${Qt5Svg_LIBRARIES}
|
||||
${DdeControlCenter_LIBRARIES}
|
||||
${GTEST_LIBRARIES}
|
||||
${GMOCK_LIBRARIES}
|
||||
-lpthread
|
||||
|
@ -0,0 +1,40 @@
|
||||
#include "gsetting_watcher.h"
|
||||
|
||||
#include <QWidget>
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
class Test_GSettingWatcher : public QObject, public ::testing::Test
|
||||
{};
|
||||
|
||||
TEST_F(Test_GSettingWatcher, bind)
|
||||
{
|
||||
GSettingWatcher watcher("com.deepin.dde.control-center", "personalization");
|
||||
|
||||
QWidget widget;
|
||||
watcher.bind("displayMode", &widget);
|
||||
watcher.bind("displayMode", nullptr);
|
||||
watcher.bind("invalid", &widget);
|
||||
watcher.bind("", &widget);
|
||||
watcher.bind("", nullptr);
|
||||
}
|
||||
|
||||
TEST_F(Test_GSettingWatcher, setStatus)
|
||||
{
|
||||
GSettingWatcher watcher("com.deepin.dde.control-center", "personalization");
|
||||
|
||||
QWidget widget;
|
||||
watcher.bind("displayMode", &widget);
|
||||
watcher.setStatus("displayMode", &widget);
|
||||
}
|
||||
|
||||
TEST_F(Test_GSettingWatcher, onStatusModeChanged)
|
||||
{
|
||||
GSettingWatcher watcher("com.deepin.dde.control-center", "personalization");
|
||||
|
||||
QWidget widget;
|
||||
watcher.bind("displayMode", &widget);
|
||||
watcher.onStatusModeChanged("displayMode");
|
||||
watcher.onStatusModeChanged("invalid");
|
||||
watcher.onStatusModeChanged("");
|
||||
}
|
24
tests/plugins/dcc-dock-settings-plugin/ut_module_widget.cpp
Normal file
24
tests/plugins/dcc-dock-settings-plugin/ut_module_widget.cpp
Normal file
@ -0,0 +1,24 @@
|
||||
#include "module_widget.h"
|
||||
|
||||
#include <QWidget>
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
class Test_ModuleWidget : public QObject, public ::testing::Test
|
||||
{};
|
||||
|
||||
TEST(Test_ModuleWidget_DeathTest, updateSliderValue)
|
||||
{
|
||||
ModuleWidget widget;
|
||||
#ifdef QT_DEBUG
|
||||
EXPECT_DEBUG_DEATH({widget.updateSliderValue(-1);}, "");
|
||||
#endif
|
||||
}
|
||||
|
||||
TEST_F(Test_ModuleWidget, updateSliderValue)
|
||||
{
|
||||
ModuleWidget widget;
|
||||
|
||||
widget.updateSliderValue(0);
|
||||
widget.updateSliderValue(1);
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user