forked from qt-creator/qt-creator
TaskTree: Add TreeStorageBase::operator==
Change-Id: I50144978b86f2e5fa89fc35c687b64ed102803e6 Reviewed-by: hjk <hjk@qt.io> Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
This commit is contained in:
@@ -31,6 +31,10 @@ class QTCREATOR_UTILS_EXPORT TreeStorageBase
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
bool isValid() const;
|
bool isValid() const;
|
||||||
|
friend bool operator==(const TreeStorageBase &first, const TreeStorageBase &second)
|
||||||
|
{ return first.m_storageData == second.m_storageData; }
|
||||||
|
friend bool operator!=(const TreeStorageBase &first, const TreeStorageBase &second)
|
||||||
|
{ return first.m_storageData != second.m_storageData; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
using StorageConstructor = std::function<void *(void)>;
|
using StorageConstructor = std::function<void *(void)>;
|
||||||
|
@@ -14,6 +14,7 @@
|
|||||||
#include <fstream>
|
#include <fstream>
|
||||||
|
|
||||||
using namespace Utils;
|
using namespace Utils;
|
||||||
|
using namespace Utils::Tasking;
|
||||||
|
|
||||||
enum class Handler {
|
enum class Handler {
|
||||||
Setup,
|
Setup,
|
||||||
@@ -38,6 +39,7 @@ private slots:
|
|||||||
void processTree();
|
void processTree();
|
||||||
void storage_data();
|
void storage_data();
|
||||||
void storage();
|
void storage();
|
||||||
|
void storageOperators();
|
||||||
void storageDestructor();
|
void storageDestructor();
|
||||||
|
|
||||||
void cleanupTestCase();
|
void cleanupTestCase();
|
||||||
@@ -65,8 +67,6 @@ void tst_TaskTree::cleanupTestCase()
|
|||||||
|
|
||||||
void tst_TaskTree::validConstructs()
|
void tst_TaskTree::validConstructs()
|
||||||
{
|
{
|
||||||
using namespace Tasking;
|
|
||||||
|
|
||||||
const Group process {
|
const Group process {
|
||||||
parallel,
|
parallel,
|
||||||
Process([](QtcProcess &) {}, [](const QtcProcess &) {}),
|
Process([](QtcProcess &) {}, [](const QtcProcess &) {}),
|
||||||
@@ -107,7 +107,6 @@ static const char s_processIdProperty[] = "__processId";
|
|||||||
|
|
||||||
void tst_TaskTree::processTree_data()
|
void tst_TaskTree::processTree_data()
|
||||||
{
|
{
|
||||||
using namespace Tasking;
|
|
||||||
using namespace std::placeholders;
|
using namespace std::placeholders;
|
||||||
|
|
||||||
QTest::addColumn<Group>("root");
|
QTest::addColumn<Group>("root");
|
||||||
@@ -462,7 +461,6 @@ void tst_TaskTree::processTree_data()
|
|||||||
void tst_TaskTree::processTree()
|
void tst_TaskTree::processTree()
|
||||||
{
|
{
|
||||||
m_log = {};
|
m_log = {};
|
||||||
using namespace Tasking;
|
|
||||||
|
|
||||||
QFETCH(Group, root);
|
QFETCH(Group, root);
|
||||||
QFETCH(Log, expectedLog);
|
QFETCH(Log, expectedLog);
|
||||||
@@ -519,7 +517,6 @@ static Log s_log;
|
|||||||
|
|
||||||
void tst_TaskTree::storage_data()
|
void tst_TaskTree::storage_data()
|
||||||
{
|
{
|
||||||
using namespace Tasking;
|
|
||||||
using namespace std::placeholders;
|
using namespace std::placeholders;
|
||||||
|
|
||||||
QTest::addColumn<Group>("root");
|
QTest::addColumn<Group>("root");
|
||||||
@@ -599,8 +596,6 @@ void tst_TaskTree::storage_data()
|
|||||||
|
|
||||||
void tst_TaskTree::storage()
|
void tst_TaskTree::storage()
|
||||||
{
|
{
|
||||||
using namespace Tasking;
|
|
||||||
|
|
||||||
QFETCH(Group, root);
|
QFETCH(Group, root);
|
||||||
QFETCH(TreeStorage<CustomStorage>, storageLog);
|
QFETCH(TreeStorage<CustomStorage>, storageLog);
|
||||||
QFETCH(Log, expectedLog);
|
QFETCH(Log, expectedLog);
|
||||||
@@ -639,10 +634,19 @@ void tst_TaskTree::storage()
|
|||||||
QCOMPARE(errorCount, expectedErrorCount);
|
QCOMPARE(errorCount, expectedErrorCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void tst_TaskTree::storageOperators()
|
||||||
|
{
|
||||||
|
TreeStorageBase storage1 = TreeStorage<CustomStorage>();
|
||||||
|
TreeStorageBase storage2 = TreeStorage<CustomStorage>();
|
||||||
|
TreeStorageBase storage3 = storage1;
|
||||||
|
|
||||||
|
QVERIFY(storage1 == storage3);
|
||||||
|
QVERIFY(storage1 != storage2);
|
||||||
|
QVERIFY(storage2 != storage3);
|
||||||
|
}
|
||||||
|
|
||||||
void tst_TaskTree::storageDestructor()
|
void tst_TaskTree::storageDestructor()
|
||||||
{
|
{
|
||||||
using namespace Tasking;
|
|
||||||
|
|
||||||
QCOMPARE(CustomStorage::instanceCount(), 0);
|
QCOMPARE(CustomStorage::instanceCount(), 0);
|
||||||
{
|
{
|
||||||
const auto setupProcess = [this](QtcProcess &process) {
|
const auto setupProcess = [this](QtcProcess &process) {
|
||||||
|
Reference in New Issue
Block a user