summaryrefslogtreecommitdiffstats
path: root/tests/auto/installer
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/installer')
-rw-r--r--tests/auto/installer/fakestopprocessforupdateoperation/fakestopprocessforupdateoperation.pro6
-rw-r--r--tests/auto/installer/fakestopprocessforupdateoperation/tst_fakestopprocessforupdateoperation.cpp78
-rw-r--r--tests/auto/installer/installer.pro3
3 files changed, 86 insertions, 1 deletions
diff --git a/tests/auto/installer/fakestopprocessforupdateoperation/fakestopprocessforupdateoperation.pro b/tests/auto/installer/fakestopprocessforupdateoperation/fakestopprocessforupdateoperation.pro
new file mode 100644
index 000000000..871b668b2
--- /dev/null
+++ b/tests/auto/installer/fakestopprocessforupdateoperation/fakestopprocessforupdateoperation.pro
@@ -0,0 +1,6 @@
+include(../../qttest.pri)
+
+QT -= gui
+QT += network script
+
+SOURCES += tst_fakestopprocessforupdateoperation.cpp
diff --git a/tests/auto/installer/fakestopprocessforupdateoperation/tst_fakestopprocessforupdateoperation.cpp b/tests/auto/installer/fakestopprocessforupdateoperation/tst_fakestopprocessforupdateoperation.cpp
new file mode 100644
index 000000000..1d23e1970
--- /dev/null
+++ b/tests/auto/installer/fakestopprocessforupdateoperation/tst_fakestopprocessforupdateoperation.cpp
@@ -0,0 +1,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"
diff --git a/tests/auto/installer/installer.pro b/tests/auto/installer/installer.pro
index 0c1b7f975..911e1ad75 100644
--- a/tests/auto/installer/installer.pro
+++ b/tests/auto/installer/installer.pro
@@ -2,4 +2,5 @@ TEMPLATE = subdirs
SUBDIRS += \
settings \
- repository
+ repository \
+ fakestopprocessforupdateoperation