diff --git a/src/tests/CMakeLists.txt b/src/tests/CMakeLists.txt index c08752de..22326ca4 100644 --- a/src/tests/CMakeLists.txt +++ b/src/tests/CMakeLists.txt @@ -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} diff --git a/src/tests/HistoryTest.cpp b/src/tests/HistoryTest.cpp new file mode 100644 index 00000000..4b23e01c --- /dev/null +++ b/src/tests/HistoryTest.cpp @@ -0,0 +1,100 @@ +/* + Copyright 2013 by Kurt Hindenburg + + 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" + diff --git a/src/tests/HistoryTest.h b/src/tests/HistoryTest.h new file mode 100644 index 00000000..e8590fc9 --- /dev/null +++ b/src/tests/HistoryTest.h @@ -0,0 +1,44 @@ +/* + Copyright 2013 by Kurt Hindenburg + + 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 + +namespace Konsole +{ + +class HistoryTest : public QObject +{ + Q_OBJECT + +private slots: + void testHistoryNone(); + void testHistoryFile(); + void testCompactHistory(); + void testEmulationHistory(); + +private: +}; + +} + +#endif // HISTORYTEST_H + diff --git a/src/tests/SessionTest.cpp b/src/tests/SessionTest.cpp index c0ac377d..6264362f 100644 --- a/src/tests/SessionTest.cpp +++ b/src/tests/SessionTest.cpp @@ -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" diff --git a/src/tests/SessionTest.h b/src/tests/SessionTest.h index e8f90973..d95b2198 100644 --- a/src/tests/SessionTest.h +++ b/src/tests/SessionTest.h @@ -32,7 +32,6 @@ class SessionTest : public QObject private slots: void testNoProfile(); void testEmulation(); - void testEmulationHistory(); private: };