27void QmlHistoryApiTest::initTestCase()
31void QmlHistoryApiTest::cleanupTestCase()
35void QmlHistoryApiTest::testAddition()
37 qRegisterMetaType<HistoryEntry>();
40 " url: 'https://example.com',"
41 " title: 'Example Domain'"
43 QTRY_COMPARE(historySpy.count(), 1);
44 HistoryEntry entry = qvariant_cast<HistoryEntry>(historySpy.at(0).at(0));
45 QCOMPARE(entry.
title,
QSL(
"Example Domain"));
48 QSignalSpy qmlHistorySpy(
object, SIGNAL(visited(
QmlHistoryItem*)));
49 mApp->history()->addHistoryEntry(QUrl(
QSL(
"https://sample.com")),
QSL(
"Sample Domain"));
50 QTRY_COMPARE(qmlHistorySpy.count(), 1);
51 mApp->history()->clearHistory();
54void QmlHistoryApiTest::testSearch()
57 mApp->history()->addHistoryEntry(QUrl(
QSL(
"https://example.com")),
QSL(
"Example Domain"));
58 mApp->history()->addHistoryEntry(QUrl(
QSL(
"https://another-example.com")),
QSL(
"Another Example Domain"));
59 mApp->history()->addHistoryEntry(QUrl(
QSL(
"https://sample.com")),
QSL(
"Sample Domain"));
60 QTRY_COMPARE(historySpy.count(), 3);
61 auto list = m_testHelper.
evaluate(
QSL(
"Falkon.History.search('example')")).toVariant().toList();
62 QCOMPARE(list.length(), 2);
65void QmlHistoryApiTest::testVisits()
67 int visits = m_testHelper.
evaluate(
QSL(
"Falkon.History.getVisits('https://sample.com')")).toInt();
70 mApp->history()->addHistoryEntry(QUrl(
QSL(
"https://sample.com")),
QSL(
"Sample Domain"));
71 QTRY_COMPARE(historySpy.count(), 1);
72 visits = m_testHelper.
evaluate(
QSL(
"Falkon.History.getVisits('https://sample.com')")).toInt();
76void QmlHistoryApiTest::testRemoval()
79 m_testHelper.
evaluate(
QSL(
"Falkon.History.deleteUrl('https://sample.com')"));
80 QTRY_COMPARE(historySpy.count(), 1);
83 QSignalSpy qmlHistorySpy(
object, SIGNAL(visitRemoved(
QmlHistoryItem*)));
84 mApp->history()->deleteHistoryEntry(
QSL(
"https://example.com"),
QSL(
"Example Domain"));
85 QTRY_COMPARE(qmlHistorySpy.count(), 1);
#define FALKONTEST_MAIN(Test)
void historyEntryDeleted(const HistoryEntry &entry)
void historyEntryEdited(const HistoryEntry &before, const HistoryEntry &after)
void historyEntryAdded(const HistoryEntry &entry)
The class exposing HistoryEntry to QML.
QObject * evaluateQObject(const QString &source)
QJSValue evaluate(const QString &source)
Q_DECLARE_METATYPE(FlashCookie)