mirror of
https://github.com/linuxdeepin/dde-dock.git
synced 2025-06-04 17:33:05 +00:00
feat: 添加单元测试代码
添加单元测试代码 Log: Change-Id: Ie8c8a970bc81968528c7130e91e30920efb7411b
This commit is contained in:
parent
8b07039f5e
commit
a586140cb2
@ -181,13 +181,6 @@ AppItem::~AppItem()
|
||||
stopSwingEffect();
|
||||
|
||||
m_appNameTips->deleteLater();
|
||||
|
||||
delete m_qgAppInterface;
|
||||
m_qgAppInterface = nullptr;
|
||||
delete m_qgActiveAppInterface;
|
||||
m_qgActiveAppInterface = nullptr;
|
||||
delete m_qgDockedAppInterface;
|
||||
m_qgDockedAppInterface = nullptr;
|
||||
}
|
||||
|
||||
void AppItem::checkEntry()
|
||||
|
@ -17,6 +17,16 @@
|
||||
#include <QtCore/QStringList>
|
||||
#include <QtCore/QVariant>
|
||||
|
||||
static QStringList dockedlist = {"/usr/share/applications/dde-file-manager.desktop",
|
||||
"/usr/share/applications/deepin-album.desktop",
|
||||
"/usr/share/applications/deepin-music.desktop",
|
||||
"/usr/share/applications/deepin-contacts.desktop",
|
||||
"/usr/share/applications/dde-calendar.desktop",
|
||||
"/usr/share/applications/dde-control-center.desktop",
|
||||
"/usr/share/applications/google-chrome.desktop",
|
||||
"/usr/share/applications/org.qt-project.qtcreator.desktop",
|
||||
"/usr/share/applications/com.syntevo.smartgit.desktop"};
|
||||
|
||||
/*
|
||||
* Implementation of adaptor class FakeDaemonDock
|
||||
*/
|
||||
@ -53,43 +63,59 @@ QStringList FakeDaemonDock::dockedApps() const
|
||||
QList<QDBusObjectPath> FakeDaemonDock::entries() const
|
||||
{
|
||||
// get the value of property Entries
|
||||
return qvariant_cast< QList<QDBusObjectPath> >(parent()->property("Entries"));
|
||||
static QList<QDBusObjectPath> pathList = {QDBusObjectPath("/com/deepin/dde/daemon/Dock/entries/e0T6045b766")
|
||||
, QDBusObjectPath("/com/deepin/dde/daemon/Dock/entries/e1T6045b766")
|
||||
, QDBusObjectPath("/com/deepin/dde/daemon/Dock/entries/e2T6045b766")
|
||||
, QDBusObjectPath("/com/deepin/dde/daemon/Dock/entries/e3T6045b766")
|
||||
, QDBusObjectPath("/com/deepin/dde/daemon/Dock/entries/e4T6045b766")
|
||||
, QDBusObjectPath("/com/deepin/dde/daemon/Dock/entries/e5T6045b766")
|
||||
, QDBusObjectPath("/com/deepin/dde/daemon/Dock/entries/e6T6045b766")
|
||||
, QDBusObjectPath("/com/deepin/dde/daemon/Dock/entries/e7T6045b766")
|
||||
, QDBusObjectPath("/com/deepin/dde/daemon/Dock/entries/e8T6045b766")
|
||||
, QDBusObjectPath("/com/deepin/dde/daemon/Dock/entries/e17T6045ba37")
|
||||
, QDBusObjectPath("/com/deepin/dde/daemon/Dock/entries/e20T6045bdd4")
|
||||
, QDBusObjectPath("/com/deepin/dde/daemon/Dock/entries/e22T6045bede")
|
||||
, QDBusObjectPath("/com/deepin/dde/daemon/Dock/entries/e33T6045c648")
|
||||
, QDBusObjectPath("/com/deepin/dde/daemon/Dock/entries/e43T6045cea2")
|
||||
, QDBusObjectPath("/com/deepin/dde/daemon/Dock/entries/e44T6045d157")
|
||||
};
|
||||
|
||||
return pathList;
|
||||
}
|
||||
|
||||
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"));
|
||||
return m_hideMode;
|
||||
}
|
||||
|
||||
void FakeDaemonDock::setHideMode(int value)
|
||||
{
|
||||
// set the value of property HideMode
|
||||
parent()->setProperty("HideMode", QVariant::fromValue(value));
|
||||
m_hideMode = value;
|
||||
}
|
||||
|
||||
int FakeDaemonDock::hideState() const
|
||||
{
|
||||
// get the value of property HideState
|
||||
return qvariant_cast< int >(parent()->property("HideState"));
|
||||
return m_hideState;
|
||||
}
|
||||
|
||||
uint FakeDaemonDock::hideTimeout() const
|
||||
{
|
||||
// get the value of property HideTimeout
|
||||
return qvariant_cast< uint >(parent()->property("HideTimeout"));
|
||||
return m_hideTimeout;
|
||||
}
|
||||
|
||||
void FakeDaemonDock::setHideTimeout(uint value)
|
||||
{
|
||||
// set the value of property HideTimeout
|
||||
parent()->setProperty("HideTimeout", QVariant::fromValue(value));
|
||||
m_hideTimeout = value;
|
||||
}
|
||||
|
||||
uint FakeDaemonDock::iconSize() const
|
||||
@ -106,26 +132,22 @@ void FakeDaemonDock::setIconSize(uint value)
|
||||
|
||||
double FakeDaemonDock::opacity() const
|
||||
{
|
||||
// get the value of property Opacity
|
||||
return qvariant_cast< double >(parent()->property("Opacity"));
|
||||
return m_opacity;
|
||||
}
|
||||
|
||||
void FakeDaemonDock::setOpacity(double value)
|
||||
{
|
||||
// set the value of property Opacity
|
||||
parent()->setProperty("Opacity", QVariant::fromValue(value));
|
||||
m_opacity = value;
|
||||
}
|
||||
|
||||
int FakeDaemonDock::position() const
|
||||
{
|
||||
// get the value of property Position
|
||||
return qvariant_cast< int >(parent()->property("Position"));
|
||||
return m_position;
|
||||
}
|
||||
|
||||
void FakeDaemonDock::setPosition(int value)
|
||||
{
|
||||
// set the value of property Position
|
||||
parent()->setProperty("Position", QVariant::fromValue(value));
|
||||
m_position = value;
|
||||
}
|
||||
|
||||
uint FakeDaemonDock::showTimeout() const
|
||||
@ -142,38 +164,32 @@ void FakeDaemonDock::setShowTimeout(uint value)
|
||||
|
||||
uint FakeDaemonDock::windowSize() const
|
||||
{
|
||||
// get the value of property WindowSize
|
||||
return qvariant_cast< uint >(parent()->property("WindowSize"));
|
||||
return 40;
|
||||
}
|
||||
|
||||
void FakeDaemonDock::setWindowSize(uint value)
|
||||
{
|
||||
// set the value of property WindowSize
|
||||
parent()->setProperty("WindowSize", QVariant::fromValue(value));
|
||||
//TODO
|
||||
}
|
||||
|
||||
uint FakeDaemonDock::windowSizeEfficient() const
|
||||
{
|
||||
// get the value of property WindowSizeEfficient
|
||||
return qvariant_cast< uint >(parent()->property("WindowSizeEfficient"));
|
||||
return 40;
|
||||
}
|
||||
|
||||
void FakeDaemonDock::setWindowSizeEfficient(uint value)
|
||||
{
|
||||
// set the value of property WindowSizeEfficient
|
||||
parent()->setProperty("WindowSizeEfficient", QVariant::fromValue(value));
|
||||
//TODO
|
||||
}
|
||||
|
||||
uint FakeDaemonDock::windowSizeFashion() const
|
||||
{
|
||||
// get the value of property WindowSizeFashion
|
||||
return qvariant_cast< uint >(parent()->property("WindowSizeFashion"));
|
||||
return 40;
|
||||
}
|
||||
|
||||
void FakeDaemonDock::setWindowSizeFashion(uint value)
|
||||
{
|
||||
// set the value of property WindowSizeFashion
|
||||
parent()->setProperty("WindowSizeFashion", QVariant::fromValue(value));
|
||||
//TODO
|
||||
}
|
||||
|
||||
void FakeDaemonDock::ActivateWindow(uint in0)
|
||||
@ -196,42 +212,44 @@ void FakeDaemonDock::CloseWindow(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;
|
||||
return dockedlist;
|
||||
}
|
||||
|
||||
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;
|
||||
static QStringList list = {"dde-file-manager",
|
||||
"deepin-album",
|
||||
"deepin-music",
|
||||
"deepin-contacts",
|
||||
"dde-calendar",
|
||||
"dde-control-center",
|
||||
"google-chrome",
|
||||
"org.qt-project.qtcreator",
|
||||
"com.syntevo.smartgit",
|
||||
"deepin-terminal",
|
||||
"org.gnome.dfeet",
|
||||
"wps-office-et",
|
||||
"org.gnome.Terminal",
|
||||
"code",
|
||||
"ca.desrt.dconf-editor",
|
||||
"deepin-editor"};
|
||||
return list;
|
||||
}
|
||||
|
||||
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;
|
||||
static QString str = "'{\"AiAssistant\":{\"pos_1\":1},\"datetime\":{\"Use24HourFormat\":true,\"pos_datetime_1\":3},\"disk-mount\":{\"holded_mount-item-key\":false},\"multitasking\":{\"pos_multitasking_1\":2},\"network\":{\"holded_network-item-key\":false},\"notifications\":{\"pos_notifications_1\":5},\"show-desktop\":{\"pos_show-desktop_1\":1},\"shutdown\":{\"pos_shutdown_1\":2},\"sound\":{\"holded_sound-item-key\":false},\"trash\":{\"pos_trash_1\":4},\"tray\":{\"fashion-tray-expanded\":true,\"holded_sni:fcitx-qimpanel\":false,\"holded_window:Deepin-WXWork\":false,\"holded_window:Deepin-WeChat\":false}}'";
|
||||
return str;
|
||||
}
|
||||
|
||||
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;
|
||||
return dockedlist.contains(in0);
|
||||
}
|
||||
|
||||
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;
|
||||
return dockedlist.contains(in0);
|
||||
}
|
||||
|
||||
void FakeDaemonDock::MakeWindowAbove(uint in0)
|
||||
|
@ -222,7 +222,12 @@ Q_SIGNALS: // SIGNALS
|
||||
void ServiceRestarted();
|
||||
|
||||
private:
|
||||
int m_position = 2;
|
||||
int m_displayMode = 1;
|
||||
int m_hideMode = 0;
|
||||
int m_hideState = 0;
|
||||
int m_hideTimeout = 0;
|
||||
double m_opacity = 0.4;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
81
tests/ut_appitem.cpp
Normal file
81
tests/ut_appitem.cpp
Normal file
@ -0,0 +1,81 @@
|
||||
/*
|
||||
* 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>
|
||||
|
||||
#define private public
|
||||
#include "appitem.h"
|
||||
#include "qgsettingsinterfacemock.h"
|
||||
#undef private
|
||||
|
||||
class Test_AppItem : public ::testing::Test
|
||||
{
|
||||
public:
|
||||
virtual void SetUp() override;
|
||||
virtual void TearDown() override;
|
||||
|
||||
public:
|
||||
AppItem *appItem = nullptr;
|
||||
};
|
||||
|
||||
void Test_AppItem::SetUp()
|
||||
{
|
||||
appItem = new AppItem(QDBusObjectPath("/com/deepin/dde/daemon/Dock/entries/e0T6045b766"), QGSettingsInterface::Type::MockType);
|
||||
}
|
||||
|
||||
void Test_AppItem::TearDown()
|
||||
{
|
||||
delete appItem;
|
||||
appItem = nullptr;
|
||||
}
|
||||
|
||||
TEST_F(Test_AppItem, coverage_test)
|
||||
{
|
||||
appItem->checkEntry();
|
||||
// ASSERT_FALSE(appItem->isValid());
|
||||
|
||||
ASSERT_TRUE(appItem->itemType() == AppItem::App);
|
||||
|
||||
appItem->setDockInfo(Dock::Position::Top, QRect(QPoint(0,0), QPoint(1920, 40)));
|
||||
|
||||
ASSERT_EQ(appItem->accessibleName(), appItem->m_itemEntryInter->name());
|
||||
}
|
||||
|
||||
TEST_F(Test_AppItem, AppItem_show_test)
|
||||
{
|
||||
appItem->show();
|
||||
|
||||
QThread::msleep(450);
|
||||
|
||||
ASSERT_EQ(appItem->isVisible(), true);
|
||||
}
|
||||
|
||||
TEST_F(Test_AppItem, AppItem_hide_test)
|
||||
{
|
||||
appItem->hide();
|
||||
|
||||
QThread::msleep(450);
|
||||
|
||||
ASSERT_EQ(appItem->isVisible(), false);
|
||||
}
|
@ -49,12 +49,12 @@ void Test_DockItemManager::TearDown()
|
||||
{
|
||||
}
|
||||
|
||||
TEST_F(Test_DockItemManager, appIsOnDock_test)
|
||||
{
|
||||
//TEST_F(Test_DockItemManager, appIsOnDock_test)
|
||||
//{
|
||||
// ASSERT_TRUE(manager->appIsOnDock("test"));
|
||||
|
||||
// manager->startLoadPlugins();
|
||||
}
|
||||
//}
|
||||
|
||||
TEST_F(Test_DockItemManager, get_method_test)
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user