33void QuickTestUtil::populateClipboardText(
int lineCount)
35#if QT_CONFIG(clipboard)
36 QString fmt(u"%1 bottles of beer on the wall, %1 bottles of beer; "
37 "take one down, pass it around, %2 bottles of beer on the wall."_s);
39 for (
int i = lineCount; i > 0; --i)
40 lines << fmt.arg(i).arg(i - 1);
41 QGuiApplication::clipboard()->setText(lines.join(u'\n'));
47QJSValue QuickTestUtil::typeName(
const QVariant &v)
const
49 QString name = QString::fromUtf8(v.typeName());
50 if (v.canConvert<QObject*>()) {
52 const QMetaObject *mo = v.value<QObject*>()->metaObject();
53 while (!type.isValid() && mo) {
54 type = QQmlMetaType::qmlType(mo);
55 mo = mo->superClass();
58 name = type.qmlTypeName();
62 QQmlEngine *engine = qmlEngine(
this);
63 QV4::ExecutionEngine *v4 = engine->handle();
64 return QJSValuePrivate::fromReturnedValue(v4->newString(name)->asReturnedValue());
71QJSValue QuickTestUtil::callerFile(
int frameIndex)
const
73 QQmlEngine *engine = qmlEngine(
this);
74 QV4::ExecutionEngine *v4 = engine->handle();
77 QVector<QV4::StackFrame> stack = v4->stackTrace(frameIndex + 2);
78 return (stack.size() > frameIndex + 1)
79 ? QJSValuePrivate::fromReturnedValue(
80 v4->newString(stack.at(frameIndex + 1).source)->asReturnedValue())
84int QuickTestUtil::callerLine(
int frameIndex)
const
86 QQmlEngine *engine = qmlEngine(
this);
87 QV4::ExecutionEngine *v4 = engine->handle();
89 QVector<QV4::StackFrame> stack = v4->stackTrace(frameIndex + 2);
90 if (stack.size() > frameIndex + 1)
91 return qAbs(stack.at(frameIndex + 1).line);