summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMontel Laurent <montel@kde.org>2016-11-02 05:50:34 (GMT)
committerMontel Laurent <montel@kde.org>2016-11-02 05:50:34 (GMT)
commitd9098e59b1638fd07878b3cc2bc4d05db63f48f3 (patch)
treebcfa3dc3e18b61a3680c2e70604f32cecf2cff6e
parenta4e94ee57cd823250114872838fd4d2bea8a76a9 (diff)
Add more autotest
-rw-r--r--src/ksieveui/managescriptsjob/autotests/renamescriptjobtest.cpp25
-rw-r--r--src/ksieveui/managescriptsjob/autotests/renamescriptjobtest.h2
-rw-r--r--src/ksieveui/managescriptsjob/renamescriptjob.cpp4
3 files changed, 30 insertions, 1 deletions
diff --git a/src/ksieveui/managescriptsjob/autotests/renamescriptjobtest.cpp b/src/ksieveui/managescriptsjob/autotests/renamescriptjobtest.cpp
index 2195295..96aae70 100644
--- a/src/ksieveui/managescriptsjob/autotests/renamescriptjobtest.cpp
+++ b/src/ksieveui/managescriptsjob/autotests/renamescriptjobtest.cpp
@@ -38,4 +38,29 @@ void RenameScriptJobTest::canNotStartByDefault()
QVERIFY(!job.canStart());
}
+void RenameScriptJobTest::shouldBeStart_data()
+{
+ QTest::addColumn<QString>("newName");
+ QTest::addColumn<QUrl>("url");
+ QTest::addColumn<bool>("canStart");
+ QTest::newRow("empty") << QString() << QUrl() << false;
+ QTest::newRow("hasNewName") << QStringLiteral("foo") << QUrl() << false;
+ QTest::newRow("hasUrl") << QString() << QUrl(QStringLiteral("http://www.kde.org")) << false;
+ QTest::newRow("canStart") << QStringLiteral("foo") << QUrl(QStringLiteral("http://www.kde.org")) << true;
+ QTest::newRow("cannotStartHasEmptyName") << QStringLiteral(" ") << QUrl(QStringLiteral("http://www.kde.org")) << false;
+ //QTest::newRow("cannotStartHasInvalidUrl") << QStringLiteral("foo") << QUrl(QStringLiteral(" ")) << false;
+}
+
+void RenameScriptJobTest::shouldBeStart()
+{
+ QFETCH(QString, newName);
+ QFETCH(QUrl, url);
+ QFETCH(bool, canStart);
+ KSieveUi::RenameScriptJob job;
+ job.setNewName(newName);
+ job.setOldUrl(url);
+ QCOMPARE(job.canStart(), canStart);
+}
+
+
QTEST_MAIN(RenameScriptJobTest)
diff --git a/src/ksieveui/managescriptsjob/autotests/renamescriptjobtest.h b/src/ksieveui/managescriptsjob/autotests/renamescriptjobtest.h
index 1b4c8ab..343b81a 100644
--- a/src/ksieveui/managescriptsjob/autotests/renamescriptjobtest.h
+++ b/src/ksieveui/managescriptsjob/autotests/renamescriptjobtest.h
@@ -30,6 +30,8 @@ public:
private Q_SLOTS:
void canNotStartByDefault();
+ void shouldBeStart_data();
+ void shouldBeStart();
};
#endif // RENAMESCRIPTJOBTEST_H
diff --git a/src/ksieveui/managescriptsjob/renamescriptjob.cpp b/src/ksieveui/managescriptsjob/renamescriptjob.cpp
index f1527aa..c22f572 100644
--- a/src/ksieveui/managescriptsjob/renamescriptjob.cpp
+++ b/src/ksieveui/managescriptsjob/renamescriptjob.cpp
@@ -21,6 +21,8 @@
#include <KLocalizedString>
+#include <QDebug>
+
using namespace KSieveUi;
class KSieveUi::RenameScriptJobPrivate
@@ -64,7 +66,7 @@ void RenameScriptJob::setNewName(const QString &newName)
bool RenameScriptJob::canStart() const
{
- return !d->mNewName.isEmpty() && !d->mOldUrl.isEmpty();
+ return !d->mNewName.trimmed().isEmpty() && d->mOldUrl.isValid();
}
void RenameScriptJob::start()