Add HistoryTest for testing of the History Classes

wilder-portage
Kurt Hindenburg 13 years ago
parent 0b9477279a
commit 6d5c95ce7c
  1. 3
      src/tests/CMakeLists.txt
  2. 100
      src/tests/HistoryTest.cpp
  3. 44
      src/tests/HistoryTest.h
  4. 13
      src/tests/SessionTest.cpp
  5. 1
      src/tests/SessionTest.h

@ -21,6 +21,9 @@ if (NOT ${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
target_link_libraries(DBusTest ${KONSOLE_TEST_LIBS})
endif()
kde4_add_unit_test(HistoryTest HistoryTest.cpp)
target_link_libraries(HistoryTest ${KONSOLE_TEST_LIBS})
if (NOT ${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
kde4_add_unit_test(PartTest PartTest.cpp)
target_link_libraries(PartTest ${KDE4_KPARTS_LIBS}

@ -0,0 +1,100 @@
/*
Copyright 2013 by Kurt Hindenburg <kurt.hindenburg@gmail.com>
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.
*/
// Own
#include "HistoryTest.h"
#include "qtest_kde.h"
// Konsole
#include "../Session.h"
#include "../Emulation.h"
#include "../History.h"
using namespace Konsole;
void HistoryTest::testHistoryNone()
{
HistoryType* history;
history = new HistoryTypeNone();
QCOMPARE(history->isEnabled(), false);
QCOMPARE(history->isUnlimited(), false);
QCOMPARE(history->maximumLineCount(), 0);
delete history;
}
void HistoryTest::testHistoryFile()
{
HistoryType* history;
history = new HistoryTypeFile();
QCOMPARE(history->isEnabled(), true);
QCOMPARE(history->isUnlimited(), true);
QCOMPARE(history->maximumLineCount(), -1);
delete history;
}
void HistoryTest::testCompactHistory()
{
HistoryType* history;
history = new CompactHistoryType(42);
QCOMPARE(history->isEnabled(), true);
QCOMPARE(history->isUnlimited(), false);
QCOMPARE(history->maximumLineCount(), 42);
delete history;
}
void HistoryTest::testEmulationHistory()
{
Session* session = new Session();
Emulation* emulation = session->emulation();
const HistoryType& historyTypeDefault = emulation->history();
QCOMPARE(historyTypeDefault.isEnabled(), false);
QCOMPARE(historyTypeDefault.isUnlimited(), false);
QCOMPARE(historyTypeDefault.maximumLineCount(), 0);
emulation->setHistory(HistoryTypeNone());
const HistoryType& historyTypeNone = emulation->history();
QCOMPARE(historyTypeNone.isEnabled(), false);
QCOMPARE(historyTypeNone.isUnlimited(), false);
QCOMPARE(historyTypeNone.maximumLineCount(), 0);
emulation->setHistory(HistoryTypeFile());
const HistoryType& historyTypeFile = emulation->history();
QCOMPARE(historyTypeFile.isEnabled(), true);
QCOMPARE(historyTypeFile.isUnlimited(), true);
QCOMPARE(historyTypeFile.maximumLineCount(), -1);
emulation->setHistory(CompactHistoryType(42));
const HistoryType& compactHistoryType = emulation->history();
QCOMPARE(compactHistoryType.isEnabled(), true);
QCOMPARE(compactHistoryType.isUnlimited(), false);
QCOMPARE(compactHistoryType.maximumLineCount(), 42);
delete session;
}
QTEST_KDEMAIN(HistoryTest , GUI)
#include "HistoryTest.moc"

@ -0,0 +1,44 @@
/*
Copyright 2013 by Kurt Hindenburg <kurt.hindenburg@gmail.com>
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.
*/
#ifndef HISTORYTEST_H
#define HISTORYTEST_H
#include <kde_terminal_interface.h>
namespace Konsole
{
class HistoryTest : public QObject
{
Q_OBJECT
private slots:
void testHistoryNone();
void testHistoryFile();
void testCompactHistory();
void testEmulationHistory();
private:
};
}
#endif // HISTORYTEST_H

@ -56,19 +56,6 @@ void SessionTest::testEmulation()
delete session;
}
void SessionTest::testEmulationHistory()
{
Session* session = new Session();
Emulation* emulation = session->emulation();
const HistoryType& historyType = emulation->history();
QCOMPARE(historyType.isEnabled(), false);
QCOMPARE(historyType.isUnlimited(), false);
delete session;
}
QTEST_KDEMAIN(SessionTest , GUI)
#include "SessionTest.moc"

@ -32,7 +32,6 @@ class SessionTest : public QObject
private slots:
void testNoProfile();
void testEmulation();
void testEmulationHistory();
private:
};

Loading…
Cancel
Save