-
Notifications
You must be signed in to change notification settings - Fork 175
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add tag ut Log: as des Task: https://pms.uniontech.com/task-view-278227.html
- Loading branch information
1 parent
c88beac
commit 5a4a888
Showing
19 changed files
with
1,087 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
128 changes: 128 additions & 0 deletions
128
tests/plugins/common/dfmplugin-tag/data/ut_tagproxyhandle.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,128 @@ | ||
// SPDX-FileCopyrightText: 2022 - 2023 UnionTech Software Technology Co., Ltd. | ||
// | ||
// SPDX-License-Identifier: GPL-3.0-or-later | ||
|
||
#include "stubext.h" | ||
#include "data/tagproxyhandle.h" | ||
#include "tagmanager_interface.h" | ||
|
||
#include <dfm-base/dfm_event_defines.h> | ||
#include <dfm-framework/event/event.h> | ||
|
||
#include <gtest/gtest.h> | ||
#include <QRect> | ||
DFMBASE_USE_NAMESPACE | ||
DPF_USE_NAMESPACE | ||
using namespace dfmplugin_tag; | ||
|
||
TEST(UT_TagProxyHandle, deleteFileTags) | ||
{ | ||
bool isRun { false }; | ||
stub_ext::StubExt stub; | ||
stub.set_lamda(&OrgDeepinFilemanagerServerTagManagerInterface::Delete, [&isRun]() { | ||
isRun = true; | ||
return QDBusPendingReply<bool>(); | ||
}); | ||
QMap<QString, QVariant> fileWithTag; | ||
fileWithTag["1"] = QVariant(QStringList() << "red"); | ||
|
||
TagProxyHandle::instance()->deleteFileTags(fileWithTag); | ||
|
||
EXPECT_TRUE(isRun); | ||
} | ||
|
||
TEST(UT_TagProxyHandle, deleteFiles) | ||
{ | ||
bool isRun { false }; | ||
stub_ext::StubExt stub; | ||
stub.set_lamda(&OrgDeepinFilemanagerServerTagManagerInterface::Delete, [&isRun]() { | ||
isRun = true; | ||
return QDBusPendingReply<bool>(); | ||
}); | ||
QMap<QString, QVariant> fileWithTag; | ||
fileWithTag["1"] = QVariant(QStringList() << "red"); | ||
|
||
TagProxyHandle::instance()->deleteFiles(fileWithTag); | ||
|
||
EXPECT_TRUE(isRun); | ||
} | ||
|
||
TEST(UT_TagProxyHandle, deleteTags) | ||
{ | ||
bool isRun { false }; | ||
stub_ext::StubExt stub; | ||
stub.set_lamda(&OrgDeepinFilemanagerServerTagManagerInterface::Delete, [&isRun]() { | ||
isRun = true; | ||
return QDBusPendingReply<bool>(); | ||
}); | ||
QMap<QString, QVariant> fileWithTag; | ||
fileWithTag["1"] = QVariant(QStringList() << "red"); | ||
|
||
TagProxyHandle::instance()->deleteTags(fileWithTag); | ||
|
||
EXPECT_TRUE(isRun); | ||
} | ||
|
||
TEST(UT_TagProxyHandle, update) | ||
{ | ||
int isRun = 0; | ||
stub_ext::StubExt stub; | ||
stub.set_lamda(&OrgDeepinFilemanagerServerTagManagerInterface::Update, [&isRun]() { | ||
isRun++; | ||
return QDBusPendingReply<bool>(); | ||
}); | ||
QMap<QString, QVariant> fileWithTag; | ||
fileWithTag["1"] = QVariant(QStringList() << "red"); | ||
|
||
TagProxyHandle::instance()->changeFilePaths(fileWithTag); | ||
TagProxyHandle::instance()->changeTagNamesWithFiles(fileWithTag); | ||
TagProxyHandle::instance()->changeTagsColor(fileWithTag); | ||
EXPECT_TRUE(isRun == 3); | ||
} | ||
|
||
TEST(UT_TagProxyHandle, Insert) | ||
{ | ||
int isRun = 0; | ||
stub_ext::StubExt stub; | ||
stub.set_lamda(&OrgDeepinFilemanagerServerTagManagerInterface::Insert, [&isRun]() { | ||
isRun++; | ||
return QDBusPendingReply<bool>(); | ||
}); | ||
QMap<QString, QVariant> fileWithTag; | ||
fileWithTag["1"] = QVariant(QStringList() << "red"); | ||
|
||
TagProxyHandle::instance()->addTags(fileWithTag); | ||
TagProxyHandle::instance()->addTagsForFiles(fileWithTag); | ||
EXPECT_TRUE(isRun == 2); | ||
} | ||
|
||
TEST(UT_TagProxyHandle, Query) | ||
{ | ||
int isRun = 0; | ||
stub_ext::StubExt stub; | ||
auto func = static_cast<QDBusPendingReply<QDBusVariant> (OrgDeepinFilemanagerServerTagManagerInterface::*)(int opt, const QStringList &)>(&OrgDeepinFilemanagerServerTagManagerInterface::Query); | ||
stub.set_lamda(func, [&isRun]() { | ||
isRun++; | ||
return QDBusPendingReply<QDBusVariant>(); | ||
}); | ||
|
||
TagProxyHandle::instance()->getTagsColor(QStringList()); | ||
TagProxyHandle::instance()->getFilesThroughTag(QStringList()); | ||
TagProxyHandle::instance()->getSameTagsOfDiffFiles(QStringList()); | ||
TagProxyHandle::instance()->getTagsThroughFile(QStringList()); | ||
EXPECT_TRUE(isRun == 4); | ||
} | ||
|
||
TEST(UT_TagProxyHandle, Query2) | ||
{ | ||
int isRun = 0; | ||
stub_ext::StubExt stub; | ||
auto func = static_cast<QDBusPendingReply<QDBusVariant> (OrgDeepinFilemanagerServerTagManagerInterface::*)(int opt)>(&OrgDeepinFilemanagerServerTagManagerInterface::Query); | ||
stub.set_lamda(func, [&isRun]() { | ||
isRun++; | ||
return QDBusPendingReply<QDBusVariant>(); | ||
}); | ||
|
||
TagProxyHandle::instance()->getAllFileWithTags(); | ||
EXPECT_TRUE(isRun == 1); | ||
} |
128 changes: 128 additions & 0 deletions
128
tests/plugins/common/dfmplugin-tag/event/ut_tageventcaller.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,128 @@ | ||
// SPDX-FileCopyrightText: 2022 - 2023 UnionTech Software Technology Co., Ltd. | ||
// | ||
// SPDX-License-Identifier: GPL-3.0-or-later | ||
|
||
#include "stubext.h" | ||
#include "events/tageventcaller.h" | ||
|
||
#include <dfm-base/dfm_event_defines.h> | ||
|
||
#include <dfm-framework/event/event.h> | ||
|
||
#include <gtest/gtest.h> | ||
#include <QRect> | ||
DFMBASE_USE_NAMESPACE | ||
DPF_USE_NAMESPACE | ||
using namespace dfmplugin_tag; | ||
|
||
Q_DECLARE_METATYPE(QRectF *) | ||
Q_DECLARE_METATYPE(QPoint *) | ||
|
||
TEST(UT_TagEventCaller, sendOpenWindow) | ||
{ | ||
bool isCall { false }; | ||
|
||
stub_ext::StubExt stub; | ||
typedef bool (EventDispatcherManager::*FuncType)(EventType, QUrl); | ||
stub.set_lamda(static_cast<FuncType>(&EventDispatcherManager::publish), [&isCall] { | ||
isCall = true; | ||
return true; | ||
}); | ||
|
||
TagEventCaller::sendOpenWindow(QUrl()); | ||
|
||
EXPECT_TRUE(isCall); | ||
} | ||
|
||
TEST(UT_TagEventCaller, sendOpenTab) | ||
{ | ||
bool isCall { false }; | ||
|
||
stub_ext::StubExt stub; | ||
typedef bool (EventDispatcherManager::*FuncType)(EventType, quint64, const QUrl &); | ||
stub.set_lamda(static_cast<FuncType>(&EventDispatcherManager::publish), [&isCall] { | ||
isCall = true; | ||
return true; | ||
}); | ||
|
||
TagEventCaller::sendOpenTab(0, QUrl()); | ||
|
||
EXPECT_TRUE(isCall); | ||
} | ||
|
||
TEST(UT_TagEventCaller, sendCheckTabAddable) | ||
{ | ||
bool isCall { false }; | ||
|
||
stub_ext::StubExt stub; | ||
typedef QVariant (EventChannelManager::*FuncType)(const QString &, const QString &, quint64); | ||
stub.set_lamda(static_cast<FuncType>(&EventChannelManager::push), [&isCall] { | ||
isCall = true; | ||
return true; | ||
}); | ||
TagEventCaller::sendCheckTabAddable(0); | ||
|
||
EXPECT_TRUE(isCall); | ||
} | ||
|
||
TEST(UT_TagEventCaller, getCollectionView) | ||
{ | ||
bool isCall { false }; | ||
|
||
stub_ext::StubExt stub; | ||
typedef QVariant (EventChannelManager::*FuncType)(const QString &, const QString &, QString); | ||
stub.set_lamda(static_cast<FuncType>(&EventChannelManager::push), [&isCall] { | ||
isCall = true; | ||
return QVariant(); | ||
}); | ||
|
||
TagEventCaller::getCollectionView(""); | ||
|
||
EXPECT_TRUE(isCall); | ||
} | ||
|
||
TEST(UT_TagEventCaller, sendOpenFiles) | ||
{ | ||
bool isCall { false }; | ||
|
||
stub_ext::StubExt stub; | ||
typedef bool (EventDispatcherManager::*FuncType)(EventType, quint64, const QList<QUrl> &); | ||
stub.set_lamda(static_cast<FuncType>(&EventDispatcherManager::publish), [&isCall] { | ||
isCall = true; | ||
return true; | ||
}); | ||
|
||
TagEventCaller::sendOpenFiles(0, QList<QUrl>() << QUrl()); | ||
|
||
EXPECT_TRUE(isCall); | ||
} | ||
|
||
TEST(UT_TagEventCaller, getCollectionVisualRect) | ||
{ | ||
bool isCall { false }; | ||
|
||
stub_ext::StubExt stub; | ||
typedef QVariant (EventChannelManager::*FuncType)(const QString &, const QString &, QString, const QUrl &); | ||
stub.set_lamda(static_cast<FuncType>(&EventChannelManager::push), [&isCall] { | ||
isCall = true; | ||
return QVariant(); | ||
}); | ||
TagEventCaller::getCollectionVisualRect("", QUrl()); | ||
|
||
EXPECT_TRUE(isCall); | ||
} | ||
|
||
TEST(UT_TagEventCaller, getCollectionIconRect) | ||
{ | ||
bool isCall { false }; | ||
|
||
stub_ext::StubExt stub; | ||
typedef QVariant (EventChannelManager::*FuncType)(const QString &, const QString &, QString, QRect &); | ||
stub.set_lamda(static_cast<FuncType>(&EventChannelManager::push), [&isCall] { | ||
isCall = true; | ||
return QVariant(); | ||
}); | ||
TagEventCaller::getCollectionIconRect("", QRect()); | ||
|
||
EXPECT_TRUE(isCall); | ||
} |
Oops, something went wrong.