generic: purge most manual tests

Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
Ivailo Monev 2023-07-03 07:16:15 +03:00
parent a4986e43b8
commit 0ba740c6c5
45 changed files with 26 additions and 747 deletions

View file

@ -21,6 +21,7 @@
#ifndef PLACESPANEL_H #ifndef PLACESPANEL_H
#define PLACESPANEL_H #define PLACESPANEL_H
#include <QGraphicsSceneDragDropEvent>
#include <KUrl> #include <KUrl>
#include <panels/panel.h> #include <panels/panel.h>
@ -29,7 +30,6 @@ class PlacesItemEditDialog;
class PlacesItem; class PlacesItem;
class PlacesItemModel; class PlacesItemModel;
class PlacesView; class PlacesView;
#include <QGraphicsSceneDragDropEvent>
/** /**
* @brief Combines bookmarks and mounted devices as list. * @brief Combines bookmarks and mounted devices as list.

View file

@ -1,2 +1,23 @@
add_subdirectory(crashtest) set(backtraceparsertest_SRCS
add_subdirectory(backtraceparsertest) fakebacktracegenerator.cpp
backtraceparsertest.cpp
)
kde4_add_test(drkonqi-backtraceparsertest ${backtraceparsertest_SRCS})
target_link_libraries(drkonqi-backtraceparsertest
${QT_QTTEST_LIBRARY}
${QT_QTCORE_LIBRARY}
drkonqi_backtrace_parser
)
# create a link so that the data directory can be accessed from the build
# directory, where the test runs
if(NOT ${CMAKE_CURRENT_BINARY_DIR} EQUAL ${CMAKE_CURRENT_SOURCE_DIR})
add_custom_command(
TARGET drkonqi-backtraceparsertest POST_BUILD
COMMAND ${CMAKE_COMMAND} -E create_symlink
${CMAKE_CURRENT_SOURCE_DIR}/backtraceparsertest_data
backtraceparsertest_data
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
)
endif()

View file

@ -21,7 +21,7 @@
#include <QtCore/qsettings.h> #include <QtCore/qsettings.h>
#include "fakebacktracegenerator.h" #include "fakebacktracegenerator.h"
#include "../../parser/backtraceparser.h" #include "../parser/backtraceparser.h"
class BacktraceParserTest : public QObject class BacktraceParserTest : public QObject
{ {

View file

@ -1,30 +0,0 @@
set(backtraceparsertest_SRCS
fakebacktracegenerator.cpp
backtraceparsertest.cpp
)
kde4_add_test(drkonqi-backtraceparsertest ${backtraceparsertest_SRCS})
target_link_libraries(drkonqi-backtraceparsertest
${QT_QTTEST_LIBRARY}
${QT_QTCORE_LIBRARY}
drkonqi_backtrace_parser
)
set(backtraceparsertest_manual_SRCS
fakebacktracegenerator.cpp
backtraceparsertest_manual.cpp
)
kde4_add_manual_test(backtraceparsertest_manual ${backtraceparsertest_manual_SRCS})
target_link_libraries(backtraceparsertest_manual drkonqi_backtrace_parser)
# create a link so that the data directory can be accessed from the build
# directory, where the test runs
if(NOT ${CMAKE_CURRENT_BINARY_DIR} EQUAL ${CMAKE_CURRENT_SOURCE_DIR})
add_custom_command(
TARGET drkonqi-backtraceparsertest POST_BUILD
COMMAND ${CMAKE_COMMAND} -E create_symlink
${CMAKE_CURRENT_SOURCE_DIR}/backtraceparsertest_data
backtraceparsertest_data
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
)
endif()

View file

@ -1,63 +0,0 @@
/*
Copyright (C) 2010 George Kiagiadakis <kiagiadakis.george@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, see <http://www.gnu.org/licenses/>.
*/
#include "fakebacktracegenerator.h"
#include "../../parser/backtraceparser.h"
#include <QtCore/QFile>
#include <QtCore/QSharedPointer>
#include <QtCore/QTextStream>
#include <QtCore/qmetaobject.h>
#include <QtCore/QCoreApplication>
#include <KAboutData>
#include <KCmdLineOptions>
#include <KLocalizedString>
int main(int argc, char **argv)
{
KAboutData aboutData("backtraceparsertest_manual", 0,
ki18n("backtraceparsertest_manual"), "1.0");
KCmdLineArgs::init(argc, argv, &aboutData);
KCmdLineOptions options;
options.add("debugger <name>", ki18n("The debugger name passed to the parser factory"), "gdb");
options.add("+file", ki18n("A file containing the backtrace."));
KCmdLineArgs::addCmdLineOptions(options);
QCoreApplication app(KCmdLineArgs::qtArgc(), KCmdLineArgs::qtArgv());
QCoreApplication::setApplicationName(QLatin1String("backtraceparsertest_manual"));
KCmdLineArgs *args = KCmdLineArgs::parsedArgs();
QString debugger = args->getOption("debugger");
QString file = args->arg(0);
if (!QFile::exists(file)) {
QTextStream(stderr) << "The specified file does not exist" << endl;
return 1;
}
FakeBacktraceGenerator generator;
QSharedPointer<BacktraceParser> parser(BacktraceParser::newParser(debugger));
parser->connectToGenerator(&generator);
generator.sendData(file);
QMetaEnum metaUsefulness = BacktraceParser::staticMetaObject.enumerator(
BacktraceParser::staticMetaObject.indexOfEnumerator("Usefulness"));
QTextStream(stdout) << "Usefulness: " << metaUsefulness.valueToKey(parser->backtraceUsefulness()) << endl;
QStringList l = static_cast<QStringList>(parser->librariesWithMissingDebugSymbols().toList());
QTextStream(stdout) << "Missing dbgsym libs: " << l.join(" ") << endl;
return 0;
}

View file

@ -1,5 +0,0 @@
set(crashtest_SRCS crashtest.cpp )
kde4_add_manual_test(crashtest ${crashtest_SRCS})
target_link_libraries(crashtest KDE4::kdeui)

View file

@ -1,181 +0,0 @@
/*****************************************************************
* drkonqi - The KDE Crash Handler
*
* Copyright (C) 2000-2002 David Faure <faure@kde.org>
* Copyright (C) 2000-2002 Waldo Bastian <bastian@kde.org>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*****************************************************************/
// Let's crash.
#include <kapplication.h>
#include <kcrash.h>
#include <kaboutdata.h>
#include <kcmdlineargs.h>
#include <kdebug.h>
#include <KLocalizedString>
#include <QRunnable>
#include <QThreadPool>
#include <assert.h>
enum CrashType { Crash, Malloc, Div0, Assert, QAssert, Threads };
struct SomeStruct
{
int foo() { return ret; }
int ret;
};
void do_crash()
{
SomeStruct *obj = 0;
int ret = obj->foo();
printf("result = %d\n", ret);
}
void do_malloc()
{
delete (char*)0xdead;
}
void do_div0()
{
volatile int a = 99;
volatile int b = 10;
volatile int c = a / ( b - 10 );
printf("result = %d\n", c);
}
void do_assert()
{
assert(false);
}
void do_qassert()
{
Q_ASSERT(false);
}
class FooRunnable : public QRunnable
{
public:
FooRunnable(const QString &foostring);
void run() final;
private:
const QString m_foostring;
};
FooRunnable::FooRunnable(const QString &foostring)
: QRunnable(),
m_foostring(foostring)
{
}
void FooRunnable::run()
{
while ( m_foostring != "thread 4" ) {}
do_crash();
}
void do_threads()
{
QStringList foolist;
foolist << "thread 1" << "thread 2" << "thread 3" << "thread 4" << "thread 5";
QThreadPool::globalInstance()->setMaxThreadCount(5);
foreach (const QString &foostring, foolist) {
QThreadPool::globalInstance()->start(new FooRunnable(foostring));
}
}
void level4(int t)
{
if (t == Malloc)
do_malloc();
else if (t == Div0)
do_div0();
else if (t == Assert)
do_assert();
else if (t == QAssert)
do_qassert();
else if (t == Threads)
do_threads();
else
do_crash();
}
void level3(int t)
{
level4(t);
}
void level2(int t)
{
level3(t);
}
void level1(int t)
{
level2(t);
}
int main(int argc, char *argv[])
{
KAboutData aboutData("crashtest", 0, ki18n("Crash Test for DrKonqi"),
"1.1",
ki18n("Crash Test for DrKonqi"),
KAboutData::License_GPL,
ki18n("(c) 2000-2002 David Faure, Waldo Bastian"));
KCmdLineArgs::init(argc, argv, &aboutData);
KCmdLineOptions options;
options.add("autorestart", ki18n("Automatically restart"));
options.add("+crash|malloc|div0|assert|threads", ki18n("Type of crash."));
KCmdLineArgs::addCmdLineOptions(options);
KApplication app;
KCmdLineArgs *args = KCmdLineArgs::parsedArgs();
KCrash::CrashFlags flags;
if (args->isSet("autorestart"))
flags |= KCrash::AutoRestart;
KCrash::setFlags(flags);
kDebug() << flags;
QByteArray type = args->count() ? args->arg(0).toUtf8() : "";
int crashtype = Crash;
if (type == "malloc")
crashtype = Malloc;
else if (type == "div0")
crashtype = Div0;
else if (type == "assert")
crashtype = Assert;
else if (type == "qassert")
crashtype = QAssert;
else if (type == "threads")
crashtype = Threads;
level1(crashtype);
return app.exec();
}

View file

@ -1,7 +1,3 @@
if(ENABLE_TESTING)
add_subdirectory(tests)
endif()
########### next target ############### ########### next target ###############
set(kcm_icons_PART_SRCS set(kcm_icons_PART_SRCS

View file

@ -1,12 +0,0 @@
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/..)
########### next target ###############
set(testicons_SRCS
testicons.cpp
${CMAKE_CURRENT_SOURCE_DIR}/../icons.cpp
)
kde4_add_manual_test(testicons ${testicons_SRCS})
target_link_libraries(testicons KDE4::kdeui)

View file

@ -1,15 +0,0 @@
/* Test program for icons setup module. */
#include <QApplication>
#include <kcomponentdata.h>
#include "icons.h"
int main(int argc, char **argv)
{
QApplication app(argc, argv);
app.setApplicationName("testicons");
KComponentData componentData("testicons");
KIconConfig *w = new KIconConfig(componentData, 0L);
w->show();
return app.exec();
}

View file

@ -11,11 +11,6 @@ set(KONSOLE_TEST_LIBS
konsoleprivate konsoleprivate
) )
kde4_add_manual_test(PartManualTest PartManualTest.cpp)
target_link_libraries(PartManualTest
${KONSOLE_TEST_LIBS}
)
kde4_add_test(konsole-CharacterColorTest CharacterColorTest.cpp) kde4_add_test(konsole-CharacterColorTest CharacterColorTest.cpp)
target_link_libraries(konsole-CharacterColorTest ${KONSOLE_TEST_LIBS}) target_link_libraries(konsole-CharacterColorTest ${KONSOLE_TEST_LIBS})

View file

@ -1,140 +0,0 @@
/*
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 "PartManualTest.h"
// Qt
#include <QWidget>
#include <QLabel>
#include <QVBoxLayout>
#include <QMenuBar>
#include <QtGui/qevent.h>
#include <qtestkeyboard.h>
// System
#include <termios.h>
#include <sys/types.h>
// KDE
#include <KMenu>
#include <KPluginLoader>
#include <KPluginFactory>
#include <KService>
#include <KParts/Part>
#include <KPtyDevice>
#include <KDialog>
#include <KDebug>
#include <KMainWindow>
#include <qtest_kde.h>
// Konsole
#include "../Pty.h"
#include "../Session.h"
#include "../KeyboardTranslator.h"
using namespace Konsole;
void PartManualTest::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;
}
void PartManualTest::overrideShortcut(QKeyEvent* event, bool& override)
{
QVERIFY(override == true);
if (event->modifiers() == Qt::ControlModifier && event->key() == Qt::Key_S) {
_overrideCalled = true;
override = _override;
_shortcutEventLoop->exit();
}
}
void PartManualTest::shortcutTriggered()
{
_shortcutTriggered = true;
}
KParts::Part* PartManualTest::createPart()
{
KPluginFactory* factory = KPluginLoader("konsolepart").factory();
Q_ASSERT(factory);
KParts::Part* terminalPart = factory->create<KParts::Part>(this);
return terminalPart;
}
QTEST_KDEMAIN(PartManualTest , GUI)
#include "moc_PartManualTest.cpp"

View file

@ -1,59 +0,0 @@
/*
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 PARTMANUALTEST_H
#define PARTMANUALTEST_H
#include <QtCore/QEventLoop>
#include <kde_terminal_interface.h>
#include <KParts/Part>
#include <QKeyEvent>
#include <QEvent>
namespace Konsole
{
class PartManualTest : public QObject
{
Q_OBJECT
private slots:
void testShortcutOverride();
// marked as protected so they are not treated as test cases
protected slots:
void overrideShortcut(QKeyEvent* event, bool& override);
void shortcutTriggered();
private:
KParts::Part* createPart();
// variables for testShortcutOverride()
bool _shortcutTriggered;
bool _overrideCalled;
bool _override;
QEventLoop* _shortcutEventLoop;
};
}
#endif // PARTMANUALTEST_H

View file

@ -9,11 +9,7 @@ include_directories(
${CMAKE_BINARY_DIR}/libs/kworkspace ${CMAKE_BINARY_DIR}/libs/kworkspace
) )
add_subdirectory( kcm ) add_subdirectory(kcm)
if(ENABLE_TESTING)
add_subdirectory(tests)
endif()
check_library_exists(ICE _IceTransNoListen "" HAVE__ICETRANSNOLISTEN) check_library_exists(ICE _IceTransNoListen "" HAVE__ICETRANSNOLISTEN)
configure_file(config-ksmserver.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config-ksmserver.h) configure_file(config-ksmserver.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config-ksmserver.h)

View file

@ -1,18 +0,0 @@
include_directories( ${CMAKE_CURRENT_SOURCE_DIR}/..)
set(testsh_SRCS
test.cpp
${CMAKE_CURRENT_SOURCE_DIR}/../shutdowndlg.cpp
)
kde4_add_manual_test(testsh ${testsh_SRCS})
target_link_libraries(testsh
kworkspace
KDE4::kdeui
KDE4::solid
KDE4::kdeclarative
KDE4::plasma
${X11_X11_LIB}
${QT_QTDECLARATIVE_LIBRARY}
)

View file

@ -1,46 +0,0 @@
#include "shutdowndlg.h"
#include <kcmdlineargs.h>
#include <kaboutdata.h>
#include <kapplication.h>
#include <kiconloader.h>
#include <kworkspace/kworkspace.h>
#include <Plasma/Theme>
int main(int argc, char *argv[])
{
KAboutData about("kapptest", 0, ki18n("kapptest"), "version");
KCmdLineArgs::init(argc, argv, &about);
KCmdLineOptions options;
options.add("t");
options.add("type <name>", ki18n("The type of shutdown to emulate: Default, None, Reboot, Halt or Logout"), "None");
options.add("theme <name>", ki18n("Theme name. List with 'plasmoidviewer --list-themes'"));
KCmdLineArgs::addCmdLineOptions(options);
KCmdLineArgs *args = KCmdLineArgs::parsedArgs();
KApplication a;
KIconLoader::global()->addAppDir("ksmserver");
qAddPostRoutine(KSMShutdownFeedback::stop);
QString sdtypeOption = args->getOption("type").toLower();
if (args->isSet("theme")) {
Plasma::Theme::defaultTheme()->setUseGlobalSettings(false); //don't change every plasma theme!
Plasma::Theme::defaultTheme()->setThemeName(args->getOption("theme"));
}
KWorkSpace::ShutdownType sdtype = KWorkSpace::ShutdownTypeDefault;
if (sdtypeOption == "reboot") {
sdtype = KWorkSpace::ShutdownTypeReboot;
} else if (sdtypeOption == "halt") {
sdtype = KWorkSpace::ShutdownTypeHalt;
} else if (sdtypeOption == "logout") {
sdtype = KWorkSpace::ShutdownTypeNone;
}
(void)KSMShutdownDlg::confirmShutdown( true, true, sdtype, "default" );
/* (void)KSMShutdownDlg::confirmShutdown( false, false, sdtype ); */
return a.exec();
}

View file

@ -1,7 +1,3 @@
if(ENABLE_TESTING)
add_subdirectory(tests)
endif()
set(kuiserver_SRCS set(kuiserver_SRCS
main.cpp main.cpp
jobview.cpp jobview.cpp

View file

@ -1,8 +0,0 @@
########### next target ###############
set(kuiservertest_SRCS kuiservertest.cpp)
kde4_add_manual_test(kuiservertest ${kuiservertest_SRCS})
target_link_libraries(kuiservertest KDE4::kio)

View file

@ -1,96 +0,0 @@
/**
* This file is part of the KDE libraries
* Copyright (C) 2007 Rafael Fernández López <ereslibre@kde.org>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License version 2 as published by the Free Software Foundation.
*
* This library 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
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public License
* along with this library; see the file COPYING.LIB. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#include "kuiservertest.h"
#include <kio/jobuidelegate.h>
#include <QTimer>
#include <kapplication.h>
#include <kcmdlineargs.h>
#include <klocale.h>
#include <kio/jobclasses.h>
#include <kuiserverjobtracker.h>
KJobTest::KJobTest(int numberOfSeconds)
: KIO::Job(), timer(new QTimer(this)), clockTimer(new QTimer(this)),
seconds(numberOfSeconds), total(numberOfSeconds)
{
setCapabilities(KJob::NoCapabilities);
}
KJobTest::~KJobTest()
{
}
void KJobTest::start()
{
connect(timer, SIGNAL(timeout()), this,
SLOT(timerTimeout()));
connect(clockTimer, SIGNAL(timeout()), this,
SLOT(updateMessage()));
timer->setSingleShot(true);
timer->start(seconds * 1000);
updateMessage();
clockTimer->start(1000);
}
void KJobTest::timerTimeout()
{
clockTimer->stop();
emitResult();
QTimer::singleShot(0, QCoreApplication::instance(), SLOT(quit()));
}
void KJobTest::updateMessage()
{
emit infoMessage(this, i18n("Testing kuiserver (%1 seconds remaining)", seconds), i18n("Testing kuiserver (%1 seconds remaining)", seconds));
emitPercent(total - seconds, total);
seconds--;
}
bool KJobTest::doSuspend()
{
clockTimer->stop();
Job::doSuspend();
return true;
}
#include "moc_kuiservertest.cpp"
int main(int argc, char **argv)
{
KCmdLineArgs::init(argc, argv, "kjobtest", 0, ki18n("KJobTest"), "0.01", ki18n("A KJob tester"));
KApplication app;
KJobTest *myJob = new KJobTest(10 /* 10 seconds before it gets removed */);
myJob->setUiDelegate(new KIO::JobUiDelegate());
KIO::getJobTracker()->registerJob(myJob);
myJob->start();
return app.exec();
}

View file

@ -1,52 +0,0 @@
/**
* This file is part of the KDE libraries
* Copyright (C) 2007 Rafael Fernández López <ereslibre@kde.org>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License version 2 as published by the Free Software Foundation.
*
* This library 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
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public License
* along with this library; see the file COPYING.LIB. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#ifndef __KJOBTEST_H__
#define __KJOBTEST_H__
#include <kjob.h>
#include <kjobuidelegate.h>
#include <kio/jobclasses.h>
#include <QTimer>
class KJobTest
: public KIO::Job
{
Q_OBJECT
public:
KJobTest(int numberOfSeconds = 5);
~KJobTest();
void start();
private Q_SLOTS:
void timerTimeout();
void updateMessage();
protected:
bool doSuspend();
private:
QTimer *timer, *clockTimer;
int seconds, total;
};
#endif // __KJOBTEST_H__