File: TestHelper.cpp

package info (click to toggle)
kf6-kauth 6.20.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 21,468 kB
  • sloc: cpp: 2,944; xml: 24; sh: 14; makefile: 7
file content (64 lines) | stat: -rw-r--r-- 1,495 bytes parent folder | download | duplicates (3)
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
/*
    SPDX-FileCopyrightText: 2012 Dario Freddi <drf@kde.org>

    SPDX-License-Identifier: LGPL-2.1-or-later
*/

#include "TestHelper.h"

#include <helpersupport.h>

#include <QDebug>
#include <QEventLoop>
#include <QFile>
#include <QTextStream>
#include <QThread>
#include <qplatformdefs.h>

ActionReply TestHelper::echoaction(QVariantMap args)
{
    qDebug() << "Echo action running";
    ActionReply reply = ActionReply::SuccessReply();
    reply.setData(args);

    return reply;
}

ActionReply TestHelper::standardaction(QVariantMap args)
{
    qDebug() << "Standard action running";
    if (args.contains(QLatin1String("fail")) && args[QLatin1String("fail")].toBool()) {
        return ActionReply::HelperErrorReply();
    }

    return ActionReply::SuccessReply();
}

ActionReply TestHelper::longaction(QVariantMap args)
{
    Q_UNUSED(args);
    qDebug() << "Long action running. Don't be scared, this action takes 2 seconds to complete";

    for (int i = 1; i <= 100; i++) {
        if (HelperSupport::isStopped()) {
            break;
        }
        if (i == 50) {
            QVariantMap map;
            map.insert(QLatin1String("Answer"), 42);
            HelperSupport::progressStep(map);
        }
        HelperSupport::progressStep(i);
        QThread::usleep(20000);
    }

    return ActionReply::SuccessReply();
}

ActionReply TestHelper::failingaction(QVariantMap args)
{
    Q_UNUSED(args)
    return ActionReply::HelperErrorReply();
}

#include "moc_TestHelper.cpp"