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

KUnitTest

  • kde3support
  • kunittest
tester.cpp
Go to the documentation of this file.
1
26#include "tester.h"
27
28#include <iostream>
29using namespace std;
30
31#include <QtCore/QMetaEnum>
32#include <QtCore/QRect>
33#include <QtCore/QVector>
34
35namespace KUnitTest
36{
37 SlotTester::SlotTester() : Tester()
38 {
39 m_total = m_results;
40 }
41
42
43 SlotTester::~SlotTester()
44 {
45 qDeleteAll( m_resultsList );
46 }
47
48
49 void SlotTester::invokeMember(const QString &str)
50 {
51 QString slotname = QString::number(QSLOT_CODE) + str;
52 connect(this, SIGNAL(invoke()), this, slotname.toLatin1().constData());
53 emit invoke();
54 disconnect(this, SIGNAL(invoke()), this, slotname.toLatin1().constData());
55 }
56
57 void SlotTester::allTests()
58 {
59 QVector<QByteArray> allSlots;
60 const int methodCount = metaObject()->methodCount();
61 const int methodOffset = metaObject()->methodOffset();
62 allSlots.reserve( methodCount );
63 for ( int i=0 ; i < methodCount; ++i )
64 {
65 QMetaMethod method = metaObject()->method( methodOffset + i );
66 if ( method.methodType() == QMetaMethod::Slot )
67 allSlots.append( method.signature() );
68 }
69
70 if ( allSlots.contains("setUp()") )
71 invokeMember("setUp()");
72
73 foreach ( const QByteArray &sl, allSlots )
74 {
75 if ( sl.startsWith("test") )
76 {
77 m_results = results(sl);
78 Q_ASSERT( m_results );
79 m_results->clear();
80
81 cout << "KUnitTest_Debug_BeginSlot[" << sl.data() << "]" << endl;
82 invokeMember(sl);
83 cout << "KUnitTest_Debug_EndSlot[" << sl.data() << "]" << endl;
84 }
85 }
86
87 if ( allSlots.contains("tearDown()") )
88 invokeMember("tearDown()");
89
90 m_total->clear();
91 }
92
93 TestResults *SlotTester::results(const char *sl)
94 {
95 if ( !m_resultsList.contains(sl) )
96 m_resultsList.insert(sl, new TestResults());
97
98 return m_resultsList[sl];
99 }
100}
101
102QTextStream& operator<<( QTextStream& str, const QRect& r ) {
103 str << "[" << r.x() << "," << r.y() << " - " << r.width() << "x" << r.height() << "]";
104 return str;
105}
106
107QTextStream& operator<<( QTextStream& str, const QPoint& r ) {
108 str << "(" << r.x() << "," << r.y() << ")";
109 return str;
110}
111
112QTextStream& operator<<( QTextStream& str, const QSize& r ) {
113 str << "[" << r.width() << "x" << r.height() << "]";
114 return str;
115}
116
117#include "tester.moc"
KUnitTest::SlotTester::allTests
void allTests()
Definition: tester.cpp:57
KUnitTest::SlotTester::results
virtual TestResults * results() const
Definition: tester.h:692
KUnitTest::SlotTester::SlotTester
SlotTester()
Definition: tester.cpp:37
KUnitTest::SlotTester::~SlotTester
virtual ~SlotTester()
Definition: tester.cpp:43
KUnitTest::SlotTester::invoke
void invoke()
KUnitTest::TestResults
Definition: tester.h:427
KUnitTest::TestResults::clear
virtual void clear()
Definition: tester.h:437
KUnitTest::Tester
Definition: tester.h:517
KUnitTest::Tester::m_results
TestResults * m_results
Definition: tester.h:671
KUnitTest
Copyright (C) 2005 Jeroen Wijnhout Jeroen.Wijnhout@kdemail.net
Definition: module.h:35
operator<<
QTextStream & operator<<(QTextStream &str, const QRect &r)
Definition: tester.cpp:102
tester.h
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Mon Feb 20 2023 00:00:00 by doxygen 1.9.6 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

KUnitTest

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

kdelibs-4.14.38 API Reference

Skip menu "kdelibs-4.14.38 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
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