mirror of
https://github.com/linuxdeepin/dde-dock.git
synced 2025-06-03 00:15:21 +00:00
feat: 添加单元测试框架
加入单元测试框架,后期由开发逐渐丰富测试用例 Log: 添加测试用例框架
This commit is contained in:
parent
a7863c5b4f
commit
6c537c668b
@ -42,6 +42,7 @@ file(GLOB INTERFACES "interfaces/*.h")
|
||||
|
||||
add_subdirectory("frame")
|
||||
add_subdirectory("plugins")
|
||||
add_subdirectory("unittest")
|
||||
|
||||
# Install settings
|
||||
if (CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
|
||||
|
28
unittest/CMakeLists.txt
Normal file
28
unittest/CMakeLists.txt
Normal file
@ -0,0 +1,28 @@
|
||||
cmake_minimum_required(VERSION 3.7)
|
||||
|
||||
set(BIN_NAME dde_dock_unit_test)
|
||||
|
||||
# 自动生成moc文件
|
||||
set(CMAKE_AUTOMOC ON)
|
||||
|
||||
# 源文件
|
||||
file(GLOB_RECURSE SRCS "*.h" "*.cpp")
|
||||
|
||||
# 查找依赖库
|
||||
find_package(PkgConfig REQUIRED)
|
||||
find_package(Qt5 COMPONENTS Test DBus REQUIRED)
|
||||
|
||||
pkg_check_modules(DFrameworkDBus REQUIRED dframeworkdbus)
|
||||
|
||||
# 添加执行文件信息
|
||||
add_executable(${BIN_NAME} ${SRCS} ${INTERFACES})
|
||||
|
||||
# 包含路径
|
||||
target_include_directories(${BIN_NAME} PUBLIC ${DFrameworkDBus_INCLUDE_DIRS})
|
||||
|
||||
# 链接库
|
||||
target_link_libraries(${BIN_NAME} PRIVATE
|
||||
${Qt5Test_LIBRARIES}
|
||||
${Qt5DBus_LIBRARIES}
|
||||
${DFrameworkDBus_LIBRARIES}
|
||||
)
|
83
unittest/dock_unit_test.cpp
Normal file
83
unittest/dock_unit_test.cpp
Normal file
@ -0,0 +1,83 @@
|
||||
/*
|
||||
* Copyright (C) 2018 ~ 2028 Uniontech Technology Co., Ltd.
|
||||
*
|
||||
* Author: fanpengcheng <fanpengcheng@uniontech.com>
|
||||
*
|
||||
* Maintainer: fanpengcheng <fanpengcheng@uniontech.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <QtTest>
|
||||
#include <QDBusInterface>
|
||||
#include <QDBusMetaType>
|
||||
#include <QDBusMessage>
|
||||
#include <QDBusArgument>
|
||||
|
||||
#include <com_deepin_daemon_display.h>
|
||||
|
||||
#include "dock_unit_test.h"
|
||||
|
||||
DockUnitTest::DockUnitTest()
|
||||
{
|
||||
qDBusRegisterMetaType<ScreenRect>();
|
||||
}
|
||||
|
||||
DockUnitTest::~DockUnitTest()
|
||||
{
|
||||
|
||||
}
|
||||
/**
|
||||
* @brief DockUnitTest::dock_geometry_test 比较任务栏自身的位置和通知给后端的位置是否吻合
|
||||
*/
|
||||
void DockUnitTest::dock_geometry_check()
|
||||
{
|
||||
ScreenRect daemonDockRect, dockRect;
|
||||
|
||||
{
|
||||
QDBusInterface inter("com.deepin.dde.daemon.Dock", "/com/deepin/dde/daemon/Dock", "org.freedesktop.DBus.Properties");
|
||||
QString interface = "com.deepin.dde.daemon.Dock";
|
||||
QString arg = "FrontendWindowRect";
|
||||
QDBusMessage msg = inter.call("Get", interface, arg);
|
||||
|
||||
QVariant var = msg.arguments().first();
|
||||
QDBusVariant dbvFirst = var.value<QDBusVariant>();
|
||||
QVariant vFirst = dbvFirst.variant();
|
||||
QDBusArgument dbusArgs = vFirst.value<QDBusArgument>();
|
||||
|
||||
dbusArgs >> daemonDockRect;
|
||||
qDebug() << daemonDockRect;
|
||||
}
|
||||
|
||||
{
|
||||
QDBusInterface inter("com.deepin.dde.Dock", "/com/deepin/dde/Dock", "org.freedesktop.DBus.Properties");
|
||||
QString interface = "com.deepin.dde.Dock";
|
||||
QString arg = "geometry";
|
||||
QDBusMessage msg = inter.call("Get", interface, arg);
|
||||
|
||||
QVariant var = msg.arguments().first();
|
||||
QDBusVariant dbvFirst = var.value<QDBusVariant>();
|
||||
QVariant vFirst = dbvFirst.variant();
|
||||
QDBusArgument dbusArgs = vFirst.value<QDBusArgument>();
|
||||
|
||||
dbusArgs >> dockRect;
|
||||
qDebug() << dockRect;
|
||||
}
|
||||
|
||||
QCOMPARE(daemonDockRect, dockRect);
|
||||
}
|
||||
|
||||
QTEST_APPLESS_MAIN(DockUnitTest)
|
||||
|
||||
#include "dock_unit_test.moc"
|
40
unittest/dock_unit_test.h
Normal file
40
unittest/dock_unit_test.h
Normal file
@ -0,0 +1,40 @@
|
||||
/*
|
||||
* Copyright (C) 2018 ~ 2028 Uniontech Technology Co., Ltd.
|
||||
*
|
||||
* Author: fanpengcheng <fanpengcheng@uniontech.com>
|
||||
*
|
||||
* Maintainer: fanpengcheng <fanpengcheng@uniontech.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#ifndef DOCK_UNIT_TEST_H
|
||||
#define DOCK_UNIT_TEST_H
|
||||
#include <QObject>
|
||||
|
||||
class DockUnitTest : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
DockUnitTest();
|
||||
~DockUnitTest();
|
||||
|
||||
private slots:
|
||||
void dock_geometry_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