Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
qabstractitemmodeltester.h
Go to the documentation of this file.
1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
4#ifndef QABSTRACTITEMMODELTESTER_H
5#define QABSTRACTITEMMODELTESTER_H
6
7#include <QtCore/QObject>
8#include <QtTest/qttestglobal.h>
9#include <QtCore/QAbstractItemModel>
10#include <QtCore/QVariant>
11
12#ifdef QT_GUI_LIB
13#include <QtGui/QFont>
14#include <QtGui/QColor>
15#include <QtGui/QBrush>
16#include <QtGui/QPixmap>
17#include <QtGui/QImage>
18#include <QtGui/QIcon>
19#endif
20
21QT_REQUIRE_CONFIG(itemmodeltester);
22
24
28
29namespace QTestPrivate {
31}
32
33class Q_TESTLIB_EXPORT QAbstractItemModelTester : public QObject
34{
36 Q_DECLARE_PRIVATE(QAbstractItemModelTester)
37
38public:
40 QtTest,
41 Warning,
42 Fatal
43 };
44
46 QAbstractItemModelTester(QAbstractItemModel *model, FailureReportingMode mode, QObject *parent = nullptr);
47
49 FailureReportingMode failureReportingMode() const;
50 void setUseFetchMore(bool value);
51
52private:
54 bool verify(bool statement, const char *statementStr, const char *description, const char *file, int line);
55};
56
57namespace QTestPrivate {
59{
60#ifdef QT_GUI_LIB
61
62#define MODELTESTER_VERIFY(statement) \
63do { \
64 if (!tester->verify(static_cast<bool>(statement), #statement, "", __FILE__, __LINE__)) \
65 return false; \
66} while (false)
67
68 const auto model = tester->model();
70
71 if (!model->hasChildren())
72 return true;
73
75
77 if (variant.isValid()) {
83 }
84
85 // General Purpose roles that should return a QFont
87 if (variant.isValid())
89
90 // General Purpose roles that should return a QColor or a QBrush
92 if (variant.isValid())
94
96 if (variant.isValid())
98
99#undef MODELTESTER_VERIFY
100
101#else
102 Q_UNUSED(tester);
103#endif // QT_GUI_LIB
104
105 return true;
106}
107} // namespaceQTestPrivate
108
110
111#endif // QABSTRACTITEMMODELTESTER_H
The QAbstractItemModelTester class helps testing QAbstractItemModel subclasses.
FailureReportingMode
This enumeration specifies how QAbstractItemModelTester should report a failure when it tests a QAbst...
QModelIndex index(int row, int column, const QModelIndex &parent=QModelIndex()) const override
Returns the index of the data in row and column with parent.
\inmodule QtGui
Definition qbrush.h:30
The QColor class provides colors based on RGB, HSV or CMYK values.
Definition qcolor.h:31
\reentrant
Definition qfont.h:22
The QIcon class provides scalable icons in different modes and states.
Definition qicon.h:20
\inmodule QtGui
Definition qimage.h:37
\inmodule QtCore
Definition qobject.h:103
Returns a copy of the pixmap that is transformed using the given transformation transform and transfo...
Definition qpixmap.h:27
QVariant data(const QModelIndex &item, int role=Qt::DisplayRole) const override
Returns the value for the specified item and role.
\inmodule QtCore
Definition qvariant.h:65
bool isValid() const
Returns true if the storage type of this variant is not QMetaType::UnknownType; otherwise returns fal...
Definition qvariant.h:714
bool canConvert(QMetaType targetType) const
Definition qvariant.h:345
Combined button and popup list for selecting options.
bool testDataGuiRoles(QAbstractItemModelTester *tester)
@ FontRole
@ ForegroundRole
@ DecorationRole
@ BackgroundRole
#define MODELTESTER_VERIFY(statement)
EGLOutputLayerEXT EGLint EGLAttrib value
[5]
GLenum mode
#define Q_ASSERT(cond)
Definition qrandom.cpp:47
#define QT_REQUIRE_CONFIG(feature)
#define Q_OBJECT
#define Q_UNUSED(x)
QSqlQueryModel * model
[16]
QFile file
[0]
QVariant variant
[1]