Falkon Develop
Cross-platform Qt-based web browser
qmltopsitesapitest.cpp
Go to the documentation of this file.
1/* ============================================================
2* Falkon - Qt web browser
3* Copyright (C) 2018 Anmol Gautam <tarptaeya@gmail.com>
4*
5* This program is free software: you can redistribute it and/or modify
6* it under the terms of the GNU General Public License as published by
7* the Free Software Foundation, either version 3 of the License, or
8* (at your option) any later version.
9*
10* This program is distributed in the hope that it will be useful,
11* but WITHOUT ANY WARRANTY; without even the implied warranty of
12* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13* GNU General Public License for more details.
14*
15* You should have received a copy of the GNU General Public License
16* along with this program. If not, see <http://www.gnu.org/licenses/>.
17* ============================================================ */
18#include "qmltopsitesapitest.h"
19#include "autotests.h"
20#include "mainapplication.h"
21#include "pluginproxy.h"
22#include "speeddial.h"
23
24void QmlTopSitesApiTest::initTestCase()
25{
26}
27
28void QmlTopSitesApiTest::cleanupTestCase()
29{
30}
31
32void QmlTopSitesApiTest::testTopSites()
33{
34 auto initialList = m_testHelper.evaluate(QSL("Falkon.TopSites.get()")).toVariant().toList();
35 auto initialListLength = initialList.length();
36
37 mApp->plugins()->speedDial()->addPage(QUrl(QSL("https://example.com")), QSL("Example Domain"));
38 auto list = m_testHelper.evaluate(QSL("Falkon.TopSites.get()")).toVariant().toList();
39 qDebug() << "Top sites list size=" << list.length();
40 for( const auto& site : list )
41 {
42 auto* object = qvariant_cast<QObject*>(site);
43 if (object)
44 {
45 qDebug() << ".." << object->property("title") << object->property("url");
46 }
47 else
48 {
49 qDebug() << ".." << site;
50 }
51 }
52 QCOMPARE(list.length(), initialListLength + 1);
53 auto* object = qvariant_cast<QObject*>(list.at(initialListLength));
54 QVERIFY(object);
55 QCOMPARE(object->property("title").toString(), QSL("Example Domain"));
56 QCOMPARE(object->property("url").toString(), QSL("https://example.com"));
57}
58
#define FALKONTEST_MAIN(Test)
Definition: autotests.h:23
QJSValue evaluate(const QString &source)
#define mApp
#define QSL(x)
Definition: qzcommon.h:40