blob: 1d23e1970f8d9e72f63cfbfa3eb2a95d24c297a1 (
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
66
67
68
69
70
71
72
73
74
75
76
77
78
|
#include "fakestopprocessforupdateoperation.h"
#include "packagemanagercore.h"
#include <QFileInfo>
#include <QTest>
using namespace KDUpdater;
using namespace QInstaller;
class tst_FakeStopProcessForUpdateOperation : public QObject
{
Q_OBJECT
private slots:
void testMissingArgument()
{
FakeStopProcessForUpdateOperation op;
op.setValue(QLatin1String("installer"), QVariant::fromValue(&m_core));
QVERIFY(op.testOperation());
QVERIFY(op.performOperation());
QVERIFY(!op.undoOperation());
QCOMPARE(UpdateOperation::Error(op.error()), UpdateOperation::InvalidArguments);
QCOMPARE(op.errorString(), QString("Number of arguments does not match: one is required"));
}
void testMissingPackageManagerCore()
{
FakeStopProcessForUpdateOperation op;
op.setArguments(QStringList() << QFileInfo(QCoreApplication::applicationFilePath()).fileName());
QVERIFY(op.testOperation());
QVERIFY(op.performOperation());
QVERIFY(!op.undoOperation());
QCOMPARE(UpdateOperation::Error(op.error()), UpdateOperation::UserDefinedError);
QCOMPARE(op.errorString(), QString("Could not get package manager core."));
}
void testRunningApplication()
{
const QString app = QFileInfo(QCoreApplication::applicationFilePath()).fileName();
FakeStopProcessForUpdateOperation op;
op.setArguments(QStringList() << app);
op.setValue(QLatin1String("installer"), QVariant::fromValue(&m_core));
QVERIFY(op.testOperation());
QVERIFY(op.performOperation());
QVERIFY(!op.undoOperation());
QCOMPARE(UpdateOperation::Error(op.error()), UpdateOperation::UserDefinedError);
QCOMPARE(op.errorString(), QString::fromLatin1("This process should be stopped before "
"continuing: %1").arg(app));
}
void testRunningNonApplication()
{
FakeStopProcessForUpdateOperation op;
op.setArguments(QStringList() << "dummy.exe");
op.setValue(QLatin1String("installer"), QVariant::fromValue(&m_core));
QVERIFY(op.testOperation());
QVERIFY(op.performOperation());
QVERIFY(op.undoOperation());
QCOMPARE(op.errorString(), QString());
QCOMPARE(UpdateOperation::Error(op.error()), UpdateOperation::NoError);
}
private:
PackageManagerCore m_core;
};
QTEST_MAIN(tst_FakeStopProcessForUpdateOperation)
#include "tst_fakestopprocessforupdateoperation.moc"
|