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
quicktest_p.h
Go to the documentation of this file.
1// Copyright (C) 2020 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 QUICKTEST_P_H
5#define QUICKTEST_P_H
6
7//
8// W A R N I N G
9// -------------
10//
11// This file is not part of the Qt API. It exists purely as an
12// implementation detail. This header file may change from version to
13// version without notice, or even be removed.
14//
15// We mean it.
16//
17
18#include <QtQuickTest/private/quicktestglobal_p.h>
19#include <QtQuickTest/quicktest.h>
20
21#include <QtQml/qqmlpropertymap.h>
22#include <QtQml/qqml.h>
23
24#include <QtCore/qpointer.h>
25
27
28class Q_QMLTEST_EXPORT QTestRootObject : public QObject
29{
31 Q_PROPERTY(bool windowShown READ windowShown NOTIFY windowShownChanged)
32 Q_PROPERTY(bool hasTestCase READ hasTestCase WRITE setHasTestCase NOTIFY hasTestCaseChanged)
33 Q_PROPERTY(QObject *defined READ defined)
34
38
39public:
41 {
42 QTestRootObject *result = instance();
44 // You can only test on one engine at a time
45 return (engine == nullptr || engine == q) ? result : nullptr;
46 }
47
49 static QPointer<QTestRootObject> object = new QTestRootObject;
50 if (!object) {
51 // QTestRootObject was deleted when previous test ended, create a new one
52 object = new QTestRootObject;
53 }
54 return object;
55 }
56
57 bool hasQuit:1;
58 bool hasTestCase() const { return m_hasTestCase; }
59 void setHasTestCase(bool value) { m_hasTestCase = value; Q_EMIT hasTestCaseChanged(); }
60
61 bool windowShown() const { return m_windowShown; }
62 void setWindowShown(bool value) { m_windowShown = value; Q_EMIT windowShownChanged(); }
63 QQmlPropertyMap *defined() const { return m_defined; }
64
65 void init() { setWindowShown(false); setHasTestCase(false); hasQuit = false; }
66
70
71private Q_SLOTS:
72 void quit() { hasQuit = true; }
73
74private:
75 QTestRootObject(QObject *parent = nullptr)
76 : QObject(parent), hasQuit(false), m_windowShown(false), m_hasTestCase(false) {
77 m_defined = new QQmlPropertyMap(this);
78#if defined(QT_OPENGL_ES_2_ANGLE)
79 m_defined->insert(QLatin1String("QT_OPENGL_ES_2_ANGLE"), QVariant(true));
80#endif
81 }
82
83 bool m_windowShown : 1;
84 bool m_hasTestCase :1;
85 QQmlPropertyMap *m_defined;
86};
87
88bool qWaitForSignal(QObject *obj, const char* signal, int timeout = 5000);
89
91
92#endif // QUICKTEST_P_H
The QJSEngine class provides an environment for evaluating JavaScript code.
Definition qjsengine.h:26
\inmodule QtCore
Definition qobject.h:103
The QQmlEngine class provides an environment for instantiating QML components.
Definition qqmlengine.h:57
The QQmlPropertyMap class allows you to set key-value pairs that can be used in QML bindings.
void setWindowShown(bool value)
Definition quicktest_p.h:62
bool windowShown() const
Definition quicktest_p.h:61
void windowShownChanged()
static QTestRootObject * instance()
Definition quicktest_p.h:48
void hasTestCaseChanged()
bool hasTestCase() const
Definition quicktest_p.h:58
void setHasTestCase(bool value)
Definition quicktest_p.h:59
QQmlPropertyMap * defined() const
Definition quicktest_p.h:63
\inmodule QtCore
Definition qvariant.h:65
auto signal
Combined button and popup list for selecting options.
EGLOutputLayerEXT EGLint EGLAttrib value
[5]
GLuint object
[3]
GLbitfield GLuint64 timeout
[4]
GLhandleARB obj
[2]
GLdouble GLdouble GLdouble GLdouble q
Definition qopenglext.h:259
GLuint64EXT * result
[6]
QQmlEngine * qmlEngine(const QObject *obj)
Definition qqml.cpp:80
#define QML_SINGLETON
#define QML_ADDED_IN_VERSION(MAJOR, MINOR)
#define QML_ELEMENT
QLatin1StringView QLatin1String
Definition qstringfwd.h:31
#define Q_PROPERTY(...)
#define Q_OBJECT
#define Q_EMIT
#define Q_SLOTS
#define Q_SIGNALS
bool qWaitForSignal(QObject *obj, const char *signal, int timeout=5000)
view create()
QJSEngine engine
[0]