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 QUICKTEST_H
5#define QUICKTEST_H
6
7#include <QtQuickTest/quicktestglobal.h>
8#include <QtTest/qtest.h>
9
10QT_BEGIN_NAMESPACE
11
12class QQuickItem;
13class QQuickWindow;
14
15Q_QUICK_TEST_EXPORT int quick_test_main(int argc, char **argv, const char *name, const char *sourceDir);
16Q_QUICK_TEST_EXPORT int quick_test_main_with_setup(int argc, char **argv, const char *name, const char *sourceDir, QObject *setup);
17
18#ifdef QUICK_TEST_SOURCE_DIR
19
20#define QUICK_TEST_MAIN(name) \
21 int main(int argc, char **argv) \
22 { \
23 QTEST_SET_MAIN_SOURCE_PATH \
24 return quick_test_main(argc, argv, #name, QUICK_TEST_SOURCE_DIR); \
25 }
26
27#define QUICK_TEST_OPENGL_MAIN(name) \
28 int main(int argc, char **argv) \
29 { \
30 QTEST_SET_MAIN_SOURCE_PATH \
31 return quick_test_main(argc, argv, #name, QUICK_TEST_SOURCE_DIR); \
32 }
33
34#define QUICK_TEST_MAIN_WITH_SETUP(name, QuickTestSetupClass) \
35 int main(int argc, char **argv) \
36 { \
37 QTEST_SET_MAIN_SOURCE_PATH \
38 QuickTestSetupClass setup; \
39 return quick_test_main_with_setup(argc, argv, #name, QUICK_TEST_SOURCE_DIR, &setup); \
40 }
41
42#else
43
44#define QUICK_TEST_MAIN(name) \
45 int main(int argc, char **argv) \
46 { \
47 QTEST_SET_MAIN_SOURCE_PATH \
48 return quick_test_main(argc, argv, #name, nullptr); \
49 }
50
51#define QUICK_TEST_OPENGL_MAIN(name) \
52 int main(int argc, char **argv) \
53 { \
54 QTEST_SET_MAIN_SOURCE_PATH \
55 return quick_test_main(argc, argv, #name, nullptr); \
56 }
57
58#define QUICK_TEST_MAIN_WITH_SETUP(name, QuickTestSetupClass) \
59 int main(int argc, char **argv) \
60 { \
61 QTEST_SET_MAIN_SOURCE_PATH \
62 QuickTestSetupClass setup; \
63 return quick_test_main_with_setup(argc, argv, #name, nullptr, &setup); \
64 }
65
66#endif
67
68namespace QQuickTest {
69static const int defaultTimeout = 5000;
70
71Q_QUICK_TEST_EXPORT bool qIsPolishScheduled(const QQuickItem *item);
72Q_QUICK_TEST_EXPORT bool qIsPolishScheduled(const QQuickWindow *window);
73
74#if QT_VERSION < QT_VERSION_CHECK(7, 0, 0)
75#if QT_DEPRECATED_SINCE(6, 4)
76 QT_DEPRECATED_X("Use qWaitForPolish(QQuickItem *) instead")
77 Q_QUICK_TEST_EXPORT bool qWaitForItemPolished(const QQuickItem *item, int timeout = defaultTimeout);
78#endif
79#endif
80Q_QUICK_TEST_EXPORT bool qWaitForPolish(const QQuickItem *item, int timeout = defaultTimeout);
81Q_QUICK_TEST_EXPORT bool qWaitForPolish(const QQuickWindow *window, int timeout = defaultTimeout);
82}
83
84QT_END_NAMESPACE
85
86#endif
87

source code of qtdeclarative/src/qmltest/quicktest.h