mirror of
https://github.com/linuxdeepin/dde-dock.git
synced 2025-06-01 07:05:48 +00:00
feat: 添加单元测试代码
添加以下类的单元测试代码: statebutton,pluginloader,imagefactory,dockpopupwindow,tipswidget Log: Change-Id: I7d26a7b9043197ebe529af94c825b0f7aad1a349
This commit is contained in:
parent
f37ffc8602
commit
1cce47a4e7
@ -61,7 +61,7 @@ private:
|
||||
|
||||
AppDragWidget::AppDragWidget(QGSettingsInterface *interface, QWidget *parent)
|
||||
: QGraphicsView(parent)
|
||||
, qgInterface(interface)
|
||||
, m_qgInterface(interface)
|
||||
, m_object(new AppGraphicsObject)
|
||||
, m_scene(new QGraphicsScene(this))
|
||||
, m_followMouseTimer(new QTimer(this))
|
||||
@ -124,8 +124,8 @@ AppDragWidget::~AppDragWidget()
|
||||
m_popupWindow=nullptr;
|
||||
}
|
||||
|
||||
delete qgInterface;
|
||||
qgInterface = nullptr;
|
||||
delete m_qgInterface;
|
||||
m_qgInterface = nullptr;
|
||||
}
|
||||
|
||||
void AppDragWidget::mouseMoveEvent(QMouseEvent *event)
|
||||
|
@ -75,7 +75,7 @@ private:
|
||||
bool isRemoveItem();
|
||||
|
||||
private:
|
||||
QGSettingsInterface *qgInterface;
|
||||
QGSettingsInterface *m_qgInterface;
|
||||
AppGraphicsObject *m_object;
|
||||
QGraphicsScene *m_scene;
|
||||
QTimer *m_followMouseTimer;
|
||||
|
@ -29,13 +29,13 @@
|
||||
#include "dockitemmanager.h"
|
||||
#include "touchsignalmanager.h"
|
||||
#include "qgsettingsinterfaceimpl.h"
|
||||
#include "utils.h"
|
||||
|
||||
#include <QDrag>
|
||||
#include <QTimer>
|
||||
#include <QStandardPaths>
|
||||
#include <QString>
|
||||
#include <QApplication>
|
||||
#include <QGSettings>
|
||||
#include <QPointer>
|
||||
|
||||
#include <DGuiApplicationHelper>
|
||||
@ -49,13 +49,6 @@
|
||||
|
||||
DWIDGET_USE_NAMESPACE
|
||||
|
||||
|
||||
static QGSettings *GSettingsByApp()
|
||||
{
|
||||
static QGSettings settings("com.deepin.dde.dock.module.app");
|
||||
return &settings;
|
||||
}
|
||||
|
||||
MainPanelControl::MainPanelControl(QWidget *parent)
|
||||
: QWidget(parent)
|
||||
, m_mainPanelLayout(new QBoxLayout(QBoxLayout::LeftToRight, this))
|
||||
@ -630,7 +623,8 @@ bool MainPanelControl::eventFilter(QObject *watched, QEvent *event)
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!GSettingsByApp()->keys().contains("removeable") || GSettingsByApp()->get("removeable").toBool())
|
||||
static const QGSettings *g_settings = Utils::SettingsPtr("app");
|
||||
if (!g_settings || !g_settings->keys().contains("removeable") || g_settings->get("removeable").toBool())
|
||||
startDrag(item);
|
||||
|
||||
return QWidget::eventFilter(watched, event);
|
||||
@ -967,6 +961,9 @@ void MainPanelControl::resizeDockIcon()
|
||||
}
|
||||
// icon个数
|
||||
int iconCount = m_fixedAreaLayout->count() + m_appAreaSonLayout->count() + pluginCount;
|
||||
if (iconCount <= 0)
|
||||
return;
|
||||
|
||||
// 余数
|
||||
int yu = (totalLength % iconCount);
|
||||
// icon宽度 = (总宽度-余数)/icon个数
|
||||
|
@ -32,6 +32,10 @@ ImageFactory::ImageFactory(QObject *parent)
|
||||
|
||||
QPixmap ImageFactory::lighterEffect(const QPixmap pixmap, const int delta)
|
||||
{
|
||||
if (pixmap.isNull()) {
|
||||
return pixmap;
|
||||
}
|
||||
|
||||
QImage image = pixmap.toImage();
|
||||
|
||||
const int width = image.width();
|
||||
|
@ -36,8 +36,16 @@ void PluginLoader::run()
|
||||
{
|
||||
QDir pluginsDir(m_pluginDirPath);
|
||||
const QStringList files = pluginsDir.entryList(QDir::Files);
|
||||
static const QGSettings gsetting("com.deepin.dde.dock.disableplugins", "/com/deepin/dde/dock/disableplugins/");
|
||||
static const auto disable_plugins_list = gsetting.get("disable-plugins-list").toStringList();
|
||||
|
||||
auto getDisablePluginList = [ = ]{
|
||||
if (QGSettings::isSchemaInstalled("com.deepin.dde.dock.disableplugins")) {
|
||||
QGSettings gsetting("com.deepin.dde.dock.disableplugins", "/com/deepin/dde/dock/disableplugins/");
|
||||
return gsetting.get("disable-plugins-list").toStringList();
|
||||
}
|
||||
return QStringList();
|
||||
};
|
||||
|
||||
const QStringList disable_plugins_list = getDisablePluginList();
|
||||
|
||||
QStringList plugins;
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2011 ~ 2018 Deepin Technology Co., Ltd.
|
||||
* Copyright (C) 2018 ~ 2028 Uniontech Technology Co., Ltd.
|
||||
*
|
||||
* Author: fanpengcheng <fanpengcheng@uniontech.com>
|
||||
*
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2011 ~ 2018 Deepin Technology Co., Ltd.
|
||||
* Copyright (C) 2018 ~ 2028 Uniontech Technology Co., Ltd.
|
||||
*
|
||||
* Author: fanpengcheng <fanpengcheng@uniontech.com>
|
||||
*
|
||||
@ -98,4 +98,7 @@ TEST_F(Test_AppDragWidget, cuntion_test)
|
||||
ASSERT_TRUE(dragWidget->isRemoveAble(QPoint(10, 1070)));
|
||||
ASSERT_FALSE(dragWidget->isRemoveAble(QPoint(1910, 10)));
|
||||
ASSERT_FALSE(dragWidget->isRemoveAble(QPoint(1910, 1070)));
|
||||
|
||||
delete dragWidget;
|
||||
dragWidget = nullptr;
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2011 ~ 2018 Deepin Technology Co., Ltd.
|
||||
* Copyright (C) 2018 ~ 2028 Uniontech Technology Co., Ltd.
|
||||
*
|
||||
* Author: fanpengcheng <fanpengcheng@uniontech.com>
|
||||
*
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2011 ~ 2018 Deepin Technology Co., Ltd.
|
||||
* Copyright (C) 2018 ~ 2028 Uniontech Technology Co., Ltd.
|
||||
*
|
||||
* Author: fanpengcheng <fanpengcheng@uniontech.com>
|
||||
*
|
||||
|
@ -87,4 +87,7 @@ TEST_F(Test_PreviewContainer, coverage_test)
|
||||
|
||||
// QDragLeaveEvent dragLeaveEvent;
|
||||
// qApp->sendEvent(container, &dragLeaveEvent);
|
||||
|
||||
delete container;
|
||||
container = nullptr;
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2011 ~ 2018 Deepin Technology Co., Ltd.
|
||||
* Copyright (C) 2018 ~ 2028 Uniontech Technology Co., Ltd.
|
||||
*
|
||||
* Author: fanpengcheng <fanpengcheng@uniontech.com>
|
||||
*
|
||||
@ -55,13 +55,16 @@ TEST_F(Test_LauncherItem, launcher_test)
|
||||
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);
|
||||
launcherItem->popupTips();
|
||||
|
||||
QTest::mouseClick(launcherItem, Qt::LeftButton, Qt::NoModifier, launcherItem->geometry().center());
|
||||
|
||||
delete launcherItem;
|
||||
launcherItem = nullptr;
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2011 ~ 2018 Deepin Technology Co., Ltd.
|
||||
* Copyright (C) 2018 ~ 2028 Uniontech Technology Co., Ltd.
|
||||
*
|
||||
* Author: fanpengcheng <fanpengcheng@uniontech.com>
|
||||
*
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2011 ~ 2018 Deepin Technology Co., Ltd.
|
||||
* Copyright (C) 2018 ~ 2028 Uniontech Technology Co., Ltd.
|
||||
*
|
||||
* Author: fanpengcheng <fanpengcheng@uniontech.com>
|
||||
*
|
||||
|
@ -49,3 +49,8 @@ void Test_MainPanelControl::TearDown()
|
||||
delete mainPanel;
|
||||
mainPanel = nullptr;
|
||||
}
|
||||
|
||||
TEST_F(Test_MainPanelControl, coverage_test)
|
||||
{
|
||||
ASSERT_TRUE(mainPanel);
|
||||
}
|
||||
|
19
tests/res/dde-calendar.svg
Normal file
19
tests/res/dde-calendar.svg
Normal file
@ -0,0 +1,19 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="16" height="16" viewBox="0 0 16 16">
|
||||
<defs>
|
||||
<path id="dde-calendar16-b" d="M6.53164557,12 L6.53164557,11.0047619 L3.82932718,11.0047619 L6.10470837,8.2047619 C6.38933317,7.84920635 6.53164557,7.44285714 6.53164557,6.98571429 C6.52517682,6.41428571 6.32949728,5.94285714 5.94460692,5.57142857 C5.56618532,5.1968254 5.07294348,5.00634921 4.46488141,5 C3.9215068,5.00634921 3.46384306,5.19365079 3.0918902,5.56190476 C2.72317172,5.93968254 2.52587498,6.41746032 2.5,6.9952381 L2.5,6.9952381 L3.50912428,6.9952381 C3.54470238,6.67777778 3.65790543,6.43174603 3.84873342,6.25714286 C4.03309266,6.08253968 4.26435031,5.9952381 4.54250636,5.9952381 C4.85624051,6.0015873 5.09881846,6.1015873 5.27024022,6.2952381 C5.43519322,6.48888889 5.51766973,6.71587302 5.51766973,6.97619048 C5.51766973,7.07460317 5.50473224,7.17936508 5.47885726,7.29047619 C5.44004478,7.40793651 5.3672714,7.53492063 5.2605371,7.67142857 L5.2605371,7.67142857 L2.5,11.0619048 L2.5,12 L6.53164557,12 Z M9.27132835,11.9556962 L11.6708861,5.99707854 L11.6708861,5 L7.63924051,5 L7.63924051,7.00369849 L8.65443801,7.00369849 L8.65443801,5.99707854 L10.5342535,5.99707854 L8.13955315,11.9556962 L9.27132835,11.9556962 Z"/>
|
||||
<filter id="dde-calendar16-a" width="143.6%" height="157.1%" x="-21.8%" y="-14.3%" filterUnits="objectBoundingBox">
|
||||
<feOffset dy="1" in="SourceAlpha" result="shadowOffsetOuter1"/>
|
||||
<feGaussianBlur in="shadowOffsetOuter1" result="shadowBlurOuter1" stdDeviation=".5"/>
|
||||
<feColorMatrix in="shadowBlurOuter1" values="0 0 0 0 0.000854821203 0 0 0 0 0.168099661 0 0 0 0 0.309386322 0 0 0 0.2 0"/>
|
||||
</filter>
|
||||
</defs>
|
||||
<g fill="none" fill-rule="evenodd" transform="rotate(-8 14.65 .35)">
|
||||
<rect width="14" height="14" fill="#FFF" rx="2.438"/>
|
||||
<path fill="#000" fill-opacity=".1" fill-rule="nonzero" d="M11.5625,0 C12.9086941,0 14,1.09130592 14,2.4375 L14,11.5625 C14,12.9086941 12.9086941,14 11.5625,14 L2.4375,14 C1.09130592,14 0,12.9086941 0,11.5625 L0,2.4375 C0,1.09130592 1.09130592,0 2.4375,0 L11.5625,0 Z M11.5625,1 L2.4375,1 C1.69029122,1 1.07623668,1.57010108 1.00658047,2.29905916 L1,2.4375 L1,11.5625 C1,12.3097088 1.57010108,12.9237633 2.29905916,12.9934195 L2.4375,13 L11.5625,13 C12.3097088,13 12.9237633,12.4298989 12.9934195,11.7009408 L13,11.5625 L13,2.4375 C13,1.69029122 12.4298989,1.07623668 11.7009408,1.00658047 L11.5625,1 Z"/>
|
||||
<path fill="#E06164" fill-rule="nonzero" d="M2.353,4 L2.353,2.908 C2.353,2.71 2.326,2.425 2.311,2.224 L2.323,2.224 L2.497,2.734 L2.884,3.787 L3.1,3.787 L3.484,2.734 L3.661,2.224 L3.673,2.224 C3.655,2.425 3.628,2.71 3.628,2.908 L3.628,4 L3.952,4 L3.952,1.789 L3.55,1.789 L3.151,2.908 L3.007,3.352 L3.007,3.352 L2.992,3.352 C2.941,3.205 2.896,3.055 2.845,2.908 L2.44,1.789 L2.041,1.789 L2.041,4 L2.353,4 Z M4.594,4 L4.783,3.37 L5.551,3.37 L5.737,4 L6.106,4 L5.374,1.789 L4.972,1.789 L4.24,4 L4.594,4 Z M5.467,3.097 L4.864,3.097 L4.954,2.8 C5.026,2.56 5.095,2.317 5.158,2.065 L5.173,2.065 C5.239,2.314 5.305,2.56 5.38,2.8 L5.467,3.097 Z M6.745,4 L6.745,3.109 L7.102,3.109 L7.603,4 L7.996,4 L7.456,3.064 C7.735,2.977 7.918,2.773 7.918,2.431 C7.918,1.954 7.576,1.789 7.12,1.789 L6.397,1.789 L6.397,4 L6.745,4 Z M7.078,2.83 L6.745,2.83 L6.745,2.071 L7.078,2.071 C7.399,2.071 7.573,2.164 7.573,2.431 C7.573,2.698 7.399,2.83 7.078,2.83 Z M9.226,4.039 C9.511,4.039 9.736,3.925 9.913,3.721 L9.727,3.502 C9.595,3.646 9.442,3.736 9.238,3.736 C8.848,3.736 8.602,3.415 8.602,2.89 C8.602,2.371 8.866,2.053 9.247,2.053 C9.427,2.053 9.565,2.134 9.679,2.251 L9.868,2.029 C9.733,1.882 9.517,1.75 9.241,1.75 C8.683,1.75 8.245,2.182 8.245,2.902 C8.245,3.625 8.671,4.039 9.226,4.039 Z M10.651,4 L10.651,2.995 L11.596,2.995 L11.596,4 L11.944,4 L11.944,1.789 L11.596,1.789 L11.596,2.692 L10.651,2.692 L10.651,1.789 L10.303,1.789 L10.303,4 L10.651,4 Z"/>
|
||||
<g fill-rule="nonzero">
|
||||
<use fill="#000" filter="url(#dde-calendar16-a)" xlink:href="#dde-calendar16-b"/>
|
||||
<use fill="#2D394F" xlink:href="#dde-calendar16-b"/>
|
||||
</g>
|
||||
</g>
|
||||
</svg>
|
After Width: | Height: | Size: 4.0 KiB |
@ -1,14 +1,36 @@
|
||||
/*
|
||||
* Copyright (C) 2018 ~ 2028 Uniontech Technology Co., Ltd.
|
||||
*
|
||||
* Author: fanpengcheng <fanpengcheng@uniontech.com>
|
||||
*
|
||||
* Maintainer: fanpengcheng <fanpengcheng@uniontech.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#include <gtest/gtest.h>
|
||||
#include <QApplication>
|
||||
|
||||
#include "dockapplication.h"
|
||||
|
||||
#include <QDebug>
|
||||
|
||||
#include <DLog>
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
// gerrit编译时没有显示器,需要指定环境变量
|
||||
qputenv("QT_QPA_PLATFORM", "offscreen");
|
||||
|
||||
QApplication app(argc, argv);
|
||||
DockApplication app(argc, argv);
|
||||
|
||||
qApp->setProperty("CANSHOW", true);
|
||||
|
||||
|
@ -1,5 +1,6 @@
|
||||
<RCC>
|
||||
<qresource prefix="/">
|
||||
<file>res/all_settings_on.png</file>
|
||||
<file>res/dde-calendar.svg</file>
|
||||
</qresource>
|
||||
</RCC>
|
||||
|
66
tests/util/ut_dockpopupwindow.cpp
Normal file
66
tests/util/ut_dockpopupwindow.cpp
Normal file
@ -0,0 +1,66 @@
|
||||
/*
|
||||
* Copyright (C) 2018 ~ 2028 Deepin Technology Co., Ltd.
|
||||
*
|
||||
* Author: fanpengcheng <fanpengcheng@uniontech.com>
|
||||
*
|
||||
* Maintainer: fanpengcheng <fanpengcheng@uniontech.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <QObject>
|
||||
#include <QApplication>
|
||||
#include <QSignalSpy>
|
||||
#include <QTest>
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
#include "dockpopupwindow.h"
|
||||
|
||||
#include <DRegionMonitor>
|
||||
|
||||
DWIDGET_USE_NAMESPACE
|
||||
|
||||
class Test_DockPopupWindow : public QObject, public ::testing::Test
|
||||
{
|
||||
public:
|
||||
virtual void SetUp() override;
|
||||
virtual void TearDown() override;
|
||||
};
|
||||
|
||||
void Test_DockPopupWindow::SetUp()
|
||||
{
|
||||
}
|
||||
|
||||
void Test_DockPopupWindow::TearDown()
|
||||
{
|
||||
}
|
||||
|
||||
TEST_F(Test_DockPopupWindow, coverage_test)
|
||||
{
|
||||
DockPopupWindow *window = new DockPopupWindow;
|
||||
QWidget *w = new QWidget;
|
||||
window->setContent(w);
|
||||
|
||||
window->show(QCursor::pos(), false);
|
||||
ASSERT_FALSE(window->model());
|
||||
|
||||
window->hide();
|
||||
|
||||
window->show(QCursor::pos(), true);
|
||||
ASSERT_TRUE(window->model());
|
||||
|
||||
delete window;
|
||||
window = nullptr;
|
||||
}
|
63
tests/util/ut_imagefactory.cpp
Normal file
63
tests/util/ut_imagefactory.cpp
Normal file
@ -0,0 +1,63 @@
|
||||
/*
|
||||
* Copyright (C) 2018 ~ 2028 Uniontech Technology Co., Ltd.
|
||||
*
|
||||
* Author: fanpengcheng <fanpengcheng@uniontech.com>
|
||||
*
|
||||
* Maintainer: fanpengcheng <fanpengcheng@uniontech.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
|
||||
#include <QObject>
|
||||
#include <QApplication>
|
||||
#include <QSignalSpy>
|
||||
#include <QTest>
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
#include "imagefactory.h"
|
||||
|
||||
class Test_ImageFactory : public QObject, public ::testing::Test
|
||||
{
|
||||
public:
|
||||
virtual void SetUp() override;
|
||||
virtual void TearDown() override;
|
||||
|
||||
public:
|
||||
ImageFactory *factory = nullptr;
|
||||
};
|
||||
|
||||
void Test_ImageFactory::SetUp()
|
||||
{
|
||||
factory = new ImageFactory();
|
||||
}
|
||||
|
||||
void Test_ImageFactory::TearDown()
|
||||
{
|
||||
delete factory;
|
||||
factory = nullptr;
|
||||
}
|
||||
|
||||
TEST_F(Test_ImageFactory, factory_test)
|
||||
{
|
||||
QPixmap pix(":/res/all_settings_on.png");
|
||||
// 以下是无效值,应该屏蔽才对
|
||||
factory->lighterEffect(pix, -1);
|
||||
factory->lighterEffect(pix, 256);
|
||||
|
||||
// 传入空的pixmap对象
|
||||
QPixmap emptyPix;
|
||||
factory->lighterEffect(emptyPix, 150);
|
||||
}
|
52
tests/util/ut_imageutil.cpp
Normal file
52
tests/util/ut_imageutil.cpp
Normal file
@ -0,0 +1,52 @@
|
||||
/*
|
||||
* Copyright (C) 2018 ~ 2028 Uniontech Technology Co., Ltd.
|
||||
*
|
||||
* Author: fanpengcheng <fanpengcheng@uniontech.com>
|
||||
*
|
||||
* Maintainer: fanpengcheng <fanpengcheng@uniontech.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include <QObject>
|
||||
#include <QApplication>
|
||||
#include <QSignalSpy>
|
||||
#include <QTest>
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
#include "imageutil.h"
|
||||
|
||||
class Test_ImageUtil : public QObject, public ::testing::Test
|
||||
{
|
||||
public:
|
||||
virtual void SetUp() override;
|
||||
virtual void TearDown() override;
|
||||
|
||||
};
|
||||
|
||||
void Test_ImageUtil::SetUp()
|
||||
{
|
||||
}
|
||||
|
||||
void Test_ImageUtil::TearDown()
|
||||
{
|
||||
}
|
||||
|
||||
TEST_F(Test_ImageUtil, coverage_test)
|
||||
{
|
||||
ASSERT_TRUE(ImageUtil::loadSvg("test", QSize(100, 100), 1.5).isNull());
|
||||
ASSERT_EQ(ImageUtil::loadSvg("dde-printer", ":/res/dde-calendar.svg", 100, 1.25).size(), QSize(125, 125));
|
||||
ASSERT_EQ(ImageUtil::loadSvg("123", "456", 100, 1.25).size(), QSize(125, 125));
|
||||
}
|
@ -58,4 +58,7 @@ TEST_F(Test_MenuWorker, coverage_test)
|
||||
ASSERT_FALSE(worker->m_autoHide);
|
||||
worker->setAutoHide(true);
|
||||
ASSERT_TRUE(worker->m_autoHide);
|
||||
|
||||
delete worker;
|
||||
worker = nullptr;
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2011 ~ 2018 Deepin Technology Co., Ltd.
|
||||
* Copyright (C) 2018 ~ 2028 Uniontech Technology Co., Ltd.
|
||||
*
|
||||
* Author: fanpengcheng <fanpengcheng@uniontech.com>
|
||||
*
|
||||
|
53
tests/util/ut_pluginloader.cpp
Normal file
53
tests/util/ut_pluginloader.cpp
Normal file
@ -0,0 +1,53 @@
|
||||
/*
|
||||
* Copyright (C) 2018 ~ 2028 Uniontech Technology Co., Ltd.
|
||||
*
|
||||
* Author: fanpengcheng <fanpengcheng@uniontech.com>
|
||||
*
|
||||
* Maintainer: fanpengcheng <fanpengcheng@uniontech.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#include <QObject>
|
||||
#include <QApplication>
|
||||
#include <QSignalSpy>
|
||||
#include <QTest>
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
#include "pluginloader.h"
|
||||
|
||||
class Test_PluginLoader : public QObject, public ::testing::Test
|
||||
{
|
||||
public:
|
||||
virtual void SetUp() override;
|
||||
virtual void TearDown() override;
|
||||
|
||||
public:
|
||||
PluginLoader *loader = nullptr;
|
||||
};
|
||||
|
||||
void Test_PluginLoader::SetUp()
|
||||
{
|
||||
loader = new PluginLoader("../", nullptr);
|
||||
connect(loader, &PluginLoader::finished, loader, &PluginLoader::deleteLater, Qt::QueuedConnection);
|
||||
}
|
||||
|
||||
void Test_PluginLoader::TearDown()
|
||||
{
|
||||
}
|
||||
|
||||
TEST_F(Test_PluginLoader, loader_test)
|
||||
{
|
||||
loader->start();
|
||||
}
|
@ -22,6 +22,9 @@
|
||||
#include <QObject>
|
||||
#include <QApplication>
|
||||
#include <QMouseEvent>
|
||||
#include <QDebug>
|
||||
#include <QSignalSpy>
|
||||
#include <QTest>
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
@ -48,22 +51,23 @@ void Test_StateButton::TearDown()
|
||||
stateButton = nullptr;
|
||||
}
|
||||
|
||||
TEST_F(Test_StateButton, statebutton_test)
|
||||
{
|
||||
ASSERT_NE(stateButton, nullptr);
|
||||
}
|
||||
|
||||
TEST_F(Test_StateButton, statebutton_clicked_test)
|
||||
{
|
||||
bool clicked = false;
|
||||
QSignalSpy spy(stateButton, SIGNAL(click()));
|
||||
QTest::mousePress(stateButton, Qt::LeftButton, Qt::NoModifier);
|
||||
ASSERT_EQ(spy.count(), 1);
|
||||
|
||||
connect(stateButton, &StateButton::click, this, [ = ]() mutable {
|
||||
clicked = true;
|
||||
});
|
||||
QEvent event(QEvent::Enter);
|
||||
qApp->sendEvent(stateButton, &event);
|
||||
|
||||
Qt::MouseButton button = Qt::LeftButton;
|
||||
QMouseEvent mouseEvent(QEvent::MouseButtonPress, stateButton->rect().center(), button, Qt::NoButton, Qt::NoModifier);
|
||||
bool ret = QApplication::sendEvent(stateButton, &mouseEvent);
|
||||
QEvent event2(QEvent::Leave);
|
||||
qApp->sendEvent(stateButton, &event2);
|
||||
|
||||
ASSERT_NE(ret, clicked);
|
||||
stateButton->show();
|
||||
|
||||
QTest::qWait(10);
|
||||
stateButton->setType(StateButton::Fork);
|
||||
|
||||
QTest::qWait(10);
|
||||
stateButton->setType(StateButton::Check);
|
||||
}
|
||||
|
@ -1,6 +1,28 @@
|
||||
/*
|
||||
* Copyright (C) 2018 ~ 2028 Uniontech Technology Co., Ltd.
|
||||
*
|
||||
* Author: fanpengcheng <fanpengcheng@uniontech.com>
|
||||
*
|
||||
* Maintainer: fanpengcheng <fanpengcheng@uniontech.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#include "themeappicon.h"
|
||||
|
||||
#include <QPixmap>
|
||||
#include <QDebug>
|
||||
#include <QApplication>
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
|
@ -1,3 +1,23 @@
|
||||
/*
|
||||
* Copyright (C) 2018 ~ 2028 Uniontech Technology Co., Ltd.
|
||||
*
|
||||
* Author: fanpengcheng <fanpengcheng@uniontech.com>
|
||||
*
|
||||
* Maintainer: fanpengcheng <fanpengcheng@uniontech.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#define private public
|
||||
#include "touchsignalmanager.h"
|
||||
#undef private
|
||||
|
@ -1,3 +1,23 @@
|
||||
/*
|
||||
* Copyright (C) 2018 ~ 2028 Uniontech Technology Co., Ltd.
|
||||
*
|
||||
* Author: fanpengcheng <fanpengcheng@uniontech.com>
|
||||
*
|
||||
* Maintainer: fanpengcheng <fanpengcheng@uniontech.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
#include "utils.h"
|
||||
|
||||
#include <QTest>
|
||||
|
@ -20,6 +20,10 @@
|
||||
*/
|
||||
|
||||
#include <QObject>
|
||||
#include <QDebug>
|
||||
#include <QApplication>
|
||||
#include <QTest>
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
#include "../widgets/tipswidget.h"
|
||||
@ -51,6 +55,13 @@ TEST_F(Test_TipsWidget, setText_test)
|
||||
const QString text = "hello dde dock";
|
||||
tipsWidget->setText(text);
|
||||
ASSERT_EQ(text, tipsWidget->text());
|
||||
|
||||
tipsWidget->show();
|
||||
QTest::qWait(10);
|
||||
|
||||
QEvent event(QEvent::FontChange);
|
||||
qApp->sendEvent(tipsWidget, &event);
|
||||
QTest::qWait(10);
|
||||
}
|
||||
|
||||
TEST_F(Test_TipsWidget, setTextList_test)
|
||||
@ -62,10 +73,12 @@ TEST_F(Test_TipsWidget, setTextList_test)
|
||||
};
|
||||
tipsWidget->setTextList(textList);
|
||||
ASSERT_EQ(textList, tipsWidget->textList());
|
||||
}
|
||||
|
||||
TEST_F(Test_TipsWidget, event_Test)
|
||||
{
|
||||
tipsWidget->update();
|
||||
tipsWidget->show();
|
||||
QTest::qWait(10);
|
||||
|
||||
QEvent event(QEvent::FontChange);
|
||||
qApp->sendEvent(tipsWidget, &event);
|
||||
QTest::qWait(10);
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user