mirror of
https://github.com/KDE/konsole.git
synced 2026-01-28 00:49:44 -05:00
No new methods have been added to the TerminalInterface class in kdelibs to avoid breaking binary compatibility so the slot must be invoked via QMetaObject::invokeMethod() for now. See tests/PartTest.cpp CCMAIL:jr@jriddell.org Squashed commit of the following: commit 0759e22dc26b7c1c28e0d8a9b0d245d909629237 Author: Robert Knight <robertknight@gmail.com> Date: Fri Apr 18 20:43:20 2008 +0100 Adapt test to kdelibs changes. Add a label to explain what the user should expect to see. commit b67be2fd20178625f01f8f135751849082eddf04 Author: Robert Knight <robertknight@gmail.com> Date: Fri Apr 18 00:47:32 2008 +0100 Export Pty, Session, KeyboardTranslator classes for use in tests. commit 6dd28bf628fe1036c59f3383aba27ba98e23152c Author: Robert Knight <robertknight@gmail.com> Date: Fri Apr 18 00:46:27 2008 +0100 Build test commit 0a9e1c9dc158f73e6bf9f7ef2fe7d4ea936a8066 Author: Robert Knight <robertknight@gmail.com> Date: Fri Apr 18 00:46:10 2008 +0100 Remove temp file commit 8e69bd56fef267ac0c31c989a4959453a8e3359e Author: Robert Knight <robertknight@gmail.com> Date: Fri Apr 18 00:45:28 2008 +0100 Add a test for using existing file descriptors with the Konsole part. commit f1f5b8a7684e88db64769324496a5fa67dd4920b Author: Robert Knight <robertknight@gmail.com> Date: Tue Apr 15 18:36:14 2008 +0100 Add support in the KPart to use an existing terminal rather than opening a new one. svn path=/trunk/KDE/kdebase/apps/konsole/; revision=798661
100 lines
2.8 KiB
C++
100 lines
2.8 KiB
C++
/*
|
|
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 "PartTest.h"
|
|
|
|
// Qt
|
|
#include <QtGui/QWidget>
|
|
#include <QtGui/QLabel>
|
|
#include <QtGui/QVBoxLayout>
|
|
#include <QtCore/QCoreApplication>
|
|
|
|
// System
|
|
#include <termios.h>
|
|
#include <sys/types.h>
|
|
|
|
// KDE
|
|
#include <KPluginLoader>
|
|
#include <KPluginFactory>
|
|
#include <KParts/Part>
|
|
#include <KPtyProcess>
|
|
#include <KPtyDevice>
|
|
#include <KDialog>
|
|
#include <qtest_kde.h>
|
|
|
|
// Konsole
|
|
#include "../Pty.h"
|
|
#include "../Session.h"
|
|
#include "../KeyboardTranslator.h"
|
|
|
|
using namespace Konsole;
|
|
|
|
void PartTest::testFd()
|
|
{
|
|
// start a pty process
|
|
KPtyProcess ptyProcess;
|
|
ptyProcess.setProgram("/bin/ping",QStringList() << "localhost");
|
|
ptyProcess.setPtyChannels(KPtyProcess::AllChannels);
|
|
ptyProcess.start();
|
|
QVERIFY(ptyProcess.waitForStarted());
|
|
|
|
int fd = ptyProcess.pty()->masterFd();
|
|
|
|
// create a Konsole part and attempt to connect to it
|
|
KParts::Part* terminalPart = createPart();
|
|
bool result = QMetaObject::invokeMethod(terminalPart,"openTeletype",
|
|
Qt::DirectConnection,Q_ARG(int,fd));
|
|
QVERIFY(result);
|
|
|
|
|
|
// suspend the KPtyDevice so that the embedded terminal gets a chance to
|
|
// read from the pty. Otherwise the KPtyDevice will simply read everything
|
|
// as soon as it becomes available and the terminal will not display any output
|
|
ptyProcess.pty()->setSuspended(true);
|
|
|
|
KDialog* dialog = new KDialog();
|
|
dialog->setButtons(0);
|
|
QVBoxLayout* layout = new QVBoxLayout(dialog->mainWidget());
|
|
layout->addWidget(new QLabel("Output of 'ping localhost' should appear in a terminal below for 5 seconds"));
|
|
layout->addWidget(terminalPart->widget());
|
|
QTimer::singleShot(5000,dialog,SLOT(close()));
|
|
dialog->exec();
|
|
|
|
delete terminalPart;
|
|
delete dialog;
|
|
ptyProcess.kill();
|
|
ptyProcess.waitForFinished(1000);
|
|
}
|
|
KParts::Part* PartTest::createPart()
|
|
{
|
|
KPluginLoader loader("libkonsolepart");
|
|
KPluginFactory* factory = loader.factory();
|
|
Q_ASSERT(factory);
|
|
|
|
KParts::Part* terminalPart = factory->create<KParts::Part>(this);
|
|
|
|
return terminalPart;
|
|
}
|
|
|
|
QTEST_KDEMAIN( PartTest , GUI )
|
|
|
|
#include "PartTest.moc"
|
|
|