2022-08-19 15:59:36 +02:00
|
|
|
// Copyright (C) 2016 The Qt Company Ltd.
|
|
|
|
|
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0+ OR GPL-3.0 WITH Qt-GPL-exception-1.0
|
2014-10-07 12:30:54 +02:00
|
|
|
|
2016-03-18 07:55:01 +01:00
|
|
|
#pragma once
|
2014-10-07 12:30:54 +02:00
|
|
|
|
2018-06-07 17:55:02 +03:00
|
|
|
#include "autotest_global.h"
|
|
|
|
|
|
2020-07-07 10:57:38 +02:00
|
|
|
#include "itemdatacache.h"
|
2016-02-03 15:59:59 +01:00
|
|
|
#include "testtreeitem.h"
|
2014-10-07 15:51:02 +02:00
|
|
|
|
2020-10-09 13:07:55 +02:00
|
|
|
#include <utils/id.h>
|
2015-09-10 15:32:12 +02:00
|
|
|
#include <utils/treemodel.h>
|
|
|
|
|
|
2014-11-11 17:30:34 +01:00
|
|
|
#include <QSortFilterProxyModel>
|
2014-10-07 12:30:54 +02:00
|
|
|
|
2020-10-19 14:46:21 +02:00
|
|
|
namespace ProjectExplorer { class Target; }
|
|
|
|
|
|
2014-10-07 12:30:54 +02:00
|
|
|
namespace Autotest {
|
|
|
|
|
namespace Internal {
|
2020-03-16 12:59:23 +01:00
|
|
|
class AutotestPluginPrivate;
|
2014-10-07 12:30:54 +02:00
|
|
|
class TestCodeParser;
|
2019-08-19 10:55:32 +02:00
|
|
|
} // namespace Internal
|
2014-10-07 12:30:54 +02:00
|
|
|
|
2019-08-19 10:55:32 +02:00
|
|
|
class TestParseResult;
|
2016-04-12 12:44:56 +02:00
|
|
|
using TestParseResultPtr = QSharedPointer<TestParseResult>;
|
|
|
|
|
|
2020-10-29 14:27:55 +01:00
|
|
|
class AUTOTESTSHARED_EXPORT TestTreeModel : public Utils::TreeModel<Utils::TreeItem, ITestTreeItem>
|
2014-10-07 12:30:54 +02:00
|
|
|
{
|
|
|
|
|
Q_OBJECT
|
2020-03-16 12:59:23 +01:00
|
|
|
|
|
|
|
|
friend class Internal::AutotestPluginPrivate; // For ctor.
|
|
|
|
|
explicit TestTreeModel(Internal::TestCodeParser *parser);
|
|
|
|
|
|
2014-10-07 12:30:54 +02:00
|
|
|
public:
|
|
|
|
|
static TestTreeModel* instance();
|
2018-07-11 15:44:51 +02:00
|
|
|
~TestTreeModel() override;
|
2014-10-07 12:30:54 +02:00
|
|
|
|
2015-09-10 15:32:12 +02:00
|
|
|
bool setData(const QModelIndex &index, const QVariant &value, int role) override;
|
|
|
|
|
Qt::ItemFlags flags(const QModelIndex &index) const override;
|
2014-10-07 12:30:54 +02:00
|
|
|
|
2019-08-19 10:55:32 +02:00
|
|
|
Internal::TestCodeParser *parser() const { return m_parser; }
|
2014-10-07 12:30:54 +02:00
|
|
|
bool hasTests() const;
|
2020-10-13 11:37:37 +02:00
|
|
|
QList<ITestConfiguration *> getAllTestCases() const;
|
|
|
|
|
QList<ITestConfiguration *> getSelectedTests() const;
|
|
|
|
|
QList<ITestConfiguration *> getFailedTests() const;
|
|
|
|
|
QList<ITestConfiguration *> getTestsForFile(const Utils::FilePath &fileName) const;
|
2021-01-27 14:38:13 +01:00
|
|
|
QList<ITestTreeItem *> testItemsByName(const QString &testName);
|
2019-09-05 10:42:01 +02:00
|
|
|
void synchronizeTestFrameworks();
|
2020-10-19 14:46:21 +02:00
|
|
|
void synchronizeTestTools();
|
2020-06-26 13:59:38 +02:00
|
|
|
void rebuild(const QList<Utils::Id> &frameworkIds);
|
2014-11-06 16:01:06 +01:00
|
|
|
|
2020-06-03 14:27:01 +02:00
|
|
|
void updateCheckStateCache();
|
2020-09-11 14:30:15 +02:00
|
|
|
bool hasFailedTests() const;
|
|
|
|
|
void clearFailedMarks();
|
2015-02-10 14:20:43 +01:00
|
|
|
#ifdef WITH_TESTS
|
|
|
|
|
int autoTestsCount() const;
|
|
|
|
|
int namedQuickTestsCount() const;
|
2021-01-27 14:38:13 +01:00
|
|
|
bool hasUnnamedQuickTests(const ITestTreeItem *rootNode) const;
|
2015-02-10 14:20:43 +01:00
|
|
|
int unnamedQuickTestsCount() const;
|
2021-01-27 14:38:13 +01:00
|
|
|
ITestTreeItem *unnamedQuickTests() const;
|
2015-11-02 11:06:19 +01:00
|
|
|
int dataTagsCount() const;
|
2015-12-10 13:46:04 +01:00
|
|
|
int gtestNamesCount() const;
|
2016-01-13 09:10:11 +01:00
|
|
|
QMultiMap<QString, int> gtestNamesAndSets() const;
|
2019-05-21 13:39:00 +02:00
|
|
|
int boostTestNamesCount() const;
|
2020-03-25 16:29:04 +01:00
|
|
|
QMap<QString, int> boostTestSuitesAndTests() const;
|
2015-02-10 14:20:43 +01:00
|
|
|
#endif
|
2014-11-06 16:01:06 +01:00
|
|
|
|
2020-10-19 13:56:19 +02:00
|
|
|
void markAllFrameworkItemsForRemoval();
|
2021-05-26 15:50:03 +02:00
|
|
|
void markForRemoval(const Utils::FilePath &filePath);
|
2016-01-26 13:52:45 +01:00
|
|
|
void sweep();
|
2016-01-25 09:30:41 +01:00
|
|
|
|
2014-10-07 12:30:54 +02:00
|
|
|
signals:
|
2014-11-04 13:42:38 +01:00
|
|
|
void testTreeModelChanged();
|
2016-06-08 12:56:25 +02:00
|
|
|
void updatedActiveFrameworks(int numberOfActiveFrameworks);
|
2016-02-10 10:43:31 +01:00
|
|
|
#ifdef WITH_TESTS
|
|
|
|
|
void sweepingDone();
|
|
|
|
|
#endif
|
2014-10-07 12:30:54 +02:00
|
|
|
|
|
|
|
|
private:
|
2016-04-12 12:44:56 +02:00
|
|
|
void onParseResultReady(const TestParseResultPtr result);
|
2020-09-23 10:48:29 +02:00
|
|
|
void onDataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight,
|
|
|
|
|
const QVector<int> &roles);
|
2016-05-09 10:27:47 +02:00
|
|
|
void handleParseResult(const TestParseResult *result, TestTreeItem *rootNode);
|
2015-02-05 16:07:45 +01:00
|
|
|
void removeAllTestItems();
|
2020-10-19 14:46:21 +02:00
|
|
|
void removeAllTestToolItems();
|
2021-05-26 15:50:03 +02:00
|
|
|
void removeFiles(const Utils::FilePaths &files);
|
2016-02-01 10:04:02 +01:00
|
|
|
bool sweepChildren(TestTreeItem *item);
|
2018-01-23 16:12:47 +01:00
|
|
|
void insertItemInParent(TestTreeItem *item, TestTreeItem *root, bool groupingEnabled);
|
2020-10-12 14:11:10 +02:00
|
|
|
void revalidateCheckState(ITestTreeItem *item);
|
2016-02-01 15:12:10 +01:00
|
|
|
void setupParsingConnections();
|
2018-02-28 09:42:13 +01:00
|
|
|
void filterAndInsert(TestTreeItem *item, TestTreeItem *root, bool groupingEnabled);
|
2020-10-19 14:46:21 +02:00
|
|
|
void onTargetChanged(ProjectExplorer::Target *target);
|
|
|
|
|
void onBuildSystemTestsUpdated();
|
2020-10-29 14:27:55 +01:00
|
|
|
const QList<TestTreeItem *> frameworkRootNodes() const;
|
|
|
|
|
const QList<ITestTreeItem *> testToolRootNodes() const;
|
2014-10-07 12:30:54 +02:00
|
|
|
|
2019-08-19 10:55:32 +02:00
|
|
|
Internal::TestCodeParser *m_parser = nullptr;
|
2020-07-07 10:57:38 +02:00
|
|
|
Internal::ItemDataCache<Qt::CheckState> *m_checkStateCache = nullptr; // not owned
|
2020-09-24 08:33:51 +02:00
|
|
|
Internal::ItemDataCache<bool> m_failedStateCache;
|
2014-10-07 12:30:54 +02:00
|
|
|
};
|
|
|
|
|
|
2019-08-19 10:55:32 +02:00
|
|
|
namespace Internal {
|
|
|
|
|
|
2014-11-11 17:30:34 +01:00
|
|
|
class TestTreeSortFilterModel : public QSortFilterProxyModel
|
|
|
|
|
{
|
|
|
|
|
Q_OBJECT
|
|
|
|
|
public:
|
|
|
|
|
enum FilterMode {
|
|
|
|
|
Basic,
|
|
|
|
|
ShowInitAndCleanup = 0x01,
|
|
|
|
|
ShowTestData = 0x02,
|
|
|
|
|
ShowAll = ShowInitAndCleanup | ShowTestData
|
|
|
|
|
};
|
|
|
|
|
|
2018-05-31 07:38:04 +02:00
|
|
|
explicit TestTreeSortFilterModel(TestTreeModel *sourceModel, QObject *parent = nullptr);
|
2021-01-27 14:38:13 +01:00
|
|
|
void setSortMode(ITestTreeItem::SortMode sortMode);
|
2014-11-11 17:30:34 +01:00
|
|
|
void setFilterMode(FilterMode filterMode);
|
|
|
|
|
void toggleFilter(FilterMode filterMode);
|
|
|
|
|
static FilterMode toFilterMode(int f);
|
|
|
|
|
|
|
|
|
|
protected:
|
2020-11-18 15:26:38 +01:00
|
|
|
bool lessThan(const QModelIndex &left, const QModelIndex &right) const final;
|
|
|
|
|
bool filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const final;
|
2014-11-11 17:30:34 +01:00
|
|
|
|
|
|
|
|
private:
|
2019-08-19 10:55:32 +02:00
|
|
|
Autotest::TestTreeItem::SortMode m_sortMode = Autotest::TestTreeItem::Alphabetically;
|
2016-09-29 12:15:43 +02:00
|
|
|
FilterMode m_filterMode = Basic;
|
2014-11-11 17:30:34 +01:00
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
2014-10-07 12:30:54 +02:00
|
|
|
} // namespace Internal
|
|
|
|
|
} // namespace Autotest
|