File indexing completed on 2024-04-28 04:55:54
0001 /* ============================================================ 0002 * Falkon - Qt web browser 0003 * Copyright (C) 2018 Anmol Gautam <tarptaeya@gmail.com> 0004 * 0005 * This program is free software: you can redistribute it and/or modify 0006 * it under the terms of the GNU General Public License as published by 0007 * the Free Software Foundation, either version 3 of the License, or 0008 * (at your option) any later version. 0009 * 0010 * This program is distributed in the hope that it will be useful, 0011 * but WITHOUT ANY WARRANTY; without even the implied warranty of 0012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 0013 * GNU General Public License for more details. 0014 * 0015 * You should have received a copy of the GNU General Public License 0016 * along with this program. If not, see <http://www.gnu.org/licenses/>. 0017 * ============================================================ */ 0018 #include "qmltopsitesapitest.h" 0019 #include "autotests.h" 0020 #include "mainapplication.h" 0021 #include "pluginproxy.h" 0022 #include "speeddial.h" 0023 0024 void QmlTopSitesApiTest::initTestCase() 0025 { 0026 } 0027 0028 void QmlTopSitesApiTest::cleanupTestCase() 0029 { 0030 } 0031 0032 void QmlTopSitesApiTest::testTopSites() 0033 { 0034 auto initialList = m_testHelper.evaluate(QSL("Falkon.TopSites.get()")).toVariant().toList(); 0035 auto initialListLength = initialList.length(); 0036 0037 mApp->plugins()->speedDial()->addPage(QUrl(QSL("https://example.com")), QSL("Example Domain")); 0038 auto list = m_testHelper.evaluate(QSL("Falkon.TopSites.get()")).toVariant().toList(); 0039 qDebug() << "Top sites list size=" << list.length(); 0040 for( const auto& site : list ) 0041 { 0042 auto* object = qvariant_cast<QObject*>(site); 0043 if (object) 0044 { 0045 qDebug() << ".." << object->property("title") << object->property("url"); 0046 } 0047 else 0048 { 0049 qDebug() << ".." << site; 0050 } 0051 } 0052 QCOMPARE(list.length(), initialListLength + 1); 0053 auto* object = qvariant_cast<QObject*>(list.at(initialListLength)); 0054 QVERIFY(object); 0055 QCOMPARE(object->property("title").toString(), QSL("Example Domain")); 0056 QCOMPARE(object->property("url").toString(), QSL("https://example.com")); 0057 } 0058 0059 FALKONTEST_MAIN(QmlTopSitesApiTest)