mirror of
https://github.com/linuxdeepin/dde-dock.git
synced 2025-06-04 09:23:03 +00:00
fix: 添加单元测试接口
This commit is contained in:
parent
52b5cfa1f4
commit
87298061c9
@ -13,6 +13,7 @@ find_package(PkgConfig REQUIRED)
|
||||
find_package(Qt5 COMPONENTS Test DBus REQUIRED)
|
||||
|
||||
pkg_check_modules(DFrameworkDBus REQUIRED dframeworkdbus)
|
||||
pkg_check_modules(QGSettings REQUIRED gsettings-qt)
|
||||
|
||||
# 添加执行文件信息
|
||||
add_executable(${BIN_NAME} ${SRCS} ${INTERFACES})
|
||||
@ -25,4 +26,5 @@ target_link_libraries(${BIN_NAME} PRIVATE
|
||||
${Qt5Test_LIBRARIES}
|
||||
${Qt5DBus_LIBRARIES}
|
||||
${DFrameworkDBus_LIBRARIES}
|
||||
${QGSettings_LIBRARIES}
|
||||
)
|
||||
|
@ -24,11 +24,14 @@
|
||||
#include <QDBusMetaType>
|
||||
#include <QDBusMessage>
|
||||
#include <QDBusArgument>
|
||||
#include <QGSettings/QGSettings>
|
||||
|
||||
#include <com_deepin_daemon_display.h>
|
||||
#include <com_deepin_dde_daemon_dock.h>
|
||||
|
||||
#include "dock_unit_test.h"
|
||||
|
||||
using DBusDock = com::deepin::dde::daemon::Dock;
|
||||
DockUnitTest::DockUnitTest()
|
||||
{
|
||||
qDBusRegisterMetaType<ScreenRect>();
|
||||
@ -77,6 +80,79 @@ void DockUnitTest::dock_geometry_check()
|
||||
|
||||
QCOMPARE(daemonDockRect, dockRect);
|
||||
}
|
||||
/**
|
||||
* @brief DockUnitTest::dock_position_check 比较Dbus和QGSettings获取的坐标信息是否一致
|
||||
*/
|
||||
void DockUnitTest::dock_position_check()
|
||||
{
|
||||
DBusDock *dockInter = new DBusDock("com.deepin.dde.daemon.Dock", "/com/deepin/dde/daemon/Dock", QDBusConnection::sessionBus(), this);
|
||||
int nPos = dockInter->position();
|
||||
QString postion = "";
|
||||
qDebug() << nPos;
|
||||
|
||||
switch (nPos) {
|
||||
case 0 :
|
||||
postion = "top";
|
||||
break;
|
||||
case 1:
|
||||
postion = "right";
|
||||
break;
|
||||
case 2:
|
||||
postion = "bottom";
|
||||
break;
|
||||
case 3:
|
||||
postion = "left";
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
QGSettings *setting = new QGSettings("com.deepin.dde.dock");
|
||||
if (setting->keys().contains("position")) {
|
||||
qDebug() << setting->get("position");
|
||||
QCOMPARE(postion,setting->get("position").toString());
|
||||
}
|
||||
}
|
||||
/**
|
||||
* @brief DockUnitTest::dock_displayMode_check 比较Dbus和QGSettings获取的显示模式是否一致
|
||||
*/
|
||||
void DockUnitTest::dock_displayMode_check()
|
||||
{
|
||||
DBusDock *dockInter = new DBusDock("com.deepin.dde.daemon.Dock", "/com/deepin/dde/daemon/Dock", QDBusConnection::sessionBus(), this);
|
||||
int nMode = dockInter->displayMode();
|
||||
QString displayMode = "";
|
||||
qDebug() << nMode;
|
||||
|
||||
switch (nMode) {
|
||||
case 0 :
|
||||
displayMode = "fashion";
|
||||
break;
|
||||
case 1:
|
||||
displayMode = "efficient";
|
||||
break;
|
||||
case 2:
|
||||
displayMode = "classic";
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
QGSettings *setting = new QGSettings("com.deepin.dde.dock");
|
||||
if (setting->keys().contains("displayMode")) {
|
||||
qDebug() << setting->get("displayMode");
|
||||
QCOMPARE(displayMode,setting->get("displayMode").toString());
|
||||
}
|
||||
}
|
||||
|
||||
void DockUnitTest::dock_appItemCount_check()
|
||||
{
|
||||
DBusDock *dockInter = new DBusDock("com.deepin.dde.daemon.Dock", "/com/deepin/dde/daemon/Dock", QDBusConnection::sessionBus(), this);
|
||||
qDebug() << dockInter->entries().size();
|
||||
for (auto inter : dockInter->entries()) {
|
||||
qDebug() << inter.path();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
QTEST_APPLESS_MAIN(DockUnitTest)
|
||||
|
||||
|
@ -32,9 +32,9 @@ public:
|
||||
|
||||
private slots:
|
||||
void dock_geometry_check(); // 显示区域
|
||||
// void dock_position_check(); // 位置检查
|
||||
// void dock_displayMode_check(); // 显示模式检查
|
||||
// void dock_appItemCount_check(); // 应用显示数量检查
|
||||
void dock_position_check(); // 位置检查
|
||||
void dock_displayMode_check(); // 显示模式检查
|
||||
void dock_appItemCount_check(); // 应用显示数量检查
|
||||
};
|
||||
|
||||
#endif // DOCK_UNIT_TEST_H
|
||||
|
Loading…
x
Reference in New Issue
Block a user