8#include <QtTest/qtest.h>
9#include <QtCore/qstring.h>
10#include <QtCore/qtimer.h>
11#include <QtGui/qguiapplication.h>
12#include <QtQuick/qquickwindow.h>
15#include <QtQml/qqmlcomponent.h>
28 static constexpr int m_argc = 1;
29 static constexpr char *m_argv[] = {
const_cast<char *
>(
"tst_qmltc_examples") };
41#define CREATE_DUMMY_ARGC_ARGV() \
43 char *argv[] = { const_cast<char *>("tst_qmltc_examples") };
45void tst_qmltc_examples::app()
58 documentRoot->setParentItem(
window.contentItem());
59 window.setHeight(documentRoot->height());
60 window.setWidth(documentRoot->width());
72void tst_qmltc_examples::appComponent()
98 documentRootItem->setParentItem(
window.contentItem());
110#if !defined(QMLTC_TESTS_SOURCE_DIR) || !defined(QMLTC_TESTS_BINARY_DIR)
111# error "Tests assume that QMLTC_TESTS_{SOURCE,BINARY}_DIR are specified (through CMake)"
115template<
typename Predicate>
128 content->append(std::move(
line));
132void tst_qmltc_examples::helloWorld()
135 QSKIP(
"expected C++ files are not bundled with Android tests.");
140 + u
"/.qmltc/tst_qmltc_examples/helloworld.h",
141 [](
const QString &) {
return true; });
143 QFAIL(
"Reading _generated_ C++ content for special/HelloWorld.qml failed");
146 const auto filterDocumentationLines = [encounteredStart =
false](
QStringView line)
mutable {
148 encounteredStart =
true;
151 if (!encounteredStart)
157 QStringLiteral(QMLTC_TESTS_SOURCE_DIR) + u
"/special/HelloWorld.qml.cpp",
158 filterDocumentationLines);
160 QFAIL(
"Reading special/HelloWorld.qml.cpp failed");
162 QVERIFY(!generatedCode.isEmpty());
163 QVERIFY(!documentationCode.isEmpty());
165 auto begin = generatedCode.cbegin();
166 for (
const QString &existingString :
std::as_const(documentationCode)) {
167 auto pos = std::find(
begin, generatedCode.cend(), existingString);
173#undef CREATE_DUMMY_ARGC_ARGV
176#include "tst_qmltc_examples.moc"
static int exec()
Enters the main event loop and waits until exit() is called, then returns the value that was set to e...
static void quit()
\threadsafe
bool open(OpenMode flags) override
Opens the file using OpenMode mode, returning true if successful; otherwise false.
bool exists() const
This is an overloaded member function, provided for convenience. It differs from the above function o...
static void setApplicationDisplayName(const QString &name)
QObject * parent() const
Returns a pointer to the parent object.
template< class T > T qobject_cast(const QObject *object)
Returns the given object cast to type T if the object is of type T (or of a subclass); otherwise retu...
The QQmlComponent class encapsulates a QML component definition.
The QQmlEngine class provides an environment for instantiating QML components.
The QQuickItem class provides the most basic of all visual items in \l {Qt Quick}.
\qmltype Window \instantiates QQuickWindow \inqmlmodule QtQuick
\macro QT_RESTRICTED_CAST_FROM_ASCII
bool startsWith(const QString &s, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
Returns true if the string starts with s; otherwise returns false.
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
QString trimmed() const &
bool singleShot
whether the timer is a single-shot timer
tst_qmltc_examples(QObject *parent=nullptr)
Q_TESTLIB_EXPORT bool currentTestFailed()
Returns true if the current test function has failed, otherwise false.
static QDBusError::ErrorType get(const char *name)
GLint GLsizei GLsizei height
GLint GLint GLint GLint GLint GLint GLint GLbitfield GLenum filter
static qreal component(const QPointF &point, unsigned int i)
QtPrivate::QRegularExpressionMatchIteratorRangeBasedForIterator begin(const QRegularExpressionMatchIterator &iterator)
#define qPrintable(string)
#define QStringLiteral(str)
#define QTEST_APPLESS_MAIN(TestObject)
#define QSKIP(statement,...)
#define QVERIFY(statement)
#define QVERIFY2(statement, description)
QUrl url("example.com")
[constructor-url-reference]
QApplication app(argc, argv)
[0]
void readFileContent(QStringList *content, const QString &url, Predicate filter)
#define CREATE_DUMMY_ARGC_ARGV()