Apparently when I moved the tests to autotests I didn't use 'git mv'

Remove unused files in tests/
wilder-portage
Kurt Hindenburg 11 years ago
parent ff66b231bf
commit 6d9ecac20b
  1. 72
      src/tests/CharacterWidthTest.cpp
  2. 42
      src/tests/CharacterWidthTest.h
  3. 142
      src/tests/HistoryTest.cpp
  4. 45
      src/tests/HistoryTest.h
  5. 100
      src/tests/KeyboardTranslatorTest.cpp
  6. 40
      src/tests/KeyboardTranslatorTest.h
  7. 61
      src/tests/SessionTest.cpp
  8. 42
      src/tests/SessionTest.h
  9. 166
      src/tests/TerminalInterfaceTest.cpp
  10. 49
      src/tests/TerminalInterfaceTest.h
  11. 104
      src/tests/TerminalTest.cpp
  12. 43
      src/tests/TerminalTest.h

@ -1,72 +0,0 @@
/*
Copyright 2014 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 "CharacterWidthTest.h"
// KDE
#include <qtest.h>
#include "../konsole_wcwidth.h"
#include "../konsole_export.h"
using namespace Konsole;
void CharacterWidthTest::testWidth_data()
{
QTest::addColumn<quint16>("character");
QTest::addColumn<int>("width");
/* This is a work in progress.... */
/* konsole_wcwidth uses -1 C0/C1 and DEL */
QTest::newRow("0xE007F") << quint16(0xE007F) << -1;
QTest::newRow("0x0300") << quint16(0x0300) << 0;
QTest::newRow("0x070F") << quint16(0x070F) << 0;
QTest::newRow("0x1160") << quint16(0x1160) << 0;
QTest::newRow("0x10300") << quint16(0x10300) << 0;
QTest::newRow("a") << quint16('a') << 1;
QTest::newRow("0x00AD") << quint16(0x00AD) << 1;
QTest::newRow("0x00A0") << quint16(0x00A0) << 1;
QTest::newRow("0x10FB") << quint16(0x10FB) << 1;
QTest::newRow("0xFF76") << quint16(0xFF76) << 1;
QTest::newRow("0x103A0") << quint16(0x103A0) << 1;
QTest::newRow("0x10A06") << quint16(0x10A06) << 1;
QTest::newRow("0x3000") << quint16(0x3000) << 2;
QTest::newRow("0x300a") << quint16(0x300a) << 2;
QTest::newRow("0x300b") << quint16(0x300b) << 2;
QTest::newRow("0xFF01") << quint16(0xFF01) << 2;
QTest::newRow("0xFF5F") << quint16(0xFF5F) << 2;
QTest::newRow("0xFF60") << quint16(0xFF60) << 2;
QTest::newRow("0xFFe0") << quint16(0xFFe6) << 2;
}
void CharacterWidthTest::testWidth()
{
QFETCH(quint16, character);
QTEST(konsole_wcwidth(character), "width");
}
QTEST_GUILESS_MAIN(CharacterWidthTest)

@ -1,42 +0,0 @@
/*
Copyright 2014 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 CHARACTERWIDTHTEST_H
#define CHARACTERWIDTHTEST_H
#include <QObject>
namespace Konsole
{
class CharacterWidthTest : public QObject
{
Q_OBJECT
private slots:
void testWidth_data();
void testWidth();
};
}
#endif // CHARACTERWIDTHTEST_H

@ -1,142 +0,0 @@
/*
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.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;
}
void HistoryTest::testHistoryScroll()
{
HistoryScroll* historyScroll;
// None
historyScroll = new HistoryScrollNone();
QVERIFY(!historyScroll->hasScroll());
QCOMPARE(historyScroll->getLines(), 0);
QCOMPARE(historyScroll->getLineLen(0), 0);
QCOMPARE(historyScroll->getLineLen(10), 0);
const HistoryType& historyTypeNone = historyScroll->getType();
QCOMPARE(historyTypeNone.isEnabled(), false);
QCOMPARE(historyTypeNone.isUnlimited(), false);
QCOMPARE(historyTypeNone.maximumLineCount(), 0);
// File
historyScroll = new HistoryScrollFile(QString("test.log"));
QVERIFY(historyScroll->hasScroll());
QCOMPARE(historyScroll->getLines(), 0);
QCOMPARE(historyScroll->getLineLen(0), 0);
QCOMPARE(historyScroll->getLineLen(10), 0);
const HistoryType& historyTypeFile = historyScroll->getType();
QCOMPARE(historyTypeFile.isEnabled(), true);
QCOMPARE(historyTypeFile.isUnlimited(), true);
QCOMPARE(historyTypeFile.maximumLineCount(), -1);
// Compact
historyScroll = new CompactHistoryScroll(42);
QVERIFY(historyScroll->hasScroll());
QCOMPARE(historyScroll->getLines(), 0);
QCOMPARE(historyScroll->getLineLen(0), 0);
QCOMPARE(historyScroll->getLineLen(10), 0);
const HistoryType& compactHistoryType = historyScroll->getType();
QCOMPARE(compactHistoryType.isEnabled(), true);
QCOMPARE(compactHistoryType.isUnlimited(), false);
QCOMPARE(compactHistoryType.maximumLineCount(), 42);
delete historyScroll;
}
QTEST_MAIN(HistoryTest )

@ -1,45 +0,0 @@
/*
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();
void testHistoryScroll();
private:
};
}
#endif // HISTORYTEST_H

@ -1,100 +0,0 @@
/*
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 "KeyboardTranslatorTest.h"
// KDE
#include <qtest.h>
using namespace Konsole;
void KeyboardTranslatorTest::testEntryTextWildcards_data()
{
// Shift = 1 + (1 << 0) = 2
// Alt = 1 + (1 << 2) = 3
// Control = 1 + (1 << 4) = 5
QTest::addColumn<QByteArray>("text");
QTest::addColumn<QByteArray>("result");
QTest::addColumn<bool>("wildcards");
QTest::addColumn<quint64>("modifiers"); // Qt::KeyboardModifers doesn't work here
QTest::newRow("Home no wildcards no modifiers")<< QByteArray("Home") << QByteArray("Home") << false << static_cast<quint64>(Qt::NoModifier);
QTest::newRow("Home no wildcards Shift modifiers")<< QByteArray("Home") << QByteArray("Home") << false << static_cast<quint64>(Qt::ShiftModifier);
QTest::newRow("Home no wildcards Alt modifiers")<< QByteArray("Home") << QByteArray("Home") << false << static_cast<quint64>(Qt::AltModifier);
QTest::newRow("Home no wildcards Control modifiers")<< QByteArray("Home") << QByteArray("Home") << false << static_cast<quint64>(Qt::ControlModifier);
QTest::newRow("Home yes wildcards no modifiers")<< QByteArray("Home") << QByteArray("Home") << true << static_cast<quint64>(Qt::NoModifier);
QTest::newRow("Home yes wildcards Shift modifiers")<< QByteArray("Home") << QByteArray("Home") << true << static_cast<quint64>(Qt::ShiftModifier);
QTest::newRow("Home yes wildcards Alt modifiers")<< QByteArray("Home") << QByteArray("Home") << true << static_cast<quint64>(Qt::AltModifier);
QTest::newRow("Home yes wildcards Control modifiers")<< QByteArray("Home") << QByteArray("Home") << true << static_cast<quint64>(Qt::ControlModifier);
// text, results: no mod, shift, alt, control
QList<QByteArray> entry;
entry << QByteArray("E*") << QByteArray("E1") << QByteArray("E2") << QByteArray("E3") << QByteArray("E5");
QTest::newRow("E* yes wildcards no modifiers")<< entry[0] << entry[1] << true << static_cast<quint64>(Qt::NoModifier);
QTest::newRow("E* yes wildcards Shift modifiers")<< entry[0] << entry[2] << true << static_cast<quint64>(Qt::ShiftModifier);
QTest::newRow("E* yes wildcards Alt modifiers")<< entry[0] << entry[3] << true << static_cast<quint64>(Qt::AltModifier);
QTest::newRow("E* yes wildcards Control modifiers")<< entry[0] << entry[4] << true << static_cast<quint64>(Qt::ControlModifier);
// combinations
entry.clear();;
entry << QByteArray("E*") << QByteArray("E4") << QByteArray("E6") << QByteArray("E8") << QByteArray("E7");
QTest::newRow("E* yes wildcards Shift+Alt modifiers")<< entry[0] << entry[1] << true << static_cast<quint64>(Qt::ShiftModifier | Qt::AltModifier);
QTest::newRow("E* yes wildcards Shift+Control modifiers")<< entry[0] << entry[2] << true << static_cast<quint64>(Qt::ShiftModifier | Qt::ControlModifier);
QTest::newRow("E* yes wildcards Shift+Alt+Control modifiers")<< entry[0] << entry[3] << true << static_cast<quint64>(Qt::ShiftModifier | Qt::AltModifier | Qt::ControlModifier);
QTest::newRow("E* yes wildcards Alt+Control modifiers")<< entry[0] << entry[4] << true << static_cast<quint64>(Qt::AltModifier | Qt::ControlModifier);
// text, results: no mod, shift, alt, control
entry.clear();;
entry << QByteArray("\E[24;*~") << QByteArray("\E[24;1~") << QByteArray("\E[24;2~") << QByteArray("\E[24;3~") << QByteArray("\E[24;5~");
QTest::newRow("\E[24;*~ yes wildcards no modifiers")<< entry[0] << entry[1] << true << static_cast<quint64>(Qt::NoModifier);
QTest::newRow("\E[24;*~ yes wildcards Shift modifiers")<< entry[0] << entry[2] << true << static_cast<quint64>(Qt::ShiftModifier);
QTest::newRow("\E[24;*~ yes wildcards Alt modifiers")<< entry[0] << entry[3] << true << static_cast<quint64>(Qt::AltModifier);
QTest::newRow("\E[24;*~ yes wildcards Control modifiers")<< entry[0] << entry[4] << true << static_cast<quint64>(Qt::ControlModifier);
// combinations
entry.clear();;
entry << QByteArray("\E[24;*~") << QByteArray("\E[24;4~") << QByteArray("\E[24;6~") << QByteArray("\E[24;8~") << QByteArray("\E[24;7~");
QTest::newRow("\E[24;*~ yes wildcards Shift+Alt modifiers")<< entry[0] << entry[1] << true << static_cast<quint64>(Qt::ShiftModifier | Qt::AltModifier);
QTest::newRow("\E[24;*~ yes wildcards Shift+Control modifiers")<< entry[0] << entry[2] << true << static_cast<quint64>(Qt::ShiftModifier | Qt::ControlModifier);
QTest::newRow("\E[24;*~ yes wildcards Shift+Alt+Control modifiers")<< entry[0] << entry[3] << true << static_cast<quint64>(Qt::ShiftModifier | Qt::AltModifier | Qt::ControlModifier);
QTest::newRow("\E[24;*~ yes wildcards Alt+Control modifiers")<< entry[0] << entry[4] << true << static_cast<quint64>(Qt::AltModifier | Qt::ControlModifier);
}
void KeyboardTranslatorTest::testEntryTextWildcards()
{
QFETCH(QByteArray, text);
QFETCH(QByteArray, result);
QFETCH(bool, wildcards);
QFETCH(quint64, modifiers);
KeyboardTranslator::Entry entry;
Qt::KeyboardModifiers keyboardModifiers = static_cast<Qt::KeyboardModifiers>(modifiers);
entry.setText(text);
QCOMPARE(entry.text(wildcards, keyboardModifiers), result);
}
QTEST_GUILESS_MAIN(KeyboardTranslatorTest)

@ -1,40 +0,0 @@
/*
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 KEYBOARDTRANSLATORTEST_H
#define KEYBOARDTRANSLATORTEST_H
#include "../KeyboardTranslator.h"
namespace Konsole
{
class KeyboardTranslatorTest : public QObject
{
Q_OBJECT
private slots:
void testEntryTextWildcards();
void testEntryTextWildcards_data();
};
}
#endif // KEYBOARDTRANSLATORTEST_H

@ -1,61 +0,0 @@
/*
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 "SessionTest.h"
#include "qtest.h"
// Konsole
#include "../Session.h"
#include "../Emulation.h"
#include "../History.h"
using namespace Konsole;
void SessionTest::testNoProfile()
{
Session* session = new Session();
// No profile loaded, nothing to run
QCOMPARE(session->isRunning(), false);
QCOMPARE(session->sessionId(), 1);
QCOMPARE(session->isRemote(), false);
QCOMPARE(session->program(), QString(""));
QCOMPARE(session->arguments(), QStringList());
QCOMPARE(session->tabTitleFormat(Session::LocalTabTitle), QString(""));
QCOMPARE(session->tabTitleFormat(Session::RemoteTabTitle), QString(""));
delete session;
}
void SessionTest::testEmulation()
{
Session* session = new Session();
Emulation* emulation = session->emulation();
QCOMPARE(emulation->lineCount(), 40);
delete session;
}
QTEST_MAIN(SessionTest )

@ -1,42 +0,0 @@
/*
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 SESSIONTEST_H
#define SESSIONTEST_H
#include <kde_terminal_interface.h>
namespace Konsole
{
class SessionTest : public QObject
{
Q_OBJECT
private slots:
void testNoProfile();
void testEmulation();
private:
};
}
#endif // SESSIONTEST_H

@ -1,166 +0,0 @@
/*
Copyright 2014 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 "TerminalInterfaceTest.h"
// Qt
#include <QSignalSpy>
// KDE
#include <KService>
#include <qtest.h>
#include "../Part.h"
using namespace Konsole;
/* In KDE 4.x there are 2 versions: TerminalInterface and TerminalInterfaceV2
The code below uses both as well the KonsolePart API
*/
void TerminalInterfaceTest::testTerminalInterface()
{
QString currentDirectory;
QString retVal;
bool result;
// create a Konsole part and attempt to connect to it
_terminalPart = createPart();
if (!_terminalPart)
QSKIP("konsolepart not found.", SkipSingle);
TerminalInterfaceV2* terminal = qobject_cast<TerminalInterfaceV2*>(_terminalPart);
QVERIFY(terminal);
terminal->showShellInDir(QDir::home().path());
int foregroundProcessId = terminal->foregroundProcessId();
QCOMPARE(foregroundProcessId, -1);
QString foregroundProcessName = terminal->foregroundProcessName();
QCOMPARE(foregroundProcessName, QString(""));
// terminalProcessId() is the user's default shell
// FIXME: find a way to verify this
// int terminalProcessId = terminal->terminalProcessId();
// Sleep is used to allow enough time for these to work
// In Qt5 we can use QSignalSpy::wait()
// Let's try using QSignalSpy
// http://techbase.kde.org/Development/Tutorials/Unittests
// QSignalSpy is really a QList of QLists, so we take the first
// list, which corresponds to the arguments for the first signal
// we caught.
QSignalSpy stateSpy(_terminalPart, SIGNAL(currentDirectoryChanged(QString)));
QVERIFY(stateSpy.isValid());
// Now we check to make sure we don't have any signals already
QCOMPARE(stateSpy.count(), 0);
// Let's trigger some signals
// #1A - Test signal currentDirectoryChanged(QString)
currentDirectory = QString("/tmp");
terminal->sendInput("cd " + currentDirectory + '\n');
sleep(2000);
QCOMPARE(stateSpy.count(), 1);
// Correct result?
QList<QVariant> firstSignalArgs = stateSpy.takeFirst();
QString firstSignalState = firstSignalArgs.at(0).toString();
QCOMPARE(firstSignalState, currentDirectory);
// Test KonsolePart API currentWorkingDirectory()
result = QMetaObject::invokeMethod(_terminalPart,
"currentWorkingDirectory",
Qt::DirectConnection,
Q_RETURN_ARG(QString, retVal));
QVERIFY(result);
QCOMPARE(retVal, currentDirectory);
// #1B - Test signal currentDirectoryChanged(QString)
// Invalid directory - no signal should be emitted
terminal->sendInput("cd /usrADADFASDF\n");
sleep(2000);
QCOMPARE(stateSpy.count(), 0);
// Should be no change since the above cd didn't work
result = QMetaObject::invokeMethod(_terminalPart,
"currentWorkingDirectory",
Qt::DirectConnection,
Q_RETURN_ARG(QString, retVal));
QVERIFY(result);
QCOMPARE(retVal, currentDirectory);
// Test starting a new program
QString command = "top";
terminal->sendInput(command + '\n');
sleep(2000);
// FIXME: find a good way to validate process id of 'top'
foregroundProcessId = terminal->foregroundProcessId();
QVERIFY(foregroundProcessId != -1);
foregroundProcessName = terminal->foregroundProcessName();
QCOMPARE(foregroundProcessName, command);
terminal->sendInput("q");
sleep(2000);
// Nothing running in foreground
foregroundProcessId = terminal->foregroundProcessId();
QCOMPARE(foregroundProcessId, -1);
foregroundProcessName = terminal->foregroundProcessName();
QCOMPARE(foregroundProcessName, QString(""));
// Test destroyed()
QSignalSpy destroyedSpy(_terminalPart, SIGNAL(destroyed()));
QVERIFY(destroyedSpy.isValid());
// Now we check to make sure we don't have any signals already
QCOMPARE(destroyedSpy.count(), 0);
delete _terminalPart;
QCOMPARE(destroyedSpy.count(), 1);
}
void TerminalInterfaceTest::sleep(int msecs)
{
QEventLoop loop;
QTimer::singleShot(msecs, &loop, SLOT(quit()));
loop.exec(QEventLoop::ExcludeUserInputEvents | QEventLoop::ExcludeSocketNotifiers);
}
KParts::Part* TerminalInterfaceTest::createPart()
{
KService::Ptr service = KService::serviceByDesktopName("konsolepart");
if (!service) // not found
return 0;
KPluginFactory* factory = KPluginLoader(service->library()).factory();
if (!factory) // not found
return 0;
KParts::Part* terminalPart = factory->create<KParts::Part>(this);
return terminalPart;
}
QTEST_MAIN(TerminalInterfaceTest)

@ -1,49 +0,0 @@
/*
Copyright 2014 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 TERMINALINTERFACETEST_H
#define TERMINALINTERFACETEST_H
#include <kde_terminal_interface_v2.h>
#include <KParts/Part>
namespace Konsole
{
class TerminalInterfaceTest : public QObject
{
Q_OBJECT
public:
private slots:
void testTerminalInterface();
private:
KParts::Part* createPart();
void sleep(int msecs = 10000);
KParts::Part* _terminalPart;
};
}
#endif // TERMINALINTERFACETEST_H

@ -1,104 +0,0 @@
/*
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 "TerminalTest.h"
#include "qtest.h"
// Konsole
#include "../TerminalDisplay.h"
#include "../CharacterColor.h"
#include "../ColorScheme.h"
using namespace Konsole;
void TerminalTest::testScrollBarPositions()
{
TerminalDisplay* display = new TerminalDisplay(0);
// ScrollBar Positions
display->setScrollBarPosition(Enum::ScrollBarLeft);
QCOMPARE(display->scrollBarPosition(), Enum::ScrollBarLeft);
display->setScrollBarPosition(Enum::ScrollBarRight);
QCOMPARE(display->scrollBarPosition(), Enum::ScrollBarRight);
display->setScrollBarPosition(Enum::ScrollBarHidden);
QCOMPARE(display->scrollBarPosition(), Enum::ScrollBarHidden);
delete display;
}
void TerminalTest::testColorTable()
{
// These are from ColorScheme.cpp but they can be anything to test
const ColorEntry defaultTable[TABLE_COLORS] = {
ColorEntry(QColor(0x00, 0x00, 0x00)), ColorEntry(QColor(0xFF, 0xFF, 0xFF)),
ColorEntry(QColor(0x00, 0x00, 0x00)), ColorEntry(QColor(0xB2, 0x18, 0x18)),
ColorEntry(QColor(0x18, 0xB2, 0x18)), ColorEntry(QColor(0xB2, 0x68, 0x18)),
ColorEntry(QColor(0x18, 0x18, 0xB2)), ColorEntry(QColor(0xB2, 0x18, 0xB2)),
ColorEntry(QColor(0x18, 0xB2, 0xB2)), ColorEntry(QColor(0xB2, 0xB2, 0xB2)),
ColorEntry(QColor(0x00, 0x00, 0x00)), ColorEntry(QColor(0xFF, 0xFF, 0xFF)),
ColorEntry(QColor(0x68, 0x68, 0x68)), ColorEntry(QColor(0xFF, 0x54, 0x54)),
ColorEntry(QColor(0x54, 0xFF, 0x54)), ColorEntry(QColor(0xFF, 0xFF, 0x54)),
ColorEntry(QColor(0x54, 0x54, 0xFF)), ColorEntry(QColor(0xFF, 0x54, 0xFF)),
ColorEntry(QColor(0x54, 0xFF, 0xFF)), ColorEntry(QColor(0x00, 0xFF, 0xFF))
};
TerminalDisplay* display = new TerminalDisplay(0);
display->setColorTable(defaultTable);
const ColorEntry* colorTable = display->colorTable();
for (int i = 0; i < TABLE_COLORS; i++)
QCOMPARE(colorTable[i], defaultTable[i]);
ColorEntry colorEntry = ColorEntry(QColor(0x00, 0x00, 0x00));
QVERIFY(colorTable[1] != colorEntry);
// UseCurrentFormat is the default FontWeight
colorEntry = ColorEntry(QColor(0x00, 0x00, 0x00), ColorEntry::Bold);
QVERIFY(colorTable[0] != colorEntry);
colorEntry = ColorEntry(QColor(0x00, 0x00, 0x00), ColorEntry::Normal);
QVERIFY(colorTable[0] != colorEntry);
colorEntry = ColorEntry(QColor(0x00, 0x00, 0x00), ColorEntry::UseCurrentFormat);
QVERIFY(colorTable[0] == colorEntry);
delete display;
}
void TerminalTest::testSize()
{
TerminalDisplay* display = new TerminalDisplay(0);
QCOMPARE(display->columns(), 1);
QCOMPARE(display->lines(), 1);
// TODO: setSize doesn't change size...
//display->setSize(80, 25);
delete display;
}
QTEST_MAIN(TerminalTest )

@ -1,43 +0,0 @@
/*
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 TERMINALTEST_H
#define TERMINALTEST_H
#include <kde_terminal_interface.h>
namespace Konsole
{
class TerminalTest : public QObject
{
Q_OBJECT
private slots:
void testScrollBarPositions();
void testColorTable();
void testSize();
private:
};
}
#endif // TERMINALTEST_H
Loading…
Cancel
Save