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

KUnitTest

  • sources
  • kde-4.12
  • kdelibs
  • kde3support
  • kunittest
tester.cpp
Go to the documentation of this file.
1 
26 #include "tester.h"
27 
28 #include <iostream>
29 using namespace std;
30 
31 #include <QtCore/QMetaEnum>
32 #include <QtCore/QRect>
33 #include <QtCore/QVector>
34 
35 namespace 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 
102 QTextStream& operator<<( QTextStream& str, const QRect& r ) {
103  str << "[" << r.x() << "," << r.y() << " - " << r.width() << "x" << r.height() << "]";
104  return str;
105 }
106 
107 QTextStream& operator<<( QTextStream& str, const QPoint& r ) {
108  str << "(" << r.x() << "," << r.y() << ")";
109  return str;
110 }
111 
112 QTextStream& operator<<( QTextStream& str, const QSize& r ) {
113  str << "[" << r.width() << "x" << r.height() << "]";
114  return str;
115 }
116 
117 #include "tester.moc"
KUnitTest::Tester
Definition: tester.h:516
KUnitTest::TestResults::clear
virtual void clear()
Definition: tester.h:437
tester.h
QString
KUnitTest::SlotTester::invoke
void invoke()
KUnitTest::SlotTester::~SlotTester
virtual ~SlotTester()
Definition: tester.cpp:43
KUnitTest::TestResults
Definition: tester.h:426
QPoint
QRect
QSize
KUnitTest::Tester::m_results
TestResults * m_results
Definition: tester.h:671
KUnitTest::SlotTester::results
virtual TestResults * results() const
Definition: tester.h:692
operator<<
QTextStream & operator<<(QTextStream &str, const QRect &r)
Definition: tester.cpp:102
KUnitTest::SlotTester::allTests
void allTests()
Definition: tester.cpp:57
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:52:07 by doxygen 1.8.7 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 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
  • kjsembed
  •   WTF
  • KNewStuff
  • KParts
  • KPty
  • Kross
  • KUnitConversion
  • KUtils
  • Nepomuk
  • Nepomuk-Core
  • 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