Qt 6.x
The Qt SDK
Loading...
Searching...
No Matches
quicktest.cpp
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#include "quicktest_p.h"
5#include "quicktestresult_p.h"
6#include <QtTest/qtestsystem.h>
7#include "qtestoptions_p.h"
8#include <QtQml/qqml.h>
9#include <QtQml/qqmlengine.h>
10#include <QtQml/qqmlcontext.h>
11#include <QtQuick/private/qquickitem_p.h>
12#include <QtQuick/private/qquickwindow_p.h>
13#include <QtQuick/qquickitem.h>
14#include <QtQuick/qquickview.h>
15#include <QtQuick/qquickwindow.h>
16#include <QtQml/qjsvalue.h>
17#include <QtQml/qjsengine.h>
18#include <QtQml/qqmlpropertymap.h>
19#include <QtQuick/private/qquickitem_p.h>
20#include <QtQuick/qquickitem.h>
21#include <qopengl.h>
22#include <QtCore/qurl.h>
23#include <QtCore/qfileinfo.h>
24#include <QtCore/qdir.h>
25#include <QtCore/qdiriterator.h>
26#include <QtCore/qfile.h>
27#include <QtCore/qdebug.h>
28#include <QtCore/qeventloop.h>
29#include <QtCore/qtextstream.h>
30#include <QtCore/qtimer.h>
31#include <QtGui/qtextdocument.h>
32#include <stdio.h>
33#include <QtGui/QGuiApplication>
34#include <QtCore/QTranslator>
35#include <QtTest/QSignalSpy>
36#include <QtQml/QQmlFileSelector>
37
38#include <private/qqmlcomponent_p.h>
39#include <private/qv4resolvedtypereference_p.h>
40
42
74{
76}
77
102{
104}
105
106#if QT_VERSION < QT_VERSION_CHECK(7, 0, 0)
107#if QT_DEPRECATED_SINCE(6, 4)
124bool QQuickTest::qWaitForItemPolished(const QQuickItem *item, int timeout)
125{
126 return qWaitForPolish(item, timeout);
127}
128#endif
129#endif
130
144{
146}
147
164{
165 return QTest::qWaitFor([&]() { return QQuickWindowPrivate::get(window)->itemsToPolish.isEmpty(); }, timeout);
166}
167
168static inline QString stripQuotes(const QString &s)
169{
170 if (s.size() >= 2 && s.startsWith(QLatin1Char('"')) && s.endsWith(QLatin1Char('"')))
171 return s.mid(1, s.size() - 2);
172 else
173 return s;
174}
175
177 const QFileInfo &fi, const QList<QQmlError> &errors, QQmlEngine *engine,
178 QQuickView *view = nullptr)
179{
180 // Error compiling the test - flag failure in the log and continue.
182 results.setTestCaseName(fi.baseName());
183 results.startLogging();
184 results.setFunctionName(QLatin1String("compile"));
185 // Verbose warning output of all messages and relevant parameters
188 str << "\n " << QDir::toNativeSeparators(fi.absoluteFilePath()) << " produced "
189 << errors.size() << " error(s):\n";
190 for (const QQmlError &e : errors) {
191 str << " ";
192 if (e.url().isLocalFile()) {
193 str << QDir::toNativeSeparators(e.url().toLocalFile());
194 } else {
195 str << e.url().toString();
196 }
197 if (e.line() > 0)
198 str << ':' << e.line() << ',' << e.column();
199 str << ": " << e.description() << '\n';
200 }
201 str << " Working directory: " << QDir::toNativeSeparators(QDir::current().absolutePath()) << '\n';
202 if (engine) {
203 str << " ";
204 if (view)
205 str << "View: " << view->metaObject()->className() << ", ";
206 str << "Import paths:\n";
207 const auto importPaths = engine->importPathList();
208 for (const QString &i : importPaths)
209 str << " '" << QDir::toNativeSeparators(i) << "'\n";
210 const QStringList pluginPaths = engine->pluginPathList();
211 str << " Plugin paths:\n";
212 for (const QString &p : pluginPaths)
213 str << " '" << QDir::toNativeSeparators(p) << "'\n";
214 }
216 // Fail with error 0.
217 results.fail(errors.at(0).description(),
218 errors.at(0).url(), errors.at(0).line());
219 results.finishTestData();
220 results.finishTestDataCleanup();
221 results.finishTestFunction();
222 results.setFunctionName(QString());
223 results.stopLogging();
224}
225
226bool qWaitForSignal(QObject *obj, const char* signal, int timeout)
227{
230 timer.start();
231
232 while (!spy.size()) {
233 int remaining = timeout - int(timer.elapsed());
234 if (remaining <= 0)
235 break;
238 QTest::qSleep(10);
239 }
240
241 return spy.size();
242}
243
244template <typename... Args>
245void maybeInvokeSetupMethod(QObject *setupObject, const char *member, Args &&... args)
246{
247 // It's OK if it doesn't exist: since we have more than one callback that
248 // can be called, it makes sense if the user only implements one of them.
249 // We do this the long way rather than just calling the static
250 // QMetaObject::invokeMethod(), because that will issue a warning if the
251 // function doesn't exist, which we don't want.
252 const QMetaObject *setupMetaObject = setupObject->metaObject();
253 const int methodIndex = setupMetaObject->indexOfMethod(member);
254 if (methodIndex != -1) {
255 const QMetaMethod method = setupMetaObject->method(methodIndex);
256 method.invoke(setupObject, std::forward<Args>(args)...);
257 }
258}
259
260using namespace QV4::CompiledData;
261
263{
264public:
266
268 {
269 QString path = fileInfo.absoluteFilePath();
270 if (path.startsWith(QLatin1String(":/")))
271 path.prepend(QLatin1String("qrc"));
272
274 m_errors += component.errors();
275
276 if (component.isReady()) {
279 TestCaseEnumerationResult result = enumerateTestCases(rootCompilationUnit.data());
280 m_testCases = result.testCases + result.finalizedPartialTestCases();
281 m_errors += result.errors;
282 }
283 }
284
285 TestCaseList testCases() const { return m_testCases; }
286 QList<QQmlError> errors() const { return m_errors; }
287
288private:
289 TestCaseList m_testCases;
290 QList<QQmlError> m_errors;
291
292 struct TestCaseEnumerationResult
293 {
294 TestCaseList testCases;
295 QList<QQmlError> errors;
296
297 // Partially constructed test cases
298 bool isTestCase = false;
299 TestCaseList testFunctions;
300 QString testCaseName;
301
302 TestCaseList finalizedPartialTestCases() const
303 {
305 for (const QString &function : testFunctions)
306 result << QString(QStringLiteral("%1::%2")).arg(testCaseName).arg(function);
307 return result;
308 }
309
310 TestCaseEnumerationResult &operator<<(const TestCaseEnumerationResult &other)
311 {
312 testCases += other.testCases + other.finalizedPartialTestCases();
313 errors += other.errors;
314 return *this;
315 }
316 };
317
318 TestCaseEnumerationResult enumerateTestCases(
320 const Object *object = nullptr)
321 {
322 QQmlType testCaseType;
323 for (quint32 i = 0, count = compilationUnit->importCount(); i < count; ++i) {
324 const Import *import = compilationUnit->importAt(i);
325 if (compilationUnit->stringAt(import->uriIndex) != QLatin1String("QtTest"))
326 continue;
327
328 QString testCaseTypeName(QStringLiteral("TestCase"));
329 QString typeQualifier = compilationUnit->stringAt(import->qualifierIndex);
330 if (!typeQualifier.isEmpty())
331 testCaseTypeName = typeQualifier % QLatin1Char('.') % testCaseTypeName;
332
333 testCaseType = compilationUnit->typeNameCache->query(testCaseTypeName).type;
334 if (testCaseType.isValid())
335 break;
336 }
337
338 TestCaseEnumerationResult result;
339
340 if (!object) // Start at root of compilation unit if not enumerating a specific child
341 object = compilationUnit->objectAt(0);
342 if (object->hasFlag(Object::IsInlineComponentRoot))
343 return result;
344
345 if (const auto superTypeUnit = compilationUnit->resolvedTypes.value(
346 object->inheritedTypeNameIndex)->compilationUnit()) {
347 // We have a non-C++ super type, which could indicate we're a subtype of a TestCase
348 if (testCaseType.isValid() && superTypeUnit->url() == testCaseType.sourceUrl())
349 result.isTestCase = true;
350 else if (superTypeUnit->url() != compilationUnit->url()) { // urls are the same for inline component, avoid infinite recursion
351 result = enumerateTestCases(superTypeUnit);
352 }
353
354 if (result.isTestCase) {
355 // Look for override of name in this type
356 for (auto binding = object->bindingsBegin(); binding != object->bindingsEnd(); ++binding) {
357 if (compilationUnit->stringAt(binding->propertyNameIndex) == QLatin1String("name")) {
358 if (binding->type() == QV4::CompiledData::Binding::Type_String) {
359 result.testCaseName = compilationUnit->stringAt(binding->stringIndex);
360 } else {
362 error.setUrl(compilationUnit->url());
363 error.setLine(binding->location.line());
364 error.setColumn(binding->location.column());
365 error.setDescription(QStringLiteral("the 'name' property of a TestCase must be a literal string"));
366 result.errors << error;
367 }
368 break;
369 }
370 }
371
372 // Look for additional functions in this type
373 auto functionsEnd = compilationUnit->objectFunctionsEnd(object);
374 for (auto function = compilationUnit->objectFunctionsBegin(object); function != functionsEnd; ++function) {
375 QString functionName = compilationUnit->stringAt(function->nameIndex);
376 if (!(functionName.startsWith(QLatin1String("test_")) || functionName.startsWith(QLatin1String("benchmark_"))))
377 continue;
378
379 if (functionName.endsWith(QLatin1String("_data")))
380 continue;
381
382 result.testFunctions << functionName;
383 }
384 }
385 }
386
387 for (auto binding = object->bindingsBegin(); binding != object->bindingsEnd(); ++binding) {
388 if (binding->type() == QV4::CompiledData::Binding::Type_Object) {
389 const Object *child = compilationUnit->objectAt(binding->value.objectIndex);
390 result << enumerateTestCases(compilationUnit, child);
391 }
392 }
393
394 return result;
395 }
396};
397
398int quick_test_main(int argc, char **argv, const char *name, const char *sourceDir)
399{
400 return quick_test_main_with_setup(argc, argv, name, sourceDir, nullptr);
401}
402
403int quick_test_main_with_setup(int argc, char **argv, const char *name, const char *sourceDir, QObject *setup)
404{
407 app.reset(new QGuiApplication(argc, argv));
408
409 if (setup)
410 maybeInvokeSetupMethod(setup, "applicationAvailable()");
411
412 // Look for QML-specific command-line options.
413 // -import dir Specify an import directory.
414 // -plugins dir Specify a directory where to search for plugins.
415 // -input dir Specify the input directory for test cases.
416 // -translation file Specify the translation file.
417 // -file-selector Specify a file selector
418 QStringList imports;
419 QStringList pluginPaths;
420 QString testPath;
421 QString translationFile;
422 QStringList fileSelectors;
423 int index = 1;
424 QScopedArrayPointer<char *> testArgV(new char *[argc + 1]);
425 testArgV[0] = argv[0];
426 int testArgC = 1;
427 while (index < argc) {
428 if (strcmp(argv[index], "-import") == 0 && (index + 1) < argc) {
429 imports += stripQuotes(QString::fromLocal8Bit(argv[index + 1]));
430 index += 2;
431 } else if (strcmp(argv[index], "-plugins") == 0 && (index + 1) < argc) {
432 pluginPaths += stripQuotes(QString::fromLocal8Bit(argv[index + 1]));
433 index += 2;
434 } else if (strcmp(argv[index], "-input") == 0 && (index + 1) < argc) {
435 testPath = stripQuotes(QString::fromLocal8Bit(argv[index + 1]));
436 index += 2;
437 } else if (strcmp(argv[index], "-opengl") == 0) {
438 ++index;
439 } else if (strcmp(argv[index], "-translation") == 0 && (index + 1) < argc) {
440 translationFile = stripQuotes(QString::fromLocal8Bit(argv[index + 1]));
441 index += 2;
442 } else if (strcmp(argv[index], "-file-selector") == 0 && (index + 1) < argc) {
443 fileSelectors += stripQuotes(QString::fromLocal8Bit(argv[index + 1]));
444 index += 2;
445 } else {
446 testArgV[testArgC++] = argv[index++];
447 }
448 }
449 testArgV[testArgC] = 0;
450
451 // Setting currentAppname and currentTestObjectName (via setProgramName) are needed
452 // for the code coverage analysis. Must be done before parseArgs is called.
455
456 QuickTestResult::parseArgs(testArgC, testArgV.data());
457
458#if QT_CONFIG(translation)
459 QTranslator translator;
460 if (!translationFile.isEmpty()) {
461 if (translator.load(translationFile)) {
462 app->installTranslator(&translator);
463 } else {
464 qWarning("Could not load the translation file '%s'.", qPrintable(translationFile));
465 }
466 }
467#endif
468
469 // Determine where to look for the test data.
470 if (testPath.isEmpty() && sourceDir) {
471 const QString s = QString::fromLocal8Bit(sourceDir);
472 if (QFile::exists(s))
473 testPath = s;
474 }
475
476#if defined(Q_OS_ANDROID) || defined(Q_OS_INTEGRITY)
477 if (testPath.isEmpty())
478 testPath = QLatin1String(":/");
479#endif
480
481 if (testPath.isEmpty()) {
482 QDir current = QDir::current();
483#ifdef Q_OS_WIN
484 // Skip release/debug subfolders
485 if (!current.dirName().compare(QLatin1String("Release"), Qt::CaseInsensitive)
486 || !current.dirName().compare(QLatin1String("Debug"), Qt::CaseInsensitive))
487 current.cdUp();
488#endif // Q_OS_WIN
489 testPath = current.absolutePath();
490 }
492
493 const QFileInfo testPathInfo(testPath);
494 if (testPathInfo.isFile()) {
495 if (testPath.endsWith(QLatin1String(".qml"))) {
496 files << testPath;
497 } else if (testPath.endsWith(QLatin1String(".qmltests"))) {
498 QFile file(testPath);
500 while (!file.atEnd()) {
501 const QString filePath = testPathInfo.dir()
503 .trimmed();
504 const QFileInfo f(filePath);
505 if (f.exists())
506 files.append(filePath);
507 else
508 qWarning("The test file '%s' does not exists", qPrintable(filePath));
509 }
510 file.close();
511 files.sort();
512 if (files.isEmpty()) {
513 qWarning("The file '%s' does not contain any tests files",
514 qPrintable(testPath));
515 return 1;
516 }
517 } else {
518 qWarning("Could not read '%s'", qPrintable(testPath));
519 }
520 } else {
521 qWarning("'%s' does not have the suffix '.qml' or '.qmltests'.", qPrintable(testPath));
522 return 1;
523 }
524 } else if (testPathInfo.isDir()) {
525 // Scan the test data directory recursively, looking for "tst_*.qml" files.
526 const QStringList filters(QStringLiteral("tst_*.qml"));
530 while (iter.hasNext())
531 files += iter.next();
532 files.sort();
533 if (files.isEmpty()) {
534 qWarning("The directory '%s' does not contain any test files matching '%s'",
535 qPrintable(testPath), qPrintable(filters.front()));
536 return 1;
537 }
538 } else {
539 qWarning("'%s' does not exist under '%s'.",
541 return 1;
542 }
543
544 qputenv("QT_QTESTLIB_RUNNING", "1");
545
546 QSet<QString> commandLineTestFunctions(QTest::testFunctions.cbegin(), QTest::testFunctions.cend());
547 const bool filteringTestFunctions = !commandLineTestFunctions.isEmpty();
548
549 // Scan through all of the "tst_*.qml" files and run each of them
550 // in turn with a separate QQuickView (for test isolation).
551 for (const QString &file : std::as_const(files)) {
552 const QFileInfo fi(file);
553 if (!fi.exists())
554 continue;
555
557 for (const QString &path : std::as_const(imports))
558 engine.addImportPath(path);
559 for (const QString &path : std::as_const(pluginPaths))
560 engine.addPluginPath(path);
561
562 if (!fileSelectors.isEmpty()) {
563 QQmlFileSelector* const qmlFileSelector = new QQmlFileSelector(&engine, &engine);
564 qmlFileSelector->setExtraSelectors(fileSelectors);
565 }
566
567 // Do this down here so that import paths, plugin paths, file selectors, etc. are available
568 // in case the user needs access to them. Do it _before_ the TestCaseCollector parses the
569 // QML files though, because it attempts to import modules, which might not be available
570 // if qmlRegisterType()/QQmlEngine::addImportPath() are called in qmlEngineAvailable().
571 if (setup)
572 maybeInvokeSetupMethod(setup, "qmlEngineAvailable(QQmlEngine*)", Q_ARG(QQmlEngine*, &engine));
573
574 TestCaseCollector testCaseCollector(fi, &engine);
575 if (!testCaseCollector.errors().isEmpty()) {
576 handleCompileErrors(fi, testCaseCollector.errors(), &engine);
577 continue;
578 }
579
580 TestCaseCollector::TestCaseList availableTestFunctions = testCaseCollector.testCases();
582 for (const QString &function : availableTestFunctions)
583 qDebug("%s()", qPrintable(function));
584 continue;
585 }
586
587 const QSet<QString> availableTestSet(availableTestFunctions.cbegin(), availableTestFunctions.cend());
588 if (filteringTestFunctions && !availableTestSet.intersects(commandLineTestFunctions))
589 continue;
590 commandLineTestFunctions.subtract(availableTestSet);
591
592 QQuickView view(&engine, nullptr);
596 QEventLoop eventLoop;
600 &eventLoop, SLOT(quit()));
602 (QLatin1String("qtest"), QTestRootObject::instance()); // Deprecated. Use QTestRootObject from QtTest instead
603
608 if (path.startsWith(QLatin1String(":/")))
610 else
612
613 while (view.status() == QQuickView::Loading)
614 QTest::qWait(10);
615 if (view.status() == QQuickView::Error) {
617 continue;
618 }
619
620 view.setFramePosition(QPoint(50, 50));
621 if (view.size().isEmpty()) { // Avoid hangs with empty windows.
622 view.resize(200, 200);
623 }
624 view.show();
626 qWarning().nospace()
627 << "Test '" << QDir::toNativeSeparators(path) << "' window not exposed after show().";
628 }
629 view.requestActivate();
631 qWarning().nospace()
632 << "Test '" << QDir::toNativeSeparators(path) << "' window not active after requestActivate().";
633 }
634 if (view.isExposed()) {
635 // Defer property update until event loop has started
636 QTimer::singleShot(0, []() {
638 });
639 } else {
640 qWarning().nospace()
641 << "Test '" << QDir::toNativeSeparators(path) << "' window was never exposed! "
642 << "If the test case was expecting windowShown, it will hang.";
643 }
644 if (!QTestRootObject::instance()->hasQuit && QTestRootObject::instance()->hasTestCase())
645 eventLoop.exec();
646 }
647
648 if (setup)
649 maybeInvokeSetupMethod(setup, "cleanupTestCase()");
650
651 // Flush the current logging stream.
653 app.reset();
654
655 // Check that all test functions passed on the command line were found
656 if (!commandLineTestFunctions.isEmpty()) {
657 qWarning() << "Could not find the following test functions:";
658 for (const QString &functionName : std::as_const(commandLineTestFunctions))
659 qWarning(" %s()", qUtf8Printable(functionName));
660 return commandLineTestFunctions.size();
661 }
662
663 // Return the number of failures as the exit code.
665}
666
668
669#include "moc_quicktest_p.cpp"
Definition main.cpp:8
static void processEvents(QEventLoop::ProcessEventsFlags flags=QEventLoop::AllEvents)
Processes some pending events for the calling thread according to the specified flags.
static QCoreApplication * instance() noexcept
Returns a pointer to the application's QCoreApplication (or QGuiApplication/QApplication) instance.
static bool installTranslator(QTranslator *messageFile)
Adds the translation file translationFile to the list of translation files to be used for translation...
static void sendPostedEvents(QObject *receiver=nullptr, int event_type=0)
Immediately dispatches all events which have been previously queued with QCoreApplication::postEvent(...
The QDirIterator class provides an iterator for directory entrylists.
\inmodule QtCore
Definition qdir.h:19
bool cdUp()
Changes directory by moving one directory up from the QDir's current directory.
Definition qdir.cpp:1042
QString dirName() const
Returns the name of the directory; this is not the same as the path, e.g.
Definition qdir.cpp:715
static QDir current()
Returns the application's current directory.
Definition qdir.h:216
QString absolutePath() const
Returns the absolute path (a path that starts with "/" or with a drive specification),...
Definition qdir.cpp:667
QString filePath(const QString &fileName) const
Returns the path name of a file in the directory.
Definition qdir.cpp:778
static QString toNativeSeparators(const QString &pathName)
Definition qdir.cpp:929
static QString currentPath()
Returns the absolute path of the application's current directory.
Definition qdir.cpp:2051
@ Files
Definition qdir.h:22
\inmodule QtCore
\inmodule QtCore
Definition qeventloop.h:16
int exec(ProcessEventsFlags flags=AllEvents)
Enters the main event loop and waits until exit() is called.
@ DeferredDelete
Definition qcoreevent.h:100
bool atEnd() const override
Returns true if the end of the file has been reached; otherwise returns false.
void close() override
Calls QFileDevice::flush() and closes the file.
\inmodule QtCore \reentrant
Definition qfileinfo.h:22
QString baseName() const
Returns the base name of the file without the path.
QString absoluteFilePath() const
Returns an absolute path including the file name.
bool isFile() const
Returns true if this object points to a file or to a symbolic link to a file.
bool isDir() const
Returns true if this object points to a directory or to a symbolic link to a directory.
QDir dir() const
Returns the path of the object's parent directory as a QDir object.
bool exists() const
Returns true if the file exists; otherwise returns false.
\inmodule QtCore
Definition qfile.h:93
bool open(OpenMode flags) override
Opens the file using OpenMode mode, returning true if successful; otherwise false.
Definition qfile.cpp:881
bool exists() const
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition qfile.cpp:351
\macro qGuiApp
qint64 readLine(char *data, qint64 maxlen)
This function reads a line of ASCII characters from the device, up to a maximum of maxSize - 1 bytes,...
Definition qlist.h:74
qsizetype size() const noexcept
Definition qlist.h:386
bool isEmpty() const noexcept
Definition qlist.h:390
const_reference at(qsizetype i) const noexcept
Definition qlist.h:429
const_iterator cend() const noexcept
Definition qlist.h:614
const_iterator cbegin() const noexcept
Definition qlist.h:613
\inmodule QtCore
Definition qmetaobject.h:18
\inmodule QtCore
Definition qobject.h:90
static QMetaObject::Connection connect(const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
\threadsafe
Definition qobject.cpp:2823
QString objectName
the name of this object
Definition qobject.h:94
Q_WEAK_OVERLOAD void setObjectName(const QString &name)
Sets the object's name to name.
Definition qobject.h:114
\inmodule QtCore\reentrant
Definition qpoint.h:23
QQmlRefPointer< QV4::ExecutableCompilationUnit > compilationUnit
static QQmlComponentPrivate * get(QQmlComponent *c)
The QQmlComponent class encapsulates a QML component definition.
void setContextProperty(const QString &, QObject *)
Set the value of the name property on this context.
The QQmlEngine class provides an environment for instantiating QML components.
Definition qqmlengine.h:57
The QQmlError class encapsulates a QML error.
Definition qqmlerror.h:18
A class for applying a QFileSelector to QML file loading.
void setExtraSelectors(const QStringList &strings)
Adds extra selectors contained in strings to the current QFileSelector being used.
T * data() const
QUrl sourceUrl() const
Definition qqmltype.cpp:743
bool isValid() const
Definition qqmltype_p.h:58
static QQuickItemPrivate * get(QQuickItem *item)
The QQuickItem class provides the most basic of all visual items in \l {Qt Quick}.
Definition qquickitem.h:64
The QQuickView class provides a window for displaying a Qt Quick user interface.
Definition qquickview.h:20
QList< QQmlError > errors() const
Return the list of errors that occurred during the last compile or create operation.
Status status
The component's current \l{QQuickView::Status} {status}.
Definition qquickview.h:23
QQmlEngine * engine() const
Returns a pointer to the QQmlEngine used for instantiating QML Components.
QQmlContext * rootContext() const
This function returns the root of the context hierarchy.
void setSource(const QUrl &)
Sets the source to the url, loads the QML component and instantiates it.
static QQuickWindowPrivate * get(QQuickWindow *c)
QVector< QQuickItem * > itemsToPolish
\qmltype Window \instantiates QQuickWindow \inqmlmodule QtQuick
\inmodule QtCore
\inmodule QtCore
T * data() const noexcept
Returns the value of the pointer referenced by this object.
Definition qset.h:18
qsizetype size() const
Definition qset.h:50
bool isEmpty() const
Definition qset.h:52
bool intersects(const QSet< T > &other) const
Definition qset.h:255
QSet< T > & subtract(const QSet< T > &other)
Definition qset.h:273
\inmodule QtCore
\inmodule QtCore
Definition qstringview.h:76
constexpr QStringView mid(qsizetype pos, qsizetype n=-1) const noexcept
Returns the substring of length length starting at position start in this object.
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:127
bool startsWith(const QString &s, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
Returns true if the string starts with s; otherwise returns false.
Definition qstring.cpp:5299
static QString fromLocal8Bit(QByteArrayView ba)
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition qstring.cpp:5788
static QString fromUtf8(QByteArrayView utf8)
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition qstring.cpp:5857
QString mid(qsizetype position, qsizetype n=-1) const
Returns a string that contains n characters of this string, starting at the specified position index.
Definition qstring.cpp:5204
bool endsWith(const QString &s, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
Returns true if the string ends with s; otherwise returns false.
Definition qstring.cpp:5350
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
Definition qstring.h:1083
int compare(const QString &s, Qt::CaseSensitivity cs=Qt::CaseSensitive) const noexcept
Definition qstring.cpp:6498
QString trimmed() const &
Definition qstring.h:380
QString & prepend(QChar c)
Definition qstring.h:411
void setWindowShown(bool value)
Definition quicktest_p.h:60
static QTestRootObject * instance()
Definition quicktest_p.h:46
\inmodule QtCore
void start(int msec)
Starts or restarts the timer with a timeout interval of msec milliseconds.
Definition qtimer.cpp:208
bool singleShot
whether the timer is a single-shot timer
Definition qtimer.h:22
\inmodule QtCore
Definition qtranslator.h:19
bool load(const QString &filename, const QString &directory=QString(), const QString &search_delimiters=QString(), const QString &suffix=QString())
Loads filename + suffix (".qm" if the suffix is not specified), which may be an absolute file name or...
\inmodule QtCore
Definition qurl.h:94
static QUrl fromLocalFile(const QString &localfile)
Returns a QUrl representation of localFile, interpreted as a local file.
Definition qurl.cpp:3354
void show()
Shows the window.
Definition qwindow.cpp:2181
void setTitle(const QString &)
Definition qwindow.cpp:972
static void setCurrentAppname(const char *appname)
static void setProgramName(const char *name)
static void parseArgs(int argc, char *argv[])
static int exitCode()
QList< QString > TestCaseList
QList< QQmlError > errors() const
TestCaseList testCases() const
TestCaseCollector(const QFileInfo &fileInfo, QQmlEngine *engine)
QString str
[2]
double e
auto signal
QSignalSpy spy(myCustomObject, SIGNAL(mySignal(int, QString, double)))
[0]
Q_QUICK_TEST_EXPORT bool qWaitForPolish(const QQuickItem *item, int timeout=defaultTimeout)
Q_QUICK_TEST_EXPORT bool qIsPolishScheduled(const QQuickItem *item)
Definition quicktest.cpp:73
Combined button and popup list for selecting options.
Q_GUI_EXPORT bool qWaitForWindowActive(QWindow *window, int timeout=5000)
Q_GUI_EXPORT bool qWaitForWindowExposed(QWindow *window, int timeout=5000)
Q_TESTLIB_EXPORT QStringList testFunctions
Q_CORE_EXPORT void qSleep(int ms)
This is an overloaded member function, provided for convenience. It differs from the above function o...
Q_TESTLIB_EXPORT bool printAvailableFunctions
static bool qWaitFor(Functor predicate, QDeadlineTimer deadline=QDeadlineTimer(std::chrono::seconds{5}))
Q_CORE_EXPORT void qWait(int ms)
This is an overloaded member function, provided for convenience. It differs from the above function o...
@ CaseInsensitive
@ Window
Definition qnamespace.h:206
@ WindowMinMaxButtonsHint
Definition qnamespace.h:229
@ WindowTitleHint
Definition qnamespace.h:225
@ WindowSystemMenuHint
Definition qnamespace.h:226
@ WindowCloseButtonHint
Definition qnamespace.h:240
DBusConnection const char DBusError DBusBusType DBusError return DBusConnection DBusHandleMessageFunction void DBusFreeFunction return DBusConnection return DBusConnection return const char DBusError return DBusConnection DBusMessage dbus_uint32_t return DBusConnection dbus_bool_t DBusConnection DBusAddWatchFunction DBusRemoveWatchFunction DBusWatchToggledFunction void DBusFreeFunction return DBusConnection DBusDispatchStatusFunction void DBusFreeFunction DBusTimeout return DBusTimeout return DBusWatch return DBusWatch unsigned int return DBusError const DBusError return const DBusMessage return DBusMessage return DBusMessage return DBusMessage return DBusMessage return DBusMessage return DBusMessageIter * iter
DBusConnection const char DBusError DBusBusType DBusError return DBusConnection DBusHandleMessageFunction function
DBusConnection const char DBusError * error
DBusConnection const char DBusError DBusBusType DBusError return DBusConnection DBusHandleMessageFunction void DBusFreeFunction return DBusConnection return DBusConnection return const char DBusError return DBusConnection DBusMessage dbus_uint32_t return DBusConnection dbus_bool_t DBusConnection DBusAddWatchFunction DBusRemoveWatchFunction DBusWatchToggledFunction void DBusFreeFunction return DBusConnection DBusDispatchStatusFunction void DBusFreeFunction DBusTimeout return DBusTimeout return DBusWatch return DBusWatch unsigned int return DBusError const DBusError return const DBusMessage return DBusMessage return DBusMessage return DBusMessage return DBusMessage return DBusMessage return DBusMessageIter int const void return DBusMessageIter DBusMessageIter return DBusMessageIter void DBusMessageIter void int return DBusMessage DBusMessageIter return DBusMessageIter return DBusMessageIter DBusMessageIter const char const char const char const char * method
#define qDebug
[1]
Definition qlogging.h:160
#define qWarning
Definition qlogging.h:162
#define SLOT(a)
Definition qobjectdefs.h:51
#define Q_ARG(Type, data)
Definition qobjectdefs.h:62
#define SIGNAL(a)
Definition qobjectdefs.h:52
GLuint index
[2]
GLenum GLenum GLsizei count
GLuint object
[3]
GLbitfield GLuint64 timeout
[4]
GLfloat GLfloat f
GLuint GLsizei const GLchar * message
GLuint name
GLhandleARB obj
[2]
GLsizei const GLchar *const * path
GLuint64EXT * result
[6]
GLdouble s
[6]
Definition qopenglext.h:235
GLfloat GLfloat p
[1]
static qreal component(const QPointF &point, unsigned int i)
static QString absolutePath(const QString &path)
SSL_CTX int(*) void arg)
#define qUtf8Printable(string)
Definition qstring.h:1395
#define qPrintable(string)
Definition qstring.h:1391
QLatin1StringView QLatin1String
Definition qstringfwd.h:31
#define QStringLiteral(str)
bool qputenv(const char *varName, QByteArrayView raw)
unsigned int quint32
Definition qtypes.h:45
bool qWaitForSignal(QObject *obj, const char *signal, int timeout)
static QString stripQuotes(const QString &s)
int quick_test_main(int argc, char **argv, const char *name, const char *sourceDir)
static void handleCompileErrors(const QFileInfo &fi, const QList< QQmlError > &errors, QQmlEngine *engine, QQuickView *view=nullptr)
void maybeInvokeSetupMethod(QObject *setupObject, const char *member, Args &&... args)
int quick_test_main_with_setup(int argc, char **argv, const char *name, const char *sourceDir, QObject *setup)
QFile file
[0]
QFileInfo fi("c:/temp/foo")
[newstuff]
QDataStream & operator<<(QDataStream &out, const MyClass &myObj)
[4]
QTimer * timer
[3]
QSharedPointer< T > other(t)
[5]
QStringList files
[8]
const QStringList filters({"Image files (*.png *.xpm *.jpg)", "Text files (*.txt)", "Any files (*)" })
[6]
QGraphicsItem * item
QApplication app(argc, argv)
[0]
QLayoutItem * child
[0]
aWidget window() -> setWindowTitle("New Window Title")
[2]
QQuickView * view
[0]
QJSValueList args
QJSEngine engine
[0]
\inmodule QtCore \reentrant
Definition qchar.h:17
\inmodule QtCore
int indexOfMethod(const char *method) const
Finds method and returns its index; otherwise returns -1.
QMetaMethod method(int index) const
Returns the meta-data for the method with the given index.