forked from Arora/arora
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added first test suite for QuickView enhancement
- Loading branch information
Daniel Graziotin
committed
Dec 6, 2010
1 parent
4154692
commit 6a3e653
Showing
9 changed files
with
154 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
historymanager |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
http://www.host-1.com/ | ||
Title: 1 | ||
Tue Aug 15 08:45:22 2006 | ||
http://www.host-2.com/ | ||
Title: 2 | ||
Tue Aug 15 08:45:25 2006 | ||
http://www.host-3.com/ | ||
Title: 3 | ||
Tue Aug 15 08:45:25 2006 | ||
http://www.host-3.com/ | ||
Title: 3 | ||
Tue Aug 15 08:45:25 2006 | ||
http://www.host-3.com/ | ||
Title: 3 | ||
Tue Aug 15 08:45:25 2006 | ||
http://www.host-3.com/ | ||
Title: 3 | ||
Tue Aug 15 08:45:25 2006 |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
TEMPLATE = app | ||
TARGET = | ||
DEPENDPATH += . | ||
INCLUDEPATH += . | ||
|
||
include(../autotests.pri) | ||
|
||
# Input | ||
SOURCES += tst_quickview.cpp | ||
HEADERS += |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,119 @@ | ||
/* | ||
* Copyright 2008 Benjamin C. Meyer <ben@meyerhome.net> | ||
* | ||
* 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 2 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, write to the Free Software | ||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, | ||
* Boston, MA 02110-1301 USA | ||
*/ | ||
|
||
#include <QtTest/QtTest> | ||
#include "qtest_arora.h" | ||
|
||
#include <historymanager.h> | ||
#include <history.h> | ||
#include <historycompleter.h> | ||
#include <modeltest.h> | ||
|
||
class tst_QuickView : public QObject | ||
{ | ||
Q_OBJECT | ||
|
||
public slots: | ||
void initTestCase(); | ||
void cleanupTestCase(); | ||
void init(); | ||
void cleanup(); | ||
|
||
private slots: | ||
void historyLength(); | ||
|
||
|
||
|
||
public: | ||
QList<HistoryEntry> m_history; | ||
}; | ||
|
||
// Subclass that exposes the protected functions. | ||
class SubHistory : public HistoryManager | ||
{ | ||
public: | ||
SubHistory() : HistoryManager() | ||
{ | ||
QWidget w; | ||
setParent(&w); | ||
if (QWebHistoryInterface::defaultInterface() == this) | ||
QWebHistoryInterface::setDefaultInterface(0); | ||
setParent(0); | ||
} | ||
|
||
~SubHistory() { | ||
setDaysToExpire(30); | ||
} | ||
|
||
void addHistoryEntry(const HistoryEntry &item) | ||
{ HistoryManager::addHistoryEntry(item); } | ||
}; | ||
|
||
// This will be called before the first test function is executed. | ||
// It is only called once. | ||
void tst_QuickView::initTestCase() | ||
{ | ||
QCoreApplication::setApplicationName("historytest"); | ||
QFile file("myhistory.txt"); | ||
if (!file.open(QFile::ReadOnly)) { | ||
qWarning() << "couldn't open file:" << file.fileName(); | ||
return; | ||
} | ||
QTextStream stream(&file); | ||
|
||
QList<HistoryEntry> list; | ||
do { | ||
QString url = stream.readLine(); | ||
QString title = stream.readLine(); | ||
QString date = stream.readLine(); | ||
QDateTime dateTime = QDateTime::fromString(date); | ||
QVERIFY(dateTime.isValid()); | ||
HistoryEntry item(url, dateTime, title); | ||
list.prepend(item); | ||
} while (!stream.atEnd()); | ||
m_history = list; | ||
} | ||
|
||
|
||
// This will be called after the last test function is executed. | ||
// It is only called once. | ||
void tst_QuickView::cleanupTestCase() | ||
{ | ||
} | ||
|
||
// This will be called before each test function is executed. | ||
void tst_QuickView::init() | ||
{ | ||
} | ||
|
||
// This will be called after every test function. | ||
void tst_QuickView::cleanup() | ||
{ | ||
} | ||
|
||
// At this point, our history contains six elements | ||
void tst_QuickView::historyLength() | ||
{ | ||
QCOMPARE(m_history.count(),6); | ||
} | ||
|
||
|
||
QTEST_MAIN(tst_QuickView) | ||
#include "tst_quickview.moc" | ||
|
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters