1
mirror of https://invent.kde.org/network/falkon.git synced 2024-09-21 09:42:10 +02:00

Autotests Qml - fix compilation with Qt 5.9

Summary: BUG: 411197

Test Plan: Compile with Qt 5.9, e.g. on Ubuntu 18.04

Reviewers: #falkon, drosca

Reviewed By: #falkon, drosca

Subscribers: drosca, falkon

Tags: #falkon

Differential Revision: https://phabricator.kde.org/D27102
This commit is contained in:
Juraj Oravec 2020-02-02 16:59:59 +01:00
parent 4b7a38680b
commit 9eaffd1208
5 changed files with 12 additions and 12 deletions

View File

@ -32,7 +32,7 @@ void QmlClipboardApiTest::cleanupTestCase()
void QmlClipboardApiTest::testClipboard() void QmlClipboardApiTest::testClipboard()
{ {
m_testHelper.evaluate("Falkon.Clipboard.copy('this text is copied')"); m_testHelper.evaluate("Falkon.Clipboard.copy('this text is copied')");
QCOMPARE(mApp->clipboard()->text(), "this text is copied"); QCOMPARE(mApp->clipboard()->text(), QSL("this text is copied"));
} }
FALKONTEST_MAIN(QmlClipboardApiTest) FALKONTEST_MAIN(QmlClipboardApiTest)

View File

@ -41,7 +41,7 @@ void QmlCookiesApiTest::testCookieAdditionRemoval()
"})"); "})");
QTRY_COMPARE(cookieAddSpy.count(), 1); QTRY_COMPARE(cookieAddSpy.count(), 1);
QNetworkCookie netCookie = qvariant_cast<QNetworkCookie>(cookieAddSpy.at(0).at(0)); QNetworkCookie netCookie = qvariant_cast<QNetworkCookie>(cookieAddSpy.at(0).at(0));
QCOMPARE(netCookie.name(), "Example"); QCOMPARE(netCookie.name(), QByteArrayLiteral("Example"));
QObject *object = m_testHelper.evaluateQObject("Falkon.Cookies"); QObject *object = m_testHelper.evaluateQObject("Falkon.Cookies");
QVERIFY(object); QVERIFY(object);
QSignalSpy qmlCookieSpy(object, SIGNAL(changed(QVariantMap))); QSignalSpy qmlCookieSpy(object, SIGNAL(changed(QVariantMap)));
@ -54,7 +54,7 @@ void QmlCookiesApiTest::testCookieAdditionRemoval()
QVariantMap addedQmlCookieMap = QVariant(qmlCookieSpy.at(0).at(0)).toMap(); QVariantMap addedQmlCookieMap = QVariant(qmlCookieSpy.at(0).at(0)).toMap();
QObject *addedQmlCookie = qvariant_cast<QObject*>(addedQmlCookieMap.value("cookie")); QObject *addedQmlCookie = qvariant_cast<QObject*>(addedQmlCookieMap.value("cookie"));
bool removed = addedQmlCookieMap.value("removed").toBool(); bool removed = addedQmlCookieMap.value("removed").toBool();
QCOMPARE(addedQmlCookie->property("name").toString(), "Hello"); QCOMPARE(addedQmlCookie->property("name").toString(), QSL("Hello"));
QCOMPARE(removed, false); QCOMPARE(removed, false);
mApp->webProfile()->cookieStore()->deleteCookie(netCookie); mApp->webProfile()->cookieStore()->deleteCookie(netCookie);
@ -62,7 +62,7 @@ void QmlCookiesApiTest::testCookieAdditionRemoval()
QVariantMap removedQmlCookieMap = QVariant(qmlCookieSpy.at(1).at(0)).toMap(); QVariantMap removedQmlCookieMap = QVariant(qmlCookieSpy.at(1).at(0)).toMap();
QObject *removedQmlCookie = qvariant_cast<QObject*>(removedQmlCookieMap.value("cookie")); QObject *removedQmlCookie = qvariant_cast<QObject*>(removedQmlCookieMap.value("cookie"));
removed = removedQmlCookieMap.value("removed").toBool(); removed = removedQmlCookieMap.value("removed").toBool();
QCOMPARE(removedQmlCookie->property("name").toString(), "Example"); QCOMPARE(removedQmlCookie->property("name").toString(), QSL("Example"));
QCOMPARE(removed, true); QCOMPARE(removed, true);
QSignalSpy cookieRemoveSpy(mApp->cookieJar(), &CookieJar::cookieRemoved); QSignalSpy cookieRemoveSpy(mApp->cookieJar(), &CookieJar::cookieRemoved);
@ -72,7 +72,7 @@ void QmlCookiesApiTest::testCookieAdditionRemoval()
"})"); "})");
QTRY_COMPARE(cookieRemoveSpy.count(), 1); QTRY_COMPARE(cookieRemoveSpy.count(), 1);
netCookie = qvariant_cast<QNetworkCookie>(cookieRemoveSpy.at(0).at(0)); netCookie = qvariant_cast<QNetworkCookie>(cookieRemoveSpy.at(0).at(0));
QCOMPARE(netCookie.name(), "Hello"); QCOMPARE(netCookie.name(), QByteArrayLiteral("Hello"));
} }
void QmlCookiesApiTest::testCookieGet() void QmlCookiesApiTest::testCookieGet()
@ -112,7 +112,7 @@ void QmlCookiesApiTest::testCookieGet()
" url: '.mango-domain.com'" " url: '.mango-domain.com'"
"})"); "})");
QVERIFY(mangoCookie); QVERIFY(mangoCookie);
QCOMPARE(mangoCookie->property("name").toString(), "Mango"); QCOMPARE(mangoCookie->property("name").toString(), QSL("Mango"));
QCOMPARE(mangoCookie->property("expirationDate").toDateTime(), actualMangoCookie.expirationDate()); QCOMPARE(mangoCookie->property("expirationDate").toDateTime(), actualMangoCookie.expirationDate());
QList<QVariant> mangoCookies = m_testHelper.evaluate("Falkon.Cookies.getAll({name: 'Mango'})").toVariant().toList(); QList<QVariant> mangoCookies = m_testHelper.evaluate("Falkon.Cookies.getAll({name: 'Mango'})").toVariant().toList();

View File

@ -43,7 +43,7 @@ void QmlHistoryApiTest::testAddition()
"})"); "})");
QTRY_COMPARE(historySpy.count(), 1); QTRY_COMPARE(historySpy.count(), 1);
HistoryEntry entry = qvariant_cast<HistoryEntry>(historySpy.at(0).at(0)); HistoryEntry entry = qvariant_cast<HistoryEntry>(historySpy.at(0).at(0));
QCOMPARE(entry.title, "Example Domain"); QCOMPARE(entry.title, QSL("Example Domain"));
auto object = m_testHelper.evaluateQObject("Falkon.History"); auto object = m_testHelper.evaluateQObject("Falkon.History");
QSignalSpy qmlHistorySpy(object, SIGNAL(visited(QmlHistoryItem*))); QSignalSpy qmlHistorySpy(object, SIGNAL(visited(QmlHistoryItem*)));

View File

@ -55,7 +55,7 @@ void QmlTabsApiTest::testTabsAPI()
QVERIFY(qmlTabObject1); QVERIFY(qmlTabObject1);
QCOMPARE(qmlTabObject1->property("index").toInt(), 0); QCOMPARE(qmlTabObject1->property("index").toInt(), 0);
QCOMPARE(qmlTabObject1->property("pinned").toBool(), false); QCOMPARE(qmlTabObject1->property("pinned").toBool(), false);
QTRY_COMPARE(qmlTabObject1->property("url").toString(), "https://example.com/"); QTRY_COMPARE(qmlTabObject1->property("url").toString(), QSL("https://example.com/"));
m_testHelper.evaluate("Falkon.Tabs.addTab({" m_testHelper.evaluate("Falkon.Tabs.addTab({"
" url: 'https://another-example.com/'," " url: 'https://another-example.com/',"
@ -73,13 +73,13 @@ void QmlTabsApiTest::testTabsAPI()
QVERIFY(qmlTabObject2); QVERIFY(qmlTabObject2);
QCOMPARE(qmlTabObject2->property("index").toInt(), 0); QCOMPARE(qmlTabObject2->property("index").toInt(), 0);
QCOMPARE(qmlTabObject2->property("pinned").toBool(), true); QCOMPARE(qmlTabObject2->property("pinned").toBool(), true);
QTRY_COMPARE(qmlTabObject2->property("url").toString(), "https://another-example.com/"); QTRY_COMPARE(qmlTabObject2->property("url").toString(), QSL("https://another-example.com/"));
bool unpinnedTab = m_testHelper.evaluate("Falkon.Tabs.unpinTab({index: 0})").toBool(); bool unpinnedTab = m_testHelper.evaluate("Falkon.Tabs.unpinTab({index: 0})").toBool();
QVERIFY(unpinnedTab); QVERIFY(unpinnedTab);
QObject *qmlTabObject3 = m_testHelper.evaluateQObject("Falkon.Tabs.get({index: 0})"); QObject *qmlTabObject3 = m_testHelper.evaluateQObject("Falkon.Tabs.get({index: 0})");
QVERIFY(qmlTabObject3); QVERIFY(qmlTabObject3);
QCOMPARE(qmlTabObject3->property("url").toString(), "https://another-example.com/"); QCOMPARE(qmlTabObject3->property("url").toString(), QSL("https://another-example.com/"));
QCOMPARE(qmlTabObject3->property("index").toInt(), 0); QCOMPARE(qmlTabObject3->property("index").toInt(), 0);
QCOMPARE(qmlTabObject3->property("pinned").toBool(), false); QCOMPARE(qmlTabObject3->property("pinned").toBool(), false);

View File

@ -37,8 +37,8 @@ void QmlTopSitesApiTest::testTopSites()
QCOMPARE(list.length(), 1); QCOMPARE(list.length(), 1);
QObject* object = qvariant_cast<QObject*>(list.at(0)); QObject* object = qvariant_cast<QObject*>(list.at(0));
QVERIFY(object); QVERIFY(object);
QCOMPARE(object->property("title").toString(), "Example Domain"); QCOMPARE(object->property("title").toString(), QSL("Example Domain"));
QCOMPARE(object->property("url").toString(), "https://example.com"); QCOMPARE(object->property("url").toString(), QSL("https://example.com"));
} }
FALKONTEST_MAIN(QmlTopSitesApiTest) FALKONTEST_MAIN(QmlTopSitesApiTest)