From 1cce47a4e77599e768fed41e35482247ca6d17d8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=8C=83=E6=9C=8B=E7=A8=8B?= Date: Tue, 16 Mar 2021 13:16:30 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=B7=BB=E5=8A=A0=E5=8D=95=E5=85=83?= =?UTF-8?q?=E6=B5=8B=E8=AF=95=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 添加以下类的单元测试代码: statebutton,pluginloader,imagefactory,dockpopupwindow,tipswidget Log: Change-Id: I7d26a7b9043197ebe529af94c825b0f7aad1a349 --- frame/item/components/appdragwidget.cpp | 6 +- frame/item/components/appdragwidget.h | 2 +- frame/panel/mainpanelcontrol.cpp | 15 ++--- frame/util/imagefactory.cpp | 4 ++ frame/util/pluginloader.cpp | 12 +++- tests/controller/ut_dockitemmanager.cpp | 2 +- tests/item/components/ut_appdragwidget.cpp | 5 +- tests/item/components/ut_appsnapshot.cpp | 2 +- .../components/ut_hoverhighlighteffect.cpp | 2 +- tests/item/components/ut_previewcontainer.cpp | 3 + tests/item/ut_launcheritem.cpp | 9 ++- tests/item/ut_placeholderitem.cpp | 2 +- tests/mock/qgsettingsmock.h | 2 +- tests/panel/ut_mainpanelcontrol.cpp | 5 ++ tests/res/dde-calendar.svg | 19 ++++++ tests/ut_main.cpp | 28 +++++++- tests/ut_res.qrc | 1 + tests/util/ut_dockpopupwindow.cpp | 66 +++++++++++++++++++ tests/util/ut_imagefactory.cpp | 63 ++++++++++++++++++ tests/util/ut_imageutil.cpp | 52 +++++++++++++++ tests/util/ut_menuworker.cpp | 3 + tests/util/ut_multiscreenworker.cpp | 2 +- tests/util/ut_pluginloader.cpp | 53 +++++++++++++++ tests/util/ut_statebutton.cpp | 30 +++++---- tests/util/ut_themeappicon.cpp | 22 +++++++ tests/util/ut_touchsignalmanager.cpp | 20 ++++++ tests/util/ut_utils.cpp | 20 ++++++ tests/widgets/ut_tipswidget.cpp | 21 ++++-- 28 files changed, 426 insertions(+), 45 deletions(-) create mode 100644 tests/res/dde-calendar.svg create mode 100644 tests/util/ut_dockpopupwindow.cpp create mode 100644 tests/util/ut_imagefactory.cpp create mode 100644 tests/util/ut_imageutil.cpp create mode 100644 tests/util/ut_pluginloader.cpp diff --git a/frame/item/components/appdragwidget.cpp b/frame/item/components/appdragwidget.cpp index 8d5719158..79f24eca1 100644 --- a/frame/item/components/appdragwidget.cpp +++ b/frame/item/components/appdragwidget.cpp @@ -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) diff --git a/frame/item/components/appdragwidget.h b/frame/item/components/appdragwidget.h index 1706a398d..c2df155a8 100644 --- a/frame/item/components/appdragwidget.h +++ b/frame/item/components/appdragwidget.h @@ -75,7 +75,7 @@ private: bool isRemoveItem(); private: - QGSettingsInterface *qgInterface; + QGSettingsInterface *m_qgInterface; AppGraphicsObject *m_object; QGraphicsScene *m_scene; QTimer *m_followMouseTimer; diff --git a/frame/panel/mainpanelcontrol.cpp b/frame/panel/mainpanelcontrol.cpp index 86c8ca3be..153238976 100755 --- a/frame/panel/mainpanelcontrol.cpp +++ b/frame/panel/mainpanelcontrol.cpp @@ -29,13 +29,13 @@ #include "dockitemmanager.h" #include "touchsignalmanager.h" #include "qgsettingsinterfaceimpl.h" +#include "utils.h" #include #include #include #include #include -#include #include #include @@ -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个数 diff --git a/frame/util/imagefactory.cpp b/frame/util/imagefactory.cpp index 6dd223911..434a00cce 100644 --- a/frame/util/imagefactory.cpp +++ b/frame/util/imagefactory.cpp @@ -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(); diff --git a/frame/util/pluginloader.cpp b/frame/util/pluginloader.cpp index 4991df982..58eac7a85 100644 --- a/frame/util/pluginloader.cpp +++ b/frame/util/pluginloader.cpp @@ -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; diff --git a/tests/controller/ut_dockitemmanager.cpp b/tests/controller/ut_dockitemmanager.cpp index a9d899459..af9fd5534 100644 --- a/tests/controller/ut_dockitemmanager.cpp +++ b/tests/controller/ut_dockitemmanager.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2011 ~ 2018 Deepin Technology Co., Ltd. + * Copyright (C) 2018 ~ 2028 Uniontech Technology Co., Ltd. * * Author: fanpengcheng * diff --git a/tests/item/components/ut_appdragwidget.cpp b/tests/item/components/ut_appdragwidget.cpp index 577929d75..08653ecfa 100644 --- a/tests/item/components/ut_appdragwidget.cpp +++ b/tests/item/components/ut_appdragwidget.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2011 ~ 2018 Deepin Technology Co., Ltd. + * Copyright (C) 2018 ~ 2028 Uniontech Technology Co., Ltd. * * Author: fanpengcheng * @@ -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; } diff --git a/tests/item/components/ut_appsnapshot.cpp b/tests/item/components/ut_appsnapshot.cpp index 594d8722a..7f58ab462 100644 --- a/tests/item/components/ut_appsnapshot.cpp +++ b/tests/item/components/ut_appsnapshot.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2011 ~ 2018 Deepin Technology Co., Ltd. + * Copyright (C) 2018 ~ 2028 Uniontech Technology Co., Ltd. * * Author: fanpengcheng * diff --git a/tests/item/components/ut_hoverhighlighteffect.cpp b/tests/item/components/ut_hoverhighlighteffect.cpp index 1192f07d5..8c0e24235 100644 --- a/tests/item/components/ut_hoverhighlighteffect.cpp +++ b/tests/item/components/ut_hoverhighlighteffect.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2011 ~ 2018 Deepin Technology Co., Ltd. + * Copyright (C) 2018 ~ 2028 Uniontech Technology Co., Ltd. * * Author: fanpengcheng * diff --git a/tests/item/components/ut_previewcontainer.cpp b/tests/item/components/ut_previewcontainer.cpp index a8ce1908a..917a20950 100644 --- a/tests/item/components/ut_previewcontainer.cpp +++ b/tests/item/components/ut_previewcontainer.cpp @@ -87,4 +87,7 @@ TEST_F(Test_PreviewContainer, coverage_test) // QDragLeaveEvent dragLeaveEvent; // qApp->sendEvent(container, &dragLeaveEvent); + + delete container; + container = nullptr; } diff --git a/tests/item/ut_launcheritem.cpp b/tests/item/ut_launcheritem.cpp index 23401a093..f720ae2d3 100644 --- a/tests/item/ut_launcheritem.cpp +++ b/tests/item/ut_launcheritem.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2011 ~ 2018 Deepin Technology Co., Ltd. + * Copyright (C) 2018 ~ 2028 Uniontech Technology Co., Ltd. * * Author: fanpengcheng * @@ -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; } diff --git a/tests/item/ut_placeholderitem.cpp b/tests/item/ut_placeholderitem.cpp index ec3c508fc..89b6a90e0 100644 --- a/tests/item/ut_placeholderitem.cpp +++ b/tests/item/ut_placeholderitem.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2011 ~ 2018 Deepin Technology Co., Ltd. + * Copyright (C) 2018 ~ 2028 Uniontech Technology Co., Ltd. * * Author: fanpengcheng * diff --git a/tests/mock/qgsettingsmock.h b/tests/mock/qgsettingsmock.h index bbc75d38d..98f1aa4e9 100644 --- a/tests/mock/qgsettingsmock.h +++ b/tests/mock/qgsettingsmock.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2011 ~ 2018 Deepin Technology Co., Ltd. + * Copyright (C) 2018 ~ 2028 Uniontech Technology Co., Ltd. * * Author: fanpengcheng * diff --git a/tests/panel/ut_mainpanelcontrol.cpp b/tests/panel/ut_mainpanelcontrol.cpp index 1f5882060..9bb6466c6 100644 --- a/tests/panel/ut_mainpanelcontrol.cpp +++ b/tests/panel/ut_mainpanelcontrol.cpp @@ -49,3 +49,8 @@ void Test_MainPanelControl::TearDown() delete mainPanel; mainPanel = nullptr; } + +TEST_F(Test_MainPanelControl, coverage_test) +{ + ASSERT_TRUE(mainPanel); +} diff --git a/tests/res/dde-calendar.svg b/tests/res/dde-calendar.svg new file mode 100644 index 000000000..611c63092 --- /dev/null +++ b/tests/res/dde-calendar.svg @@ -0,0 +1,19 @@ + + + + + + + + + + + + + + + + + + + diff --git a/tests/ut_main.cpp b/tests/ut_main.cpp index 92570d788..0fee75106 100644 --- a/tests/ut_main.cpp +++ b/tests/ut_main.cpp @@ -1,14 +1,36 @@ +/* + * Copyright (C) 2018 ~ 2028 Uniontech Technology Co., Ltd. + * + * Author: fanpengcheng + * + * Maintainer: fanpengcheng + * + * 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 "dockapplication.h" + #include + #include int main(int argc, char **argv) { // gerrit编译时没有显示器,需要指定环境变量 qputenv("QT_QPA_PLATFORM", "offscreen"); - - QApplication app(argc, argv); + DockApplication app(argc, argv); qApp->setProperty("CANSHOW", true); diff --git a/tests/ut_res.qrc b/tests/ut_res.qrc index c061b67c3..606a61792 100644 --- a/tests/ut_res.qrc +++ b/tests/ut_res.qrc @@ -1,5 +1,6 @@ res/all_settings_on.png + res/dde-calendar.svg diff --git a/tests/util/ut_dockpopupwindow.cpp b/tests/util/ut_dockpopupwindow.cpp new file mode 100644 index 000000000..4bdffad8b --- /dev/null +++ b/tests/util/ut_dockpopupwindow.cpp @@ -0,0 +1,66 @@ +/* + * Copyright (C) 2018 ~ 2028 Deepin Technology Co., Ltd. + * + * Author: fanpengcheng + * + * Maintainer: fanpengcheng + * + * 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 "dockpopupwindow.h" + +#include + +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; +} diff --git a/tests/util/ut_imagefactory.cpp b/tests/util/ut_imagefactory.cpp new file mode 100644 index 000000000..39314b9c9 --- /dev/null +++ b/tests/util/ut_imagefactory.cpp @@ -0,0 +1,63 @@ +/* + * Copyright (C) 2018 ~ 2028 Uniontech Technology Co., Ltd. + * + * Author: fanpengcheng + * + * Maintainer: fanpengcheng + * + * 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 "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); +} diff --git a/tests/util/ut_imageutil.cpp b/tests/util/ut_imageutil.cpp new file mode 100644 index 000000000..f69f11697 --- /dev/null +++ b/tests/util/ut_imageutil.cpp @@ -0,0 +1,52 @@ +/* + * Copyright (C) 2018 ~ 2028 Uniontech Technology Co., Ltd. + * + * Author: fanpengcheng + * + * Maintainer: fanpengcheng + * + * 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 "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)); +} diff --git a/tests/util/ut_menuworker.cpp b/tests/util/ut_menuworker.cpp index 88686658a..3e682b880 100644 --- a/tests/util/ut_menuworker.cpp +++ b/tests/util/ut_menuworker.cpp @@ -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; } diff --git a/tests/util/ut_multiscreenworker.cpp b/tests/util/ut_multiscreenworker.cpp index 8d2342d85..9bf5b9651 100644 --- a/tests/util/ut_multiscreenworker.cpp +++ b/tests/util/ut_multiscreenworker.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2011 ~ 2018 Deepin Technology Co., Ltd. + * Copyright (C) 2018 ~ 2028 Uniontech Technology Co., Ltd. * * Author: fanpengcheng * diff --git a/tests/util/ut_pluginloader.cpp b/tests/util/ut_pluginloader.cpp new file mode 100644 index 000000000..adb662ff6 --- /dev/null +++ b/tests/util/ut_pluginloader.cpp @@ -0,0 +1,53 @@ +/* + * Copyright (C) 2018 ~ 2028 Uniontech Technology Co., Ltd. + * + * Author: fanpengcheng + * + * Maintainer: fanpengcheng + * + * 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 "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(); +} diff --git a/tests/util/ut_statebutton.cpp b/tests/util/ut_statebutton.cpp index 5292d9345..f4f0d7eba 100644 --- a/tests/util/ut_statebutton.cpp +++ b/tests/util/ut_statebutton.cpp @@ -22,6 +22,9 @@ #include #include #include +#include +#include +#include #include @@ -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); } diff --git a/tests/util/ut_themeappicon.cpp b/tests/util/ut_themeappicon.cpp index 68cbe69c2..885d94bdb 100644 --- a/tests/util/ut_themeappicon.cpp +++ b/tests/util/ut_themeappicon.cpp @@ -1,6 +1,28 @@ +/* + * Copyright (C) 2018 ~ 2028 Uniontech Technology Co., Ltd. + * + * Author: fanpengcheng + * + * Maintainer: fanpengcheng + * + * 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 "themeappicon.h" #include +#include +#include #include diff --git a/tests/util/ut_touchsignalmanager.cpp b/tests/util/ut_touchsignalmanager.cpp index 334ae839b..be201e605 100644 --- a/tests/util/ut_touchsignalmanager.cpp +++ b/tests/util/ut_touchsignalmanager.cpp @@ -1,3 +1,23 @@ +/* + * Copyright (C) 2018 ~ 2028 Uniontech Technology Co., Ltd. + * + * Author: fanpengcheng + * + * Maintainer: fanpengcheng + * + * 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 . + */ #define private public #include "touchsignalmanager.h" #undef private diff --git a/tests/util/ut_utils.cpp b/tests/util/ut_utils.cpp index 0c31cdfae..21aeba17e 100644 --- a/tests/util/ut_utils.cpp +++ b/tests/util/ut_utils.cpp @@ -1,3 +1,23 @@ +/* + * Copyright (C) 2018 ~ 2028 Uniontech Technology Co., Ltd. + * + * Author: fanpengcheng + * + * Maintainer: fanpengcheng + * + * 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 "utils.h" #include diff --git a/tests/widgets/ut_tipswidget.cpp b/tests/widgets/ut_tipswidget.cpp index 2dcccc160..86003fdab 100644 --- a/tests/widgets/ut_tipswidget.cpp +++ b/tests/widgets/ut_tipswidget.cpp @@ -20,6 +20,10 @@ */ #include +#include +#include +#include + #include #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); } }