• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdelibs API Reference
  • KDE Home
  • Contact Us
 

KDECore

  • sources
  • kde-4.14
  • kdelibs
  • kdecore
  • util
Namespaces | Macros | Enumerations | Functions
qtest_kde.h File Reference
#include <QtTest/QtTest>
#include <stdlib.h>
#include <assert.h>
#include <kaboutdata.h>
#include <kcmdlineargs.h>
#include <kcomponentdata.h>
#include <kglobal.h>
#include <kurl.h>
#include <QtGui/QApplication>
#include <QtCore/QEventLoop>
#include <QtTest/QSignalSpy>
Include dependency graph for qtest_kde.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Namespaces

 QTest
 

Macros

#define QTEST_KDEMAIN(TestObject, flags)   QTEST_KDEMAIN_WITH_COMPONENTNAME(TestObject, flags, "qttest")
 
#define QTEST_KDEMAIN_CORE(TestObject)   QTEST_KDEMAIN_CORE_WITH_COMPONENTNAME(TestObject, "qttest")
 
#define QTEST_KDEMAIN_CORE_WITH_COMPONENTNAME(TestObject, componentName)
 
#define QTEST_KDEMAIN_WITH_COMPONENTNAME(TestObject, flags, componentName)
 

Enumerations

enum  KDEMainFlag { NoGUI = 0, GUI = 1 }
 

Functions

bool QTest::kWaitForSignal (QObject *obj, const char *signal, int timeout=0)
 

Macro Definition Documentation

#define QTEST_KDEMAIN (   TestObject,
  flags 
)    QTEST_KDEMAIN_WITH_COMPONENTNAME(TestObject, flags, "qttest")

KDE Replacement for QTEST_MAIN from QTestLib.

This macro should be used for classes that need a KComponentData. So instead of writing QTEST_MAIN( TestClass ) you write QTEST_KDEMAIN( TestClass, GUI ).

Parameters
TestObjectThe class you use for testing.
flagsone of KDEMainFlag. This is passed to the QApplication constructor.
See also
KDEMainFlag
QTestLib

Definition at line 104 of file qtest_kde.h.

#define QTEST_KDEMAIN_CORE (   TestObject)    QTEST_KDEMAIN_CORE_WITH_COMPONENTNAME(TestObject, "qttest")

KDE Replacement for QTEST_MAIN from QTestLib, for non-gui code.

This macro should be used for classes that need a KComponentData. So instead of writing QTEST_MAIN( TestClass ) you write QTEST_KDEMAIN_CORE( TestClass ).

Parameters
TestObjectThe class you use for testing.
See also
KDEMainFlag
QTestLib

Definition at line 153 of file qtest_kde.h.

#define QTEST_KDEMAIN_CORE_WITH_COMPONENTNAME (   TestObject,
  componentName 
)
Value:
int main(int argc, char *argv[]) \
{ \
setenv("LC_ALL", "C", 1); \
assert( !QDir::homePath().isEmpty() ); \
setenv("KDEHOME", QFile::encodeName( QDir::homePath() + QString::fromLatin1("/.kde-unit-test" )), 1); \
setenv("XDG_DATA_HOME", QFile::encodeName( QDir::homePath() + QString::fromLatin1("/.kde-unit-test/xdg/local") ), 1); \
setenv("XDG_CONFIG_HOME", QFile::encodeName( QDir::homePath() + QString::fromLatin1("/.kde-unit-test/xdg/config") ), 1); \
setenv("KDE_SKIP_KDERC", "1", 1); \
unsetenv("KDE_COLOR_DEBUG"); \
QFile::remove(QDir::homePath() + QString::fromLatin1("/.kde-unit-test/share/config/qttestrc")); \
KAboutData aboutData( QByteArray(componentName), QByteArray(), ki18n("KDE Test Program"), QByteArray("version") ); \
KComponentData cData(&aboutData); \
QCoreApplication app( argc, argv ); \
app.setApplicationName( QLatin1String("qttest") ); \
qRegisterMetaType<KUrl>(); /*as done by kapplication*/ \
qRegisterMetaType<KUrl::List>(); \
TestObject tc; \
KGlobal::ref(); /* don't quit qeventloop after closing a mainwindow */ \
return QTest::qExec( &tc, argc, argv ); \
}
QByteArray
QFile::remove
bool remove()
ki18n
KLocalizedString ki18n(const char *msg)
Creates localized string from a given message.
Definition: klocalizedstring.cpp:924
main
int main(int argc, char **argv)
Definition: policy-gen.cpp:35
QDir::homePath
QString homePath()
KGlobal::ref
void ref()
Tells KGlobal about one more operations that should be finished before the application exits...
Definition: kglobal.cpp:321
QTest::qExec
int qExec(QObject *testObject, int argc, char **argv)
QLatin1String
QString::fromLatin1
QString fromLatin1(const char *str, int size)
QFile::encodeName
QByteArray encodeName(const QString &fileName)

KDE Replacement for QTEST_MAIN from QTestLib, for non-gui code.

This macro should be used for classes that need a KComponentData. So instead of writing QTEST_MAIN( TestClass ) you write QTEST_KDEMAIN_CORE( TestClass ).

Parameters
TestObjectThe class you use for testing.
See also
KDEMainFlag
QTestLib
Since
4.3

Definition at line 119 of file qtest_kde.h.

#define QTEST_KDEMAIN_WITH_COMPONENTNAME (   TestObject,
  flags,
  componentName 
)
Value:
int main(int argc, char *argv[]) \
{ \
setenv("LC_ALL", "C", 1); \
assert( !QDir::homePath().isEmpty() ); \
setenv("KDEHOME", QFile::encodeName( QDir::homePath() + QString::fromLatin1("/.kde-unit-test") ), 1); \
setenv("XDG_DATA_HOME", QFile::encodeName( QDir::homePath() + QString::fromLatin1("/.kde-unit-test/xdg/local") ), 1); \
setenv("XDG_CONFIG_HOME", QFile::encodeName( QDir::homePath() + QString::fromLatin1("/.kde-unit-test/xdg/config") ), 1); \
setenv("KDE_SKIP_KDERC", "1", 1); \
unsetenv("KDE_COLOR_DEBUG"); \
QFile::remove(QDir::homePath() + QString::fromLatin1("/.kde-unit-test/share/config/qttestrc")); \
KAboutData aboutData( QByteArray(componentName), QByteArray(), ki18n("KDE Test Program"), QByteArray("version") ); \
KDEMainFlags mainFlags = flags; \
KComponentData cData(&aboutData); \
QApplication app( argc, argv, (mainFlags & GUI) != 0 ); \
app.setApplicationName( QLatin1String("qttest") ); \
qRegisterMetaType<KUrl>(); /*as done by kapplication*/ \
qRegisterMetaType<KUrl::List>(); \
TestObject tc; \
KGlobal::ref(); /* don't quit qeventloop after closing a mainwindow */ \
return QTest::qExec( &tc, argc, argv ); \
}
QByteArray
QFile::remove
bool remove()
ki18n
KLocalizedString ki18n(const char *msg)
Creates localized string from a given message.
Definition: klocalizedstring.cpp:924
main
int main(int argc, char **argv)
Definition: policy-gen.cpp:35
QDir::homePath
QString homePath()
KGlobal::ref
void ref()
Tells KGlobal about one more operations that should be finished before the application exits...
Definition: kglobal.cpp:321
GUI
Definition: qtest_kde.h:50
QTest::qExec
int qExec(QObject *testObject, int argc, char **argv)
QLatin1String
QString::fromLatin1
QString fromLatin1(const char *str, int size)
QFile::encodeName
QByteArray encodeName(const QString &fileName)

QTEST_KDEMAIN variant with additional argument for the main component name.

This variant is useful for testing application classes which rely on the main component having a specific name (for instance to find xmlgui .rc files).

This variant should not be needed in kdelibs's own unit tests.

Parameters
TestObjectThe class you use for testing.
flagsone of KDEMainFlag. This is passed to the QApplication constructor.
componentNamethe name that will be given to the main component data.
See also
KDEMainFlag
QTestLib

Definition at line 68 of file qtest_kde.h.

Enumeration Type Documentation

enum KDEMainFlag
Enumerator
NoGUI 
GUI 

Definition at line 50 of file qtest_kde.h.

This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:22:12 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

KDECore

Skip menu "KDECore"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Modules
  • Related Pages

kdelibs API Reference

Skip menu "kdelibs API Reference"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDEWebKit
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • kio
  • KIOSlave
  • KJS
  •   KJS-API
  •   WTF
  • kjsembed
  • KNewStuff
  • KParts
  • KPty
  • Kross
  • KUnitConversion
  • KUtils
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal