diff --git a/autotests/qml/qmlclipboardapitest.cpp b/autotests/qml/qmlclipboardapitest.cpp index 88fb0a2e..bfb9fd6f 100644 --- a/autotests/qml/qmlclipboardapitest.cpp +++ b/autotests/qml/qmlclipboardapitest.cpp @@ -1,38 +1,38 @@ /* ============================================================ * Falkon - Qt web browser * Copyright (C) 2018 Anmol Gautam * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * 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, see . * ============================================================ */ #include "qmlclipboardapitest.h" #include "autotests.h" #include "qmltesthelper.h" #include "mainapplication.h" #include void QmlClipboardApiTest::initTestCase() { } void QmlClipboardApiTest::cleanupTestCase() { } void QmlClipboardApiTest::testClipboard() { 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) diff --git a/autotests/qml/qmlcookiesapitest.cpp b/autotests/qml/qmlcookiesapitest.cpp index 4dc70882..2e851f80 100644 --- a/autotests/qml/qmlcookiesapitest.cpp +++ b/autotests/qml/qmlcookiesapitest.cpp @@ -1,122 +1,122 @@ /* ============================================================ * Falkon - Qt web browser * Copyright (C) 2018 Anmol Gautam * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * 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, see . * ============================================================ */ #include "qmlcookiesapitest.h" #include "autotests.h" #include "qmltesthelper.h" #include "mainapplication.h" #include "cookiejar.h" #include "qml/api/cookies/qmlcookie.h" #include void QmlCookiesApiTest::initTestCase() { } void QmlCookiesApiTest::cleanupTestCase() { } void QmlCookiesApiTest::testCookieAdditionRemoval() { QSignalSpy cookieAddSpy(mApp->cookieJar(), &CookieJar::cookieAdded); m_testHelper.evaluate("Falkon.Cookies.set({" " name: 'Example'," " url: '.example.com'," " expirationDate: Date.now() + 60*1000" "})"); QTRY_COMPARE(cookieAddSpy.count(), 1); QNetworkCookie netCookie = qvariant_cast(cookieAddSpy.at(0).at(0)); - QCOMPARE(netCookie.name(), "Example"); + QCOMPARE(netCookie.name(), QByteArrayLiteral("Example")); QObject *object = m_testHelper.evaluateQObject("Falkon.Cookies"); QVERIFY(object); QSignalSpy qmlCookieSpy(object, SIGNAL(changed(QVariantMap))); QNetworkCookie anotherNetCookie; anotherNetCookie.setName(QString("Hello").toLocal8Bit()); anotherNetCookie.setDomain(".mydomain.com"); anotherNetCookie.setExpirationDate(QDateTime::currentDateTime().addSecs(60)); mApp->webProfile()->cookieStore()->setCookie(anotherNetCookie); QTRY_COMPARE(qmlCookieSpy.count(), 1); QVariantMap addedQmlCookieMap = QVariant(qmlCookieSpy.at(0).at(0)).toMap(); QObject *addedQmlCookie = qvariant_cast(addedQmlCookieMap.value("cookie")); bool removed = addedQmlCookieMap.value("removed").toBool(); - QCOMPARE(addedQmlCookie->property("name").toString(), "Hello"); + QCOMPARE(addedQmlCookie->property("name").toString(), QSL("Hello")); QCOMPARE(removed, false); mApp->webProfile()->cookieStore()->deleteCookie(netCookie); QTRY_COMPARE(qmlCookieSpy.count(), 2); QVariantMap removedQmlCookieMap = QVariant(qmlCookieSpy.at(1).at(0)).toMap(); QObject *removedQmlCookie = qvariant_cast(removedQmlCookieMap.value("cookie")); removed = removedQmlCookieMap.value("removed").toBool(); - QCOMPARE(removedQmlCookie->property("name").toString(), "Example"); + QCOMPARE(removedQmlCookie->property("name").toString(), QSL("Example")); QCOMPARE(removed, true); QSignalSpy cookieRemoveSpy(mApp->cookieJar(), &CookieJar::cookieRemoved); m_testHelper.evaluate("Falkon.Cookies.remove({" " name: 'Hello'," " url: '.mydomain.com'," "})"); QTRY_COMPARE(cookieRemoveSpy.count(), 1); netCookie = qvariant_cast(cookieRemoveSpy.at(0).at(0)); - QCOMPARE(netCookie.name(), "Hello"); + QCOMPARE(netCookie.name(), QByteArrayLiteral("Hello")); } void QmlCookiesApiTest::testCookieGet() { QDateTime current = QDateTime::currentDateTime(); QSignalSpy cookieAddSpy(mApp->cookieJar(), &CookieJar::cookieAdded); QNetworkCookie netCookie_1; netCookie_1.setName(QString("Apple").toLocal8Bit()); netCookie_1.setDomain(".apple-domain.com"); netCookie_1.setExpirationDate(current.addSecs(60)); mApp->webProfile()->cookieStore()->setCookie(netCookie_1); QNetworkCookie netCookie_2; netCookie_2.setName(QString("Mango").toLocal8Bit()); netCookie_2.setDomain(".mango-domain.com"); netCookie_2.setExpirationDate(current.addSecs(120)); mApp->webProfile()->cookieStore()->setCookie(netCookie_2); QNetworkCookie netCookie_3; netCookie_3.setName(QString("Mango").toLocal8Bit()); netCookie_3.setDomain(".yet-another-mango-domain.com"); netCookie_3.setExpirationDate(current.addSecs(180)); mApp->webProfile()->cookieStore()->setCookie(netCookie_3); QTRY_COMPARE(cookieAddSpy.count(), 3); QNetworkCookie actualMangoCookie; for (const QNetworkCookie &cookie : mApp->cookieJar()->getAllCookies()) { if (cookie.name() == QSL("Mango") && cookie.domain() == QSL(".mango-domain.com")) { actualMangoCookie = cookie; } } QObject *mangoCookie = m_testHelper.evaluateQObject("Falkon.Cookies.get({" " name: 'Mango'," " url: '.mango-domain.com'" "})"); QVERIFY(mangoCookie); - QCOMPARE(mangoCookie->property("name").toString(), "Mango"); + QCOMPARE(mangoCookie->property("name").toString(), QSL("Mango")); QCOMPARE(mangoCookie->property("expirationDate").toDateTime(), actualMangoCookie.expirationDate()); QList mangoCookies = m_testHelper.evaluate("Falkon.Cookies.getAll({name: 'Mango'})").toVariant().toList(); QCOMPARE(mangoCookies.length(), 2); } FALKONTEST_MAIN(QmlCookiesApiTest) diff --git a/autotests/qml/qmlhistoryapitest.cpp b/autotests/qml/qmlhistoryapitest.cpp index 02c5d26a..da6fe44d 100644 --- a/autotests/qml/qmlhistoryapitest.cpp +++ b/autotests/qml/qmlhistoryapitest.cpp @@ -1,89 +1,89 @@ /* ============================================================ * Falkon - Qt web browser * Copyright (C) 2018 Anmol Gautam * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * 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, see . * ============================================================ */ #include "qmlhistoryapitest.h" #include "autotests.h" #include "qmltesthelper.h" #include "mainapplication.h" #include "history.h" #include "qml/api/history/qmlhistoryitem.h" #include "qml/api/history/qmlhistory.h" Q_DECLARE_METATYPE(HistoryEntry) void QmlHistoryApiTest::initTestCase() { } void QmlHistoryApiTest::cleanupTestCase() { } void QmlHistoryApiTest::testAddition() { qRegisterMetaType(); QSignalSpy historySpy(mApp->history(), &History::historyEntryAdded); m_testHelper.evaluate("Falkon.History.addUrl({" " url: 'https://example.com'," " title: 'Example Domain'" "})"); QTRY_COMPARE(historySpy.count(), 1); HistoryEntry entry = qvariant_cast(historySpy.at(0).at(0)); - QCOMPARE(entry.title, "Example Domain"); + QCOMPARE(entry.title, QSL("Example Domain")); auto object = m_testHelper.evaluateQObject("Falkon.History"); QSignalSpy qmlHistorySpy(object, SIGNAL(visited(QmlHistoryItem*))); mApp->history()->addHistoryEntry(QUrl("https://sample.com"), "Sample Domain"); QTRY_COMPARE(qmlHistorySpy.count(), 1); mApp->history()->clearHistory(); } void QmlHistoryApiTest::testSearch() { QSignalSpy historySpy(mApp->history(), &History::historyEntryAdded); mApp->history()->addHistoryEntry(QUrl("https://example.com"), "Example Domain"); mApp->history()->addHistoryEntry(QUrl("https://another-example.com"), "Another Example Domain"); mApp->history()->addHistoryEntry(QUrl("https://sample.com"), "Sample Domain"); QTRY_COMPARE(historySpy.count(), 3); auto list = m_testHelper.evaluate("Falkon.History.search('example')").toVariant().toList(); QCOMPARE(list.length(), 2); } void QmlHistoryApiTest::testVisits() { int visits = m_testHelper.evaluate("Falkon.History.getVisits('https://sample.com')").toInt(); QCOMPARE(visits, 1); QSignalSpy historySpy(mApp->history(), &History::historyEntryEdited); mApp->history()->addHistoryEntry(QUrl("https://sample.com"), "Sample Domain"); QTRY_COMPARE(historySpy.count(), 1); visits = m_testHelper.evaluate("Falkon.History.getVisits('https://sample.com')").toInt(); QCOMPARE(visits, 2); } void QmlHistoryApiTest::testRemoval() { QSignalSpy historySpy(mApp->history(), &History::historyEntryDeleted); m_testHelper.evaluate("Falkon.History.deleteUrl('https://sample.com')"); QTRY_COMPARE(historySpy.count(), 1); auto object = m_testHelper.evaluateQObject("Falkon.History"); QSignalSpy qmlHistorySpy(object, SIGNAL(visitRemoved(QmlHistoryItem*))); mApp->history()->deleteHistoryEntry("https://example.com", "Example Domain"); QTRY_COMPARE(qmlHistorySpy.count(), 1); } FALKONTEST_MAIN(QmlHistoryApiTest) diff --git a/autotests/qml/qmltabsapitest.cpp b/autotests/qml/qmltabsapitest.cpp index 0b6657cd..a9661b92 100644 --- a/autotests/qml/qmltabsapitest.cpp +++ b/autotests/qml/qmltabsapitest.cpp @@ -1,114 +1,114 @@ /* ============================================================ * Falkon - Qt web browser * Copyright (C) 2018 Anmol Gautam * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * 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, see . * ============================================================ */ #include "qmltabsapitest.h" #include "autotests.h" #include "qmltesthelper.h" #include "mainapplication.h" #include "tabwidget.h" void QmlTabsApiTest::initTestCase() { } void QmlTabsApiTest::cleanupTestCase() { } void QmlTabsApiTest::testInitWindowCount() { QCOMPARE(mApp->windowCount(), 1); QCOMPARE(mApp->getWindow()->tabCount(), 0); } void QmlTabsApiTest::testTabsAPI() { // Tab Insertion QObject *qmlTabsObject = m_testHelper.evaluateQObject("Falkon.Tabs"); QVERIFY(qmlTabsObject); QSignalSpy qmlTabsInsertedSpy(qmlTabsObject, SIGNAL(tabInserted(QVariantMap))); m_testHelper.evaluate("Falkon.Tabs.addTab({" " url: 'https://example.com/'" "})"); QCOMPARE(qmlTabsInsertedSpy.count(), 1); QVariantMap retMap1 = QVariant(qmlTabsInsertedSpy.at(0).at(0)).toMap(); int index1 = retMap1.value(QSL("index"), -1).toInt(); int windowId1 = retMap1.value(QSL("windowId"), -1).toInt(); QCOMPARE(index1, 0); QCOMPARE(windowId1, 0); QObject *qmlTabObject1 = m_testHelper.evaluateQObject("Falkon.Tabs.get({index: 0})"); QVERIFY(qmlTabObject1); QCOMPARE(qmlTabObject1->property("index").toInt(), 0); 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({" " url: 'https://another-example.com/'," "})"); QCOMPARE(qmlTabsInsertedSpy.count(), 2); QVariantMap retMap2 = QVariant(qmlTabsInsertedSpy.at(1).at(0)).toMap(); int index2 = retMap2.value(QSL("index"), -1).toInt(); int windowId2 = retMap2.value(QSL("windowId"), -1).toInt(); QCOMPARE(index2, 1); QCOMPARE(windowId2, 0); bool pinnedTab = m_testHelper.evaluate("Falkon.Tabs.pinTab({index: 1})").toBool(); QVERIFY(pinnedTab); QObject *qmlTabObject2 = m_testHelper.evaluateQObject("Falkon.Tabs.get({index: 0})"); QVERIFY(qmlTabObject2); QCOMPARE(qmlTabObject2->property("index").toInt(), 0); 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(); QVERIFY(unpinnedTab); QObject *qmlTabObject3 = m_testHelper.evaluateQObject("Falkon.Tabs.get({index: 0})"); 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("pinned").toBool(), false); // Next-Previous-Current QCOMPARE(mApp->getWindow()->tabWidget()->currentIndex(), 0); m_testHelper.evaluate("Falkon.Tabs.nextTab()"); QCOMPARE(mApp->getWindow()->tabWidget()->currentIndex(), 1); m_testHelper.evaluate("Falkon.Tabs.nextTab()"); QCOMPARE(mApp->getWindow()->tabWidget()->currentIndex(), 0); m_testHelper.evaluate("Falkon.Tabs.previousTab()"); QCOMPARE(mApp->getWindow()->tabWidget()->currentIndex(), 1); m_testHelper.evaluate("Falkon.Tabs.previousTab()"); QCOMPARE(mApp->getWindow()->tabWidget()->currentIndex(), 0); m_testHelper.evaluate("Falkon.Tabs.setCurrentIndex({index: 1})"); QCOMPARE(mApp->getWindow()->tabWidget()->currentIndex(), 1); m_testHelper.evaluate("Falkon.Tabs.setCurrentIndex({index: 0})"); QCOMPARE(mApp->getWindow()->tabWidget()->currentIndex(), 0); // Move Tab QSignalSpy qmlTabsMovedSpy(qmlTabsObject, SIGNAL(tabMoved(QVariantMap))); m_testHelper.evaluate("Falkon.Tabs.moveTab({from: 0, to:1, windowId: 0})"); QCOMPARE(qmlTabsMovedSpy.count(), 1); // Tab Removal QCOMPARE(mApp->getWindow()->tabCount(), 2); QSignalSpy qmlTabsRemovedSpy(qmlTabsObject, SIGNAL(tabRemoved(QVariantMap))); m_testHelper.evaluate("Falkon.Tabs.closeTab({index: 0})"); QCOMPARE(qmlTabsRemovedSpy.count(), 1); QCOMPARE(mApp->getWindow()->tabCount(), 1); } FALKONTEST_MAIN(QmlTabsApiTest) diff --git a/autotests/qml/qmltopsitesapitest.cpp b/autotests/qml/qmltopsitesapitest.cpp index 8ca0c750..79d2dcc7 100644 --- a/autotests/qml/qmltopsitesapitest.cpp +++ b/autotests/qml/qmltopsitesapitest.cpp @@ -1,44 +1,44 @@ /* ============================================================ * Falkon - Qt web browser * Copyright (C) 2018 Anmol Gautam * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * 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, see . * ============================================================ */ #include "qmltopsitesapitest.h" #include "autotests.h" #include "qmltesthelper.h" #include "mainapplication.h" #include "pluginproxy.h" #include "speeddial.h" void QmlTopSitesApiTest::initTestCase() { } void QmlTopSitesApiTest::cleanupTestCase() { } void QmlTopSitesApiTest::testTopSites() { mApp->plugins()->speedDial()->addPage(QUrl("https://example.com"), "Example Domain"); auto list = m_testHelper.evaluate("Falkon.TopSites.get()").toVariant().toList(); QCOMPARE(list.length(), 1); QObject* object = qvariant_cast(list.at(0)); QVERIFY(object); - QCOMPARE(object->property("title").toString(), "Example Domain"); - QCOMPARE(object->property("url").toString(), "https://example.com"); + QCOMPARE(object->property("title").toString(), QSL("Example Domain")); + QCOMPARE(object->property("url").toString(), QSL("https://example.com")); } FALKONTEST_MAIN(QmlTopSitesApiTest)