Hi All,
I want to test a http application using QTest, my purpose is to
get contents from a url ,and check whether the content is as expected.
the code something like:
{
Q_OBJECT
private slots:
void testGet();
void compareConfig();
private:
CMyhttp *_myhttp;
};
void initTestCase()
{
_myhttp = new CMyhttp ;
}
void testGet()
{
_myhttp->get("some url");
//here I need to wait until the contents returned from web server,
//but it seemed that qtest lib will not wait
connect(_myhttp ,SIGNAL(finished()),this,SLOT(compareConfig()));
}
void compareConfig()
{
QCOMPARE
(
_myhttp.content = "content expected ..."
)
}
class testHttp : public QObject
{
Q_OBJECT
private slots:
void testGet();
void compareConfig();
private:
CMyhttp *_myhttp;
};
void initTestCase()
{
_myhttp = new CMyhttp ;
}
void testGet()
{
_myhttp->get("some url");
//here I need to wait until the contents returned from web server,
//but it seemed that qtest lib will not wait
connect(_myhttp ,SIGNAL(finished()),this,SLOT(compareConfig()));
}
void compareConfig()
{
QCOMPARE
(
_myhttp.content = "content expected ..."
)
}
To copy to clipboard, switch view to plain text mode
Any ideas about it?
Thanks advance for your help.
Best regards,
hb
Bookmarks