1
mirror of https://invent.kde.org/network/falkon.git synced 2024-11-11 01:22:10 +01:00

Autotests: Fix qmlTopSitesApiTest

NO_CHANGELOG

Signed-off-by: Juraj Oravec <jurajoravec@mailo.com>
This commit is contained in:
Juraj Oravec 2023-11-23 21:58:16 +01:00
parent d12e7cfeb0
commit 7734f6f555
Signed by: SGOrava
GPG Key ID: 13660A3F1D9F093B

View File

@ -31,6 +31,9 @@ void QmlTopSitesApiTest::cleanupTestCase()
void QmlTopSitesApiTest::testTopSites() void QmlTopSitesApiTest::testTopSites()
{ {
auto initialList = m_testHelper.evaluate(QSL("Falkon.TopSites.get()")).toVariant().toList();
auto initialListLength = initialList.length();
mApp->plugins()->speedDial()->addPage(QUrl(QSL("https://example.com")), QSL("Example Domain")); mApp->plugins()->speedDial()->addPage(QUrl(QSL("https://example.com")), QSL("Example Domain"));
auto list = m_testHelper.evaluate(QSL("Falkon.TopSites.get()")).toVariant().toList(); auto list = m_testHelper.evaluate(QSL("Falkon.TopSites.get()")).toVariant().toList();
qDebug() << "Top sites list size=" << list.length(); qDebug() << "Top sites list size=" << list.length();
@ -46,8 +49,8 @@ void QmlTopSitesApiTest::testTopSites()
qDebug() << ".." << site; qDebug() << ".." << site;
} }
} }
QCOMPARE(list.length(), 1); QCOMPARE(list.length(), initialListLength + 1);
auto* object = qvariant_cast<QObject*>(list.at(0)); auto* object = qvariant_cast<QObject*>(list.at(initialListLength));
QVERIFY(object); QVERIFY(object);
QCOMPARE(object->property("title").toString(), QSL("Example Domain")); QCOMPARE(object->property("title").toString(), QSL("Example Domain"));
QCOMPARE(object->property("url").toString(), QSL("https://example.com")); QCOMPARE(object->property("url").toString(), QSL("https://example.com"));