/
redgpu
/
ezEngine
Обзор
Документация
Войти
/
redgpu
/
ezEngine
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
dev
Code/UnitTests/TestFramework/Framework/Qt/qtTestModel.h
114 строк
3 KB
Ingrater
Clang-format fixes and update to 18.1.1 (#1234)
10 мар 2024, 15:51
Не верифицирован
10 мар 2024, 15:51
2f16acf
Код
Авторство
О чём код?
#pragma once #ifdef EZ_USE_QT # include <QAbstractItemModel> # include <QColor> # include <QIcon> # include <TestFramework/Framework/Qt/qtTestFramework.h> # include <TestFramework/TestFrameworkDLL.h> class ezQtTestFramework; /// \brief Helper class that stores the test hierarchy used in ezQtTestModel. class ezQtTestModelEntry { public: ezQtTestModelEntry(const ezTestFrameworkResult* pResult, ezInt32 iTestIndex = -1, ezInt32 iSubTestIndex = -1); ~ezQtTestModelEntry(); private: ezQtTestModelEntry(ezQtTestModelEntry&); void operator=(ezQtTestModelEntry&); public: enum ezTestModelEntryType { RootNode, TestNode, SubTestNode }; void ClearEntries(); ezUInt32 GetNumSubEntries() const; ezQtTestModelEntry* GetSubEntry(ezUInt32 uiIndex) const; void AddSubEntry(ezQtTestModelEntry* pEntry); ezQtTestModelEntry* GetParentEntry() const { return m_pParentEntry; } ezUInt32 GetIndexInParent() const { return m_uiIndexInParent; } ezTestModelEntryType GetNodeType() const; const ezTestResultData* GetTestResult() const; ezInt32 GetTestIndex() const { return m_iTestIndex; } ezInt32 GetSubTestIndex() const { return m_iSubTestIndex; } private: const ezTestFrameworkResult* m_pResult; ezInt32 m_iTestIndex; ezInt32 m_iSubTestIndex; ezQtTestModelEntry* m_pParentEntry = nullptr; ezUInt32 m_uiIndexInParent = 0; std::deque<ezQtTestModelEntry*> m_SubEntries; }; /// \brief A Model that lists all unit tests and sub-tests in a tree. class EZ_TEST_DLL ezQtTestModel : public QAbstractItemModel { Q_OBJECT public: ezQtTestModel(QObject* pParent, ezQtTestFramework* pTestFramework); virtual ~ezQtTestModel(); void Reset(); void InvalidateAll(); void TestDataChanged(ezInt32 iTestIndex, ezInt32 iSubTestIndex); struct UserRoles { enum Enum { Duration = Qt::UserRole, DurationColor = Qt::UserRole + 1, }; }; struct Columns { enum Enum { Name = 0, Status, Duration, Errors, Asserts, Progress, ColumnCount, }; }; public: // QAbstractItemModel interface virtual QVariant data(const QModelIndex& index, int iRole) const override; virtual Qt::ItemFlags flags(const QModelIndex& index) const override; virtual QVariant headerData(int iSection, Qt::Orientation orientation, int iRole = Qt::DisplayRole) const override; virtual QModelIndex index(int iRow, int iColumn, const QModelIndex& parent = QModelIndex()) const override; virtual QModelIndex parent(const QModelIndex& index) const override; virtual int rowCount(const QModelIndex& parent = QModelIndex()) const override; virtual int columnCount(const QModelIndex& parent = QModelIndex()) const override; virtual bool setData(const QModelIndex& index, const QVariant& value, int iRole = Qt::EditRole) override; public Q_SLOTS: void UpdateModel(); private: ezQtTestFramework* m_pTestFramework; ezTestFrameworkResult* m_pResult; ezQtTestModelEntry m_Root; QColor m_SucessColor; QColor m_FailedColor; QColor m_CustomStatusColor; QColor m_TestColor; QColor m_SubTestColor; QIcon m_TestIcon; QIcon m_TestIconOff; }; #endif