aboutsummaryrefslogtreecommitdiffstats
path: root/src/qmltest/quicktestutil_p.h
blob: d9c0241cbecb640a2336c0d6ffb1d080c0707216 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
// Copyright (C) 2019 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only

#ifndef QUICKTESTUTIL_P_H
#define QUICKTESTUTIL_P_H

//
//  W A R N I N G
//  -------------
//
// This file is not part of the Qt API.  It exists purely as an
// implementation detail.  This header file may change from version to
// version without notice, or even be removed.
//
// We mean it.
//

#include <QtQuickTest/private/quicktestglobal_p.h>

#include <QtCore/qobject.h>
#include <QtQml/qqml.h>
#include <QtQml/private/qqmlsignalnames_p.h>
#include <QtQml/qjsvalue.h>

QT_BEGIN_NAMESPACE

class Q_QMLTEST_EXPORT QuickTestUtil : public QObject
{
    Q_OBJECT
    Q_PROPERTY(bool printAvailableFunctions READ printAvailableFunctions NOTIFY printAvailableFunctionsChanged)
    Q_PROPERTY(int dragThreshold READ dragThreshold NOTIFY dragThresholdChanged)
    QML_NAMED_ELEMENT(TestUtil)
    QML_ADDED_IN_VERSION(1, 0)
public:
    QuickTestUtil(QObject *parent = nullptr) :QObject(parent) {}
    ~QuickTestUtil() override {}

    bool printAvailableFunctions() const;
    int dragThreshold() const;

    Q_INVOKABLE void populateClipboardText(int lineCount);

Q_SIGNALS:
    void printAvailableFunctionsChanged();
    void dragThresholdChanged();

public Q_SLOTS:

    QJSValue typeName(const QVariant& v) const;
    bool compare(const QVariant& act, const QVariant& exp) const;

    QJSValue callerFile(int frameIndex = 0) const;
    int callerLine(int frameIndex = 0) const;

    Q_REVISION(6, 7) QString signalHandlerName(const QString &signalName)
    {
        if (QQmlSignalNames::isHandlerName(signalName))
            return signalName;
        return QQmlSignalNames::signalNameToHandlerName(signalName);
    }
};

QT_END_NAMESPACE

#endif // QUICKTESTUTIL_P_H