diff --git a/frame/item/components/appdrag.cpp b/frame/item/components/appdrag.cpp index e3581f415..f8f3e7733 100644 --- a/frame/item/components/appdrag.cpp +++ b/frame/item/components/appdrag.cpp @@ -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); diff --git a/frame/item/components/appdrag.h b/frame/item/components/appdrag.h index d385755d3..ddd63367d 100644 --- a/frame/item/components/appdrag.h +++ b/frame/item/components/appdrag.h @@ -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 &); diff --git a/frame/item/components/appdragwidget.cpp b/frame/item/components/appdragwidget.cpp index 6fe5af49a..8d5719158 100644 --- a/frame/item/components/appdragwidget.cpp +++ b/frame/item/components/appdragwidget.cpp @@ -21,7 +21,7 @@ #include "../appitem.h" #include "appdragwidget.h" -#include +#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(); } } diff --git a/frame/item/components/appdragwidget.h b/frame/item/components/appdragwidget.h index e5204f210..1706a398d 100644 --- a/frame/item/components/appdragwidget.h +++ b/frame/item/components/appdragwidget.h @@ -32,16 +32,18 @@ #include #include #include -#include +#include + #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; diff --git a/frame/panel/mainpanelcontrol.cpp b/frame/panel/mainpanelcontrol.cpp index 5997bde30..6c9835ba9 100755 --- a/frame/panel/mainpanelcontrol.cpp +++ b/frame/panel/mainpanelcontrol.cpp @@ -28,6 +28,7 @@ #include "traypluginitem.h" #include "dockitemmanager.h" #include "touchsignalmanager.h" +#include "qgsettingsinterfaceimpl.h" #include #include @@ -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(); diff --git a/frame/util/abstractpluginscontroller.cpp b/frame/util/abstractpluginscontroller.cpp index 485c7f846..55e1c8d4a 100644 --- a/frame/util/abstractpluginscontroller.cpp +++ b/frame/util/abstractpluginscontroller.cpp @@ -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; diff --git a/gen_report.sh b/gen_report.sh index 9dbd2bea4..aedd31e96 100755 --- a/gen_report.sh +++ b/gen_report.sh @@ -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 diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 0f9a180d3..99e03ca55 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -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 ) # 链接库 diff --git a/tests/fakedbus/dockrect.cpp b/tests/fakedbus/dockrect.cpp new file mode 100644 index 000000000..560714a30 --- /dev/null +++ b/tests/fakedbus/dockrect.cpp @@ -0,0 +1,50 @@ +#include "dockrect.h" +#include + +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"); + qDBusRegisterMetaType(); +} diff --git a/tests/fakedbus/dockrect.h b/tests/fakedbus/dockrect.h new file mode 100644 index 000000000..88ae33ea2 --- /dev/null +++ b/tests/fakedbus/dockrect.h @@ -0,0 +1,28 @@ +#ifndef DOCKRECT_H +#define DOCKRECT_H + +#include +#include + +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 diff --git a/tests/fakedbus/fake_com_deepin_dde_daemon_dock.cpp b/tests/fakedbus/fake_com_deepin_dde_daemon_dock.cpp new file mode 100644 index 000000000..34d5b6bda --- /dev/null +++ b/tests/fakedbus/fake_com_deepin_dde_daemon_dock.cpp @@ -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 +#include +#include +#include +#include +#include +#include + +/* + * 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 FakeDaemonDock::entries() const +{ + // get the value of property Entries + return qvariant_cast< QList >(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)); +} + diff --git a/tests/fakedbus/fake_com_deepin_dde_daemon_dock.h b/tests/fakedbus/fake_com_deepin_dde_daemon_dock.h new file mode 100644 index 000000000..75ccdad8a --- /dev/null +++ b/tests/fakedbus/fake_com_deepin_dde_daemon_dock.h @@ -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 +#include + +#include "dockrect.h" + +QT_BEGIN_NAMESPACE +class QByteArray; +template class QList; +template 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", "" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \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 Entries READ entries) + QList 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 diff --git a/tests/res/all_settings_on.png b/tests/res/all_settings_on.png new file mode 100644 index 000000000..f1838b402 Binary files /dev/null and b/tests/res/all_settings_on.png differ diff --git a/tests/test-recoverage.sh b/tests/test-recoverage.sh index 8d5e59e33..c5d2edc0e 100755 --- a/tests/test-recoverage.sh +++ b/tests/test-recoverage.sh @@ -8,7 +8,7 @@ rm -rf $BUILD_DIR mkdir $BUILD_DIR cd $BUILD_DIR cmake ../ -make +make -j 16 cd tests/ diff --git a/tests/ut_appdrag.cpp b/tests/ut_appdrag.cpp new file mode 100644 index 000000000..10f8c1cf2 --- /dev/null +++ b/tests/ut_appdrag.cpp @@ -0,0 +1,60 @@ +/* + * Copyright (C) 2018 ~ 2028 Uniontech Technology Co., Ltd. + * + * Author: chenjun + * + * Maintainer: chenjun + * + * 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 . + */ + +#include +#include + +#include + +#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(); +} diff --git a/tests/ut_appdragwidget.cpp b/tests/ut_appdragwidget.cpp new file mode 100644 index 000000000..07dbacb26 --- /dev/null +++ b/tests/ut_appdragwidget.cpp @@ -0,0 +1,109 @@ +/* + * Copyright (C) 2018 ~ 2028 Uniontech Technology Co., Ltd. + * + * Author: chenjun + * + * Maintainer: chenjun + * + * 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 . + */ + +#include +#include + +#include + +#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))); +} diff --git a/tests/ut_appsnapshot.cpp b/tests/ut_appsnapshot.cpp new file mode 100644 index 000000000..4cc08f612 --- /dev/null +++ b/tests/ut_appsnapshot.cpp @@ -0,0 +1,53 @@ +/* + * Copyright (C) 2018 ~ 2028 Uniontech Technology Co., Ltd. + * + * Author: chenjun + * + * Maintainer: chenjun + * + * 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 . + */ + +#include +#include +#include +#include +#include + +#include + +#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; +} diff --git a/tests/ut_dockitemmanager.cpp b/tests/ut_dockitemmanager.cpp new file mode 100644 index 000000000..4e82f4ba9 --- /dev/null +++ b/tests/ut_dockitemmanager.cpp @@ -0,0 +1,74 @@ +/* + * Copyright (C) 2018 ~ 2028 Uniontech Technology Co., Ltd. + * + * Author: chenjun + * + * Maintainer: chenjun + * + * 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 . + */ + +#include +#include + +#include + +#include + +#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(); +} diff --git a/tests/ut_hoverhighlighteffect.cpp b/tests/ut_hoverhighlighteffect.cpp new file mode 100644 index 000000000..babd74335 --- /dev/null +++ b/tests/ut_hoverhighlighteffect.cpp @@ -0,0 +1,53 @@ +/* + * Copyright (C) 2018 ~ 2028 Uniontech Technology Co., Ltd. + * + * Author: chenjun + * + * Maintainer: chenjun + * + * 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 . + */ + +#include +#include +#include +#include +#include + +#include + +#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; +} diff --git a/tests/ut_launcheritem.cpp b/tests/ut_launcheritem.cpp index 4c74bdae4..d659540ce 100644 --- a/tests/ut_launcheritem.cpp +++ b/tests/ut_launcheritem.cpp @@ -21,12 +21,14 @@ #include #include +#include #include +#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()); } diff --git a/tests/ut_multiscreenworker.cpp b/tests/ut_multiscreenworker.cpp new file mode 100644 index 000000000..a6b2831e9 --- /dev/null +++ b/tests/ut_multiscreenworker.cpp @@ -0,0 +1,58 @@ +/* + * Copyright (C) 2018 ~ 2028 Uniontech Technology Co., Ltd. + * + * Author: chenjun + * + * Maintainer: chenjun + * + * 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 . + */ + +#include + +#include + +#include + +#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()); +} + diff --git a/tests/ut_placeholderitem.cpp b/tests/ut_placeholderitem.cpp new file mode 100644 index 000000000..8648631c3 --- /dev/null +++ b/tests/ut_placeholderitem.cpp @@ -0,0 +1,53 @@ +/* + * Copyright (C) 2018 ~ 2028 Uniontech Technology Co., Ltd. + * + * Author: chenjun + * + * Maintainer: chenjun + * + * 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 . + */ + +#include +#include + +#include + +#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); +} diff --git a/tests/ut_res.qrc b/tests/ut_res.qrc new file mode 100644 index 000000000..c061b67c3 --- /dev/null +++ b/tests/ut_res.qrc @@ -0,0 +1,5 @@ + + + res/all_settings_on.png + + diff --git a/tests/ut_statebutton.cpp b/tests/ut_statebutton.cpp index 6f2f0549e..5292d9345 100644 --- a/tests/ut_statebutton.cpp +++ b/tests/ut_statebutton.cpp @@ -20,9 +20,7 @@ */ #include -#include #include -#include #include #include