summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMontel Laurent <[email protected]>2016-04-05 13:14:16 +0200
committerMontel Laurent <[email protected]>2016-04-05 13:14:16 +0200
commite84e72ca36492cdc61c0084e050c22490344b4d9 (patch)
tree24384ecfb76d05a2ddfb77d6d142c5799c50b60b
parent796de2ba2da0f0c60d56c8ed79aafde6dd1bda73 (diff)
Add autotests
-rw-r--r--CMakeLists.txt2
-rw-r--r--messageviewer/src/CMakeLists.txt1
-rw-r--r--messageviewer/src/webengine/autotests/CMakeLists.txt7
-rw-r--r--messageviewer/src/webengine/autotests/webhittestresulttest.cpp124
-rw-r--r--messageviewer/src/webengine/autotests/webhittestresulttest.h38
5 files changed, 171 insertions, 1 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index ad437c0..168ddaa 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -18,7 +18,7 @@ include(KDEFrameworkCompilerSettings NO_POLICY_SCOPE)
include(ECMQtDeclareLoggingCategory)
include(ECMAddTests)
-set(MESSAGELIB_LIB_VERSION "5.2.54")
+set(MESSAGELIB_LIB_VERSION "5.2.55")
set(KF5_VERSION "5.19.0")
set(KDEPIMLIBS_LIB_VERSION "5.2.40")
diff --git a/messageviewer/src/CMakeLists.txt b/messageviewer/src/CMakeLists.txt
index 9018b9f..d10c44e 100644
--- a/messageviewer/src/CMakeLists.txt
+++ b/messageviewer/src/CMakeLists.txt
@@ -40,6 +40,7 @@ if(BUILD_TESTING)
add_subdirectory(htmlwriter/autotests/)
if (QTWEBENGINE_SUPPORT_OPTION)
add_subdirectory(webengine/tests)
+ add_subdirectory(webengine/autotests)
add_subdirectory(webengine/webengineaccesskey/autotests)
endif()
diff --git a/messageviewer/src/webengine/autotests/CMakeLists.txt b/messageviewer/src/webengine/autotests/CMakeLists.txt
new file mode 100644
index 0000000..2675ee9
--- /dev/null
+++ b/messageviewer/src/webengine/autotests/CMakeLists.txt
@@ -0,0 +1,7 @@
+ecm_add_test(webhittestresulttest.cpp ../webhittestresult.cpp
+ TEST_NAME webhittestresulttest
+ NAME_PREFIX "messageviewer-webengine-"
+ LINK_LIBRARIES Qt5::Test KF5::MessageViewer
+)
+
+
diff --git a/messageviewer/src/webengine/autotests/webhittestresulttest.cpp b/messageviewer/src/webengine/autotests/webhittestresulttest.cpp
new file mode 100644
index 0000000..343b615
--- /dev/null
+++ b/messageviewer/src/webengine/autotests/webhittestresulttest.cpp
@@ -0,0 +1,124 @@
+/*
+ Copyright (c) 2016 Montel Laurent <[email protected]>
+
+ This program is free software; you can redistribute it and/or modify it
+ under the terms of the GNU General Public License, version 2, as
+ published by the Free Software Foundation.
+
+ This program is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License along
+ with this program; if not, write to the Free Software Foundation, Inc.,
+ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+*/
+
+
+#include "webhittestresulttest.h"
+#include "../webhittestresult.h"
+#include <QTest>
+
+WebHitTestResultTest::WebHitTestResultTest(QObject *parent)
+ : QObject(parent)
+{
+
+}
+
+WebHitTestResultTest::~WebHitTestResultTest()
+{
+
+}
+
+void WebHitTestResultTest::shouldHaveDefaultValues()
+{
+ MessageViewer::WebHitTestResult result;
+ QVERIFY(result.alternateText().isEmpty());
+ QVERIFY(result.boundingRect().isNull());
+ QVERIFY(!result.imageUrl().isValid());
+ QVERIFY(!result.isContentEditable());
+ QVERIFY(!result.isContentSelected());
+ QVERIFY(result.isNull());
+ QVERIFY(result.linkTitle().isEmpty());
+ QVERIFY(!result.linkUrl().isValid());
+ QVERIFY(!result.mediaUrl().isValid());
+ QVERIFY(!result.mediaPaused());
+ QVERIFY(!result.mediaMuted());
+ QVERIFY(result.pos().isNull());
+ QVERIFY(result.tagName().isEmpty());
+ QVERIFY(!result.pageUrl().isValid());
+}
+
+void WebHitTestResultTest::shouldAssignPosAndUrl()
+{
+ QPoint pos(5,5);
+ QUrl url(QStringLiteral("http://www.kde.org"));
+ MessageViewer::WebHitTestResult result(pos, url, QVariant());
+ QVERIFY(result.alternateText().isEmpty());
+ QVERIFY(result.boundingRect().isNull());
+ QVERIFY(!result.imageUrl().isValid());
+ QVERIFY(!result.isContentEditable());
+ QVERIFY(!result.isContentSelected());
+ QVERIFY(result.isNull());
+ QVERIFY(result.linkTitle().isEmpty());
+ QVERIFY(!result.mediaUrl().isValid());
+ QVERIFY(!result.mediaPaused());
+ QVERIFY(!result.mediaMuted());
+ QVERIFY(result.tagName().isEmpty());
+ QVERIFY(!result.linkUrl().isValid());
+
+ QCOMPARE(result.pageUrl(), url);
+ QCOMPARE(result.pos(), pos);
+}
+
+void WebHitTestResultTest::shouldAssignFromQVariant()
+{
+ QPoint pos(5,5);
+ QUrl pageUrl(QStringLiteral("http://www.kde.org"));
+
+ QVariantMap map;
+ QString alternateText = QStringLiteral("FOO");
+ map.insert(QStringLiteral("alternateText"), alternateText);
+ bool contentEditable = true;
+ map.insert(QStringLiteral("contentEditable"), contentEditable);
+ bool contentSelected = true;
+ map.insert(QStringLiteral("contentSelected"), contentSelected);
+ QString linkTitle = QStringLiteral("GGGG");
+ map.insert(QStringLiteral("linkTitle"), linkTitle);
+ QUrl imageUrl(QStringLiteral("https://www.foo.net"));
+ map.insert(QStringLiteral("imageUrl"), imageUrl);
+ QUrl linkUrl(QStringLiteral("https://www.linux.org"));
+ map.insert(QStringLiteral("linkUrl"), linkUrl);
+ QUrl mediaUrl(QStringLiteral("https://www.media.org"));
+ map.insert(QStringLiteral("mediaUrl"), mediaUrl);
+ bool mediaPaused = true;
+ map.insert(QStringLiteral("mediaPaused"), mediaPaused);
+ bool mediaMuted = true;
+ map.insert(QStringLiteral("mediaMuted"), mediaMuted);
+ QString tagName = QStringLiteral("HHHHHH");
+ map.insert(QStringLiteral("tagName"), tagName);
+ QRect boundingRect(5,7,9,11);
+ QVariantList lstRect;
+ lstRect << boundingRect.left() << boundingRect.top() << boundingRect.width() << boundingRect.height();
+ map.insert(QStringLiteral("boundingRect"), lstRect);
+
+ MessageViewer::WebHitTestResult result(pos, pageUrl, map);
+
+ QCOMPARE(result.alternateText(), alternateText);
+ QCOMPARE(result.boundingRect(), boundingRect);
+ QCOMPARE(result.imageUrl(), imageUrl);
+ QCOMPARE(result.isContentEditable(), contentEditable);
+ QCOMPARE(result.isContentSelected(), contentSelected);
+ QCOMPARE(result.isNull(), false);
+ QCOMPARE(result.linkTitle(), linkTitle);
+ QCOMPARE(result.linkUrl(), linkUrl);
+ QCOMPARE(result.mediaUrl(), mediaUrl);
+ QCOMPARE(result.mediaPaused(), mediaPaused);
+ QCOMPARE(result.mediaMuted(), mediaMuted);
+ QCOMPARE(result.pos(), pos);
+ QCOMPARE(result.tagName(), tagName);
+ QCOMPARE(result.pageUrl(), pageUrl);
+}
+
+QTEST_MAIN(WebHitTestResultTest)
diff --git a/messageviewer/src/webengine/autotests/webhittestresulttest.h b/messageviewer/src/webengine/autotests/webhittestresulttest.h
new file mode 100644
index 0000000..70f4aa3
--- /dev/null
+++ b/messageviewer/src/webengine/autotests/webhittestresulttest.h
@@ -0,0 +1,38 @@
+/*
+ Copyright (c) 2016 Montel Laurent <[email protected]>
+
+ This program is free software; you can redistribute it and/or modify it
+ under the terms of the GNU General Public License, version 2, as
+ published by the Free Software Foundation.
+
+ This program is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License along
+ with this program; if not, write to the Free Software Foundation, Inc.,
+ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+*/
+
+
+#ifndef WEBHITTESTRESULTTEST_H
+#define WEBHITTESTRESULTTEST_H
+
+#include <QObject>
+
+class WebHitTestResultTest : public QObject
+{
+ Q_OBJECT
+public:
+ explicit WebHitTestResultTest(QObject *parent = Q_NULLPTR);
+ ~WebHitTestResultTest();
+private Q_SLOTS:
+ void shouldHaveDefaultValues();
+ void shouldAssignPosAndUrl();
+ void shouldAssignFromQVariant();
+
+
+};
+
+#endif // WEBHITTESTRESULTTEST_H