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

KDECore

qtest_kde.h File Reference

#include <QtTest/QtTest>
#include <stdlib.h>
#include <kaboutdata.h>
#include <kcmdlineargs.h>
#include <kcomponentdata.h>
#include <kurl.h>
#include <QtGui/QApplication>
#include <QtCore/QEventLoop>
#include <QtTest/QSignalSpy>

Include dependency graph for qtest_kde.h:

Go to the source code of this file.


Namespaces

namespace  QTest

Defines

#define QTEST_KDEMAIN(TestObject, flags)   QTEST_KDEMAIN_WITH_COMPONENTNAME(TestObject, flags, "qttest")
#define QTEST_KDEMAIN_CORE(TestObject)
#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)

Define 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:
TestObject The class you use for testing.
flags one of KDEMainFlag. This is passed to the QApplication constructor.
See also:
KDEMainFlag

QTestLib

Definition at line 109 of file qtest_kde.h.

#define QTEST_KDEMAIN_CORE ( TestObject   ) 

Value:

int main(int argc, char *argv[]) \
{ \
    setenv("LC_ALL", "C", 1); \
    setenv("KDEHOME", QFile::encodeName( QDir::homePath() + "/.kde-unit-test" ), 1); \
    setenv("XDG_DATA_HOME", QFile::encodeName( QDir::homePath() + "/.kde-unit-test/xdg/local" ), 1); \
    setenv("XDG_CONFIG_HOME", QFile::encodeName( QDir::homePath() + "/.kde-unit-test/xdg/config" ), 1); \
    unsetenv("KDE_COLOR_DEBUG"); \
    KAboutData aboutData( QByteArray("qttest"), QByteArray(), ki18n("KDE Test Program"), QByteArray("version") );  \
    KComponentData cData(&aboutData); \
    QCoreApplication app( argc, argv ); \
    app.setApplicationName( "qttest" ); \
    qRegisterMetaType<KUrl>(); /*as done by kapplication*/ \
    qRegisterMetaType<KUrl::List>(); \
    TestObject tc; \
    return QTest::qExec( &tc, argc, argv ); \
}
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:
TestObject The class you use for testing.
See also:
KDEMainFlag

QTestLib

Definition at line 123 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); \
    setenv("KDEHOME", QFile::encodeName( QDir::homePath() + "/.kde-unit-test" ), 1); \
    setenv("XDG_DATA_HOME", QFile::encodeName( QDir::homePath() + "/.kde-unit-test/xdg/local" ), 1); \
    setenv("XDG_CONFIG_HOME", QFile::encodeName( QDir::homePath() + "/.kde-unit-test/xdg/config" ), 1); \
    unsetenv("KDE_COLOR_DEBUG"); \
    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( "qttest" ); \
    qRegisterMetaType<KUrl>(); /*as done by kapplication*/ \
    qRegisterMetaType<KUrl::List>(); \
    TestObject tc; \
    return QTest::qExec( &tc, argc, argv ); \
}
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:
TestObject The class you use for testing.
flags one of KDEMainFlag. This is passed to the QApplication constructor.
componentName the name that will be given to the main component data.
See also:
KDEMainFlag

QTestLib

Definition at line 77 of file qtest_kde.h.


Enumeration Type Documentation

enum KDEMainFlag

Enumerator:
NoGUI 
GUI 

Definition at line 59 of file qtest_kde.h.

KDECore

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

kdelibs

Skip menu "kdelibs"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • Kate
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • KIO
  • KIOSlave
  • KJS
  •   KJS-API
  •   WTF
  • kjsembed
  • KNewStuff
  • KParts
  • Kross
  • KUtils
  • Nepomuk
  • Solid
  • Sonnet
  • ThreadWeaver
Generated for kdelibs by doxygen 1.5.4
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal