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.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 <QtTest/private/qtestcrashhandler_p.h>
8#include "qtestoptions_p.h"
9#include <QtQml/qqml.h>
10#include <QtQml/qqmlengine.h>
11#include <QtQml/qqmlcontext.h>
12#include <QtQuick/private/qquickitem_p.h>
13#include <QtQuick/private/qquickwindow_p.h>
14#include <QtQuick/qquickitem.h>
15#include <QtQuick/qquickview.h>
16#include <QtQuick/qquickwindow.h>
17#include <QtQml/qjsvalue.h>
18#include <QtQml/qjsengine.h>
19#include <QtQml/qqmlpropertymap.h>
20#include <QtQuick/private/qquickitem_p.h>
21#include <QtQuick/qquickitem.h>
22#include <qopengl.h>
23#include <QtCore/qurl.h>
24#include <QtCore/qfileinfo.h>
25#include <QtCore/qdir.h>
26#include <QtCore/qdiriterator.h>
27#include <QtCore/qfile.h>
28#include <QtCore/qdebug.h>
29#include <QtCore/qeventloop.h>
30#include <QtCore/qtextstream.h>
31#include <QtCore/qtimer.h>
32#include <QtGui/qtextdocument.h>
33#include <stdio.h>
34#include <QtGui/QGuiApplication>
35#include <QtGui/private/qguiapplication_p.h>
36#include <QtGui/qpa/qplatformintegration.h>
37#include <QtCore/QTranslator>
38#include <QtTest/QSignalSpy>
39#include <QtQml/QQmlFileSelector>
40
41#include <private/qqmlcomponent_p.h>
42#include <private/qv4resolvedtypereference_p.h>
43
45
77{
78 return QQuickItemPrivate::get(item)->polishScheduled;
79}
80
105{
106 return !QQuickWindowPrivate::get(window)->itemsToPolish.isEmpty();
107}
108
109#if QT_VERSION < QT_VERSION_CHECK(7, 0, 0)
110#if QT_DEPRECATED_SINCE(6, 4)
127bool QQuickTest::qWaitForItemPolished(const QQuickItem *item, int timeout)
128{
129 return qWaitForPolish(item, timeout);
130}
131#endif
132#endif
133
147{
148 return QTest::qWaitFor([&]() { return !QQuickItemPrivate::get(item)->polishScheduled; }, timeout);
149}
150
167{
168 return QTest::qWaitFor([&]() { return QQuickWindowPrivate::get(window)->itemsToPolish.isEmpty(); }, timeout);
169}
170
171static inline QString stripQuotes(const QString &s)
172{
173 if (s.size() >= 2 && s.startsWith(QLatin1Char('"')) && s.endsWith(QLatin1Char('"')))
174 return s.mid(1, s.size() - 2);
175 else
176 return s;
177}
178
180 const QFileInfo &fi, const QList<QQmlError> &errors, QQmlEngine *engine,
181 QQuickView *view = nullptr)
182{
183 // Error compiling the test - flag failure in the log and continue.
185 results.setTestCaseName(fi.baseName());
186 results.startLogging();
187 results.setFunctionName(QLatin1String("compile"));
188 // Verbose warning output of all messages and relevant parameters
191 str << "\n " << QDir::toNativeSeparators(fi.absoluteFilePath()) << " produced "
192 << errors.size() << " error(s):\n";
193 for (const QQmlError &e : errors) {
194 str << " ";
195 if (e.url().isLocalFile()) {
196 str << QDir::toNativeSeparators(e.url().toLocalFile());
197 } else {
198 str << e.url().toString();
199 }
200 if (e.line() > 0)
201 str << ':' << e.line() << ',' << e.column();
202 str << ": " << e.description() << '\n';
203 }
204 str << " Working directory: " << QDir::toNativeSeparators(QDir::current().absolutePath()) << '\n';
205 if (engine) {
206 str << " ";
207 if (view)
208 str << "View: " << view->metaObject()->className() << ", ";
209 str << "Import paths:\n";
210 const auto importPaths = engine->importPathList();
211 for (const QString &i : importPaths)
212 str << " '" << QDir::toNativeSeparators(i) << "'\n";
213 const QStringList pluginPaths = engine->pluginPathList();
214 str << " Plugin paths:\n";
215 for (const QString &p : pluginPaths)
216 str << " '" << QDir::toNativeSeparators(p) << "'\n";
217 }
219 // Fail with error 0.
220 results.fail(errors.at(0).description(),
221 errors.at(0).url(), errors.at(0).line());
222 results.finishTestData();
223 results.finishTestDataCleanup();
224 results.finishTestFunction();
225 results.setFunctionName(QString());
226 results.stopLogging();
227}
228
229class SimpleReceiver : public QObject {
231public:
232 bool signalReceived = false;
233public slots:
234 void slotFun() { signalReceived = true; }
235};
236
237bool qWaitForSignal(QObject *obj, const char* signal, int timeout)
238{
239 if (!obj || !signal) {
240 qWarning("qWaitForSignal: invalid arguments");
241 return false;
242 }
243 if (((signal[0] - '0') & 0x03) != QSIGNAL_CODE) {
244 qWarning("qWaitForSignal: not a valid signal, use the SIGNAL macro");
245 return false;
246 }
247
248 int sig = obj->metaObject()->indexOfSignal(signal + 1);
249 if (sig == -1) {
251 sig = obj->metaObject()->indexOfSignal(ba.constData());
252 if (sig == -1) {
253 qWarning("qWaitForSignal: no such signal %s::%s", obj->metaObject()->className(),
254 signal);
255 return false;
256 }
257 }
258
259 SimpleReceiver receiver;
260 static int slot = receiver.metaObject()->indexOfSlot("slotFun()");
261 if (!QMetaObject::connect(obj, sig, &receiver, slot)) {
262 qWarning("qWaitForSignal: failed to connect to signal %s::%s",
263 obj->metaObject()->className(), signal);
264 return false;
265 }
266
267 return QTest::qWaitFor([&]() { return receiver.signalReceived; }, timeout);
268}
269
270template <typename... Args>
271void maybeInvokeSetupMethod(QObject *setupObject, const char *member, Args &&... args)
272{
273 // It's OK if it doesn't exist: since we have more than one callback that
274 // can be called, it makes sense if the user only implements one of them.
275 // We do this the long way rather than just calling the static
276 // QMetaObject::invokeMethod(), because that will issue a warning if the
277 // function doesn't exist, which we don't want.
278 const QMetaObject *setupMetaObject = setupObject->metaObject();
279 const int methodIndex = setupMetaObject->indexOfMethod(member);
280 if (methodIndex != -1) {
281 const QMetaMethod method = setupMetaObject->method(methodIndex);
282 method.invoke(setupObject, std::forward<Args>(args)...);
283 }
284}
285
286using namespace QV4::CompiledData;
287
289{
290public:
291 typedef QList<QString> TestCaseList;
292
293 TestCaseCollector(const QFileInfo &fileInfo, QQmlEngine *engine) : m_engine(engine)
294 {
295 QString path = fileInfo.absoluteFilePath();
296 if (path.startsWith(QLatin1String(":/")))
297 path.prepend(QLatin1String("qrc"));
298
300 m_errors += component.errors();
301
302 if (component.isReady()) {
303 QQmlRefPointer<QV4::ExecutableCompilationUnit> rootCompilationUnit
304 = QQmlComponentPrivate::get(&component)->compilationUnit;
305 TestCaseEnumerationResult result = enumerateTestCases(
306 rootCompilationUnit->baseCompilationUnit().data());
307 m_testCases = result.testCases + result.finalizedPartialTestCases();
308 m_errors += result.errors;
309 }
310 }
311
312 TestCaseList testCases() const { return m_testCases; }
313 QList<QQmlError> errors() const { return m_errors; }
314
315private:
316 TestCaseList m_testCases;
317 QList<QQmlError> m_errors;
318 QQmlEngine *m_engine = nullptr;
319
320 struct TestCaseEnumerationResult
321 {
322 TestCaseList testCases;
323 QList<QQmlError> errors;
324
325 // Partially constructed test cases
326 bool isTestCase = false;
327 TestCaseList testFunctions;
328 QString testCaseName;
329
330 TestCaseList finalizedPartialTestCases() const
331 {
333 for (const QString &function : testFunctions)
334 result << QString(QStringLiteral("%1::%2")).arg(testCaseName).arg(function);
335 return result;
336 }
337
338 TestCaseEnumerationResult &operator<<(const TestCaseEnumerationResult &other)
339 {
340 testCases += other.testCases + other.finalizedPartialTestCases();
341 errors += other.errors;
342 return *this;
343 }
344 };
345
346 TestCaseEnumerationResult enumerateTestCases(
347 const QQmlRefPointer<QV4::CompiledData::CompilationUnit> &compilationUnit,
348 const QV4::CompiledData::Object *object = nullptr)
349 {
350 QQmlType testCaseType;
351 for (quint32 i = 0, count = compilationUnit->importCount(); i < count; ++i) {
352 const Import *import = compilationUnit->importAt(i);
353 if (compilationUnit->stringAt(import->uriIndex) != QLatin1String("QtTest"))
354 continue;
355
356 QString testCaseTypeName(QStringLiteral("TestCase"));
357 QString typeQualifier = compilationUnit->stringAt(import->qualifierIndex);
358 if (!typeQualifier.isEmpty())
359 testCaseTypeName = typeQualifier % QLatin1Char('.') % testCaseTypeName;
360
361 testCaseType = compilationUnit->typeNameCache->query(
362 testCaseTypeName, QQmlTypeLoader::get(m_engine)).type;
363 if (testCaseType.isValid())
364 break;
365 }
366
367 TestCaseEnumerationResult result;
368
369 if (!object) // Start at root of compilation unit if not enumerating a specific child
370 object = compilationUnit->objectAt(0);
372 return result;
373
374 if (const auto superTypeUnit = compilationUnit->resolvedType(object->inheritedTypeNameIndex)
375 ->compilationUnit()) {
376 // We have a non-C++ super type, which could indicate we're a subtype of a TestCase
377 if (testCaseType.isValid() && superTypeUnit->url() == testCaseType.sourceUrl())
378 result.isTestCase = true;
379 else if (superTypeUnit->url() != compilationUnit->url()) { // urls are the same for inline component, avoid infinite recursion
380 result = enumerateTestCases(superTypeUnit);
381 }
382
383 if (result.isTestCase) {
384 // Look for override of name in this type
385 for (auto binding = object->bindingsBegin(); binding != object->bindingsEnd(); ++binding) {
386 if (compilationUnit->stringAt(binding->propertyNameIndex) == QLatin1String("name")) {
387 if (binding->type() == QV4::CompiledData::Binding::Type_String) {
388 result.testCaseName = compilationUnit->stringAt(binding->stringIndex);
389 } else {
391 error.setUrl(compilationUnit->url());
392 error.setLine(binding->location.line());
393 error.setColumn(binding->location.column());
394 error.setDescription(QStringLiteral("the 'name' property of a TestCase must be a literal string"));
395 result.errors << error;
396 }
397 break;
398 }
399 }
400
401 // Look for additional functions in this type
402 auto functionsEnd = compilationUnit->objectFunctionsEnd(object);
403 for (auto function = compilationUnit->objectFunctionsBegin(object); function != functionsEnd; ++function) {
404 QString functionName = compilationUnit->stringAt(function->nameIndex);
405 if (!(functionName.startsWith(QLatin1String("test_")) || functionName.startsWith(QLatin1String("benchmark_"))))
406 continue;
407
408 if (functionName.endsWith(QLatin1String("_data")))
409 continue;
410
411 result.testFunctions << functionName;
412 }
413 }
414 }
415
416 for (auto binding = object->bindingsBegin(); binding != object->bindingsEnd(); ++binding) {
417 if (binding->type() == QV4::CompiledData::Binding::Type_Object) {
418 const QV4::CompiledData::Object *child = compilationUnit->objectAt(binding->value.objectIndex);
419 result << enumerateTestCases(compilationUnit, child);
420 }
421 }
422
423 return result;
424 }
425};
426
427int quick_test_main(int argc, char **argv, const char *name, const char *sourceDir)
428{
429 return quick_test_main_with_setup(argc, argv, name, sourceDir, nullptr);
430}
431
432int quick_test_main_with_setup(int argc, char **argv, const char *name, const char *sourceDir, QObject *setup)
433{
434 QScopedPointer<QCoreApplication> app;
436 app.reset(new QGuiApplication(argc, argv));
437
438 if (setup)
439 maybeInvokeSetupMethod(setup, "applicationAvailable()");
440
441 // Look for QML-specific command-line options.
442 // -import dir Specify an import directory.
443 // -plugins dir Specify a directory where to search for plugins.
444 // -input dir Specify the input directory for test cases.
445 // -translation file Specify the translation file.
446 // -file-selector Specify a file selector
447 QStringList imports;
448 QStringList pluginPaths;
449 QString testPath;
450 QString translationFile;
451 QStringList fileSelectors;
452 int index = 1;
453 QScopedArrayPointer<char *> testArgV(new char *[argc + 1]);
454 testArgV[0] = argv[0];
455 int testArgC = 1;
456 while (index < argc) {
457 if (strcmp(argv[index], "-import") == 0 && (index + 1) < argc) {
458 imports += stripQuotes(QString::fromLocal8Bit(argv[index + 1]));
459 index += 2;
460 } else if (strcmp(argv[index], "-plugins") == 0 && (index + 1) < argc) {
461 pluginPaths += stripQuotes(QString::fromLocal8Bit(argv[index + 1]));
462 index += 2;
463 } else if (strcmp(argv[index], "-input") == 0 && (index + 1) < argc) {
464 testPath = stripQuotes(QString::fromLocal8Bit(argv[index + 1]));
465 index += 2;
466 } else if (strcmp(argv[index], "-opengl") == 0) {
467 ++index;
468 } else if (strcmp(argv[index], "-translation") == 0 && (index + 1) < argc) {
469 translationFile = stripQuotes(QString::fromLocal8Bit(argv[index + 1]));
470 index += 2;
471 } else if (strcmp(argv[index], "-file-selector") == 0 && (index + 1) < argc) {
472 fileSelectors += stripQuotes(QString::fromLocal8Bit(argv[index + 1]));
473 index += 2;
474 } else {
475 testArgV[testArgC++] = argv[index++];
476 }
477 }
478 testArgV[testArgC] = 0;
479
480 // Setting currentAppname and currentTestObjectName (via setProgramName) are needed
481 // for the code coverage analysis. Must be done before parseArgs is called.
484
485 QuickTestResult::parseArgs(testArgC, testArgV.data());
486
487#if QT_CONFIG(translation)
488 QTranslator translator;
489 if (!translationFile.isEmpty()) {
490 if (translator.load(translationFile)) {
491 app->installTranslator(&translator);
492 } else {
493 qWarning("Could not load the translation file '%s'.", qPrintable(translationFile));
494 }
495 }
496#endif
497
498 // Determine where to look for the test data.
499 if (testPath.isEmpty() && sourceDir) {
500 const QString s = QString::fromLocal8Bit(sourceDir);
501 if (QFile::exists(s))
502 testPath = s;
503 }
504
505#if defined(Q_OS_ANDROID) || defined(Q_OS_INTEGRITY)
506 if (testPath.isEmpty())
507 testPath = QLatin1String(":/");
508#endif
509
510 if (testPath.isEmpty()) {
511 QDir current = QDir::current();
512#ifdef Q_OS_WIN
513 // Skip release/debug subfolders
514 if (!current.dirName().compare(QLatin1String("Release"), Qt::CaseInsensitive)
515 || !current.dirName().compare(QLatin1String("Debug"), Qt::CaseInsensitive))
516 current.cdUp();
517#endif // Q_OS_WIN
518 testPath = current.absolutePath();
519 }
521
522 const QFileInfo testPathInfo(testPath);
523 if (testPathInfo.isFile()) {
524 if (testPath.endsWith(QLatin1String(".qml"))) {
525 files << testPath;
526 } else if (testPath.endsWith(QLatin1String(".qmltests"))) {
527 QFile file(testPath);
529 while (!file.atEnd()) {
530 const QString filePath = testPathInfo.dir()
531 .filePath(QString::fromUtf8(file.readLine()))
532 .trimmed();
533 const QFileInfo f(filePath);
534 if (f.exists())
535 files.append(filePath);
536 else
537 qWarning("The test file '%s' does not exists", qPrintable(filePath));
538 }
539 file.close();
540 files.sort();
541 if (files.isEmpty()) {
542 qWarning("The file '%s' does not contain any tests files",
543 qPrintable(testPath));
544 return 1;
545 }
546 } else {
547 qWarning("Could not read '%s'", qPrintable(testPath));
548 }
549 } else {
550 qWarning("'%s' does not have the suffix '.qml' or '.qmltests'.", qPrintable(testPath));
551 return 1;
552 }
553 } else if (testPathInfo.isDir()) {
554 // Scan the test data directory recursively, looking for "tst_*.qml" files.
555 const QStringList filters(QStringLiteral("tst_*.qml"));
556 QDirIterator iter(testPathInfo.absoluteFilePath(), filters, QDir::Files,
559 while (iter.hasNext())
560 files += iter.next();
561 files.sort();
562 if (files.isEmpty()) {
563 qWarning("The directory '%s' does not contain any test files matching '%s'",
564 qPrintable(testPath), qPrintable(filters.front()));
565 return 1;
566 }
567 } else {
568 qWarning("'%s' does not exist under '%s'.",
570 return 1;
571 }
572
573 std::optional<QTest::CrashHandler::FatalSignalHandler> handler;
576 handler.emplace();
577
578 qputenv("QT_QTESTLIB_RUNNING", "1");
579
580 QSet<QString> commandLineTestFunctions(QTest::testFunctions.cbegin(), QTest::testFunctions.cend());
581 const bool filteringTestFunctions = !commandLineTestFunctions.isEmpty();
582
583 // Scan through all of the "tst_*.qml" files and run each of them
584 // in turn with a separate QQuickView (for test isolation).
585 for (const QString &file : std::as_const(files)) {
586 const QFileInfo fi(file);
587 if (!fi.exists())
588 continue;
589
591 for (const QString &path : std::as_const(imports))
592 engine.addImportPath(path);
593 for (const QString &path : std::as_const(pluginPaths))
594 engine.addPluginPath(path);
595
596 if (!fileSelectors.isEmpty()) {
597 QQmlFileSelector* const qmlFileSelector = new QQmlFileSelector(&engine, &engine);
598 qmlFileSelector->setExtraSelectors(fileSelectors);
599 }
600
601 // Do this down here so that import paths, plugin paths, file selectors, etc. are available
602 // in case the user needs access to them. Do it _before_ the TestCaseCollector parses the
603 // QML files though, because it attempts to import modules, which might not be available
604 // if qmlRegisterType()/QQmlEngine::addImportPath() are called in qmlEngineAvailable().
605 if (setup)
606 maybeInvokeSetupMethod(setup, "qmlEngineAvailable(QQmlEngine*)", Q_ARG(QQmlEngine*, &engine));
607
608 TestCaseCollector testCaseCollector(fi, &engine);
609 if (!testCaseCollector.errors().isEmpty()) {
610 handleCompileErrors(fi, testCaseCollector.errors(), &engine);
611 continue;
612 }
613
614 TestCaseCollector::TestCaseList availableTestFunctions = testCaseCollector.testCases();
616 for (const QString &function : availableTestFunctions)
617 qDebug("%s()", qPrintable(function));
618 continue;
619 }
620
621 const QSet<QString> availableTestSet(availableTestFunctions.cbegin(), availableTestFunctions.cend());
622 if (filteringTestFunctions && !availableTestSet.intersects(commandLineTestFunctions))
623 continue;
624 commandLineTestFunctions.subtract(availableTestSet);
625
626 QQuickView view(&engine, nullptr);
630 QEventLoop eventLoop;
634 &eventLoop, SLOT(quit()));
636 (QLatin1String("qtest"), QTestRootObject::instance()); // Deprecated. Use QTestRootObject from QtTest instead
637
638 view.setObjectName(fi.baseName());
641 QString path = fi.absoluteFilePath();
642 if (path.startsWith(QLatin1String(":/")))
644 else
646
647 while (view.status() == QQuickView::Loading)
648 QTest::qWait(10);
649 if (view.status() == QQuickView::Error) {
651 continue;
652 }
653
654 view.setFramePosition(QPoint(50, 50));
655 if (view.size().isEmpty()) { // Avoid hangs with empty windows.
656 view.resize(200, 200);
657 }
658 view.show();
660 qWarning().nospace()
661 << "Test '" << QDir::toNativeSeparators(path) << "' window not exposed after show().";
662 }
664 view.requestActivate();
666 qWarning().nospace()
667 << "Test '" << QDir::toNativeSeparators(path) << "' window not active after requestActivate().";
668 }
669 }
670 if (view.isExposed()) {
671 // Defer property update until event loop has started
672 QTimer::singleShot(0, []() {
673 QTestRootObject::instance()->setWindowShown(true);
674 });
675 } else {
676 qWarning().nospace()
677 << "Test '" << QDir::toNativeSeparators(path) << "' window was never exposed! "
678 << "If the test case was expecting windowShown, it will hang.";
679 }
680 if (!QTestRootObject::instance()->hasQuit && QTestRootObject::instance()->hasTestCase())
681 eventLoop.exec();
682 }
683
684 if (setup)
685 maybeInvokeSetupMethod(setup, "cleanupTestCase()");
686
687 // Flush the current logging stream.
689 app.reset();
690
691 // Check that all test functions passed on the command line were found
692 if (!commandLineTestFunctions.isEmpty()) {
693 qWarning() << "Could not find the following test functions:";
694 for (const QString &functionName : std::as_const(commandLineTestFunctions))
695 qWarning(" %s()", qUtf8Printable(functionName));
696 return commandLineTestFunctions.size();
697 }
698
699 // Return the number of failures as the exit code.
701}
702
704
705#include "moc_quicktest_p.cpp"
706#include "quicktest.moc"
\inmodule QtCore
Definition qbytearray.h:57
const char * constData() const noexcept
Returns a pointer to the const data stored in the byte array.
Definition qbytearray.h:124
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...
The QDirIterator class provides an iterator for directory entrylists.
\inmodule QtCore
Definition qdir.h:20
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:219
QString absolutePath() const
Returns the absolute path (a path that starts with "/" or with a drive specification),...
Definition qdir.cpp:667
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:2054
@ Files
Definition qdir.h:23
\inmodule QtCore
Definition qeventloop.h:16
int exec(ProcessEventsFlags flags=AllEvents)
Enters the main event loop and waits until exit() is called.
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.
QString absoluteFilePath() const
\inmodule QtCore
Definition qfile.h:93
QFILE_MAYBE_NODISCARD bool open(OpenMode flags) override
Opens the file using OpenMode mode, returning true if successful; otherwise false.
Definition qfile.cpp:904
bool exists() const
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition qfile.cpp:351
static QPlatformIntegration * platformIntegration()
\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,...
\inmodule QtCore
Definition qmetaobject.h:19
\inmodule QtCore
Definition qobject.h:103
static QMetaObject::Connection connect(const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
\threadsafe
Definition qobject.cpp:2960
QString objectName
the name of this object
Definition qobject.h:107
Q_WEAK_OVERLOAD void setObjectName(const QString &name)
Sets the object's name to name.
Definition qobject.h:127
\inmodule QtCore\reentrant
Definition qpoint.h:25
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.
static QQmlTypeLoader * get(Engine *engine)
static QQuickItemPrivate * get(QQuickItem *item)
The QQuickItem class provides the most basic of all visual items in \l {Qt Quick}.
Definition qquickitem.h:63
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)
\qmltype Window \instantiates QQuickWindow \inqmlmodule QtQuick
\inmodule QtCore
\inmodule QtCore
Definition qstringview.h:78
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:129
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:5455
static QString fromLocal8Bit(QByteArrayView ba)
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition qstring.cpp:5949
bool isEmpty() const noexcept
Returns true if the string has no characters; otherwise returns false.
Definition qstring.h:192
static QString fromUtf8(QByteArrayView utf8)
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition qstring.cpp:6018
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:5506
int compare(const QString &s, Qt::CaseSensitivity cs=Qt::CaseSensitive) const noexcept
Definition qstring.cpp:6664
QString trimmed() const &
Definition qstring.h:447
QString & prepend(QChar c)
Definition qstring.h:478
static QTestRootObject * instance()
Definition quicktest_p.h:48
\inmodule QtCore
bool singleShot
whether the timer is a single-shot timer
Definition qtimer.h:22
\inmodule QtCore
Definition qtranslator.h:19
\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:3368
void show()
Shows the window.
Definition qwindow.cpp:2254
void setTitle(const QString &)
Definition qwindow.cpp:1030
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]
auto signal
Q_QMLTEST_EXPORT bool qWaitForPolish(const QQuickItem *item, int timeout=defaultTimeout)
Q_QMLTEST_EXPORT bool qIsPolishScheduled(const QQuickItem *item)
Definition quicktest.cpp:76
Combined button and popup list for selecting options.
bool qWaitFor(Functor predicate, QDeadlineTimer deadline=QDeadlineTimer(std::chrono::seconds{5}))
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_TESTLIB_EXPORT bool printAvailableFunctions
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:207
@ WindowMinMaxButtonsHint
Definition qnamespace.h:230
@ WindowTitleHint
Definition qnamespace.h:226
@ WindowSystemMenuHint
Definition qnamespace.h:227
@ WindowCloseButtonHint
Definition qnamespace.h:241
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:164
#define qWarning
Definition qlogging.h:166
#define SLOT(a)
Definition qobjectdefs.h:52
#define QSIGNAL_CODE
Definition qobjectdefs.h:42
#define Q_ARG(Type, data)
Definition qobjectdefs.h:63
#define SIGNAL(a)
Definition qobjectdefs.h:53
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]
GLdouble s
[6]
Definition qopenglext.h:235
GLsizei const GLchar *const * path
GLuint64EXT * result
[6]
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:1535
#define qPrintable(string)
Definition qstring.h:1531
QLatin1StringView QLatin1String
Definition qstringfwd.h:31
#define QStringLiteral(str)
bool qputenv(const char *varName, QByteArrayView raw)
#define Q_OBJECT
#define slots
unsigned int quint32
Definition qtypes.h:50
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)
QByteArray ba
[0]
QFile file
[0]
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:18
\inmodule QtCore
static QByteArray normalizedSignature(const char *method)
Normalizes the signature of the given method.
static Connection connect(const QObject *sender, int signal_index, const QObject *receiver, int method_index, int type=0, int *types=nullptr)
Definition qobject.cpp:3556
int indexOfMethod(const char *method) const
Finds method and returns its index; otherwise returns -1.