14QQuickControlsTestUtils::QQuickControlsApplicationHelper::QQuickControlsApplicationHelper(QQmlDataTest *testCase,
15 const QString &testFilePath,
const QVariantMap &initialProperties,
const QStringList &qmlImportPaths)
16 : QQuickApplicationHelper(testCase, testFilePath, initialProperties, qmlImportPaths)
19 appWindow = qobject_cast<QQuickApplicationWindow*>(cleanup.data());
33 if (!currentStyle.isEmpty() && style == currentStyle)
38 qmlClearTypeRegistrations();
39 engine.reset(
new QQmlEngine);
40 QQuickStyle::setStyle(style);
42 QQmlComponent component(engine.data());
43 component.setData(QString::fromUtf8(
"import QtQuick\nimport QtQuick.Controls\n Control { }").toUtf8(), QUrl());
44 if (!component.isReady())
45 qWarning() <<
"Failed to load component:" << component.errorString();
46 return component.isReady();
50 const QString &sourcePath,
const QString &targetPath,
const QStringList &skipList,
64 const QFileInfoList entries = QDir(qqc2ImportPath + QLatin1Char(
'/') + sourcePath).entryInfoList(
65 QStringList(QStringLiteral(
"*.qml")), QDir::Files);
66 for (
const QFileInfo &entry : entries) {
67 QString name = entry.baseName();
68 if (!skipList.contains(name)) {
69 const auto importPathList = engine->importPathList();
70 for (
const QString &importPath : importPathList) {
71 QString name = entry.dir().dirName() + QLatin1Char(
'/') + entry.fileName();
72 QString filePath = importPath + QLatin1Char(
'/') + targetPath + QLatin1Char(
'/') + entry.fileName();
73 if (filePath.startsWith(QLatin1Char(
':')))
74 filePath.prepend(QStringLiteral(
"qrc"));
75 if (QFile::exists(filePath)) {
76 callback(name, QUrl::fromLocalFile(filePath));
80 filePath = QQmlFile::urlToLocalFileOrQrc(filePath);
81 if (!filePath.isEmpty() && QFile::exists(filePath)) {
134 QSignalSpy spy(button, &QQuickAbstractButton::clicked);
135 if (!spy.isValid()) {
136 qWarning() <<
"button" << button <<
"must have a valid clicked signal";
140 const QPoint buttonCenter = button->mapToScene(QPointF(button->width() / 2, button->height() / 2)).toPoint();
141 QTest::mouseClick(button->window(), Qt::LeftButton, Qt::NoModifier, buttonCenter);
142 if (spy.size() != 1) {
143 qWarning() <<
"clicked signal of button" << button <<
"was not emitted after clicking";
155 QSignalSpy spy(button, &QQuickAbstractButton::clicked);
156 if (!spy.isValid()) {
157 qWarning() <<
"button" << button <<
"must have a valid doubleClicked signal";
161 const QPoint buttonCenter = button->mapToScene(QPointF(button->width() / 2, button->height() / 2)).toPoint();
162 QTest::mouseDClick(button->window(), Qt::LeftButton, Qt::NoModifier, buttonCenter);
163 if (spy.size() != 1) {
164 qWarning() <<
"doubleClicked signal of button" << button <<
"was not emitted after double-clicking";
207 QDebug debug(&message);
208 const auto *controlPrivate = QQuickControlPrivate::get(control);
209 const QQuickWindow *window = control->window();
210 const QString activeFocusItemStr = window
211 ? QDebug::toString(window->activeFocusItem()) : QStringLiteral(
"(unknown; control has no window)");
212 debug.nospace() <<
"control: " << control <<
" activeFocus: " << control->hasActiveFocus()
213 <<
" focusReason: " <<
static_cast<Qt::FocusReason>(controlPrivate->focusReason)
214 <<
" activeFocusItem: " << activeFocusItemStr;
void forEachControl(QQmlEngine *engine, const QString &qqc2ImportPath, const QString &sourcePath, const QString &targetPath, const QStringList &skipList, ForEachCallback callback)