summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMontel Laurent <montel@kde.org>2016-10-27 11:48:53 (GMT)
committerMontel Laurent <montel@kde.org>2016-10-27 11:48:53 (GMT)
commit3ef824512ecb89551ec73ee27c59b5ac8e28b0c2 (patch)
tree9115afc7e07522181e2e38ac1278b95b77678753
parent4659635afd71784dee7b83839b4edcada004ca71 (diff)
Improve tests apps
-rw-r--r--messageviewer/src/checkphishingurl/checkphishingurljob.h3
-rw-r--r--messageviewer/src/checkphishingurl/tests/checkphishingurlgui.cpp26
-rw-r--r--messageviewer/src/checkphishingurl/tests/checkphishingurlgui.h2
3 files changed, 30 insertions, 1 deletions
diff --git a/messageviewer/src/checkphishingurl/checkphishingurljob.h b/messageviewer/src/checkphishingurl/checkphishingurljob.h
index fed56e5..16feab2 100644
--- a/messageviewer/src/checkphishingurl/checkphishingurljob.h
+++ b/messageviewer/src/checkphishingurl/checkphishingurljob.h
@@ -22,9 +22,10 @@
#include <QObject>
#include <QUrl>
+#include "messageviewer_export.h"
namespace MessageViewer {
-class CheckPhishingUrlJob : public QObject
+class MESSAGEVIEWER_EXPORT CheckPhishingUrlJob : public QObject
{
Q_OBJECT
public:
diff --git a/messageviewer/src/checkphishingurl/tests/checkphishingurlgui.cpp b/messageviewer/src/checkphishingurl/tests/checkphishingurlgui.cpp
index fbfd64b..a093678 100644
--- a/messageviewer/src/checkphishingurl/tests/checkphishingurlgui.cpp
+++ b/messageviewer/src/checkphishingurl/tests/checkphishingurlgui.cpp
@@ -55,7 +55,33 @@ CheckPhishingUrlGui::~CheckPhishingUrlGui()
void CheckPhishingUrlGui::slotCheckUrl()
{
+ const QString urlStr = mCheckUrlLineEdit->text().trimmed();
+ if (urlStr.isEmpty()) {
+ return;
+ }
+ mResult->clear();
+ MessageViewer::CheckPhishingUrlJob *job = new MessageViewer::CheckPhishingUrlJob(this);
+ connect(job, &MessageViewer::CheckPhishingUrlJob::result, this, &CheckPhishingUrlGui::slotGetResult);
+ job->setUrl(QUrl(urlStr));
+ job->start();
+}
+
+void CheckPhishingUrlGui::slotGetResult(MessageViewer::CheckPhishingUrlJob::UrlStatus result)
+{
+ QString resultStr;
+ switch(result) {
+ case MessageViewer::CheckPhishingUrlJob::Ok:
+ resultStr = QStringLiteral("Url ok");
+ break;
+ case MessageViewer::CheckPhishingUrlJob::MalWare:
+ resultStr = QStringLiteral("Url MalWare");
+ break;
+ case MessageViewer::CheckPhishingUrlJob::Unknown:
+ resultStr = QStringLiteral("Url Unknow state");
+ break;
+ }
+ mResult->setText(resultStr);
}
int main(int argc, char **argv)
diff --git a/messageviewer/src/checkphishingurl/tests/checkphishingurlgui.h b/messageviewer/src/checkphishingurl/tests/checkphishingurlgui.h
index 9236886..f9c3191 100644
--- a/messageviewer/src/checkphishingurl/tests/checkphishingurlgui.h
+++ b/messageviewer/src/checkphishingurl/tests/checkphishingurlgui.h
@@ -22,6 +22,7 @@
#define CHECKPHISHINGURLGUI_H
#include <QWidget>
+#include "../checkphishingurljob.h"
class QLineEdit;
class QTextEdit;
class CheckPhishingUrlGui : public QWidget
@@ -32,6 +33,7 @@ public:
~CheckPhishingUrlGui();
private Q_SLOTS:
void slotCheckUrl();
+ void slotGetResult(MessageViewer::CheckPhishingUrlJob::UrlStatus result);
private:
QLineEdit *mCheckUrlLineEdit;
QTextEdit *mResult;