2014-10-07 12:30:54 +02:00
|
|
|
/****************************************************************************
|
|
|
|
|
**
|
2016-01-22 10:37:55 +01:00
|
|
|
** Copyright (C) 2016 The Qt Company Ltd.
|
|
|
|
|
** Contact: https://www.qt.io/licensing/
|
2014-10-07 12:30:54 +02:00
|
|
|
**
|
2016-01-22 10:37:55 +01:00
|
|
|
** This file is part of Qt Creator.
|
2014-10-07 12:30:54 +02:00
|
|
|
**
|
2016-01-22 10:37:55 +01:00
|
|
|
** Commercial License Usage
|
|
|
|
|
** Licensees holding valid commercial Qt licenses may use this file in
|
|
|
|
|
** accordance with the commercial license agreement provided with the
|
2014-10-07 12:30:54 +02:00
|
|
|
** Software or, alternatively, in accordance with the terms contained in
|
2016-01-22 10:37:55 +01:00
|
|
|
** a written agreement between you and The Qt Company. For licensing terms
|
|
|
|
|
** and conditions see https://www.qt.io/terms-conditions. For further
|
|
|
|
|
** information use the contact form at https://www.qt.io/contact-us.
|
2014-10-07 12:30:54 +02:00
|
|
|
**
|
2016-01-22 10:37:55 +01:00
|
|
|
** GNU General Public License Usage
|
|
|
|
|
** Alternatively, this file may be used under the terms of the GNU
|
|
|
|
|
** General Public License version 3 as published by the Free Software
|
|
|
|
|
** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
|
|
|
|
|
** included in the packaging of this file. Please review the following
|
|
|
|
|
** information to ensure the GNU General Public License requirements will
|
|
|
|
|
** be met: https://www.gnu.org/licenses/gpl-3.0.html.
|
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"
|
|
|
|
|
|
2014-10-07 15:51:02 +02:00
|
|
|
#include "testconfiguration.h"
|
2016-02-03 15:59:59 +01:00
|
|
|
#include "testtreeitem.h"
|
2014-10-07 15:51:02 +02:00
|
|
|
|
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
|
|
|
|
|
|
|
|
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>;
|
|
|
|
|
|
2018-06-07 17:55:02 +03:00
|
|
|
class AUTOTESTSHARED_EXPORT TestTreeModel : public Utils::TreeModel<>
|
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;
|
2014-10-07 15:51:02 +02:00
|
|
|
QList<TestConfiguration *> getAllTestCases() const;
|
|
|
|
|
QList<TestConfiguration *> getSelectedTests() const;
|
2019-05-28 13:49:26 +02:00
|
|
|
QList<TestConfiguration *> getTestsForFile(const Utils::FilePath &fileName) const;
|
2018-02-16 17:57:37 +01:00
|
|
|
QList<TestTreeItem *> testItemsByName(const QString &testName);
|
2019-09-05 10:42:01 +02:00
|
|
|
void synchronizeTestFrameworks();
|
2017-12-06 08:45:36 +01:00
|
|
|
void rebuild(const QList<Core::Id> &frameworkIds);
|
2014-11-06 16:01:06 +01:00
|
|
|
|
2020-06-03 14:27:01 +02:00
|
|
|
void updateCheckStateCache();
|
2015-02-10 14:20:43 +01:00
|
|
|
#ifdef WITH_TESTS
|
|
|
|
|
int autoTestsCount() const;
|
|
|
|
|
int namedQuickTestsCount() const;
|
2016-06-01 16:22:50 +02:00
|
|
|
bool hasUnnamedQuickTests(const TestTreeItem *rootNode) const;
|
2015-02-10 14:20:43 +01:00
|
|
|
int unnamedQuickTestsCount() const;
|
2016-06-01 16:22:50 +02:00
|
|
|
TestTreeItem *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
|
|
|
|
2016-01-26 13:52:45 +01:00
|
|
|
void markAllForRemoval();
|
|
|
|
|
void markForRemoval(const QString &filePath);
|
|
|
|
|
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);
|
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();
|
2016-01-25 13:05:12 +01:00
|
|
|
void removeFiles(const QStringList &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);
|
|
|
|
|
void revalidateCheckState(TestTreeItem *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);
|
2018-02-16 17:57:37 +01:00
|
|
|
QList<TestTreeItem *> testItemsByName(TestTreeItem *root, const QString &testName);
|
2014-10-07 12:30:54 +02:00
|
|
|
|
2019-08-19 10:55:32 +02:00
|
|
|
Internal::TestCodeParser *m_parser = nullptr;
|
2020-06-17 13:04:44 +02:00
|
|
|
QHash<QString, Qt::CheckState> m_checkStateCache;
|
2020-06-03 14:27:01 +02:00
|
|
|
QHash<QString, int> m_itemUseCache;
|
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);
|
2019-08-19 10:55:32 +02:00
|
|
|
void setSortMode(Autotest::TestTreeItem::SortMode sortMode);
|
2014-11-11 17:30:34 +01:00
|
|
|
void setFilterMode(FilterMode filterMode);
|
|
|
|
|
void toggleFilter(FilterMode filterMode);
|
|
|
|
|
static FilterMode toFilterMode(int f);
|
|
|
|
|
|
|
|
|
|
protected:
|
|
|
|
|
bool lessThan(const QModelIndex &left, const QModelIndex &right) const;
|
|
|
|
|
bool filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const;
|
|
|
|
|
|
|
|
|
|
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
|