Skip to content

Commit

Permalink
Move test function needed only in one file out of the common.cpp
Browse files Browse the repository at this point in the history
  • Loading branch information
pvuorela committed Mar 19, 2021
1 parent 6a18c1c commit 1cd0e4e
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 13 deletions.
11 changes: 0 additions & 11 deletions tests/common.cpp
Expand Up @@ -530,17 +530,6 @@ bool waitSignal(QSignalSpy &spy, int msec)
return !spy.isEmpty();
}

void waitWithDeletes(int msec)
{
QTime timer;
timer.start();
while (timer.elapsed() < msec) {
QCoreApplication::sendPostedEvents();
QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete);
QCoreApplication::processEvents();
}
}

void summarizeResults(const QString &className, QList<int> &times, QFile *logFile, int testSecs)
{
int sum = 0;
Expand Down
2 changes: 0 additions & 2 deletions tests/common.h
Expand Up @@ -93,8 +93,6 @@ bool compareEvents(Event &e1, Event &e2);
void deleteAll();
QString randomMessage(int words);
bool waitSignal(QSignalSpy &spy, int msec = WAIT_SIGNAL_TIMEOUT);
// wait and allow deferred deletes to be processed (http://bugreports.qt.nokia.com/browse/QTBUG-12575)
void waitWithDeletes(int msec = WAIT_SIGNAL_TIMEOUT);
void summarizeResults(const QString &className, QList<int> &times, QFile *logFile, int testSecs);

#endif
13 changes: 13 additions & 0 deletions tests/mem_eventmodel/mem_eventmodel.cpp
Expand Up @@ -21,6 +21,7 @@
******************************************************************************/

#include <QtTest/QtTest>
#include <QTime>
#include <time.h>
#include <malloc.h>
#include "eventmodel.h"
Expand All @@ -38,6 +39,18 @@ Group group;

#define MALLINFO_DUMP(s) {struct mallinfo m = mallinfo();qDebug() << "MALLINFO" << (s) << m.arena << m.uordblks << m.fordblks;}

static void waitWithDeletes(int msec)
{
QTime timer;
timer.start();
while (timer.elapsed() < msec) {
QCoreApplication::sendPostedEvents();
QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete);
QCoreApplication::processEvents();
}
}


void MemEventModelTest::initTestCase()
{
initTestDatabase();
Expand Down

0 comments on commit 1cd0e4e

Please sign in to comment.