Commit cda59521 authored by Jekyll Wu's avatar Jekyll Wu
Browse files

Add super primitive tests for class PlainTextDecoder

parent 08b9e8c4
......@@ -27,6 +27,7 @@
// Konsole
#include "Character.h"
#include "konsole_export.h"
class QTextStream;
......@@ -41,7 +42,7 @@ namespace Konsole
* Derived classes may produce either plain text with no other color or appearance information, or
* they may produce text which incorporates these additional properties.
*/
class TerminalCharacterDecoder
class KONSOLEPRIVATE_EXPORT TerminalCharacterDecoder
{
public:
virtual ~TerminalCharacterDecoder() {}
......@@ -68,7 +69,7 @@ public:
* A terminal character decoder which produces plain text, ignoring colors and other appearance-related
* properties of the original characters.
*/
class PlainTextDecoder : public TerminalCharacterDecoder
class KONSOLEPRIVATE_EXPORT PlainTextDecoder : public TerminalCharacterDecoder
{
public:
PlainTextDecoder();
......@@ -111,7 +112,7 @@ private:
/**
* A terminal character decoder which produces pretty HTML markup
*/
class HTMLDecoder : public TerminalCharacterDecoder
class KONSOLEPRIVATE_EXPORT HTMLDecoder : public TerminalCharacterDecoder
{
public:
/**
......
......@@ -15,6 +15,9 @@ target_link_libraries(ShellCommandTest ${KONSOLE_TEST_LIBS})
kde4_add_unit_test(CharacterColorTest CharacterColorTest.cpp)
target_link_libraries(CharacterColorTest ${KONSOLE_TEST_LIBS})
kde4_add_unit_test(TerminalCharacterDecoderTest TerminalCharacterDecoderTest.cpp)
target_link_libraries(TerminalCharacterDecoderTest ${KONSOLE_TEST_LIBS})
kde4_add_unit_test(ProfileTest ProfileTest.cpp)
target_link_libraries(ProfileTest ${KONSOLE_TEST_LIBS})
......
/*
Copyright 2008 by Robert Knight <robertknight@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 "TerminalCharacterDecoderTest.h"
// Qt
#include <QtCore/QStringList>
#include <QtCore/QTextStream>
// KDE
#include <qtest_kde.h>
using namespace Konsole;
void TerminalCharacterDecoderTest::init()
{
}
void TerminalCharacterDecoderTest::cleanup()
{
}
void TerminalCharacterDecoderTest::testPlainTextDecoder()
{
TerminalCharacterDecoder* decoder = new PlainTextDecoder();
Character characters[6];
characters[0] = Character('h');
characters[1] = Character('e');
characters[2] = Character('l');
characters[3] = Character('l');
characters[4] = Character('o');
characters[5] = Character(' ');
characters[5].isRealCharacter = false;
QString outputString;
QTextStream outputStream(&outputString);
decoder->begin(&outputStream);
decoder->decodeLine(characters, 6, LINE_DEFAULT);
decoder->end();
QCOMPARE(outputString, QString("hello"));
delete decoder;
}
QTEST_KDEMAIN_CORE(TerminalCharacterDecoderTest)
#include "TerminalCharacterDecoderTest.moc"
/*
Copyright 2008 by Robert Knight <robertknight@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 TERMINALCHARACTERDECODERTEST_H
#define TERMINALCHARACTERDECODERTEST_H
#include "../TerminalCharacterDecoder.h"
namespace Konsole
{
class TerminalCharacterDecoderTest : public QObject
{
Q_OBJECT
private slots:
void init();
void cleanup();
void testPlainTextDecoder();
};
}
#endif // TERMINALCHARACTERDECODERTEST_H
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment