Qt 6.x
The Qt SDK
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
25
27{
29 Q_PROPERTY(bool windowShown READ windowShown NOTIFY windowShownChanged)
30 Q_PROPERTY(bool hasTestCase READ hasTestCase WRITE setHasTestCase NOTIFY hasTestCaseChanged)
31 Q_PROPERTY(QObject *defined READ defined)
32
36
37public:
39 {
40 QTestRootObject *result = instance();
42 // You can only test on one engine at a time
43 return (engine == nullptr || engine == q) ? result : nullptr;
44 }
45
48 if (!object) {
49 // QTestRootObject was deleted when previous test ended, create a new one
50 object = new QTestRootObject;
51 }
52 return object;
53 }
54
55 bool hasQuit:1;
56 bool hasTestCase() const { return m_hasTestCase; }
57 void setHasTestCase(bool value) { m_hasTestCase = value; Q_EMIT hasTestCaseChanged(); }
58
59 bool windowShown() const { return m_windowShown; }
60 void setWindowShown(bool value) { m_windowShown = value; Q_EMIT windowShownChanged(); }
61 QQmlPropertyMap *defined() const { return m_defined; }
62
63 void init() { setWindowShown(false); setHasTestCase(false); hasQuit = false; }
64
68
69private Q_SLOTS:
70 void quit() { hasQuit = true; }
71
72private:
74 : QObject(parent), hasQuit(false), m_windowShown(false), m_hasTestCase(false) {
75 m_defined = new QQmlPropertyMap(this);
76#if defined(QT_OPENGL_ES_2_ANGLE)
77 m_defined->insert(QLatin1String("QT_OPENGL_ES_2_ANGLE"), QVariant(true));
78#endif
79 }
80
81 bool m_windowShown : 1;
82 bool m_hasTestCase :1;
83 QQmlPropertyMap *m_defined;
84};
85
86bool qWaitForSignal(QObject *obj, const char* signal, int timeout = 5000);
87
89
90#endif // QUICKTEST_P_H
The QJSEngine class provides an environment for evaluating JavaScript code.
Definition qjsengine.h:26
\inmodule QtCore
Definition qobject.h:90
\inmodule QtCore
Definition qpointer.h:18
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.
static QTestRootObject * create(QQmlEngine *q, QJSEngine *)
Definition quicktest_p.h:38
void setWindowShown(bool value)
Definition quicktest_p.h:60
bool windowShown() const
Definition quicktest_p.h:59
void windowShownChanged()
static QTestRootObject * instance()
Definition quicktest_p.h:46
void hasTestCaseChanged()
bool hasTestCase() const
Definition quicktest_p.h:56
void setHasTestCase(bool value)
Definition quicktest_p.h:57
QQmlPropertyMap * defined() const
Definition quicktest_p.h:61
\inmodule QtCore
Definition qvariant.h:64
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:76
#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)
#define Q_QUICK_TEST_PRIVATE_EXPORT
QJSEngine engine
[0]
IUIAutomationTreeWalker __RPC__deref_out_opt IUIAutomationElement ** parent