mismael85
20th November 2010, 17:34
Hello everybody,
I writing my first Unit test application but there are problems when using Signals and slots.
slots never been called. and also is it possible to test a class inherits QThread.
Here are my code sample
TestSearchEngine::TestSearchEngine()
{
m_pSearchEngine = new SearchEngine();
connect(m_pSearchEngine, SIGNAL(resultsDetected(int)), this, SLOT(onSearchResultDetected(int)));
}
void TestSearchEngine::testSearch()
{
QStringList searchWords;
searchWords <<tr("sampleword");
QList<int> booksId;
booksId << 11430;
QBENCHMARK{
m_pSearchEngine->search(searchWords, booksId);}
}
void TestSearchEngine::onSearchResultDetected(int count)
{
QCOMPARE(count, 3075 );
testSearchResult(1);
}
void TestSearchEngine::testSearchResult(int index)
{
QBENCHMARK{
m_pSearchEngine->searchResult(index);}
}
Note that m_pSearchEngine is an object of a class inherits QThread and it starts the thread when calling search function.
Thank you
I writing my first Unit test application but there are problems when using Signals and slots.
slots never been called. and also is it possible to test a class inherits QThread.
Here are my code sample
TestSearchEngine::TestSearchEngine()
{
m_pSearchEngine = new SearchEngine();
connect(m_pSearchEngine, SIGNAL(resultsDetected(int)), this, SLOT(onSearchResultDetected(int)));
}
void TestSearchEngine::testSearch()
{
QStringList searchWords;
searchWords <<tr("sampleword");
QList<int> booksId;
booksId << 11430;
QBENCHMARK{
m_pSearchEngine->search(searchWords, booksId);}
}
void TestSearchEngine::onSearchResultDetected(int count)
{
QCOMPARE(count, 3075 );
testSearchResult(1);
}
void TestSearchEngine::testSearchResult(int index)
{
QBENCHMARK{
m_pSearchEngine->searchResult(index);}
}
Note that m_pSearchEngine is an object of a class inherits QThread and it starts the thread when calling search function.
Thank you