mirror of
https://github.com/linuxdeepin/dde-dock.git
synced 2025-06-02 15:45:21 +00:00
feat: 添加单元测试代码
添加单元测试代码 Log: Change-Id: I05428bb97788dda68dfc1c1422b57c4aa86cc9dd
This commit is contained in:
parent
147fed9107
commit
5943d8868d
@ -20,10 +20,11 @@
|
||||
*/
|
||||
|
||||
#include "appdrag.h"
|
||||
#include "qgsettingsinterfaceimpl.h"
|
||||
|
||||
AppDrag::AppDrag(QObject *dragSource)
|
||||
AppDrag::AppDrag(QGSettingsInterface *interface, QObject *dragSource)
|
||||
: QDrag(dragSource)
|
||||
, m_appDragWidget(new AppDragWidget)
|
||||
, m_appDragWidget(new AppDragWidget(interface))
|
||||
{
|
||||
// delete by itself
|
||||
m_appDragWidget->setVisible(false);
|
||||
|
@ -30,7 +30,7 @@
|
||||
class AppDrag : public QDrag
|
||||
{
|
||||
public:
|
||||
explicit AppDrag(QObject *dragSource);
|
||||
explicit AppDrag(QGSettingsInterface *interface, QObject *dragSource);
|
||||
virtual ~AppDrag();
|
||||
|
||||
void setPixmap(const QPixmap &);
|
||||
|
@ -21,7 +21,7 @@
|
||||
|
||||
#include "../appitem.h"
|
||||
#include "appdragwidget.h"
|
||||
#include <QGSettings>
|
||||
#include "qgsettingsinterface.h"
|
||||
|
||||
class AppGraphicsObject : public QGraphicsObject
|
||||
{
|
||||
@ -59,18 +59,20 @@ private:
|
||||
QPixmap m_appPixmap;
|
||||
};
|
||||
|
||||
AppDragWidget::AppDragWidget(QWidget *parent) :
|
||||
QGraphicsView(parent),
|
||||
m_object(new AppGraphicsObject),
|
||||
m_scene(new QGraphicsScene(this)),
|
||||
m_followMouseTimer(new QTimer(this)),
|
||||
m_animScale(new QPropertyAnimation(m_object, "scale", this)),
|
||||
m_animRotation(new QPropertyAnimation(m_object, "rotation", this)),
|
||||
m_animOpacity(new QPropertyAnimation(m_object, "opacity", this)),
|
||||
m_animGroup(new QParallelAnimationGroup(this)),
|
||||
m_goBackAnim(new QPropertyAnimation(this, "pos", this)),
|
||||
m_removeTips(new TipsWidget(this)),
|
||||
m_popupWindow(nullptr)
|
||||
AppDragWidget::AppDragWidget(QGSettingsInterface *interface, QWidget *parent)
|
||||
: QGraphicsView(parent)
|
||||
, qgInterface(interface)
|
||||
, m_object(new AppGraphicsObject)
|
||||
, m_scene(new QGraphicsScene(this))
|
||||
, m_followMouseTimer(new QTimer(this))
|
||||
, m_animScale(new QPropertyAnimation(m_object, "scale", this))
|
||||
, m_animRotation(new QPropertyAnimation(m_object, "rotation", this))
|
||||
, m_animOpacity(new QPropertyAnimation(m_object, "opacity", this))
|
||||
, m_animGroup(new QParallelAnimationGroup(this))
|
||||
, m_goBackAnim(new QPropertyAnimation(this, "pos", this))
|
||||
, m_removeTips(new TipsWidget(this))
|
||||
, m_popupWindow(nullptr)
|
||||
, m_distanceMultiple(interface->get("distance-multiple").toDouble())
|
||||
{
|
||||
m_removeTips->setText(tr("Remove"));
|
||||
m_removeTips->setObjectName("AppRemoveTips");
|
||||
@ -101,7 +103,6 @@ AppDragWidget::AppDragWidget(QWidget *parent) :
|
||||
setAcceptDrops(true);
|
||||
|
||||
initAnimations();
|
||||
initConfigurations();
|
||||
|
||||
m_followMouseTimer->setSingleShot(false);
|
||||
m_followMouseTimer->setInterval(1);
|
||||
@ -122,6 +123,9 @@ AppDragWidget::~AppDragWidget()
|
||||
delete m_popupWindow;
|
||||
m_popupWindow=nullptr;
|
||||
}
|
||||
|
||||
delete qgInterface;
|
||||
qgInterface = nullptr;
|
||||
}
|
||||
|
||||
void AppDragWidget::mouseMoveEvent(QMouseEvent *event)
|
||||
@ -268,16 +272,6 @@ void AppDragWidget::initAnimations()
|
||||
connect(m_goBackAnim, &QPropertyAnimation::finished, this, &AppDragWidget::hide);
|
||||
}
|
||||
|
||||
void AppDragWidget::initConfigurations()
|
||||
{
|
||||
if (QGSettings::isSchemaInstalled("com.deepin.dde.dock.distancemultiple")) {
|
||||
QGSettings gsetting("com.deepin.dde.dock.distancemultiple", "/com/deepin/dde/dock/distancemultiple/");
|
||||
m_distanceMultiple = gsetting.get("distance-multiple").toDouble();
|
||||
} else {
|
||||
m_distanceMultiple = 1.5;
|
||||
}
|
||||
}
|
||||
|
||||
void AppDragWidget::showRemoveAnimation()
|
||||
{
|
||||
if (m_animGroup->state() == QParallelAnimationGroup::Running) {
|
||||
@ -376,7 +370,7 @@ bool AppDragWidget::isRemoveItem()
|
||||
void AppDragWidget::enterEvent(QEvent *event)
|
||||
{
|
||||
if (m_goBackAnim->state() != QPropertyAnimation::State::Running
|
||||
&& m_animGroup->state() != QParallelAnimationGroup::Running) {
|
||||
&& m_animGroup->state() != QParallelAnimationGroup::Running) {
|
||||
hide();
|
||||
}
|
||||
}
|
||||
|
@ -32,16 +32,18 @@
|
||||
#include <QTimer>
|
||||
#include <QPropertyAnimation>
|
||||
#include <QParallelAnimationGroup>
|
||||
#include <qwidget.h>
|
||||
#include <QWidget>
|
||||
|
||||
#include "../widgets/tipswidget.h"
|
||||
#include "dockpopupwindow.h"
|
||||
|
||||
class QGSettingsInterface;
|
||||
class AppGraphicsObject;
|
||||
class AppDragWidget : public QGraphicsView
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit AppDragWidget(QWidget *parent = Q_NULLPTR);
|
||||
explicit AppDragWidget(QGSettingsInterface *interface, QWidget *parent = Q_NULLPTR);
|
||||
virtual ~AppDragWidget() override;
|
||||
|
||||
void setAppPixmap(const QPixmap &pix);
|
||||
@ -63,7 +65,6 @@ protected:
|
||||
|
||||
private:
|
||||
void initAnimations();
|
||||
void initConfigurations();
|
||||
void showRemoveAnimation();
|
||||
void showGoBackAnimation();
|
||||
void onRemoveAnimationStateChanged(QAbstractAnimation::State newState,
|
||||
@ -74,6 +75,7 @@ private:
|
||||
bool isRemoveItem();
|
||||
|
||||
private:
|
||||
QGSettingsInterface *qgInterface;
|
||||
AppGraphicsObject *m_object;
|
||||
QGraphicsScene *m_scene;
|
||||
QTimer *m_followMouseTimer;
|
||||
|
@ -28,6 +28,7 @@
|
||||
#include "traypluginitem.h"
|
||||
#include "dockitemmanager.h"
|
||||
#include "touchsignalmanager.h"
|
||||
#include "qgsettingsinterfaceimpl.h"
|
||||
|
||||
#include <QDrag>
|
||||
#include <QTimer>
|
||||
@ -695,7 +696,7 @@ void MainPanelControl::startDrag(DockItem *dockItem)
|
||||
|
||||
QDrag *drag = nullptr;
|
||||
if (item->itemType() == DockItem::App) {
|
||||
AppDrag *appDrag = new AppDrag(item);
|
||||
AppDrag *appDrag = new AppDrag(new QGSettingsInterfaceImpl("com.deepin.dde.dock.distancemultiple", "/com/deepin/dde/dock/distancemultiple/"),item);
|
||||
|
||||
m_appDragWidget = appDrag->appDragWidget();
|
||||
|
||||
|
@ -256,7 +256,6 @@ void AbstractPluginsController::initPlugin(PluginsItemInterface *interface)
|
||||
void AbstractPluginsController::refreshPluginSettings()
|
||||
{
|
||||
const QString &pluginSettings = m_dockDaemonInter->GetPluginSettings().value();
|
||||
qDebug() << pluginSettings;
|
||||
if (pluginSettings.isEmpty()) {
|
||||
qDebug() << "Error! get plugin settings from dbus failed!";
|
||||
return;
|
||||
|
@ -6,7 +6,7 @@ lcov -c -i -d ./ -o init.info
|
||||
./dde_dock_unit_test
|
||||
lcov -c -d ./ -o cover.info
|
||||
lcov -a init.info -a cover.info -o total.info
|
||||
lcov --remove total.info '*/usr/include/*' '*/usr/lib/*' '*/usr/lib64/*' '*/usr/local/include/*' '*/usr/local/lib/*' '*/usr/local/lib64/*' '*/third/*' 'testa.cpp' -o final.info
|
||||
lcov --remove total.info '*/usr/include/*' '*/usr/lib/*' '*/usr/lib64/*' '*/usr/local/include/*' '*/usr/local/lib/*' '*/usr/local/lib64/*' '*/third/*' 'testa.cpp' '*/unittest/dde_dock_unit_test_autogen/*' '*/dde-dock/frame/dbus/*' '*/dde-dock/interfaces/*' '*/dde-dock/unittest/*' -o final.info
|
||||
|
||||
# 生成报告
|
||||
genhtml -o cover_report --legend --title "lcov" --prefix=./ final.info
|
||||
|
@ -27,7 +27,7 @@ pkg_check_modules(DFrameworkDBus REQUIRED dframeworkdbus)
|
||||
pkg_check_modules(XCB_EWMH REQUIRED xcb-ewmh x11)
|
||||
|
||||
# 添加执行文件信息
|
||||
add_executable(${BIN_NAME} ${SRCS} ${INTERFACES} ${SRC_PATH} ../frame/item/item.qrc ../frame/frame.qrc)
|
||||
add_executable(${BIN_NAME} ${SRCS} ${INTERFACES} ${SRC_PATH} ../frame/item/item.qrc ../frame/frame.qrc ut_res.qrc)
|
||||
|
||||
# 包含路径
|
||||
target_include_directories(${BIN_NAME} PUBLIC
|
||||
@ -37,6 +37,7 @@ target_include_directories(${BIN_NAME} PUBLIC
|
||||
${Qt5Gui_PRIVATE_INCLUDE_DIRS}
|
||||
${QGSettings_INCLUDE_DIRS}
|
||||
../interfaces
|
||||
fakedbus
|
||||
)
|
||||
|
||||
# 链接库
|
||||
|
50
tests/fakedbus/dockrect.cpp
Normal file
50
tests/fakedbus/dockrect.cpp
Normal file
@ -0,0 +1,50 @@
|
||||
#include "dockrect.h"
|
||||
#include <QDebug>
|
||||
|
||||
DockRect::DockRect()
|
||||
: x(0)
|
||||
, y(0)
|
||||
, w(0)
|
||||
, h(0)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
QDebug operator<<(QDebug debug, const DockRect &rect)
|
||||
{
|
||||
debug << QString("DockRect(%1, %2, %3, %4)").arg(rect.x)
|
||||
.arg(rect.y)
|
||||
.arg(rect.w)
|
||||
.arg(rect.h);
|
||||
|
||||
return debug;
|
||||
}
|
||||
|
||||
DockRect::operator QRect() const
|
||||
{
|
||||
return QRect(x, y, w, h);
|
||||
}
|
||||
|
||||
QDBusArgument &operator<<(QDBusArgument &arg, const DockRect &rect)
|
||||
{
|
||||
arg.beginStructure();
|
||||
arg << rect.x << rect.y << rect.w << rect.h;
|
||||
arg.endStructure();
|
||||
|
||||
return arg;
|
||||
}
|
||||
|
||||
const QDBusArgument &operator>>(const QDBusArgument &arg, DockRect &rect)
|
||||
{
|
||||
arg.beginStructure();
|
||||
arg >> rect.x >> rect.y >> rect.w >> rect.h;
|
||||
arg.endStructure();
|
||||
|
||||
return arg;
|
||||
}
|
||||
|
||||
void registerDockRectMetaType()
|
||||
{
|
||||
qRegisterMetaType<DockRect>("DockRect");
|
||||
qDBusRegisterMetaType<DockRect>();
|
||||
}
|
28
tests/fakedbus/dockrect.h
Normal file
28
tests/fakedbus/dockrect.h
Normal file
@ -0,0 +1,28 @@
|
||||
#ifndef DOCKRECT_H
|
||||
#define DOCKRECT_H
|
||||
|
||||
#include <QRect>
|
||||
#include <QDBusMetaType>
|
||||
|
||||
struct DockRect
|
||||
{
|
||||
public:
|
||||
DockRect();
|
||||
operator QRect() const;
|
||||
|
||||
friend QDebug operator<<(QDebug debug, const DockRect &rect);
|
||||
friend const QDBusArgument &operator>>(const QDBusArgument &arg, DockRect &rect);
|
||||
friend QDBusArgument &operator<<(QDBusArgument &arg, const DockRect &rect);
|
||||
|
||||
private:
|
||||
int x;
|
||||
int y;
|
||||
uint w;
|
||||
uint h;
|
||||
};
|
||||
|
||||
Q_DECLARE_METATYPE(DockRect)
|
||||
|
||||
void registerDockRectMetaType();
|
||||
|
||||
#endif // DOCKRECT_H
|
320
tests/fakedbus/fake_com_deepin_dde_daemon_dock.cpp
Normal file
320
tests/fakedbus/fake_com_deepin_dde_daemon_dock.cpp
Normal file
@ -0,0 +1,320 @@
|
||||
/*
|
||||
* This file was generated by qdbusxml2cpp version 0.8
|
||||
* Command line was: qdbusxml2cpp -a fake_com_deepin_dde_daemon_dock -c FakeDaemonDock com.deepin.dde.daemon.Dock.xml
|
||||
*
|
||||
* qdbusxml2cpp is Copyright (C) 2017 The Qt Company Ltd.
|
||||
*
|
||||
* This is an auto-generated file.
|
||||
* Do not edit! All changes made to it will be lost.
|
||||
*/
|
||||
|
||||
#include "fake_com_deepin_dde_daemon_dock.h"
|
||||
#include <QtCore/QMetaObject>
|
||||
#include <QtCore/QByteArray>
|
||||
#include <QtCore/QList>
|
||||
#include <QtCore/QMap>
|
||||
#include <QtCore/QString>
|
||||
#include <QtCore/QStringList>
|
||||
#include <QtCore/QVariant>
|
||||
|
||||
/*
|
||||
* Implementation of adaptor class FakeDaemonDock
|
||||
*/
|
||||
|
||||
FakeDaemonDock::FakeDaemonDock(QObject *parent)
|
||||
: QDBusAbstractAdaptor(parent)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
FakeDaemonDock::~FakeDaemonDock()
|
||||
{
|
||||
// destructor
|
||||
}
|
||||
|
||||
int FakeDaemonDock::displayMode() const
|
||||
{
|
||||
// get the value of property DisplayMode
|
||||
return m_displayMode;
|
||||
}
|
||||
|
||||
void FakeDaemonDock::setDisplayMode(int value)
|
||||
{
|
||||
// set the value of property DisplayMode
|
||||
m_displayMode = value;
|
||||
}
|
||||
|
||||
QStringList FakeDaemonDock::dockedApps() const
|
||||
{
|
||||
// get the value of property DockedApps
|
||||
return qvariant_cast< QStringList >(parent()->property("DockedApps"));
|
||||
}
|
||||
|
||||
QList<QDBusObjectPath> FakeDaemonDock::entries() const
|
||||
{
|
||||
// get the value of property Entries
|
||||
return qvariant_cast< QList<QDBusObjectPath> >(parent()->property("Entries"));
|
||||
}
|
||||
|
||||
DockRect FakeDaemonDock::frontendWindowRect() const
|
||||
{
|
||||
// get the value of property FrontendWindowRect
|
||||
return qvariant_cast< DockRect >(parent()->property("FrontendWindowRect"));
|
||||
}
|
||||
|
||||
int FakeDaemonDock::hideMode() const
|
||||
{
|
||||
// get the value of property HideMode
|
||||
return qvariant_cast< int >(parent()->property("HideMode"));
|
||||
}
|
||||
|
||||
void FakeDaemonDock::setHideMode(int value)
|
||||
{
|
||||
// set the value of property HideMode
|
||||
parent()->setProperty("HideMode", QVariant::fromValue(value));
|
||||
}
|
||||
|
||||
int FakeDaemonDock::hideState() const
|
||||
{
|
||||
// get the value of property HideState
|
||||
return qvariant_cast< int >(parent()->property("HideState"));
|
||||
}
|
||||
|
||||
uint FakeDaemonDock::hideTimeout() const
|
||||
{
|
||||
// get the value of property HideTimeout
|
||||
return qvariant_cast< uint >(parent()->property("HideTimeout"));
|
||||
}
|
||||
|
||||
void FakeDaemonDock::setHideTimeout(uint value)
|
||||
{
|
||||
// set the value of property HideTimeout
|
||||
parent()->setProperty("HideTimeout", QVariant::fromValue(value));
|
||||
}
|
||||
|
||||
uint FakeDaemonDock::iconSize() const
|
||||
{
|
||||
// get the value of property IconSize
|
||||
return qvariant_cast< uint >(parent()->property("IconSize"));
|
||||
}
|
||||
|
||||
void FakeDaemonDock::setIconSize(uint value)
|
||||
{
|
||||
// set the value of property IconSize
|
||||
parent()->setProperty("IconSize", QVariant::fromValue(value));
|
||||
}
|
||||
|
||||
double FakeDaemonDock::opacity() const
|
||||
{
|
||||
// get the value of property Opacity
|
||||
return qvariant_cast< double >(parent()->property("Opacity"));
|
||||
}
|
||||
|
||||
void FakeDaemonDock::setOpacity(double value)
|
||||
{
|
||||
// set the value of property Opacity
|
||||
parent()->setProperty("Opacity", QVariant::fromValue(value));
|
||||
}
|
||||
|
||||
int FakeDaemonDock::position() const
|
||||
{
|
||||
// get the value of property Position
|
||||
return qvariant_cast< int >(parent()->property("Position"));
|
||||
}
|
||||
|
||||
void FakeDaemonDock::setPosition(int value)
|
||||
{
|
||||
// set the value of property Position
|
||||
parent()->setProperty("Position", QVariant::fromValue(value));
|
||||
}
|
||||
|
||||
uint FakeDaemonDock::showTimeout() const
|
||||
{
|
||||
// get the value of property ShowTimeout
|
||||
return qvariant_cast< uint >(parent()->property("ShowTimeout"));
|
||||
}
|
||||
|
||||
void FakeDaemonDock::setShowTimeout(uint value)
|
||||
{
|
||||
// set the value of property ShowTimeout
|
||||
parent()->setProperty("ShowTimeout", QVariant::fromValue(value));
|
||||
}
|
||||
|
||||
uint FakeDaemonDock::windowSize() const
|
||||
{
|
||||
// get the value of property WindowSize
|
||||
return qvariant_cast< uint >(parent()->property("WindowSize"));
|
||||
}
|
||||
|
||||
void FakeDaemonDock::setWindowSize(uint value)
|
||||
{
|
||||
// set the value of property WindowSize
|
||||
parent()->setProperty("WindowSize", QVariant::fromValue(value));
|
||||
}
|
||||
|
||||
uint FakeDaemonDock::windowSizeEfficient() const
|
||||
{
|
||||
// get the value of property WindowSizeEfficient
|
||||
return qvariant_cast< uint >(parent()->property("WindowSizeEfficient"));
|
||||
}
|
||||
|
||||
void FakeDaemonDock::setWindowSizeEfficient(uint value)
|
||||
{
|
||||
// set the value of property WindowSizeEfficient
|
||||
parent()->setProperty("WindowSizeEfficient", QVariant::fromValue(value));
|
||||
}
|
||||
|
||||
uint FakeDaemonDock::windowSizeFashion() const
|
||||
{
|
||||
// get the value of property WindowSizeFashion
|
||||
return qvariant_cast< uint >(parent()->property("WindowSizeFashion"));
|
||||
}
|
||||
|
||||
void FakeDaemonDock::setWindowSizeFashion(uint value)
|
||||
{
|
||||
// set the value of property WindowSizeFashion
|
||||
parent()->setProperty("WindowSizeFashion", QVariant::fromValue(value));
|
||||
}
|
||||
|
||||
void FakeDaemonDock::ActivateWindow(uint in0)
|
||||
{
|
||||
// handle method call com.deepin.dde.daemon.Dock.ActivateWindow
|
||||
QMetaObject::invokeMethod(parent(), "ActivateWindow", Q_ARG(uint, in0));
|
||||
}
|
||||
|
||||
void FakeDaemonDock::CancelPreviewWindow()
|
||||
{
|
||||
// handle method call com.deepin.dde.daemon.Dock.CancelPreviewWindow
|
||||
QMetaObject::invokeMethod(parent(), "CancelPreviewWindow");
|
||||
}
|
||||
|
||||
void FakeDaemonDock::CloseWindow(uint in0)
|
||||
{
|
||||
// handle method call com.deepin.dde.daemon.Dock.CloseWindow
|
||||
QMetaObject::invokeMethod(parent(), "CloseWindow", Q_ARG(uint, in0));
|
||||
}
|
||||
|
||||
QStringList FakeDaemonDock::GetDockedAppsDesktopFiles()
|
||||
{
|
||||
// handle method call com.deepin.dde.daemon.Dock.GetDockedAppsDesktopFiles
|
||||
QStringList out0;
|
||||
QMetaObject::invokeMethod(parent(), "GetDockedAppsDesktopFiles", Q_RETURN_ARG(QStringList, out0));
|
||||
return out0;
|
||||
}
|
||||
|
||||
QStringList FakeDaemonDock::GetEntryIDs()
|
||||
{
|
||||
// handle method call com.deepin.dde.daemon.Dock.GetEntryIDs
|
||||
QStringList out0;
|
||||
QMetaObject::invokeMethod(parent(), "GetEntryIDs", Q_RETURN_ARG(QStringList, out0));
|
||||
return out0;
|
||||
}
|
||||
|
||||
QString FakeDaemonDock::GetPluginSettings()
|
||||
{
|
||||
// handle method call com.deepin.dde.daemon.Dock.GetPluginSettings
|
||||
QString out0;
|
||||
QMetaObject::invokeMethod(parent(), "GetPluginSettings", Q_RETURN_ARG(QString, out0));
|
||||
return out0;
|
||||
}
|
||||
|
||||
bool FakeDaemonDock::IsDocked(const QString &in0)
|
||||
{
|
||||
// handle method call com.deepin.dde.daemon.Dock.IsDocked
|
||||
bool out0;
|
||||
QMetaObject::invokeMethod(parent(), "IsDocked", Q_RETURN_ARG(bool, out0), Q_ARG(QString, in0));
|
||||
return out0;
|
||||
}
|
||||
|
||||
bool FakeDaemonDock::IsOnDock(const QString &in0)
|
||||
{
|
||||
// handle method call com.deepin.dde.daemon.Dock.IsOnDock
|
||||
bool out0;
|
||||
QMetaObject::invokeMethod(parent(), "IsOnDock", Q_RETURN_ARG(bool, out0), Q_ARG(QString, in0));
|
||||
return out0;
|
||||
}
|
||||
|
||||
void FakeDaemonDock::MakeWindowAbove(uint in0)
|
||||
{
|
||||
// handle method call com.deepin.dde.daemon.Dock.MakeWindowAbove
|
||||
QMetaObject::invokeMethod(parent(), "MakeWindowAbove", Q_ARG(uint, in0));
|
||||
}
|
||||
|
||||
void FakeDaemonDock::MaximizeWindow(uint in0)
|
||||
{
|
||||
// handle method call com.deepin.dde.daemon.Dock.MaximizeWindow
|
||||
QMetaObject::invokeMethod(parent(), "MaximizeWindow", Q_ARG(uint, in0));
|
||||
}
|
||||
|
||||
void FakeDaemonDock::MergePluginSettings(const QString &in0)
|
||||
{
|
||||
// handle method call com.deepin.dde.daemon.Dock.MergePluginSettings
|
||||
QMetaObject::invokeMethod(parent(), "MergePluginSettings", Q_ARG(QString, in0));
|
||||
}
|
||||
|
||||
void FakeDaemonDock::MinimizeWindow(uint in0)
|
||||
{
|
||||
// handle method call com.deepin.dde.daemon.Dock.MinimizeWindow
|
||||
QMetaObject::invokeMethod(parent(), "MinimizeWindow", Q_ARG(uint, in0));
|
||||
}
|
||||
|
||||
void FakeDaemonDock::MoveEntry(int in0, int in1)
|
||||
{
|
||||
// handle method call com.deepin.dde.daemon.Dock.MoveEntry
|
||||
QMetaObject::invokeMethod(parent(), "MoveEntry", Q_ARG(int, in0), Q_ARG(int, in1));
|
||||
}
|
||||
|
||||
void FakeDaemonDock::MoveWindow(uint in0)
|
||||
{
|
||||
// handle method call com.deepin.dde.daemon.Dock.MoveWindow
|
||||
QMetaObject::invokeMethod(parent(), "MoveWindow", Q_ARG(uint, in0));
|
||||
}
|
||||
|
||||
void FakeDaemonDock::PreviewWindow(uint in0)
|
||||
{
|
||||
// handle method call com.deepin.dde.daemon.Dock.PreviewWindow
|
||||
QMetaObject::invokeMethod(parent(), "PreviewWindow", Q_ARG(uint, in0));
|
||||
}
|
||||
|
||||
QString FakeDaemonDock::QueryWindowIdentifyMethod(uint in0)
|
||||
{
|
||||
// handle method call com.deepin.dde.daemon.Dock.QueryWindowIdentifyMethod
|
||||
QString out0;
|
||||
QMetaObject::invokeMethod(parent(), "QueryWindowIdentifyMethod", Q_RETURN_ARG(QString, out0), Q_ARG(uint, in0));
|
||||
return out0;
|
||||
}
|
||||
|
||||
void FakeDaemonDock::RemovePluginSettings(const QString &in0, const QStringList &in1)
|
||||
{
|
||||
// handle method call com.deepin.dde.daemon.Dock.RemovePluginSettings
|
||||
QMetaObject::invokeMethod(parent(), "RemovePluginSettings", Q_ARG(QString, in0), Q_ARG(QStringList, in1));
|
||||
}
|
||||
|
||||
bool FakeDaemonDock::RequestDock(const QString &in0, int in1)
|
||||
{
|
||||
// handle method call com.deepin.dde.daemon.Dock.RequestDock
|
||||
bool out0;
|
||||
QMetaObject::invokeMethod(parent(), "RequestDock", Q_RETURN_ARG(bool, out0), Q_ARG(QString, in0), Q_ARG(int, in1));
|
||||
return out0;
|
||||
}
|
||||
|
||||
bool FakeDaemonDock::RequestUndock(const QString &in0)
|
||||
{
|
||||
// handle method call com.deepin.dde.daemon.Dock.RequestUndock
|
||||
bool out0;
|
||||
QMetaObject::invokeMethod(parent(), "RequestUndock", Q_RETURN_ARG(bool, out0), Q_ARG(QString, in0));
|
||||
return out0;
|
||||
}
|
||||
|
||||
void FakeDaemonDock::SetFrontendWindowRect(int in0, int in1, uint in2, uint in3)
|
||||
{
|
||||
// handle method call com.deepin.dde.daemon.Dock.SetFrontendWindowRect
|
||||
QMetaObject::invokeMethod(parent(), "SetFrontendWindowRect", Q_ARG(int, in0), Q_ARG(int, in1), Q_ARG(uint, in2), Q_ARG(uint, in3));
|
||||
}
|
||||
|
||||
void FakeDaemonDock::SetPluginSettings(const QString &in0)
|
||||
{
|
||||
// handle method call com.deepin.dde.daemon.Dock.SetPluginSettings
|
||||
QMetaObject::invokeMethod(parent(), "SetPluginSettings", Q_ARG(QString, in0));
|
||||
}
|
||||
|
228
tests/fakedbus/fake_com_deepin_dde_daemon_dock.h
Normal file
228
tests/fakedbus/fake_com_deepin_dde_daemon_dock.h
Normal file
@ -0,0 +1,228 @@
|
||||
/*
|
||||
* This file was generated by qdbusxml2cpp version 0.8
|
||||
* Command line was: qdbusxml2cpp -a fake_com_deepin_dde_daemon_dock -c FakeDaemonDock com.deepin.dde.daemon.Dock.xml
|
||||
*
|
||||
* qdbusxml2cpp is Copyright (C) 2017 The Qt Company Ltd.
|
||||
*
|
||||
* This is an auto-generated file.
|
||||
* This file may have been hand-edited. Look for HAND-EDIT comments
|
||||
* before re-generating it.
|
||||
*/
|
||||
|
||||
#ifndef FAKE_COM_DEEPIN_DDE_DAEMON_DOCK_H
|
||||
#define FAKE_COM_DEEPIN_DDE_DAEMON_DOCK_H
|
||||
|
||||
#include <QtCore/QObject>
|
||||
#include <QtDBus/QtDBus>
|
||||
|
||||
#include "dockrect.h"
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
class QByteArray;
|
||||
template<class T> class QList;
|
||||
template<class Key, class Value> class QMap;
|
||||
class QString;
|
||||
class QStringList;
|
||||
class QVariant;
|
||||
QT_END_NAMESPACE
|
||||
|
||||
/*
|
||||
* Adaptor class for interface com.deepin.dde.daemon.Dock
|
||||
*/
|
||||
class FakeDaemonDock: public QDBusAbstractAdaptor
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_CLASSINFO("D-Bus Interface", "com.deepin.dde.daemon.Dock")
|
||||
Q_CLASSINFO("D-Bus Introspection", ""
|
||||
" <interface name=\"com.deepin.dde.daemon.Dock\">\n"
|
||||
" <method name=\"ActivateWindow\">\n"
|
||||
" <arg direction=\"in\" type=\"u\"/>\n"
|
||||
" </method>\n"
|
||||
" <method name=\"CancelPreviewWindow\"/>\n"
|
||||
" <method name=\"CloseWindow\">\n"
|
||||
" <arg direction=\"in\" type=\"u\"/>\n"
|
||||
" </method>\n"
|
||||
" <method name=\"GetDockedAppsDesktopFiles\">\n"
|
||||
" <arg direction=\"out\" type=\"as\"/>\n"
|
||||
" </method>\n"
|
||||
" <method name=\"GetEntryIDs\">\n"
|
||||
" <arg direction=\"out\" type=\"as\"/>\n"
|
||||
" </method>\n"
|
||||
" <method name=\"GetPluginSettings\">\n"
|
||||
" <arg direction=\"out\" type=\"s\"/>\n"
|
||||
" </method>\n"
|
||||
" <method name=\"IsDocked\">\n"
|
||||
" <arg direction=\"in\" type=\"s\"/>\n"
|
||||
" <arg direction=\"out\" type=\"b\"/>\n"
|
||||
" </method>\n"
|
||||
" <method name=\"IsOnDock\">\n"
|
||||
" <arg direction=\"in\" type=\"s\"/>\n"
|
||||
" <arg direction=\"out\" type=\"b\"/>\n"
|
||||
" </method>\n"
|
||||
" <method name=\"MakeWindowAbove\">\n"
|
||||
" <arg direction=\"in\" type=\"u\"/>\n"
|
||||
" </method>\n"
|
||||
" <method name=\"MaximizeWindow\">\n"
|
||||
" <arg direction=\"in\" type=\"u\"/>\n"
|
||||
" </method>\n"
|
||||
" <method name=\"MinimizeWindow\">\n"
|
||||
" <arg direction=\"in\" type=\"u\"/>\n"
|
||||
" </method>\n"
|
||||
" <method name=\"MoveEntry\">\n"
|
||||
" <arg direction=\"in\" type=\"i\"/>\n"
|
||||
" <arg direction=\"in\" type=\"i\"/>\n"
|
||||
" </method>\n"
|
||||
" <method name=\"MoveWindow\">\n"
|
||||
" <arg direction=\"in\" type=\"u\"/>\n"
|
||||
" </method>\n"
|
||||
" <method name=\"PreviewWindow\">\n"
|
||||
" <arg direction=\"in\" type=\"u\"/>\n"
|
||||
" </method>\n"
|
||||
" <method name=\"QueryWindowIdentifyMethod\">\n"
|
||||
" <arg direction=\"in\" type=\"u\"/>\n"
|
||||
" <arg direction=\"out\" type=\"s\"/>\n"
|
||||
" </method>\n"
|
||||
" <method name=\"RemovePluginSettings\">\n"
|
||||
" <arg direction=\"in\" type=\"s\"/>\n"
|
||||
" <arg direction=\"in\" type=\"as\"/>\n"
|
||||
" </method>\n"
|
||||
" <method name=\"RequestDock\">\n"
|
||||
" <arg direction=\"in\" type=\"s\"/>\n"
|
||||
" <arg direction=\"in\" type=\"i\"/>\n"
|
||||
" <arg direction=\"out\" type=\"b\"/>\n"
|
||||
" </method>\n"
|
||||
" <method name=\"RequestUndock\">\n"
|
||||
" <arg direction=\"in\" type=\"s\"/>\n"
|
||||
" <arg direction=\"out\" type=\"b\"/>\n"
|
||||
" </method>\n"
|
||||
" <method name=\"SetFrontendWindowRect\">\n"
|
||||
" <arg direction=\"in\" type=\"i\"/>\n"
|
||||
" <arg direction=\"in\" type=\"i\"/>\n"
|
||||
" <arg direction=\"in\" type=\"u\"/>\n"
|
||||
" <arg direction=\"in\" type=\"u\"/>\n"
|
||||
" </method>\n"
|
||||
" <method name=\"SetPluginSettings\">\n"
|
||||
" <arg direction=\"in\" type=\"s\"/>\n"
|
||||
" </method>\n"
|
||||
" <method name=\"MergePluginSettings\">\n"
|
||||
" <arg direction=\"in\" type=\"s\"/>\n"
|
||||
" </method>\n"
|
||||
" <signal name=\"ServiceRestarted\"/>\n"
|
||||
" <signal name=\"EntryAdded\">\n"
|
||||
" <arg type=\"o\"/>\n"
|
||||
" <arg type=\"i\"/>\n"
|
||||
" </signal>\n"
|
||||
" <signal name=\"EntryRemoved\">\n"
|
||||
" <arg type=\"s\"/>\n"
|
||||
" </signal>\n"
|
||||
" <signal name=\"PluginSettingsSynced\"/>\n"
|
||||
" <signal name=\"DockAppSettingsSynced\"/>\n"
|
||||
" <property access=\"read\" type=\"ao\" name=\"Entries\"/>\n"
|
||||
" <property access=\"readwrite\" type=\"i\" name=\"HideMode\"/>\n"
|
||||
" <property access=\"readwrite\" type=\"i\" name=\"DisplayMode\"/>\n"
|
||||
" <property access=\"readwrite\" type=\"i\" name=\"Position\"/>\n"
|
||||
" <property access=\"readwrite\" type=\"u\" name=\"IconSize\"/>\n"
|
||||
" <property access=\"readwrite\" type=\"u\" name=\"WindowSize\"/>\n"
|
||||
" <property access=\"readwrite\" type=\"u\" name=\"WindowSizeEfficient\"/>\n"
|
||||
" <property access=\"readwrite\" type=\"u\" name=\"WindowSizeFashion\"/>\n"
|
||||
" <property access=\"readwrite\" type=\"u\" name=\"ShowTimeout\"/>\n"
|
||||
" <property access=\"readwrite\" type=\"u\" name=\"HideTimeout\"/>\n"
|
||||
" <property access=\"read\" type=\"as\" name=\"DockedApps\"/>\n"
|
||||
" <property access=\"read\" type=\"i\" name=\"HideState\"/>\n"
|
||||
" <property access=\"read\" type=\"(iiuu)\" name=\"FrontendWindowRect\">\n"
|
||||
" <annotation value=\"DockRect\" name=\"org.qtproject.QtDBus.QtTypeName\"/>\n"
|
||||
" </property>\n"
|
||||
" <property access=\"readwrite\" type=\"d\" name=\"Opacity\"/>\n"
|
||||
" </interface>\n"
|
||||
"")
|
||||
public:
|
||||
FakeDaemonDock(QObject *parent);
|
||||
virtual ~FakeDaemonDock();
|
||||
|
||||
public: // PROPERTIES
|
||||
Q_PROPERTY(int DisplayMode READ displayMode WRITE setDisplayMode)
|
||||
int displayMode() const;
|
||||
void setDisplayMode(int value);
|
||||
|
||||
Q_PROPERTY(QStringList DockedApps READ dockedApps)
|
||||
QStringList dockedApps() const;
|
||||
|
||||
Q_PROPERTY(QList<QDBusObjectPath> Entries READ entries)
|
||||
QList<QDBusObjectPath> entries() const;
|
||||
|
||||
Q_PROPERTY(DockRect FrontendWindowRect READ frontendWindowRect)
|
||||
DockRect frontendWindowRect() const;
|
||||
|
||||
Q_PROPERTY(int HideMode READ hideMode WRITE setHideMode)
|
||||
int hideMode() const;
|
||||
void setHideMode(int value);
|
||||
|
||||
Q_PROPERTY(int HideState READ hideState)
|
||||
int hideState() const;
|
||||
|
||||
Q_PROPERTY(uint HideTimeout READ hideTimeout WRITE setHideTimeout)
|
||||
uint hideTimeout() const;
|
||||
void setHideTimeout(uint value);
|
||||
|
||||
Q_PROPERTY(uint IconSize READ iconSize WRITE setIconSize)
|
||||
uint iconSize() const;
|
||||
void setIconSize(uint value);
|
||||
|
||||
Q_PROPERTY(double Opacity READ opacity WRITE setOpacity)
|
||||
double opacity() const;
|
||||
void setOpacity(double value);
|
||||
|
||||
Q_PROPERTY(int Position READ position WRITE setPosition)
|
||||
int position() const;
|
||||
void setPosition(int value);
|
||||
|
||||
Q_PROPERTY(uint ShowTimeout READ showTimeout WRITE setShowTimeout)
|
||||
uint showTimeout() const;
|
||||
void setShowTimeout(uint value);
|
||||
|
||||
Q_PROPERTY(uint WindowSize READ windowSize WRITE setWindowSize)
|
||||
uint windowSize() const;
|
||||
void setWindowSize(uint value);
|
||||
|
||||
Q_PROPERTY(uint WindowSizeEfficient READ windowSizeEfficient WRITE setWindowSizeEfficient)
|
||||
uint windowSizeEfficient() const;
|
||||
void setWindowSizeEfficient(uint value);
|
||||
|
||||
Q_PROPERTY(uint WindowSizeFashion READ windowSizeFashion WRITE setWindowSizeFashion)
|
||||
uint windowSizeFashion() const;
|
||||
void setWindowSizeFashion(uint value);
|
||||
|
||||
public Q_SLOTS: // METHODS
|
||||
void ActivateWindow(uint in0);
|
||||
void CancelPreviewWindow();
|
||||
void CloseWindow(uint in0);
|
||||
QStringList GetDockedAppsDesktopFiles();
|
||||
QStringList GetEntryIDs();
|
||||
QString GetPluginSettings();
|
||||
bool IsDocked(const QString &in0);
|
||||
bool IsOnDock(const QString &in0);
|
||||
void MakeWindowAbove(uint in0);
|
||||
void MaximizeWindow(uint in0);
|
||||
void MergePluginSettings(const QString &in0);
|
||||
void MinimizeWindow(uint in0);
|
||||
void MoveEntry(int in0, int in1);
|
||||
void MoveWindow(uint in0);
|
||||
void PreviewWindow(uint in0);
|
||||
QString QueryWindowIdentifyMethod(uint in0);
|
||||
void RemovePluginSettings(const QString &in0, const QStringList &in1);
|
||||
bool RequestDock(const QString &in0, int in1);
|
||||
bool RequestUndock(const QString &in0);
|
||||
void SetFrontendWindowRect(int in0, int in1, uint in2, uint in3);
|
||||
void SetPluginSettings(const QString &in0);
|
||||
Q_SIGNALS: // SIGNALS
|
||||
void DockAppSettingsSynced();
|
||||
void EntryAdded(const QDBusObjectPath &in0, int in1);
|
||||
void EntryRemoved(const QString &in0);
|
||||
void PluginSettingsSynced();
|
||||
void ServiceRestarted();
|
||||
|
||||
private:
|
||||
int m_displayMode = 1;
|
||||
};
|
||||
|
||||
#endif
|
BIN
tests/res/all_settings_on.png
Normal file
BIN
tests/res/all_settings_on.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 578 B |
@ -8,7 +8,7 @@ rm -rf $BUILD_DIR
|
||||
mkdir $BUILD_DIR
|
||||
cd $BUILD_DIR
|
||||
cmake ../
|
||||
make
|
||||
make -j 16
|
||||
|
||||
cd tests/
|
||||
|
||||
|
60
tests/ut_appdrag.cpp
Normal file
60
tests/ut_appdrag.cpp
Normal file
@ -0,0 +1,60 @@
|
||||
/*
|
||||
* Copyright (C) 2018 ~ 2028 Uniontech Technology Co., Ltd.
|
||||
*
|
||||
* Author: chenjun <chenjun@uniontech.com>
|
||||
*
|
||||
* Maintainer: chenjun <chenjun@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 <QObject>
|
||||
#include <QThread>
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
#include "appdrag.h"
|
||||
#include "qgsettingsinterfacemock.h"
|
||||
|
||||
class Test_AppDrag : public ::testing::Test
|
||||
{
|
||||
public:
|
||||
virtual void SetUp() override;
|
||||
virtual void TearDown() override;
|
||||
|
||||
public:
|
||||
AppDrag *drag = nullptr;
|
||||
};
|
||||
|
||||
void Test_AppDrag::SetUp()
|
||||
{
|
||||
QWidget *w = new QWidget;
|
||||
drag = new AppDrag(new QGSettingsInterfaceMock("com.deepin.dde.dock.distancemultiple", "/com/deepin/dde/dock/distancemultiple/"),w);
|
||||
}
|
||||
|
||||
void Test_AppDrag::TearDown()
|
||||
{
|
||||
delete drag;
|
||||
drag = nullptr;
|
||||
}
|
||||
|
||||
TEST_F(Test_AppDrag, drag_test)
|
||||
{
|
||||
QPixmap pix(":/res/all_settings_on.png");
|
||||
drag->setPixmap(pix);
|
||||
|
||||
ASSERT_TRUE(drag->appDragWidget());
|
||||
|
||||
drag->exec();
|
||||
}
|
109
tests/ut_appdragwidget.cpp
Normal file
109
tests/ut_appdragwidget.cpp
Normal file
@ -0,0 +1,109 @@
|
||||
/*
|
||||
* Copyright (C) 2018 ~ 2028 Uniontech Technology Co., Ltd.
|
||||
*
|
||||
* Author: chenjun <chenjun@uniontech.com>
|
||||
*
|
||||
* Maintainer: chenjun <chenjun@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 <QObject>
|
||||
#include <QTest>
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
#define private public
|
||||
#include "appdragwidget.h"
|
||||
#include "qgsettingsinterfacemock.h"
|
||||
#undef private
|
||||
|
||||
class Test_AppDragWidget : public ::testing::Test
|
||||
{
|
||||
public:
|
||||
virtual void SetUp() override;
|
||||
virtual void TearDown() override;
|
||||
|
||||
public:
|
||||
AppDragWidget *dragWidget = nullptr;
|
||||
};
|
||||
|
||||
void Test_AppDragWidget::SetUp()
|
||||
{
|
||||
dragWidget = new AppDragWidget(new QGSettingsInterfaceMock("com.deepin.dde.dock.distancemultiple", "/com/deepin/dde/dock/distancemultiple/"));
|
||||
}
|
||||
|
||||
void Test_AppDragWidget::TearDown()
|
||||
{
|
||||
delete dragWidget;
|
||||
dragWidget = nullptr;
|
||||
}
|
||||
|
||||
TEST_F(Test_AppDragWidget, cuntion_test)
|
||||
{
|
||||
QPixmap pix(":/res/all_settings_on.png");
|
||||
dragWidget->setAppPixmap(pix);
|
||||
dragWidget->setOriginPos(QPoint(-1, -1));
|
||||
|
||||
dragWidget->popupMarkPoint(Dock::Position::Top);
|
||||
dragWidget->popupMarkPoint(Dock::Position::Bottom);
|
||||
dragWidget->popupMarkPoint(Dock::Position::Left);
|
||||
dragWidget->popupMarkPoint(Dock::Position::Right);
|
||||
|
||||
dragWidget->showRemoveTips();
|
||||
dragWidget->showGoBackAnimation();
|
||||
}
|
||||
|
||||
TEST_F(Test_AppDragWidget, event_test)
|
||||
{
|
||||
dragWidget->show();
|
||||
dragWidget->hide();
|
||||
|
||||
QTest::mouseClick(dragWidget,Qt::LeftButton, Qt::NoModifier, QPoint(dragWidget->rect().center()));
|
||||
}
|
||||
|
||||
TEST_F(Test_AppDragWidget, isRemoveAble_test)
|
||||
{
|
||||
// bottom
|
||||
const QRect &rect = QRect(QPoint(0, 1040), QPoint(1920, 1080));
|
||||
dragWidget->setDockInfo(Dock::Position::Bottom, rect);
|
||||
ASSERT_TRUE(dragWidget->isRemoveAble(QPoint(10, 10)));
|
||||
ASSERT_FALSE(dragWidget->isRemoveAble(QPoint(10, 1070)));
|
||||
ASSERT_TRUE(dragWidget->isRemoveAble(QPoint(1910, 10)));
|
||||
ASSERT_FALSE(dragWidget->isRemoveAble(QPoint(1910, 1070)));
|
||||
|
||||
// top
|
||||
const QRect &rect1 = QRect(QPoint(0, 0), QPoint(1920, 40));
|
||||
dragWidget->setDockInfo(Dock::Position::Top, rect1);
|
||||
ASSERT_FALSE(dragWidget->isRemoveAble(QPoint(10, 10)));
|
||||
ASSERT_TRUE(dragWidget->isRemoveAble(QPoint(10, 1070)));
|
||||
ASSERT_FALSE(dragWidget->isRemoveAble(QPoint(1910, 10)));
|
||||
ASSERT_TRUE(dragWidget->isRemoveAble(QPoint(1910, 1070)));
|
||||
|
||||
// left
|
||||
const QRect &rect2 = QRect(QPoint(0, 0), QPoint(40, 1080));
|
||||
dragWidget->setDockInfo(Dock::Position::Left, rect2);
|
||||
ASSERT_FALSE(dragWidget->isRemoveAble(QPoint(10, 10)));
|
||||
ASSERT_FALSE(dragWidget->isRemoveAble(QPoint(10, 1070)));
|
||||
ASSERT_TRUE(dragWidget->isRemoveAble(QPoint(1910, 10)));
|
||||
ASSERT_TRUE(dragWidget->isRemoveAble(QPoint(1910, 1070)));
|
||||
|
||||
// right
|
||||
const QRect &rect3 = QRect(QPoint(1880, 0), QPoint(1920, 1080));
|
||||
dragWidget->setDockInfo(Dock::Position::Right, rect3);
|
||||
ASSERT_TRUE(dragWidget->isRemoveAble(QPoint(10, 10)));
|
||||
ASSERT_TRUE(dragWidget->isRemoveAble(QPoint(10, 1070)));
|
||||
ASSERT_FALSE(dragWidget->isRemoveAble(QPoint(1910, 10)));
|
||||
ASSERT_FALSE(dragWidget->isRemoveAble(QPoint(1910, 1070)));
|
||||
}
|
53
tests/ut_appsnapshot.cpp
Normal file
53
tests/ut_appsnapshot.cpp
Normal file
@ -0,0 +1,53 @@
|
||||
/*
|
||||
* Copyright (C) 2018 ~ 2028 Uniontech Technology Co., Ltd.
|
||||
*
|
||||
* Author: chenjun <chenjun@uniontech.com>
|
||||
*
|
||||
* Maintainer: chenjun <chenjun@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 <QObject>
|
||||
#include <QThread>
|
||||
#include <QTest>
|
||||
#include <QSignalSpy>
|
||||
#include <QThread>
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
#define private public
|
||||
#include "appsnapshot.h"
|
||||
#undef private
|
||||
|
||||
class Test_AppSnapshot : public ::testing::Test
|
||||
{
|
||||
public:
|
||||
virtual void SetUp() override;
|
||||
virtual void TearDown() override;
|
||||
|
||||
public:
|
||||
AppSnapshot *shot = nullptr;
|
||||
};
|
||||
|
||||
void Test_AppSnapshot::SetUp()
|
||||
{
|
||||
shot = new AppSnapshot(1000000);
|
||||
}
|
||||
|
||||
void Test_AppSnapshot::TearDown()
|
||||
{
|
||||
delete shot;
|
||||
shot = nullptr;
|
||||
}
|
74
tests/ut_dockitemmanager.cpp
Normal file
74
tests/ut_dockitemmanager.cpp
Normal file
@ -0,0 +1,74 @@
|
||||
/*
|
||||
* Copyright (C) 2018 ~ 2028 Uniontech Technology Co., Ltd.
|
||||
*
|
||||
* Author: chenjun <chenjun@uniontech.com>
|
||||
*
|
||||
* Maintainer: chenjun <chenjun@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 <QObject>
|
||||
#include <QDebug>
|
||||
|
||||
#include <DWindowManagerHelper>
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
#define private public
|
||||
#include "dockitemmanager.h"
|
||||
#include "dockitem.h"
|
||||
#undef private
|
||||
|
||||
class Test_DockItemManager : public ::testing::Test
|
||||
{
|
||||
public:
|
||||
virtual void SetUp() override;
|
||||
virtual void TearDown() override;
|
||||
|
||||
public:
|
||||
DockItemManager *manager = nullptr;
|
||||
};
|
||||
|
||||
void Test_DockItemManager::SetUp()
|
||||
{
|
||||
// manager = DockItemManager::instance();
|
||||
}
|
||||
|
||||
void Test_DockItemManager::TearDown()
|
||||
{
|
||||
}
|
||||
|
||||
TEST_F(Test_DockItemManager, appIsOnDock_test)
|
||||
{
|
||||
// ASSERT_TRUE(manager->appIsOnDock("test"));
|
||||
|
||||
// manager->startLoadPlugins();
|
||||
}
|
||||
|
||||
TEST_F(Test_DockItemManager, get_method_test)
|
||||
{
|
||||
// manager->itemList();
|
||||
// manager->pluginList();
|
||||
|
||||
// qDebug() << manager->m_itemList.size();
|
||||
// for (auto item: manager->m_itemList)
|
||||
// qDebug() << item->itemType();
|
||||
}
|
||||
|
||||
TEST_F(Test_DockItemManager, refershItemsIcon_test)
|
||||
{
|
||||
// manager->refershItemsIcon();
|
||||
// manager->sortPluginItems();
|
||||
}
|
53
tests/ut_hoverhighlighteffect.cpp
Normal file
53
tests/ut_hoverhighlighteffect.cpp
Normal file
@ -0,0 +1,53 @@
|
||||
/*
|
||||
* Copyright (C) 2018 ~ 2028 Uniontech Technology Co., Ltd.
|
||||
*
|
||||
* Author: chenjun <chenjun@uniontech.com>
|
||||
*
|
||||
* Maintainer: chenjun <chenjun@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 <QObject>
|
||||
#include <QThread>
|
||||
#include <QTest>
|
||||
#include <QSignalSpy>
|
||||
#include <QThread>
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
#define private public
|
||||
#include "hoverhighlighteffect.h"
|
||||
#undef private
|
||||
|
||||
class Test_HoverHighlightEffect : public ::testing::Test
|
||||
{
|
||||
public:
|
||||
virtual void SetUp() override;
|
||||
virtual void TearDown() override;
|
||||
|
||||
public:
|
||||
HoverHighlightEffect *effect = nullptr;
|
||||
};
|
||||
|
||||
void Test_HoverHighlightEffect::SetUp()
|
||||
{
|
||||
effect = new HoverHighlightEffect();
|
||||
}
|
||||
|
||||
void Test_HoverHighlightEffect::TearDown()
|
||||
{
|
||||
delete effect;
|
||||
effect = nullptr;
|
||||
}
|
@ -21,12 +21,14 @@
|
||||
|
||||
#include <QObject>
|
||||
#include <QThread>
|
||||
#include <QTest>
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
#define private public
|
||||
#include "launcheritem.h"
|
||||
#undef private
|
||||
#include "qgsettingsinterfacemock.h"
|
||||
|
||||
class Test_LauncherItem : public ::testing::Test
|
||||
{
|
||||
public:
|
||||
@ -48,7 +50,18 @@ void Test_LauncherItem::TearDown()
|
||||
launcherItem = nullptr;
|
||||
}
|
||||
|
||||
TEST_F(Test_LauncherItem, dockitem_test)
|
||||
TEST_F(Test_LauncherItem, launcher_test)
|
||||
{
|
||||
ASSERT_NE(launcherItem, nullptr);
|
||||
ASSERT_EQ(launcherItem->itemType(), LauncherItem::Launcher);
|
||||
launcherItem->refreshIcon();
|
||||
launcherItem->show();
|
||||
launcherItem->update();
|
||||
QThread::msleep(10);
|
||||
launcherItem->hide();
|
||||
launcherItem->update();
|
||||
QThread::msleep(10);
|
||||
launcherItem->resize(100,100);
|
||||
ASSERT_TRUE(launcherItem->popupTips());
|
||||
|
||||
QTest::mouseClick(launcherItem, Qt::LeftButton, Qt::NoModifier, launcherItem->geometry().center());
|
||||
}
|
||||
|
58
tests/ut_multiscreenworker.cpp
Normal file
58
tests/ut_multiscreenworker.cpp
Normal file
@ -0,0 +1,58 @@
|
||||
/*
|
||||
* Copyright (C) 2018 ~ 2028 Uniontech Technology Co., Ltd.
|
||||
*
|
||||
* Author: chenjun <chenjun@uniontech.com>
|
||||
*
|
||||
* Maintainer: chenjun <chenjun@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 <QObject>
|
||||
|
||||
#include <DWindowManagerHelper>
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
#include "mainwindow.h"
|
||||
#include "multiscreenworker.h"
|
||||
|
||||
class Test_MultiScreenWorker : public ::testing::Test
|
||||
{
|
||||
public:
|
||||
virtual void SetUp() override;
|
||||
virtual void TearDown() override;
|
||||
|
||||
public:
|
||||
MainWindow *mainwindow;
|
||||
MultiScreenWorker *worker = nullptr;
|
||||
};
|
||||
|
||||
void Test_MultiScreenWorker::SetUp()
|
||||
{
|
||||
// mainwindow = new MainWindow();
|
||||
// worker = new MultiScreenWorker(mainwindow, DWindowManagerHelper::instance());
|
||||
}
|
||||
|
||||
void Test_MultiScreenWorker::TearDown()
|
||||
{
|
||||
// delete worker;
|
||||
// worker = nullptr;
|
||||
}
|
||||
|
||||
TEST_F(Test_MultiScreenWorker, dockInter_test)
|
||||
{
|
||||
// ASSERT_TRUE(worker->dockInter());
|
||||
}
|
||||
|
53
tests/ut_placeholderitem.cpp
Normal file
53
tests/ut_placeholderitem.cpp
Normal file
@ -0,0 +1,53 @@
|
||||
/*
|
||||
* Copyright (C) 2018 ~ 2028 Uniontech Technology Co., Ltd.
|
||||
*
|
||||
* Author: chenjun <chenjun@uniontech.com>
|
||||
*
|
||||
* Maintainer: chenjun <chenjun@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 <QObject>
|
||||
#include <QTest>
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
#include "placeholderitem.h"
|
||||
|
||||
class Test_PlaceholderItem : public ::testing::Test
|
||||
{
|
||||
public:
|
||||
virtual void SetUp() override;
|
||||
virtual void TearDown() override;
|
||||
|
||||
public:
|
||||
PlaceholderItem *placeholderitem = nullptr;
|
||||
};
|
||||
|
||||
void Test_PlaceholderItem::SetUp()
|
||||
{
|
||||
placeholderitem = new PlaceholderItem();
|
||||
}
|
||||
|
||||
void Test_PlaceholderItem::TearDown()
|
||||
{
|
||||
delete placeholderitem;
|
||||
placeholderitem = nullptr;
|
||||
}
|
||||
|
||||
TEST_F(Test_PlaceholderItem, launcher_test)
|
||||
{
|
||||
QCOMPARE(placeholderitem->itemType(), PlaceholderItem::Placeholder);
|
||||
}
|
5
tests/ut_res.qrc
Normal file
5
tests/ut_res.qrc
Normal file
@ -0,0 +1,5 @@
|
||||
<RCC>
|
||||
<qresource prefix="/">
|
||||
<file>res/all_settings_on.png</file>
|
||||
</qresource>
|
||||
</RCC>
|
@ -20,9 +20,7 @@
|
||||
*/
|
||||
|
||||
#include <QObject>
|
||||
#include <QThread>
|
||||
#include <QApplication>
|
||||
#include <QEvent>
|
||||
#include <QMouseEvent>
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
|
Loading…
x
Reference in New Issue
Block a user