Skip to content

Commit

Permalink
Added first test suite for QuickView enhancement
Browse files Browse the repository at this point in the history
  • Loading branch information
Daniel Graziotin committed Dec 6, 2010
1 parent 4154692 commit 6a3e653
Show file tree
Hide file tree
Showing 9 changed files with 154 additions and 2 deletions.
1 change: 1 addition & 0 deletions autotests/autotests.pro
Expand Up @@ -11,6 +11,7 @@ SUBDIRS = \
opensearchmanager \
opensearchreader \
opensearchwriter \
quickview \
searchlineedit \
tabbar \
tabwidget \
Expand Down
1 change: 1 addition & 0 deletions autotests/quickview/.gitignore
@@ -0,0 +1 @@
historymanager
18 changes: 18 additions & 0 deletions autotests/quickview/myhistory.txt
@@ -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 added autotests/quickview/quickview
Binary file not shown.
10 changes: 10 additions & 0 deletions autotests/quickview/quickview.pro
@@ -0,0 +1,10 @@
TEMPLATE = app
TARGET =
DEPENDPATH += .
INCLUDEPATH += .

include(../autotests.pri)

# Input
SOURCES += tst_quickview.cpp
HEADERS +=
119 changes: 119 additions & 0 deletions autotests/quickview/tst_quickview.cpp
@@ -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 modified report.docx
Binary file not shown.
3 changes: 3 additions & 0 deletions src/quickview.cpp
Expand Up @@ -30,6 +30,9 @@
#include <qtimer.h>
#include <qwebsettings.h>

/**QList<HistoryEntry> QuickView::getLastSixHistoryEntries(){
return 0;
}*/

/*
void FileAccessReply::listDirectory()
Expand Down
4 changes: 2 additions & 2 deletions src/quickview.h
Expand Up @@ -20,15 +20,15 @@
#ifndef QUICKVIEW_H
#define QUICKVIEW_H

#include "schemeaccesshandler.h"

#include <qbuffer.h>
#include <qnetworkreply.h>
#include "history/historymanager.h"

class QuickView
{
public:
QuickView(QObject *parent = 0);
QList<HistoryEntry> getLastSixHistoryEntries();
};

#endif // QUICKVIEW_H

0 comments on commit 6a3e653

Please sign in to comment.