summaryrefslogtreecommitdiffstats
path: root/tests/auto/installer/fakestopprocessforupdateoperation/tst_fakestopprocessforupdateoperation.cpp
diff options
context:
space:
mode:
authorkh1 <karsten.heimrich@digia.com>2013-02-28 11:34:07 +0100
committerTim Jenssen <tim.jenssen@digia.com>2013-02-28 13:24:43 +0100
commite094c0c0fa72d6b51e3d583374985efb614804db (patch)
treef5dffa2216c9e708822c780c47c8cbaae791468c /tests/auto/installer/fakestopprocessforupdateoperation/tst_fakestopprocessforupdateoperation.cpp
parent3a08a5f593944711e0449742726bb45c4eac3d85 (diff)
Fix wrong check for running application.
Add auto test. Reuse already existing code in package manager core. Change-Id: I4346333882e37c8edba9a2eb85a9cdd56ae5917e Reviewed-by: Niels Weber <niels.weber@digia.com> Reviewed-by: Kai Koehne <kai.koehne@digia.com> Reviewed-by: Tim Jenssen <tim.jenssen@digia.com>
Diffstat (limited to 'tests/auto/installer/fakestopprocessforupdateoperation/tst_fakestopprocessforupdateoperation.cpp')
-rw-r--r--tests/auto/installer/fakestopprocessforupdateoperation/tst_fakestopprocessforupdateoperation.cpp78
1 files changed, 78 insertions, 0 deletions
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"