From 5101fa2595c234ee17426be84d3db2c8d38e7d1a Mon Sep 17 00:00:00 2001 From: Benjamin C Meyer Date: Sun, 9 Mar 2014 14:42:07 -0400 Subject: [PATCH 15/23] Add unit tests for functionality that wasn't unit tested. --- .../historymanager/tst_historymanager.cpp | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git autotests/historymanager/tst_historymanager.cpp autotests/historymanager/tst_historymanager.cpp index 2dc5461..c1173f9 100644 --- autotests/historymanager/tst_historymanager.cpp +++ autotests/historymanager/tst_historymanager.cpp @@ -25,6 +25,8 @@ #include #include +#include + class tst_HistoryManager : public QObject { Q_OBJECT @@ -40,6 +42,8 @@ private slots: void history(); void addHistoryEntry_data(); void addHistoryEntry(); + void addHistoryEntry_private(); + void addHistoryEntry_url(); void updateHistoryEntry_data(); void updateHistoryEntry(); void daysToExpire_data(); @@ -205,6 +209,26 @@ void tst_HistoryManager::addHistoryEntry() QCOMPARE(history.history(), expected); } +void tst_HistoryManager::addHistoryEntry_private() +{ + SubHistory history; + history.setHistory(HistoryList()); + QWebSettings *globalSettings = QWebSettings::globalSettings(); + globalSettings->setAttribute(QWebSettings::PrivateBrowsingEnabled, true); + history.prependHistoryEntry(HistoryEntry()); + globalSettings->setAttribute(QWebSettings::PrivateBrowsingEnabled, false); + QVERIFY(history.history().isEmpty()); +} + +void tst_HistoryManager::addHistoryEntry_url() +{ + SubHistory history; + QString urlWithPassword("http://username:password@example.com"); + history.addHistoryEntry(urlWithPassword); + QString cleanedUrl = "http://username@example.com"; + QCOMPARE(history.history()[0].url, cleanedUrl); +} + void tst_HistoryManager::updateHistoryEntry_data() { QTest::addColumn("list"); -- 2.44.0