Commit 55cb3b99 authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

Fix copy webhitresult

parent e84e72ca
......@@ -121,4 +121,55 @@ void WebHitTestResultTest::shouldAssignFromQVariant()
QCOMPARE(result.pageUrl(), pageUrl);
}
void WebHitTestResultTest::shouldCopyWebHitTestResult()
{
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);
const MessageViewer::WebHitTestResult result1(pos, pageUrl, map);
MessageViewer::WebHitTestResult result = result1;
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)
......@@ -31,6 +31,7 @@ private Q_SLOTS:
void shouldHaveDefaultValues();
void shouldAssignPosAndUrl();
void shouldAssignFromQVariant();
void shouldCopyWebHitTestResult();
};
......
......@@ -113,6 +113,14 @@ WebHitTestResult::WebHitTestResult(const QPoint &pos, const QUrl &pageUrl, const
{
}
WebHitTestResult::WebHitTestResult(const WebHitTestResult &other)
: d(other.d)
{
d = new WebHitTestResultPrivate;
(*this) = other;
}
WebHitTestResult::~WebHitTestResult()
{
delete d;
......@@ -121,7 +129,7 @@ WebHitTestResult::~WebHitTestResult()
WebHitTestResult &WebHitTestResult::operator=(const WebHitTestResult &other)
{
if (this != &other) {
d = other.d;
*d = *(other.d);
}
return *this;
}
......
......@@ -49,6 +49,7 @@ class MESSAGEVIEWER_EXPORT WebHitTestResult
public:
WebHitTestResult();
WebHitTestResult(const QPoint &pos, const QUrl &pageUrl, const QVariant &result);
WebHitTestResult(const WebHitTestResult &other);
~WebHitTestResult();
QString alternateText() const;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment