Apply astyle-kdelibs

wilder-portage
Kurt Hindenburg 14 years ago
parent c953cbd04b
commit 7c6538712d
  1. 4
      src/tests/DBusTest.cpp
  2. 205
      src/tests/PartTest.cpp
  3. 22
      src/tests/PartTest.h
  4. 66
      src/tests/ProfileTest.cpp
  5. 2
      src/tests/ProfileTest.h
  6. 2
      src/tests/SessionManagerTest.cpp
  7. 2
      src/tests/SessionManagerTest.h

@ -54,7 +54,7 @@ void DBusTest::initTestCase()
// Wait for above Konsole to finish starting
#ifdef HAVE_USLEEP
usleep(5*1000);
usleep(5 * 1000);
#else
sleep(5);
#endif
@ -169,7 +169,7 @@ void DBusTest::testSessions()
// Compare result with name due to aliases issue
// Better way to do this?
QCOMPARE((QTextCodec::codecForName(arrayReply.value()))->name(),
(QTextCodec::codecForName(availableCodecs[i]))->name());
(QTextCodec::codecForName(availableCodecs[i]))->name());
}
//****************** Test is/set flowControlEnabled

@ -52,125 +52,124 @@ 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);
// 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);
}
void PartTest::testShortcutOverride()
{
// FIXME: This test asks the user to press shortcut key sequences manually because
// the result is different than when sending the key press via QTest::keyClick()
//
// When the key presses are sent manually, Konsole::TerminalDisplay::event() is called
// and the overrideShortcut() signal is emitted by the part.
// When the key presses are sent automatically, the shortcut is triggered but
// Konsole::TerminalDisplay::event() is not called and the overrideShortcut() signal is
// not emitted by the part.
// Create a main window with a menu and a test
// action with a shortcut set to Ctrl+S, which is also used by the terminal
KMainWindow* mainWindow = new KMainWindow();
QMenu* fileMenu = mainWindow->menuBar()->addMenu("File");
QAction* testAction = fileMenu->addAction("Test");
testAction->setShortcut(QKeySequence(Qt::CTRL+Qt::Key_S));
connect(testAction,SIGNAL(triggered()),this,SLOT(shortcutTriggered()));
// Create terminal part and embed in into the main window
KParts::Part* terminalPart = createPart();
QVERIFY(terminalPart);
mainWindow->setCentralWidget(terminalPart->widget());
TerminalInterface* terminal = qobject_cast<TerminalInterface*>(terminalPart);
QVERIFY(terminal);
terminal->sendInput("Press Ctrl+S twice.\n");
mainWindow->show();
// Test shortcut with override disabled, so the shortcut will be triggered
_shortcutTriggered = false;
_override = false;
_overrideCalled = false;
QVERIFY( connect(terminalPart,SIGNAL(overrideShortcut(QKeyEvent*,bool&)),
this,SLOT(overrideShortcut(QKeyEvent*,bool&))) );
//QTest::keyClick(terminalPart->widget(),Qt::Key_S,Qt::ControlModifier);
_shortcutEventLoop = new QEventLoop();
_shortcutEventLoop->exec();
QVERIFY(_overrideCalled);
QVERIFY(_shortcutTriggered);
QVERIFY(!_override);
// Test shortcut with override enabled, so the shortcut will not be triggered
_override = true;
_overrideCalled = false;
_shortcutTriggered = false;
//QTest::keyClick(terminalPart->widget(),Qt::Key_S,Qt::ControlModifier);
_shortcutEventLoop->exec();
QVERIFY(_overrideCalled);
QVERIFY(!_shortcutTriggered);
QVERIFY(_override);
delete _shortcutEventLoop;
delete terminalPart;
delete mainWindow;
// FIXME: This test asks the user to press shortcut key sequences manually because
// the result is different than when sending the key press via QTest::keyClick()
//
// When the key presses are sent manually, Konsole::TerminalDisplay::event() is called
// and the overrideShortcut() signal is emitted by the part.
// When the key presses are sent automatically, the shortcut is triggered but
// Konsole::TerminalDisplay::event() is not called and the overrideShortcut() signal is
// not emitted by the part.
// Create a main window with a menu and a test
// action with a shortcut set to Ctrl+S, which is also used by the terminal
KMainWindow* mainWindow = new KMainWindow();
QMenu* fileMenu = mainWindow->menuBar()->addMenu("File");
QAction* testAction = fileMenu->addAction("Test");
testAction->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_S));
connect(testAction, SIGNAL(triggered()), this, SLOT(shortcutTriggered()));
// Create terminal part and embed in into the main window
KParts::Part* terminalPart = createPart();
QVERIFY(terminalPart);
mainWindow->setCentralWidget(terminalPart->widget());
TerminalInterface* terminal = qobject_cast<TerminalInterface*>(terminalPart);
QVERIFY(terminal);
terminal->sendInput("Press Ctrl+S twice.\n");
mainWindow->show();
// Test shortcut with override disabled, so the shortcut will be triggered
_shortcutTriggered = false;
_override = false;
_overrideCalled = false;
QVERIFY(connect(terminalPart, SIGNAL(overrideShortcut(QKeyEvent*, bool&)),
this, SLOT(overrideShortcut(QKeyEvent*, bool&))));
//QTest::keyClick(terminalPart->widget(),Qt::Key_S,Qt::ControlModifier);
_shortcutEventLoop = new QEventLoop();
_shortcutEventLoop->exec();
QVERIFY(_overrideCalled);
QVERIFY(_shortcutTriggered);
QVERIFY(!_override);
// Test shortcut with override enabled, so the shortcut will not be triggered
_override = true;
_overrideCalled = false;
_shortcutTriggered = false;
//QTest::keyClick(terminalPart->widget(),Qt::Key_S,Qt::ControlModifier);
_shortcutEventLoop->exec();
QVERIFY(_overrideCalled);
QVERIFY(!_shortcutTriggered);
QVERIFY(_override);
delete _shortcutEventLoop;
delete terminalPart;
delete mainWindow;
}
void PartTest::overrideShortcut(QKeyEvent* event,bool& override)
void PartTest::overrideShortcut(QKeyEvent* event, bool& override)
{
QVERIFY(override == true);
if (event->modifiers() == Qt::ControlModifier && event->key() == Qt::Key_S)
{
_overrideCalled = true;
override = _override;
_shortcutEventLoop->exit();
}
QVERIFY(override == true);
if (event->modifiers() == Qt::ControlModifier && event->key() == Qt::Key_S) {
_overrideCalled = true;
override = _override;
_shortcutEventLoop->exit();
}
}
void PartTest::shortcutTriggered()
{
_shortcutTriggered = true;
_shortcutTriggered = true;
}
KParts::Part* PartTest::createPart()
{
KPluginLoader loader("libkonsolepart");
KPluginFactory* factory = loader.factory();
Q_ASSERT(factory);
KPluginLoader loader("libkonsolepart");
KPluginFactory* factory = loader.factory();
Q_ASSERT(factory);
KParts::Part* terminalPart = factory->create<KParts::Part>(this);
KParts::Part* terminalPart = factory->create<KParts::Part>(this);
return terminalPart;
return terminalPart;
}
QTEST_KDEMAIN( PartTest , GUI )
QTEST_KDEMAIN(PartTest , GUI)
#include "PartTest.moc"

@ -33,25 +33,25 @@ namespace Konsole
class PartTest : public QObject
{
Q_OBJECT
Q_OBJECT
private slots:
void testShortcutOverride();
void testFd();
void testShortcutOverride();
void testFd();
// marked as protected so they are not treated as test cases
protected slots:
void overrideShortcut(QKeyEvent* event, bool& override);
void shortcutTriggered();
void overrideShortcut(QKeyEvent* event, bool& override);
void shortcutTriggered();
private:
KParts::Part* createPart();
KParts::Part* createPart();
// variables for testShortcutOverride()
bool _shortcutTriggered;
bool _overrideCalled;
bool _override;
QEventLoop* _shortcutEventLoop;
// variables for testShortcutOverride()
bool _shortcutTriggered;
bool _overrideCalled;
bool _override;
QEventLoop* _shortcutEventLoop;
};
}

@ -35,12 +35,12 @@ void ProfileTest::testProfile()
parent->setProperty(Profile::Name, "Parent");
parent->setProperty(Profile::Path, "FakePath");
parent->setProperty(Profile::AntiAliasFonts,false);
parent->setProperty(Profile::StartInCurrentSessionDir,false);
parent->setProperty(Profile::AntiAliasFonts, false);
parent->setProperty(Profile::StartInCurrentSessionDir, false);
// create a child profile
Profile* child = new Profile(Profile::Ptr(parent));
child->setProperty(Profile::StartInCurrentSessionDir,true);
child->setProperty(Profile::StartInCurrentSessionDir, true);
// check which properties are set
QVERIFY(parent->isPropertySet(Profile::Name));
@ -55,11 +55,11 @@ void ProfileTest::testProfile()
QVERIFY(!child->isPropertySet(Profile::AntiAliasFonts));
QVERIFY(!child->isPropertySet(Profile::ColorScheme));
// read non-inheritable properties
QCOMPARE(parent->property<QString>(Profile::Name),QString("Parent"));
QCOMPARE(child->property<QVariant>(Profile::Name),QVariant());
QCOMPARE(parent->property<QString>(Profile::Path),QString("FakePath"));
QCOMPARE(child->property<QVariant>(Profile::Path),QVariant());
// read non-inheritable properties
QCOMPARE(parent->property<QString>(Profile::Name), QString("Parent"));
QCOMPARE(child->property<QVariant>(Profile::Name), QVariant());
QCOMPARE(parent->property<QString>(Profile::Path), QString("FakePath"));
QCOMPARE(child->property<QVariant>(Profile::Path), QVariant());
// read inheritable properties
QVERIFY(parent->property<bool>(Profile::AntiAliasFonts) == false);
@ -74,27 +74,27 @@ void ProfileTest::testClone()
{
// create source profile and parent
Profile::Ptr parent(new Profile);
parent->setProperty(Profile::Command,"ps");
parent->setProperty(Profile::ColorScheme,"BlackOnWhite");
parent->setProperty(Profile::Command, "ps");
parent->setProperty(Profile::ColorScheme, "BlackOnWhite");
Profile::Ptr source(new Profile(parent));
source->setProperty(Profile::AntiAliasFonts,false);
source->setProperty(Profile::HistorySize,4567);
source->setProperty(Profile::AntiAliasFonts, false);
source->setProperty(Profile::HistorySize, 4567);
source->setProperty(Profile::Name,"SourceProfile");
source->setProperty(Profile::Path,"SourcePath");
source->setProperty(Profile::Name, "SourceProfile");
source->setProperty(Profile::Path, "SourcePath");
// create target to clone source and parent
Profile::Ptr targetParent(new Profile);
// same value as source parent
targetParent->setProperty(Profile::Command,"ps");
targetParent->setProperty(Profile::Command, "ps");
// different value from source parent
targetParent->setProperty(Profile::ColorScheme,"BlackOnGrey");
targetParent->setProperty(Profile::ColorScheme, "BlackOnGrey");
Profile::Ptr target(new Profile(parent));
// clone source profile, setting only properties that differ
// between the source and target
target->clone(source,true);
target->clone(source, true);
// check that properties from source have been cloned into target
QCOMPARE(source->property<bool>(Profile::AntiAliasFonts),
@ -120,45 +120,43 @@ void ProfileTest::testProfileGroup()
{
// create three new profiles
Profile::Ptr profile[3];
for (int i=0;i<3;i++)
{
for (int i = 0; i < 3; i++) {
profile[i] = new Profile;
QVERIFY(!profile[i]->asGroup());
}
// set properties with different values
profile[0]->setProperty(Profile::UseCustomCursorColor,true);
profile[1]->setProperty(Profile::UseCustomCursorColor,false);
profile[0]->setProperty(Profile::UseCustomCursorColor, true);
profile[1]->setProperty(Profile::UseCustomCursorColor, false);
// set properties with same values
for (int i=0;i<3;i++)
profile[i]->setProperty(Profile::HistorySize,1234);
for (int i = 0; i < 3; i++)
profile[i]->setProperty(Profile::HistorySize, 1234);
// create a group profile
ProfileGroup::Ptr group = ProfileGroup::Ptr(new ProfileGroup);
QVERIFY(group->asGroup());
for (int i=0;i<3;i++)
{
for (int i = 0; i < 3; i++) {
group->addProfile(profile[i]);
QVERIFY(group->profiles().contains(profile[i]));
}
group->updateValues();
// read and check properties from the group
QCOMPARE(group->property<int>(Profile::HistorySize),1234);
QCOMPARE(group->property<QVariant>(Profile::UseCustomCursorColor),QVariant());
QCOMPARE(group->property<int>(Profile::HistorySize), 1234);
QCOMPARE(group->property<QVariant>(Profile::UseCustomCursorColor), QVariant());
// set and test shareable properties in the group
group->setProperty(Profile::Command,"ssh");
group->setProperty(Profile::AntiAliasFonts,false);
group->setProperty(Profile::Command, "ssh");
group->setProperty(Profile::AntiAliasFonts, false);
QCOMPARE(profile[0]->property<QString>(Profile::Command),QString("ssh"));
QCOMPARE(profile[0]->property<QString>(Profile::Command), QString("ssh"));
QVERIFY(profile[1]->property<bool>(Profile::AntiAliasFonts) == false);
// set and test non-sharable properties in the group
// (should have no effect)
group->setProperty(Profile::Name,"NewName");
group->setProperty(Profile::Path,"NewPath");
group->setProperty(Profile::Name, "NewName");
group->setProperty(Profile::Path, "NewPath");
QVERIFY(profile[1]->property<QString>(Profile::Name) != "NewName");
QVERIFY(profile[2]->property<QString>(Profile::Path) != "NewPath");
@ -168,11 +166,11 @@ void ProfileTest::testProfileGroup()
group->updateValues();
// check that profile is no longer affected by group
group->setProperty(Profile::Command,"fish");
group->setProperty(Profile::Command, "fish");
QVERIFY(profile[0]->property<QString>(Profile::Command) != "fish");
}
QTEST_KDEMAIN_CORE( ProfileTest )
QTEST_KDEMAIN_CORE(ProfileTest)
#include "ProfileTest.moc"

@ -27,7 +27,7 @@ namespace Konsole
class ProfileTest : public QObject
{
Q_OBJECT
Q_OBJECT
private slots:
void testProfile();

@ -36,7 +36,7 @@ void SessionManagerTest::cleanup()
{
}
QTEST_KDEMAIN_CORE( SessionManagerTest )
QTEST_KDEMAIN_CORE(SessionManagerTest)
#include "SessionManagerTest.moc"

@ -27,7 +27,7 @@ namespace Konsole
class SessionManagerTest : public QObject
{
Q_OBJECT
Q_OBJECT
private slots:
void init();

Loading…
Cancel
Save