diff options
author | Tim Jenssen <tim.jenssen@digia.com> | 2013-02-28 13:24:58 +0100 |
---|---|---|
committer | Tim Jenssen <tim.jenssen@digia.com> | 2013-02-28 13:25:47 +0100 |
commit | 2b821012f37784b6e4fa9c572b50bebf9b5e660a (patch) | |
tree | ce2c5fff34ba7e756526c8e0d97abf09b9317c97 /tests | |
parent | ae11e205d25a1294bb2c127debebde08ac4575c1 (diff) | |
parent | e094c0c0fa72d6b51e3d583374985efb614804db (diff) |
Merge remote-tracking branch 'origin/1.3'
Change-Id: Ib88eb76f360819fbdf2fd52b19fde6d5f5650447
Diffstat (limited to 'tests')
9 files changed, 212 insertions, 24 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 c01c4125c..911e1ad75 100644 --- a/tests/auto/installer/installer.pro +++ b/tests/auto/installer/installer.pro @@ -1,4 +1,6 @@ TEMPLATE = subdirs SUBDIRS += \ - settings + settings \ + repository \ + fakestopprocessforupdateoperation diff --git a/tests/auto/installer/repository/repository.pro b/tests/auto/installer/repository/repository.pro new file mode 100644 index 000000000..2d192eeaa --- /dev/null +++ b/tests/auto/installer/repository/repository.pro @@ -0,0 +1,6 @@ +include(../../qttest.pri) + +QT += network +QT -= gui + +SOURCES += tst_repository.cpp diff --git a/tests/auto/installer/repository/tst_repository.cpp b/tests/auto/installer/repository/tst_repository.cpp new file mode 100644 index 000000000..e3b7b74a6 --- /dev/null +++ b/tests/auto/installer/repository/tst_repository.cpp @@ -0,0 +1,119 @@ +#include "repository.h" + +#include <QTest> + +using namespace QInstaller; + +class tst_Repository : public QObject +{ + Q_OBJECT + +private slots: + void testRepository() + { + Repository repo; + QCOMPARE(repo.isValid(), false); + QCOMPARE(repo.isDefault(), false); + QCOMPARE(repo.isEnabled(), false); + + QCOMPARE(repo.url(), QUrl()); + QCOMPARE(repo.username(), QString()); + QCOMPARE(repo.password(), QString()); + + repo.setUrl(QUrl("http://www.digia.com")); + QCOMPARE(repo.isValid(), true); + QCOMPARE(repo.url(), QUrl("http://www.digia.com")); + + repo.setEnabled(true); + QCOMPARE(repo.isEnabled(), true); + + repo.setUsername("tester"); + QCOMPARE(repo.username(), QString("tester")); + + repo.setPassword("test"); + QCOMPARE(repo.password(), QString("test")); + } + + void testRepositoryFromUrl() + { + Repository repo(QUrl("http://www.digia.com"), true); + QCOMPARE(repo.isValid(), true); + QCOMPARE(repo.isDefault(), true); + QCOMPARE(repo.isEnabled(), true); + + QCOMPARE(repo.url(), QUrl("http://www.digia.com")); + QCOMPARE(repo.username(), QString()); + QCOMPARE(repo.password(), QString()); + + repo.setUrl(QUrl()); + QCOMPARE(repo.isValid(), false); + + repo.setEnabled(false); + QCOMPARE(repo.isEnabled(), false); + + repo.setUsername("tester"); + QCOMPARE(repo.username(), QString("tester")); + + repo.setPassword("test"); + QCOMPARE(repo.password(), QString("test")); + } + + void testRepositoryFromUserInput() + { + Repository repo = Repository::fromUserInput("ftp://tester:test@www.digia.com"); + QCOMPARE(repo.isValid(), true); + QCOMPARE(repo.isDefault(), false); + QCOMPARE(repo.isEnabled(), true); + + QCOMPARE(repo.url(), QUrl("ftp://www.digia.com")); + QCOMPARE(repo.username(), QString("tester")); + QCOMPARE(repo.password(), QString("test")); + + repo.setUrl(QUrl()); + QCOMPARE(repo.isValid(), false); + + repo.setEnabled(false); + QCOMPARE(repo.isEnabled(), false); + + repo.setUsername(""); + QCOMPARE(repo.username(), QString()); + + repo.setPassword(""); + QCOMPARE(repo.password(), QString()); + } + + void testRepositoryOperators() + { + Repository lhs, rhs; + + // operator== + QVERIFY(lhs == rhs); + + // assignment operator + rhs = Repository::fromUserInput("ftp://tester:test@www.digia.com"); + + // operator!= + QVERIFY(lhs != rhs); + + // copy constructor + Repository clhs(rhs); + + // operator== + QVERIFY(clhs == rhs); + + QByteArray ba1, ba2; + QDataStream s1(&ba1, QIODevice::ReadWrite), s2(&ba2, QIODevice::ReadWrite); + + // QDatastream operator + s1 << clhs; s2 << rhs; + QCOMPARE(ba1, ba2); + + Repository r1, r2; + s1 >> r1; s2 >> r2; + QCOMPARE(r1, r2); + } +}; + +QTEST_MAIN(tst_Repository) + +#include "tst_repository.moc" diff --git a/tests/testvm-configs/franks-host-config.cfg b/tests/testvm-configs/franks-host-config.cfg deleted file mode 100644 index bddb76af9..000000000 --- a/tests/testvm-configs/franks-host-config.cfg +++ /dev/null @@ -1,5 +0,0 @@ -[General] -vmrun=vmrun -checkerInstallation=/home/frank/workspace-eclipse/test-framework/checker -testcase0=TestCases/testcase1/testcase1.cfg -vm0=VMs/NokiaTestVistaVM.cfg diff --git a/tests/testvm-configs/franks-test-vm.cfg b/tests/testvm-configs/franks-test-vm.cfg deleted file mode 100644 index 9bd0a113e..000000000 --- a/tests/testvm-configs/franks-test-vm.cfg +++ /dev/null @@ -1,7 +0,0 @@ -[General] -snapshot=base -username=kdab -password=kdab -vmx=NokiaTestVistaVM/WindowsVista32Bit.vmx -tempDir=c:\Users\kdab\Desktop -os=windows diff --git a/tests/testvm-configs/mikes-host-config.cfg b/tests/testvm-configs/mikes-host-config.cfg deleted file mode 100644 index 42fb37d79..000000000 --- a/tests/testvm-configs/mikes-host-config.cfg +++ /dev/null @@ -1,4 +0,0 @@ -[General] -checkerInstallation=/Users/mike/Documents/KDAB/NokiaSDK/installer/test-framework/checker -testcase0=/Users/mike/Documents/KDAB/NokiaSDK/installer/examples/testcases/testcase1/testcase1.cfg -vm0=/Users/mike/Documents/KDAB/NokiaSDK/installer/examples/testvm-configs/mikes-test-vm.cfg
\ No newline at end of file diff --git a/tests/testvm-configs/mikes-test-vm.cfg b/tests/testvm-configs/mikes-test-vm.cfg deleted file mode 100644 index cc8fa4179..000000000 --- a/tests/testvm-configs/mikes-test-vm.cfg +++ /dev/null @@ -1,7 +0,0 @@ -[General] -snapshot=base -username=nokia -password=nokia -vmx=/Users/mike/Documents/Virtual Machines.localized/Nokia.vmwarevm/Nokia.vmx -tempDir=c:\Users\nokia\Desktop -os=windows
\ No newline at end of file |