2014-10-07 15:51:02 +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 15:51:02 +02:00
|
|
|
**
|
2016-01-22 10:37:55 +01:00
|
|
|
** This file is part of Qt Creator.
|
2014-10-07 15:51:02 +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 15:51:02 +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 15:51:02 +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 15:51:02 +02:00
|
|
|
**
|
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
2016-03-18 07:55:01 +01:00
|
|
|
#pragma once
|
2014-10-07 15:51:02 +02:00
|
|
|
|
|
|
|
|
#include "testresult.h"
|
|
|
|
|
|
|
|
|
|
#include <QAbstractItemModel>
|
2014-10-21 13:10:37 +02:00
|
|
|
#include <QSortFilterProxyModel>
|
2014-10-07 15:51:02 +02:00
|
|
|
#include <QFont>
|
2014-10-21 13:10:37 +02:00
|
|
|
#include <QSet>
|
2014-10-07 15:51:02 +02:00
|
|
|
|
2019-04-15 16:08:10 +02:00
|
|
|
#include <utils/optional.h>
|
2015-08-20 15:59:15 +02:00
|
|
|
#include <utils/treemodel.h>
|
|
|
|
|
|
2014-10-07 15:51:02 +02:00
|
|
|
namespace Autotest {
|
|
|
|
|
namespace Internal {
|
|
|
|
|
|
2019-02-06 08:57:33 +01:00
|
|
|
class TestResultItem : public Utils::TypedTreeItem<TestResultItem, TestResultItem>
|
2015-08-20 15:59:15 +02:00
|
|
|
{
|
|
|
|
|
public:
|
2016-02-25 13:02:31 +01:00
|
|
|
explicit TestResultItem(const TestResultPtr &testResult);
|
2016-09-29 12:15:43 +02:00
|
|
|
QVariant data(int column, int role) const override;
|
2016-02-25 13:02:31 +01:00
|
|
|
const TestResult *testResult() const { return m_testResult.data(); }
|
2015-08-20 15:59:15 +02:00
|
|
|
void updateDescription(const QString &description);
|
2019-04-15 16:08:10 +02:00
|
|
|
|
|
|
|
|
struct SummaryEvaluation
|
|
|
|
|
{
|
|
|
|
|
bool failed = false;
|
|
|
|
|
bool warnings = false;
|
|
|
|
|
|
|
|
|
|
bool operator==(const SummaryEvaluation &other) const
|
|
|
|
|
{ return failed == other.failed && warnings == other.warnings; }
|
|
|
|
|
bool operator!=(const SummaryEvaluation &other) const
|
|
|
|
|
{ return !(*this == other); }
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
void updateResult(bool &changed, ResultType addedChildType,
|
|
|
|
|
const Utils::optional<SummaryEvaluation> &summary);
|
2016-10-31 13:11:52 +01:00
|
|
|
|
|
|
|
|
TestResultItem *intermediateFor(const TestResultItem *item) const;
|
|
|
|
|
TestResultItem *createAndAddIntermediateFor(const TestResultItem *child);
|
2019-04-15 16:08:10 +02:00
|
|
|
QString resultString() const;
|
|
|
|
|
Utils::optional<SummaryEvaluation> summaryResult() const { return m_summaryResult; }
|
2015-08-20 15:59:15 +02:00
|
|
|
|
|
|
|
|
private:
|
2016-02-25 13:02:31 +01:00
|
|
|
TestResultPtr m_testResult;
|
2019-04-15 16:08:10 +02:00
|
|
|
Utils::optional<SummaryEvaluation> m_summaryResult;
|
2015-08-20 15:59:15 +02:00
|
|
|
};
|
|
|
|
|
|
2019-02-06 08:57:33 +01:00
|
|
|
class TestResultModel : public Utils::TreeModel<TestResultItem>
|
2014-10-07 15:51:02 +02:00
|
|
|
{
|
|
|
|
|
public:
|
2018-05-31 07:38:04 +02:00
|
|
|
explicit TestResultModel(QObject *parent = nullptr);
|
2015-08-20 15:59:15 +02:00
|
|
|
|
2016-02-25 13:02:31 +01:00
|
|
|
void addTestResult(const TestResultPtr &testResult, bool autoExpand = false);
|
2014-12-05 14:01:16 +01:00
|
|
|
void removeCurrentTestMessage();
|
2014-10-07 15:51:02 +02:00
|
|
|
void clearTestResults();
|
|
|
|
|
|
2016-04-13 10:20:17 +02:00
|
|
|
const TestResult *testResult(const QModelIndex &idx);
|
2014-10-07 15:51:02 +02:00
|
|
|
|
|
|
|
|
int maxWidthOfFileName(const QFont &font);
|
|
|
|
|
int maxWidthOfLineNumber(const QFont &font);
|
|
|
|
|
|
2019-02-06 14:11:19 +01:00
|
|
|
int resultTypeCount(ResultType type) const { return m_testResultCount.value(type, 0); }
|
2015-12-14 12:48:58 +01:00
|
|
|
int disabledTests() const { return m_disabled; }
|
2019-03-20 09:03:11 +01:00
|
|
|
void raiseDisabledTests(int amount) { m_disabled += amount; }
|
2014-10-07 15:51:02 +02:00
|
|
|
|
|
|
|
|
private:
|
2016-10-31 13:11:52 +01:00
|
|
|
void recalculateMaxWidthOfFileName(const QFont &font);
|
|
|
|
|
void addFileName(const QString &fileName);
|
|
|
|
|
TestResultItem *findParentItemFor(const TestResultItem *item,
|
2018-05-31 07:38:04 +02:00
|
|
|
const TestResultItem *startItem = nullptr) const;
|
2017-12-13 13:10:00 +01:00
|
|
|
void updateParent(const TestResultItem *item);
|
2019-02-06 14:11:19 +01:00
|
|
|
QMap<ResultType, int> m_testResultCount;
|
2016-09-29 12:15:43 +02:00
|
|
|
int m_widthOfLineNumber = 0;
|
|
|
|
|
int m_maxWidthOfFileName = 0;
|
|
|
|
|
int m_disabled = 0;
|
2016-10-31 13:11:52 +01:00
|
|
|
QSet<QString> m_fileNames; // TODO: check whether this caching is necessary at all
|
2014-10-07 15:51:02 +02:00
|
|
|
QFont m_measurementFont;
|
|
|
|
|
};
|
|
|
|
|
|
2014-10-21 13:10:37 +02:00
|
|
|
class TestResultFilterModel : public QSortFilterProxyModel
|
|
|
|
|
{
|
|
|
|
|
Q_OBJECT
|
|
|
|
|
public:
|
2018-05-31 07:38:04 +02:00
|
|
|
explicit TestResultFilterModel(TestResultModel *sourceModel, QObject *parent = nullptr);
|
2014-10-21 13:10:37 +02:00
|
|
|
|
2019-04-16 09:21:36 +02:00
|
|
|
void enableAllResultTypes(bool enabled);
|
2019-02-06 14:11:19 +01:00
|
|
|
void toggleTestResultType(ResultType type);
|
2014-10-21 13:10:37 +02:00
|
|
|
void clearTestResults();
|
|
|
|
|
bool hasResults();
|
2016-04-13 10:20:17 +02:00
|
|
|
const TestResult *testResult(const QModelIndex &index) const;
|
2019-04-15 16:08:10 +02:00
|
|
|
TestResultItem *itemForIndex(const QModelIndex &index) const;
|
2014-10-21 13:10:37 +02:00
|
|
|
|
|
|
|
|
protected:
|
2016-09-29 12:15:43 +02:00
|
|
|
bool filterAcceptsRow(int sourceRow, const QModelIndex &sourceParent) const override;
|
2014-10-21 13:10:37 +02:00
|
|
|
|
|
|
|
|
private:
|
2016-10-31 13:11:52 +01:00
|
|
|
bool acceptTestCaseResult(const QModelIndex &srcIndex) const;
|
2014-10-21 13:10:37 +02:00
|
|
|
TestResultModel *m_sourceModel;
|
2019-02-06 14:11:19 +01:00
|
|
|
QSet<ResultType> m_enabled;
|
2014-10-21 13:10:37 +02:00
|
|
|
};
|
|
|
|
|
|
2014-10-07 15:51:02 +02:00
|
|
|
} // namespace Internal
|
|
|
|
|
} // namespace Autotest
|